diff options
| author | Chris Lattner <clattner@google.com> | 2018-12-26 11:21:53 -0800 |
|---|---|---|
| committer | jpienaar <jpienaar@google.com> | 2019-03-29 14:36:35 -0700 |
| commit | d613f5ab65bbb80c3f5a0a38fef22cb4878c4358 (patch) | |
| tree | dfa4207dd899f87741ad784fe8fc343afba6885d /mlir/lib/Parser/Parser.cpp | |
| parent | 9a4060d3f50f046973d4e0b61f324bbc6ebbbdb9 (diff) | |
| download | bcm5719-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/Parser/Parser.cpp')
| -rw-r--r-- | mlir/lib/Parser/Parser.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 781ec461b62..1a28648eba9 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -2777,7 +2777,7 @@ class MLFunctionParser : public FunctionParser { public: MLFunctionParser(ParserState &state, MLFunction *function) : FunctionParser(state, Kind::MLFunc), function(function), - builder(function, function->end()) {} + builder(function->getBody()) {} ParseResult parseFunctionBody(); @@ -2796,7 +2796,7 @@ private: ParseResult parseBound(SmallVectorImpl<MLValue *> &operands, AffineMap &map, bool isLower); ParseResult parseIfStmt(); - ParseResult parseElseClause(IfClause *elseClause); + ParseResult parseElseClause(StmtBlock *elseClause); ParseResult parseStatements(StmtBlock *block); ParseResult parseStmtBlock(StmtBlock *block); @@ -2812,7 +2812,7 @@ ParseResult MLFunctionParser::parseFunctionBody() { auto braceLoc = getToken().getLoc(); // Parse statements in this function. - if (parseStmtBlock(function)) + if (parseStmtBlock(function->getBody())) return ParseFailure; return finalizeFunction(function, braceLoc); @@ -3121,7 +3121,7 @@ ParseResult MLFunctionParser::parseIfStmt() { IfStmt *ifStmt = builder.createIf(getEncodedSourceLocation(loc), operands, set); - IfClause *thenClause = ifStmt->getThen(); + StmtBlock *thenClause = ifStmt->getThen(); // When parsing of an if statement body fails, the IR contains // the if statement with the portion of the body that has been @@ -3141,7 +3141,7 @@ ParseResult MLFunctionParser::parseIfStmt() { return ParseSuccess; } -ParseResult MLFunctionParser::parseElseClause(IfClause *elseClause) { +ParseResult MLFunctionParser::parseElseClause(StmtBlock *elseClause) { if (getToken().is(Token::kw_if)) { builder.setInsertionPointToEnd(elseClause); return parseIfStmt(); |

