Parse operations in ML functions. Add builder class for ML functions.
Refactors operation parsing to share functionality between CFG and ML functions. ML function construction now goes through a builder, similar to the way it is done for
CFG functions.
PiperOrigin-RevId: 204779279
diff --git a/lib/IR/AsmPrinter.cpp b/lib/IR/AsmPrinter.cpp
index 7347a81..9a86b85 100644
--- a/lib/IR/AsmPrinter.cpp
+++ b/lib/IR/AsmPrinter.cpp
@@ -258,8 +258,8 @@
void MLFunctionState::print(const Statement *stmt) {
switch (stmt->getKind()) {
- case Statement::Kind::Operation: // TODO
- llvm_unreachable("Operation statement is not yet implemented");
+ case Statement::Kind::Operation:
+ return print(cast<OperationStmt>(stmt));
case Statement::Kind::For:
return print(cast<ForStmt>(stmt));
case Statement::Kind::If:
@@ -274,7 +274,7 @@
void MLFunctionState::print(const ForStmt *stmt) {
os.indent(numSpaces) << "for {\n";
print(static_cast<const StmtBlock *>(stmt));
- os.indent(numSpaces) << "}\n";
+ os.indent(numSpaces) << "}";
}
void MLFunctionState::print(const IfStmt *stmt) {
@@ -286,7 +286,6 @@
print(stmt->getElseClause());
os.indent(numSpaces) << "}";
}
- os << "\n";
}
//===----------------------------------------------------------------------===//