target-arm: fix Neon VUZP, VZIP instructions
cover target-arm: fix Neon VUZP, VZIP instructions
This patch series is a pair of patches from the meego tree which fix bugs in the Neon VZIP and VUZP instructions by abandoning the existing inline implementations in favour of calling out to a straightforward helper function. The inline routines could generate 50+ TCG ops each, which is well over the recommended limit in tcg/README for using helpers instead; they also did not give the correct results...
I've tested these patches using the usual random instruction generation approach.
Juha Riihimäki (2):
target-arm: Move Neon VUZP to a helper function
target-arm: Move Neon VZIP to a helper function
target-arm/helpers.h | 3 + target-arm/neon_helper.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++ target-arm/translate.c | 163 ++------------------------------------------- 3 files changed, 177 insertions(+), 155 deletions(-)
PATCH 1/2 target-arm: Move Neon VUZP to a helper function
From: Juha Riihimäki <[email protected]>
Move the implementation of the Neon VUZP unzip instruction from inline code to a helper function. (At 50+ TCG ops it was well over the ecommended limit for coding inline.) The helper implementation also fixes the handling of the quadword version of the instruction.
--- target-arm/helpers.h | 2 + target-arm/neon_helper.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++ target-arm/translate.c | 82 ++------------------------------------------ 3 files changed, 91 insertions(+), 78 deletions(-)
target-arm/helpers.h +2 -0
@@ -460,4 +460,6 @@ DEF_HELPER_3(iwmmxt_muladdswl, i64, i64, i32, i32) DEF_HELPER_2(set_teecr, void, env, i32) +DEF_HELPER_2(neon_unzip, void, env, i32) +#include "def-helper.h"
target-arm/neon_helper.c +85 -0
88 lines not on this page · raw message
target-arm/translate.c +4 -78
102 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 1/2] target-arm: Move Neon VUZP to a helper function
target-arm/neon_helper.c uint32_t HELPER(neon_acgt_f32)(uint32_t a, uint32_t b) · line 1678
Quoted 10 lines · Peter Maydell
target-arm/neon_helper.c +10
-0+void HELPER (neon_unzip )(CPUState *env,uint32_t insn) +{ + int rd = ((insn >> 18) & 0x10) | ((insn >> 12) & 0x0f); + int rm = ((insn >> 1) & 0x10) | (insn & 0x0f); + int size = (insn >> 18) & 3; + if (insn & 0x40) { /* Q */ + uint64_t zm0 = float64_val(env->vfp.regs[rm]); + uint64_t zm1 = float64_val(env->vfp.regs[rm + 1]); + uint64_t zd0 = float64_val(env->vfp.regs[rd]); + uint64_t zd1 = float64_val(env->vfp.regs[rd + 1]);
I can rework these patches if people don't like the way this is effectively doing decoding in a helper function, incidentally, although I'm not convinced it would end up any nicer overall.
-- PMM
Re: [Qemu-devel] [PATCH 1/2] target-arm: Move Neon VUZP to a helper function
Quoted 15 lines · Peter Maydell
target-arm/neon_helper.c uint32_t HELPER(neon_acgt_f32)(uint32_t a, uint32_t b) · line 1678
Quoted 10 lines · Peter Maydell
target-arm/neon_helper.c +10
-0+void HELPER (neon_unzip )(CPUState *env,uint32_t insn) +{ + int rd = ((insn >> 18) & 0x10) | ((insn >> 12) & 0x0f); + int rm = ((insn >> 1) & 0x10) | (insn & 0x0f); + int size = (insn >> 18) & 3; + if (insn & 0x40) { /* Q */ + uint64_t zm0 = float64_val(env->vfp.regs[rm]); + uint64_t zm1 = float64_val(env->vfp.regs[rm + 1]); + uint64_t zd0 = float64_val(env->vfp.regs[rd]); + uint64_t zd1 = float64_val(env->vfp.regs[rd + 1]);I can rework these patches if people don't like the way this is effectively doing decoding in a helper function, incidentally, although I'm not convinced it would end up any nicer overall.
I do think the preferred way would be to extract rd, rm, size, and Q up-front, rather than having the helper twiddle instruction bits.
-Nathan
Re: [Qemu-devel] [PATCH 1/2] target-arm: Move Neon VUZP to a helper function
Quoted 17 lines · Nathan Froyd
Quoted 15 lines · Peter Maydell
target-arm/neon_helper.c uint32_t HELPER(neon_acgt_f32)(uint32_t a, uint32_t b) · line 1678
Quoted 10 lines · Peter Maydell
target-arm/neon_helper.c +10
-0+void HELPER (neon_unzip )(CPUState *env,uint32_t insn) +{ + int rd = ((insn >> 18) & 0x10) | ((insn >> 12) & 0x0f); + int rm = ((insn >> 1) & 0x10) | (insn & 0x0f); + int size = (insn >> 18) & 3; + if (insn & 0x40) { /* Q */ + uint64_t zm0 = float64_val(env->vfp.regs[rm]); + uint64_t zm1 = float64_val(env->vfp.regs[rm + 1]); + uint64_t zd0 = float64_val(env->vfp.regs[rd]); + uint64_t zd1 = float64_val(env->vfp.regs[rd + 1]);I can rework these patches if people don't like the way this is effectively doing decoding in a helper function, incidentally, although I'm not convinced it would end up any nicer overall.
Quoted 2 lines
I do think the preferred way would be to extract rd, rm, size, and Q up-front, rather than having the helper twiddle instruction bits.
OK. You're happy to still have the helper do the reading and writing of env->vfp.regs[] directly, though?
-- PMM
Re: [Qemu-devel] [PATCH 1/2] target-arm: Move Neon VUZP to a helper function
Quoted 6 lines · Peter Maydell
Quoted 2 lines · Nathan Froyd
I do think the preferred way would be to extract rd, rm, size, and Q up-front, rather than having the helper twiddle instruction bits.
OK. You're happy to still have the helper do the reading and writing of env->vfp.regs[] directly, though?
I think you can make a case either way, but you're passing enough values already that accessing env->vfp.regs directly in the helper seems reasonable.
-Nathan
PATCH 2/2 target-arm: Move Neon VZIP to a helper function
In reply to Peter MaydellFrom: Juha Riihimäki <[email protected]>
Move the implementation of the Neon VUZP unzip instruction from inline code to a helper function. (At 50+ TCG ops it was well over the recommended limit for coding inline.) The helper implementation also gives the correct answers where the inline implementation did not.
--- target-arm/helpers.h | 1 + target-arm/neon_helper.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++ target-arm/translate.c | 81 ++------------------------------------------- 3 files changed, 86 insertions(+), 77 deletions(-)
target-arm/helpers.h +1 -0
@@ -461,5 +461,6 @@ DEF_HELPER_3(iwmmxt_muladdswl, i64, i64, i32, i32) DEF_HELPER_2(set_teecr, void, env, i32) DEF_HELPER_2(neon_unzip, void, env, i32) +DEF_HELPER_2(neon_zip, void, env, i32)#include "def-helper.h"
target-arm/neon_helper.c +81 -0
84 lines not on this page · raw message
target-arm/translate.c +4 -77
95 lines not on this page · raw message
Signature · 1 line
1.7.1