diff options
Diffstat (limited to 'mlir/test/lib')
10 files changed, 48 insertions, 44 deletions
diff --git a/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp b/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp index e79e690cc5c3..f88544032c21 100644 --- a/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp +++ b/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp @@ -102,7 +102,7 @@ public: /// Get the last modifications of a value. Returns none if the last /// modifications are not known. - Optional<ArrayRef<Operation *>> getLastModifiers(Value value) const { + std::optional<ArrayRef<Operation *>> getLastModifiers(Value value) const { auto it = lastMods.find(value); if (it == lastMods.end()) return {}; @@ -260,7 +260,7 @@ struct TestLastModifiedPass return solver.lookupState<UnderlyingValueLattice>(value); }); assert(value && "expected an underlying value"); - if (Optional<ArrayRef<Operation *>> lastMod = + if (std::optional<ArrayRef<Operation *>> lastMod = lastMods->getLastModifiers(value)) { for (Operation *lastModifier : *lastMod) { if (auto tagName = diff --git a/mlir/test/lib/Analysis/TestDataFlowFramework.cpp b/mlir/test/lib/Analysis/TestDataFlowFramework.cpp index ecacc36c479f..00449249a708 100644 --- a/mlir/test/lib/Analysis/TestDataFlowFramework.cpp +++ b/mlir/test/lib/Analysis/TestDataFlowFramework.cpp @@ -62,7 +62,7 @@ public: private: /// An optional integer value. - Optional<uint64_t> state; + std::optional<uint64_t> state; }; /// This analysis computes `FooState` across operations and control-flow edges. diff --git a/mlir/test/lib/Dialect/Shape/TestShapeMappingAnalysis.cpp b/mlir/test/lib/Dialect/Shape/TestShapeMappingAnalysis.cpp index d3c5fa4e252f..391cb50c4bd4 100644 --- a/mlir/test/lib/Dialect/Shape/TestShapeMappingAnalysis.cpp +++ b/mlir/test/lib/Dialect/Shape/TestShapeMappingAnalysis.cpp @@ -24,7 +24,7 @@ struct TestShapeMappingPass return "Print the contents of a constructed shape mapping information."; } void runOnOperation() override { - llvm::Optional<std::reference_wrapper<shape::ShapeMappingAnalysis>> + std::optional<std::reference_wrapper<shape::ShapeMappingAnalysis>> maybeAnalysis = getCachedAnalysis<shape::ShapeMappingAnalysis>(); if (maybeAnalysis.has_value()) maybeAnalysis->get().print(llvm::errs()); diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 56e6bd22b945..e62d5a81c84d 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -956,7 +956,7 @@ ParseResult PrettyPrintedRegionOp::parse(OpAsmParser &parser, StringAttr innerOpName = parseOpNameInfo->getIdentifier(); FunctionType opFntype; - Optional<Location> explicitLoc; + std::optional<Location> explicitLoc; if (parser.parseKeyword("end") || parser.parseColon() || parser.parseType(opFntype) || parser.parseOptionalLocationSpecifier(explicitLoc)) @@ -1059,7 +1059,7 @@ void PolyForOp::getAsmBlockArgumentNames(Region ®ion, //===----------------------------------------------------------------------===// static ParseResult parseOptionalLoc(OpAsmParser &p, Attribute &loc) { - Optional<Location> result; + std::optional<Location> result; SMLoc sourceLoc = p.getCurrentLocation(); if (p.parseOptionalLocationSpecifier(result)) return failure(); diff --git a/mlir/test/lib/Dialect/Test/TestTypeDefs.td b/mlir/test/lib/Dialect/Test/TestTypeDefs.td index 81280d8d533c..72e857c12222 100644 --- a/mlir/test/lib/Dialect/Test/TestTypeDefs.td +++ b/mlir/test/lib/Dialect/Test/TestTypeDefs.td @@ -219,7 +219,7 @@ def TestTypeStructCaptureAll : Test_Type<"TestStructTypeCaptureAll"> { def TestTypeOptionalParam : Test_Type<"TestTypeOptionalParam"> { let parameters = (ins - OptionalParameter<"mlir::Optional<int>">:$a, + OptionalParameter<"std::optional<int>">:$a, "int":$b, DefaultValuedParameter<"std::optional<::mlir::Attribute>", "std::nullopt">:$c @@ -229,7 +229,7 @@ def TestTypeOptionalParam : Test_Type<"TestTypeOptionalParam"> { } def TestTypeOptionalParams : Test_Type<"TestTypeOptionalParams"> { - let parameters = (ins OptionalParameter<"mlir::Optional<int>">:$a, + let parameters = (ins OptionalParameter<"std::optional<int>">:$a, StringRefParameter<>:$b); let mnemonic = "optional_params"; let assemblyFormat = "`<` params `>`"; @@ -238,48 +238,48 @@ def TestTypeOptionalParams : Test_Type<"TestTypeOptionalParams"> { def TestTypeOptionalParamsAfterRequired : Test_Type<"TestTypeOptionalParamsAfterRequired"> { let parameters = (ins StringRefParameter<>:$a, - OptionalParameter<"mlir::Optional<int>">:$b); + OptionalParameter<"std::optional<int>">:$b); let mnemonic = "optional_params_after"; let assemblyFormat = "`<` params `>`"; } def TestTypeOptionalStruct : Test_Type<"TestTypeOptionalStruct"> { - let parameters = (ins OptionalParameter<"mlir::Optional<int>">:$a, + let parameters = (ins OptionalParameter<"std::optional<int>">:$a, StringRefParameter<>:$b); let mnemonic = "optional_struct"; let assemblyFormat = "`<` struct(params) `>`"; } def TestTypeAllOptionalParams : Test_Type<"TestTypeAllOptionalParams"> { - let parameters = (ins OptionalParameter<"mlir::Optional<int>">:$a, - OptionalParameter<"mlir::Optional<int>">:$b); + let parameters = (ins OptionalParameter<"std::optional<int>">:$a, + OptionalParameter<"std::optional<int>">:$b); let mnemonic = "all_optional_params"; let assemblyFormat = "`<` params `>`"; } def TestTypeAllOptionalStruct : Test_Type<"TestTypeAllOptionalStruct"> { - let parameters = (ins OptionalParameter<"mlir::Optional<int>">:$a, - OptionalParameter<"mlir::Optional<int>">:$b); + let parameters = (ins OptionalParameter<"std::optional<int>">:$a, + OptionalParameter<"std::optional<int>">:$b); let mnemonic = "all_optional_struct"; let assemblyFormat = "`<` struct(params) `>`"; } def TestTypeOptionalGroup : Test_Type<"TestTypeOptionalGroup"> { - let parameters = (ins "int":$a, OptionalParameter<"mlir::Optional<int>">:$b); + let parameters = (ins "int":$a, OptionalParameter<"std::optional<int>">:$b); let mnemonic = "optional_group"; let assemblyFormat = "`<` (`(` $b^ `)`) : (`x`)? $a `>`"; } def TestTypeOptionalGroupParams : Test_Type<"TestTypeOptionalGroupParams"> { - let parameters = (ins DefaultValuedParameter<"mlir::Optional<int>", "10">:$a, - OptionalParameter<"mlir::Optional<int>">:$b); + let parameters = (ins DefaultValuedParameter<"std::optional<int>", "10">:$a, + OptionalParameter<"std::optional<int>">:$b); let mnemonic = "optional_group_params"; let assemblyFormat = "`<` (`(` params^ `)`) : (`x`)? `>`"; } def TestTypeOptionalGroupStruct : Test_Type<"TestTypeOptionalGroupStruct"> { - let parameters = (ins OptionalParameter<"mlir::Optional<int>">:$a, - OptionalParameter<"mlir::Optional<int>">:$b); + let parameters = (ins OptionalParameter<"std::optional<int>">:$a, + OptionalParameter<"std::optional<int>">:$b); let mnemonic = "optional_group_struct"; let assemblyFormat = "`<` (`(` struct(params)^ `)`) : (`x`)? `>`"; } @@ -322,7 +322,7 @@ def TestTypeDefaultValuedType : Test_Type<"TestTypeDefaultValuedType"> { } def TestTypeCustom : Test_Type<"TestTypeCustom"> { - let parameters = (ins "int":$a, OptionalParameter<"mlir::Optional<int>">:$b); + let parameters = (ins "int":$a, OptionalParameter<"std::optional<int>">:$b); let mnemonic = "custom_type"; let assemblyFormat = [{ `<` custom<CustomTypeA>($a) `` custom<CustomTypeB>(ref($a), $b) `>` }]; @@ -343,14 +343,14 @@ def TestTypeCustomString : Test_Type<"TestTypeCustomString"> { } def TestTypeElseAnchor : Test_Type<"TestTypeElseAnchor"> { - let parameters = (ins OptionalParameter<"mlir::Optional<int>">:$a); + let parameters = (ins OptionalParameter<"std::optional<int>">:$a); let mnemonic = "else_anchor"; let assemblyFormat = "`<` (`?`) : ($a^)? `>`"; } def TestTypeElseAnchorStruct : Test_Type<"TestTypeElseAnchorStruct"> { - let parameters = (ins OptionalParameter<"mlir::Optional<int>">:$a, - OptionalParameter<"mlir::Optional<int>">:$b); + let parameters = (ins OptionalParameter<"std::optional<int>">:$a, + OptionalParameter<"std::optional<int>">:$b); let mnemonic = "else_anchor_struct"; let assemblyFormat = "`<` (`?`) : (struct($a, $b)^)? `>`"; } diff --git a/mlir/test/lib/Dialect/Test/TestTypes.cpp b/mlir/test/lib/Dialect/Test/TestTypes.cpp index 067c9b203adc..4d5c9b89957f 100644 --- a/mlir/test/lib/Dialect/Test/TestTypes.cpp +++ b/mlir/test/lib/Dialect/Test/TestTypes.cpp @@ -98,7 +98,7 @@ static LogicalResult parseCustomTypeA(AsmParser &parser, static void printCustomTypeA(AsmPrinter &printer, int a) { printer << a; } static LogicalResult parseCustomTypeB(AsmParser &parser, int a, - FailureOr<Optional<int>> &bResult) { + FailureOr<std::optional<int>> &bResult) { if (a < 0) return success(); for (int i : llvm::seq(0, a)) @@ -108,7 +108,7 @@ static LogicalResult parseCustomTypeB(AsmParser &parser, int a, return parser.parseInteger(**bResult); } -static void printCustomTypeB(AsmPrinter &printer, int a, Optional<int> b) { +static void printCustomTypeB(AsmPrinter &printer, int a, std::optional<int> b) { if (a < 0) return; printer << ' '; diff --git a/mlir/test/lib/Dialect/Test/TestTypes.h b/mlir/test/lib/Dialect/Test/TestTypes.h index bb3751d28182..b6a7e275781a 100644 --- a/mlir/test/lib/Dialect/Test/TestTypes.h +++ b/mlir/test/lib/Dialect/Test/TestTypes.h @@ -74,9 +74,9 @@ inline mlir::AsmPrinter &operator<<(mlir::AsmPrinter &printer, /// Overload the attribute parameter parser for optional integers. template <> -struct FieldParser<Optional<int>> { - static FailureOr<Optional<int>> parse(AsmParser &parser) { - Optional<int> value; +struct FieldParser<std::optional<int>> { + static FailureOr<std::optional<int>> parse(AsmParser &parser) { + std::optional<int> value; value.emplace(); OptionalParseResult result = parser.parseOptionalInteger(*value); if (result.has_value()) { diff --git a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp index b0f11ffeafff..68edea5efca0 100644 --- a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp +++ b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp @@ -73,7 +73,7 @@ struct TestVectorToVectorLowering private: // Return the target shape based on op type. - static Optional<SmallVector<int64_t>> getShape(Operation *op) { + static std::optional<SmallVector<int64_t>> getShape(Operation *op) { if (isa<arith::AddFOp, arith::SelectOp, arith::CmpFOp>(op)) return SmallVector<int64_t>(2, 2); if (isa<vector::ContractionOp>(op)) @@ -315,7 +315,7 @@ struct TestVectorUnrollingPatterns if (unrollBasedOnType) { UnrollVectorOptions::NativeShapeFnType nativeShapeFn = - [](Operation *op) -> Optional<SmallVector<int64_t>> { + [](Operation *op) -> std::optional<SmallVector<int64_t>> { vector::ContractionOp contractOp = cast<vector::ContractionOp>(op); SmallVector<int64_t> nativeShape(contractOp.getIteratorTypes().size(), 4); @@ -330,17 +330,20 @@ struct TestVectorUnrollingPatterns [](Operation *op) { return success(isa<ContractionOp>(op)); }); if (!unrollOrder.empty()) { - opts.setUnrollTraversalOrderFn([this](Operation *op) - -> Optional<SmallVector<int64_t>> { - vector::ContractionOp contractOp = cast<vector::ContractionOp>(op); - if (contractOp.getIteratorTypes().size() == unrollOrder.size()) - return SmallVector<int64_t>(unrollOrder.begin(), unrollOrder.end()); - return std::nullopt; - }); + opts.setUnrollTraversalOrderFn( + [this](Operation *op) -> std::optional<SmallVector<int64_t>> { + vector::ContractionOp contractOp = + cast<vector::ContractionOp>(op); + if (contractOp.getIteratorTypes().size() == unrollOrder.size()) + return SmallVector<int64_t>(unrollOrder.begin(), + unrollOrder.end()); + return std::nullopt; + }); } populateVectorUnrollPatterns(patterns, opts); } else { - auto nativeShapeFn = [](Operation *op) -> Optional<SmallVector<int64_t>> { + auto nativeShapeFn = + [](Operation *op) -> std::optional<SmallVector<int64_t>> { auto contractOp = dyn_cast<ContractionOp>(op); if (!contractOp) return std::nullopt; @@ -398,7 +401,7 @@ struct TestVectorTransferUnrollingPatterns }); if (reverseUnrollOrder.getValue()) { opts.setUnrollTraversalOrderFn( - [](Operation *op) -> Optional<SmallVector<int64_t>> { + [](Operation *op) -> std::optional<SmallVector<int64_t>> { int64_t numLoops = 0; if (auto readOp = dyn_cast<vector::TransferReadOp>(op)) numLoops = readOp.getVectorType().getRank(); diff --git a/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp b/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp index a7e90d4a977d..d862d0b980c1 100644 --- a/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp +++ b/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp @@ -51,11 +51,11 @@ struct LinalgTransformationFilter { explicit LinalgTransformationFilter( ArrayRef<StringAttr> matchDisjunction = {}, - Optional<StringAttr> replacement = std::nullopt); + std::optional<StringAttr> replacement = std::nullopt); explicit LinalgTransformationFilter( const FilterFunction &f, ArrayRef<StringAttr> matchDisjunction = {}, - Optional<StringAttr> replacement = std::nullopt); + std::optional<StringAttr> replacement = std::nullopt); LinalgTransformationFilter(LinalgTransformationFilter &&) = default; LinalgTransformationFilter(const LinalgTransformationFilter &) = default; @@ -89,14 +89,15 @@ struct LinalgTransformationFilter { private: SmallVector<FilterFunction> filters; SmallVector<StringAttr> matchDisjunction; - Optional<StringAttr> replacement; + std::optional<StringAttr> replacement; /// When set to true, if the attribute is not set, it will be treated as /// a match. Default is false. bool matchByDefault; }; LinalgTransformationFilter::LinalgTransformationFilter( - ArrayRef<StringAttr> matchDisjunction, Optional<StringAttr> replacement) + ArrayRef<StringAttr> matchDisjunction, + std::optional<StringAttr> replacement) : matchDisjunction(matchDisjunction.begin(), matchDisjunction.end()), replacement(replacement), matchByDefault(false) {} diff --git a/mlir/test/lib/Transforms/TestIntRangeInference.cpp b/mlir/test/lib/Transforms/TestIntRangeInference.cpp index cb4ce7106d0e..64ff4ce5b9e5 100644 --- a/mlir/test/lib/Transforms/TestIntRangeInference.cpp +++ b/mlir/test/lib/Transforms/TestIntRangeInference.cpp @@ -30,7 +30,7 @@ static LogicalResult replaceWithConstant(DataFlowSolver &solver, OpBuilder &b, return failure(); const ConstantIntRanges &inferredRange = maybeInferredRange->getValue().getValue(); - Optional<APInt> maybeConstValue = inferredRange.getConstantValue(); + std::optional<APInt> maybeConstValue = inferredRange.getConstantValue(); if (!maybeConstValue.has_value()) return failure(); |