summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorChris Lattner <clattner@google.com>2018-12-26 11:21:53 -0800
committerjpienaar <jpienaar@google.com>2019-03-29 14:36:35 -0700
commitd613f5ab65bbb80c3f5a0a38fef22cb4878c4358 (patch)
treedfa4207dd899f87741ad784fe8fc343afba6885d /mlir/lib/IR/Function.cpp
parent9a4060d3f50f046973d4e0b61f324bbc6ebbbdb9 (diff)
downloadbcm5719-llvm-d613f5ab65bbb80c3f5a0a38fef22cb4878c4358.tar.gz
bcm5719-llvm-d613f5ab65bbb80c3f5a0a38fef22cb4878c4358.zip
Refactor MLFunction to contain a StmtBlock for its body instead of inheriting
from it. This is necessary progress to squaring away the parent relationship that a StmtBlock has with its enclosing if/for/fn, and makes room for functions to have more than one block in the future. This also removes IfClause and ForStmtBody. This is step 5/n towards merging instructions and statements, NFC. PiperOrigin-RevId: 226936541
Diffstat (limited to 'mlir/lib/IR/Function.cpp')
-rw-r--r--mlir/lib/IR/Function.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp
index b79e1596a65..533be8e2a29 100644
--- a/mlir/lib/IR/Function.cpp
+++ b/mlir/lib/IR/Function.cpp
@@ -202,14 +202,13 @@ MLFunction *MLFunction::create(Location location, StringRef name,
MLFunction::MLFunction(Location location, StringRef name, FunctionType type,
ArrayRef<NamedAttribute> attrs)
- : Function(Kind::MLFunc, location, name, type, attrs),
- StmtBlock(StmtBlockKind::MLFunc) {}
+ : Function(Kind::MLFunc, location, name, type, attrs), body(this) {}
MLFunction::~MLFunction() {
// Explicitly erase statements instead of relying of 'StmtBlock' destructor
// since child statements need to be destroyed before function arguments
// are destroyed.
- clear();
+ getBody()->clear();
// Explicitly run the destructors for the function arguments.
for (auto &arg : getArgumentsInternal())
@@ -222,11 +221,11 @@ void MLFunction::destroy() {
}
const OperationStmt *MLFunction::getReturnStmt() const {
- return cast<OperationStmt>(&back());
+ return cast<OperationStmt>(&getBody()->back());
}
OperationStmt *MLFunction::getReturnStmt() {
- return cast<OperationStmt>(&back());
+ return cast<OperationStmt>(&getBody()->back());
}
void MLFunction::walk(std::function<void(OperationStmt *)> callback) {
OpenPOWER on IntegriCloud