]> review.fuel-infra Code Review - packages/centos6/qemu.git/blob - 0060-tcg-mips-use-TCGArg-or-TCGReg-instead-of-int.patch
Merge "QEMU update with VENOM (CVE-2015-3456) patch" into 5.0.2
[packages/centos6/qemu.git] / 0060-tcg-mips-use-TCGArg-or-TCGReg-instead-of-int.patch
1 From 7b817977fbb87ee2e34018d92b64907197974a75 Mon Sep 17 00:00:00 2001
2 From: Aurelien Jarno <aurelien@aurel32.net>
3 Date: Fri, 21 Sep 2012 18:20:26 +0200
4 Subject: [PATCH] tcg/mips: use TCGArg or TCGReg instead of int
5
6 Instead of int, use the correct TCGArg and TCGReg type: TCGReg when
7 representing a TCG target register, TCGArg when representing the latter
8 or a constant.
9
10 Reviewed-by: Richard Henderson <rth@twiddle.net>
11 Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
13 ---
14  tcg/mips/tcg-target.c | 63 ++++++++++++++++++++++++++++-----------------------
15  1 file changed, 35 insertions(+), 28 deletions(-)
16
17 diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c
18 index a09c0d6..8b38f98 100644
19 --- a/tcg/mips/tcg-target.c
20 +++ b/tcg/mips/tcg-target.c
21 @@ -68,7 +68,7 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
22  #endif
23  
24  /* check if we really need so many registers :P */
25 -static const int tcg_target_reg_alloc_order[] = {
26 +static const TCGReg tcg_target_reg_alloc_order[] = {
27      TCG_REG_S0,
28      TCG_REG_S1,
29      TCG_REG_S2,
30 @@ -94,14 +94,14 @@ static const int tcg_target_reg_alloc_order[] = {
31      TCG_REG_V1
32  };
33  
34 -static const int tcg_target_call_iarg_regs[4] = {
35 +static const TCGReg tcg_target_call_iarg_regs[4] = {
36      TCG_REG_A0,
37      TCG_REG_A1,
38      TCG_REG_A2,
39      TCG_REG_A3
40  };
41  
42 -static const int tcg_target_call_oarg_regs[2] = {
43 +static const TCGReg tcg_target_call_oarg_regs[2] = {
44      TCG_REG_V0,
45      TCG_REG_V1
46  };
47 @@ -327,7 +327,8 @@ enum {
48  /*
49   * Type reg
50   */
51 -static inline void tcg_out_opc_reg(TCGContext *s, int opc, int rd, int rs, int rt)
52 +static inline void tcg_out_opc_reg(TCGContext *s, int opc,
53 +                                   TCGReg rd, TCGReg rs, TCGReg rt)
54  {
55      int32_t inst;
56  
57 @@ -341,7 +342,8 @@ static inline void tcg_out_opc_reg(TCGContext *s, int opc, int rd, int rs, int r
58  /*
59   * Type immediate
60   */
61 -static inline void tcg_out_opc_imm(TCGContext *s, int opc, int rt, int rs, int imm)
62 +static inline void tcg_out_opc_imm(TCGContext *s, int opc,
63 +                                   TCGReg rt, TCGReg rs, TCGArg imm)
64  {
65      int32_t inst;
66  
67 @@ -355,7 +357,8 @@ static inline void tcg_out_opc_imm(TCGContext *s, int opc, int rt, int rs, int i
68  /*
69   * Type branch
70   */
71 -static inline void tcg_out_opc_br(TCGContext *s, int opc, int rt, int rs)
72 +static inline void tcg_out_opc_br(TCGContext *s, int opc,
73 +                                  TCGReg rt, TCGReg rs)
74  {
75      /* We pay attention here to not modify the branch target by reading
76         the existing value and using it again. This ensure that caches and
77 @@ -368,7 +371,8 @@ static inline void tcg_out_opc_br(TCGContext *s, int opc, int rt, int rs)
78  /*
79   * Type sa
80   */
81 -static inline void tcg_out_opc_sa(TCGContext *s, int opc, int rd, int rt, int sa)
82 +static inline void tcg_out_opc_sa(TCGContext *s, int opc,
83 +                                  TCGReg rd, TCGReg rt, TCGArg sa)
84  {
85      int32_t inst;
86  
87 @@ -407,7 +411,7 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type,
88      }
89  }
90  
91 -static inline void tcg_out_bswap16(TCGContext *s, int ret, int arg)
92 +static inline void tcg_out_bswap16(TCGContext *s, TCGReg ret, TCGReg arg)
93  {
94      /* ret and arg can't be register at */
95      if (ret == TCG_REG_AT || arg == TCG_REG_AT) {
96 @@ -422,7 +426,7 @@ static inline void tcg_out_bswap16(TCGContext *s, int ret, int arg)
97      tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
98  }
99  
100 -static inline void tcg_out_bswap16s(TCGContext *s, int ret, int arg)
101 +static inline void tcg_out_bswap16s(TCGContext *s, TCGReg ret, TCGReg arg)
102  {
103      /* ret and arg can't be register at */
104      if (ret == TCG_REG_AT || arg == TCG_REG_AT) {
105 @@ -437,7 +441,7 @@ static inline void tcg_out_bswap16s(TCGContext *s, int ret, int arg)
106      tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
107  }
108  
109 -static inline void tcg_out_bswap32(TCGContext *s, int ret, int arg)
110 +static inline void tcg_out_bswap32(TCGContext *s, TCGReg ret, TCGReg arg)
111  {
112      /* ret and arg must be different and can't be register at */
113      if (ret == arg || ret == TCG_REG_AT || arg == TCG_REG_AT) {
114 @@ -458,7 +462,7 @@ static inline void tcg_out_bswap32(TCGContext *s, int ret, int arg)
115      tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
116  }
117  
118 -static inline void tcg_out_ext8s(TCGContext *s, int ret, int arg)
119 +static inline void tcg_out_ext8s(TCGContext *s, TCGReg ret, TCGReg arg)
120  {
121  #ifdef _MIPS_ARCH_MIPS32R2
122      tcg_out_opc_reg(s, OPC_SEB, ret, 0, arg);
123 @@ -468,7 +472,7 @@ static inline void tcg_out_ext8s(TCGContext *s, int ret, int arg)
124  #endif
125  }
126  
127 -static inline void tcg_out_ext16s(TCGContext *s, int ret, int arg)
128 +static inline void tcg_out_ext16s(TCGContext *s, TCGReg ret, TCGReg arg)
129  {
130  #ifdef _MIPS_ARCH_MIPS32R2
131      tcg_out_opc_reg(s, OPC_SEH, ret, 0, arg);
132 @@ -478,8 +482,8 @@ static inline void tcg_out_ext16s(TCGContext *s, int ret, int arg)
133  #endif
134  }
135  
136 -static inline void tcg_out_ldst(TCGContext *s, int opc, int arg,
137 -                              int arg1, tcg_target_long arg2)
138 +static inline void tcg_out_ldst(TCGContext *s, int opc, TCGArg arg,
139 +                                TCGReg arg1, TCGArg arg2)
140  {
141      if (arg2 == (int16_t) arg2) {
142          tcg_out_opc_imm(s, opc, arg, arg1, arg2);
143 @@ -502,7 +506,7 @@ static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg,
144      tcg_out_ldst(s, OPC_SW, arg, arg1, arg2);
145  }
146  
147 -static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)
148 +static inline void tcg_out_addi(TCGContext *s, TCGReg reg, TCGArg val)
149  {
150      if (val == (int16_t)val) {
151          tcg_out_opc_imm(s, OPC_ADDIU, reg, reg, val);
152 @@ -543,7 +547,7 @@ DEFINE_TCG_OUT_CALL_IARG(tcg_out_call_iarg_reg16, TCGReg arg)
153  #undef DEFINE_TCG_OUT_CALL_IARG_GET_ARG
154  #define DEFINE_TCG_OUT_CALL_IARG_GET_ARG(A) \
155      tcg_out_movi(s, TCG_TYPE_I32, A, arg);
156 -DEFINE_TCG_OUT_CALL_IARG(tcg_out_call_iarg_imm32, uint32_t arg)
157 +DEFINE_TCG_OUT_CALL_IARG(tcg_out_call_iarg_imm32, TCGArg arg)
158  #undef DEFINE_TCG_OUT_CALL_IARG_GET_ARG
159  
160  /* We don't use the macro for this one to avoid an unnecessary reg-reg
161 @@ -573,8 +577,8 @@ static inline void tcg_out_call_iarg_reg64(TCGContext *s, int *arg_num,
162  #endif
163  }
164  
165 -static void tcg_out_brcond(TCGContext *s, TCGCond cond, int arg1,
166 -                           int arg2, int label_index)
167 +static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGArg arg1,
168 +                           TCGArg arg2, int label_index)
169  {
170      TCGLabel *l = &s->labels[label_index];
171  
172 @@ -631,8 +635,9 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, int arg1,
173  
174  /* XXX: we implement it at the target level to avoid having to
175     handle cross basic blocks temporaries */
176 -static void tcg_out_brcond2(TCGContext *s, TCGCond cond, int arg1,
177 -                            int arg2, int arg3, int arg4, int label_index)
178 +static void tcg_out_brcond2(TCGContext *s, TCGCond cond, TCGArg arg1,
179 +                            TCGArg arg2, TCGArg arg3, TCGArg arg4,
180 +                            int label_index)
181  {
182      void *label_ptr;
183  
184 @@ -694,8 +699,8 @@ static void tcg_out_brcond2(TCGContext *s, TCGCond cond, int arg1,
185      reloc_pc16(label_ptr, (tcg_target_long) s->code_ptr);
186  }
187  
188 -static void tcg_out_setcond(TCGContext *s, TCGCond cond, int ret,
189 -                            int arg1, int arg2)
190 +static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret,
191 +                            TCGArg arg1, TCGArg arg2)
192  {
193      switch (cond) {
194      case TCG_COND_EQ:
195 @@ -754,8 +759,8 @@ static void tcg_out_setcond(TCGContext *s, TCGCond cond, int ret,
196  
197  /* XXX: we implement it at the target level to avoid having to
198     handle cross basic blocks temporaries */
199 -static void tcg_out_setcond2(TCGContext *s, TCGCond cond, int ret,
200 -                             int arg1, int arg2, int arg3, int arg4)
201 +static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret,
202 +                             TCGArg arg1, TCGArg arg2, TCGArg arg3, TCGArg arg4)
203  {
204      switch (cond) {
205      case TCG_COND_EQ:
206 @@ -842,7 +847,7 @@ static const void * const qemu_st_helpers[4] = {
207  static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
208                              int opc)
209  {
210 -    int addr_regl, data_regl, data_regh, data_reg1, data_reg2;
211 +    TCGReg addr_regl, data_regl, data_regh, data_reg1, data_reg2;
212  #if defined(CONFIG_SOFTMMU)
213      void *label1_ptr, *label2_ptr;
214      int arg_num;
215 @@ -850,7 +855,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
216      int addr_meml;
217  # if TARGET_LONG_BITS == 64
218      uint8_t *label3_ptr;
219 -    int addr_regh, addr_memh;
220 +    TCGReg addr_regh;
221 +    int addr_memh;
222  # endif
223  #endif
224      data_regl = *args++;
225 @@ -1026,7 +1032,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
226  static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
227                              int opc)
228  {
229 -    int addr_regl, data_regl, data_regh, data_reg1, data_reg2;
230 +    TCGReg addr_regl, data_regl, data_regh, data_reg1, data_reg2;
231  #if defined(CONFIG_SOFTMMU)
232      uint8_t *label1_ptr, *label2_ptr;
233      int arg_num;
234 @@ -1036,7 +1042,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
235  #if TARGET_LONG_BITS == 64
236  # if defined(CONFIG_SOFTMMU)
237      uint8_t *label3_ptr;
238 -    int addr_regh, addr_memh;
239 +    TCGReg addr_regh;
240 +    int addr_memh;
241  # endif
242  #endif
243      data_regl = *args++;
244 -- 
245 1.7.12.1
246