ARM: Write a function for printing mnemonics and predicates.
authorGabe Black <gblack@eecs.umich.edu>
Sat, 27 Jun 2009 07:29:12 +0000 (00:29 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Sat, 27 Jun 2009 07:29:12 +0000 (00:29 -0700)
src/arch/arm/insts/branch.cc
src/arch/arm/insts/mem.cc
src/arch/arm/insts/pred_inst.cc
src/arch/arm/insts/static_inst.cc
src/arch/arm/insts/static_inst.hh

index 5160994f4e01975cd7ebeb9c09f2dad4176c043f..39ad041c8025d55e92268cf183588653bf5c238f 100644 (file)
@@ -70,7 +70,7 @@ Branch::generateDisassembly(Addr pc, const SymbolTable *symtab) const
 {
     std::stringstream ss;
 
-    ccprintf(ss, "%-10s ", mnemonic);
+    printMnemonic(ss);
 
     Addr target = pc + 8 + disp;
 
@@ -87,13 +87,10 @@ std::string
 BranchExchange::generateDisassembly(Addr pc, const SymbolTable *symtab) const
 {
     std::stringstream ss;
-
-    ccprintf(ss, "%-10s ", mnemonic);
-
+    printMnemonic(ss);
     if (_numSrcRegs > 0) {
         printReg(ss, _srcRegIdx[0]);
     }
-
     return ss.str();
 }
 
@@ -101,9 +98,7 @@ std::string
 Jump::generateDisassembly(Addr pc, const SymbolTable *symtab) const
 {
     std::stringstream ss;
-
-    ccprintf(ss, "%-10s ", mnemonic);
-
+    printMnemonic(ss);
     return ss.str();
 }
 }
index e5e91a9ea7664381b7727ca564442c4a285cf175..7909330aacb7735c1215a9a9111d15d18d27890f 100644 (file)
@@ -35,12 +35,16 @@ namespace ArmISA
 std::string
 Memory::generateDisassembly(Addr pc, const SymbolTable *symtab) const
 {
-    return csprintf("%-10s", mnemonic);
+    std::stringstream ss;
+    printMnemonic(ss);
+    return ss.str();
 }
 
 std::string
 MemoryNoDisp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
 {
-    return csprintf("%-10s", mnemonic);
+    std::stringstream ss;
+    printMnemonic(ss);
+    return ss.str();
 }
 }
index 416815aa84bdd224b6e1058a813895ae4bf07ce5..7fd891b194d49573965df42dbe9d3a96dbf9de96 100644 (file)
@@ -35,9 +35,7 @@ std::string
 PredOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
 {
     std::stringstream ss;
-
-    ccprintf(ss, "%-10s ", mnemonic);
-
+    printMnemonic(ss);
     if (_numDestRegs > 0) {
         printReg(ss, _destRegIdx[0]);
     }
index 1a7853f2c60165f77ee2e7103337d670196ca6ee..6b641d8bb4f380351c1d9413e11e636b24bd5ba0 100644 (file)
@@ -245,14 +245,76 @@ ArmStaticInst::printReg(std::ostream &os, int reg) const
     }
 }
 
+void
+ArmStaticInst::printMnemonic(std::ostream &os,
+                             const std::string &suffix,
+                             bool withPred) const
+{
+    os << "  " << mnemonic;
+    if (withPred) {
+        unsigned condCode = machInst.condCode;
+        switch (condCode) {
+          case COND_EQ:
+            os << "eq";
+            break;
+          case COND_NE:
+            os << "ne";
+            break;
+          case COND_CS:
+            os << "cs";
+            break;
+          case COND_CC:
+            os << "cc";
+            break;
+          case COND_MI:
+            os << "mi";
+            break;
+          case COND_PL:
+            os << "pl";
+            break;
+          case COND_VS:
+            os << "vs";
+            break;
+          case COND_VC:
+            os << "vc";
+            break;
+          case COND_HI:
+            os << "hi";
+            break;
+          case COND_LS:
+            os << "ls";
+            break;
+          case COND_GE:
+            os << "ge";
+            break;
+          case COND_LT:
+            os << "lt";
+            break;
+          case COND_GT:
+            os << "gt";
+            break;
+          case COND_LE:
+            os << "le";
+            break;
+          case COND_AL:
+            // This one is implicit.
+            break;
+          case COND_NV:
+            os << "nv";
+            break;
+          default:
+            panic("Unrecognized condition code %d.\n", condCode);
+        }
+        os << suffix << "   ";
+    }
+}
+
 std::string
 ArmStaticInst::generateDisassembly(Addr pc,
                                    const SymbolTable *symtab) const
 {
     std::stringstream ss;
-
-    ccprintf(ss, "%-10s ", mnemonic);
-
+    printMnemonic(ss);
     return ss.str();
 }
 }
index 6321f0de9ee27e44ec7bc7f1bb357b31a02fe10c..ca4cb0f642d416604233c41fc8bf2cc889932696 100644 (file)
@@ -62,6 +62,9 @@ class ArmStaticInst : public StaticInst
     /// Print a register name for disassembly given the unique
     /// dependence tag number (FP or int).
     void printReg(std::ostream &os, int reg) const;
+    void printMnemonic(std::ostream &os,
+                       const std::string &suffix = "",
+                       bool withPred = true) const;
 
     std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
 };