diff --git a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td --- a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td +++ b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td @@ -774,7 +774,7 @@ let builders = [ OpBuilder<"OpBuilder &builder, OperationState &state, Value attribute," "ArrayRef caseValues," - "Block *defaultDest, ArrayRef dests", [{ + "Block *defaultDest, BlockRange dests", [{ build(builder, state, attribute, builder.getArrayAttr(caseValues), defaultDest, dests); }]>]; @@ -808,7 +808,7 @@ let builders = [ OpBuilder<"OpBuilder &builder, OperationState &state, Value operation, " "ArrayRef counts, Block *defaultDest, " - "ArrayRef dests", [{ + "BlockRange dests", [{ build(builder, state, operation, builder.getI32VectorAttr(counts), defaultDest, dests); }]>]; @@ -843,7 +843,7 @@ let builders = [ OpBuilder<"OpBuilder &builder, OperationState &state, Value operation, " "ArrayRef names, " - "Block *defaultDest, ArrayRef dests", [{ + "Block *defaultDest, BlockRange dests", [{ auto stringNames = llvm::to_vector<8>(llvm::map_range(names, [](OperationName name) { return name.getStringRef(); })); build(builder, state, operation, builder.getStrArrayAttr(stringNames), @@ -880,7 +880,7 @@ let builders = [ OpBuilder<"OpBuilder &builder, OperationState &state, Value operation, " "ArrayRef counts, Block *defaultDest, " - "ArrayRef dests", [{ + "BlockRange dests", [{ build(builder, state, operation, builder.getI32VectorAttr(counts), defaultDest, dests); }]>]; @@ -912,7 +912,7 @@ let builders = [ OpBuilder<"OpBuilder &builder, OperationState &state, Value edge, " - "TypeRange types, Block *defaultDest, ArrayRef dests", [{ + "TypeRange types, Block *defaultDest, BlockRange dests", [{ build(builder, state, edge, builder.getTypeArrayAttr(types), defaultDest, dests); }]>, diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -15,6 +15,7 @@ #define MLIR_IR_OPERATION_SUPPORT_H #include "mlir/IR/Attributes.h" +#include "mlir/IR/BlockSupport.h" #include "mlir/IR/Identifier.h" #include "mlir/IR/Location.h" #include "mlir/IR/TypeRange.h" @@ -28,8 +29,6 @@ #include namespace mlir { -class Block; -class BlockRange; class Dialect; class Operation; struct OperationState; @@ -364,8 +363,8 @@ OperationState(Location location, OperationName name); OperationState(Location location, StringRef name, ValueRange operands, - ArrayRef types, ArrayRef attributes, - ArrayRef successors = {}, + TypeRange types, ArrayRef attributes, + BlockRange successors = {}, MutableArrayRef> regions = {}); void addOperands(ValueRange newOperands); diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -60,9 +60,10 @@ /// readable to human, we perform depth-first CFG traversal and delay the /// serialization of the merge block and the continue block, if exists, until /// after all other blocks have been processed. -static LogicalResult visitInPrettyBlockOrder( - Block *headerBlock, function_ref blockHandler, - bool skipHeader = false, ArrayRef skipBlocks = {}) { +static LogicalResult +visitInPrettyBlockOrder(Block *headerBlock, + function_ref blockHandler, + bool skipHeader = false, BlockRange skipBlocks = {}) { llvm::df_iterator_default_set doneBlocks; doneBlocks.insert(skipBlocks.begin(), skipBlocks.end()); diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -169,9 +169,9 @@ : location(location), name(name) {} OperationState::OperationState(Location location, StringRef name, - ValueRange operands, ArrayRef types, + ValueRange operands, TypeRange types, ArrayRef attributes, - ArrayRef successors, + BlockRange successors, MutableArrayRef> regions) : location(location), name(name, location->getContext()), operands(operands.begin(), operands.end()), diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -1420,8 +1420,8 @@ /// Insert parameters for each successor. for (const NamedSuccessor &succ : op.getSuccessors()) { - StringRef type = succ.isVariadic() ? "::llvm::ArrayRef<::mlir::Block *>" - : "::mlir::Block *"; + StringRef type = + succ.isVariadic() ? "::mlir::BlockRange" : "::mlir::Block *"; paramList.emplace_back(type, succ.name); } @@ -1888,12 +1888,14 @@ if (successor.constraint.getPredicate().isNull()) continue; - body << " for (::mlir::Block *successor : "; - body << formatv(successor.isVariadic() - ? "{0}()" - : "::llvm::ArrayRef<::mlir::Block *>({0}())", - successor.name); - body << ") {\n"; + if (successor.isVariadic()) { + body << formatv(" for (::mlir::Block *successor : {0}()) {\n", + successor.name); + } else { + body << " {\n"; + body << formatv(" ::mlir::Block *successor = {0}();\n", + successor.name); + } auto constraint = tgfmt(successor.constraint.getConditionTemplate(), &verifyCtx.withSelf("successor")) .str();