ARM: Decode the ldrex instruction.
authorGabe Black <gblack@eecs.umich.edu>
Wed, 2 Jun 2010 17:58:07 +0000 (12:58 -0500)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 2 Jun 2010 17:58:07 +0000 (12:58 -0500)
src/arch/arm/isa/formats/mem.isa

index 209f62af49fc4d6345b52043a1138785c836fcc2..6b36e39fb60df59ebe78171e739e4518b5e2cf4e 100644 (file)
@@ -227,12 +227,28 @@ def format ArmSyncMem() {{
           case 0x18:
             return new WarnUnimplemented("strex", machInst);
           case 0x19:
-            return new WarnUnimplemented("ldrex", machInst);
+            return new %(ldrex)s(machInst, rt, rn, true, 0);
+          case 0x1a:
+            return new WarnUnimplemented("strexd", machInst);
+          case 0x1b:
+            return new WarnUnimplemented("ldrexd", machInst);
+          case 0x1c:
+            return new WarnUnimplemented("strexb", machInst);
+          case 0x1d:
+            return new %(ldrexb)s(machInst, rt, rn, true, 0);
+          case 0x1e:
+            return new WarnUnimplemented("strexh", machInst);
+          case 0x1f:
+            return new %(ldrexh)s(machInst, rt, rn, true, 0);
           default:
             return new Unknown(machInst);
         }
     }
-    '''
+    ''' % {
+        "ldrex" : "LDREX_" + loadImmClassName(False, True, False, size=4),
+        "ldrexb" : "LDREXB_" + loadImmClassName(False, True, False, size=1),
+        "ldrexh" : "LDREXH_" + loadImmClassName(False, True, False, size=2)
+    }
 }};
 
 def format Thumb32LdrStrDExTbh() {{
@@ -242,12 +258,16 @@ def format Thumb32LdrStrDExTbh() {{
         const uint32_t op2 = bits(machInst, 21, 20);
         const uint32_t op3 = bits(machInst, 7, 4);
         const IntRegIndex rn = (IntRegIndex)(uint32_t)bits(machInst, 19, 16);
+        const IntRegIndex rt = (IntRegIndex)(uint32_t)bits(machInst, 15, 12);
+        /* This isn't used yet, and that makes gcc upset. */
+        //const IntRegIndex rt2 = (IntRegIndex)(uint32_t)bits(machInst, 11, 8);
         if (bits(op1, 1) == 0 && bits(op2, 1) == 0) {
             if (op1 == 0) {
+                const uint32_t imm = bits(machInst, 7, 0) << 2;
                 if (op2 == 0) {
                     return new WarnUnimplemented("strex", machInst);
                 } else {
-                    return new WarnUnimplemented("ldrex", machInst);
+                    return new %(ldrex)s(machInst, rt, rn, true, imm);
                 }
             } else {
                 if (op2 == 0) {
@@ -268,9 +288,9 @@ def format Thumb32LdrStrDExTbh() {{
                       case 0x1:
                         return new WarnUnimplemented("tbh", machInst);
                       case 0x4:
-                        return new WarnUnimplemented("ldrexb", machInst);
+                        return new %(ldrexb)s(machInst, rt, rn, true, 0);
                       case 0x5:
-                        return new WarnUnimplemented("ldrexh", machInst);
+                        return new %(ldrexh)s(machInst, rt, rn, true, 0);
                       case 0x7:
                         return new WarnUnimplemented("ldrexd", machInst);
                       default:
@@ -286,7 +306,11 @@ def format Thumb32LdrStrDExTbh() {{
             }
         }
     }
-    '''
+    ''' % {
+        "ldrex" : "LDREX_" + loadImmClassName(False, True, False, size=4),
+        "ldrexb" : "LDREXB_" + loadImmClassName(False, True, False, size=1),
+        "ldrexh" : "LDREXH_" + loadImmClassName(False, True, False, size=2)
+    }
 }};
 
 def format Thumb32LoadWord() {{