- Use BlockRange in ODS generated builders as well as other places throughout the code
Differential Revision: https://reviews.llvm.org/D87955
let builders = [
OpBuilder<"Value attribute, ArrayRef<Attribute> caseValues,"
- "Block *defaultDest, ArrayRef<Block *> dests", [{
+ "Block *defaultDest, BlockRange dests", [{
build($_builder, $_state, attribute, $_builder.getArrayAttr(caseValues),
defaultDest, dests);
}]>];
let builders = [
OpBuilder<"Value operation, ArrayRef<int32_t> counts, "
- "Block *defaultDest, ArrayRef<Block *> dests", [{
+ "Block *defaultDest, BlockRange dests", [{
build($_builder, $_state, operation, $_builder.getI32VectorAttr(counts),
defaultDest, dests);
}]>];
let builders = [
OpBuilder<"Value operation, ArrayRef<OperationName> names, "
- "Block *defaultDest, ArrayRef<Block *> 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),
let builders = [
OpBuilder<"Value operation, ArrayRef<int32_t> counts, Block *defaultDest, "
- "ArrayRef<Block *> dests", [{
+ "BlockRange dests", [{
build($_builder, $_state, operation, $_builder.getI32VectorAttr(counts),
defaultDest, dests);
}]>];
let builders = [
OpBuilder<"Value edge, TypeRange types, Block *defaultDest, "
- "ArrayRef<Block *> dests", [{
+ "BlockRange dests", [{
build($_builder, $_state, edge, $_builder.getTypeArrayAttr(types),
defaultDest, dests);
}]>,
#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"
#include <memory>
namespace mlir {
-class Block;
-class BlockRange;
class Dialect;
class Operation;
struct OperationState;
OperationState(Location location, OperationName name);
OperationState(Location location, StringRef name, ValueRange operands,
- ArrayRef<Type> types, ArrayRef<NamedAttribute> attributes,
- ArrayRef<Block *> successors = {},
+ TypeRange types, ArrayRef<NamedAttribute> attributes,
+ BlockRange successors = {},
MutableArrayRef<std::unique_ptr<Region>> regions = {});
void addOperands(ValueRange newOperands);
/// 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<LogicalResult(Block *)> blockHandler,
- bool skipHeader = false, ArrayRef<Block *> skipBlocks = {}) {
+static LogicalResult
+visitInPrettyBlockOrder(Block *headerBlock,
+ function_ref<LogicalResult(Block *)> blockHandler,
+ bool skipHeader = false, BlockRange skipBlocks = {}) {
llvm::df_iterator_default_set<Block *, 4> doneBlocks;
doneBlocks.insert(skipBlocks.begin(), skipBlocks.end());
: location(location), name(name) {}
OperationState::OperationState(Location location, StringRef name,
- ValueRange operands, ArrayRef<Type> types,
+ ValueRange operands, TypeRange types,
ArrayRef<NamedAttribute> attributes,
- ArrayRef<Block *> successors,
+ BlockRange successors,
MutableArrayRef<std::unique_ptr<Region>> regions)
: location(location), name(name, location->getContext()),
operands(operands.begin(), operands.end()),
/// 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);
}
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();