]> git.proxmox.com Git - qemu.git/commitdiff
target-arm: Use sextract32() in branch decode
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 10 Sep 2013 18:09:32 +0000 (19:09 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 10 Sep 2013 18:09:32 +0000 (19:09 +0100)
In the decode of ARM B and BL insns, swap the order of the
"append 2 implicit zeros to imm24" and the sign extend, and
use the new sextract32() utility function to do the latter.
This avoids a direct dependency on the undefined C behaviour
of shifting into the sign bit of an integer.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-id: 1378391908-22137-2-git-send-email-peter.maydell@linaro.org

target-arm/translate.c

index 4f4a0a97d20ef04d026c5ca48ef86d123ebacdd0..8bcfaf3e1b3c68b6078b3d47eaa1a66b171d55f7 100644 (file)
@@ -28,6 +28,7 @@
 #include "disas/disas.h"
 #include "tcg-op.h"
 #include "qemu/log.h"
+#include "qemu/bitops.h"
 
 #include "helper.h"
 #define GEN_HELPER 1
@@ -7957,8 +7958,8 @@ static void disas_arm_insn(CPUARMState * env, DisasContext *s)
                     tcg_gen_movi_i32(tmp, val);
                     store_reg(s, 14, tmp);
                 }
-                offset = (((int32_t)insn << 8) >> 8);
-                val += (offset << 2) + 4;
+                offset = sextract32(insn << 2, 0, 26);
+                val += offset + 4;
                 gen_jmp(s, val);
             }
             break;