* [Qemu-devel] [PATCH 0/2] ARM: Fix VQSHL/VQSHLU immediate forms @ 2011-01-03 16:20 Peter Maydell 2011-01-03 16:20 ` [Qemu-devel] [PATCH 1/2] ARM: add neon helpers for VQSHLU Peter Maydell ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Peter Maydell @ 2011-01-03 16:20 UTC (permalink / raw) To: qemu-devel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 768 bytes --] This patchset fixes errors in the decoding and implementation of the immediate forms of the VQSHL/VQSHLU ARM instructions. Tested in the usual random-instruction-set way. This is the final part of the maemo-qemu tree commit 03a2445a fixes (the first part being the already-committed VQSHL-reg patchset); the patch down as authored by me is a minor tweaking of changes in the maemo-qemu commit. Juha Riihimäki (1): ARM: Fix decoding of VQSHL/VQSHLU immediate forms Peter Maydell (1): ARM: add neon helpers for VQSHLU target-arm/helpers.h | 4 +++ target-arm/neon_helper.c | 47 ++++++++++++++++++++++++++++++++++++++++++ target-arm/translate.c | 51 ++++++++++++++++++++++++++++++++------------- 3 files changed, 87 insertions(+), 15 deletions(-) ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/2] ARM: add neon helpers for VQSHLU 2011-01-03 16:20 [Qemu-devel] [PATCH 0/2] ARM: Fix VQSHL/VQSHLU immediate forms Peter Maydell @ 2011-01-03 16:20 ` Peter Maydell 2011-01-04 22:04 ` Aurelien Jarno 2011-01-03 16:20 ` [Qemu-devel] [PATCH 2/2] ARM: Fix decoding of VQSHL/VQSHLU immediate forms Peter Maydell 2011-01-03 16:52 ` [Qemu-devel] [PATCH 0/2] ARM: Fix " Peter Maydell 2 siblings, 1 reply; 6+ messages in thread From: Peter Maydell @ 2011-01-03 16:20 UTC (permalink / raw) To: qemu-devel Add neon helper functions to implement VQSHLU, which is a signed-to-unsigned version of VQSHL available only as an immediate form. Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> --- target-arm/helpers.h | 4 +++ target-arm/neon_helper.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 0 deletions(-) diff --git a/target-arm/helpers.h b/target-arm/helpers.h index 0d1bc47..b88ebae 100644 --- a/target-arm/helpers.h +++ b/target-arm/helpers.h @@ -249,6 +249,10 @@ DEF_HELPER_3(neon_qshl_u32, i32, env, i32, i32) DEF_HELPER_3(neon_qshl_s32, i32, env, i32, i32) DEF_HELPER_3(neon_qshl_u64, i64, env, i64, i64) DEF_HELPER_3(neon_qshl_s64, i64, env, i64, i64) +DEF_HELPER_3(neon_qshlu_s8, i32, env, i32, i32); +DEF_HELPER_3(neon_qshlu_s16, i32, env, i32, i32); +DEF_HELPER_3(neon_qshlu_s32, i32, env, i32, i32); +DEF_HELPER_3(neon_qshlu_s64, i64, env, i64, i64); DEF_HELPER_3(neon_qrshl_u8, i32, env, i32, i32) DEF_HELPER_3(neon_qrshl_s8, i32, env, i32, i32) DEF_HELPER_3(neon_qrshl_u16, i32, env, i32, i32) diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c index dae063e..20f3c16 100644 --- a/target-arm/neon_helper.c +++ b/target-arm/neon_helper.c @@ -632,6 +632,53 @@ uint64_t HELPER(neon_qshl_s64)(CPUState *env, uint64_t valop, uint64_t shiftop) return val; } +#define NEON_FN(dest, src1, src2) do { \ + if (src1 & (1 << (sizeof(src1) * 8 - 1))) { \ + SET_QC(); \ + dest = 0; \ + } else { \ + int8_t tmp; \ + tmp = (int8_t)src2; \ + if (tmp >= (ssize_t)sizeof(src1) * 8) { \ + if (src1) { \ + SET_QC(); \ + dest = ~0; \ + } else { \ + dest = 0; \ + } \ + } else if (tmp <= -(ssize_t)sizeof(src1) * 8) { \ + dest = 0; \ + } else if (tmp < 0) { \ + dest = src1 >> -tmp; \ + } else { \ + dest = src1 << tmp; \ + if ((dest >> tmp) != src1) { \ + SET_QC(); \ + dest = ~0; \ + } \ + } \ + }} while (0) +NEON_VOP_ENV(qshlu_s8, neon_u8, 4) +NEON_VOP_ENV(qshlu_s16, neon_u16, 2) +#undef NEON_FN + +uint32_t HELPER(neon_qshlu_s32)(CPUState *env, uint32_t valop, uint32_t shiftop) +{ + if ((int32_t)valop < 0) { + SET_QC(); + return 0; + } + return helper_neon_qshl_u32(env, valop, shiftop); +} + +uint64_t HELPER(neon_qshlu_s64)(CPUState *env, uint64_t valop, uint64_t shiftop) +{ + if ((int64_t)valop < 0) { + SET_QC(); + return 0; + } + return helper_neon_qshl_u64(env, valop, shiftop); +} /* FIXME: This is wrong. */ #define NEON_FN(dest, src1, src2) do { \ -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] ARM: add neon helpers for VQSHLU 2011-01-03 16:20 ` [Qemu-devel] [PATCH 1/2] ARM: add neon helpers for VQSHLU Peter Maydell @ 2011-01-04 22:04 ` Aurelien Jarno 0 siblings, 0 replies; 6+ messages in thread From: Aurelien Jarno @ 2011-01-04 22:04 UTC (permalink / raw) To: Peter Maydell; +Cc: qemu-devel On Mon, Jan 03, 2011 at 04:20:47PM +0000, Peter Maydell wrote: > Add neon helper functions to implement VQSHLU, which is a > signed-to-unsigned version of VQSHL available only as an > immediate form. > > Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com> > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> > --- > target-arm/helpers.h | 4 +++ > target-arm/neon_helper.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 51 insertions(+), 0 deletions(-) > > diff --git a/target-arm/helpers.h b/target-arm/helpers.h > index 0d1bc47..b88ebae 100644 > --- a/target-arm/helpers.h > +++ b/target-arm/helpers.h > @@ -249,6 +249,10 @@ DEF_HELPER_3(neon_qshl_u32, i32, env, i32, i32) > DEF_HELPER_3(neon_qshl_s32, i32, env, i32, i32) > DEF_HELPER_3(neon_qshl_u64, i64, env, i64, i64) > DEF_HELPER_3(neon_qshl_s64, i64, env, i64, i64) > +DEF_HELPER_3(neon_qshlu_s8, i32, env, i32, i32); > +DEF_HELPER_3(neon_qshlu_s16, i32, env, i32, i32); > +DEF_HELPER_3(neon_qshlu_s32, i32, env, i32, i32); > +DEF_HELPER_3(neon_qshlu_s64, i64, env, i64, i64); > DEF_HELPER_3(neon_qrshl_u8, i32, env, i32, i32) > DEF_HELPER_3(neon_qrshl_s8, i32, env, i32, i32) > DEF_HELPER_3(neon_qrshl_u16, i32, env, i32, i32) > diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c > index dae063e..20f3c16 100644 > --- a/target-arm/neon_helper.c > +++ b/target-arm/neon_helper.c > @@ -632,6 +632,53 @@ uint64_t HELPER(neon_qshl_s64)(CPUState *env, uint64_t valop, uint64_t shiftop) > return val; > } > > +#define NEON_FN(dest, src1, src2) do { \ > + if (src1 & (1 << (sizeof(src1) * 8 - 1))) { \ > + SET_QC(); \ > + dest = 0; \ > + } else { \ > + int8_t tmp; \ > + tmp = (int8_t)src2; \ > + if (tmp >= (ssize_t)sizeof(src1) * 8) { \ > + if (src1) { \ > + SET_QC(); \ > + dest = ~0; \ > + } else { \ > + dest = 0; \ > + } \ > + } else if (tmp <= -(ssize_t)sizeof(src1) * 8) { \ > + dest = 0; \ > + } else if (tmp < 0) { \ > + dest = src1 >> -tmp; \ > + } else { \ > + dest = src1 << tmp; \ > + if ((dest >> tmp) != src1) { \ > + SET_QC(); \ > + dest = ~0; \ > + } \ > + } \ > + }} while (0) > +NEON_VOP_ENV(qshlu_s8, neon_u8, 4) > +NEON_VOP_ENV(qshlu_s16, neon_u16, 2) > +#undef NEON_FN > + > +uint32_t HELPER(neon_qshlu_s32)(CPUState *env, uint32_t valop, uint32_t shiftop) > +{ > + if ((int32_t)valop < 0) { > + SET_QC(); > + return 0; > + } > + return helper_neon_qshl_u32(env, valop, shiftop); > +} I guess defining this function using helper_neon_qshl_u32() instead of using NEON_VOP_ENV(qshlu_s32, neon_u32, 1) is to optimize the generated code. Note that it only make 48 bytes difference, with one jump. > +uint64_t HELPER(neon_qshlu_s64)(CPUState *env, uint64_t valop, uint64_t shiftop) > +{ > + if ((int64_t)valop < 0) { > + SET_QC(); > + return 0; > + } > + return helper_neon_qshl_u64(env, valop, shiftop); > +} > > /* FIXME: This is wrong. */ > #define NEON_FN(dest, src1, src2) do { \ Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] ARM: Fix decoding of VQSHL/VQSHLU immediate forms 2011-01-03 16:20 [Qemu-devel] [PATCH 0/2] ARM: Fix VQSHL/VQSHLU immediate forms Peter Maydell 2011-01-03 16:20 ` [Qemu-devel] [PATCH 1/2] ARM: add neon helpers for VQSHLU Peter Maydell @ 2011-01-03 16:20 ` Peter Maydell 2011-01-04 22:05 ` Aurelien Jarno 2011-01-03 16:52 ` [Qemu-devel] [PATCH 0/2] ARM: Fix " Peter Maydell 2 siblings, 1 reply; 6+ messages in thread From: Peter Maydell @ 2011-01-03 16:20 UTC (permalink / raw) To: qemu-devel From: Juha Riihimäki <juha.riihimaki@nokia.com> Fix errors in the decoding of ARM VQSHL/VQSHLU immediate forms, including using the new VQSHLU helper functions where appropriate. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> --- target-arm/translate.c | 51 +++++++++++++++++++++++++++++++++-------------- 1 files changed, 36 insertions(+), 15 deletions(-) diff --git a/target-arm/translate.c b/target-arm/translate.c index 2598268..1853b5c 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -4647,14 +4647,22 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) case 5: /* VSHL, VSLI */ gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1); break; - case 6: /* VQSHL */ - if (u) - gen_helper_neon_qshl_u64(cpu_V0, cpu_env, cpu_V0, cpu_V1); - else - gen_helper_neon_qshl_s64(cpu_V0, cpu_env, cpu_V0, cpu_V1); + case 6: /* VQSHLU */ + if (u) { + gen_helper_neon_qshlu_s64(cpu_V0, cpu_env, + cpu_V0, cpu_V1); + } else { + return 1; + } break; - case 7: /* VQSHLU */ - gen_helper_neon_qshl_u64(cpu_V0, cpu_env, cpu_V0, cpu_V1); + case 7: /* VQSHL */ + if (u) { + gen_helper_neon_qshl_u64(cpu_V0, cpu_env, + cpu_V0, cpu_V1); + } else { + gen_helper_neon_qshl_s64(cpu_V0, cpu_env, + cpu_V0, cpu_V1); + } break; } if (op == 1 || op == 3) { @@ -4693,17 +4701,30 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) default: return 1; } break; - case 6: /* VQSHL */ - GEN_NEON_INTEGER_OP_ENV(qshl); - break; - case 7: /* VQSHLU */ + case 6: /* VQSHLU */ + if (!u) { + return 1; + } switch (size) { - case 0: gen_helper_neon_qshl_u8(tmp, cpu_env, tmp, tmp2); break; - case 1: gen_helper_neon_qshl_u16(tmp, cpu_env, tmp, tmp2); break; - case 2: gen_helper_neon_qshl_u32(tmp, cpu_env, tmp, tmp2); break; - default: return 1; + case 0: + gen_helper_neon_qshlu_s8(tmp, cpu_env, + tmp, tmp2); + break; + case 1: + gen_helper_neon_qshlu_s16(tmp, cpu_env, + tmp, tmp2); + break; + case 2: + gen_helper_neon_qshlu_s32(tmp, cpu_env, + tmp, tmp2); + break; + default: + return 1; } break; + case 7: /* VQSHL */ + GEN_NEON_INTEGER_OP_ENV(qshl); + break; } dead_tmp(tmp2); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] ARM: Fix decoding of VQSHL/VQSHLU immediate forms 2011-01-03 16:20 ` [Qemu-devel] [PATCH 2/2] ARM: Fix decoding of VQSHL/VQSHLU immediate forms Peter Maydell @ 2011-01-04 22:05 ` Aurelien Jarno 0 siblings, 0 replies; 6+ messages in thread From: Aurelien Jarno @ 2011-01-04 22:05 UTC (permalink / raw) To: Peter Maydell; +Cc: qemu-devel On Mon, Jan 03, 2011 at 04:20:48PM +0000, Peter Maydell wrote: > From: Juha Riihimäki <juha.riihimaki@nokia.com> > > Fix errors in the decoding of ARM VQSHL/VQSHLU immediate forms, > including using the new VQSHLU helper functions where appropriate. > > Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> > --- > target-arm/translate.c | 51 +++++++++++++++++++++++++++++++++-------------- > 1 files changed, 36 insertions(+), 15 deletions(-) > > diff --git a/target-arm/translate.c b/target-arm/translate.c > index 2598268..1853b5c 100644 > --- a/target-arm/translate.c > +++ b/target-arm/translate.c > @@ -4647,14 +4647,22 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) > case 5: /* VSHL, VSLI */ > gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1); > break; > - case 6: /* VQSHL */ > - if (u) > - gen_helper_neon_qshl_u64(cpu_V0, cpu_env, cpu_V0, cpu_V1); > - else > - gen_helper_neon_qshl_s64(cpu_V0, cpu_env, cpu_V0, cpu_V1); > + case 6: /* VQSHLU */ > + if (u) { > + gen_helper_neon_qshlu_s64(cpu_V0, cpu_env, > + cpu_V0, cpu_V1); > + } else { > + return 1; > + } > break; > - case 7: /* VQSHLU */ > - gen_helper_neon_qshl_u64(cpu_V0, cpu_env, cpu_V0, cpu_V1); > + case 7: /* VQSHL */ > + if (u) { > + gen_helper_neon_qshl_u64(cpu_V0, cpu_env, > + cpu_V0, cpu_V1); > + } else { > + gen_helper_neon_qshl_s64(cpu_V0, cpu_env, > + cpu_V0, cpu_V1); > + } > break; > } > if (op == 1 || op == 3) { > @@ -4693,17 +4701,30 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) > default: return 1; > } > break; > - case 6: /* VQSHL */ > - GEN_NEON_INTEGER_OP_ENV(qshl); > - break; > - case 7: /* VQSHLU */ > + case 6: /* VQSHLU */ > + if (!u) { > + return 1; > + } > switch (size) { > - case 0: gen_helper_neon_qshl_u8(tmp, cpu_env, tmp, tmp2); break; > - case 1: gen_helper_neon_qshl_u16(tmp, cpu_env, tmp, tmp2); break; > - case 2: gen_helper_neon_qshl_u32(tmp, cpu_env, tmp, tmp2); break; > - default: return 1; > + case 0: > + gen_helper_neon_qshlu_s8(tmp, cpu_env, > + tmp, tmp2); > + break; > + case 1: > + gen_helper_neon_qshlu_s16(tmp, cpu_env, > + tmp, tmp2); > + break; > + case 2: > + gen_helper_neon_qshlu_s32(tmp, cpu_env, > + tmp, tmp2); > + break; > + default: > + return 1; > } > break; > + case 7: /* VQSHL */ > + GEN_NEON_INTEGER_OP_ENV(qshl); > + break; > } > dead_tmp(tmp2); > > -- > 1.6.3.3 > > > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] ARM: Fix VQSHL/VQSHLU immediate forms 2011-01-03 16:20 [Qemu-devel] [PATCH 0/2] ARM: Fix VQSHL/VQSHLU immediate forms Peter Maydell 2011-01-03 16:20 ` [Qemu-devel] [PATCH 1/2] ARM: add neon helpers for VQSHLU Peter Maydell 2011-01-03 16:20 ` [Qemu-devel] [PATCH 2/2] ARM: Fix decoding of VQSHL/VQSHLU immediate forms Peter Maydell @ 2011-01-03 16:52 ` Peter Maydell 2 siblings, 0 replies; 6+ messages in thread From: Peter Maydell @ 2011-01-03 16:52 UTC (permalink / raw) To: qemu-devel On 3 January 2011 16:20, Peter Maydell <peter.maydell@linaro.org> wrote: > This patchset fixes errors in the decoding and implementation of the > immediate forms of the VQSHL/VQSHLU ARM instructions. > Tested in the usual random-instruction-set way. This is the final part > of the maemo-qemu tree commit 03a2445a fixes (the first part being > the already-committed VQSHL-reg patchset); the patch down as authored > by me is a minor tweaking of changes in the maemo-qemu commit. > > Juha Riihimäki (1): > ARM: Fix decoding of VQSHL/VQSHLU immediate forms > > Peter Maydell (1): > ARM: add neon helpers for VQSHLU Whoops, I changed the wrong patch when I was adjusting the authors for this patchset -- the authors should be the other way round. I'll fix this in a v2 but since it's not a code change I'll see if there's any review commentary first. -- PMM ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-01-04 22:05 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-01-03 16:20 [Qemu-devel] [PATCH 0/2] ARM: Fix VQSHL/VQSHLU immediate forms Peter Maydell 2011-01-03 16:20 ` [Qemu-devel] [PATCH 1/2] ARM: add neon helpers for VQSHLU Peter Maydell 2011-01-04 22:04 ` Aurelien Jarno 2011-01-03 16:20 ` [Qemu-devel] [PATCH 2/2] ARM: Fix decoding of VQSHL/VQSHLU immediate forms Peter Maydell 2011-01-04 22:05 ` Aurelien Jarno 2011-01-03 16:52 ` [Qemu-devel] [PATCH 0/2] ARM: Fix " Peter Maydell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).