From: Kazu Hirata Date: Sun, 4 Dec 2022 21:52:45 +0000 (-0800) Subject: [mlir] Use std::nullopt instead of None (NFC) X-Git-Tag: upstream/17.0.6~25380 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=552109719071677c0ff9bd03f662f6c3eb70285a;p=platform%2Fupstream%2Fllvm.git [mlir] Use std::nullopt instead of None (NFC) I've verified that every change in this patch affects generated files and would reduce the number of warnings if None were deprecated. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 --- diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td index 4327922..46b3c90 100644 --- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td @@ -224,12 +224,12 @@ def AffineForOp : Affine_Op<"for", let skipDefaultBuilders = 1; let builders = [ OpBuilder<(ins "int64_t":$lowerBound, "int64_t":$upperBound, - CArg<"int64_t", "1">:$step, CArg<"ValueRange", "llvm::None">:$iterArgs, + CArg<"int64_t", "1">:$step, CArg<"ValueRange", "std::nullopt">:$iterArgs, CArg<"function_ref", "nullptr">:$bodyBuilder)>, OpBuilder<(ins "ValueRange":$lbOperands, "AffineMap":$lbMap, "ValueRange":$ubOperands, "AffineMap":$ubMap, CArg<"int64_t", "1">:$step, - CArg<"ValueRange", "llvm::None">:$iterArgs, + CArg<"ValueRange", "std::nullopt">:$iterArgs, CArg<"function_ref", "nullptr">:$bodyBuilder)> ]; @@ -925,7 +925,7 @@ def AffineYieldOp : Affine_Op<"yield", [Pure, Terminator, ReturnLike, let arguments = (ins Variadic:$operands); let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, llvm::None); }]> + OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> ]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; diff --git a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td index 678930f..30895e5 100644 --- a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td +++ b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td @@ -281,7 +281,7 @@ def Async_ReturnOp : Async_Op<"return", let arguments = (ins Variadic:$operands); - let builders = [OpBuilder<(ins), [{build($_builder, $_state, llvm::None);}]>]; + let builders = [OpBuilder<(ins), [{build($_builder, $_state, std::nullopt);}]>]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; let hasVerifier = 1; @@ -332,7 +332,7 @@ def Async_AwaitOp : Async_Op<"await"> { let extraClassDeclaration = [{ Optional getResultType() { - if (getResultTypes().empty()) return None; + if (getResultTypes().empty()) return std::nullopt; return getResultTypes()[0]; } }]; diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td b/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td index b30adae..de63062 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td +++ b/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td @@ -39,7 +39,7 @@ def AllocationOpInterface : OpInterface<"AllocationOpInterface"> { }], "::mlir::Optional<::mlir::Operation*>", "buildDealloc", (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}], - /*defaultImplementation=*/[{ return llvm::None; }] + /*defaultImplementation=*/[{ return std::nullopt; }] >, StaticInterfaceMethod<[{ Builds a clone operation using the provided builder and the current @@ -50,7 +50,7 @@ def AllocationOpInterface : OpInterface<"AllocationOpInterface"> { }], "::mlir::Optional<::mlir::Value>", "buildClone", (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}], - /*defaultImplementation=*/[{ return llvm::None; }] + /*defaultImplementation=*/[{ return std::nullopt; }] > ]; } diff --git a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td index 0129828..f1b7cfd 100644 --- a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td +++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td @@ -349,7 +349,7 @@ def ReturnOp : Func_Op<"return", [Pure, HasParent<"FuncOp">, let arguments = (ins Variadic:$operands); let builders = [OpBuilder<(ins), [{ - build($_builder, $_state, llvm::None); + build($_builder, $_state, std::nullopt); }]>]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td index d40c6d2..13f4502 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td @@ -273,7 +273,7 @@ class LLVM_DbgIntrOp : LLVM_IntrOp:$operands); let builders = [OpBuilder<(ins), [{ - build($_builder, $_state, llvm::None); + build($_builder, $_state, std::nullopt); }]>]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; @@ -483,7 +483,7 @@ def MLProgram_ReturnOp : MLProgram_Op<"return", [ let arguments = (ins Variadic:$operands); let builders = [OpBuilder<(ins), [{ - build($_builder, $_state, llvm::None); + build($_builder, $_state, std::nullopt); }]>]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; diff --git a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td index 2332d80..30aa8bd 100644 --- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td +++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td @@ -420,7 +420,7 @@ def PDL_PatternOp : PDL_Op<"pattern", [ let builders = [ OpBuilder<(ins CArg<"Optional", "1">:$benefit, - CArg<"Optional", "llvm::None">:$name)>, + CArg<"Optional", "std::nullopt">:$name)>, ]; let extraClassDeclaration = [{ //===------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td index 09a4969..60f2548 100644 --- a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td +++ b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td @@ -222,7 +222,7 @@ def ForOp : SCF_Op<"for", let skipDefaultBuilders = 1; let builders = [ OpBuilder<(ins "Value":$lowerBound, "Value":$upperBound, "Value":$step, - CArg<"ValueRange", "llvm::None">:$iterArgs, + CArg<"ValueRange", "std::nullopt">:$iterArgs, CArg<"function_ref", "nullptr">)> ]; @@ -276,10 +276,10 @@ def ForOp : SCF_Op<"for", /// operand return llvm::None. Optional getIterArgNumberForOpOperand(OpOperand &opOperand) { if (opOperand.getOwner() != getOperation()) - return llvm::None; + return std::nullopt; unsigned operandNumber = opOperand.getOperandNumber(); if (operandNumber < getNumControlOperands()) - return llvm::None; + return std::nullopt; return operandNumber - getNumControlOperands(); } diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td index 82310cf..3441455 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td @@ -68,7 +68,7 @@ class MinVersionBase "$overall = static_cast<" # scheme.returnType # ">(" "std::max(*$overall, $instance)); " "} else { $overall = $instance; }}"; - let initializer = "::llvm::None"; + let initializer = "::std::nullopt"; let instanceType = scheme.cppNamespace # "::" # scheme.enum.className; let instance = scheme.cppNamespace # "::" # scheme.enum.className # "::" # @@ -87,7 +87,7 @@ class MaxVersionBase "$overall = static_cast<" # scheme.returnType # ">(" "std::min(*$overall, $instance)); " "} else { $overall = $instance; }}"; - let initializer = "::llvm::None"; + let initializer = "::std::nullopt"; let instanceType = scheme.cppNamespace # "::" # scheme.enum.className; let instance = scheme.cppNamespace # "::" # scheme.enum.className # "::" # diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td index 6c0e784..c3697f0 100644 --- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td +++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td @@ -752,7 +752,7 @@ def Shape_YieldOp : Shape_Op<"yield", let arguments = (ins Variadic:$operands); let builders = [OpBuilder<(ins), - [{ build($_builder, $_state, llvm::None); }]> + [{ build($_builder, $_state, std::nullopt); }]> ]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; diff --git a/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td b/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td index b48284f..ee44862 100644 --- a/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td +++ b/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td @@ -1765,7 +1765,7 @@ def Tensor_PackOp : Tensor_RelayoutOp<"pack", [ OpBuilder<(ins "Value":$source, "Value":$dest, "ArrayRef":$innerDimsPos, "ArrayRef":$innerTiles, - CArg<"Optional", "llvm::None">:$paddingValue, + CArg<"Optional", "std::nullopt">:$paddingValue, CArg<"ArrayRef", "{}">:$outerDimsPerm)> ]; diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td index ff7b79b..8d8939eb 100644 --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -1368,19 +1368,19 @@ def Vector_TransferReadOp : "Value":$source, "ValueRange":$indices, "AffineMap":$permutationMap, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, /// 3. Builder that sets permutation map to 'getMinorIdentityMap'. OpBuilder<(ins "VectorType":$vectorType, "Value":$source, "ValueRange":$indices, "Value":$padding, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, /// 4. Builder that sets padding to zero and permutation map to /// 'getMinorIdentityMap'. OpBuilder<(ins "VectorType":$vectorType, "Value":$source, "ValueRange":$indices, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, ]; let extraClassDeclaration = [{ @@ -1517,13 +1517,13 @@ def Vector_TransferWriteOp : "Value":$dest, "ValueRange":$indices, "AffineMap":$permutationMap, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, /// 4. Builder with type inference that sets an empty mask and sets permutation /// map to 'getMinorIdentityMap'. OpBuilder<(ins "Value":$vector, "Value":$dest, "ValueRange":$indices, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, ]; let extraClassDeclaration = [{ diff --git a/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td b/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td index 7facac83..bbde7bc3 100644 --- a/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td +++ b/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td @@ -63,7 +63,7 @@ def MaskableOpInterface : OpInterface<"MaskableOpInterface"> { /*defaultImplementation=*/[{ // Default implementation is only aimed for operations that implement the // `getVectorType()` method. - return $_op.getVectorType().cloneWith(/*shape=*/llvm::None, + return $_op.getVectorType().cloneWith(/*shape=*/std::nullopt, IntegerType::get($_op.getContext(), /*width=*/1)); }]>, ]; diff --git a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td index eb60977..22e91f1 100644 --- a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td +++ b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td @@ -398,7 +398,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> { DefaultValueCheckT>> tryGetValues() const { if (Optional> beginIt = try_value_begin()) return iterator_range(getType(), *beginIt, value_end()); - return llvm::None; + return std::nullopt; } template DefaultValueCheckT>> try_value_begin() const; @@ -409,7 +409,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> { Optional> tryGetValues() const { auto values = tryGetValues(); if (!values) - return llvm::None; + return std::nullopt; auto castFn = [](Attribute attr) { return attr.template cast(); }; return DerivedAttrValueIteratorRange( @@ -421,7 +421,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> { Optional> try_value_begin() const { if (auto values = tryGetValues()) return values->begin(); - return llvm::None; + return std::nullopt; } }] # ElementsAttrInterfaceAccessors; } diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td index 70a535a..fc0f696 100644 --- a/mlir/include/mlir/IR/BuiltinAttributes.td +++ b/mlir/include/mlir/IR/BuiltinAttributes.td @@ -534,7 +534,7 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", [ }]; let parameters = (ins ArrayRefParameter<"NamedAttribute", "">:$value); let builders = [ - AttrBuilder<(ins CArg<"ArrayRef", "llvm::None">:$value)> + AttrBuilder<(ins CArg<"ArrayRef", "std::nullopt">:$value)> ]; let extraClassDeclaration = [{ using ValueType = ArrayRef; diff --git a/mlir/include/mlir/IR/BuiltinOps.td b/mlir/include/mlir/IR/BuiltinOps.td index 72ce4cb..68a512c 100644 --- a/mlir/include/mlir/IR/BuiltinOps.td +++ b/mlir/include/mlir/IR/BuiltinOps.td @@ -61,7 +61,7 @@ def ModuleOp : Builtin_Op<"module", [ let builders = [OpBuilder<(ins CArg<"Optional", "{}">:$name)>]; let extraClassDeclaration = [{ /// Construct a module from the given location with an optional name. - static ModuleOp create(Location loc, Optional name = llvm::None); + static ModuleOp create(Location loc, Optional name = std::nullopt); /// Return the name of this module if present. Optional getName() { return getSymName(); } diff --git a/mlir/include/mlir/IR/BuiltinTypeInterfaces.td b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td index 08efe25..cfbf937 100644 --- a/mlir/include/mlir/IR/BuiltinTypeInterfaces.td +++ b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td @@ -121,7 +121,7 @@ def ShapedTypeInterface : TypeInterface<"ShapedType"> { } /// Return a clone of this type with the given new element type. auto clone(::mlir::Type elementType) { - return $_type.cloneWith(/*shape=*/llvm::None, elementType); + return $_type.cloneWith(/*shape=*/std::nullopt, elementType); } /// If an element type is an integer or a float, return its width. Otherwise, diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td index 15749cf..be9d14d 100644 --- a/mlir/include/mlir/IR/BuiltinTypes.td +++ b/mlir/include/mlir/IR/BuiltinTypes.td @@ -880,7 +880,7 @@ def Builtin_UnrankedMemRef : Builtin_Type<"UnrankedMemRef", [ using ShapedType::Trait::getDimSize; using ShapedType::Trait::getDynamicDimIndex; - ArrayRef getShape() const { return llvm::None; } + ArrayRef getShape() const { return std::nullopt; } /// [deprecated] Returns the memory space in old raw integer representation. /// New `Attribute getMemorySpace()` method should be used instead. @@ -933,7 +933,7 @@ def Builtin_UnrankedTensor : Builtin_Type<"UnrankedTensor", [ using ShapedType::Trait::getDimSize; using ShapedType::Trait::getDynamicDimIndex; - ArrayRef getShape() const { return llvm::None; } + ArrayRef getShape() const { return std::nullopt; } }]; let skipDefaultBuilders = 1; let genVerifyDecl = 1; diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index e74cd00..2affd9ae 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1035,7 +1035,7 @@ class OptionalAttr : Attr { let storageType = attr.storageType; let returnType = "::llvm::Optional<" # attr.returnType #">"; let convertFromStorage = "$_self ? " # returnType # "(" # - attr.convertFromStorage # ") : (::llvm::None)"; + attr.convertFromStorage # ") : (::std::nullopt)"; let valueType = attr.valueType; let isOptional = 1; diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td index e1d36a8..6e2ed7e 100644 --- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td +++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td @@ -79,7 +79,7 @@ def BranchOpInterface : OpInterface<"BranchOpInterface"> { opaqueOp->getSuccessor(i))) return arg; } - return ::llvm::None; + return ::std::nullopt; }] >, InterfaceMethod<[{ diff --git a/mlir/include/mlir/Interfaces/LoopLikeInterface.td b/mlir/include/mlir/Interfaces/LoopLikeInterface.td index 2578b1b..6c89c10 100644 --- a/mlir/include/mlir/Interfaces/LoopLikeInterface.td +++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.td @@ -57,7 +57,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> { /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - return llvm::None; + return std::nullopt; }] >, InterfaceMethod<[{ @@ -69,7 +69,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> { /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - return llvm::None; + return std::nullopt; }] >, InterfaceMethod<[{ @@ -81,7 +81,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> { /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - return llvm::None; + return std::nullopt; }] >, InterfaceMethod<[{ @@ -93,7 +93,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> { /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - return llvm::None; + return std::nullopt; }] >, ]; diff --git a/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td b/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td index b703fa5..842b7ff 100644 --- a/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td +++ b/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td @@ -115,7 +115,7 @@ class EffectOpInterfaceBase return isa(it.getEffect()) && it.getValue() == value; }); if (it == effects.end()) - return llvm::None; + return std::nullopt; return *it; } diff --git a/mlir/include/mlir/Interfaces/VectorInterfaces.td b/mlir/include/mlir/Interfaces/VectorInterfaces.td index 0da3309..645f57f 100644 --- a/mlir/include/mlir/Interfaces/VectorInterfaces.td +++ b/mlir/include/mlir/Interfaces/VectorInterfaces.td @@ -37,7 +37,7 @@ def VectorUnrollOpInterface : OpInterface<"VectorUnrollOpInterface"> { auto vt = $_op.getResult().getType(). template dyn_cast<::mlir::VectorType>(); if (!vt) - return ::mlir::None; + return ::std::nullopt; ::llvm::SmallVector res(vt.getShape().begin(), vt.getShape().end()); return res; }] diff --git a/mlir/test/mlir-tblgen/attrdefs.td b/mlir/test/mlir-tblgen/attrdefs.td index c5ef651..020cd0c 100644 --- a/mlir/test/mlir-tblgen/attrdefs.td +++ b/mlir/test/mlir-tblgen/attrdefs.td @@ -33,7 +33,7 @@ include "mlir/IR/OpBase.td" // DEF-NEXT: return ::mlir::success(!!value); // DEF: .Default([&](llvm::StringRef keyword, // DEF-NEXT: *mnemonic = keyword; -// DEF-NEXT: return llvm::None; +// DEF-NEXT: return std::nullopt; def Test_Dialect: Dialect { // DECL-NOT: TestDialect diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td index cf76ce0..269d6e1 100644 --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -112,7 +112,7 @@ def AOp : NS_Op<"a_op", []> { // DEF-NEXT: ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, getCAttrAttrName()).dyn_cast_or_null() // DEF: ::llvm::Optional AOp::getCAttr() { // DEF-NEXT: auto attr = getCAttrAttr() -// DEF-NEXT: return attr ? ::llvm::Optional(attr.some-convert-from-storage()) : (::llvm::None); +// DEF-NEXT: return attr ? ::llvm::Optional(attr.some-convert-from-storage()) : (::std::nullopt); // DEF: some-attr-kind AOp::getDAttrAttr() // DEF-NEXT: ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, getDAttrAttrName()).dyn_cast_or_null() @@ -249,7 +249,7 @@ def AgetOp : Op { // DEF-NEXT: return ::mlir::impl::getAttrFromSortedRange({{.*}}).dyn_cast_or_null() // DEF: ::llvm::Optional AgetOp::getCAttr() { // DEF-NEXT: auto attr = getCAttrAttr() -// DEF-NEXT: return attr ? ::llvm::Optional(attr.some-convert-from-storage()) : (::llvm::None); +// DEF-NEXT: return attr ? ::llvm::Optional(attr.some-convert-from-storage()) : (::std::nullopt); // Test setter methods // --- diff --git a/mlir/test/mlir-tblgen/typedefs.td b/mlir/test/mlir-tblgen/typedefs.td index f247264..5100663 100644 --- a/mlir/test/mlir-tblgen/typedefs.td +++ b/mlir/test/mlir-tblgen/typedefs.td @@ -33,7 +33,7 @@ include "mlir/IR/OpBase.td" // DEF-NEXT: return ::mlir::success(!!value); // DEF: .Default([&](llvm::StringRef keyword, // DEF-NEXT: *mnemonic = keyword; -// DEF-NEXT: return llvm::None; +// DEF-NEXT: return std::nullopt; def Test_Dialect: Dialect { // DECL-NOT: TestDialect 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 476b935..bede051 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 @@ -525,7 +525,7 @@ def {0} : LinalgStructuredBase_Op<"{1}", !listconcat([AttrSizedOperandSegments], (ins "ValueRange":$inputs, "ValueRange":$outputs, CArg<"ArrayRef", "{{}">:$attributes), [{{ - buildStructuredOp($_builder, $_state, llvm::None, inputs, outputs, + buildStructuredOp($_builder, $_state, std::nullopt, inputs, outputs, attributes, {0}::getRegionBuilder()); }]>, OpBuilder< diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp index f34aaa3..31e7375 100644 --- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp @@ -815,7 +815,7 @@ void DefGenerator::emitParsePrintDispatch(ArrayRef defs) { } parse.body() << " .Default([&](llvm::StringRef keyword, llvm::SMLoc) {\n" " *mnemonic = keyword;\n" - " return llvm::None;\n" + " return std::nullopt;\n" " });"; printer.body() << " .Default([](auto) { return ::mlir::failure(); });"; diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index f4e7566..4543b9d 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -392,7 +392,7 @@ static void emitStrToSymFnForIntEnum(const Record &enumDef, raw_ostream &os) { os << formatv(" .Case(\"{1}\", {0}::{2})\n", enumName, str, makeIdentifier(symbol)); } - os << " .Default(::llvm::None);\n"; + os << " .Default(::std::nullopt);\n"; os << "}\n"; } @@ -433,9 +433,9 @@ static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) { if (auto val = enumerant.getValue()) os.indent(6) << formatv(".Case(\"{0}\", {1})\n", enumerant.getStr(), val); } - os.indent(6) << ".Default(::llvm::None);\n"; + os.indent(6) << ".Default(::std::nullopt);\n"; - os << " if (bit) { val |= *bit; } else { return ::llvm::None; }\n"; + os << " if (bit) { val |= *bit; } else { return ::std::nullopt; }\n"; os << " }\n"; os << formatv(" return static_cast<{0}>(val);\n", enumName); @@ -468,7 +468,7 @@ static void emitUnderlyingToSymFnForIntEnum(const Record &enumDef, os << formatv(" case {0}: return {1}::{2};\n", value, enumName, makeIdentifier(symbol)); } - os << " default: return ::llvm::None;\n" + os << " default: return ::std::nullopt;\n" << " }\n" << "}\n\n"; } @@ -548,7 +548,7 @@ static void emitUnderlyingToSymFnForBitEnum(const Record &enumDef, makeIdentifier(allBitsUnsetCase->getSymbol())); } int64_t validBits = enumDef.getValueAsInt("validBits"); - os << formatv(" if (value & ~static_cast<{0}>({1}u)) return llvm::None;\n", + os << formatv(" if (value & ~static_cast<{0}>({1}u)) return std::nullopt;\n", underlyingType, validBits); os << formatv(" return static_cast<{0}>(value);\n", enumName); os << "}\n"; diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp index 128f4d0..014c947 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -362,7 +362,7 @@ static void emitAvailabilityQueryForIntEnum(const Record &enumDef, if (classCasePair.getValue().size() < enumAttr.getAllCases().size()) os << " default: break;\n"; os << " }\n" - << " return llvm::None;\n" + << " return std::nullopt;\n" << "}\n"; } } @@ -407,7 +407,7 @@ static void emitAvailabilityQueryForBitEnum(const Record &enumDef, } os << " default: break;\n"; os << " }\n" - << " return llvm::None;\n" + << " return std::nullopt;\n" << "}\n"; } }