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; }]
>,
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; }]
>
/// 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);
uint32_t getBinding();
/// Returns `spirv::StorageClass`.
- Optional<StorageClass> getStorageClass();
+ std::optional<StorageClass> getStorageClass();
static LogicalResult verify(function_ref<InFlightDiagnostic()> emitError,
IntegerAttr descriptorSet, IntegerAttr binding,
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) `>`";
}
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.
: Availability {
let interfaceName = name;
- let queryFnRetType = "llvm::Optional<" # scheme.returnType # ">";
+ let queryFnRetType = "std::optional<" # scheme.returnType # ">";
let queryFnName = "getMinVersion";
let mergeAction = "{ "
: Availability {
let interfaceName = name;
- let queryFnRetType = "llvm::Optional<" # scheme.returnType # ">";
+ let queryFnRetType = "std::optional<" # scheme.returnType # ">";
let queryFnName = "getMaxVersion";
let mergeAction = "{ "
// 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<
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).
/// 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.
/// 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};
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);
/// 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
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
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));
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();
}
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();
}
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 =
<< " 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.
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);
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);
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());
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.
}
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(); \
}
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);
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);
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)) {
// 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 "
}
}
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 "
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) {
/// 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;
}
/// 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));
}
/// 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) {
/// 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);
}
}
// 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, "
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";
}
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";
}
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";
}
// 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)^ `>`)?";
}
//===----------------------------------------------------------------------===//
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");
}
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.