arch-arm: RBIT instruction using mirroring func
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 18 Oct 2017 00:18:46 +0000 (01:18 +0100)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 20 Oct 2017 15:33:40 +0000 (15:33 +0000)
The high speed bit-reversing function is now used
for the Aarch64/32 RBIT instruction implementation.

Change-Id: Id5a8a93d928d00fd33ec4061fbb586b8420a1c1b
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/5262
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/arch/arm/isa/insts/data64.isa
src/arch/arm/isa/insts/misc.isa

index 48fc87ccb16ede8350f520af6f6fc12f02a1f517..3284d5b2a09b8a3f55598036fa9e6b948e0f3839 100644 (file)
@@ -248,18 +248,7 @@ let {{
         Dest64 = (Op164 == 0) ? intWidth : (intWidth - 1 - findMsbSet(Op164));
     ''')
     buildDataXRegInst("rbit", 1, '''
-        uint64_t result = Op164;
-        uint64_t lBit = 1ULL << (intWidth - 1);
-        uint64_t rBit = 1ULL;
-        while (lBit > rBit) {
-            uint64_t maskBits = lBit | rBit;
-            uint64_t testBits = result & maskBits;
-            // If these bits are different, swap them by toggling them.
-            if (testBits && testBits != maskBits)
-                result ^= maskBits;
-            lBit >>= 1; rBit <<= 1;
-        }
-        Dest64 = result;
+        Dest64 = reverseBits(Op164, intWidth/8);
     ''')
     buildDataXRegInst("rev", 1, '''
         if (intWidth == 32)
index 5eda615b5506c383e56c83cc2c8078f897b485d0..edeb0f6d30015b1cc03455f305e69fcd7f4fc5a8 100644 (file)
@@ -329,17 +329,7 @@ let {{
     exec_output += PredOpExecute.subst(revshIop)
 
     rbitCode = '''
-    uint8_t *opBytes = (uint8_t *)&Op1;
-    uint32_t resTemp;
-    uint8_t *destBytes = (uint8_t *)&resTemp;
-    // This reverses the bytes and bits of the input, or so says the
-    // internet.
-    for (int i = 0; i < 4; i++) {
-        uint32_t temp = opBytes[i];
-        temp = (temp * 0x0802 & 0x22110) | (temp * 0x8020 & 0x88440);
-        destBytes[3 - i] = (temp * 0x10101) >> 16;
-    }
-    Dest = resTemp;
+    Dest = reverseBits(Op1);
     '''
     rbitIop = InstObjParams("rbit", "Rbit", "RegRegOp",
                             { "code": rbitCode,