Patchwork [1/2,SPARC] Improve sparc handling of ta

login
register
mail settings
Submitter Julien Grall
Date May 17, 2011, 3:32 p.m.
Message ID <BANLkTi=9Dgt2sUx3mHPS+TRLuWEziv=h6g@mail.gmail.com>
Download mbox | patch
Permalink /patch/95948/
State New
Headers show

Comments

Julien Grall - May 17, 2011, 3:32 p.m.
Improve sparc handling of ta

Signed-off-by: Julien Grall <julien.grall@gmail.com>
---
 target-sparc/helper.h    |    1 +
 target-sparc/op_helper.c |    6 ++++++
 target-sparc/translate.c |    7 ++++---
 3 files changed, 11 insertions(+), 3 deletions(-)

--
1.7.4.4
Blue Swirl - May 27, 2011, 5:26 p.m.
On Tue, May 17, 2011 at 6:32 PM, Julien Grall <julien.grall@gmail.com> wrote:
> Improve sparc handling of ta
>
> Signed-off-by: Julien Grall <julien.grall@gmail.com>
> ---
>  target-sparc/helper.h    |    1 +
>  target-sparc/op_helper.c |    6 ++++++
>  target-sparc/translate.c |    7 ++++---
>  3 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/target-sparc/helper.h b/target-sparc/helper.h
> index 12e8557..61ef03a 100644
> --- a/target-sparc/helper.h
> +++ b/target-sparc/helper.h
> @@ -85,6 +85,7 @@ DEF_HELPER_0(fcmpeq_fcc2, void)
>  DEF_HELPER_0(fcmpeq_fcc3, void)
>  #endif
>  DEF_HELPER_1(raise_exception, void, int)
> +DEF_HELPER_1(trap_always, void, int)
>  DEF_HELPER_0(shutdown, void)
>  #define F_HELPER_0_0(name) DEF_HELPER_0(f ## name, void)
>  #define F_HELPER_DQ_0_0(name)                   \
> diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
> index ffffb8c..a6fabad 100644
> --- a/target-sparc/op_helper.c
> +++ b/target-sparc/op_helper.c
> @@ -324,6 +324,12 @@ void HELPER(raise_exception)(int tt)
>     raise_exception(tt);
>  }
>
> +void HELPER(trap_always)(int tt)
> +{
> +    env->exception_index = tt;
> +    do_interrupt(env);

Sorry, I didn't catch this earlier. This should be cpu_loop_exit() and
then the function becomes equal to raise_exception().

> +}
> +
>  void helper_shutdown(void)
>  {
>  #if !defined(CONFIG_USER_ONLY)
> diff --git a/target-sparc/translate.c b/target-sparc/translate.c
> index 3c958b2..b30003b 100644
> --- a/target-sparc/translate.c
> +++ b/target-sparc/translate.c
> @@ -1982,7 +1982,7 @@ static void disas_sparc_insn(DisasContext * dc)
>     case 2:                     /* FPU & Logical Operations */
>         {
>             unsigned int xop = GET_FIELD(insn, 7, 12);
> -            if (xop == 0x3a) {  /* generate trap */
> +            if (xop == 0x3a) {  /* ta, tcc: generate trap */
>                 int cond;
>
>                 cpu_src1 = get_src1(insn, cpu_src1);
> @@ -2015,7 +2015,7 @@ static void disas_sparc_insn(DisasContext * dc)
>                         gen_helper_shutdown();
>
>                     } else {
> -                        gen_helper_raise_exception(cpu_tmp32);
> +                        gen_helper_trap_always(cpu_tmp32);
>                     }
>                 } else if (cond != 0) {
>                     TCGv r_cond = tcg_temp_new();
> @@ -2049,8 +2049,9 @@ static void disas_sparc_insn(DisasContext * dc)
>
>                     gen_set_label(l1);
>                     tcg_temp_free(r_cond);
> +
> +                    gen_op_next_insn();
>                 }
> -                gen_op_next_insn();
>                 tcg_gen_exit_tb(0);
>                 dc->is_br = 1;
>                 goto jmp_insn;
> --
> 1.7.4.4
>
>

Patch

diff --git a/target-sparc/helper.h b/target-sparc/helper.h
index 12e8557..61ef03a 100644
--- a/target-sparc/helper.h
+++ b/target-sparc/helper.h
@@ -85,6 +85,7 @@  DEF_HELPER_0(fcmpeq_fcc2, void)
 DEF_HELPER_0(fcmpeq_fcc3, void)
 #endif
 DEF_HELPER_1(raise_exception, void, int)
+DEF_HELPER_1(trap_always, void, int)
 DEF_HELPER_0(shutdown, void)
 #define F_HELPER_0_0(name) DEF_HELPER_0(f ## name, void)
 #define F_HELPER_DQ_0_0(name)                   \
diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
index ffffb8c..a6fabad 100644
--- a/target-sparc/op_helper.c
+++ b/target-sparc/op_helper.c
@@ -324,6 +324,12 @@  void HELPER(raise_exception)(int tt)
    raise_exception(tt);
 }

+void HELPER(trap_always)(int tt)
+{
+    env->exception_index = tt;
+    do_interrupt(env);
+}
+
 void helper_shutdown(void)
 {
 #if !defined(CONFIG_USER_ONLY)
diff --git a/target-sparc/translate.c b/target-sparc/translate.c
index 3c958b2..b30003b 100644
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -1982,7 +1982,7 @@  static void disas_sparc_insn(DisasContext * dc)
    case 2:                     /* FPU & Logical Operations */
        {
            unsigned int xop = GET_FIELD(insn, 7, 12);
-            if (xop == 0x3a) {  /* generate trap */
+            if (xop == 0x3a) {  /* ta, tcc: generate trap */
                int cond;

                cpu_src1 = get_src1(insn, cpu_src1);
@@ -2015,7 +2015,7 @@  static void disas_sparc_insn(DisasContext * dc)
                        gen_helper_shutdown();

                    } else {
-                        gen_helper_raise_exception(cpu_tmp32);
+                        gen_helper_trap_always(cpu_tmp32);
                    }
                } else if (cond != 0) {
                    TCGv r_cond = tcg_temp_new();
@@ -2049,8 +2049,9 @@  static void disas_sparc_insn(DisasContext * dc)

                    gen_set_label(l1);
                    tcg_temp_free(r_cond);
+
+                    gen_op_next_insn();
                }
-                gen_op_next_insn();
                tcg_gen_exit_tb(0);
                dc->is_br = 1;
                goto jmp_insn;