render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0090-tcg-sparc-Use-defines-for-temporaries.patch

5544c1
From fc9726f880dea515a2cf98456c5f03a1388e4e14 Mon Sep 17 00:00:00 2001
5544c1
From: Richard Henderson <rth@twiddle.net>
5544c1
Date: Sun, 25 Mar 2012 22:04:59 +0200
5544c1
Subject: [PATCH] tcg-sparc: Use defines for temporaries.
5544c1
5544c1
And change from %i4/%i5 to %g1/%o7 to remove a v8plus fixme.
5544c1
5544c1
Signed-off-by: Richard Henderson <rth@twiddle.net>
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 tcg/sparc/tcg-target.c | 115 +++++++++++++++++++++++++------------------------
5544c1
 1 file changed, 59 insertions(+), 56 deletions(-)
5544c1
5544c1
diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c
5544c1
index be5c170..d401f8e 100644
5544c1
--- a/tcg/sparc/tcg-target.c
5544c1
+++ b/tcg/sparc/tcg-target.c
5544c1
@@ -59,8 +59,12 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
5544c1
 };
5544c1
 #endif
5544c1
 
5544c1
+/* Define some temporary registers.  T2 is used for constant generation.  */
5544c1
+#define TCG_REG_T1  TCG_REG_G1
5544c1
+#define TCG_REG_T2  TCG_REG_O7
5544c1
+
5544c1
 #ifdef CONFIG_USE_GUEST_BASE
5544c1
-# define TCG_GUEST_BASE_REG TCG_REG_I3
5544c1
+# define TCG_GUEST_BASE_REG TCG_REG_I5
5544c1
 #else
5544c1
 # define TCG_GUEST_BASE_REG TCG_REG_G0
5544c1
 #endif
5544c1
@@ -79,6 +83,7 @@ static const int tcg_target_reg_alloc_order[] = {
5544c1
     TCG_REG_I2,
5544c1
     TCG_REG_I3,
5544c1
     TCG_REG_I4,
5544c1
+    TCG_REG_I5,
5544c1
 };
5544c1
 
5544c1
 static const int tcg_target_call_iarg_regs[6] = {
5544c1
@@ -366,10 +371,10 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type,
5544c1
         tcg_out_sethi(s, ret, ~arg);
5544c1
         tcg_out_arithi(s, ret, ret, (arg & 0x3ff) | -0x400, ARITH_XOR);
5544c1
     } else {
5544c1
-        tcg_out_movi_imm32(s, TCG_REG_I4, arg >> (TCG_TARGET_REG_BITS / 2));
5544c1
-        tcg_out_arithi(s, TCG_REG_I4, TCG_REG_I4, 32, SHIFT_SLLX);
5544c1
-        tcg_out_movi_imm32(s, ret, arg);
5544c1
-        tcg_out_arith(s, ret, ret, TCG_REG_I4, ARITH_OR);
5544c1
+        tcg_out_movi_imm32(s, ret, arg >> (TCG_TARGET_REG_BITS / 2));
5544c1
+        tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX);
5544c1
+        tcg_out_movi_imm32(s, TCG_REG_T2, arg);
5544c1
+        tcg_out_arith(s, ret, ret, TCG_REG_T2, ARITH_OR);
5544c1
     }
5544c1
 }
5544c1
 
5544c1
@@ -386,8 +391,8 @@ static inline void tcg_out_ldst(TCGContext *s, int ret, int addr,
5544c1
         tcg_out32(s, op | INSN_RD(ret) | INSN_RS1(addr) |
5544c1
                   INSN_IMM13(offset));
5544c1
     } else {
5544c1
-        tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I5, offset);
5544c1
-        tcg_out_ldst_rr(s, ret, addr, TCG_REG_I5, op);
5544c1
+        tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T1, offset);
5544c1
+        tcg_out_ldst_rr(s, ret, addr, TCG_REG_T1, op);
5544c1
     }
5544c1
 }
5544c1
 
5544c1
@@ -428,8 +433,8 @@ static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)
5544c1
         if (check_fit_tl(val, 13))
5544c1
             tcg_out_arithi(s, reg, reg, val, ARITH_ADD);
5544c1
         else {
5544c1
-            tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I5, val);
5544c1
-            tcg_out_arith(s, reg, reg, TCG_REG_I5, ARITH_ADD);
5544c1
+            tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T1, val);
5544c1
+            tcg_out_arith(s, reg, reg, TCG_REG_T1, ARITH_ADD);
5544c1
         }
5544c1
     }
5544c1
 }
5544c1
@@ -441,8 +446,8 @@ static inline void tcg_out_andi(TCGContext *s, int rd, int rs,
5544c1
         if (check_fit_tl(val, 13))
5544c1
             tcg_out_arithi(s, rd, rs, val, ARITH_AND);
5544c1
         else {
5544c1
-            tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_I5, val);
5544c1
-            tcg_out_arith(s, rd, rs, TCG_REG_I5, ARITH_AND);
5544c1
+            tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T1, val);
5544c1
+            tcg_out_arith(s, rd, rs, TCG_REG_T1, ARITH_AND);
5544c1
         }
5544c1
     }
5544c1
 }
5544c1
@@ -454,8 +459,8 @@ static void tcg_out_div32(TCGContext *s, int rd, int rs1,
5544c1
     if (uns) {
5544c1
         tcg_out_sety(s, TCG_REG_G0);
5544c1
     } else {
5544c1
-        tcg_out_arithi(s, TCG_REG_I5, rs1, 31, SHIFT_SRA);
5544c1
-        tcg_out_sety(s, TCG_REG_I5);
5544c1
+        tcg_out_arithi(s, TCG_REG_T1, rs1, 31, SHIFT_SRA);
5544c1
+        tcg_out_sety(s, TCG_REG_T1);
5544c1
     }
5544c1
 
5544c1
     tcg_out_arithc(s, rd, rs1, val2, val2const,
5544c1
@@ -601,8 +606,8 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGArg ret,
5544c1
     case TCG_COND_GTU:
5544c1
     case TCG_COND_GEU:
5544c1
         if (c2const && c2 != 0) {
5544c1
-            tcg_out_movi_imm13(s, TCG_REG_I5, c2);
5544c1
-            c2 = TCG_REG_I5;
5544c1
+            tcg_out_movi_imm13(s, TCG_REG_T1, c2);
5544c1
+            c2 = TCG_REG_T1;
5544c1
         }
5544c1
         t = c1, c1 = c2, c2 = t, c2const = 0;
5544c1
         cond = tcg_swap_cond(cond);
5544c1
@@ -649,15 +654,15 @@ static void tcg_out_setcond2_i32(TCGContext *s, TCGCond cond, TCGArg ret,
5544c1
 
5544c1
     switch (cond) {
5544c1
     case TCG_COND_EQ:
5544c1
-        tcg_out_setcond_i32(s, TCG_COND_EQ, TCG_REG_I5, al, bl, blconst);
5544c1
+        tcg_out_setcond_i32(s, TCG_COND_EQ, TCG_REG_T1, al, bl, blconst);
5544c1
         tcg_out_setcond_i32(s, TCG_COND_EQ, ret, ah, bh, bhconst);
5544c1
-        tcg_out_arith(s, ret, ret, TCG_REG_I5, ARITH_AND);
5544c1
+        tcg_out_arith(s, ret, ret, TCG_REG_T1, ARITH_AND);
5544c1
         break;
5544c1
 
5544c1
     case TCG_COND_NE:
5544c1
-        tcg_out_setcond_i32(s, TCG_COND_NE, TCG_REG_I5, al, al, blconst);
5544c1
+        tcg_out_setcond_i32(s, TCG_COND_NE, TCG_REG_T1, al, al, blconst);
5544c1
         tcg_out_setcond_i32(s, TCG_COND_NE, ret, ah, bh, bhconst);
5544c1
-        tcg_out_arith(s, ret, ret, TCG_REG_I5, ARITH_OR);
5544c1
+        tcg_out_arith(s, ret, ret, TCG_REG_T1, ARITH_OR);
5544c1
         break;
5544c1
 
5544c1
     default:
5544c1
@@ -935,8 +940,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int sizeop)
5544c1
 #else
5544c1
     addr_reg = args[addrlo_idx];
5544c1
     if (TCG_TARGET_REG_BITS == 64 && TARGET_LONG_BITS == 32) {
5544c1
-        tcg_out_arithi(s, TCG_REG_I5, addr_reg, 0, SHIFT_SRL);
5544c1
-        addr_reg = TCG_REG_I5;
5544c1
+        tcg_out_arithi(s, TCG_REG_T1, addr_reg, 0, SHIFT_SRL);
5544c1
+        addr_reg = TCG_REG_T1;
5544c1
     }
5544c1
     if (TCG_TARGET_REG_BITS == 32 && sizeop == 3) {
5544c1
         int reg64 = (datalo < 16 ? datalo : TCG_REG_O0);
5544c1
@@ -979,12 +984,11 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int sizeop)
5544c1
                                 offsetof(CPUTLBEntry, addr_write));
5544c1
 
5544c1
     if (TCG_TARGET_REG_BITS == 32 && sizeop == 3) {
5544c1
-        /* Reconstruct the full 64-bit value in %g1, using %o2 as temp.  */
5544c1
-        /* ??? Redefine the temps from %i4/%i5 so that we have a o/g temp. */
5544c1
-        tcg_out_arithi(s, TCG_REG_G1, datalo, 0, SHIFT_SRL);
5544c1
+        /* Reconstruct the full 64-bit value.  */
5544c1
+        tcg_out_arithi(s, TCG_REG_T1, datalo, 0, SHIFT_SRL);
5544c1
         tcg_out_arithi(s, TCG_REG_O2, datahi, 32, SHIFT_SLLX);
5544c1
-        tcg_out_arith(s, TCG_REG_G1, TCG_REG_G1, TCG_REG_O2, ARITH_OR);
5544c1
-        datalo = TCG_REG_G1;
5544c1
+        tcg_out_arith(s, TCG_REG_O2, TCG_REG_T1, TCG_REG_O2, ARITH_OR);
5544c1
+        datalo = TCG_REG_O2;
5544c1
     }
5544c1
 
5544c1
     /* The fast path is exactly one insn.  Thus we can perform the entire
5544c1
@@ -1024,16 +1028,14 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int sizeop)
5544c1
 #else
5544c1
     addr_reg = args[addrlo_idx];
5544c1
     if (TCG_TARGET_REG_BITS == 64 && TARGET_LONG_BITS == 32) {
5544c1
-        tcg_out_arithi(s, TCG_REG_I5, addr_reg, 0, SHIFT_SRL);
5544c1
-        addr_reg = TCG_REG_I5;
5544c1
+        tcg_out_arithi(s, TCG_REG_T1, addr_reg, 0, SHIFT_SRL);
5544c1
+        addr_reg = TCG_REG_T1;
5544c1
     }
5544c1
     if (TCG_TARGET_REG_BITS == 32 && sizeop == 3) {
5544c1
-        /* Reconstruct the full 64-bit value in %g1, using %o2 as temp.  */
5544c1
-        /* ??? Redefine the temps from %i4/%i5 so that we have a o/g temp. */
5544c1
-        tcg_out_arithi(s, TCG_REG_G1, datalo, 0, SHIFT_SRL);
5544c1
+        tcg_out_arithi(s, TCG_REG_T1, datalo, 0, SHIFT_SRL);
5544c1
         tcg_out_arithi(s, TCG_REG_O2, datahi, 32, SHIFT_SLLX);
5544c1
-        tcg_out_arith(s, TCG_REG_G1, TCG_REG_G1, TCG_REG_O2, ARITH_OR);
5544c1
-        datalo = TCG_REG_G1;
5544c1
+        tcg_out_arith(s, TCG_REG_O2, TCG_REG_T1, TCG_REG_O2, ARITH_OR);
5544c1
+        datalo = TCG_REG_O2;
5544c1
     }
5544c1
     tcg_out_ldst_rr(s, datalo, addr_reg,
5544c1
                     (GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_G0),
5544c1
@@ -1057,28 +1059,29 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
5544c1
     case INDEX_op_goto_tb:
5544c1
         if (s->tb_jmp_offset) {
5544c1
             /* direct jump method */
5544c1
-            tcg_out_sethi(s, TCG_REG_I5, args[0] & 0xffffe000);
5544c1
-            tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) |
5544c1
+            tcg_out_sethi(s, TCG_REG_T1, args[0] & 0xffffe000);
5544c1
+            tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_T1) |
5544c1
                       INSN_IMM13((args[0] & 0x1fff)));
5544c1
             s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
5544c1
         } else {
5544c1
             /* indirect jump method */
5544c1
-            tcg_out_ld_ptr(s, TCG_REG_I5, (tcg_target_long)(s->tb_next + args[0]));
5544c1
-            tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) |
5544c1
+            tcg_out_ld_ptr(s, TCG_REG_T1,
5544c1
+                           (tcg_target_long)(s->tb_next + args[0]));
5544c1
+            tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_T1) |
5544c1
                       INSN_RS2(TCG_REG_G0));
5544c1
         }
5544c1
         tcg_out_nop(s);
5544c1
         s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
5544c1
         break;
5544c1
     case INDEX_op_call:
5544c1
-        if (const_args[0])
5544c1
+        if (const_args[0]) {
5544c1
             tcg_out32(s, CALL | ((((tcg_target_ulong)args[0]
5544c1
                                    - (tcg_target_ulong)s->code_ptr) >> 2)
5544c1
                                  & 0x3fffffff));
5544c1
-        else {
5544c1
-            tcg_out_ld_ptr(s, TCG_REG_I5,
5544c1
+        } else {
5544c1
+            tcg_out_ld_ptr(s, TCG_REG_T1,
5544c1
                            (tcg_target_long)(s->tb_next + args[0]));
5544c1
-            tcg_out32(s, JMPL | INSN_RD(TCG_REG_O7) | INSN_RS1(TCG_REG_I5) |
5544c1
+            tcg_out32(s, JMPL | INSN_RD(TCG_REG_O7) | INSN_RS1(TCG_REG_T1) |
5544c1
                       INSN_RS2(TCG_REG_G0));
5544c1
         }
5544c1
         /* delay slot */
5544c1
@@ -1184,11 +1187,11 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
5544c1
 
5544c1
     case INDEX_op_rem_i32:
5544c1
     case INDEX_op_remu_i32:
5544c1
-        tcg_out_div32(s, TCG_REG_I5, args[1], args[2], const_args[2],
5544c1
+        tcg_out_div32(s, TCG_REG_T1, args[1], args[2], const_args[2],
5544c1
                       opc == INDEX_op_remu_i32);
5544c1
-        tcg_out_arithc(s, TCG_REG_I5, TCG_REG_I5, args[2], const_args[2],
5544c1
+        tcg_out_arithc(s, TCG_REG_T1, TCG_REG_T1, args[2], const_args[2],
5544c1
                        ARITH_UMUL);
5544c1
-        tcg_out_arith(s, args[0], args[1], TCG_REG_I5, ARITH_SUB);
5544c1
+        tcg_out_arith(s, args[0], args[1], TCG_REG_T1, ARITH_SUB);
5544c1
         break;
5544c1
 
5544c1
     case INDEX_op_brcond_i32:
5544c1
@@ -1305,11 +1308,11 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
5544c1
         goto gen_arith;
5544c1
     case INDEX_op_rem_i64:
5544c1
     case INDEX_op_remu_i64:
5544c1
-        tcg_out_arithc(s, TCG_REG_I5, args[1], args[2], const_args[2],
5544c1
+        tcg_out_arithc(s, TCG_REG_T1, args[1], args[2], const_args[2],
5544c1
                        opc == INDEX_op_rem_i64 ? ARITH_SDIVX : ARITH_UDIVX);
5544c1
-        tcg_out_arithc(s, TCG_REG_I5, TCG_REG_I5, args[2], const_args[2],
5544c1
+        tcg_out_arithc(s, TCG_REG_T1, TCG_REG_T1, args[2], const_args[2],
5544c1
                        ARITH_MULX);
5544c1
-        tcg_out_arith(s, args[0], args[1], TCG_REG_I5, ARITH_SUB);
5544c1
+        tcg_out_arith(s, args[0], args[1], TCG_REG_T1, ARITH_SUB);
5544c1
         break;
5544c1
     case INDEX_op_ext32s_i64:
5544c1
         if (const_args[1]) {
5544c1
@@ -1507,15 +1510,15 @@ static void tcg_target_init(TCGContext *s)
5544c1
                      (1 << TCG_REG_O7));
5544c1
 
5544c1
     tcg_regset_clear(s->reserved_regs);
5544c1
-    tcg_regset_set_reg(s->reserved_regs, TCG_REG_G0);
5544c1
-#if TCG_TARGET_REG_BITS == 64
5544c1
-    tcg_regset_set_reg(s->reserved_regs, TCG_REG_I4); // for internal use
5544c1
-#endif
5544c1
-    tcg_regset_set_reg(s->reserved_regs, TCG_REG_I5); // for internal use
5544c1
-    tcg_regset_set_reg(s->reserved_regs, TCG_REG_I6);
5544c1
-    tcg_regset_set_reg(s->reserved_regs, TCG_REG_I7);
5544c1
-    tcg_regset_set_reg(s->reserved_regs, TCG_REG_O6);
5544c1
-    tcg_regset_set_reg(s->reserved_regs, TCG_REG_O7);
5544c1
+    tcg_regset_set_reg(s->reserved_regs, TCG_REG_G0); /* zero */
5544c1
+    tcg_regset_set_reg(s->reserved_regs, TCG_REG_G6); /* reserved for os */
5544c1
+    tcg_regset_set_reg(s->reserved_regs, TCG_REG_G7); /* thread pointer */
5544c1
+    tcg_regset_set_reg(s->reserved_regs, TCG_REG_I6); /* frame pointer */
5544c1
+    tcg_regset_set_reg(s->reserved_regs, TCG_REG_I7); /* return address */
5544c1
+    tcg_regset_set_reg(s->reserved_regs, TCG_REG_O6); /* stack pointer */
5544c1
+    tcg_regset_set_reg(s->reserved_regs, TCG_REG_T1); /* for internal use */
5544c1
+    tcg_regset_set_reg(s->reserved_regs, TCG_REG_T2); /* for internal use */
5544c1
+
5544c1
     tcg_add_target_add_op_defs(sparc_op_defs);
5544c1
 }
5544c1
 
5544c1
-- 
5544c1
1.7.12.1
5544c1