diff --git a/mlir/include/mlir/IR/FunctionInterfaces.td b/mlir/include/mlir/IR/FunctionInterfaces.td --- a/mlir/include/mlir/IR/FunctionInterfaces.td +++ b/mlir/include/mlir/IR/FunctionInterfaces.td @@ -169,36 +169,36 @@ 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 @@ /// 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`. diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp --- a/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp @@ -40,8 +40,8 @@ } 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(&op)) { if (failed(convertAffineLoopNestToGPULaunch(forOp, numBlockDims, numThreadDims))) diff --git a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp @@ -106,7 +106,7 @@ matchAndRewrite(FunctionOpInterface op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { rewriter.startRootUpdate(op); - Region ®ion = op.getBody(); + Region ®ion = op.getFunctionBody(); SmallVector conversions; for (Block &block : llvm::drop_begin(region, 1)) { @@ -461,7 +461,7 @@ 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 @@ // boundaries, which we conservatively approximate as all function // signatures. if (auto funcOp = dyn_cast(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) { diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -3077,8 +3077,8 @@ SmallVector 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. diff --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp --- a/mlir/test/lib/IR/TestMatchers.cpp +++ b/mlir/test/lib/IR/TestMatchers.cpp @@ -139,7 +139,7 @@ m_Op(a, m_Op(a, m_Constant(&floatAttr))); auto p1 = m_Op(a, m_Op(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: " diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp --- a/mlir/test/lib/Pass/TestPassManager.cpp +++ b/mlir/test/lib/Pass/TestPassManager.cpp @@ -129,7 +129,7 @@ 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 @@ } void runOnOperation() final { FunctionOpInterface op = getOperation(); - OpBuilder b(getOperation().getBody()); + OpBuilder b(op.getFunctionBody()); b.create(op.getLoc(), TypeRange(), "some_unknown_func", ValueRange()); }