5544c1b
From 7b817977fbb87ee2e34018d92b64907197974a75 Mon Sep 17 00:00:00 2001
5544c1b
From: Aurelien Jarno <aurelien@aurel32.net>
5544c1b
Date: Fri, 21 Sep 2012 18:20:26 +0200
5544c1b
Subject: [PATCH] tcg/mips: use TCGArg or TCGReg instead of int
5544c1b
5544c1b
Instead of int, use the correct TCGArg and TCGReg type: TCGReg when
5544c1b
representing a TCG target register, TCGArg when representing the latter
5544c1b
or a constant.
5544c1b
5544c1b
Reviewed-by: Richard Henderson <rth@twiddle.net>
5544c1b
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1b
---
5544c1b
 tcg/mips/tcg-target.c | 63 ++++++++++++++++++++++++++++-----------------------
5544c1b
 1 file changed, 35 insertions(+), 28 deletions(-)
5544c1b
5544c1b
diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c
5544c1b
index a09c0d6..8b38f98 100644
5544c1b
--- a/tcg/mips/tcg-target.c
5544c1b
+++ b/tcg/mips/tcg-target.c
5544c1b
@@ -68,7 +68,7 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
5544c1b
 #endif
5544c1b
 
5544c1b
 /* check if we really need so many registers :P */
5544c1b
-static const int tcg_target_reg_alloc_order[] = {
5544c1b
+static const TCGReg tcg_target_reg_alloc_order[] = {
5544c1b
     TCG_REG_S0,
5544c1b
     TCG_REG_S1,
5544c1b
     TCG_REG_S2,
5544c1b
@@ -94,14 +94,14 @@ static const int tcg_target_reg_alloc_order[] = {
5544c1b
     TCG_REG_V1
5544c1b
 };
5544c1b
 
5544c1b
-static const int tcg_target_call_iarg_regs[4] = {
5544c1b
+static const TCGReg tcg_target_call_iarg_regs[4] = {
5544c1b
     TCG_REG_A0,
5544c1b
     TCG_REG_A1,
5544c1b
     TCG_REG_A2,
5544c1b
     TCG_REG_A3
5544c1b
 };
5544c1b
 
5544c1b
-static const int tcg_target_call_oarg_regs[2] = {
5544c1b
+static const TCGReg tcg_target_call_oarg_regs[2] = {
5544c1b
     TCG_REG_V0,
5544c1b
     TCG_REG_V1
5544c1b
 };
5544c1b
@@ -327,7 +327,8 @@ enum {
5544c1b
 /*
5544c1b
  * Type reg
5544c1b
  */
5544c1b
-static inline void tcg_out_opc_reg(TCGContext *s, int opc, int rd, int rs, int rt)
5544c1b
+static inline void tcg_out_opc_reg(TCGContext *s, int opc,
5544c1b
+                                   TCGReg rd, TCGReg rs, TCGReg rt)
5544c1b
 {
5544c1b
     int32_t inst;
5544c1b
 
5544c1b
@@ -341,7 +342,8 @@ static inline void tcg_out_opc_reg(TCGContext *s, int opc, int rd, int rs, int r
5544c1b
 /*
5544c1b
  * Type immediate
5544c1b
  */
5544c1b
-static inline void tcg_out_opc_imm(TCGContext *s, int opc, int rt, int rs, int imm)
5544c1b
+static inline void tcg_out_opc_imm(TCGContext *s, int opc,
5544c1b
+                                   TCGReg rt, TCGReg rs, TCGArg imm)
5544c1b
 {
5544c1b
     int32_t inst;
5544c1b
 
5544c1b
@@ -355,7 +357,8 @@ static inline void tcg_out_opc_imm(TCGContext *s, int opc, int rt, int rs, int i
5544c1b
 /*
5544c1b
  * Type branch
5544c1b
  */
5544c1b
-static inline void tcg_out_opc_br(TCGContext *s, int opc, int rt, int rs)
5544c1b
+static inline void tcg_out_opc_br(TCGContext *s, int opc,
5544c1b
+                                  TCGReg rt, TCGReg rs)
5544c1b
 {
5544c1b
     /* We pay attention here to not modify the branch target by reading
5544c1b
        the existing value and using it again. This ensure that caches and
5544c1b
@@ -368,7 +371,8 @@ static inline void tcg_out_opc_br(TCGContext *s, int opc, int rt, int rs)
5544c1b
 /*
5544c1b
  * Type sa
5544c1b
  */
5544c1b
-static inline void tcg_out_opc_sa(TCGContext *s, int opc, int rd, int rt, int sa)
5544c1b
+static inline void tcg_out_opc_sa(TCGContext *s, int opc,
5544c1b
+                                  TCGReg rd, TCGReg rt, TCGArg sa)
5544c1b
 {
5544c1b
     int32_t inst;
5544c1b
 
5544c1b
@@ -407,7 +411,7 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type,
5544c1b
     }
5544c1b
 }
5544c1b
 
5544c1b
-static inline void tcg_out_bswap16(TCGContext *s, int ret, int arg)
5544c1b
+static inline void tcg_out_bswap16(TCGContext *s, TCGReg ret, TCGReg arg)
5544c1b
 {
5544c1b
     /* ret and arg can't be register at */
5544c1b
     if (ret == TCG_REG_AT || arg == TCG_REG_AT) {
5544c1b
@@ -422,7 +426,7 @@ static inline void tcg_out_bswap16(TCGContext *s, int ret, int arg)
5544c1b
     tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
5544c1b
 }
5544c1b
 
5544c1b
-static inline void tcg_out_bswap16s(TCGContext *s, int ret, int arg)
5544c1b
+static inline void tcg_out_bswap16s(TCGContext *s, TCGReg ret, TCGReg arg)
5544c1b
 {
5544c1b
     /* ret and arg can't be register at */
5544c1b
     if (ret == TCG_REG_AT || arg == TCG_REG_AT) {
5544c1b
@@ -437,7 +441,7 @@ static inline void tcg_out_bswap16s(TCGContext *s, int ret, int arg)
5544c1b
     tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
5544c1b
 }
5544c1b
 
5544c1b
-static inline void tcg_out_bswap32(TCGContext *s, int ret, int arg)
5544c1b
+static inline void tcg_out_bswap32(TCGContext *s, TCGReg ret, TCGReg arg)
5544c1b
 {
5544c1b
     /* ret and arg must be different and can't be register at */
5544c1b
     if (ret == arg || ret == TCG_REG_AT || arg == TCG_REG_AT) {
5544c1b
@@ -458,7 +462,7 @@ static inline void tcg_out_bswap32(TCGContext *s, int ret, int arg)
5544c1b
     tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
5544c1b
 }
5544c1b
 
5544c1b
-static inline void tcg_out_ext8s(TCGContext *s, int ret, int arg)
5544c1b
+static inline void tcg_out_ext8s(TCGContext *s, TCGReg ret, TCGReg arg)
5544c1b
 {
5544c1b
 #ifdef _MIPS_ARCH_MIPS32R2
5544c1b
     tcg_out_opc_reg(s, OPC_SEB, ret, 0, arg);
5544c1b
@@ -468,7 +472,7 @@ static inline void tcg_out_ext8s(TCGContext *s, int ret, int arg)
5544c1b
 #endif
5544c1b
 }
5544c1b
 
5544c1b
-static inline void tcg_out_ext16s(TCGContext *s, int ret, int arg)
5544c1b
+static inline void tcg_out_ext16s(TCGContext *s, TCGReg ret, TCGReg arg)
5544c1b
 {
5544c1b
 #ifdef _MIPS_ARCH_MIPS32R2
5544c1b
     tcg_out_opc_reg(s, OPC_SEH, ret, 0, arg);
5544c1b
@@ -478,8 +482,8 @@ static inline void tcg_out_ext16s(TCGContext *s, int ret, int arg)
5544c1b
 #endif
5544c1b
 }
5544c1b
 
5544c1b
-static inline void tcg_out_ldst(TCGContext *s, int opc, int arg,
5544c1b
-                              int arg1, tcg_target_long arg2)
5544c1b
+static inline void tcg_out_ldst(TCGContext *s, int opc, TCGArg arg,
5544c1b
+                                TCGReg arg1, TCGArg arg2)
5544c1b
 {
5544c1b
     if (arg2 == (int16_t) arg2) {
5544c1b
         tcg_out_opc_imm(s, opc, arg, arg1, arg2);
5544c1b
@@ -502,7 +506,7 @@ static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg,
5544c1b
     tcg_out_ldst(s, OPC_SW, arg, arg1, arg2);
5544c1b
 }
5544c1b
 
5544c1b
-static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)
5544c1b
+static inline void tcg_out_addi(TCGContext *s, TCGReg reg, TCGArg val)
5544c1b
 {
5544c1b
     if (val == (int16_t)val) {
5544c1b
         tcg_out_opc_imm(s, OPC_ADDIU, reg, reg, val);
5544c1b
@@ -543,7 +547,7 @@ DEFINE_TCG_OUT_CALL_IARG(tcg_out_call_iarg_reg16, TCGReg arg)
5544c1b
 #undef DEFINE_TCG_OUT_CALL_IARG_GET_ARG
5544c1b
 #define DEFINE_TCG_OUT_CALL_IARG_GET_ARG(A) \
5544c1b
     tcg_out_movi(s, TCG_TYPE_I32, A, arg);
5544c1b
-DEFINE_TCG_OUT_CALL_IARG(tcg_out_call_iarg_imm32, uint32_t arg)
5544c1b
+DEFINE_TCG_OUT_CALL_IARG(tcg_out_call_iarg_imm32, TCGArg arg)
5544c1b
 #undef DEFINE_TCG_OUT_CALL_IARG_GET_ARG
5544c1b
 
5544c1b
 /* We don't use the macro for this one to avoid an unnecessary reg-reg
5544c1b
@@ -573,8 +577,8 @@ static inline void tcg_out_call_iarg_reg64(TCGContext *s, int *arg_num,
5544c1b
 #endif
5544c1b
 }
5544c1b
 
5544c1b
-static void tcg_out_brcond(TCGContext *s, TCGCond cond, int arg1,
5544c1b
-                           int arg2, int label_index)
5544c1b
+static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGArg arg1,
5544c1b
+                           TCGArg arg2, int label_index)
5544c1b
 {
5544c1b
     TCGLabel *l = &s->labels[label_index];
5544c1b
 
5544c1b
@@ -631,8 +635,9 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, int arg1,
5544c1b
 
5544c1b
 /* XXX: we implement it at the target level to avoid having to
5544c1b
    handle cross basic blocks temporaries */
5544c1b
-static void tcg_out_brcond2(TCGContext *s, TCGCond cond, int arg1,
5544c1b
-                            int arg2, int arg3, int arg4, int label_index)
5544c1b
+static void tcg_out_brcond2(TCGContext *s, TCGCond cond, TCGArg arg1,
5544c1b
+                            TCGArg arg2, TCGArg arg3, TCGArg arg4,
5544c1b
+                            int label_index)
5544c1b
 {
5544c1b
     void *label_ptr;
5544c1b
 
5544c1b
@@ -694,8 +699,8 @@ static void tcg_out_brcond2(TCGContext *s, TCGCond cond, int arg1,
5544c1b
     reloc_pc16(label_ptr, (tcg_target_long) s->code_ptr);
5544c1b
 }
5544c1b
 
5544c1b
-static void tcg_out_setcond(TCGContext *s, TCGCond cond, int ret,
5544c1b
-                            int arg1, int arg2)
5544c1b
+static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret,
5544c1b
+                            TCGArg arg1, TCGArg arg2)
5544c1b
 {
5544c1b
     switch (cond) {
5544c1b
     case TCG_COND_EQ:
5544c1b
@@ -754,8 +759,8 @@ static void tcg_out_setcond(TCGContext *s, TCGCond cond, int ret,
5544c1b
 
5544c1b
 /* XXX: we implement it at the target level to avoid having to
5544c1b
    handle cross basic blocks temporaries */
5544c1b
-static void tcg_out_setcond2(TCGContext *s, TCGCond cond, int ret,
5544c1b
-                             int arg1, int arg2, int arg3, int arg4)
5544c1b
+static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret,
5544c1b
+                             TCGArg arg1, TCGArg arg2, TCGArg arg3, TCGArg arg4)
5544c1b
 {
5544c1b
     switch (cond) {
5544c1b
     case TCG_COND_EQ:
5544c1b
@@ -842,7 +847,7 @@ static const void * const qemu_st_helpers[4] = {
5544c1b
 static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
5544c1b
                             int opc)
5544c1b
 {
5544c1b
-    int addr_regl, data_regl, data_regh, data_reg1, data_reg2;
5544c1b
+    TCGReg addr_regl, data_regl, data_regh, data_reg1, data_reg2;
5544c1b
 #if defined(CONFIG_SOFTMMU)
5544c1b
     void *label1_ptr, *label2_ptr;
5544c1b
     int arg_num;
5544c1b
@@ -850,7 +855,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
5544c1b
     int addr_meml;
5544c1b
 # if TARGET_LONG_BITS == 64
5544c1b
     uint8_t *label3_ptr;
5544c1b
-    int addr_regh, addr_memh;
5544c1b
+    TCGReg addr_regh;
5544c1b
+    int addr_memh;
5544c1b
 # endif
5544c1b
 #endif
5544c1b
     data_regl = *args++;
5544c1b
@@ -1026,7 +1032,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
5544c1b
 static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
5544c1b
                             int opc)
5544c1b
 {
5544c1b
-    int addr_regl, data_regl, data_regh, data_reg1, data_reg2;
5544c1b
+    TCGReg addr_regl, data_regl, data_regh, data_reg1, data_reg2;
5544c1b
 #if defined(CONFIG_SOFTMMU)
5544c1b
     uint8_t *label1_ptr, *label2_ptr;
5544c1b
     int arg_num;
5544c1b
@@ -1036,7 +1042,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
5544c1b
 #if TARGET_LONG_BITS == 64
5544c1b
 # if defined(CONFIG_SOFTMMU)
5544c1b
     uint8_t *label3_ptr;
5544c1b
-    int addr_regh, addr_memh;
5544c1b
+    TCGReg addr_regh;
5544c1b
+    int addr_memh;
5544c1b
 # endif
5544c1b
 #endif
5544c1b
     data_regl = *args++;