Skip to contentSkip to conversation

[4477] BSR/BSF TCG conversion

Qemu-devel Fabrice Bellard 1 participant 1 message May 17, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 4477

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4477
Author:   bellard
Date:     2008-05-17 18:44:58 +0000 (Sat, 17 May 2008)

Log Message:
-----------
BSR/BSF TCG conversion

Modified Paths:
--------------

    trunk/target-i386/helper.c
    trunk/target-i386/helper.h
    trunk/target-i386/ops_template.h
    trunk/target-i386/translate.c

Modified: trunk/target-i386/helper.c
===================================================================

target-i386/helper.c +31 -0
@@ -5240,6 +5240,37 @@
 
 #endif
 
+/* bit operations */
+target_ulong helper_bsf(target_ulong t0)
+{
+    int count;
+    target_ulong res;
+
+    res = t0;
+    count = 0;
+    while ((res & 1) == 0) {
+        count++;
+        res >>= 1;
+    }
+    return count;
+}
+
+target_ulong helper_bsr(target_ulong t0)
+{
+    int count;
+    target_ulong res, mask;
+    
+    res = t0;
+    count = TARGET_LONG_BITS - 1;
+    mask = (target_ulong)1 << (TARGET_LONG_BITS - 1);
+    while ((res & mask) == 0) {
+        count--;
+        res <<= 1;
+    }
+    return count;
+}
+
+
 static int compute_all_eflags(void)
 {
     return CC_SRC;

Modified: trunk/target-i386/helper.h
===================================================================

target-i386/helper.h +2 -0
@@ -187,6 +187,8 @@
 void helper_frstor(target_ulong ptr, int data32);
 void helper_fxsave(target_ulong ptr, int data64);
 void helper_fxrstor(target_ulong ptr, int data64);
+target_ulong helper_bsf(target_ulong t0);
+target_ulong helper_bsr(target_ulong t0);
 
 /* MMX/SSE */
 

Modified: trunk/target-i386/ops_template.h
===================================================================

target-i386/ops_template.h +0 -45

51 lines not on this page · raw message

Modified: trunk/target-i386/translate.c
===================================================================

target-i386/translate.c +21 -27

60 lines not on this page · raw message