about summary refs log tree commit diff stats
path: root/src/tools/bitutils.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-04-11 13:01:51 +0000
committerptitSeb <sebastien.chev@gmail.com>2023-04-11 13:01:51 +0000
commite96b1c810672a2493050a36d32f4961b3158901c (patch)
tree6af9594d202a62567c1cbbc63859b87e3af6d19c /src/tools/bitutils.c
parentfdb6908474979b6602fa2c23087cf4ddc4c988e7 (diff)
downloadbox64-e96b1c810672a2493050a36d32f4961b3158901c.tar.gz
box64-e96b1c810672a2493050a36d32f4961b3158901c.zip
[RV64_DYNAREC] Added 0F BC/BD opcodes
Diffstat (limited to 'src/tools/bitutils.c')
-rw-r--r--src/tools/bitutils.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/tools/bitutils.c b/src/tools/bitutils.c
index 518085c2..fc8879af 100644
--- a/src/tools/bitutils.c
+++ b/src/tools/bitutils.c
@@ -1,6 +1,5 @@
 #include <stdint.h>
 
-const uint64_t deBruijn64 = 0x03f79d71b4ca8b09;
 const uint8_t deBruijn64tab[64] = {
 	0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4,
 	62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5,
@@ -9,9 +8,15 @@ const uint8_t deBruijn64tab[64] = {
 };
 
 int TrailingZeros64(uint64_t x) {
+    static const uint64_t deBruijn64 = 0x03f79d71b4ca8b09ULL;
     if (x == 0) {
         return 64;
     }
 
     return (int)deBruijn64tab[(x&-x)*deBruijn64>>(64-6)];
 }
+
+const uint8_t lead0tab[16] = {
+    //0b0000 0b0001 0b0010 0b0011 0b0100 0b0101 0b0110 0b0111 0b1000...
+        0,      1,     2,     2,     3,     3,    3,     3,     4, 4, 4, 4, 4, 4, 4, 4
+};
\ No newline at end of file