[Mlir-commits] [mlir] 5521097 - [mlir] Use std::nullopt instead of None (NFC)
Kazu Hirata
llvmlistbot at llvm.org
Sun Dec 4 13:52:58 PST 2022
Author: Kazu Hirata
Date: 2022-12-04T13:52:46-08:00
New Revision: 552109719071677c0ff9bd03f662f6c3eb70285a
URL: https://github.com/llvm/llvm-project/commit/552109719071677c0ff9bd03f662f6c3eb70285a
DIFF: https://github.com/llvm/llvm-project/commit/552109719071677c0ff9bd03f662f6c3eb70285a.diff
LOG: [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
Added:
Modified:
mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td
mlir/include/mlir/Dialect/Func/IR/FuncOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td
mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td
mlir/include/mlir/IR/BuiltinAttributeInterfaces.td
mlir/include/mlir/IR/BuiltinAttributes.td
mlir/include/mlir/IR/BuiltinOps.td
mlir/include/mlir/IR/BuiltinTypeInterfaces.td
mlir/include/mlir/IR/BuiltinTypes.td
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
mlir/include/mlir/Interfaces/LoopLikeInterface.td
mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td
mlir/include/mlir/Interfaces/VectorInterfaces.td
mlir/test/mlir-tblgen/attrdefs.td
mlir/test/mlir-tblgen/op-attribute.td
mlir/test/mlir-tblgen/typedefs.td
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
mlir/tools/mlir-tblgen/EnumsGen.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
index 432792220c35d..46b3c90a1c1dd 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<void(OpBuilder &, Location, Value, ValueRange)>",
"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<void(OpBuilder &, Location, Value, ValueRange)>",
"nullptr">:$bodyBuilder)>
];
@@ -925,7 +925,7 @@ def AffineYieldOp : Affine_Op<"yield", [Pure, Terminator, ReturnLike,
let arguments = (ins Variadic<AnyType>:$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 678930f0a5de3..30895e577ad6c 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<AnyType>:$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<Type> 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 b30adaeae1740..de63062187a84 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 01298280f7a98..f1b7cfdb63022 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<AnyType>:$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 d40c6d2685c52..13f4502ca63a2 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -273,7 +273,7 @@ class LLVM_DbgIntrOp<string name, string argName> : LLVM_IntrOp<name, [], [], []
llvm::MetadataAsValue::get(ctx,
llvm::ValueAsMetadata::get(moduleTranslation.lookupValue(opInst.getOperand(0)))),
llvm::MetadataAsValue::get(ctx, moduleTranslation.translateDebugInfo($varInfo)),
- llvm::MetadataAsValue::get(ctx, llvm::DIExpression::get(ctx, llvm::None)),
+ llvm::MetadataAsValue::get(ctx, llvm::DIExpression::get(ctx, std::nullopt)),
});
}];
let mlirBuilder = [{
diff --git a/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td b/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td
index 82a559aab0664..422680a06deaa 100644
--- a/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td
+++ b/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td
@@ -457,7 +457,7 @@ def MLProgram_OutputOp : MLProgram_Op<"output", [
let arguments = (ins Variadic<AnyType>:$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<AnyType>:$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 2332d802dd9c5..30aa8bdad7d71 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<uint16_t>", "1">:$benefit,
- CArg<"Optional<StringRef>", "llvm::None">:$name)>,
+ CArg<"Optional<StringRef>", "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 09a496918d568..60f254863cb12 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<void(OpBuilder &, Location, Value, ValueRange)>",
"nullptr">)>
];
@@ -276,10 +276,10 @@ def ForOp : SCF_Op<"for",
/// operand return llvm::None.
Optional<unsigned> 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 82310cf00bb57..3441455cb9de5 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<string name, EnumAttr scheme, I32EnumAttrCase min>
"$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<string name, EnumAttr scheme, I32EnumAttrCase max>
"$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 6c0e7841d306c..c3697f01bb776 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<AnyType>:$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 b48284f01a6b0..ee44862ba72db 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<int64_t>":$innerDimsPos,
"ArrayRef<OpFoldResult>":$innerTiles,
- CArg<"Optional<Value>", "llvm::None">:$paddingValue,
+ CArg<"Optional<Value>", "std::nullopt">:$paddingValue,
CArg<"ArrayRef<int64_t>", "{}">:$outerDimsPerm)>
];
diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
index ff7b79b37c200..8d8939eb4f115 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<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+ CArg<"Optional<ArrayRef<bool>>", "::std::nullopt">:$inBounds)>,
/// 3. Builder that sets permutation map to 'getMinorIdentityMap'.
OpBuilder<(ins "VectorType":$vectorType,
"Value":$source,
"ValueRange":$indices,
"Value":$padding,
- CArg<"Optional<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+ CArg<"Optional<ArrayRef<bool>>", "::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<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+ CArg<"Optional<ArrayRef<bool>>", "::std::nullopt">:$inBounds)>,
];
let extraClassDeclaration = [{
@@ -1517,13 +1517,13 @@ def Vector_TransferWriteOp :
"Value":$dest,
"ValueRange":$indices,
"AffineMap":$permutationMap,
- CArg<"Optional<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+ CArg<"Optional<ArrayRef<bool>>", "::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<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+ CArg<"Optional<ArrayRef<bool>>", "::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 7facac839b9f0..bbde7bc33bf02 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 eb60977c8fb62..22e91f1e1abb2 100644
--- a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td
+++ b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td
@@ -398,7 +398,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> {
DefaultValueCheckT<T, Optional<iterator_range<T>>> tryGetValues() const {
if (Optional<iterator<T>> beginIt = try_value_begin<T>())
return iterator_range<T>(getType(), *beginIt, value_end<T>());
- return llvm::None;
+ return std::nullopt;
}
template <typename T>
DefaultValueCheckT<T, Optional<iterator<T>>> try_value_begin() const;
@@ -409,7 +409,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> {
Optional<DerivedAttrValueIteratorRange<T>> tryGetValues() const {
auto values = tryGetValues<Attribute>();
if (!values)
- return llvm::None;
+ return std::nullopt;
auto castFn = [](Attribute attr) { return attr.template cast<T>(); };
return DerivedAttrValueIteratorRange<T>(
@@ -421,7 +421,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> {
Optional<DerivedAttrValueIterator<T>> try_value_begin() const {
if (auto values = tryGetValues<T>())
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 70a535a922feb..fc0f696cefc28 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<NamedAttribute>", "llvm::None">:$value)>
+ AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "std::nullopt">:$value)>
];
let extraClassDeclaration = [{
using ValueType = ArrayRef<NamedAttribute>;
diff --git a/mlir/include/mlir/IR/BuiltinOps.td b/mlir/include/mlir/IR/BuiltinOps.td
index 72ce4cb5ecd87..68a512c06430c 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<StringRef>", "{}">:$name)>];
let extraClassDeclaration = [{
/// Construct a module from the given location with an optional name.
- static ModuleOp create(Location loc, Optional<StringRef> name = llvm::None);
+ static ModuleOp create(Location loc, Optional<StringRef> name = std::nullopt);
/// Return the name of this module if present.
Optional<StringRef> getName() { return getSymName(); }
diff --git a/mlir/include/mlir/IR/BuiltinTypeInterfaces.td b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td
index 08efe25809c84..cfbf937bf06cc 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 15749cf4a0ed8..be9d14d8c3040 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<UnrankedMemRefType>::getDimSize;
using ShapedType::Trait<UnrankedMemRefType>::getDynamicDimIndex;
- ArrayRef<int64_t> getShape() const { return llvm::None; }
+ ArrayRef<int64_t> 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<UnrankedTensorType>::getDimSize;
using ShapedType::Trait<UnrankedTensorType>::getDynamicDimIndex;
- ArrayRef<int64_t> getShape() const { return llvm::None; }
+ ArrayRef<int64_t> 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 e74cd00f7c638..2affd9ae3e031 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -1035,7 +1035,7 @@ class OptionalAttr<Attr attr> : Attr<attr.predicate, attr.summary> {
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 e1d36a86afaec..6e2ed7e76d979 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 2578b1b26b7c1..6c89c10e8256d 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 b703fa5d1fcde..842b7ff6d50b2 100644
--- a/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td
+++ b/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td
@@ -115,7 +115,7 @@ class EffectOpInterfaceBase<string name, string baseEffect>
return isa<Effect>(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 0da3309d165f4..645f57fb95883 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<int64_t, 4> 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 c5ef65124498b..020cd0ca65b69 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 cf76ce0744ca3..269d6e1e9b795 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<some-attr-kind>()
// DEF: ::llvm::Optional<some-return-type> AOp::getCAttr() {
// DEF-NEXT: auto attr = getCAttrAttr()
-// DEF-NEXT: return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::llvm::None);
+// DEF-NEXT: return attr ? ::llvm::Optional<some-return-type>(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<some-attr-kind>()
@@ -249,7 +249,7 @@ def AgetOp : Op<Test2_Dialect, "a_get_op", []> {
// DEF-NEXT: return ::mlir::impl::getAttrFromSortedRange({{.*}}).dyn_cast_or_null<some-attr-kind>()
// DEF: ::llvm::Optional<some-return-type> AgetOp::getCAttr() {
// DEF-NEXT: auto attr = getCAttrAttr()
-// DEF-NEXT: return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::llvm::None);
+// DEF-NEXT: return attr ? ::llvm::Optional<some-return-type>(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 f247264a60452..51006635a75a4 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 476b9351a24eb..bede0513a5517 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<NamedAttribute>", "{{}">:$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 f34aaa364fac9..31e73756eae9a 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -815,7 +815,7 @@ void DefGenerator::emitParsePrintDispatch(ArrayRef<AttrOrTypeDef> 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 f4e7566c762d0..4543b9db03253 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 128f4d0a95e51..014c94783119b 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";
}
}
More information about the Mlir-commits
mailing list