forked from OSchip/llvm-project
[MLIR][NFC] Adopt use of BlockRange in place of ArrayRef<Block *>
- Use BlockRange in ODS generated builders as well as other places throughout the code Differential Revision: https://reviews.llvm.org/D87955
This commit is contained in:
parent
f6aceb72d6
commit
a6ae695017
|
@ -771,7 +771,7 @@ def PDLInterp_SwitchAttributeOp
|
|||
|
||||
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);
|
||||
}]>];
|
||||
|
@ -804,7 +804,7 @@ def PDLInterp_SwitchOperandCountOp
|
|||
|
||||
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);
|
||||
}]>];
|
||||
|
@ -838,7 +838,7 @@ def PDLInterp_SwitchOperationNameOp
|
|||
|
||||
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),
|
||||
|
@ -874,7 +874,7 @@ def PDLInterp_SwitchResultCountOp
|
|||
|
||||
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);
|
||||
}]>];
|
||||
|
@ -906,7 +906,7 @@ def PDLInterp_SwitchTypeOp : PDLInterp_SwitchOp<"switch_type", [NoSideEffect]> {
|
|||
|
||||
let builders = [
|
||||
OpBuilder<"Value edge, TypeRange types, Block *defaultDest, "
|
||||
"ArrayRef<Block *> dests", [{
|
||||
"BlockRange dests", [{
|
||||
build($_builder, $_state, edge, $_builder.getTypeArrayAttr(types),
|
||||
defaultDest, dests);
|
||||
}]>,
|
||||
|
|
|
@ -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 <memory>
|
||||
|
||||
namespace mlir {
|
||||
class Block;
|
||||
class BlockRange;
|
||||
class Dialect;
|
||||
class Operation;
|
||||
struct OperationState;
|
||||
|
@ -364,8 +363,8 @@ public:
|
|||
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);
|
||||
|
|
|
@ -60,9 +60,10 @@ static LogicalResult encodeInstructionInto(SmallVectorImpl<uint32_t> &binary,
|
|||
/// 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());
|
||||
|
||||
|
|
|
@ -169,9 +169,9 @@ OperationState::OperationState(Location location, OperationName name)
|
|||
: 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()),
|
||||
|
|
|
@ -1420,8 +1420,8 @@ void OpEmitter::buildParamList(SmallVectorImpl<OpMethodParameter> ¶mList,
|
|||
|
||||
/// 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 @@ void OpEmitter::genSuccessorVerifier(OpMethodBody &body) {
|
|||
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();
|
||||
|
|
Loading…
Reference in New Issue