ARM: Implement 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/insts/misc.isa

index 09d27360e0db672f82b386cc71f1c3b27a73eef9..c673372bbd798dffd02416f85a6e35c176adce18 100644 (file)
@@ -174,6 +174,16 @@ let {{
     decoder_output += RevOpConstructor.subst(rbitIop)
     exec_output += PredOpExecute.subst(rbitIop)
 
+    clzCode = '''
+        Dest = (Op1 == 0) ? 32 : (31 - findMsbSet(Op1));
+    '''
+    clzIop = InstObjParams("clz", "ClzInst", "RevOp",
+                           { "code": clzCode,
+                             "predicate_test": predicateTest }, [])
+    header_output += RevOpDeclare.subst(clzIop)
+    decoder_output += RevOpConstructor.subst(clzIop)
+    exec_output += PredOpExecute.subst(clzIop)
+
     ssatCode = '''
         int32_t operand = shift_rm_imm(Op1, shiftAmt, shiftType, 0);
         int32_t res;