[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 4/5] libvixl: fix 64bit constants usage
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH v2 4/5] libvixl: fix 64bit constants usage |
Date: |
Mon, 28 Apr 2014 16:02:23 +0100 |
From: Michael Tokarev <address@hidden>
Cherry-pick QEMU commit 0dbcf95a1, because it is still needed
for libvixl 1.3:
disas/libvixl/ contains functions which uses 64bit constants
without using appropriate suffixes, which fails on 32bits.
Fix this by using ULL suffix.
Signed-off-by: Michael Tokarev <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
---
disas/libvixl/a64/disasm-a64.cc | 16 ++++++++--------
disas/libvixl/utils.cc | 20 +++++++++++++-------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/disas/libvixl/a64/disasm-a64.cc b/disas/libvixl/a64/disasm-a64.cc
index 4a2a6df..94b0063 100644
--- a/disas/libvixl/a64/disasm-a64.cc
+++ b/disas/libvixl/a64/disasm-a64.cc
@@ -269,19 +269,19 @@ bool Disassembler::IsMovzMovnImm(unsigned reg_size,
uint64_t value) {
((reg_size == kWRegSize) && (value <= 0xffffffff)));
// Test for movz: 16 bits set at positions 0, 16, 32 or 48.
- if (((value & 0xffffffffffff0000) == 0) ||
- ((value & 0xffffffff0000ffff) == 0) ||
- ((value & 0xffff0000ffffffff) == 0) ||
- ((value & 0x0000ffffffffffff) == 0)) {
+ if (((value & 0xffffffffffff0000ULL) == 0ULL) ||
+ ((value & 0xffffffff0000ffffULL) == 0ULL) ||
+ ((value & 0xffff0000ffffffffULL) == 0ULL) ||
+ ((value & 0x0000ffffffffffffULL) == 0ULL)) {
return true;
}
// Test for movn: NOT(16 bits set at positions 0, 16, 32 or 48).
if ((reg_size == kXRegSize) &&
- (((value & 0xffffffffffff0000) == 0xffffffffffff0000) ||
- ((value & 0xffffffff0000ffff) == 0xffffffff0000ffff) ||
- ((value & 0xffff0000ffffffff) == 0xffff0000ffffffff) ||
- ((value & 0x0000ffffffffffff) == 0x0000ffffffffffff))) {
+ (((value & 0xffffffffffff0000ULL) == 0xffffffffffff0000ULL) ||
+ ((value & 0xffffffff0000ffffULL) == 0xffffffff0000ffffULL) ||
+ ((value & 0xffff0000ffffffffULL) == 0xffff0000ffffffffULL) ||
+ ((value & 0x0000ffffffffffffULL) == 0x0000ffffffffffffULL))) {
return true;
}
if ((reg_size == kWRegSize) &&
diff --git a/disas/libvixl/utils.cc b/disas/libvixl/utils.cc
index 6e3aa71..e6e2516 100644
--- a/disas/libvixl/utils.cc
+++ b/disas/libvixl/utils.cc
@@ -95,7 +95,7 @@ int CountSetBits(uint64_t value, int width) {
VIXL_ASSERT((width == 32) || (width == 64));
// Mask out unused bits to ensure that they are not counted.
- value &= (0xffffffffffffffff >> (64-width));
+ value &= (0xffffffffffffffffULL >> (64-width));
// Add up the set bits.
// The algorithm works by adding pairs of bit fields together iteratively,
@@ -108,12 +108,18 @@ int CountSetBits(uint64_t value, int width) {
// value = h+g+f+e d+c+b+a
// \ |
// value = h+g+f+e+d+c+b+a
- value = ((value >> 1) & 0x5555555555555555) + (value & 0x5555555555555555);
- value = ((value >> 2) & 0x3333333333333333) + (value & 0x3333333333333333);
- value = ((value >> 4) & 0x0f0f0f0f0f0f0f0f) + (value & 0x0f0f0f0f0f0f0f0f);
- value = ((value >> 8) & 0x00ff00ff00ff00ff) + (value & 0x00ff00ff00ff00ff);
- value = ((value >> 16) & 0x0000ffff0000ffff) + (value & 0x0000ffff0000ffff);
- value = ((value >> 32) & 0x00000000ffffffff) + (value & 0x00000000ffffffff);
+ value = ((value >> 1) & 0x5555555555555555ULL) +
+ (value & 0x5555555555555555ULL);
+ value = ((value >> 2) & 0x3333333333333333ULL) +
+ (value & 0x3333333333333333ULL);
+ value = ((value >> 4) & 0x0f0f0f0f0f0f0f0fULL) +
+ (value & 0x0f0f0f0f0f0f0f0fULL);
+ value = ((value >> 8) & 0x00ff00ff00ff00ffULL) +
+ (value & 0x00ff00ff00ff00ffULL);
+ value = ((value >> 16) & 0x0000ffff0000ffffULL) +
+ (value & 0x0000ffff0000ffffULL);
+ value = ((value >> 32) & 0x00000000ffffffffULL) +
+ (value & 0x00000000ffffffffULL);
return value;
}
--
1.9.2
- [Qemu-devel] [PATCH v2 0/5] disas/libvixl: update to upstream 1.3, Peter Maydell, 2014/04/28
- [Qemu-devel] [PATCH v2 1/5] configure: Disable building A64 disassembler for libvixl update, Peter Maydell, 2014/04/28
- [Qemu-devel] [PATCH v2 4/5] libvixl: fix 64bit constants usage,
Peter Maydell <=
- [Qemu-devel] [PATCH v2 3/5] disas/libvixl: Add missing ULL suffixes, Peter Maydell, 2014/04/28
- [Qemu-devel] [PATCH v2 5/5] Revert "configure: Disable building A64 disassembler for libvixl update", Peter Maydell, 2014/04/28
- [Qemu-devel] [PATCH v2 2/5] disas/libvixl: Update to libvixl 1.3, Peter Maydell, 2014/04/28
- Re: [Qemu-devel] [PATCH v2 0/5] disas/libvixl: update to upstream 1.3, Richard Henderson, 2014/04/28