diff --git a/mlir/include/mlir/AsmParser/AsmParserState.h b/mlir/include/mlir/AsmParser/AsmParserState.h index 98bdc4696b84..e47cb32ee402 100644 --- a/mlir/include/mlir/AsmParser/AsmParserState.h +++ b/mlir/include/mlir/AsmParser/AsmParserState.h @@ -195,7 +195,7 @@ public: /// Finalize the most recently started operation definition. void finalizeOperationDefinition( Operation *op, SMRange nameLoc, SMLoc endLoc, - ArrayRef> resultGroups = std::nullopt); + ArrayRef> resultGroups = {}); /// Start a definition for a region nested under the current operation. void startRegionDefinition(); diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h index fc151d02ceef..48978eb7663d 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -94,7 +94,7 @@ bool isReductionIterator(utils::IteratorType iteratorType); /// ``` Value makeComposedPadHighOp(OpBuilder &b, Location loc, RankedTensorType type, Value source, Value padding, bool nofold, - ValueRange typeDynDims = std::nullopt); + ValueRange typeDynDims = {}); /// Returns GenericOp that copies an n-D memref. Unlike the current /// implementation of memref::CopyOp, this op can further tile, lower to loops diff --git a/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h b/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h index a1ce4e252c2f..da4c4ffb6d1b 100644 --- a/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h @@ -30,7 +30,7 @@ namespace tensor { // for _static_ dimensions. PadOp createPadHighOp(RankedTensorType resType, Value source, Value pad, bool nofold, Location loc, OpBuilder &builder, - ValueRange dynOutDims = std::nullopt); + ValueRange dynOutDims = {}); // Creates dim ops for each dynamic dimension of the ranked tensor argument and // returns these as values. diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h index 66f49c787c19..96ccebcd5685 100644 --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -157,8 +157,7 @@ public: /// Invokes the function with the given name passing it the list of opaque /// pointers to the actual arguments. - llvm::Error invokePacked(StringRef name, - MutableArrayRef args = std::nullopt); + llvm::Error invokePacked(StringRef name, MutableArrayRef args = {}); /// Trait that defines how a given type is passed to the JIT code. This /// defaults to passing the address but can be specialized. diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h index 41434269d555..f9fbef2f3753 100644 --- a/mlir/include/mlir/IR/BlockSupport.h +++ b/mlir/include/mlir/IR/BlockSupport.h @@ -106,7 +106,7 @@ class BlockRange final Block *, Block *, Block *> { public: using RangeBaseT::RangeBaseT; - BlockRange(ArrayRef blocks = std::nullopt); + BlockRange(ArrayRef blocks = {}); BlockRange(SuccessorRange successors); template , Arg>::value>> diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index d68dbdb1efee..ad59ea63a690 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -454,15 +454,14 @@ public: /// 'parent'. `locs` contains the locations of the inserted arguments, and /// should match the size of `argTypes`. Block *createBlock(Region *parent, Region::iterator insertPt = {}, - TypeRange argTypes = std::nullopt, - ArrayRef locs = std::nullopt); + TypeRange argTypes = {}, ArrayRef locs = {}); /// Add new block with 'argTypes' arguments and set the insertion point to the /// end of it. The block is placed before 'insertBefore'. `locs` contains the /// locations of the inserted arguments, and should match the size of /// `argTypes`. - Block *createBlock(Block *insertBefore, TypeRange argTypes = std::nullopt, - ArrayRef locs = std::nullopt); + Block *createBlock(Block *insertBefore, TypeRange argTypes = {}, + ArrayRef locs = {}); //===--------------------------------------------------------------------===// // Operation Creation diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td index 771de01fc8d5..d5663bcbf6a5 100644 --- a/mlir/include/mlir/IR/BuiltinTypes.td +++ b/mlir/include/mlir/IR/BuiltinTypes.td @@ -1200,7 +1200,7 @@ def Builtin_UnrankedMemRef : Builtin_Type<"UnrankedMemRef", "unranked_memref", [ using ShapedType::Trait::getDimSize; using ShapedType::Trait::getDynamicDimIndex; - ArrayRef getShape() const { return std::nullopt; } + ArrayRef getShape() const { return {}; } /// [deprecated] Returns the memory space in old raw integer representation. /// New `Attribute getMemorySpace()` method should be used instead. @@ -1259,7 +1259,7 @@ def Builtin_UnrankedTensor : Builtin_Type<"UnrankedTensor", "unranked_tensor", [ using ShapedType::Trait::getDimSize; using ShapedType::Trait::getDynamicDimIndex; - ArrayRef getShape() const { return std::nullopt; } + ArrayRef getShape() const { return {}; } }]; let skipDefaultBuilders = 1; let genVerifyDecl = 1; diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index 10cfe851765d..b6659a7f915c 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -520,7 +520,7 @@ public: /// unreachable operations. virtual void inlineBlockBefore(Block *source, Block *dest, Block::iterator before, - ValueRange argValues = std::nullopt); + ValueRange argValues = {}); /// Inline the operations of block 'source' before the operation 'op'. The /// source block will be deleted and must have no uses. 'argValues' is used to @@ -529,7 +529,7 @@ public: /// The source block must have no successors. Otherwise, the resulting IR /// would have unreachable operations. void inlineBlockBefore(Block *source, Operation *op, - ValueRange argValues = std::nullopt); + ValueRange argValues = {}); /// Inline the operations of block 'source' into the end of block 'dest'. The /// source block will be deleted and must have no uses. 'argValues' is used to @@ -537,8 +537,7 @@ public: /// /// The dest block must have no successors. Otherwise, the resulting IR would /// have unreachable operation. - void mergeBlocks(Block *source, Block *dest, - ValueRange argValues = std::nullopt); + void mergeBlocks(Block *source, Block *dest, ValueRange argValues = {}); /// Split the operations starting at "before" (inclusive) out of the given /// block into a new block, and return it. diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h index 22cb7037772d..1fcb31675023 100644 --- a/mlir/include/mlir/IR/Region.h +++ b/mlir/include/mlir/IR/Region.h @@ -353,7 +353,7 @@ class RegionRange public: using RangeBaseT::RangeBaseT; - RegionRange(MutableArrayRef regions = std::nullopt); + RegionRange(MutableArrayRef regions = {}); template >, Arg>::value>> diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h index 557a2ba85cd6..e4622354b898 100644 --- a/mlir/include/mlir/IR/SymbolTable.h +++ b/mlir/include/mlir/IR/SymbolTable.h @@ -411,7 +411,8 @@ public: /// Return the users of the provided symbol operation. ArrayRef getUsers(Operation *symbol) const { auto it = symbolToUsers.find(symbol); - return it != symbolToUsers.end() ? it->second.getArrayRef() : std::nullopt; + return it != symbolToUsers.end() ? it->second.getArrayRef() + : ArrayRef(); } /// Return true if the given symbol has no uses. diff --git a/mlir/include/mlir/IR/TypeRange.h b/mlir/include/mlir/IR/TypeRange.h index e098370ae6e5..c6cbf3461bcd 100644 --- a/mlir/include/mlir/IR/TypeRange.h +++ b/mlir/include/mlir/IR/TypeRange.h @@ -37,7 +37,7 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base< Type, Type, Type> { public: using RangeBaseT::RangeBaseT; - TypeRange(ArrayRef types = std::nullopt); + TypeRange(ArrayRef types = {}); explicit TypeRange(OperandRange values); explicit TypeRange(ResultRange values); explicit TypeRange(ValueRange values); diff --git a/mlir/include/mlir/IR/ValueRange.h b/mlir/include/mlir/IR/ValueRange.h index 0c33e2b596b9..f04ed0544c0f 100644 --- a/mlir/include/mlir/IR/ValueRange.h +++ b/mlir/include/mlir/IR/ValueRange.h @@ -126,7 +126,7 @@ public: /// and range length. `operandSegments` is an optional set of operand segments /// to be updated when mutating the operand list. MutableOperandRange(Operation *owner, unsigned start, unsigned length, - ArrayRef operandSegments = std::nullopt); + ArrayRef operandSegments = {}); MutableOperandRange(Operation *owner); /// Construct a new mutable range for the given OpOperand. @@ -409,7 +409,7 @@ public: : ValueRange(ResultRange(values)) {} ValueRange(ArrayRef values) : ValueRange(ArrayRef(values.data(), values.size())) {} - ValueRange(ArrayRef values = std::nullopt); + ValueRange(ArrayRef values = {}); ValueRange(OperandRange values); ValueRange(ResultRange values); diff --git a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h index 4c6e3cd9ce6f..d6c431206e06 100644 --- a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h +++ b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h @@ -47,10 +47,9 @@ public: /// `RewritePatternSet::addWithLabel`. Debug names may be empty, but patterns /// created with `RewritePattern::create` have their default debug name set to /// their type name. - FrozenRewritePatternSet( - RewritePatternSet &&patterns, - ArrayRef disabledPatternLabels = std::nullopt, - ArrayRef enabledPatternLabels = std::nullopt); + FrozenRewritePatternSet(RewritePatternSet &&patterns, + ArrayRef disabledPatternLabels = {}, + ArrayRef enabledPatternLabels = {}); /// Return the op specific native patterns held by this list. const OpSpecificNativePatternListT &getOpSpecificNativePatterns() const { diff --git a/mlir/include/mlir/Tools/PDLL/AST/Types.h b/mlir/include/mlir/Tools/PDLL/AST/Types.h index 57161db5fdba..538ea7c61b44 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Types.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Types.h @@ -226,8 +226,7 @@ public: /// Return an instance of the Tuple type. static TupleType get(Context &context, ArrayRef elementTypes, ArrayRef elementNames); - static TupleType get(Context &context, - ArrayRef elementTypes = std::nullopt); + static TupleType get(Context &context, ArrayRef elementTypes = {}); /// Return the element types of this tuple. ArrayRef getElementTypes() const; diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index e7d05c3ce1ad..5a5f116073a9 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -826,7 +826,7 @@ public: /// PatternRewriter hook for inlining the ops of a block into another block. void inlineBlockBefore(Block *source, Block *dest, Block::iterator before, - ValueRange argValues = std::nullopt) override; + ValueRange argValues = {}) override; using PatternRewriter::inlineBlockBefore; /// PatternRewriter hook for updating the given operation in-place. diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h index 41f208216374..9cd2ef34e15e 100644 --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -62,8 +62,8 @@ std::unique_ptr createCanonicalizerPass(); /// set to their type name. std::unique_ptr createCanonicalizerPass(const GreedyRewriteConfig &config, - ArrayRef disabledPatterns = std::nullopt, - ArrayRef enabledPatterns = std::nullopt); + ArrayRef disabledPatterns = {}, + ArrayRef enabledPatterns = {}); /// Creates a pass to perform control-flow sinking. std::unique_ptr createControlFlowSinkPass(); diff --git a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp index a64dc7f74a19..695d43b04cff 100644 --- a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp @@ -55,7 +55,7 @@ static bool isInsideLaunch(Operation *op) { static std::tuple> getFlatOffsetAndStrides(OpBuilder &rewriter, Location loc, Value source, ArrayRef subOffsets, - ArrayRef subStrides = std::nullopt) { + ArrayRef subStrides = {}) { auto sourceType = cast(source.getType()); auto sourceRank = static_cast(sourceType.getRank()); diff --git a/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h b/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h index 8767b1c3ffc5..081a89d0b5dc 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h +++ b/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h @@ -69,7 +69,7 @@ public: class Key { public: /// Constructs a key for an identified struct. - Key(StringRef name, bool opaque, ArrayRef types = std::nullopt) + Key(StringRef name, bool opaque, ArrayRef types = {}) : types(types), name(name), identified(true), packed(false), opaque(opaque) {} /// Constructs a key for a literal struct. diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp index 779dcfe7b666..01191aa82444 100644 --- a/mlir/lib/Pass/PassStatistics.cpp +++ b/mlir/lib/Pass/PassStatistics.cpp @@ -27,7 +27,7 @@ struct Statistic { /// Utility to print a pass entry in the statistics output. static void printPassEntry(raw_ostream &os, unsigned indent, StringRef pass, - MutableArrayRef stats = std::nullopt) { + MutableArrayRef stats = {}) { os.indent(indent) << pass << "\n"; if (stats.empty()) return; diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp index 18ee9d71cb9f..6ea74a988ca8 100644 --- a/mlir/unittests/IR/OperationSupportTest.cpp +++ b/mlir/unittests/IR/OperationSupportTest.cpp @@ -18,9 +18,8 @@ using namespace mlir; using namespace mlir::detail; -static Operation *createOp(MLIRContext *context, - ArrayRef operands = std::nullopt, - ArrayRef resultTypes = std::nullopt, +static Operation *createOp(MLIRContext *context, ArrayRef operands = {}, + ArrayRef resultTypes = {}, unsigned int numRegions = 0) { context->allowUnregisteredDialects(); return Operation::create( diff --git a/mlir/unittests/IR/ValueTest.cpp b/mlir/unittests/IR/ValueTest.cpp index 1a84b7ca13df..58678224780b 100644 --- a/mlir/unittests/IR/ValueTest.cpp +++ b/mlir/unittests/IR/ValueTest.cpp @@ -16,9 +16,8 @@ using namespace mlir; -static Operation *createOp(MLIRContext *context, - ArrayRef operands = std::nullopt, - ArrayRef resultTypes = std::nullopt, +static Operation *createOp(MLIRContext *context, ArrayRef operands = {}, + ArrayRef resultTypes = {}, unsigned int numRegions = 0) { context->allowUnregisteredDialects(); return Operation::create(