ARM: Decode the clz instruction.
authorGabe Black <gblack@eecs.umich.edu>
Wed, 2 Jun 2010 17:58:08 +0000 (12:58 -0500)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 2 Jun 2010 17:58:08 +0000 (12:58 -0500)
src/arch/arm/isa/decoder/arm.isa
src/arch/arm/isa/formats/branch.isa
src/arch/arm/isa/formats/data.isa
src/arch/arm/isa/insts/misc.isa

index fe8e1ed2e02b7040aa648acc5b86f1b77956cd09..ca74a2c1e5dfb54309342e2ff8c572dca94ffed8 100644 (file)
@@ -67,12 +67,7 @@ format DataOp {
             1: decode OPCODE_7 {
                 0x0: decode MISC_OPCODE {
                     0x0: ArmMsrMrs::armMsrMrs();
-                    0x1: decode OPCODE {
-                        0x9: ArmBx::armBx();
-                        0xb: PredOp::clz({{
-                            Rd = ((Rm == 0) ? 32 : (31 - findMsbSet(Rm)));
-                        }});
-                    }
+                    0x1: ArmBxClz::armBxClz();
                     0x2: decode OPCODE {
                         0x9: WarnUnimpl::bxj();
                     }
index 999126081eef40fd507c09c605d429e9dadb7cdd..07f39b1294b836179a22dc7d00b5ddd4183d16a9 100644 (file)
@@ -71,10 +71,20 @@ def format ArmBlBlxImm() {{
     '''
 }};
 
-def format ArmBx() {{
+def format ArmBxClz() {{
     decode_block = '''
-        return new BxReg(machInst, (IntRegIndex)(uint32_t)bits(machInst, 3, 0),
-                         (ConditionCode)(uint32_t)machInst.condCode);
+    {
+        const IntRegIndex rm = (IntRegIndex)(uint32_t)bits(machInst, 3, 0);
+        const IntRegIndex rd = (IntRegIndex)(uint32_t)bits(machInst, 15, 12);
+        if (OPCODE == 0x9) {
+            return new BxReg(machInst, rm,
+                    (ConditionCode)(uint32_t)machInst.condCode);
+        } else if (OPCODE == 0xb) {
+            return new Clz(machInst, rd, rm);
+        } else {
+            return new Unknown(machInst);
+        }
+    }
     '''
 }};
 
index 9dca0e8a3a753163ce85583fa3601832dae4451f..03f94075c9b11ce5a9e69701dfe85709f24f7042 100644 (file)
@@ -803,7 +803,7 @@ def format Thumb32DataProcReg() {{
                     break;
                   case 0x3:
                     if (op2 == 0) {
-                        return new WarnUnimplemented("clz", machInst);
+                        return new Clz(machInst, rd, rm);
                     }
                 }
             }
index c673372bbd798dffd02416f85a6e35c176adce18..d7fa310b7486cf8b1da8906cdb77319fa4a624bf 100644 (file)
@@ -177,7 +177,7 @@ let {{
     clzCode = '''
         Dest = (Op1 == 0) ? 32 : (31 - findMsbSet(Op1));
     '''
-    clzIop = InstObjParams("clz", "ClzInst", "RevOp",
+    clzIop = InstObjParams("clz", "Clz", "RevOp",
                            { "code": clzCode,
                              "predicate_test": predicateTest }, [])
     header_output += RevOpDeclare.subst(clzIop)