[Mlir-commits] [mlir] [mlir] Use {} instead of std::nullopt to initialize empty ArrayRef (PR #109527)
Jay Foad
llvmlistbot at llvm.org
Tue Nov 19 06:01:46 PST 2024
https://github.com/jayfoad updated https://github.com/llvm/llvm-project/pull/109527
>From 4651b6857f4bdcdab15e2a3d29f818f682efbb76 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Sat, 21 Sep 2024 10:05:25 +0100
Subject: [PATCH 1/2] [mlir] Use {} instead of std::nullopt to initialize empty
ArrayRef
Follow up to #109133.
---
mlir/include/mlir/AsmParser/AsmParserState.h | 2 +-
mlir/include/mlir/CAPI/Wrap.h | 2 +-
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 2 +-
mlir/include/mlir/Dialect/PDL/IR/PDLOps.td | 2 +-
.../mlir/ExecutionEngine/ExecutionEngine.h | 2 +-
mlir/include/mlir/IR/BlockSupport.h | 2 +-
mlir/include/mlir/IR/Builders.h | 4 ++--
mlir/include/mlir/IR/BuiltinAttributes.td | 2 +-
mlir/include/mlir/IR/BuiltinTypes.td | 4 ++--
mlir/include/mlir/IR/Matchers.h | 2 +-
mlir/include/mlir/IR/PatternMatch.h | 4 ++--
mlir/include/mlir/IR/Region.h | 2 +-
mlir/include/mlir/IR/SymbolTable.h | 2 +-
mlir/include/mlir/IR/TypeRange.h | 4 +++-
mlir/include/mlir/IR/ValueRange.h | 5 +++--
.../mlir/Rewrite/FrozenRewritePatternSet.h | 4 ++--
mlir/include/mlir/Support/StorageUniquer.h | 2 +-
mlir/include/mlir/Tools/PDLL/AST/Nodes.h | 2 +-
mlir/include/mlir/Tools/PDLL/AST/Types.h | 2 +-
mlir/include/mlir/Transforms/Passes.h | 4 ++--
.../PDLToPDLInterp/PDLToPDLInterp.cpp | 2 +-
.../Conversion/TosaToLinalg/TosaToLinalg.cpp | 14 ++++++-------
mlir/lib/Dialect/Async/IR/Async.cpp | 2 +-
mlir/lib/Dialect/EmitC/IR/EmitC.cpp | 2 +-
mlir/lib/Dialect/Func/IR/FuncOps.cpp | 2 +-
.../GPU/Transforms/DecomposeMemRefs.cpp | 4 ++--
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 2 +-
mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h | 2 +-
mlir/lib/Dialect/Shape/IR/Shape.cpp | 2 +-
mlir/lib/IR/Diagnostics.cpp | 2 +-
mlir/lib/Interfaces/FunctionInterfaces.cpp | 4 ++--
mlir/lib/Pass/PassStatistics.cpp | 2 +-
mlir/lib/Reducer/Tester.cpp | 2 +-
.../LLVMIR/LoopAnnotationTranslation.cpp | 2 +-
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 2 +-
mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp | 2 +-
mlir/lib/Tools/PDLL/Parser/Parser.cpp | 10 +++++-----
.../Tools/mlir-pdll-lsp-server/PDLLServer.cpp | 4 ++--
mlir/test/lib/Dialect/Test/TestAttributes.cpp | 2 +-
mlir/test/lib/Dialect/Test/TestPatterns.cpp | 4 ++--
.../FileLineColLocBreakpointManagerTest.cpp | 2 +-
mlir/unittests/IR/OperationSupportTest.cpp | 20 +++++++++----------
.../Transforms/DialectConversion.cpp | 2 +-
43 files changed, 75 insertions(+), 72 deletions(-)
diff --git a/mlir/include/mlir/AsmParser/AsmParserState.h b/mlir/include/mlir/AsmParser/AsmParserState.h
index 98bdc4696b846b..e47cb32ee4027f 100644
--- a/mlir/include/mlir/AsmParser/AsmParserState.h
+++ b/mlir/include/mlir/AsmParser/AsmParserState.h
@@ -195,7 +195,7 @@ class AsmParserState {
/// Finalize the most recently started operation definition.
void finalizeOperationDefinition(
Operation *op, SMRange nameLoc, SMLoc endLoc,
- ArrayRef<std::pair<unsigned, SMLoc>> resultGroups = std::nullopt);
+ ArrayRef<std::pair<unsigned, SMLoc>> resultGroups = {});
/// Start a definition for a region nested under the current operation.
void startRegionDefinition();
diff --git a/mlir/include/mlir/CAPI/Wrap.h b/mlir/include/mlir/CAPI/Wrap.h
index 5b68f417a3df4e..fd5b6e18d49520 100644
--- a/mlir/include/mlir/CAPI/Wrap.h
+++ b/mlir/include/mlir/CAPI/Wrap.h
@@ -44,7 +44,7 @@ static llvm::ArrayRef<CppTy> unwrapList(size_t size, CTy *first,
"incompatible C and C++ types");
if (size == 0)
- return std::nullopt;
+ return {};
assert(storage.empty() && "expected to populate storage");
storage.reserve(size);
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 8584a25f8b3d6c..18dbdba746269e 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -371,7 +371,7 @@ def LLVM_LoadOp : LLVM_MemAccessOpBase<"load",
auto *inst = builder.CreateLoad($_resultType, $addr, $volatile_);
$res = inst;
if ($invariant) {
- llvm::MDNode *metadata = llvm::MDNode::get(inst->getContext(), std::nullopt);
+ llvm::MDNode *metadata = llvm::MDNode::get(inst->getContext(), {});
inst->setMetadata(llvm::LLVMContext::MD_invariant_load, metadata);
}
}] # setOrderingCode
diff --git a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
index 1e108c3d8ac77a..22d905ebb0a406 100644
--- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
+++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
@@ -363,7 +363,7 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> {
let builders = [
OpBuilder<(ins CArg<"std::optional<StringRef>", "std::nullopt">:$name,
CArg<"ValueRange", "std::nullopt">:$operandValues,
- CArg<"ArrayRef<StringRef>", "std::nullopt">:$attrNames,
+ CArg<"ArrayRef<StringRef>", "{}">:$attrNames,
CArg<"ValueRange", "std::nullopt">:$attrValues,
CArg<"ValueRange", "std::nullopt">:$resultTypes), [{
auto nameAttr = name ? $_builder.getStringAttr(*name) : StringAttr();
diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
index 66f49c787c1905..594cee107790f8 100644
--- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
+++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
@@ -158,7 +158,7 @@ class ExecutionEngine {
/// Invokes the function with the given name passing it the list of opaque
/// pointers to the actual arguments.
llvm::Error invokePacked(StringRef name,
- MutableArrayRef<void *> args = std::nullopt);
+ MutableArrayRef<void *> 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 ff508891ac2ffc..c8a70a5a1d9593 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<Block *> blocks = std::nullopt);
+ BlockRange(ArrayRef<Block *> blocks = {});
BlockRange(SuccessorRange successors);
template <typename Arg, typename = std::enable_if_t<std::is_constructible<
ArrayRef<Block *>, Arg>::value>>
diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 196d34e12d9b28..c2bfe84d5093fa 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -463,14 +463,14 @@ class OpBuilder : public Builder {
/// should match the size of `argTypes`.
Block *createBlock(Region *parent, Region::iterator insertPt = {},
TypeRange argTypes = std::nullopt,
- ArrayRef<Location> locs = std::nullopt);
+ ArrayRef<Location> 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<Location> locs = std::nullopt);
+ ArrayRef<Location> locs = {});
//===--------------------------------------------------------------------===//
// Operation Creation
diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td
index f0d41754001400..9aa46b978cb03e 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.td
+++ b/mlir/include/mlir/IR/BuiltinAttributes.td
@@ -516,7 +516,7 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", "dictionary"> {
}];
let parameters = (ins ArrayRefParameter<"NamedAttribute", "">:$value);
let builders = [
- AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "std::nullopt">:$value)>
+ AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "{}">:$value)>
];
let extraClassDeclaration = [{
using ValueType = ArrayRef<NamedAttribute>;
diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td
index c283c20f36e91e..40894236d3242d 100644
--- a/mlir/include/mlir/IR/BuiltinTypes.td
+++ b/mlir/include/mlir/IR/BuiltinTypes.td
@@ -1070,7 +1070,7 @@ def Builtin_UnrankedMemRef : Builtin_Type<"UnrankedMemRef", "unranked_memref", [
using ShapedType::Trait<UnrankedMemRefType>::getDimSize;
using ShapedType::Trait<UnrankedMemRefType>::getDynamicDimIndex;
- ArrayRef<int64_t> getShape() const { return std::nullopt; }
+ ArrayRef<int64_t> getShape() const { return {}; }
/// [deprecated] Returns the memory space in old raw integer representation.
/// New `Attribute getMemorySpace()` method should be used instead.
@@ -1129,7 +1129,7 @@ def Builtin_UnrankedTensor : Builtin_Type<"UnrankedTensor", "unranked_tensor", [
using ShapedType::Trait<UnrankedTensorType>::getDimSize;
using ShapedType::Trait<UnrankedTensorType>::getDynamicDimIndex;
- ArrayRef<int64_t> getShape() const { return std::nullopt; }
+ ArrayRef<int64_t> getShape() const { return {}; }
}];
let skipDefaultBuilders = 1;
let genVerifyDecl = 1;
diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h
index 6fa5a47109d20d..41a8ce2d58cb9a 100644
--- a/mlir/include/mlir/IR/Matchers.h
+++ b/mlir/include/mlir/IR/Matchers.h
@@ -88,7 +88,7 @@ struct constant_op_binder {
// Fold the constant to an attribute.
SmallVector<OpFoldResult, 1> foldedOp;
- LogicalResult result = op->fold(/*operands=*/std::nullopt, foldedOp);
+ LogicalResult result = op->fold(/*operands=*/{}, foldedOp);
(void)result;
assert(succeeded(result) && "expected ConstantLike op to be foldable");
diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 896fdf1c899e3d..2ae25449480da7 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -847,7 +847,7 @@ class RewritePatternSet {
RewritePatternSet &add(ConstructorArg &&arg, ConstructorArgs &&...args) {
// The following expands a call to emplace_back for each of the pattern
// types 'Ts'.
- (addImpl<Ts>(/*debugLabels=*/std::nullopt,
+ (addImpl<Ts>(/*debugLabels=*/{},
std::forward<ConstructorArg>(arg),
std::forward<ConstructorArgs>(args)...),
...);
@@ -931,7 +931,7 @@ class RewritePatternSet {
RewritePatternSet &insert(ConstructorArg &&arg, ConstructorArgs &&...args) {
// The following expands a call to emplace_back for each of the pattern
// types 'Ts'.
- (addImpl<Ts>(/*debugLabels=*/std::nullopt, arg, args...), ...);
+ (addImpl<Ts>(/*debugLabels=*/{}, arg, args...), ...);
return *this;
}
diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h
index 93fc9dbb430eec..cfcd920b33460e 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<Region> regions = std::nullopt);
+ RegionRange(MutableArrayRef<Region> regions = {});
template <typename Arg, typename = std::enable_if_t<std::is_constructible<
ArrayRef<std::unique_ptr<Region>>, Arg>::value>>
diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h
index 597c6a9a1d8910..090b01a324581d 100644
--- a/mlir/include/mlir/IR/SymbolTable.h
+++ b/mlir/include/mlir/IR/SymbolTable.h
@@ -395,7 +395,7 @@ class SymbolUserMap {
/// Return the users of the provided symbol operation.
ArrayRef<Operation *> 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<Operation *>();
}
/// 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 99fabab334f922..424366d6a5a8d5 100644
--- a/mlir/include/mlir/IR/TypeRange.h
+++ b/mlir/include/mlir/IR/TypeRange.h
@@ -36,7 +36,7 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base<
Type, Type, Type> {
public:
using RangeBaseT::RangeBaseT;
- TypeRange(ArrayRef<Type> types = std::nullopt);
+ TypeRange(ArrayRef<Type> types = {});
explicit TypeRange(OperandRange values);
explicit TypeRange(ResultRange values);
explicit TypeRange(ValueRange values);
@@ -47,6 +47,8 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base<
template <typename Arg, typename = std::enable_if_t<std::is_constructible<
ArrayRef<Type>, Arg>::value>>
TypeRange(Arg &&arg) : TypeRange(ArrayRef<Type>(std::forward<Arg>(arg))) {}
+ TypeRange(std::nullopt_t)
+ : TypeRange(ArrayRef<Type>()) {}
TypeRange(std::initializer_list<Type> types)
: TypeRange(ArrayRef<Type>(types)) {}
diff --git a/mlir/include/mlir/IR/ValueRange.h b/mlir/include/mlir/IR/ValueRange.h
index 4b421c08d8418e..b934622fa80c1d 100644
--- a/mlir/include/mlir/IR/ValueRange.h
+++ b/mlir/include/mlir/IR/ValueRange.h
@@ -123,7 +123,7 @@ class MutableOperandRange {
/// 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<OperandSegment> operandSegments = std::nullopt);
+ ArrayRef<OperandSegment> operandSegments = {});
MutableOperandRange(Operation *owner);
/// Construct a new mutable range for the given OpOperand.
@@ -392,6 +392,7 @@ class ValueRange final
std::is_constructible<ArrayRef<Value>, Arg>::value &&
!std::is_convertible<Arg, Value>::value>>
ValueRange(Arg &&arg) : ValueRange(ArrayRef<Value>(std::forward<Arg>(arg))) {}
+ ValueRange(std::nullopt_t) : ValueRange(ArrayRef<Value>()) {}
ValueRange(const Value &value) : ValueRange(&value, /*count=*/1) {}
ValueRange(const std::initializer_list<Value> &values)
: ValueRange(ArrayRef<Value>(values)) {}
@@ -401,7 +402,7 @@ class ValueRange final
: ValueRange(ResultRange(values)) {}
ValueRange(ArrayRef<BlockArgument> values)
: ValueRange(ArrayRef<Value>(values.data(), values.size())) {}
- ValueRange(ArrayRef<Value> values = std::nullopt);
+ ValueRange(ArrayRef<Value> values = {});
ValueRange(OperandRange values);
ValueRange(ResultRange values);
diff --git a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h
index 4c6e3cd9ce6f4c..aeec4e875f4b2c 100644
--- a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h
+++ b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h
@@ -49,8 +49,8 @@ class FrozenRewritePatternSet {
/// their type name.
FrozenRewritePatternSet(
RewritePatternSet &&patterns,
- ArrayRef<std::string> disabledPatternLabels = std::nullopt,
- ArrayRef<std::string> enabledPatternLabels = std::nullopt);
+ ArrayRef<std::string> disabledPatternLabels = {},
+ ArrayRef<std::string> enabledPatternLabels = {});
/// Return the op specific native patterns held by this list.
const OpSpecificNativePatternListT &getOpSpecificNativePatterns() const {
diff --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h
index 26bdf09abba21c..1a89081074ec12 100644
--- a/mlir/include/mlir/Support/StorageUniquer.h
+++ b/mlir/include/mlir/Support/StorageUniquer.h
@@ -97,7 +97,7 @@ class StorageUniquer {
template <typename T>
ArrayRef<T> copyInto(ArrayRef<T> elements) {
if (elements.empty())
- return std::nullopt;
+ return {};
auto result = allocator.Allocate<T>(elements.size());
std::uninitialized_copy(elements.begin(), elements.end(), result);
return ArrayRef<T>(result, elements.size());
diff --git a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h
index aed2562e4d30dd..49b596e47c61d5 100644
--- a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h
+++ b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h
@@ -897,7 +897,7 @@ class UserConstraintDecl final
ArrayRef<VariableDecl *> results,
const CompoundStmt *body,
Type resultType) {
- return createImpl(ctx, name, inputs, /*nativeInputTypes=*/std::nullopt,
+ return createImpl(ctx, name, inputs, /*nativeInputTypes=*/{},
results, /*codeBlock=*/std::nullopt, body, resultType);
}
diff --git a/mlir/include/mlir/Tools/PDLL/AST/Types.h b/mlir/include/mlir/Tools/PDLL/AST/Types.h
index 89c8e193ddc32b..620351f737129e 100644
--- a/mlir/include/mlir/Tools/PDLL/AST/Types.h
+++ b/mlir/include/mlir/Tools/PDLL/AST/Types.h
@@ -254,7 +254,7 @@ class TupleType : public Type::TypeBase<detail::TupleTypeStorage> {
static TupleType get(Context &context, ArrayRef<Type> elementTypes,
ArrayRef<StringRef> elementNames);
static TupleType get(Context &context,
- ArrayRef<Type> elementTypes = std::nullopt);
+ ArrayRef<Type> elementTypes = {});
/// Return the element types of this tuple.
ArrayRef<Type> getElementTypes() const;
diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h
index 8e4a43c3f24586..b0afc7b16fc41f 100644
--- a/mlir/include/mlir/Transforms/Passes.h
+++ b/mlir/include/mlir/Transforms/Passes.h
@@ -61,8 +61,8 @@ std::unique_ptr<Pass> createCanonicalizerPass();
/// set to their type name.
std::unique_ptr<Pass>
createCanonicalizerPass(const GreedyRewriteConfig &config,
- ArrayRef<std::string> disabledPatterns = std::nullopt,
- ArrayRef<std::string> enabledPatterns = std::nullopt);
+ ArrayRef<std::string> disabledPatterns = {},
+ ArrayRef<std::string> enabledPatterns = {});
/// Creates a pass to perform control-flow sinking.
std::unique_ptr<Pass> createControlFlowSinkPass();
diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
index b00cd0dee3ae80..cb10671ac5b798 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
@@ -991,7 +991,7 @@ void PDLToPDLInterpPass::runOnOperation() {
module.getLoc(), pdl_interp::PDLInterpDialect::getMatcherFunctionName(),
builder.getFunctionType(builder.getType<pdl::OperationType>(),
/*results=*/std::nullopt),
- /*attrs=*/std::nullopt);
+ /*attrs=*/ArrayRef<NamedAttribute>());
// Create a nested module to hold the functions invoked for rewriting the IR
// after a successful match.
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index 93e284af051883..07801057611697 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -250,7 +250,7 @@ static Value createLinalgBodyCalculationForElementwiseOp(
rewriter.create<arith::ShRSIOp>(loc, resultTypes, args[0], subtract)
->getResults();
auto truncated =
- rewriter.create<arith::TruncIOp>(loc, i1Ty, shifted, std::nullopt);
+ rewriter.create<arith::TruncIOp>(loc, i1Ty, shifted, llvm::ArrayRef<NamedAttribute>());
auto isInputOdd =
rewriter.create<arith::AndIOp>(loc, i1Ty, truncated, i1one);
@@ -453,20 +453,20 @@ static Value createLinalgBodyCalculationForElementwiseOp(
if (isa<FloatType>(srcTy) && isa<FloatType>(dstTy) && bitExtend)
return rewriter.create<arith::ExtFOp>(loc, resultTypes, args,
- std::nullopt);
+ llvm::ArrayRef<NamedAttribute>());
if (isa<FloatType>(srcTy) && isa<FloatType>(dstTy) && !bitExtend)
return rewriter.create<arith::TruncFOp>(loc, resultTypes, args,
- std::nullopt);
+ llvm::ArrayRef<NamedAttribute>());
// 1-bit integers need to be treated as signless.
if (srcTy.isInteger(1) && arith::UIToFPOp::areCastCompatible(srcTy, dstTy))
return rewriter.create<arith::UIToFPOp>(loc, resultTypes, args,
- std::nullopt);
+ llvm::ArrayRef<NamedAttribute>());
if (srcTy.isInteger(1) && isa<IntegerType>(dstTy) && bitExtend)
return rewriter.create<arith::ExtUIOp>(loc, resultTypes, args,
- std::nullopt);
+ llvm::ArrayRef<NamedAttribute>());
// Unsigned integers need an unrealized cast so that they can be passed
// to UIToFP.
@@ -484,7 +484,7 @@ static Value createLinalgBodyCalculationForElementwiseOp(
// All other si-to-fp conversions should be handled by SIToFP.
if (arith::SIToFPOp::areCastCompatible(srcTy, dstTy))
return rewriter.create<arith::SIToFPOp>(loc, resultTypes, args,
- std::nullopt);
+ llvm::ArrayRef<NamedAttribute>());
// Casting to boolean, floats need to only be checked as not-equal to zero.
if (isa<FloatType>(srcTy) && dstTy.isInteger(1)) {
@@ -590,7 +590,7 @@ static Value createLinalgBodyCalculationForElementwiseOp(
if (isa<IntegerType>(srcTy) && isa<IntegerType>(dstTy) && bitExtend)
return rewriter.create<arith::ExtSIOp>(loc, resultTypes, args,
- std::nullopt);
+ llvm::ArrayRef<NamedAttribute>());
if (isa<IntegerType>(srcTy) && isa<IntegerType>(dstTy) && !bitExtend) {
return rewriter.create<arith::TruncIOp>(loc, dstTy, args[0]);
diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp
index a3e3f80954efce..fda8516a15c398 100644
--- a/mlir/lib/Dialect/Async/IR/Async.cpp
+++ b/mlir/lib/Dialect/Async/IR/Async.cpp
@@ -309,7 +309,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name,
return;
assert(type.getNumInputs() == argAttrs.size());
function_interface_impl::addArgAndResultAttrs(
- builder, state, argAttrs, /*resultAttrs=*/std::nullopt,
+ builder, state, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name));
}
diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
index fdc21d6c6e24b9..17afc274e07a2c 100644
--- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
+++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
@@ -530,7 +530,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name,
return;
assert(type.getNumInputs() == argAttrs.size());
function_interface_impl::addArgAndResultAttrs(
- builder, state, argAttrs, /*resultAttrs=*/std::nullopt,
+ builder, state, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name));
}
diff --git a/mlir/lib/Dialect/Func/IR/FuncOps.cpp b/mlir/lib/Dialect/Func/IR/FuncOps.cpp
index a490b4c3c4ab43..3037735d30c3bd 100644
--- a/mlir/lib/Dialect/Func/IR/FuncOps.cpp
+++ b/mlir/lib/Dialect/Func/IR/FuncOps.cpp
@@ -191,7 +191,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name,
return;
assert(type.getNumInputs() == argAttrs.size());
function_interface_impl::addArgAndResultAttrs(
- builder, state, argAttrs, /*resultAttrs=*/std::nullopt,
+ builder, state, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name));
}
diff --git a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp
index 2b2d10a7733ece..7199aa2a41e80a 100644
--- a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp
@@ -44,7 +44,7 @@ static bool isInsideLaunch(Operation *op) {
static std::tuple<Value, OpFoldResult, SmallVector<OpFoldResult>>
getFlatOffsetAndStrides(OpBuilder &rewriter, Location loc, Value source,
ArrayRef<OpFoldResult> subOffsets,
- ArrayRef<OpFoldResult> subStrides = std::nullopt) {
+ ArrayRef<OpFoldResult> subStrides = {}) {
auto sourceType = cast<MemRefType>(source.getType());
auto sourceRank = static_cast<unsigned>(sourceType.getRank());
@@ -100,7 +100,7 @@ static Value getFlatMemref(OpBuilder &rewriter, Location loc, Value source,
getFlatOffsetAndStrides(rewriter, loc, source, offsetsTemp);
auto retType = cast<MemRefType>(base.getType());
return rewriter.create<memref::ReinterpretCastOp>(loc, retType, base, offset,
- std::nullopt, std::nullopt);
+ llvm::ArrayRef<OpFoldResult>(), llvm::ArrayRef<OpFoldResult>());
}
static bool needFlatten(Value val) {
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 205d7494d4378c..964a16ec3841be 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -2304,7 +2304,7 @@ void LLVMFuncOp::build(OpBuilder &builder, OperationState &result,
assert(llvm::cast<LLVMFunctionType>(type).getNumParams() == argAttrs.size() &&
"expected as many argument attribute lists as arguments");
function_interface_impl::addArgAndResultAttrs(
- builder, result, argAttrs, /*resultAttrs=*/std::nullopt,
+ builder, result, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(result.name), getResAttrsAttrName(result.name));
}
diff --git a/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h b/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h
index 8767b1c3ffc5bd..081a89d0b5dc7b 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h
+++ b/mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h
@@ -69,7 +69,7 @@ struct LLVMStructTypeStorage : public TypeStorage {
class Key {
public:
/// Constructs a key for an identified struct.
- Key(StringRef name, bool opaque, ArrayRef<Type> types = std::nullopt)
+ Key(StringRef name, bool opaque, ArrayRef<Type> types = {})
: types(types), name(name), identified(true), packed(false),
opaque(opaque) {}
/// Constructs a key for a literal struct.
diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp
index 8eb8e579954faa..0aaa657ef2e16a 100644
--- a/mlir/lib/Dialect/Shape/IR/Shape.cpp
+++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp
@@ -1290,7 +1290,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name,
return;
assert(type.getNumInputs() == argAttrs.size());
function_interface_impl::addArgAndResultAttrs(
- builder, state, argAttrs, /*resultAttrs=*/std::nullopt,
+ builder, state, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name));
}
diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp
index 7eb3d5bcd07f19..ef61a65735ae19 100644
--- a/mlir/lib/IR/Diagnostics.cpp
+++ b/mlir/lib/IR/Diagnostics.cpp
@@ -710,7 +710,7 @@ SourceMgrDiagnosticVerifierHandlerImpl::computeExpectedDiags(
raw_ostream &os, llvm::SourceMgr &mgr, const llvm::MemoryBuffer *buf) {
// If the buffer is invalid, return an empty list.
if (!buf)
- return std::nullopt;
+ return {};
auto &expectedDiags = expectedDiagsPerFile[buf->getBufferIdentifier()];
// The number of the last line that did not correlate to a designator.
diff --git a/mlir/lib/Interfaces/FunctionInterfaces.cpp b/mlir/lib/Interfaces/FunctionInterfaces.cpp
index 80f47a3f836768..6ac5aead96926f 100644
--- a/mlir/lib/Interfaces/FunctionInterfaces.cpp
+++ b/mlir/lib/Interfaces/FunctionInterfaces.cpp
@@ -44,14 +44,14 @@ function_interface_impl::getResultAttrDict(FunctionOpInterface op,
ArrayRef<NamedAttribute>
function_interface_impl::getArgAttrs(FunctionOpInterface op, unsigned index) {
auto argDict = getArgAttrDict(op, index);
- return argDict ? argDict.getValue() : std::nullopt;
+ return argDict ? argDict.getValue() : ArrayRef<NamedAttribute>();
}
ArrayRef<NamedAttribute>
function_interface_impl::getResultAttrs(FunctionOpInterface op,
unsigned index) {
auto resultDict = getResultAttrDict(op, index);
- return resultDict ? resultDict.getValue() : std::nullopt;
+ return resultDict ? resultDict.getValue() : ArrayRef<NamedAttribute>();
}
/// Get either the argument or result attributes array.
diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp
index 779dcfe7b6661d..01191aa8244403 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<Statistic> stats = std::nullopt) {
+ MutableArrayRef<Statistic> stats = {}) {
os.indent(indent) << pass << "\n";
if (stats.empty())
return;
diff --git a/mlir/lib/Reducer/Tester.cpp b/mlir/lib/Reducer/Tester.cpp
index 14760c0be70df9..03f12af1748398 100644
--- a/mlir/lib/Reducer/Tester.cpp
+++ b/mlir/lib/Reducer/Tester.cpp
@@ -68,7 +68,7 @@ Tester::Interestingness Tester::isInteresting(StringRef testCase) const {
std::string errMsg;
int result = llvm::sys::ExecuteAndWait(
- testScript, testerArgs, /*Env=*/std::nullopt, /*Redirects=*/std::nullopt,
+ testScript, testerArgs, /*Env=*/std::nullopt, /*Redirects=*/{},
/*SecondsToWait=*/0, /*MemoryLimit=*/0, &errMsg);
if (result < 0)
diff --git a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp
index 1dde457b5c34ff..d98a90016c109b 100644
--- a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp
@@ -206,7 +206,7 @@ void LoopAnnotationConversion::convertLocation(FusedLoc location) {
llvm::MDNode *LoopAnnotationConversion::convert() {
// Reserve operand 0 for loop id self reference.
- auto dummy = llvm::MDNode::getTemporary(ctx, std::nullopt);
+ auto dummy = llvm::MDNode::getTemporary(ctx, {});
metadataNodes.push_back(dummy.get());
if (FusedLoc startLoc = attr.getStartLoc())
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index fcb329eb7a92c1..a73bc790ca3cb2 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1673,7 +1673,7 @@ ModuleTranslation::getOrCreateAliasScope(AliasScopeAttr aliasScopeAttr) {
if (!scopeInserted)
return scopeIt->second;
llvm::LLVMContext &ctx = llvmModule->getContext();
- auto dummy = llvm::MDNode::getTemporary(ctx, std::nullopt);
+ auto dummy = llvm::MDNode::getTemporary(ctx, {});
// Convert the domain metadata node if necessary.
auto [domainIt, insertedDomain] = aliasDomainMetadataMapping.try_emplace(
aliasScopeAttr.getDomain(), nullptr);
diff --git a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
index 964d94c9c0a465..94a2766774d665 100644
--- a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
+++ b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
@@ -351,7 +351,7 @@ Value CodeGen::genNonInitializerVar(const ast::VariableDecl *varDecl,
loc, pdl::RangeType::get(builder.getType<pdl::TypeType>()),
/*types=*/ArrayAttr());
return builder.create<pdl::OperationOp>(
- loc, opType.getName(), operands, std::nullopt, ValueRange(), results);
+ loc, opType.getName(), operands, llvm::ArrayRef<llvm::StringRef>(), ValueRange(), results);
}
if (ast::RangeType rangeTy = dyn_cast<ast::RangeType>(type)) {
diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
index 575fb4aacd947c..378c032f0ba5a5 100644
--- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp
+++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
@@ -984,7 +984,7 @@ ast::Decl *Parser::createODSNativePDLLConstraintDecl(
// Build the native constraint.
auto *constraintDecl = ast::UserConstraintDecl::createNative(
ctx, ast::Name::create(ctx, name, loc), paramVar,
- /*results=*/std::nullopt, codeBlock, ast::TupleType::get(ctx),
+ /*results=*/{}, codeBlock, ast::TupleType::get(ctx),
nativeType);
constraintDecl->setDocComment(ctx, docString);
curDeclScope->add(constraintDecl);
@@ -1780,7 +1780,7 @@ Parser::parseConstraint(std::optional<SMRange> &typeConstraint,
FailureOr<ast::ConstraintRef> Parser::parseArgOrResultConstraint() {
std::optional<SMRange> typeConstraint;
- return parseConstraint(typeConstraint, /*existingConstraints=*/std::nullopt,
+ return parseConstraint(typeConstraint, /*existingConstraints=*/{},
/*allowInlineTypeConstraints=*/false);
}
@@ -2877,7 +2877,7 @@ Parser::validateOperationOperands(SMRange loc, std::optional<StringRef> name,
SmallVectorImpl<ast::Expr *> &operands) {
return validateOperationOperandsOrResults(
"operand", loc, odsOp ? odsOp->getLoc() : std::optional<SMRange>(), name,
- operands, odsOp ? odsOp->getOperands() : std::nullopt, valueTy,
+ operands, odsOp ? odsOp->getOperands() : ArrayRef<ods::OperandOrResult>(), valueTy,
valueRangeTy);
}
@@ -2887,7 +2887,7 @@ Parser::validateOperationResults(SMRange loc, std::optional<StringRef> name,
SmallVectorImpl<ast::Expr *> &results) {
return validateOperationOperandsOrResults(
"result", loc, odsOp ? odsOp->getLoc() : std::optional<SMRange>(), name,
- results, odsOp ? odsOp->getResults() : std::nullopt, typeTy, typeRangeTy);
+ results, odsOp ? odsOp->getResults() : ArrayRef<ods::OperandOrResult>(), typeTy, typeRangeTy);
}
void Parser::checkOperationResultTypeInferrence(SMRange loc, StringRef opName,
@@ -2987,7 +2987,7 @@ LogicalResult Parser::validateOperationOperandsOrResults(
// adhere to the ODS signature.
for (unsigned i = 0, e = odsValues.size(); i < e; ++i) {
values.push_back(ast::RangeExpr::create(
- ctx, loc, /*elements=*/std::nullopt, rangeTy));
+ ctx, loc, /*elements=*/{}, rangeTy));
}
return success();
}
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
index 76b066feb69308..3ef3aebe0c88e5 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
@@ -1044,7 +1044,7 @@ class LSPSignatureHelpContext : public CodeCompleteContext {
const ods::Operation *odsOp =
opName ? odsContext.lookupOperation(*opName) : nullptr;
codeCompleteOperationOperandOrResultSignature(
- opName, odsOp, odsOp ? odsOp->getOperands() : std::nullopt,
+ opName, odsOp, odsOp ? odsOp->getOperands() : ArrayRef<ods::OperandOrResult>(),
currentNumOperands, "operand", "Value");
}
@@ -1053,7 +1053,7 @@ class LSPSignatureHelpContext : public CodeCompleteContext {
const ods::Operation *odsOp =
opName ? odsContext.lookupOperation(*opName) : nullptr;
codeCompleteOperationOperandOrResultSignature(
- opName, odsOp, odsOp ? odsOp->getResults() : std::nullopt,
+ opName, odsOp, odsOp ? odsOp->getResults() : ArrayRef<ods::OperandOrResult>(),
currentNumResults, "result", "Type");
}
diff --git a/mlir/test/lib/Dialect/Test/TestAttributes.cpp b/mlir/test/lib/Dialect/Test/TestAttributes.cpp
index e09ea109061648..d62f7a24a65b31 100644
--- a/mlir/test/lib/Dialect/Test/TestAttributes.cpp
+++ b/mlir/test/lib/Dialect/Test/TestAttributes.cpp
@@ -194,7 +194,7 @@ void TestSubElementsAccessAttr::print(::mlir::AsmPrinter &printer) const {
ArrayRef<uint64_t> TestExtern1DI64ElementsAttr::getElements() const {
if (auto *blob = getHandle().getBlob())
return blob->getDataAs<uint64_t>();
- return std::nullopt;
+ return {};
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
index 3cbc307835afd7..5886fcda15a1dc 100644
--- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp
+++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
@@ -903,7 +903,7 @@ struct TestPassthroughInvalidOp : public ConversionPattern {
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const final {
rewriter.replaceOpWithNewOp<TestValidOp>(op, std::nullopt, operands,
- std::nullopt);
+ llvm::ArrayRef<NamedAttribute>());
return success();
}
};
@@ -919,7 +919,7 @@ struct TestDropAndReplaceInvalidOp : public ConversionPattern {
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const final {
rewriter.replaceOpWithNewOp<TestValidOp>(op, std::nullopt, ValueRange(),
- std::nullopt);
+ llvm::ArrayRef<NamedAttribute>());
return success();
}
};
diff --git a/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp b/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp
index 5b48e80749c8b8..e9a57f9084220a 100644
--- a/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp
+++ b/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp
@@ -25,7 +25,7 @@ static Operation *createOp(MLIRContext *context, Location loc,
context->allowUnregisteredDialects();
return Operation::create(loc, OperationName(operationName, context),
std::nullopt, std::nullopt, std::nullopt,
- OpaqueProperties(nullptr), std::nullopt, numRegions);
+ OpaqueProperties(nullptr), BlockRange(), numRegions);
}
namespace {
diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp
index f94dc784458077..4d0f32aadb96d8 100644
--- a/mlir/unittests/IR/OperationSupportTest.cpp
+++ b/mlir/unittests/IR/OperationSupportTest.cpp
@@ -19,13 +19,13 @@ using namespace mlir;
using namespace mlir::detail;
static Operation *createOp(MLIRContext *context,
- ArrayRef<Value> operands = std::nullopt,
- ArrayRef<Type> resultTypes = std::nullopt,
+ ArrayRef<Value> operands = {},
+ ArrayRef<Type> resultTypes = {},
unsigned int numRegions = 0) {
context->allowUnregisteredDialects();
return Operation::create(
UnknownLoc::get(context), OperationName("foo.bar", context), resultTypes,
- operands, std::nullopt, nullptr, std::nullopt, numRegions);
+ operands, std::nullopt, nullptr, BlockRange(), numRegions);
}
namespace {
@@ -34,7 +34,7 @@ TEST(OperandStorageTest, NonResizable) {
Builder builder(&context);
Operation *useOp =
- createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16));
+ createOp(&context, /*operands=*/{}, builder.getIntegerType(16));
Value operand = useOp->getResult(0);
// Create a non-resizable operation with one operand.
@@ -58,7 +58,7 @@ TEST(OperandStorageTest, Resizable) {
Builder builder(&context);
Operation *useOp =
- createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16));
+ createOp(&context, /*operands=*/{}, builder.getIntegerType(16));
Value operand = useOp->getResult(0);
// Create a resizable operation with one operand.
@@ -86,7 +86,7 @@ TEST(OperandStorageTest, RangeReplace) {
Builder builder(&context);
Operation *useOp =
- createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16));
+ createOp(&context, /*operands=*/{}, builder.getIntegerType(16));
Value operand = useOp->getResult(0);
// Create a resizable operation with one operand.
@@ -122,7 +122,7 @@ TEST(OperandStorageTest, MutableRange) {
Builder builder(&context);
Operation *useOp =
- createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16));
+ createOp(&context, /*operands=*/{}, builder.getIntegerType(16));
Value operand = useOp->getResult(0);
// Create a resizable operation with one operand.
@@ -160,7 +160,7 @@ TEST(OperandStorageTest, RangeErase) {
Type type = builder.getNoneType();
Operation *useOp =
- createOp(&context, /*operands=*/std::nullopt, {type, type});
+ createOp(&context, /*operands=*/{}, {type, type});
Value operand1 = useOp->getResult(0);
Value operand2 = useOp->getResult(1);
@@ -190,8 +190,8 @@ TEST(OperationOrderTest, OrderIsAlwaysValid) {
MLIRContext context;
Builder builder(&context);
- Operation *containerOp = createOp(&context, /*operands=*/std::nullopt,
- /*resultTypes=*/std::nullopt,
+ Operation *containerOp = createOp(&context, /*operands=*/{},
+ /*resultTypes=*/{},
/*numRegions=*/1);
Region ®ion = containerOp->getRegion(0);
Block *block = new Block();
diff --git a/mlir/unittests/Transforms/DialectConversion.cpp b/mlir/unittests/Transforms/DialectConversion.cpp
index 10d7fb041278d9..389d80c19963fe 100644
--- a/mlir/unittests/Transforms/DialectConversion.cpp
+++ b/mlir/unittests/Transforms/DialectConversion.cpp
@@ -15,7 +15,7 @@ static Operation *createOp(MLIRContext *context) {
context->allowUnregisteredDialects();
return Operation::create(
UnknownLoc::get(context), OperationName("foo.bar", context), std::nullopt,
- std::nullopt, std::nullopt, /*properties=*/nullptr, std::nullopt, 0);
+ std::nullopt, std::nullopt, /*properties=*/nullptr, BlockRange(), 0);
}
namespace {
>From 27ad38f3e83e275a8a2a8e4f65acd1da3acca424 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Sat, 21 Sep 2024 10:49:25 +0100
Subject: [PATCH 2/2] clang-format
---
.../include/mlir/ExecutionEngine/ExecutionEngine.h | 3 +--
mlir/include/mlir/IR/PatternMatch.h | 3 +--
mlir/include/mlir/IR/SymbolTable.h | 3 ++-
mlir/include/mlir/IR/TypeRange.h | 3 +--
.../include/mlir/Rewrite/FrozenRewritePatternSet.h | 7 +++----
mlir/include/mlir/Tools/PDLL/AST/Nodes.h | 4 ++--
mlir/include/mlir/Tools/PDLL/AST/Types.h | 3 +--
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp | 4 ++--
.../Dialect/GPU/Transforms/DecomposeMemRefs.cpp | 5 +++--
mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp | 5 +++--
mlir/lib/Tools/PDLL/Parser/Parser.cpp | 14 +++++++-------
mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp | 6 ++++--
mlir/unittests/IR/OperationSupportTest.cpp | 6 ++----
13 files changed, 32 insertions(+), 34 deletions(-)
diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
index 594cee107790f8..96ccebcd5685eb 100644
--- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
+++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
@@ -157,8 +157,7 @@ class ExecutionEngine {
/// Invokes the function with the given name passing it the list of opaque
/// pointers to the actual arguments.
- llvm::Error invokePacked(StringRef name,
- MutableArrayRef<void *> args = {});
+ llvm::Error invokePacked(StringRef name, MutableArrayRef<void *> 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/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 2ae25449480da7..93ca1d9d5aa3c4 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -847,8 +847,7 @@ class RewritePatternSet {
RewritePatternSet &add(ConstructorArg &&arg, ConstructorArgs &&...args) {
// The following expands a call to emplace_back for each of the pattern
// types 'Ts'.
- (addImpl<Ts>(/*debugLabels=*/{},
- std::forward<ConstructorArg>(arg),
+ (addImpl<Ts>(/*debugLabels=*/{}, std::forward<ConstructorArg>(arg),
std::forward<ConstructorArgs>(args)...),
...);
return *this;
diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h
index 090b01a324581d..b3953cdf42bdf7 100644
--- a/mlir/include/mlir/IR/SymbolTable.h
+++ b/mlir/include/mlir/IR/SymbolTable.h
@@ -395,7 +395,8 @@ class SymbolUserMap {
/// Return the users of the provided symbol operation.
ArrayRef<Operation *> getUsers(Operation *symbol) const {
auto it = symbolToUsers.find(symbol);
- return it != symbolToUsers.end() ? it->second.getArrayRef() : ArrayRef<Operation *>();
+ return it != symbolToUsers.end() ? it->second.getArrayRef()
+ : ArrayRef<Operation *>();
}
/// 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 424366d6a5a8d5..67897c2c3db8f6 100644
--- a/mlir/include/mlir/IR/TypeRange.h
+++ b/mlir/include/mlir/IR/TypeRange.h
@@ -47,8 +47,7 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base<
template <typename Arg, typename = std::enable_if_t<std::is_constructible<
ArrayRef<Type>, Arg>::value>>
TypeRange(Arg &&arg) : TypeRange(ArrayRef<Type>(std::forward<Arg>(arg))) {}
- TypeRange(std::nullopt_t)
- : TypeRange(ArrayRef<Type>()) {}
+ TypeRange(std::nullopt_t) : TypeRange(ArrayRef<Type>()) {}
TypeRange(std::initializer_list<Type> types)
: TypeRange(ArrayRef<Type>(types)) {}
diff --git a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h
index aeec4e875f4b2c..d6c431206e06ee 100644
--- a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h
+++ b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h
@@ -47,10 +47,9 @@ class FrozenRewritePatternSet {
/// `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<std::string> disabledPatternLabels = {},
- ArrayRef<std::string> enabledPatternLabels = {});
+ FrozenRewritePatternSet(RewritePatternSet &&patterns,
+ ArrayRef<std::string> disabledPatternLabels = {},
+ ArrayRef<std::string> enabledPatternLabels = {});
/// Return the op specific native patterns held by this list.
const OpSpecificNativePatternListT &getOpSpecificNativePatterns() const {
diff --git a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h
index 49b596e47c61d5..7a9e5048aebe78 100644
--- a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h
+++ b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h
@@ -897,8 +897,8 @@ class UserConstraintDecl final
ArrayRef<VariableDecl *> results,
const CompoundStmt *body,
Type resultType) {
- return createImpl(ctx, name, inputs, /*nativeInputTypes=*/{},
- results, /*codeBlock=*/std::nullopt, body, resultType);
+ return createImpl(ctx, name, inputs, /*nativeInputTypes=*/{}, results,
+ /*codeBlock=*/std::nullopt, body, resultType);
}
/// Return the name of the constraint.
diff --git a/mlir/include/mlir/Tools/PDLL/AST/Types.h b/mlir/include/mlir/Tools/PDLL/AST/Types.h
index 620351f737129e..aa483a81f87f58 100644
--- a/mlir/include/mlir/Tools/PDLL/AST/Types.h
+++ b/mlir/include/mlir/Tools/PDLL/AST/Types.h
@@ -253,8 +253,7 @@ class TupleType : public Type::TypeBase<detail::TupleTypeStorage> {
/// Return an instance of the Tuple type.
static TupleType get(Context &context, ArrayRef<Type> elementTypes,
ArrayRef<StringRef> elementNames);
- static TupleType get(Context &context,
- ArrayRef<Type> elementTypes = {});
+ static TupleType get(Context &context, ArrayRef<Type> elementTypes = {});
/// Return the element types of this tuple.
ArrayRef<Type> getElementTypes() const;
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index 07801057611697..ca4abe09f8d952 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -249,8 +249,8 @@ static Value createLinalgBodyCalculationForElementwiseOp(
auto shifted =
rewriter.create<arith::ShRSIOp>(loc, resultTypes, args[0], subtract)
->getResults();
- auto truncated =
- rewriter.create<arith::TruncIOp>(loc, i1Ty, shifted, llvm::ArrayRef<NamedAttribute>());
+ auto truncated = rewriter.create<arith::TruncIOp>(
+ loc, i1Ty, shifted, llvm::ArrayRef<NamedAttribute>());
auto isInputOdd =
rewriter.create<arith::AndIOp>(loc, i1Ty, truncated, i1one);
diff --git a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp
index 7199aa2a41e80a..9040260f6bb416 100644
--- a/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp
@@ -99,8 +99,9 @@ static Value getFlatMemref(OpBuilder &rewriter, Location loc, Value source,
auto &&[base, offset, ignore] =
getFlatOffsetAndStrides(rewriter, loc, source, offsetsTemp);
auto retType = cast<MemRefType>(base.getType());
- return rewriter.create<memref::ReinterpretCastOp>(loc, retType, base, offset,
- llvm::ArrayRef<OpFoldResult>(), llvm::ArrayRef<OpFoldResult>());
+ return rewriter.create<memref::ReinterpretCastOp>(
+ loc, retType, base, offset, llvm::ArrayRef<OpFoldResult>(),
+ llvm::ArrayRef<OpFoldResult>());
}
static bool needFlatten(Value val) {
diff --git a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
index 94a2766774d665..f91abd714e2859 100644
--- a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
+++ b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
@@ -350,8 +350,9 @@ Value CodeGen::genNonInitializerVar(const ast::VariableDecl *varDecl,
Value results = builder.create<pdl::TypesOp>(
loc, pdl::RangeType::get(builder.getType<pdl::TypeType>()),
/*types=*/ArrayAttr());
- return builder.create<pdl::OperationOp>(
- loc, opType.getName(), operands, llvm::ArrayRef<llvm::StringRef>(), ValueRange(), results);
+ return builder.create<pdl::OperationOp>(loc, opType.getName(), operands,
+ llvm::ArrayRef<llvm::StringRef>(),
+ ValueRange(), results);
}
if (ast::RangeType rangeTy = dyn_cast<ast::RangeType>(type)) {
diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
index 378c032f0ba5a5..fd10f217491442 100644
--- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp
+++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
@@ -984,8 +984,7 @@ ast::Decl *Parser::createODSNativePDLLConstraintDecl(
// Build the native constraint.
auto *constraintDecl = ast::UserConstraintDecl::createNative(
ctx, ast::Name::create(ctx, name, loc), paramVar,
- /*results=*/{}, codeBlock, ast::TupleType::get(ctx),
- nativeType);
+ /*results=*/{}, codeBlock, ast::TupleType::get(ctx), nativeType);
constraintDecl->setDocComment(ctx, docString);
curDeclScope->add(constraintDecl);
return constraintDecl;
@@ -2877,8 +2876,8 @@ Parser::validateOperationOperands(SMRange loc, std::optional<StringRef> name,
SmallVectorImpl<ast::Expr *> &operands) {
return validateOperationOperandsOrResults(
"operand", loc, odsOp ? odsOp->getLoc() : std::optional<SMRange>(), name,
- operands, odsOp ? odsOp->getOperands() : ArrayRef<ods::OperandOrResult>(), valueTy,
- valueRangeTy);
+ operands, odsOp ? odsOp->getOperands() : ArrayRef<ods::OperandOrResult>(),
+ valueTy, valueRangeTy);
}
LogicalResult
@@ -2887,7 +2886,8 @@ Parser::validateOperationResults(SMRange loc, std::optional<StringRef> name,
SmallVectorImpl<ast::Expr *> &results) {
return validateOperationOperandsOrResults(
"result", loc, odsOp ? odsOp->getLoc() : std::optional<SMRange>(), name,
- results, odsOp ? odsOp->getResults() : ArrayRef<ods::OperandOrResult>(), typeTy, typeRangeTy);
+ results, odsOp ? odsOp->getResults() : ArrayRef<ods::OperandOrResult>(),
+ typeTy, typeRangeTy);
}
void Parser::checkOperationResultTypeInferrence(SMRange loc, StringRef opName,
@@ -2986,8 +2986,8 @@ LogicalResult Parser::validateOperationOperandsOrResults(
// Otherwise, create dummy values for each of the entries so that we
// adhere to the ODS signature.
for (unsigned i = 0, e = odsValues.size(); i < e; ++i) {
- values.push_back(ast::RangeExpr::create(
- ctx, loc, /*elements=*/{}, rangeTy));
+ values.push_back(
+ ast::RangeExpr::create(ctx, loc, /*elements=*/{}, rangeTy));
}
return success();
}
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
index 3ef3aebe0c88e5..3a822f9d0d4bb7 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
@@ -1044,7 +1044,8 @@ class LSPSignatureHelpContext : public CodeCompleteContext {
const ods::Operation *odsOp =
opName ? odsContext.lookupOperation(*opName) : nullptr;
codeCompleteOperationOperandOrResultSignature(
- opName, odsOp, odsOp ? odsOp->getOperands() : ArrayRef<ods::OperandOrResult>(),
+ opName, odsOp,
+ odsOp ? odsOp->getOperands() : ArrayRef<ods::OperandOrResult>(),
currentNumOperands, "operand", "Value");
}
@@ -1053,7 +1054,8 @@ class LSPSignatureHelpContext : public CodeCompleteContext {
const ods::Operation *odsOp =
opName ? odsContext.lookupOperation(*opName) : nullptr;
codeCompleteOperationOperandOrResultSignature(
- opName, odsOp, odsOp ? odsOp->getResults() : ArrayRef<ods::OperandOrResult>(),
+ opName, odsOp,
+ odsOp ? odsOp->getResults() : ArrayRef<ods::OperandOrResult>(),
currentNumResults, "result", "Type");
}
diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp
index 4d0f32aadb96d8..d4be24410d6b97 100644
--- a/mlir/unittests/IR/OperationSupportTest.cpp
+++ b/mlir/unittests/IR/OperationSupportTest.cpp
@@ -18,8 +18,7 @@
using namespace mlir;
using namespace mlir::detail;
-static Operation *createOp(MLIRContext *context,
- ArrayRef<Value> operands = {},
+static Operation *createOp(MLIRContext *context, ArrayRef<Value> operands = {},
ArrayRef<Type> resultTypes = {},
unsigned int numRegions = 0) {
context->allowUnregisteredDialects();
@@ -159,8 +158,7 @@ TEST(OperandStorageTest, RangeErase) {
Builder builder(&context);
Type type = builder.getNoneType();
- Operation *useOp =
- createOp(&context, /*operands=*/{}, {type, type});
+ Operation *useOp = createOp(&context, /*operands=*/{}, {type, type});
Value operand1 = useOp->getResult(0);
Value operand2 = useOp->getResult(1);
More information about the Mlir-commits
mailing list