mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
[mlir] Rename FunctionOpInterface::getBody to getFunctionBody
This is much more explicit, and prevents annoying conflicts with op specific accessors (which may have a different contract). This is similar to the past rename of getType -> getFunctionType, Fixes #58030 Differential Revision: https://reviews.llvm.org/D135007
This commit is contained in:
@@ -169,36 +169,36 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
|
||||
bool isExternal() { return empty(); }
|
||||
|
||||
/// Return the region containing the body of this function.
|
||||
Region &getBody() { return $_op->getRegion(0); }
|
||||
Region &getFunctionBody() { return $_op->getRegion(0); }
|
||||
|
||||
/// Delete all blocks from this function.
|
||||
void eraseBody() {
|
||||
getBody().dropAllReferences();
|
||||
getBody().getBlocks().clear();
|
||||
getFunctionBody().dropAllReferences();
|
||||
getFunctionBody().getBlocks().clear();
|
||||
}
|
||||
|
||||
/// Return the list of blocks within the function body.
|
||||
BlockListType &getBlocks() { return getBody().getBlocks(); }
|
||||
BlockListType &getBlocks() { return getFunctionBody().getBlocks(); }
|
||||
|
||||
iterator begin() { return getBody().begin(); }
|
||||
iterator end() { return getBody().end(); }
|
||||
reverse_iterator rbegin() { return getBody().rbegin(); }
|
||||
reverse_iterator rend() { return getBody().rend(); }
|
||||
iterator begin() { return getFunctionBody().begin(); }
|
||||
iterator end() { return getFunctionBody().end(); }
|
||||
reverse_iterator rbegin() { return getFunctionBody().rbegin(); }
|
||||
reverse_iterator rend() { return getFunctionBody().rend(); }
|
||||
|
||||
/// Returns true if this function has no blocks within the body.
|
||||
bool empty() { return getBody().empty(); }
|
||||
bool empty() { return getFunctionBody().empty(); }
|
||||
|
||||
/// Push a new block to the back of the body region.
|
||||
void push_back(Block *block) { getBody().push_back(block); }
|
||||
void push_back(Block *block) { getFunctionBody().push_back(block); }
|
||||
|
||||
/// Push a new block to the front of the body region.
|
||||
void push_front(Block *block) { getBody().push_front(block); }
|
||||
void push_front(Block *block) { getFunctionBody().push_front(block); }
|
||||
|
||||
/// Return the last block in the body region.
|
||||
Block &back() { return getBody().back(); }
|
||||
Block &back() { return getFunctionBody().back(); }
|
||||
|
||||
/// Return the first block in the body region.
|
||||
Block &front() { return getBody().front(); }
|
||||
Block &front() { return getFunctionBody().front(); }
|
||||
|
||||
/// Add an entry block to an empty function, and set up the block arguments
|
||||
/// to match the signature of the function. The newly inserted entry block
|
||||
@@ -280,13 +280,13 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
|
||||
|
||||
/// Returns the entry block function argument at the given index.
|
||||
BlockArgument getArgument(unsigned idx) {
|
||||
return getBody().getArgument(idx);
|
||||
return getFunctionBody().getArgument(idx);
|
||||
}
|
||||
|
||||
/// Support argument iteration.
|
||||
args_iterator args_begin() { return getBody().args_begin(); }
|
||||
args_iterator args_end() { return getBody().args_end(); }
|
||||
BlockArgListType getArguments() { return getBody().getArguments(); }
|
||||
args_iterator args_begin() { return getFunctionBody().args_begin(); }
|
||||
args_iterator args_end() { return getFunctionBody().args_end(); }
|
||||
BlockArgListType getArguments() { return getFunctionBody().getArguments(); }
|
||||
|
||||
/// Insert a single argument of type `argType` with attributes `argAttrs` and
|
||||
/// location `argLoc` at `argIndex`.
|
||||
|
||||
@@ -40,8 +40,8 @@ struct ForLoopMapper : public impl::ConvertAffineForToGPUBase<ForLoopMapper> {
|
||||
}
|
||||
|
||||
void runOnOperation() override {
|
||||
for (Operation &op :
|
||||
llvm::make_early_inc_range(getOperation().getBody().getOps())) {
|
||||
for (Operation &op : llvm::make_early_inc_range(
|
||||
getOperation().getFunctionBody().getOps())) {
|
||||
if (auto forOp = dyn_cast<AffineForOp>(&op)) {
|
||||
if (failed(convertAffineLoopNestToGPULaunch(forOp, numBlockDims,
|
||||
numThreadDims)))
|
||||
|
||||
@@ -106,7 +106,7 @@ struct FunctionNonEntryBlockConversion
|
||||
matchAndRewrite(FunctionOpInterface op, ArrayRef<Value> operands,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
rewriter.startRootUpdate(op);
|
||||
Region ®ion = op.getBody();
|
||||
Region ®ion = op.getFunctionBody();
|
||||
SmallVector<TypeConverter::SignatureConversion, 2> conversions;
|
||||
|
||||
for (Block &block : llvm::drop_begin(region, 1)) {
|
||||
@@ -461,7 +461,7 @@ struct LinalgDetensorize
|
||||
opsToDetensor.insert(genericOp);
|
||||
});
|
||||
|
||||
for (Block &block : llvm::drop_begin(func.getBody(), 1))
|
||||
for (Block &block : llvm::drop_begin(func.getFunctionBody(), 1))
|
||||
for (BlockArgument blockArgument : block.getArguments())
|
||||
blockArgsToDetensor.insert(blockArgument);
|
||||
}
|
||||
@@ -500,7 +500,7 @@ struct LinalgDetensorize
|
||||
// boundaries, which we conservatively approximate as all function
|
||||
// signatures.
|
||||
if (auto funcOp = dyn_cast<FunctionOpInterface>(op)) {
|
||||
Region &body = funcOp.getBody();
|
||||
Region &body = funcOp.getFunctionBody();
|
||||
return llvm::all_of(llvm::drop_begin(body, 1), [&](Block &block) {
|
||||
return !llvm::any_of(
|
||||
blockArgsToDetensor, [&](BlockArgument blockArgument) {
|
||||
|
||||
@@ -3077,8 +3077,8 @@ struct FunctionOpInterfaceSignatureConversion : public ConversionPattern {
|
||||
SmallVector<Type, 1> newResults;
|
||||
if (failed(typeConverter->convertSignatureArgs(type.getInputs(), result)) ||
|
||||
failed(typeConverter->convertTypes(type.getResults(), newResults)) ||
|
||||
failed(rewriter.convertRegionTypes(&funcOp.getBody(), *typeConverter,
|
||||
&result)))
|
||||
failed(rewriter.convertRegionTypes(&funcOp.getFunctionBody(),
|
||||
*typeConverter, &result)))
|
||||
return failure();
|
||||
|
||||
// Update the function signature in-place.
|
||||
|
||||
@@ -139,7 +139,7 @@ void test2(FunctionOpInterface f) {
|
||||
m_Op<arith::MulFOp>(a, m_Op<arith::AddFOp>(a, m_Constant(&floatAttr)));
|
||||
auto p1 = m_Op<arith::MulFOp>(a, m_Op<arith::AddFOp>(a, m_Constant()));
|
||||
// Last operation that is not the terminator.
|
||||
Operation *lastOp = f.getBody().front().back().getPrevNode();
|
||||
Operation *lastOp = f.getFunctionBody().front().back().getPrevNode();
|
||||
if (p.match(lastOp))
|
||||
llvm::outs()
|
||||
<< "Pattern add(add(a, constant), a) matched and bound constant to: "
|
||||
|
||||
@@ -129,7 +129,7 @@ struct TestInvalidIRPass
|
||||
signalPassFailure();
|
||||
if (!emitInvalidIR)
|
||||
return;
|
||||
OpBuilder b(getOperation().getBody());
|
||||
OpBuilder b(getOperation().getFunctionBody());
|
||||
OperationState state(b.getUnknownLoc(), "test.any_attr_of_i32_str");
|
||||
b.create(state);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ struct TestInvalidParentPass
|
||||
}
|
||||
void runOnOperation() final {
|
||||
FunctionOpInterface op = getOperation();
|
||||
OpBuilder b(getOperation().getBody());
|
||||
OpBuilder b(op.getFunctionBody());
|
||||
b.create<test::TestCallOp>(op.getLoc(), TypeRange(), "some_unknown_func",
|
||||
ValueRange());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user