Initial support for operands and results and SSA constructs, first on
the instruction side of the house.
This has a number of limitations, including that we are still dropping
operands on the floor in the parser. Also, most of the convenience methods
aren't wired up yet. This is enough to get result type lists round tripping
through.
PiperOrigin-RevId: 205148223
diff --git a/lib/IR/AsmPrinter.cpp b/lib/IR/AsmPrinter.cpp
index baddac9..6a2d932 100644
--- a/lib/IR/AsmPrinter.cpp
+++ b/lib/IR/AsmPrinter.cpp
@@ -342,6 +342,8 @@
[&]() { os << ", "; });
os << '}';
}
+
+ // TODO: Print signature type once that is plumbed through to Operation.
}
//===----------------------------------------------------------------------===//
@@ -421,8 +423,30 @@
void CFGFunctionState::print(const OperationInst *inst) {
printOperation(inst);
-}
+ // FIXME: Move this into printOperation when Operation has operands and
+ // results
+
+ // Print the type signature of the operation.
+ os << " : (";
+ interleave(
+ inst->getOperands(),
+ [&](const InstOperand &op) { moduleState->print(op.get()->getType()); },
+ [&]() { os << ", "; });
+ os << ") -> ";
+
+ auto resultList = inst->getResults();
+ if (resultList.size() == 1) {
+ moduleState->print(resultList[0].getType());
+ } else {
+ os << '(';
+ interleave(
+ resultList,
+ [&](const InstResult &result) { moduleState->print(result.getType()); },
+ [&]() { os << ", "; });
+ os << ')';
+ }
+}
void CFGFunctionState::print(const BranchInst *inst) {
os << " br bb" << getBBID(inst->getDest());
}