From: Fangrui Song Date: Fri, 16 Dec 2022 20:24:35 +0000 (+0000) Subject: [mlir] Drop uses of operator<<(raw_ostream &OS, const Optional &O) X-Git-Tag: upstream/17.0.6~23501 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bef481df8b10e30c8b20ee9a9d622e24688b8411;p=platform%2Fupstream%2Fllvm.git [mlir] Drop uses of operator<<(raw_ostream &OS, const Optional &O) --- diff --git a/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h index 70a579e..f66ff37 100644 --- a/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h +++ b/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h @@ -30,7 +30,7 @@ public: static IntegerValueRange getMaxRange(Value value); /// Create an integer value range lattice value. - IntegerValueRange(Optional value = std::nullopt) + IntegerValueRange(std::optional value = std::nullopt) : value(std::move(value)) {} /// Whether the range is uninitialized. This happens when the state hasn't @@ -63,7 +63,7 @@ public: private: /// The known integer value range. - Optional value; + std::optional value; }; /// This lattice element represents the integer value range of an SSA value. diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index 7790f96..0743e37 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -89,7 +89,7 @@ public: /// Return the root node that this pattern matches. Patterns that can match /// multiple root types return std::nullopt. - Optional getRootKind() const { + std::optional getRootKind() const { if (rootKind == RootKind::OperationName) return OperationName::getFromOpaquePointer(rootValue); return std::nullopt; diff --git a/mlir/include/mlir/Pass/PassOptions.h b/mlir/include/mlir/Pass/PassOptions.h index d32c3de..6717a35 100644 --- a/mlir/include/mlir/Pass/PassOptions.h +++ b/mlir/include/mlir/Pass/PassOptions.h @@ -118,7 +118,7 @@ private: using llvm::cl::parser::parser; /// Returns an argument name that maps to the specified value. - Optional findArgStrForValue(const DataType &value) { + std::optional findArgStrForValue(const DataType &value) { for (auto &it : this->Values) if (it.V.compare(value)) return it.Name; @@ -130,8 +130,8 @@ private: template static void printValue(raw_ostream &os, GenericOptionParser &parser, const DataT &value) { - if (Optional argStr = parser.findArgStrForValue(value)) - os << argStr; + if (std::optional argStr = parser.findArgStrForValue(value)) + os << *argStr; else llvm_unreachable("unknown data value for option"); } diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp index 3341b5e..2dfd1b7 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp @@ -327,7 +327,7 @@ static void printMemoryAccessAttribute( if (auto alignment = (alignmentAttrValue ? alignmentAttrValue : memoryOp.getAlignment())) { elidedAttrs.push_back(kAlignmentAttrName); - printer << ", " << alignment; + printer << ", " << *alignment; } } printer << "]"; @@ -360,7 +360,7 @@ static void printSourceMemoryAccessAttribute( if (auto alignment = (alignmentAttrValue ? alignmentAttrValue : memoryOp.getAlignment())) { elidedAttrs.push_back(kSourceAlignmentAttrName); - printer << ", " << alignment; + printer << ", " << *alignment; } } printer << "]"; diff --git a/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp b/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp index 7b83d10..fc6cc96 100644 --- a/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp +++ b/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp @@ -100,7 +100,7 @@ FrozenRewritePatternSet::FrozenRewritePatternSet( continue; } - if (Optional rootName = pat->getRootKind()) { + if (std::optional rootName = pat->getRootKind()) { impl->nativeOpSpecificPatternMap[*rootName].push_back(pat.get()); impl->nativeOpSpecificPatternList.push_back(std::move(pat)); continue; diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp index 84759aa..f9f7ae7 100644 --- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp +++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp @@ -553,7 +553,7 @@ PDLDocument::buildHoverForCoreConstraint(const ast::CoreConstraintDecl *decl, .Case([&](const ast::OpConstraintDecl *opCst) { hoverOS << "Op"; if (Optional name = opCst->getName()) - hoverOS << "<" << name << ">"; + hoverOS << "<" << *name << ">"; }) .Case([&](const ast::TypeConstraintDecl *) { hoverOS << "Type"; }) .Case([&](const ast::TypeRangeConstraintDecl *) { diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp index 790810b..5c795f9 100644 --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -382,8 +382,8 @@ static std::string getNodeName(CallOpInterface op) { /// Return true if the specified `inlineHistoryID` indicates an inline history /// that already includes `node`. static bool inlineHistoryIncludes( - CallGraphNode *node, Optional inlineHistoryID, - MutableArrayRef>> + CallGraphNode *node, std::optional inlineHistoryID, + MutableArrayRef>> inlineHistory) { while (inlineHistoryID.has_value()) { assert(inlineHistoryID.value() < inlineHistory.size() && @@ -488,7 +488,7 @@ static LogicalResult inlineCallsInSCC(Inliner &inliner, CGUseList &useList, // When inlining a callee produces new call sites, we want to keep track of // the fact that they were inlined from the callee. This allows us to avoid // infinite inlining. - using InlineHistoryT = Optional; + using InlineHistoryT = std::optional; SmallVector, 8> inlineHistory; std::vector callHistory(calls.size(), InlineHistoryT{}); diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 2fb3422..795293b 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -2146,7 +2146,7 @@ void OperationLegalizer::buildLegalizationGraph( // Build the mapping from operations to the parent ops that may generate them. applicator.walkAllPatterns([&](const Pattern &pattern) { - Optional root = pattern.getRootKind(); + std::optional root = pattern.getRootKind(); // If the pattern has no specific root, we can't analyze the relationship // between the root op and generated operations. Given that, add all such @@ -2228,7 +2228,7 @@ void OperationLegalizer::computeLegalizationGraphBenefit( // decreasing benefit. applicator.applyCostModel([&](const Pattern &pattern) { ArrayRef orderedPatternList; - if (Optional rootName = pattern.getRootKind()) + if (std::optional rootName = pattern.getRootKind()) orderedPatternList = legalizerPatterns[*rootName]; else orderedPatternList = anyOpLegalizerPatterns; diff --git a/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp b/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp index 9e81b85..d4f03ec 100644 --- a/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp +++ b/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp @@ -21,7 +21,7 @@ namespace { class UnderlyingValue { public: /// Create an underlying value state with a known underlying value. - explicit UnderlyingValue(Optional underlyingValue = std::nullopt) + explicit UnderlyingValue(std::optional underlyingValue = std::nullopt) : underlyingValue(underlyingValue) {} /// Whether the state is uninitialized. @@ -54,7 +54,7 @@ public: void print(raw_ostream &os) const { os << underlyingValue; } private: - Optional underlyingValue; + std::optional underlyingValue; }; /// This lattice represents, for a given memory resource, the potential last diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp index f9b8389..cfa1880 100644 --- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp +++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp @@ -1145,7 +1145,7 @@ if ({1}Iter != attrs.end()) {{ Optional cppValue = generateExpression(assignment->value); if (!cppValue) return failure(); - stmts.push_back(llvm::formatv("yields.push_back({0});", cppValue)); + stmts.push_back(llvm::formatv("yields.push_back({0});", *cppValue)); } if (generatedAssignmentCount != assignments.size())