A64: Implement last four Neon insns
cover A64: Implement last four Neon insns
These two patches implement the last four A64 Neon instructions:
SQNEG, SQABS, USQADD, SUQADD
meaning that we have complete coverage of the userspace instruction set, with the exception of the optional crypto and CRC instructions.
As with the previous set, these are safe changes so I'd like to get them into 2.0 even though they're not strictly speaking bugfixes. Review appreciated :-)
thanks
-- PMM
Alex Bennée (2):
target-arm: A64: Add saturating int ops (SQNEG/SQABS)
target-arm: A64: Add saturating accumulate ops (USQADD/SUQADD)
target-arm/helper.h | 34 ++++++--- target-arm/neon_helper.c | 187 +++++++++++++++++++++++++++++++++++++++++++++ target-arm/translate-a64.c | 160 +++++++++++++++++++++++++++++++++++--- 3 files changed, 359 insertions(+), 22 deletions(-)
Signature · 1 line
1.9.0
PATCH 1/2 target-arm: A64: Add saturating int ops (SQNEG/SQABS)
From: Alex Bennée <[email protected]>
This mostly re-uses the existing NEON helpers with an additional two for the 64 bit case. I also took the opportunity to add TCG_CALL_NO_RWG options to the helpers as they don't modify globals (saturation flags are in the CPU Environment).
--- target-arm/helper.h | 14 +++++++------ target-arm/neon_helper.c | 22 ++++++++++++++++++++ target-arm/translate-a64.c | 51 ++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 75 insertions(+), 12 deletions(-)
target-arm/helper.h +8 -6
@@ -375,12 +375,14 @@ DEF_HELPER_2(neon_mull_s16, i64, i32, i32) DEF_HELPER_1(neon_negl_u16, i64, i64) DEF_HELPER_1(neon_negl_u32, i64, i64) -DEF_HELPER_2(neon_qabs_s8, i32, env, i32) -DEF_HELPER_2(neon_qabs_s16, i32, env, i32) -DEF_HELPER_2(neon_qabs_s32, i32, env, i32) -DEF_HELPER_2(neon_qneg_s8, i32, env, i32) -DEF_HELPER_2(neon_qneg_s16, i32, env, i32) -DEF_HELPER_2(neon_qneg_s32, i32, env, i32) +DEF_HELPER_FLAGS_2(neon_qabs_s8, TCG_CALL_NO_RWG, i32, env, i32) +DEF_HELPER_FLAGS_2(neon_qabs_s16, TCG_CALL_NO_RWG, i32, env, i32) +DEF_HELPER_FLAGS_2(neon_qabs_s32, TCG_CALL_NO_RWG, i32, env, i32) +DEF_HELPER_FLAGS_2(neon_qabs_s64, TCG_CALL_NO_RWG, i64, env, i64) +DEF_HELPER_FLAGS_2(neon_qneg_s8, TCG_CALL_NO_RWG, i32, env, i32) +DEF_HELPER_FLAGS_2(neon_qneg_s16, TCG_CALL_NO_RWG, i32, env, i32) +DEF_HELPER_FLAGS_2(neon_qneg_s32, TCG_CALL_NO_RWG, i32, env, i32) +DEF_HELPER_FLAGS_2(neon_qneg_s64, TCG_CALL_NO_RWG, i64, env, i64) DEF_HELPER_3(neon_abd_f32, i32, i32, i32, ptr)DEF_HELPER_3 (neon_ceq_f32, i32, i32, i32, ptr)
target-arm/neon_helper.c +22 -0
@@ -1776,6 +1776,28 @@ uint32_t HELPER(neon_qneg_s32)(CPUARMState *env, uint32_t x)return x; } +uint64_t HELPER (neon_qabs_s64 )(CPUARMState *env,uint64_t x) +{ +if (x ==SIGNBIT64 ) { +SET_QC (); + x = ~SIGNBIT64 ; + }else if ((int64_t )x <0 ) { + x = -x; + } +return x; +} + +uint64_t HELPER (neon_qneg_s64 )(CPUARMState *env,uint64_t x) +{ +if (x ==SIGNBIT64 ) { +SET_QC (); + x = ~SIGNBIT64 ; + }else { + x = -x; + } +return x; +} +/* NEON Float helpers. */ uint32_t HELPER (neon_abd_f32 )(uint32_t a,uint32_t b,void *fpstp) {
target-arm/translate-a64.c +45 -6
102 lines not on this page · raw message
Signature · 1 line
1.9.0
Re: [Qemu-devel] [PATCH for-2.0 1/2] target-arm: A64: Add saturating int ops (SQNEG/SQABS)
Quoted 7 lines · Peter Maydell
From: Alex Bennée <[email protected]>
This mostly re-uses the existing NEON helpers with an additional two for the 64 bit case. I also took the opportunity to add
TCG_CALL_NO_RWGoptions to the helpers as they don't modify globals (saturation flags are in the CPU Environment).
Quoted 7 lines
Signed-off-by Alex Bennée <[email protected]>Signed-off-by Peter Maydell <[email protected]>--- target-arm/helper.h | 14 +++++++------ target-arm/neon_helper.c | 22 ++++++++++++++++++++ target-arm/translate-a64.c | 51 ++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 75 insertions(+), 12 deletions(-)
r~
PATCH 2/2 target-arm: A64: Add saturating accumulate ops (USQADD/SUQADD)
In reply to Peter MaydellFrom: Alex Bennée <[email protected]>
Add the saturating accumulate operations USQADD and SUQADD to the A64 instruction set. This completes coverage of A64 Neon. These operations (which are unsigned + signed -> signed and signed + unsigned -> unsigned) don't exist in the A32/T32 instruction set, so require a complete new set of helper functions.
--- target-arm/helper.h | 20 ++++-- target-arm/neon_helper.c | 165 +++++++++++++++++++++++++++++++++++++++++++++ target-arm/translate-a64.c | 109 ++++++++++++++++++++++++++++-- 3 files changed, 284 insertions(+), 10 deletions(-)
target-arm/helper.h +14 -6
@@ -186,12 +186,20 @@ DEF_HELPER_FLAGS_2(rints, TCG_CALL_NO_RWG, f32, f32, ptr)DEF_HELPER_FLAGS_2 (rintd,TCG_CALL_NO_RWG , f64, f64, ptr) /* neon_helper.c */ -DEF_HELPER_3(neon_qadd_u8, i32, env, i32, i32) -DEF_HELPER_3(neon_qadd_s8, i32, env, i32, i32) -DEF_HELPER_3(neon_qadd_u16, i32, env, i32, i32) -DEF_HELPER_3(neon_qadd_s16, i32, env, i32, i32) -DEF_HELPER_3(neon_qadd_u32, i32, env, i32, i32) -DEF_HELPER_3(neon_qadd_s32, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_qadd_u8, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_qadd_s8, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_qadd_u16, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_qadd_s16, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_qadd_u32, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_qadd_s32, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_uqadd_s8, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_uqadd_s16, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_uqadd_s32, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_uqadd_s64, TCG_CALL_NO_RWG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(neon_sqadd_u8, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_sqadd_u16, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_sqadd_u32, TCG_CALL_NO_RWG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(neon_sqadd_u64, TCG_CALL_NO_RWG, i64, env, i64, i64) DEF_HELPER_3(neon_qsub_u8, i32, env, i32, i32) DEF_HELPER_3(neon_qsub_s8, i32, env, i32, i32)DEF_HELPER_3 (neon_qsub_u16, i32, env, i32, i32)
target-arm/neon_helper.c +165 -0
171 lines not on this page · raw message
target-arm/translate-a64.c +105 -4
133 lines not on this page · raw message
Signature · 1 line
1.9.0
Re: [Qemu-devel] [PATCH for-2.0 2/2] target-arm: A64: Add saturating accumulate ops (USQADD/SUQADD)
target-arm/neon_helper.c uint64_t HELPER(neon_qadd_s64)(CPUARMState *env, uint64_t src1, uint64_t src2) · line 254
Quoted 4 lines · Peter Maydell
target-arm/neon_helper.c +4
-0+#define USATACC (bits, shift) \ + do { \ + va = (int##bits##_t)((a >> shift) & ((1 << bits) - 1)); \ + vb = (uint##bits##_t)((b >> shift) & ((1 << bits) - 1)); \
The masking seems redundant with the cast.
Perhaps better to use extract32/sextract32?
Quoted 1 line
+ r |= (
uint32_t) (vr & ((1 << bits) - 1)) << shift; \
Perhaps better with deposit32? That implies an unnecessary mask of R, but perhaps the compiler can clean that up...
Otherwise I don't actually see anything wrong,
r~
Re: [Qemu-devel] [PATCH for-2.0 2/2] target-arm: A64: Add saturating accumulate ops (USQADD/SUQADD)
Quoted 6 lines · Richard Henderson
target-arm/neon_helper.c uint64_t HELPER(neon_qadd_s64)(CPUARMState *env, uint64_t src1, uint64_t src2) · line 254
Quoted 4 lines · Peter Maydell
target-arm/neon_helper.c +4
-0+#define USATACC (bits, shift) \ + do { \ + va = (int##bits##_t)((a >> shift) & ((1 << bits) - 1)); \ + vb = (uint##bits##_t)((b >> shift) & ((1 << bits) - 1)); \
Quoted 7 lines
The masking seems redundant with the cast.
Perhaps better to use extract32/sextract32?Quoted 1 line
+ r |= (
uint32_t) (vr & ((1 << bits) - 1)) << shift; \Perhaps better with deposit32? That implies an unnecessary mask of R, but perhaps the compiler can clean that up...
Yeah, it looks much nicer with extract32/deposit32, so I'll just switch it (and SSATACC) to use those.
thanks
-- PMM