[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 18/28] target-ppc: Altivec 2.07: Change Bit Masks to S
From: |
Tom Musta |
Subject: |
[Qemu-ppc] [PATCH 18/28] target-ppc: Altivec 2.07: Change Bit Masks to Support 64-bit Rotates and Shifts |
Date: |
Wed, 12 Feb 2014 15:23:09 -0600 |
Existing code in the VROTATE, VSL and VSR macros for the Altivec rotate and
shift
helpers uses a formula to compute a bit mask used to extract the rotate/shift
amount from the VRB register. What is desired is:
mask = (1 << (3 + log2(sizeof(element)))) - 1
but what is implemented is:
mask = (1 << (3 + (sizeof(element)/2))) - 1
This produces correct answers when "element" is uint8_t, uint16_t or uint_32t.
But
it breaks down when element is uint64_t.
This patch corrects the situation. Since the mask is known at compile time, the
macros are changed to simply accept the mask as an argument.
Subsequent patches in this series will add double-word variants of rotates and
shifts and thus take advantage of this fix.
Signed-off-by: Tom Musta <address@hidden>
---
target-ppc/int_helper.c | 40 +++++++++++++++-------------------------
1 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index 56e8d9a..59b5a1f 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -1128,23 +1128,20 @@ VRFI(p, float_round_up)
VRFI(z, float_round_to_zero)
#undef VRFI
-#define VROTATE(suffix, element) \
+#define VROTATE(suffix, element, mask) \
void helper_vrl##suffix(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \
{ \
int i; \
\
for (i = 0; i < ARRAY_SIZE(r->element); i++) { \
- unsigned int mask = ((1 << \
- (3 + (sizeof(a->element[0]) >> 1))) \
- - 1); \
unsigned int shift = b->element[i] & mask; \
r->element[i] = (a->element[i] << shift) | \
(a->element[i] >> (sizeof(a->element[0]) * 8 - shift)); \
} \
}
-VROTATE(b, u8)
-VROTATE(h, u16)
-VROTATE(w, u32)
+VROTATE(b, u8, 0x7)
+VROTATE(h, u16, 0xF)
+VROTATE(w, u32, 0x1F)
#undef VROTATE
void helper_vrsqrtefp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *b)
@@ -1225,23 +1222,20 @@ VSHIFT(r, RIGHT)
#undef LEFT
#undef RIGHT
-#define VSL(suffix, element) \
+#define VSL(suffix, element, mask) \
void helper_vsl##suffix(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \
{ \
int i; \
\
for (i = 0; i < ARRAY_SIZE(r->element); i++) { \
- unsigned int mask = ((1 << \
- (3 + (sizeof(a->element[0]) >> 1))) \
- - 1); \
unsigned int shift = b->element[i] & mask; \
\
r->element[i] = a->element[i] << shift; \
} \
}
-VSL(b, u8)
-VSL(h, u16)
-VSL(w, u32)
+VSL(b, u8, 0x7)
+VSL(h, u16, 0x0F)
+VSL(w, u32, 0x1F)
#undef VSL
void helper_vsldoi(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t shift)
@@ -1325,26 +1319,22 @@ VSPLTI(h, s16, int16_t)
VSPLTI(w, s32, int32_t)
#undef VSPLTI
-#define VSR(suffix, element) \
+#define VSR(suffix, element, mask) \
void helper_vsr##suffix(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \
{ \
int i; \
\
for (i = 0; i < ARRAY_SIZE(r->element); i++) { \
- unsigned int mask = ((1 << \
- (3 + (sizeof(a->element[0]) >> 1))) \
- - 1); \
unsigned int shift = b->element[i] & mask; \
- \
r->element[i] = a->element[i] >> shift; \
} \
}
-VSR(ab, s8)
-VSR(ah, s16)
-VSR(aw, s32)
-VSR(b, u8)
-VSR(h, u16)
-VSR(w, u32)
+VSR(ab, s8, 0x7)
+VSR(ah, s16, 0xF)
+VSR(aw, s32, 0x1F)
+VSR(b, u8, 0x7)
+VSR(h, u16, 0xF)
+VSR(w, u32, 0x1F)
#undef VSR
void helper_vsro(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
--
1.7.1
- [Qemu-ppc] [PATCH 20/28] target-ppc: Altivec 2.07: Quadword Addition and Subtracation, (continued)
- [Qemu-ppc] [PATCH 20/28] target-ppc: Altivec 2.07: Quadword Addition and Subtracation, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 21/28] target-ppc: Altivec 2.07: vbpermq Instruction, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 22/28] target-ppc: Altivec 2.07: Doubleword Compares, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 23/28] target-ppc: Altivec 2.07: Vector Gather Bits by Bytes, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 24/28] target-ppc: Altivec 2.07: Vector Polynomial Multiply Sum, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 25/28] target-ppc: Altivec 2.07: Binary Coded Decimal Instructions, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 26/28] target-ppc: Altivec 2.07: AES Instructions, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 27/28] target-ppc: Altivec 2.07: Vector SHA Sigma Instructions, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 28/28] target-ppc: Altivec 2.07: Vector Permute and Exclusive OR, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 19/28] target-ppc: Altivec 2.07: Vector Doubleword Rotate and Shift Instructions, Tom Musta, 2014/02/12
- [Qemu-ppc] [PATCH 18/28] target-ppc: Altivec 2.07: Change Bit Masks to Support 64-bit Rotates and Shifts,
Tom Musta <=
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Richard W.M. Jones, 2014/02/18
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Tom Musta, 2014/02/18
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Richard W.M. Jones, 2014/02/20
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Richard W.M. Jones, 2014/02/20
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Alexander Graf, 2014/02/20
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Richard W.M. Jones, 2014/02/20
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Aneesh Kumar K.V, 2014/02/21
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Avik Sil, 2014/02/21
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Alexander Graf, 2014/02/21
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 00/28] target-ppc: Altivec 2.07, Peter Maydell, 2014/02/21