[Mlir-commits] [mlir] e8bcc37 - mlir/{SPIRV, Bufferization}: use std::optional in .td files (NFC)
Ramkumar Ramachandra
llvmlistbot at llvm.org
Tue Dec 20 00:24:19 PST 2022
Author: Ramkumar Ramachandra
Date: 2022-12-20T09:23:58+01:00
New Revision: e8bcc37fff5bda7dd9326903a2c31e6703b4fe68
URL: https://github.com/llvm/llvm-project/commit/e8bcc37fff5bda7dd9326903a2c31e6703b4fe68
DIFF: https://github.com/llvm/llvm-project/commit/e8bcc37fff5bda7dd9326903a2c31e6703b4fe68.diff
LOG: mlir/{SPIRV,Bufferization}: use std::optional in .td files (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional. 22426110c5ef changed the way mlir-tblgen generates .inc
files, emitting std::optional when an Optional attribute is specified in
a .td file. It also changed several .td files hard-coding llvm::Optional
to use std::optional. However, the patch excluded a few .td files in
SPIRV and Bufferization hard-coding llvm::Optional. This patch fixes
that defect, and after this patch, references to llvm::Optional in .cpp
and .h files can be replaced mechanically.
See also: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Signed-off-by: Ramkumar Ramachandra <r at artagnon.com>
Differential Revision: https://reviews.llvm.org/D140329
Added:
Modified:
mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
mlir/include/mlir/IR/DialectImplementation.h
mlir/include/mlir/IR/SymbolInterfaces.td
mlir/include/mlir/IR/SymbolTable.h
mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp
mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
mlir/lib/IR/SymbolTable.cpp
mlir/lib/Transforms/SymbolDCE.cpp
mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
mlir/test/lib/Dialect/Test/TestAttrDefs.td
mlir/test/lib/Dialect/Test/TestAttributes.cpp
mlir/test/lib/IR/TestSymbolUses.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td b/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td
index eaee9d282929b..e3fbee7bf96c5 100644
--- a/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td
+++ b/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td
@@ -37,7 +37,7 @@ def AllocationOpInterface : OpInterface<"AllocationOpInterface"> {
operation implementing this interface. If there is no compatible
deallocation operation, this method can return ::std::nullopt.
}],
- "::mlir::Optional<::mlir::Operation*>", "buildDealloc",
+ "::std::optional<::mlir::Operation*>", "buildDealloc",
(ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}],
/*defaultImplementation=*/[{ return std::nullopt; }]
>,
@@ -48,7 +48,7 @@ def AllocationOpInterface : OpInterface<"AllocationOpInterface"> {
implementing this interface. If there is no compatible clone operation,
this method can return ::std::nullopt.
}],
- "::mlir::Optional<::mlir::Value>", "buildClone",
+ "::std::optional<::mlir::Value>", "buildClone",
(ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}],
/*defaultImplementation=*/[{ return std::nullopt; }]
>
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
index 2de4bc225f71f..1d304610a03a8 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
@@ -53,7 +53,7 @@ class InterfaceVarABIAttr
/// Gets a InterfaceVarABIAttr.
static InterfaceVarABIAttr get(uint32_t descriptorSet, uint32_t binding,
- Optional<StorageClass> storageClass,
+ std::optional<StorageClass> storageClass,
MLIRContext *context);
static InterfaceVarABIAttr get(IntegerAttr descriptorSet, IntegerAttr binding,
IntegerAttr storageClass);
@@ -68,7 +68,7 @@ class InterfaceVarABIAttr
uint32_t getBinding();
/// Returns `spirv::StorageClass`.
- Optional<StorageClass> getStorageClass();
+ std::optional<StorageClass> getStorageClass();
static LogicalResult verify(function_ref<InFlightDiagnostic()> emitError,
IntegerAttr descriptorSet, IntegerAttr binding,
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.td
index 80f1715664ee1..7e51150f55576 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.td
@@ -35,7 +35,7 @@ class SPIRV_Attr<string attrName, string attrMnemonic>
def SPIRV_EntryPointABIAttr : SPIRV_Attr<"EntryPointABI", "entry_point_abi"> {
let parameters = (ins
OptionalParameter<"DenseI32ArrayAttr">:$workgroup_size,
- OptionalParameter<"llvm::Optional<int>">:$subgroup_size
+ OptionalParameter<"std::optional<int>">:$subgroup_size
);
let assemblyFormat = "`<` struct(params) `>`";
}
@@ -116,9 +116,9 @@ def SPIRV_ResourceLimitsAttr : SPIRV_Attr<"ResourceLimits", "resource_limits"> {
DefaultValuedParameter<"int", "32">:$subgroup_size,
// The minimum supported size if the subgroup size is controllable.
- OptionalParameter<"mlir::Optional<int>">:$min_subgroup_size,
+ OptionalParameter<"std::optional<int>">:$min_subgroup_size,
// The maximum supported size if the subgroup size is controllable.
- OptionalParameter<"mlir::Optional<int>">:$max_subgroup_size,
+ OptionalParameter<"std::optional<int>">:$max_subgroup_size,
// The configurations of cooperative matrix operations
// supported. Default is an empty list.
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
index 3441455cb9de5..46f637bfe2cf3 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
@@ -60,7 +60,7 @@ class MinVersionBase<string name, EnumAttr scheme, I32EnumAttrCase min>
: Availability {
let interfaceName = name;
- let queryFnRetType = "llvm::Optional<" # scheme.returnType # ">";
+ let queryFnRetType = "std::optional<" # scheme.returnType # ">";
let queryFnName = "getMinVersion";
let mergeAction = "{ "
@@ -79,7 +79,7 @@ class MaxVersionBase<string name, EnumAttr scheme, I32EnumAttrCase max>
: Availability {
let interfaceName = name;
- let queryFnRetType = "llvm::Optional<" # scheme.returnType # ">";
+ let queryFnRetType = "std::optional<" # scheme.returnType # ">";
let queryFnName = "getMaxVersion";
let mergeAction = "{ "
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
index 4be10e61ddee2..795a39856cd21 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
@@ -238,11 +238,11 @@ class SPIRVOpInterface<string name> : OpInterface<name> {
// Remove them once we are able to support dialect-specific contents in ODS.
def QueryMinVersionInterface : SPIRVOpInterface<"QueryMinVersionInterface"> {
let methods = [InterfaceMethod<
- "", "::llvm::Optional<::mlir::spirv::Version>", "getMinVersion">];
+ "", "::std::optional<::mlir::spirv::Version>", "getMinVersion">];
}
def QueryMaxVersionInterface : SPIRVOpInterface<"QueryMaxVersionInterface"> {
let methods = [InterfaceMethod<
- "", "::llvm::Optional<::mlir::spirv::Version>", "getMaxVersion">];
+ "", "::std::optional<::mlir::spirv::Version>", "getMaxVersion">];
}
def QueryExtensionInterface : SPIRVOpInterface<"QueryExtensionInterface"> {
let methods = [InterfaceMethod<
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
index 48c08cfa69b52..55b88586749fc 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
@@ -73,10 +73,10 @@ class TargetEnv {
StringRef getInterfaceVarABIAttrName();
/// Gets the InterfaceVarABIAttr given its fields.
-InterfaceVarABIAttr getInterfaceVarABIAttr(unsigned descriptorSet,
- unsigned binding,
- Optional<StorageClass> storageClass,
- MLIRContext *context);
+InterfaceVarABIAttr
+getInterfaceVarABIAttr(unsigned descriptorSet, unsigned binding,
+ std::optional<StorageClass> storageClass,
+ MLIRContext *context);
/// Returns whether the given SPIR-V target (described by TargetEnvAttr) needs
/// ABI attributes for interface variables (spirv.interface_var_abi).
@@ -88,7 +88,7 @@ StringRef getEntryPointABIAttrName();
/// Gets the EntryPointABIAttr given its fields.
EntryPointABIAttr getEntryPointABIAttr(MLIRContext *context,
ArrayRef<int32_t> workgroupSize = {},
- llvm::Optional<int> subgroupSize = {});
+ std::optional<int> subgroupSize = {});
/// Queries the entry point ABI on the nearest function-like op containing the
/// given `op`. Returns null attribute if not found.
diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h
index 7e4899618066e..e0c7c068f41e7 100644
--- a/mlir/include/mlir/IR/DialectImplementation.h
+++ b/mlir/include/mlir/IR/DialectImplementation.h
@@ -108,14 +108,14 @@ struct FieldParser<std::string> {
/// Parse an Optional integer.
template <typename IntT>
struct FieldParser<
- llvm::Optional<IntT>,
- std::enable_if_t<std::is_integral<IntT>::value, Optional<IntT>>> {
- static FailureOr<Optional<IntT>> parse(AsmParser &parser) {
+ std::optional<IntT>,
+ std::enable_if_t<std::is_integral<IntT>::value, std::optional<IntT>>> {
+ static FailureOr<std::optional<IntT>> parse(AsmParser &parser) {
IntT value;
OptionalParseResult result = parser.parseOptionalInteger(value);
if (result.has_value()) {
if (succeeded(*result))
- return {Optional<IntT>(value)};
+ return {std::optional<IntT>(value)};
return failure();
}
return {std::nullopt};
diff --git a/mlir/include/mlir/IR/SymbolInterfaces.td b/mlir/include/mlir/IR/SymbolInterfaces.td
index ea5251f941cd6..50737746f3d6d 100644
--- a/mlir/include/mlir/IR/SymbolInterfaces.td
+++ b/mlir/include/mlir/IR/SymbolInterfaces.td
@@ -99,7 +99,7 @@ def Symbol : OpInterface<"SymbolOpInterface"> {
given operation 'from'.
Note: See mlir::SymbolTable::getSymbolUses for more details.
}],
- "::llvm::Optional<::mlir::SymbolTable::UseRange>", "getSymbolUses",
+ "::std::optional<::mlir::SymbolTable::UseRange>", "getSymbolUses",
(ins "::mlir::Operation *":$from), [{}],
/*defaultImplementation=*/[{
return ::mlir::SymbolTable::getSymbolUses(this->getOperation(), from);
diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h
index 6addd72be1fbf..7b325c8b896ce 100644
--- a/mlir/include/mlir/IR/SymbolTable.h
+++ b/mlir/include/mlir/IR/SymbolTable.h
@@ -181,17 +181,19 @@ class SymbolTable {
/// within the given operation 'from'. This does not traverse into any nested
/// symbol tables. This function returns std::nullopt if there are any unknown
/// operations that may potentially be symbol tables.
- static Optional<UseRange> getSymbolUses(Operation *from);
- static Optional<UseRange> getSymbolUses(Region *from);
+ static std::optional<UseRange> getSymbolUses(Operation *from);
+ static std::optional<UseRange> getSymbolUses(Region *from);
/// Get all of the uses of the given symbol that are nested within the given
/// operation 'from'. This does not traverse into any nested symbol tables.
/// This function returns std::nullopt if there are any unknown operations
/// that may potentially be symbol tables.
- static Optional<UseRange> getSymbolUses(StringAttr symbol, Operation *from);
- static Optional<UseRange> getSymbolUses(Operation *symbol, Operation *from);
- static Optional<UseRange> getSymbolUses(StringAttr symbol, Region *from);
- static Optional<UseRange> getSymbolUses(Operation *symbol, Region *from);
+ static std::optional<UseRange> getSymbolUses(StringAttr symbol,
+ Operation *from);
+ static std::optional<UseRange> getSymbolUses(Operation *symbol,
+ Operation *from);
+ static std::optional<UseRange> getSymbolUses(StringAttr symbol, Region *from);
+ static std::optional<UseRange> getSymbolUses(Operation *symbol, Region *from);
/// Return if the given symbol is known to have no uses that are nested
/// within the given operation 'from'. This does not traverse into any nested
diff --git a/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp
index 07c8ed9517937..636ab5875461f 100644
--- a/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp
@@ -146,7 +146,7 @@ void DeadCodeAnalysis::initializeSymbolCallables(Operation *top) {
return;
// Walk the symbol table to check for non-call uses of symbols.
- Optional<SymbolTable::UseRange> uses =
+ std::optional<SymbolTable::UseRange> uses =
SymbolTable::getSymbolUses(&symbolTableRegion);
if (!uses) {
// If we couldn't gather the symbol uses, conservatively assume that
diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
index 2a8389598f36a..5c9de5ebcc955 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
@@ -265,7 +265,7 @@ getDefaultABIAttrs(MLIRContext *context, gpu::GPUFuncOp funcOp,
return failure();
// Vulkan's interface variable requirements needs scalars to be wrapped in a
// struct. The struct held in storage buffer.
- Optional<spirv::StorageClass> sc;
+ std::optional<spirv::StorageClass> sc;
if (funcOp.getArgument(argIndex).getType().isIntOrIndexOrFloat())
sc = spirv::StorageClass::StorageBuffer;
argABI.push_back(spirv::getInterfaceVarABIAttr(0, argIndex, sc, context));
diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
index 374a1f324be92..f021a593f2415 100644
--- a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
+++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
@@ -690,12 +690,13 @@ LogicalResult ToMemrefOp::bufferize(RewriterBase &rewriter,
return success();
}
-Optional<Operation *> CloneOp::buildDealloc(OpBuilder &builder, Value alloc) {
+std::optional<Operation *> CloneOp::buildDealloc(OpBuilder &builder,
+ Value alloc) {
return builder.create<memref::DeallocOp>(alloc.getLoc(), alloc)
.getOperation();
}
-Optional<Value> CloneOp::buildClone(OpBuilder &builder, Value alloc) {
+std::optional<Value> CloneOp::buildClone(OpBuilder &builder, Value alloc) {
return builder.create<CloneOp>(alloc.getLoc(), alloc).getResult();
}
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
index 9a4d12c2b32b5..7b112e8662c94 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
@@ -628,11 +628,12 @@ class BufferDeallocation : public BufferPlacementTransformationBase {
struct DefaultAllocationInterface
: public bufferization::AllocationOpInterface::ExternalModel<
DefaultAllocationInterface, memref::AllocOp> {
- static Optional<Operation *> buildDealloc(OpBuilder &builder, Value alloc) {
+ static std::optional<Operation *> buildDealloc(OpBuilder &builder,
+ Value alloc) {
return builder.create<memref::DeallocOp>(alloc.getLoc(), alloc)
.getOperation();
}
- static Optional<Value> buildClone(OpBuilder &builder, Value alloc) {
+ static std::optional<Value> buildClone(OpBuilder &builder, Value alloc) {
return builder.create<bufferization::CloneOp>(alloc.getLoc(), alloc)
.getResult();
}
diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
index 1fe9e74d38af8..fadae79eff85b 100644
--- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
@@ -360,7 +360,7 @@ class GpuKernelOutliningPass
SmallVector<Operation *, 8> symbolDefWorklist = {kernelFunc};
while (!symbolDefWorklist.empty()) {
- if (Optional<SymbolTable::UseRange> symbolUses =
+ if (std::optional<SymbolTable::UseRange> symbolUses =
SymbolTable::getSymbolUses(symbolDefWorklist.pop_back_val())) {
for (SymbolTable::SymbolUse symbolUse : *symbolUses) {
StringRef symbolName =
diff --git a/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp b/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp
index f61cbc458229b..ad30ee0898cb0 100644
--- a/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp
+++ b/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp
@@ -120,7 +120,8 @@ void NormalizeMemRefs::setCalleesAndCallersNonNormalizable(
<< " calls or is called by non-normalizable function\n");
normalizableFuncs.erase(funcOp);
// Caller of the function.
- Optional<SymbolTable::UseRange> symbolUses = funcOp.getSymbolUses(moduleOp);
+ std::optional<SymbolTable::UseRange> symbolUses =
+ funcOp.getSymbolUses(moduleOp);
for (SymbolTable::SymbolUse symbolUse : *symbolUses) {
// TODO: Extend this for ops that are FunctionOpInterface. This would
// require creating an OpInterface for FunctionOpInterface ops.
@@ -256,7 +257,8 @@ void NormalizeMemRefs::updateFunctionSignature(func::FuncOp funcOp,
llvm::SmallDenseSet<func::FuncOp, 8> funcOpsToUpdate;
// We iterate over all symbolic uses of the function and update the return
// type at the caller site.
- Optional<SymbolTable::UseRange> symbolUses = funcOp.getSymbolUses(moduleOp);
+ std::optional<SymbolTable::UseRange> symbolUses =
+ funcOp.getSymbolUses(moduleOp);
for (SymbolTable::SymbolUse symbolUse : *symbolUses) {
Operation *userOp = symbolUse.getUser();
OpBuilder builder(userOp);
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
index 3481bb3719938..c8179cc5e7b34 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
@@ -121,7 +121,7 @@ struct TargetEnvAttributeStorage : public AttributeStorage {
spirv::InterfaceVarABIAttr
spirv::InterfaceVarABIAttr::get(uint32_t descriptorSet, uint32_t binding,
- Optional<spirv::StorageClass> storageClass,
+ std::optional<spirv::StorageClass> storageClass,
MLIRContext *context) {
Builder b(context);
auto descriptorSetAttr = b.getI32IntegerAttr(descriptorSet);
@@ -152,7 +152,8 @@ uint32_t spirv::InterfaceVarABIAttr::getDescriptorSet() {
return getImpl()->descriptorSet.cast<IntegerAttr>().getInt();
}
-Optional<spirv::StorageClass> spirv::InterfaceVarABIAttr::getStorageClass() {
+std::optional<spirv::StorageClass>
+spirv::InterfaceVarABIAttr::getStorageClass() {
if (getImpl()->storageClass)
return static_cast<spirv::StorageClass>(
getImpl()->storageClass.cast<IntegerAttr>().getValue().getZExtValue());
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
index 929010651b764..36c1c6d0c61be 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
@@ -4851,11 +4851,11 @@ static LogicalResult verifyIntegerDotProduct(Operation *op) {
return success();
}
-static Optional<spirv::Version> getIntegerDotProductMinVersion() {
+static std::optional<spirv::Version> getIntegerDotProductMinVersion() {
return spirv::Version::V_1_0; // Available in SPIR-V >= 1.0.
}
-static Optional<spirv::Version> getIntegerDotProductMaxVersion() {
+static std::optional<spirv::Version> getIntegerDotProductMaxVersion() {
return spirv::Version::V_1_6; // Available in SPIR-V <= 1.6.
}
@@ -4910,10 +4910,10 @@ getIntegerDotProductCapabilities(Operation *op) {
SmallVector<ArrayRef<spirv::Capability>, 1> OpName::getCapabilities() { \
return getIntegerDotProductCapabilities(*this); \
} \
- Optional<spirv::Version> OpName::getMinVersion() { \
+ std::optional<spirv::Version> OpName::getMinVersion() { \
return getIntegerDotProductMinVersion(); \
} \
- Optional<spirv::Version> OpName::getMaxVersion() { \
+ std::optional<spirv::Version> OpName::getMaxVersion() { \
return getIntegerDotProductMaxVersion(); \
}
diff --git a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
index ee7720fd39f56..f23a91936ad78 100644
--- a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
@@ -101,7 +101,7 @@ StringRef spirv::getInterfaceVarABIAttrName() {
spirv::InterfaceVarABIAttr
spirv::getInterfaceVarABIAttr(unsigned descriptorSet, unsigned binding,
- Optional<spirv::StorageClass> storageClass,
+ std::optional<spirv::StorageClass> storageClass,
MLIRContext *context) {
return spirv::InterfaceVarABIAttr::get(descriptorSet, binding, storageClass,
context);
@@ -122,7 +122,7 @@ StringRef spirv::getEntryPointABIAttrName() { return "spirv.entry_point_abi"; }
spirv::EntryPointABIAttr
spirv::getEntryPointABIAttr(MLIRContext *context,
ArrayRef<int32_t> workgroupSize,
- llvm::Optional<int> subgroupSize) {
+ std::optional<int> subgroupSize) {
DenseI32ArrayAttr workgroupSizeAttr;
if (!workgroupSize.empty()) {
assert(workgroupSize.size() == 3);
diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
index 04ebea7ed5403..9e25e9f2b3503 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
@@ -160,7 +160,7 @@ static LogicalResult lowerEntryPointABIAttr(spirv::FuncOp funcOp,
entryPointAttr.getSubgroupSize());
}
}
- if (Optional<int> subgroupSize = entryPointAttr.getSubgroupSize()) {
+ if (std::optional<int> subgroupSize = entryPointAttr.getSubgroupSize()) {
std::optional<ArrayRef<spirv::Capability>> caps =
spirv::getCapabilities(spirv::ExecutionMode::SubgroupSize);
if (!caps || targetEnv.allows(*caps)) {
diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
index b455993924b55..ba83fdc25f9a0 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
@@ -848,7 +848,7 @@ bool SPIRVConversionTarget::isLegalOp(Operation *op) {
// QueryMinVersionInterface/QueryMaxVersionInterface are available to all
// SPIR-V versions.
if (auto minVersionIfx = dyn_cast<spirv::QueryMinVersionInterface>(op)) {
- Optional<spirv::Version> minVersion = minVersionIfx.getMinVersion();
+ std::optional<spirv::Version> minVersion = minVersionIfx.getMinVersion();
if (minVersion && *minVersion > this->targetEnv.getVersion()) {
LLVM_DEBUG(llvm::dbgs()
<< op->getName() << " illegal: requiring min version "
@@ -857,7 +857,7 @@ bool SPIRVConversionTarget::isLegalOp(Operation *op) {
}
}
if (auto maxVersionIfx = dyn_cast<spirv::QueryMaxVersionInterface>(op)) {
- Optional<spirv::Version> maxVersion = maxVersionIfx.getMaxVersion();
+ std::optional<spirv::Version> maxVersion = maxVersionIfx.getMaxVersion();
if (maxVersion && *maxVersion < this->targetEnv.getVersion()) {
LLVM_DEBUG(llvm::dbgs()
<< op->getName() << " illegal: requiring max version "
diff --git a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
index 33091b5f5575a..25bc0c87995c4 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
@@ -118,7 +118,7 @@ void UpdateVCEPass::runOnOperation() {
WalkResult walkResult = module.walk([&](Operation *op) -> WalkResult {
// Op min version requirements
if (auto minVersionIfx = dyn_cast<spirv::QueryMinVersionInterface>(op)) {
- Optional<spirv::Version> minVersion = minVersionIfx.getMinVersion();
+ std::optional<spirv::Version> minVersion = minVersionIfx.getMinVersion();
if (minVersion) {
deducedVersion = std::max(deducedVersion, *minVersion);
if (deducedVersion > allowedVersion) {
diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp
index 11bb980119e63..741a0a4fd5b90 100644
--- a/mlir/lib/IR/SymbolTable.cpp
+++ b/mlir/lib/IR/SymbolTable.cpp
@@ -733,14 +733,14 @@ static bool isReferencePrefixOf(SymbolRefAttr subRef, SymbolRefAttr ref) {
/// The implementation of SymbolTable::getSymbolUses below.
template <typename FromT>
-static Optional<SymbolTable::UseRange> getSymbolUsesImpl(FromT from) {
+static std::optional<SymbolTable::UseRange> getSymbolUsesImpl(FromT from) {
std::vector<SymbolTable::SymbolUse> uses;
auto walkFn = [&](SymbolTable::SymbolUse symbolUse) {
uses.push_back(symbolUse);
return WalkResult::advance();
};
auto result = walkSymbolUses(from, walkFn);
- return result ? Optional<SymbolTable::UseRange>(std::move(uses))
+ return result ? std::optional<SymbolTable::UseRange>(std::move(uses))
: std::nullopt;
}
@@ -751,10 +751,10 @@ static Optional<SymbolTable::UseRange> getSymbolUsesImpl(FromT from) {
/// boundary of the symbol table, and not the op itself. This function returns
/// std::nullopt if there are any unknown operations that may potentially be
/// symbol tables.
-auto SymbolTable::getSymbolUses(Operation *from) -> Optional<UseRange> {
+auto SymbolTable::getSymbolUses(Operation *from) -> std::optional<UseRange> {
return getSymbolUsesImpl(from);
}
-auto SymbolTable::getSymbolUses(Region *from) -> Optional<UseRange> {
+auto SymbolTable::getSymbolUses(Region *from) -> std::optional<UseRange> {
return getSymbolUsesImpl(MutableArrayRef<Region>(*from));
}
@@ -763,8 +763,8 @@ auto SymbolTable::getSymbolUses(Region *from) -> Optional<UseRange> {
/// The implementation of SymbolTable::getSymbolUses below.
template <typename SymbolT, typename IRUnitT>
-static Optional<SymbolTable::UseRange> getSymbolUsesImpl(SymbolT symbol,
- IRUnitT *limit) {
+static std::optional<SymbolTable::UseRange> getSymbolUsesImpl(SymbolT symbol,
+ IRUnitT *limit) {
std::vector<SymbolTable::SymbolUse> uses;
for (SymbolScope &scope : collectSymbolScopes(symbol, limit)) {
if (!scope.walk([&](SymbolTable::SymbolUse symbolUse) {
@@ -781,19 +781,19 @@ static Optional<SymbolTable::UseRange> getSymbolUsesImpl(SymbolT symbol,
/// traverse into any nested symbol tables. This function returns std::nullopt
/// if there are any unknown operations that may potentially be symbol tables.
auto SymbolTable::getSymbolUses(StringAttr symbol, Operation *from)
- -> Optional<UseRange> {
+ -> std::optional<UseRange> {
return getSymbolUsesImpl(symbol, from);
}
auto SymbolTable::getSymbolUses(Operation *symbol, Operation *from)
- -> Optional<UseRange> {
+ -> std::optional<UseRange> {
return getSymbolUsesImpl(symbol, from);
}
auto SymbolTable::getSymbolUses(StringAttr symbol, Region *from)
- -> Optional<UseRange> {
+ -> std::optional<UseRange> {
return getSymbolUsesImpl(symbol, from);
}
auto SymbolTable::getSymbolUses(Operation *symbol, Region *from)
- -> Optional<UseRange> {
+ -> std::optional<UseRange> {
return getSymbolUsesImpl(symbol, from);
}
diff --git a/mlir/lib/Transforms/SymbolDCE.cpp b/mlir/lib/Transforms/SymbolDCE.cpp
index bf85cecaa46e1..93d9a6547883a 100644
--- a/mlir/lib/Transforms/SymbolDCE.cpp
+++ b/mlir/lib/Transforms/SymbolDCE.cpp
@@ -120,7 +120,7 @@ LogicalResult SymbolDCE::computeLiveness(Operation *symbolTableOp,
}
// Collect the uses held by this operation.
- Optional<SymbolTable::UseRange> uses = SymbolTable::getSymbolUses(op);
+ std::optional<SymbolTable::UseRange> uses = SymbolTable::getSymbolUses(op);
if (!uses) {
return op->emitError()
<< "operation contains potentially unknown symbol table, "
diff --git a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
index 2c117a1a05372..fc01d5a708f0c 100644
--- a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
+++ b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
@@ -45,7 +45,7 @@ void PrintOpAvailability::runOnOperation() {
auto &os = llvm::outs();
if (auto minVersionIfx = dyn_cast<spirv::QueryMinVersionInterface>(op)) {
- Optional<spirv::Version> minVersion = minVersionIfx.getMinVersion();
+ std::optional<spirv::Version> minVersion = minVersionIfx.getMinVersion();
os << opName << " min version: ";
if (minVersion)
os << spirv::stringifyVersion(*minVersion) << "\n";
@@ -54,7 +54,7 @@ void PrintOpAvailability::runOnOperation() {
}
if (auto maxVersionIfx = dyn_cast<spirv::QueryMaxVersionInterface>(op)) {
- Optional<spirv::Version> maxVersion = maxVersionIfx.getMaxVersion();
+ std::optional<spirv::Version> maxVersion = maxVersionIfx.getMaxVersion();
os << opName << " max version: ";
if (maxVersion)
os << spirv::stringifyVersion(*maxVersion) << "\n";
diff --git a/mlir/test/lib/Dialect/Test/TestAttrDefs.td b/mlir/test/lib/Dialect/Test/TestAttrDefs.td
index 9c134e4f28415..f28afe4daf051 100644
--- a/mlir/test/lib/Dialect/Test/TestAttrDefs.td
+++ b/mlir/test/lib/Dialect/Test/TestAttrDefs.td
@@ -202,13 +202,13 @@ def TestAttrWithFormat : Test_Attr<"TestAttrWithFormat"> {
}
def TestAttrWithOptionalSigned : Test_Attr<"TestAttrWithOptionalSigned"> {
- let parameters = (ins OptionalParameter<"mlir::Optional<int64_t>">:$value);
+ let parameters = (ins OptionalParameter<"std::optional<int64_t>">:$value);
let assemblyFormat = "`<` $value `>`";
let mnemonic = "attr_with_optional_signed";
}
def TestAttrWithOptionalUnsigned : Test_Attr<"TestAttrWithOptionalUnsigned"> {
- let parameters = (ins OptionalParameter<"mlir::Optional<uint64_t>">:$value);
+ let parameters = (ins OptionalParameter<"std::optional<uint64_t>">:$value);
let assemblyFormat = "`<` $value `>`";
let mnemonic = "attr_with_optional_unsigned";
}
@@ -310,7 +310,7 @@ def TestArrayOfEnums : ArrayOfAttr<Test_Dialect, "ArrayOfEnums",
// Test custom directive as optional group anchor.
def TestCustomAnchor : Test_Attr<"TestCustomAnchor"> {
- let parameters = (ins "int":$a, OptionalParameter<"mlir::Optional<int>">:$b);
+ let parameters = (ins "int":$a, OptionalParameter<"std::optional<int>">:$b);
let mnemonic = "custom_anchor";
let assemblyFormat = "`<` $a (`>`) : (`,` custom<TrueFalse>($b)^ `>`)?";
}
diff --git a/mlir/test/lib/Dialect/Test/TestAttributes.cpp b/mlir/test/lib/Dialect/Test/TestAttributes.cpp
index 7b79ce67c5fb0..3123c11607eb2 100644
--- a/mlir/test/lib/Dialect/Test/TestAttributes.cpp
+++ b/mlir/test/lib/Dialect/Test/TestAttributes.cpp
@@ -165,15 +165,15 @@ ArrayRef<uint64_t> TestExtern1DI64ElementsAttr::getElements() const {
//===----------------------------------------------------------------------===//
static ParseResult parseTrueFalse(AsmParser &p,
- FailureOr<Optional<int>> &result) {
+ FailureOr<std::optional<int>> &result) {
bool b;
if (p.parseInteger(b))
return failure();
- result = Optional<int>(b);
+ result = std::optional<int>(b);
return success();
}
-static void printTrueFalse(AsmPrinter &p, Optional<int> result) {
+static void printTrueFalse(AsmPrinter &p, std::optional<int> result) {
p << (*result ? "true" : "false");
}
diff --git a/mlir/test/lib/IR/TestSymbolUses.cpp b/mlir/test/lib/IR/TestSymbolUses.cpp
index 9a3621f1f1b3b..d311f7ac8a899 100644
--- a/mlir/test/lib/IR/TestSymbolUses.cpp
+++ b/mlir/test/lib/IR/TestSymbolUses.cpp
@@ -26,7 +26,7 @@ struct SymbolUsesPass
WalkResult operateOnSymbol(Operation *symbol, ModuleOp module,
SmallVectorImpl<func::FuncOp> &deadFunctions) {
// Test computing uses on a non symboltable op.
- Optional<SymbolTable::UseRange> symbolUses =
+ std::optional<SymbolTable::UseRange> symbolUses =
SymbolTable::getSymbolUses(symbol);
// Test the conservative failure case.
More information about the Mlir-commits
mailing list