Unify branch flags, pretty printer for OpKind.
LIR operand 0 is always an offset for a branch. This is clear in
conditional branches that are binary and have the 2nd operand as the
condition codes of the branch. This changes unconditional branches to be
unary and therefore more intention revealing that the 1st operand will
be used by the assembler to hold an offset.
A << operator for OpKind allows easy pretty printing.
Change-Id: I933b8e0bf43f5be3eff13f93c3fc1539ae526840
diff --git a/src/compiler/IntermediateRep.cc b/src/compiler/IntermediateRep.cc
index 1567fcc..6626877 100644
--- a/src/compiler/IntermediateRep.cc
+++ b/src/compiler/IntermediateRep.cc
@@ -19,6 +19,52 @@
namespace art {
+static const char* gOpKindNames[kOpInvalid + 1] = {
+ "OpMov",
+ "OpMvn",
+ "OpCmp",
+ "OpLsl",
+ "OpLsr",
+ "OpAsr",
+ "OpRor",
+ "OpNot",
+ "OpAnd",
+ "OpOr",
+ "OpXor",
+ "OpNeg",
+ "OpAdd",
+ "OpAdc",
+ "OpSub",
+ "OpSbc",
+ "OpRsub",
+ "OpMul",
+ "OpDiv",
+ "OpRem",
+ "OpBic",
+ "OpCmn",
+ "OpTst",
+ "OpBkpt",
+ "OpBlx",
+ "OpPush",
+ "OpPop",
+ "Op2Char",
+ "Op2Short",
+ "Op2Byte",
+ "OpCondBr",
+ "OpUncondBr",
+ "OpBx",
+ "OpInvalid",
+};
+
+std::ostream& operator<<(std::ostream& os, const OpKind& kind) {
+ if (kind >= kOpMov && kind <= kOpInvalid) {
+ os << gOpKindNames[kind];
+ } else {
+ os << "Unknown Op " << static_cast<int>(kind);
+ }
+ return os;
+}
+
/* Allocate a new basic block */
BasicBlock* oatNewBB(CompilationUnit* cUnit, BBType blockType, int blockId)
{