arm: Don't use a stack allocated mnemonic
authorMitchell Hayenga <Mitchell.Hayenga@ARM.com>
Wed, 23 Apr 2014 09:18:20 +0000 (05:18 -0400)
committerMitchell Hayenga <Mitchell.Hayenga@ARM.com>
Wed, 23 Apr 2014 09:18:20 +0000 (05:18 -0400)
FailUnimplemented passed a stack created mnemonic as a const char * which
causes some grief when the stack goes away.

src/arch/arm/isa/formats/aarch64.isa
src/arch/arm/isa/formats/misc.isa
src/arch/arm/isa/formats/unimp.isa

index 3ed70ce818d9c07387e45ce19c7289285125eb74..c7cc776e34fcd09bedbef6dd598b591823402c97 100644 (file)
@@ -374,9 +374,11 @@ namespace Aarch64
                         return new WarnUnimplemented(read ? "mrs" : "msr",
                                                      machInst, full_mnem);
                     } else {
-                        return new FailUnimplemented(csprintf("%s %s",
-                            read ? "mrs" : "msr", miscRegName[miscReg]).c_str(),
-                            machInst);
+                        return new FailUnimplemented(read ? "mrs" : "msr",
+                                    machInst,
+                                    csprintf("%s %s",
+                                      read ? "mrs" : "msr",
+                                      miscRegName[miscReg]));
                     }
                   }
                   break;
index 647f9846da5356d66c9f6fb9ae85a8eeeaf651a2..0ba114e86da78c2a7e6f246c0fb00308688a82ce 100644 (file)
@@ -139,10 +139,10 @@ let {{
           case MISCREG_NOP:
             return new NopInst(machInst);
           case MISCREG_CP14_UNIMPL:
-            return new FailUnimplemented(
+            return new FailUnimplemented(isRead ? "mrc unknown" : "mcr unknown",
+                    machInst,
                     csprintf("miscreg crn:%d opc1:%d crm:%d opc2:%d %s unknown",
-                    crn, opc1, crm, opc2, isRead ? "read" : "write").c_str(),
-                    machInst);
+                    crn, opc1, crm, opc2, isRead ? "read" : "write"));
           default:
             uint32_t iss = mcrMrcIssBuild(isRead, crm, rt, crn, opc1, opc2);
             if (isRead) {
@@ -183,10 +183,10 @@ let {{
           case MISCREG_NOP:
             return new NopInst(machInst);
           case MISCREG_CP15_UNIMPL:
-            return new FailUnimplemented(
+            return new FailUnimplemented(isRead ? "mrc unkown" : "mcr unkown",
+                    machInst,
                     csprintf("miscreg crn:%d opc1:%d crm:%d opc2:%d %s unknown",
-                    crn, opc1, crm, opc2, isRead ? "read" : "write").c_str(),
-                    machInst);
+                    crn, opc1, crm, opc2, isRead ? "read" : "write"));
           case MISCREG_DCCMVAC:
             return new FlushPipeInst(
                     isRead ? "mrc dccmvac" : "mcr dccmvac", machInst);
@@ -217,9 +217,9 @@ let {{
                     return new Mrc15(machInst, rt, (IntRegIndex)miscReg, iss);
                 return new Mcr15(machInst, (IntRegIndex)miscReg, rt, iss);
             } else {
-                return new FailUnimplemented(csprintf("%s %s",
-                    isRead ? "mrc" : "mcr", miscRegName[miscReg]).c_str(),
-                    machInst);
+                return new FailUnimplemented(isRead ? "mrc" : "mcr", machInst,
+                    csprintf("%s %s", isRead ? "mrc" : "mcr",
+                        miscRegName[miscReg]));
             }
         }
     }
@@ -251,10 +251,9 @@ let {{
 
         switch (miscReg) {
           case MISCREG_CP15_UNIMPL:
-            return new FailUnimplemented(
+            return new FailUnimplemented(isRead ? "mrc" : "mcr", machInst,
                     csprintf("miscreg crm:%d opc1:%d 64-bit %s unknown",
-                    crm, opc1, isRead ? "read" : "write").c_str(),
-                    machInst);
+                    crm, opc1, isRead ? "read" : "write"));
           default:
             if (miscRegInfo[miscReg][MISCREG_WARN_NOT_FAIL]) {
                 std::string full_mnem = csprintf("%s %s",
@@ -278,9 +277,9 @@ let {{
                     return new Mrrc15(machInst, (IntRegIndex) miscReg, rt2, rt, iss);
                 return new Mcrr15(machInst, rt2, rt, (IntRegIndex) miscReg, iss);
             } else {
-                return new FailUnimplemented(csprintf("%s %s",
-                    isRead ? "mrrc" : "mcrr", miscRegName[miscReg]).c_str(),
-                    machInst);
+                return new FailUnimplemented(isRead ? "mrrc" : "mcrr", machInst,
+                    csprintf("%s %s",
+                    isRead ? "mrrc" : "mcrr", miscRegName[miscReg]));
             }
         }
     }
index 8e346112c0f0e8c9310ada35fbdcc38296d491e9..393a210cb8eb7504b7dcddd48211e5776c4c7ae4 100644 (file)
@@ -56,6 +56,10 @@ output header {{
     class FailUnimplemented : public ArmStaticInst
     {
       public:
+        /// Full mnemonic for MRC and MCR instructions including the
+        /// coproc. register name
+        std::string fullMnemonic;
+
         /// Constructor
         FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst)
             : ArmStaticInst(_mnemonic, _machInst, No_OpClass)
@@ -65,6 +69,16 @@ output header {{
             flags[IsNonSpeculative] = true;
         }
 
+        FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst,
+                          const std::string& _fullMnemonic)
+            : ArmStaticInst(_mnemonic, _machInst, No_OpClass),
+              fullMnemonic(_fullMnemonic)
+        {
+            // don't call execute() (which panics) if we're on a
+            // speculative path
+            flags[IsNonSpeculative] = true;
+        }
+
         %(BasicExecDeclare)s
 
         std::string
@@ -137,14 +151,16 @@ output decoder {{
     FailUnimplemented::generateDisassembly(Addr pc,
                                            const SymbolTable *symtab) const
     {
-        return csprintf("%-10s (unimplemented)", mnemonic);
+        return csprintf("%-10s (unimplemented)",
+                        fullMnemonic.size() ? fullMnemonic.c_str() : mnemonic);
     }
 
     std::string
     WarnUnimplemented::generateDisassembly(Addr pc,
                                            const SymbolTable *symtab) const
     {
-        return csprintf("%-10s (unimplemented)", mnemonic);
+        return csprintf("%-10s (unimplemented)",
+                        fullMnemonic.size() ? fullMnemonic.c_str() : mnemonic);
     }
 
     std::string