diff mbox

[v4,4/7] target-m68k: move fmove CR to a function

Message ID 20170611231633.32582-5-laurent@vivier.eu (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Vivier June 11, 2017, 11:16 p.m. UTC
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(-)

Comments

Richard Henderson June 12, 2017, 4:13 p.m. UTC | #1
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~
Laurent Vivier June 12, 2017, 5:56 p.m. UTC | #2
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
Richard Henderson June 12, 2017, 6:37 p.m. UTC | #3
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~
Philippe Mathieu-Daudé June 12, 2017, 7:12 p.m. UTC | #4
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:
>          {
>
diff mbox

Patch

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:
         {