Move code of fmove to/from control register to a function
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
target/m68k/translate.c | 66 ++++++++++++++++++++++++++++++-------------------
1 file changed, 41 insertions(+), 25 deletions(-)
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 049d837..45733ce 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -4099,6 +4099,45 @@ DISAS_INSN(trap)
gen_exception(s, s->pc - 2, EXCP_TRAP0 + (insn & 0xf));
}
+static void gen_op_fmove_fcr(CPUM68KState *env, DisasContext *s,
+ uint32_t insn, uint32_t ext)
+{
+ int mask = (ext >> 10) & 7;
+ int is_write = (ext >> 13) & 1;
+ TCGv val;
+
+ if (is_write) {
+ switch (mask) {
+ case 1: /* FPIAR */
+ case 2: /* FPSR */
+ default:
+ cpu_abort(NULL, "Unimplemented: fmove from control %d", mask);
+ goto undef;
+ case 4: /* FPCR */
+ val = tcg_const_i32(0);
+ DEST_EA(env, insn, OS_LONG, val, NULL);
+ tcg_temp_free(val);
+ break;
+ }
+ return;
+ }
+ switch (mask) {
+ case 1: /* FPIAR */
+ case 2: /* FPSR */
+ default:
+ cpu_abort(NULL, "Unimplemented: fmove to control %d",
+ mask);
+ break;
+ case 4: /* FPCR */
+ /* Not implemented. Ignore writes. */
+ break;
+ }
+ return;
+undef:
+ s->pc -= 2;
+ disas_undef_fpu(env, s, insn);
+}
+
/* ??? FP exceptions are not implemented. Most exceptions are deferred until
immediately before the next FP instruction is executed. */
DISAS_INSN(fpu)
@@ -4177,32 +4216,9 @@ DISAS_INSN(fpu)
tcg_temp_free_i32(tmp32);
return;
case 4: /* fmove to control register. */
- switch ((ext >> 10) & 7) {
- case 4: /* FPCR */
- /* Not implemented. Ignore writes. */
- break;
- case 1: /* FPIAR */
- case 2: /* FPSR */
- default:
- cpu_abort(NULL, "Unimplemented: fmove to control %d",
- (ext >> 10) & 7);
- }
- break;
case 5: /* fmove from control register. */
- switch ((ext >> 10) & 7) {
- case 4: /* FPCR */
- /* Not implemented. Always return zero. */
- tmp32 = tcg_const_i32(0);
- break;
- case 1: /* FPIAR */
- case 2: /* FPSR */
- default:
- cpu_abort(NULL, "Unimplemented: fmove from control %d",
- (ext >> 10) & 7);
- goto undef;
- }
- DEST_EA(env, insn, OS_LONG, tmp32, NULL);
- break;
+ gen_op_fmove_fcr(env, s, insn, ext);
+ return;
case 6: /* fmovem */
case 7:
{
--
2.9.4
On 06/11/2017 04:16 PM, Laurent Vivier wrote: > Move code of fmove to/from control register to a function > > Signed-off-by: Laurent Vivier <laurent@vivier.eu> > --- > target/m68k/translate.c | 66 ++++++++++++++++++++++++++++++------------------- > 1 file changed, 41 insertions(+), 25 deletions(-) In that this is 100% code movement, Reviewed-by: Richard Henderson <rth@twiddle.net> > + cpu_abort(NULL, "Unimplemented: fmove from control %d", mask); > + goto undef; But cpu_abort doesn't return, and will exit qemu. This should be qemu_log_mask(LOG_UNIMP, ...). r~
Le 12/06/2017 à 18:13, Richard Henderson a écrit : > On 06/11/2017 04:16 PM, Laurent Vivier wrote: >> Move code of fmove to/from control register to a function >> >> Signed-off-by: Laurent Vivier <laurent@vivier.eu> >> --- >> target/m68k/translate.c | 66 >> ++++++++++++++++++++++++++++++------------------- >> 1 file changed, 41 insertions(+), 25 deletions(-) > > In that this is 100% code movement, > > Reviewed-by: Richard Henderson <rth@twiddle.net> > > >> + cpu_abort(NULL, "Unimplemented: fmove from control %d", >> mask); >> + goto undef; > > But cpu_abort doesn't return, and will exit qemu. > This should be qemu_log_mask(LOG_UNIMP, ...). Do you want I update the patch to fix that? Thanks, Laurent
On 06/12/2017 10:56 AM, Laurent Vivier wrote: > Le 12/06/2017 à 18:13, Richard Henderson a écrit : >> On 06/11/2017 04:16 PM, Laurent Vivier wrote: >>> Move code of fmove to/from control register to a function >>> >>> Signed-off-by: Laurent Vivier <laurent@vivier.eu> >>> --- >>> target/m68k/translate.c | 66 >>> ++++++++++++++++++++++++++++++------------------- >>> 1 file changed, 41 insertions(+), 25 deletions(-) >> >> In that this is 100% code movement, >> >> Reviewed-by: Richard Henderson <rth@twiddle.net> >> >> >>> + cpu_abort(NULL, "Unimplemented: fmove from control %d", >>> mask); >>> + goto undef; >> >> But cpu_abort doesn't return, and will exit qemu. >> This should be qemu_log_mask(LOG_UNIMP, ...). > > Do you want I update the patch to fix that? Yes please. r~
Hi Laurent,
On 06/11/2017 08:16 PM, Laurent Vivier wrote:
> Move code of fmove to/from control register to a function
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> target/m68k/translate.c | 66 ++++++++++++++++++++++++++++++-------------------
> 1 file changed, 41 insertions(+), 25 deletions(-)
>
> diff --git a/target/m68k/translate.c b/target/m68k/translate.c
> index 049d837..45733ce 100644
> --- a/target/m68k/translate.c
> +++ b/target/m68k/translate.c
> @@ -4099,6 +4099,45 @@ DISAS_INSN(trap)
> gen_exception(s, s->pc - 2, EXCP_TRAP0 + (insn & 0xf));
> }
>
> +static void gen_op_fmove_fcr(CPUM68KState *env, DisasContext *s,
> + uint32_t insn, uint32_t ext)
> +{
> + int mask = (ext >> 10) & 7;
> + int is_write = (ext >> 13) & 1;
> + TCGv val;
> +
> + if (is_write) {
> + switch (mask) {
> + case 1: /* FPIAR */
> + case 2: /* FPSR */
> + default:
> + cpu_abort(NULL, "Unimplemented: fmove from control %d", mask);
> + goto undef;
> + case 4: /* FPCR */
It seems easier to move the 'if (is_write) {' check here
> + val = tcg_const_i32(0);
> + DEST_EA(env, insn, OS_LONG, val, NULL);
> + tcg_temp_free(val);
then '}'
> + break;
> + }
> + return;
> + }
> + switch (mask) {
> + case 1: /* FPIAR */
> + case 2: /* FPSR */
> + default:
> + cpu_abort(NULL, "Unimplemented: fmove to control %d",
> + mask);
> + break;
> + case 4: /* FPCR */
> + /* Not implemented. Ignore writes. */
> + break;
> + }
> + return;
> +undef:
> + s->pc -= 2;
> + disas_undef_fpu(env, s, insn);
> +}
> +
> /* ??? FP exceptions are not implemented. Most exceptions are deferred until
> immediately before the next FP instruction is executed. */
> DISAS_INSN(fpu)
> @@ -4177,32 +4216,9 @@ DISAS_INSN(fpu)
> tcg_temp_free_i32(tmp32);
> return;
> case 4: /* fmove to control register. */
> - switch ((ext >> 10) & 7) {
> - case 4: /* FPCR */
> - /* Not implemented. Ignore writes. */
> - break;
> - case 1: /* FPIAR */
> - case 2: /* FPSR */
> - default:
> - cpu_abort(NULL, "Unimplemented: fmove to control %d",
> - (ext >> 10) & 7);
> - }
> - break;
> case 5: /* fmove from control register. */
> - switch ((ext >> 10) & 7) {
> - case 4: /* FPCR */
> - /* Not implemented. Always return zero. */
> - tmp32 = tcg_const_i32(0);
> - break;
> - case 1: /* FPIAR */
> - case 2: /* FPSR */
> - default:
> - cpu_abort(NULL, "Unimplemented: fmove from control %d",
> - (ext >> 10) & 7);
> - goto undef;
> - }
> - DEST_EA(env, insn, OS_LONG, tmp32, NULL);
> - break;
> + gen_op_fmove_fcr(env, s, insn, ext);
> + return;
> case 6: /* fmovem */
> case 7:
> {
>
© 2016 - 2025 Red Hat, Inc.