Patchwork [10/12] target-arm: replace tcg_gen_rori_i32 by tcg_gen_rotri_i32

login
register
mail settings
Submitter Juha.Riihimaki@nokia.com
Date Oct. 21, 2009, 10:18 a.m.
Message ID <E6798041-CBE7-46A4-A85F-CA0EC4CB9D43@nokia.com>
Download mbox | patch
Permalink /patch/36521/
State New
Headers show

Comments

Juha.Riihimaki@nokia.com - Oct. 21, 2009, 10:18 a.m.
Use native rotation if possible instead of a simulated one.

From: Filip Navara <filip.navara@gmail.com>
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
---
      TCGv tmp = new_tmp();
@@ -484,7 +469,7 @@ static inline void gen_arm_shift_im(TCGv var, int  
shiftop, int shift, int flags)
          if (shift != 0) {
              if (flags)
                  shifter_out_im(var, shift - 1);
-            tcg_gen_rori_i32(var, var, shift); break;
+            tcg_gen_rotri_i32(var, var, shift); break;
          } else {
              TCGv tmp = load_cpu_field(CF);
              if (flags)
@@ -6634,7 +6619,7 @@ static void disas_arm_insn(CPUState * env,  
DisasContext *s)
                          /* ??? In many cases it's not neccessary to  
do a
                             rotate, a shift is sufficient.  */
                          if (shift != 0)
-                            tcg_gen_rori_i32(tmp, tmp, shift * 8);
+                            tcg_gen_rotri_i32(tmp, tmp, shift * 8);
                          op1 = (insn >> 20) & 7;
                          switch (op1) {
                          case 0: gen_sxtb16(tmp);  break;
@@ -7451,7 +7436,7 @@ static int disas_thumb2_insn(CPUState *env,  
DisasContext *s, uint16_t insn_hw1)
              /* ??? In many cases it's not neccessary to do a
                 rotate, a shift is sufficient.  */
              if (shift != 0)
-                tcg_gen_rori_i32(tmp, tmp, shift * 8);
+                tcg_gen_rotri_i32(tmp, tmp, shift * 8);
              op = (insn >> 20) & 7;
              switch (op) {
              case 0: gen_sxth(tmp);   break;
Laurent Desnogues - Oct. 21, 2009, 10:49 a.m.
On Wed, Oct 21, 2009 at 12:18 PM,  <Juha.Riihimaki@nokia.com> wrote:
> Use native rotation if possible instead of a simulated one.
>
> From: Filip Navara <filip.navara@gmail.com>
> Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>

Acked-by: Laurent Desnogues <laurent.desnogues@gmail.com>

> ---
> diff --git a/target-arm/translate.c b/target-arm/translate.c
> index 99a9ffd..1734fae 100644
> --- a/target-arm/translate.c
> +++ b/target-arm/translate.c
> @@ -418,21 +418,6 @@ static inline void tcg_gen_bic_i32(TCGv dest,
> TCGv t0, TCGv t1)
>  /* FIXME:  Implement this natively.  */
>  #define tcg_gen_abs_i32(t0, t1) gen_helper_abs(t0, t1)
>
> -/* FIXME:  Implement this natively.  */
> -static void tcg_gen_rori_i32(TCGv t0, TCGv t1, int i)
> -{
> -    TCGv tmp;
> -
> -    if (i == 0)
> -        return;
> -
> -    tmp = new_tmp();
> -    tcg_gen_shri_i32(tmp, t1, i);
> -    tcg_gen_shli_i32(t1, t1, 32 - i);
> -    tcg_gen_or_i32(t0, t1, tmp);
> -    dead_tmp(tmp);
> -}
> -
>  static void shifter_out_im(TCGv var, int shift)
>  {
>      TCGv tmp = new_tmp();
> @@ -484,7 +469,7 @@ static inline void gen_arm_shift_im(TCGv var, int
> shiftop, int shift, int flags)
>          if (shift != 0) {
>              if (flags)
>                  shifter_out_im(var, shift - 1);
> -            tcg_gen_rori_i32(var, var, shift); break;
> +            tcg_gen_rotri_i32(var, var, shift); break;
>          } else {
>              TCGv tmp = load_cpu_field(CF);
>              if (flags)
> @@ -6634,7 +6619,7 @@ static void disas_arm_insn(CPUState * env,
> DisasContext *s)
>                          /* ??? In many cases it's not neccessary to
> do a
>                             rotate, a shift is sufficient.  */
>                          if (shift != 0)
> -                            tcg_gen_rori_i32(tmp, tmp, shift * 8);
> +                            tcg_gen_rotri_i32(tmp, tmp, shift * 8);
>                          op1 = (insn >> 20) & 7;
>                          switch (op1) {
>                          case 0: gen_sxtb16(tmp);  break;
> @@ -7451,7 +7436,7 @@ static int disas_thumb2_insn(CPUState *env,
> DisasContext *s, uint16_t insn_hw1)
>              /* ??? In many cases it's not neccessary to do a
>                 rotate, a shift is sufficient.  */
>              if (shift != 0)
> -                tcg_gen_rori_i32(tmp, tmp, shift * 8);
> +                tcg_gen_rotri_i32(tmp, tmp, shift * 8);
>              op = (insn >> 20) & 7;
>              switch (op) {
>              case 0: gen_sxth(tmp);   break;
>

Patch

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 99a9ffd..1734fae 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -418,21 +418,6 @@  static inline void tcg_gen_bic_i32(TCGv dest,  
TCGv t0, TCGv t1)
  /* FIXME:  Implement this natively.  */
  #define tcg_gen_abs_i32(t0, t1) gen_helper_abs(t0, t1)

-/* FIXME:  Implement this natively.  */
-static void tcg_gen_rori_i32(TCGv t0, TCGv t1, int i)
-{
-    TCGv tmp;
-
-    if (i == 0)
-        return;
-
-    tmp = new_tmp();
-    tcg_gen_shri_i32(tmp, t1, i);
-    tcg_gen_shli_i32(t1, t1, 32 - i);
-    tcg_gen_or_i32(t0, t1, tmp);
-    dead_tmp(tmp);
-}
-
  static void shifter_out_im(TCGv var, int shift)
  {