forked from OSchip/llvm-project
[NFC] Use llvm::hasSingleElement() in place of .size() == 1
- Also use functions in Region instead of Region::getBlocks() where possible. Differential Revision: https://reviews.llvm.org/D82032
This commit is contained in:
parent
6c45532908
commit
2eaadfc4fe
|
@ -218,25 +218,25 @@ void LaunchOp::build(OpBuilder &builder, OperationState &result,
|
|||
}
|
||||
|
||||
KernelDim3 LaunchOp::getBlockIds() {
|
||||
assert(!body().getBlocks().empty() && "FuncOp body must not be empty.");
|
||||
assert(!body().empty() && "LaunchOp body must not be empty.");
|
||||
auto args = body().getBlocks().front().getArguments();
|
||||
return KernelDim3{args[0], args[1], args[2]};
|
||||
}
|
||||
|
||||
KernelDim3 LaunchOp::getThreadIds() {
|
||||
assert(!body().getBlocks().empty() && "FuncOp body must not be empty.");
|
||||
assert(!body().empty() && "LaunchOp body must not be empty.");
|
||||
auto args = body().getBlocks().front().getArguments();
|
||||
return KernelDim3{args[3], args[4], args[5]};
|
||||
}
|
||||
|
||||
KernelDim3 LaunchOp::getGridSize() {
|
||||
assert(!body().getBlocks().empty() && "FuncOp body must not be empty.");
|
||||
assert(!body().empty() && "LaunchOp body must not be empty.");
|
||||
auto args = body().getBlocks().front().getArguments();
|
||||
return KernelDim3{args[6], args[7], args[8]};
|
||||
}
|
||||
|
||||
KernelDim3 LaunchOp::getBlockSize() {
|
||||
assert(!body().getBlocks().empty() && "FuncOp body must not be empty.");
|
||||
assert(!body().empty() && "LaunchOp body must not be empty.");
|
||||
auto args = body().getBlocks().front().getArguments();
|
||||
return KernelDim3{args[9], args[10], args[11]};
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ Operation *mlir::edsc::makeGenericLinalgOp(
|
|||
SmallVector<Value, 8> handles(blockTypes.size());
|
||||
BlockBuilder(&b, op->getRegion(0), blockTypes,
|
||||
handles)([&] { regionBuilder(b.getBlock()->getArguments()); });
|
||||
assert(op->getRegion(0).getBlocks().size() == 1);
|
||||
assert(llvm::hasSingleElement(op->getRegion(0)));
|
||||
return op;
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ static LogicalResult verifyGenericOp(GenericOpType op) {
|
|||
<< " inputs (tensor or buffer) and output buffer operands";
|
||||
|
||||
auto ®ion = op.region();
|
||||
if (region.getBlocks().size() != 1)
|
||||
if (!llvm::hasSingleElement(region))
|
||||
return op.emitOpError("expected region with 1 block");
|
||||
if (failed(BlockArgsVerifier<GenericOpType>::verify(op, region.front())))
|
||||
return failure();
|
||||
|
|
|
@ -182,7 +182,7 @@ static void transformIndexedGenericOpIndices(
|
|||
indexedGenericOp.emitOpError("expected a region");
|
||||
return;
|
||||
}
|
||||
auto &block = region.getBlocks().front();
|
||||
auto &block = region.front();
|
||||
|
||||
OpBuilder::InsertionGuard g(b);
|
||||
b.setInsertionPointToStart(&block);
|
||||
|
|
|
@ -636,7 +636,7 @@ bool MemRefDependenceGraph::init(FuncOp f) {
|
|||
DenseMap<Value, SetVector<unsigned>> memrefAccesses;
|
||||
|
||||
// TODO: support multi-block functions.
|
||||
if (f.getBlocks().size() != 1)
|
||||
if (!llvm::hasSingleElement(f))
|
||||
return false;
|
||||
|
||||
DenseMap<Operation *, unsigned> forToNodeMap;
|
||||
|
|
|
@ -178,7 +178,7 @@ void MemRefDataFlowOpt::forwardStoreToLoad(AffineLoadOp loadOp) {
|
|||
void MemRefDataFlowOpt::runOnFunction() {
|
||||
// Only supports single block functions at the moment.
|
||||
FuncOp f = getFunction();
|
||||
if (f.getBlocks().size() != 1) {
|
||||
if (!llvm::hasSingleElement(f)) {
|
||||
markAllAnalysesPreserved();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ struct PrintOpPass : public PrintOpBase<PrintOpPass> {
|
|||
for (Region ®ion : op.getRegions()) {
|
||||
for (auto indexed_block : llvm::enumerate(region)) {
|
||||
// Suffix block number if there are more than 1 block.
|
||||
auto blockName = region.getBlocks().size() == 1
|
||||
auto blockName = llvm::hasSingleElement(region)
|
||||
? ""
|
||||
: ("__" + llvm::utostr(indexed_block.index()));
|
||||
llvm::WriteGraph(os, &indexed_block.value(), short_names,
|
||||
|
|
|
@ -248,7 +248,7 @@ void VectorizerTestPass::runOnFunction() {
|
|||
|
||||
// Only support single block functions at this point.
|
||||
FuncOp f = getFunction();
|
||||
if (f.getBlocks().size() != 1)
|
||||
if (!llvm::hasSingleElement(f))
|
||||
return;
|
||||
|
||||
std::string str;
|
||||
|
|
Loading…
Reference in New Issue