Commit ac56dd48120521b530e48f641b65b1f15c061899
1 parent
724db118
Add TCG variable opaque type.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3961 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
488 additions
and
364 deletions
target-i386/translate.c
... | ... | @@ -122,9 +122,9 @@ |
122 | 122 | #endif |
123 | 123 | |
124 | 124 | /* global register indexes */ |
125 | -static int cpu_env, cpu_T[2], cpu_A0; | |
125 | +static TCGv cpu_env, cpu_T[2], cpu_A0; | |
126 | 126 | /* local register indexes (only used inside old micro ops) */ |
127 | -static int cpu_tmp0; | |
127 | +static TCGv cpu_tmp0; | |
128 | 128 | |
129 | 129 | #ifdef TARGET_X86_64 |
130 | 130 | static int x86_64_hregs; |
... | ... | @@ -5592,7 +5592,7 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start) |
5592 | 5592 | gen_op_mov_reg_T0(OT_QUAD, reg); |
5593 | 5593 | } else |
5594 | 5594 | { |
5595 | - int tmp0; | |
5595 | + TCGv tmp0; | |
5596 | 5596 | gen_op_mov_TN_reg(OT_LONG, 0, reg); |
5597 | 5597 | |
5598 | 5598 | tmp0 = tcg_temp_new(TCG_TYPE_I32); | ... | ... |
tcg/tcg-op.h
... | ... | @@ -28,75 +28,141 @@ |
28 | 28 | |
29 | 29 | int gen_new_label(void); |
30 | 30 | |
31 | -static inline void tcg_gen_op1(int opc, TCGArg arg1) | |
31 | +static inline void tcg_gen_op1(int opc, TCGv arg1) | |
32 | 32 | { |
33 | 33 | *gen_opc_ptr++ = opc; |
34 | - *gen_opparam_ptr++ = arg1; | |
34 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
35 | 35 | } |
36 | 36 | |
37 | -static inline void tcg_gen_op2(int opc, TCGArg arg1, TCGArg arg2) | |
37 | +static inline void tcg_gen_op1i(int opc, TCGArg arg1) | |
38 | 38 | { |
39 | 39 | *gen_opc_ptr++ = opc; |
40 | 40 | *gen_opparam_ptr++ = arg1; |
41 | - *gen_opparam_ptr++ = arg2; | |
42 | 41 | } |
43 | 42 | |
44 | -static inline void tcg_gen_op3(int opc, TCGArg arg1, TCGArg arg2, TCGArg arg3) | |
43 | +static inline void tcg_gen_op2(int opc, TCGv arg1, TCGv arg2) | |
45 | 44 | { |
46 | 45 | *gen_opc_ptr++ = opc; |
47 | - *gen_opparam_ptr++ = arg1; | |
48 | - *gen_opparam_ptr++ = arg2; | |
49 | - *gen_opparam_ptr++ = arg3; | |
46 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
47 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
50 | 48 | } |
51 | 49 | |
52 | -static inline void tcg_gen_op4(int opc, TCGArg arg1, TCGArg arg2, TCGArg arg3, | |
53 | - TCGArg arg4) | |
50 | +static inline void tcg_gen_op2i(int opc, TCGv arg1, TCGArg arg2) | |
54 | 51 | { |
55 | 52 | *gen_opc_ptr++ = opc; |
56 | - *gen_opparam_ptr++ = arg1; | |
53 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
57 | 54 | *gen_opparam_ptr++ = arg2; |
55 | +} | |
56 | + | |
57 | +static inline void tcg_gen_op3(int opc, TCGv arg1, TCGv arg2, TCGv arg3) | |
58 | +{ | |
59 | + *gen_opc_ptr++ = opc; | |
60 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
61 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
62 | + *gen_opparam_ptr++ = GET_TCGV(arg3); | |
63 | +} | |
64 | + | |
65 | +static inline void tcg_gen_op3i(int opc, TCGv arg1, TCGv arg2, TCGArg arg3) | |
66 | +{ | |
67 | + *gen_opc_ptr++ = opc; | |
68 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
69 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
58 | 70 | *gen_opparam_ptr++ = arg3; |
71 | +} | |
72 | + | |
73 | +static inline void tcg_gen_op4(int opc, TCGv arg1, TCGv arg2, TCGv arg3, | |
74 | + TCGv arg4) | |
75 | +{ | |
76 | + *gen_opc_ptr++ = opc; | |
77 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
78 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
79 | + *gen_opparam_ptr++ = GET_TCGV(arg3); | |
80 | + *gen_opparam_ptr++ = GET_TCGV(arg4); | |
81 | +} | |
82 | + | |
83 | +static inline void tcg_gen_op4i(int opc, TCGv arg1, TCGv arg2, TCGv arg3, | |
84 | + TCGArg arg4) | |
85 | +{ | |
86 | + *gen_opc_ptr++ = opc; | |
87 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
88 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
89 | + *gen_opparam_ptr++ = GET_TCGV(arg3); | |
59 | 90 | *gen_opparam_ptr++ = arg4; |
60 | 91 | } |
61 | 92 | |
62 | -static inline void tcg_gen_op5(int opc, TCGArg arg1, TCGArg arg2, | |
63 | - TCGArg arg3, TCGArg arg4, | |
64 | - TCGArg arg5) | |
93 | +static inline void tcg_gen_op4ii(int opc, TCGv arg1, TCGv arg2, TCGArg arg3, | |
94 | + TCGArg arg4) | |
65 | 95 | { |
66 | 96 | *gen_opc_ptr++ = opc; |
67 | - *gen_opparam_ptr++ = arg1; | |
68 | - *gen_opparam_ptr++ = arg2; | |
97 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
98 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
69 | 99 | *gen_opparam_ptr++ = arg3; |
70 | 100 | *gen_opparam_ptr++ = arg4; |
101 | +} | |
102 | + | |
103 | +static inline void tcg_gen_op5(int opc, TCGv arg1, TCGv arg2, | |
104 | + TCGv arg3, TCGv arg4, | |
105 | + TCGv arg5) | |
106 | +{ | |
107 | + *gen_opc_ptr++ = opc; | |
108 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
109 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
110 | + *gen_opparam_ptr++ = GET_TCGV(arg3); | |
111 | + *gen_opparam_ptr++ = GET_TCGV(arg4); | |
112 | + *gen_opparam_ptr++ = GET_TCGV(arg5); | |
113 | +} | |
114 | + | |
115 | +static inline void tcg_gen_op5i(int opc, TCGv arg1, TCGv arg2, | |
116 | + TCGv arg3, TCGv arg4, | |
117 | + TCGArg arg5) | |
118 | +{ | |
119 | + *gen_opc_ptr++ = opc; | |
120 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
121 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
122 | + *gen_opparam_ptr++ = GET_TCGV(arg3); | |
123 | + *gen_opparam_ptr++ = GET_TCGV(arg4); | |
71 | 124 | *gen_opparam_ptr++ = arg5; |
72 | 125 | } |
73 | 126 | |
74 | -static inline void tcg_gen_op6(int opc, TCGArg arg1, TCGArg arg2, | |
75 | - TCGArg arg3, TCGArg arg4, | |
76 | - TCGArg arg5, TCGArg arg6) | |
127 | +static inline void tcg_gen_op6(int opc, TCGv arg1, TCGv arg2, | |
128 | + TCGv arg3, TCGv arg4, | |
129 | + TCGv arg5, TCGv arg6) | |
77 | 130 | { |
78 | 131 | *gen_opc_ptr++ = opc; |
79 | - *gen_opparam_ptr++ = arg1; | |
80 | - *gen_opparam_ptr++ = arg2; | |
81 | - *gen_opparam_ptr++ = arg3; | |
82 | - *gen_opparam_ptr++ = arg4; | |
132 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
133 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
134 | + *gen_opparam_ptr++ = GET_TCGV(arg3); | |
135 | + *gen_opparam_ptr++ = GET_TCGV(arg4); | |
136 | + *gen_opparam_ptr++ = GET_TCGV(arg5); | |
137 | + *gen_opparam_ptr++ = GET_TCGV(arg6); | |
138 | +} | |
139 | + | |
140 | +static inline void tcg_gen_op6ii(int opc, TCGv arg1, TCGv arg2, | |
141 | + TCGv arg3, TCGv arg4, | |
142 | + TCGArg arg5, TCGArg arg6) | |
143 | +{ | |
144 | + *gen_opc_ptr++ = opc; | |
145 | + *gen_opparam_ptr++ = GET_TCGV(arg1); | |
146 | + *gen_opparam_ptr++ = GET_TCGV(arg2); | |
147 | + *gen_opparam_ptr++ = GET_TCGV(arg3); | |
148 | + *gen_opparam_ptr++ = GET_TCGV(arg4); | |
83 | 149 | *gen_opparam_ptr++ = arg5; |
84 | 150 | *gen_opparam_ptr++ = arg6; |
85 | 151 | } |
86 | 152 | |
87 | 153 | static inline void gen_set_label(int n) |
88 | 154 | { |
89 | - tcg_gen_op1(INDEX_op_set_label, n); | |
155 | + tcg_gen_op1i(INDEX_op_set_label, n); | |
90 | 156 | } |
91 | 157 | |
92 | -static inline void tcg_gen_mov_i32(int ret, int arg) | |
158 | +static inline void tcg_gen_mov_i32(TCGv ret, TCGv arg) | |
93 | 159 | { |
94 | 160 | tcg_gen_op2(INDEX_op_mov_i32, ret, arg); |
95 | 161 | } |
96 | 162 | |
97 | -static inline void tcg_gen_movi_i32(int ret, int32_t arg) | |
163 | +static inline void tcg_gen_movi_i32(TCGv ret, int32_t arg) | |
98 | 164 | { |
99 | - tcg_gen_op2(INDEX_op_movi_i32, ret, arg); | |
165 | + tcg_gen_op2i(INDEX_op_movi_i32, ret, arg); | |
100 | 166 | } |
101 | 167 | |
102 | 168 | /* helper calls */ |
... | ... | @@ -109,16 +175,16 @@ static inline void tcg_gen_helper_0_0(void *func) |
109 | 175 | 0, NULL, 0, NULL); |
110 | 176 | } |
111 | 177 | |
112 | -static inline void tcg_gen_helper_0_1(void *func, TCGArg arg) | |
178 | +static inline void tcg_gen_helper_0_1(void *func, TCGv arg) | |
113 | 179 | { |
114 | 180 | tcg_gen_call(&tcg_ctx, |
115 | 181 | tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, |
116 | 182 | 0, NULL, 1, &arg); |
117 | 183 | } |
118 | 184 | |
119 | -static inline void tcg_gen_helper_0_2(void *func, TCGArg arg1, TCGArg arg2) | |
185 | +static inline void tcg_gen_helper_0_2(void *func, TCGv arg1, TCGv arg2) | |
120 | 186 | { |
121 | - TCGArg args[2]; | |
187 | + TCGv args[2]; | |
122 | 188 | args[0] = arg1; |
123 | 189 | args[1] = arg2; |
124 | 190 | tcg_gen_call(&tcg_ctx, |
... | ... | @@ -126,10 +192,10 @@ static inline void tcg_gen_helper_0_2(void *func, TCGArg arg1, TCGArg arg2) |
126 | 192 | 0, NULL, 2, args); |
127 | 193 | } |
128 | 194 | |
129 | -static inline void tcg_gen_helper_1_2(void *func, TCGArg ret, | |
130 | - TCGArg arg1, TCGArg arg2) | |
195 | +static inline void tcg_gen_helper_1_2(void *func, TCGv ret, | |
196 | + TCGv arg1, TCGv arg2) | |
131 | 197 | { |
132 | - TCGArg args[2]; | |
198 | + TCGv args[2]; | |
133 | 199 | args[0] = arg1; |
134 | 200 | args[1] = arg2; |
135 | 201 | tcg_gen_call(&tcg_ctx, |
... | ... | @@ -139,72 +205,72 @@ static inline void tcg_gen_helper_1_2(void *func, TCGArg ret, |
139 | 205 | |
140 | 206 | /* 32 bit ops */ |
141 | 207 | |
142 | -static inline void tcg_gen_ld8u_i32(int ret, int arg2, tcg_target_long offset) | |
208 | +static inline void tcg_gen_ld8u_i32(TCGv ret, TCGv arg2, tcg_target_long offset) | |
143 | 209 | { |
144 | - tcg_gen_op3(INDEX_op_ld8u_i32, ret, arg2, offset); | |
210 | + tcg_gen_op3i(INDEX_op_ld8u_i32, ret, arg2, offset); | |
145 | 211 | } |
146 | 212 | |
147 | -static inline void tcg_gen_ld8s_i32(int ret, int arg2, tcg_target_long offset) | |
213 | +static inline void tcg_gen_ld8s_i32(TCGv ret, TCGv arg2, tcg_target_long offset) | |
148 | 214 | { |
149 | - tcg_gen_op3(INDEX_op_ld8s_i32, ret, arg2, offset); | |
215 | + tcg_gen_op3i(INDEX_op_ld8s_i32, ret, arg2, offset); | |
150 | 216 | } |
151 | 217 | |
152 | -static inline void tcg_gen_ld16u_i32(int ret, int arg2, tcg_target_long offset) | |
218 | +static inline void tcg_gen_ld16u_i32(TCGv ret, TCGv arg2, tcg_target_long offset) | |
153 | 219 | { |
154 | - tcg_gen_op3(INDEX_op_ld16u_i32, ret, arg2, offset); | |
220 | + tcg_gen_op3i(INDEX_op_ld16u_i32, ret, arg2, offset); | |
155 | 221 | } |
156 | 222 | |
157 | -static inline void tcg_gen_ld16s_i32(int ret, int arg2, tcg_target_long offset) | |
223 | +static inline void tcg_gen_ld16s_i32(TCGv ret, TCGv arg2, tcg_target_long offset) | |
158 | 224 | { |
159 | - tcg_gen_op3(INDEX_op_ld16s_i32, ret, arg2, offset); | |
225 | + tcg_gen_op3i(INDEX_op_ld16s_i32, ret, arg2, offset); | |
160 | 226 | } |
161 | 227 | |
162 | -static inline void tcg_gen_ld_i32(int ret, int arg2, tcg_target_long offset) | |
228 | +static inline void tcg_gen_ld_i32(TCGv ret, TCGv arg2, tcg_target_long offset) | |
163 | 229 | { |
164 | - tcg_gen_op3(INDEX_op_ld_i32, ret, arg2, offset); | |
230 | + tcg_gen_op3i(INDEX_op_ld_i32, ret, arg2, offset); | |
165 | 231 | } |
166 | 232 | |
167 | -static inline void tcg_gen_st8_i32(int arg1, int arg2, tcg_target_long offset) | |
233 | +static inline void tcg_gen_st8_i32(TCGv arg1, TCGv arg2, tcg_target_long offset) | |
168 | 234 | { |
169 | - tcg_gen_op3(INDEX_op_st8_i32, arg1, arg2, offset); | |
235 | + tcg_gen_op3i(INDEX_op_st8_i32, arg1, arg2, offset); | |
170 | 236 | } |
171 | 237 | |
172 | -static inline void tcg_gen_st16_i32(int arg1, int arg2, tcg_target_long offset) | |
238 | +static inline void tcg_gen_st16_i32(TCGv arg1, TCGv arg2, tcg_target_long offset) | |
173 | 239 | { |
174 | - tcg_gen_op3(INDEX_op_st16_i32, arg1, arg2, offset); | |
240 | + tcg_gen_op3i(INDEX_op_st16_i32, arg1, arg2, offset); | |
175 | 241 | } |
176 | 242 | |
177 | -static inline void tcg_gen_st_i32(int arg1, int arg2, tcg_target_long offset) | |
243 | +static inline void tcg_gen_st_i32(TCGv arg1, TCGv arg2, tcg_target_long offset) | |
178 | 244 | { |
179 | - tcg_gen_op3(INDEX_op_st_i32, arg1, arg2, offset); | |
245 | + tcg_gen_op3i(INDEX_op_st_i32, arg1, arg2, offset); | |
180 | 246 | } |
181 | 247 | |
182 | -static inline void tcg_gen_add_i32(int ret, int arg1, int arg2) | |
248 | +static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
183 | 249 | { |
184 | 250 | tcg_gen_op3(INDEX_op_add_i32, ret, arg1, arg2); |
185 | 251 | } |
186 | 252 | |
187 | -static inline void tcg_gen_addi_i32(int ret, int arg1, int32_t arg2) | |
253 | +static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2) | |
188 | 254 | { |
189 | 255 | tcg_gen_add_i32(ret, arg1, tcg_const_i32(arg2)); |
190 | 256 | } |
191 | 257 | |
192 | -static inline void tcg_gen_sub_i32(int ret, int arg1, int arg2) | |
258 | +static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
193 | 259 | { |
194 | 260 | tcg_gen_op3(INDEX_op_sub_i32, ret, arg1, arg2); |
195 | 261 | } |
196 | 262 | |
197 | -static inline void tcg_gen_subi_i32(int ret, int arg1, int32_t arg2) | |
263 | +static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2) | |
198 | 264 | { |
199 | 265 | tcg_gen_sub_i32(ret, arg1, tcg_const_i32(arg2)); |
200 | 266 | } |
201 | 267 | |
202 | -static inline void tcg_gen_and_i32(int ret, int arg1, int arg2) | |
268 | +static inline void tcg_gen_and_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
203 | 269 | { |
204 | 270 | tcg_gen_op3(INDEX_op_and_i32, ret, arg1, arg2); |
205 | 271 | } |
206 | 272 | |
207 | -static inline void tcg_gen_andi_i32(int ret, int arg1, int32_t arg2) | |
273 | +static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2) | |
208 | 274 | { |
209 | 275 | /* some cases can be optimized here */ |
210 | 276 | if (arg2 == 0) { |
... | ... | @@ -216,12 +282,12 @@ static inline void tcg_gen_andi_i32(int ret, int arg1, int32_t arg2) |
216 | 282 | } |
217 | 283 | } |
218 | 284 | |
219 | -static inline void tcg_gen_or_i32(int ret, int arg1, int arg2) | |
285 | +static inline void tcg_gen_or_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
220 | 286 | { |
221 | 287 | tcg_gen_op3(INDEX_op_or_i32, ret, arg1, arg2); |
222 | 288 | } |
223 | 289 | |
224 | -static inline void tcg_gen_ori_i32(int ret, int arg1, int32_t arg2) | |
290 | +static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2) | |
225 | 291 | { |
226 | 292 | /* some cases can be optimized here */ |
227 | 293 | if (arg2 == 0xffffffff) { |
... | ... | @@ -233,12 +299,12 @@ static inline void tcg_gen_ori_i32(int ret, int arg1, int32_t arg2) |
233 | 299 | } |
234 | 300 | } |
235 | 301 | |
236 | -static inline void tcg_gen_xor_i32(int ret, int arg1, int arg2) | |
302 | +static inline void tcg_gen_xor_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
237 | 303 | { |
238 | 304 | tcg_gen_op3(INDEX_op_xor_i32, ret, arg1, arg2); |
239 | 305 | } |
240 | 306 | |
241 | -static inline void tcg_gen_xori_i32(int ret, int arg1, int32_t arg2) | |
307 | +static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2) | |
242 | 308 | { |
243 | 309 | /* some cases can be optimized here */ |
244 | 310 | if (arg2 == 0) { |
... | ... | @@ -248,95 +314,95 @@ static inline void tcg_gen_xori_i32(int ret, int arg1, int32_t arg2) |
248 | 314 | } |
249 | 315 | } |
250 | 316 | |
251 | -static inline void tcg_gen_shl_i32(int ret, int arg1, int arg2) | |
317 | +static inline void tcg_gen_shl_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
252 | 318 | { |
253 | 319 | tcg_gen_op3(INDEX_op_shl_i32, ret, arg1, arg2); |
254 | 320 | } |
255 | 321 | |
256 | -static inline void tcg_gen_shli_i32(int ret, int arg1, int32_t arg2) | |
322 | +static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2) | |
257 | 323 | { |
258 | 324 | tcg_gen_shl_i32(ret, arg1, tcg_const_i32(arg2)); |
259 | 325 | } |
260 | 326 | |
261 | -static inline void tcg_gen_shr_i32(int ret, int arg1, int arg2) | |
327 | +static inline void tcg_gen_shr_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
262 | 328 | { |
263 | 329 | tcg_gen_op3(INDEX_op_shr_i32, ret, arg1, arg2); |
264 | 330 | } |
265 | 331 | |
266 | -static inline void tcg_gen_shri_i32(int ret, int arg1, int32_t arg2) | |
332 | +static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2) | |
267 | 333 | { |
268 | 334 | tcg_gen_shr_i32(ret, arg1, tcg_const_i32(arg2)); |
269 | 335 | } |
270 | 336 | |
271 | -static inline void tcg_gen_sar_i32(int ret, int arg1, int arg2) | |
337 | +static inline void tcg_gen_sar_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
272 | 338 | { |
273 | 339 | tcg_gen_op3(INDEX_op_sar_i32, ret, arg1, arg2); |
274 | 340 | } |
275 | 341 | |
276 | -static inline void tcg_gen_sari_i32(int ret, int arg1, int32_t arg2) | |
342 | +static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2) | |
277 | 343 | { |
278 | 344 | tcg_gen_sar_i32(ret, arg1, tcg_const_i32(arg2)); |
279 | 345 | } |
280 | 346 | |
281 | -static inline void tcg_gen_brcond_i32(int cond, TCGArg arg1, TCGArg arg2, | |
347 | +static inline void tcg_gen_brcond_i32(int cond, TCGv arg1, TCGv arg2, | |
282 | 348 | int label_index) |
283 | 349 | { |
284 | - tcg_gen_op4(INDEX_op_brcond_i32, arg1, arg2, cond, label_index); | |
350 | + tcg_gen_op4ii(INDEX_op_brcond_i32, arg1, arg2, cond, label_index); | |
285 | 351 | } |
286 | 352 | |
287 | -static inline void tcg_gen_mul_i32(int ret, int arg1, int arg2) | |
353 | +static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
288 | 354 | { |
289 | 355 | tcg_gen_op3(INDEX_op_mul_i32, ret, arg1, arg2); |
290 | 356 | } |
291 | 357 | |
292 | 358 | #ifdef TCG_TARGET_HAS_div_i32 |
293 | -static inline void tcg_gen_div_i32(int ret, int arg1, int arg2) | |
359 | +static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
294 | 360 | { |
295 | 361 | tcg_gen_op3(INDEX_op_div_i32, ret, arg1, arg2); |
296 | 362 | } |
297 | 363 | |
298 | -static inline void tcg_gen_rem_i32(int ret, int arg1, int arg2) | |
364 | +static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
299 | 365 | { |
300 | 366 | tcg_gen_op3(INDEX_op_rem_i32, ret, arg1, arg2); |
301 | 367 | } |
302 | 368 | |
303 | -static inline void tcg_gen_divu_i32(int ret, int arg1, int arg2) | |
369 | +static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
304 | 370 | { |
305 | 371 | tcg_gen_op3(INDEX_op_divu_i32, ret, arg1, arg2); |
306 | 372 | } |
307 | 373 | |
308 | -static inline void tcg_gen_remu_i32(int ret, int arg1, int arg2) | |
374 | +static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
309 | 375 | { |
310 | 376 | tcg_gen_op3(INDEX_op_remu_i32, ret, arg1, arg2); |
311 | 377 | } |
312 | 378 | #else |
313 | -static inline void tcg_gen_div_i32(int ret, int arg1, int arg2) | |
379 | +static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
314 | 380 | { |
315 | - int t0; | |
381 | + TCGv t0; | |
316 | 382 | t0 = tcg_temp_new(TCG_TYPE_I32); |
317 | 383 | tcg_gen_sari_i32(t0, arg1, 31); |
318 | 384 | tcg_gen_op5(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2); |
319 | 385 | } |
320 | 386 | |
321 | -static inline void tcg_gen_rem_i32(int ret, int arg1, int arg2) | |
387 | +static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
322 | 388 | { |
323 | - int t0; | |
389 | + TCGv t0; | |
324 | 390 | t0 = tcg_temp_new(TCG_TYPE_I32); |
325 | 391 | tcg_gen_sari_i32(t0, arg1, 31); |
326 | 392 | tcg_gen_op5(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2); |
327 | 393 | } |
328 | 394 | |
329 | -static inline void tcg_gen_divu_i32(int ret, int arg1, int arg2) | |
395 | +static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
330 | 396 | { |
331 | - int t0; | |
397 | + TCGv t0; | |
332 | 398 | t0 = tcg_temp_new(TCG_TYPE_I32); |
333 | 399 | tcg_gen_movi_i32(t0, 0); |
334 | 400 | tcg_gen_op5(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2); |
335 | 401 | } |
336 | 402 | |
337 | -static inline void tcg_gen_remu_i32(int ret, int arg1, int arg2) | |
403 | +static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2) | |
338 | 404 | { |
339 | - int t0; | |
405 | + TCGv t0; | |
340 | 406 | t0 = tcg_temp_new(TCG_TYPE_I32); |
341 | 407 | tcg_gen_movi_i32(t0, 0); |
342 | 408 | tcg_gen_op5(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2); |
... | ... | @@ -345,433 +411,443 @@ static inline void tcg_gen_remu_i32(int ret, int arg1, int arg2) |
345 | 411 | |
346 | 412 | #if TCG_TARGET_REG_BITS == 32 |
347 | 413 | |
348 | -static inline void tcg_gen_mov_i64(int ret, int arg) | |
414 | +static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg) | |
349 | 415 | { |
350 | 416 | tcg_gen_mov_i32(ret, arg); |
351 | - tcg_gen_mov_i32(ret + 1, arg + 1); | |
417 | + tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); | |
352 | 418 | } |
353 | 419 | |
354 | -static inline void tcg_gen_movi_i64(int ret, int64_t arg) | |
420 | +static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg) | |
355 | 421 | { |
356 | 422 | tcg_gen_movi_i32(ret, arg); |
357 | - tcg_gen_movi_i32(ret + 1, arg >> 32); | |
423 | + tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32); | |
358 | 424 | } |
359 | 425 | |
360 | -static inline void tcg_gen_ld8u_i64(int ret, int arg2, tcg_target_long offset) | |
426 | +static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, tcg_target_long offset) | |
361 | 427 | { |
362 | 428 | tcg_gen_ld8u_i32(ret, arg2, offset); |
363 | - tcg_gen_movi_i32(ret + 1, 0); | |
429 | + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); | |
364 | 430 | } |
365 | 431 | |
366 | -static inline void tcg_gen_ld8s_i64(int ret, int arg2, tcg_target_long offset) | |
432 | +static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, tcg_target_long offset) | |
367 | 433 | { |
368 | 434 | tcg_gen_ld8s_i32(ret, arg2, offset); |
369 | - tcg_gen_sari_i32(ret + 1, ret, 31); | |
435 | + tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31); | |
370 | 436 | } |
371 | 437 | |
372 | -static inline void tcg_gen_ld16u_i64(int ret, int arg2, tcg_target_long offset) | |
438 | +static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, tcg_target_long offset) | |
373 | 439 | { |
374 | 440 | tcg_gen_ld16u_i32(ret, arg2, offset); |
375 | - tcg_gen_movi_i32(ret + 1, 0); | |
441 | + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); | |
376 | 442 | } |
377 | 443 | |
378 | -static inline void tcg_gen_ld16s_i64(int ret, int arg2, tcg_target_long offset) | |
444 | +static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, tcg_target_long offset) | |
379 | 445 | { |
380 | 446 | tcg_gen_ld16s_i32(ret, arg2, offset); |
381 | - tcg_gen_sari_i32(ret + 1, ret, 31); | |
447 | + tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31); | |
382 | 448 | } |
383 | 449 | |
384 | -static inline void tcg_gen_ld32u_i64(int ret, int arg2, tcg_target_long offset) | |
450 | +static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, tcg_target_long offset) | |
385 | 451 | { |
386 | 452 | tcg_gen_ld_i32(ret, arg2, offset); |
387 | - tcg_gen_movi_i32(ret + 1, 0); | |
453 | + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); | |
388 | 454 | } |
389 | 455 | |
390 | -static inline void tcg_gen_ld32s_i64(int ret, int arg2, tcg_target_long offset) | |
456 | +static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, tcg_target_long offset) | |
391 | 457 | { |
392 | 458 | tcg_gen_ld_i32(ret, arg2, offset); |
393 | - tcg_gen_sari_i32(ret + 1, ret, 31); | |
459 | + tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31); | |
394 | 460 | } |
395 | 461 | |
396 | -static inline void tcg_gen_ld_i64(int ret, int arg2, tcg_target_long offset) | |
462 | +static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset) | |
397 | 463 | { |
398 | 464 | /* since arg2 and ret have different types, they cannot be the |
399 | 465 | same temporary */ |
400 | 466 | #ifdef TCG_TARGET_WORDS_BIGENDIAN |
401 | - tcg_gen_ld_i32(ret + 1, arg2, offset); | |
467 | + tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset); | |
402 | 468 | tcg_gen_ld_i32(ret, arg2, offset + 4); |
403 | 469 | #else |
404 | 470 | tcg_gen_ld_i32(ret, arg2, offset); |
405 | - tcg_gen_ld_i32(ret + 1, arg2, offset + 4); | |
471 | + tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4); | |
406 | 472 | #endif |
407 | 473 | } |
408 | 474 | |
409 | -static inline void tcg_gen_st8_i64(int arg1, int arg2, tcg_target_long offset) | |
475 | +static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, tcg_target_long offset) | |
410 | 476 | { |
411 | 477 | tcg_gen_st8_i32(arg1, arg2, offset); |
412 | 478 | } |
413 | 479 | |
414 | -static inline void tcg_gen_st16_i64(int arg1, int arg2, tcg_target_long offset) | |
480 | +static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, tcg_target_long offset) | |
415 | 481 | { |
416 | 482 | tcg_gen_st16_i32(arg1, arg2, offset); |
417 | 483 | } |
418 | 484 | |
419 | -static inline void tcg_gen_st32_i64(int arg1, int arg2, tcg_target_long offset) | |
485 | +static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, tcg_target_long offset) | |
420 | 486 | { |
421 | 487 | tcg_gen_st_i32(arg1, arg2, offset); |
422 | 488 | } |
423 | 489 | |
424 | -static inline void tcg_gen_st_i64(int arg1, int arg2, tcg_target_long offset) | |
490 | +static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset) | |
425 | 491 | { |
426 | 492 | #ifdef TCG_TARGET_WORDS_BIGENDIAN |
427 | - tcg_gen_st_i32(arg1 + 1, arg2, offset); | |
493 | + tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset); | |
428 | 494 | tcg_gen_st_i32(arg1, arg2, offset + 4); |
429 | 495 | #else |
430 | 496 | tcg_gen_st_i32(arg1, arg2, offset); |
431 | - tcg_gen_st_i32(arg1 + 1, arg2, offset + 4); | |
497 | + tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4); | |
432 | 498 | #endif |
433 | 499 | } |
434 | 500 | |
435 | -static inline void tcg_gen_add_i64(int ret, int arg1, int arg2) | |
501 | +static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
436 | 502 | { |
437 | - tcg_gen_op6(INDEX_op_add2_i32, ret, ret + 1, | |
438 | - arg1, arg1 + 1, arg2, arg2 + 1); | |
503 | + tcg_gen_op6(INDEX_op_add2_i32, ret, TCGV_HIGH(ret), | |
504 | + arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2)); | |
439 | 505 | } |
440 | 506 | |
441 | -static inline void tcg_gen_addi_i64(int ret, int arg1, int64_t arg2) | |
507 | +static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
442 | 508 | { |
443 | 509 | tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2)); |
444 | 510 | } |
445 | 511 | |
446 | -static inline void tcg_gen_sub_i64(int ret, int arg1, int arg2) | |
512 | +static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
447 | 513 | { |
448 | - tcg_gen_op6(INDEX_op_sub2_i32, ret, ret + 1, | |
449 | - arg1, arg1 + 1, arg2, arg2 + 1); | |
514 | + tcg_gen_op6(INDEX_op_sub2_i32, ret, TCGV_HIGH(ret), | |
515 | + arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2)); | |
450 | 516 | } |
451 | 517 | |
452 | -static inline void tcg_gen_subi_i64(int ret, int arg1, int64_t arg2) | |
518 | +static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
453 | 519 | { |
454 | 520 | tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2)); |
455 | 521 | } |
456 | 522 | |
457 | -static inline void tcg_gen_and_i64(int ret, int arg1, int arg2) | |
523 | +static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
458 | 524 | { |
459 | 525 | tcg_gen_and_i32(ret, arg1, arg2); |
460 | - tcg_gen_and_i32(ret + 1, arg1 + 1, arg2 + 1); | |
526 | + tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
461 | 527 | } |
462 | 528 | |
463 | -static inline void tcg_gen_andi_i64(int ret, int arg1, int64_t arg2) | |
529 | +static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
464 | 530 | { |
465 | 531 | tcg_gen_andi_i32(ret, arg1, arg2); |
466 | - tcg_gen_andi_i32(ret + 1, arg1 + 1, arg2 >> 32); | |
532 | + tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); | |
467 | 533 | } |
468 | 534 | |
469 | -static inline void tcg_gen_or_i64(int ret, int arg1, int arg2) | |
535 | +static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
470 | 536 | { |
471 | 537 | tcg_gen_or_i32(ret, arg1, arg2); |
472 | - tcg_gen_or_i32(ret + 1, arg1 + 1, arg2 + 1); | |
538 | + tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
473 | 539 | } |
474 | 540 | |
475 | -static inline void tcg_gen_ori_i64(int ret, int arg1, int64_t arg2) | |
541 | +static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
476 | 542 | { |
477 | 543 | tcg_gen_ori_i32(ret, arg1, arg2); |
478 | - tcg_gen_ori_i32(ret + 1, arg1 + 1, arg2 >> 32); | |
544 | + tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); | |
479 | 545 | } |
480 | 546 | |
481 | -static inline void tcg_gen_xor_i64(int ret, int arg1, int arg2) | |
547 | +static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
482 | 548 | { |
483 | 549 | tcg_gen_xor_i32(ret, arg1, arg2); |
484 | - tcg_gen_xor_i32(ret + 1, arg1 + 1, arg2 + 1); | |
550 | + tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); | |
485 | 551 | } |
486 | 552 | |
487 | -static inline void tcg_gen_xori_i64(int ret, int arg1, int64_t arg2) | |
553 | +static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
488 | 554 | { |
489 | 555 | tcg_gen_xori_i32(ret, arg1, arg2); |
490 | - tcg_gen_xori_i32(ret + 1, arg1 + 1, arg2 >> 32); | |
556 | + tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); | |
491 | 557 | } |
492 | 558 | |
493 | 559 | /* XXX: use generic code when basic block handling is OK or CPU |
494 | 560 | specific code (x86) */ |
495 | -static inline void tcg_gen_shl_i64(int ret, int arg1, int64_t arg2) | |
561 | +static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
496 | 562 | { |
497 | 563 | tcg_gen_helper_1_2(tcg_helper_shl_i64, ret, arg1, arg2); |
498 | 564 | } |
499 | 565 | |
500 | -static inline void tcg_gen_shli_i64(int ret, int arg1, int64_t arg2) | |
566 | +static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
501 | 567 | { |
502 | 568 | tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0); |
503 | 569 | } |
504 | 570 | |
505 | -static inline void tcg_gen_shr_i64(int ret, int arg1, int64_t arg2) | |
571 | +static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
506 | 572 | { |
507 | 573 | tcg_gen_helper_1_2(tcg_helper_shr_i64, ret, arg1, arg2); |
508 | 574 | } |
509 | 575 | |
510 | -static inline void tcg_gen_shri_i64(int ret, int arg1, int64_t arg2) | |
576 | +static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
511 | 577 | { |
512 | 578 | tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0); |
513 | 579 | } |
514 | 580 | |
515 | -static inline void tcg_gen_sar_i64(int ret, int arg1, int64_t arg2) | |
581 | +static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
516 | 582 | { |
517 | 583 | tcg_gen_helper_1_2(tcg_helper_sar_i64, ret, arg1, arg2); |
518 | 584 | } |
519 | 585 | |
520 | -static inline void tcg_gen_sari_i64(int ret, int arg1, int64_t arg2) | |
586 | +static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
521 | 587 | { |
522 | 588 | tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1); |
523 | 589 | } |
524 | 590 | |
525 | -static inline void tcg_gen_brcond_i64(int cond, TCGArg arg1, TCGArg arg2, | |
591 | +static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2, | |
526 | 592 | int label_index) |
527 | 593 | { |
528 | - tcg_gen_op6(INDEX_op_brcond2_i32, | |
529 | - arg1, arg1 + 1, arg2, arg2 + 1, cond, label_index); | |
594 | + tcg_gen_op6ii(INDEX_op_brcond2_i32, | |
595 | + arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2), | |
596 | + cond, label_index); | |
530 | 597 | } |
531 | 598 | |
532 | -static inline void tcg_gen_mul_i64(int ret, int arg1, int arg2) | |
599 | +static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
533 | 600 | { |
534 | - int t0, t1; | |
601 | + TCGv t0, t1; | |
535 | 602 | |
536 | 603 | t0 = tcg_temp_new(TCG_TYPE_I64); |
537 | 604 | t1 = tcg_temp_new(TCG_TYPE_I32); |
538 | 605 | |
539 | - tcg_gen_op4(INDEX_op_mulu2_i32, t0, t0 + 1, arg1, arg2); | |
606 | + tcg_gen_op4(INDEX_op_mulu2_i32, t0, TCGV_HIGH(t0), arg1, arg2); | |
540 | 607 | |
541 | - tcg_gen_mul_i32(t1, arg1, arg2 + 1); | |
542 | - tcg_gen_add_i32(t0 + 1, t0 + 1, t1); | |
543 | - tcg_gen_mul_i32(t1, arg1 + 1, arg2); | |
544 | - tcg_gen_add_i32(t0 + 1, t0 + 1, t1); | |
608 | + tcg_gen_mul_i32(t1, arg1, TCGV_HIGH(arg2)); | |
609 | + tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1); | |
610 | + tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), arg2); | |
611 | + tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1); | |
545 | 612 | |
546 | 613 | tcg_gen_mov_i64(ret, t0); |
547 | 614 | } |
548 | 615 | |
549 | -static inline void tcg_gen_div_i64(int ret, int arg1, int64_t arg2) | |
616 | +static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
550 | 617 | { |
551 | 618 | tcg_gen_helper_1_2(tcg_helper_div_i64, ret, arg1, arg2); |
552 | 619 | } |
553 | 620 | |
554 | -static inline void tcg_gen_rem_i64(int ret, int arg1, int64_t arg2) | |
621 | +static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
555 | 622 | { |
556 | 623 | tcg_gen_helper_1_2(tcg_helper_rem_i64, ret, arg1, arg2); |
557 | 624 | } |
558 | 625 | |
559 | -static inline void tcg_gen_divu_i64(int ret, int arg1, int64_t arg2) | |
626 | +static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
560 | 627 | { |
561 | 628 | tcg_gen_helper_1_2(tcg_helper_divu_i64, ret, arg1, arg2); |
562 | 629 | } |
563 | 630 | |
564 | -static inline void tcg_gen_remu_i64(int ret, int arg1, int64_t arg2) | |
631 | +static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
565 | 632 | { |
566 | 633 | tcg_gen_helper_1_2(tcg_helper_remu_i64, ret, arg1, arg2); |
567 | 634 | } |
568 | 635 | |
569 | 636 | #else |
570 | 637 | |
571 | -static inline void tcg_gen_mov_i64(int ret, int arg) | |
638 | +static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg) | |
572 | 639 | { |
573 | 640 | tcg_gen_op2(INDEX_op_mov_i64, ret, arg); |
574 | 641 | } |
575 | 642 | |
576 | -static inline void tcg_gen_movi_i64(int ret, int64_t arg) | |
643 | +static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg) | |
577 | 644 | { |
578 | - tcg_gen_op2(INDEX_op_movi_i64, ret, arg); | |
645 | + tcg_gen_op2i(INDEX_op_movi_i64, ret, arg); | |
579 | 646 | } |
580 | 647 | |
581 | -static inline void tcg_gen_ld8u_i64(int ret, int arg2, tcg_target_long offset) | |
648 | +static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, | |
649 | + tcg_target_long offset) | |
582 | 650 | { |
583 | - tcg_gen_op3(INDEX_op_ld8u_i64, ret, arg2, offset); | |
651 | + tcg_gen_op3i(INDEX_op_ld8u_i64, ret, arg2, offset); | |
584 | 652 | } |
585 | 653 | |
586 | -static inline void tcg_gen_ld8s_i64(int ret, int arg2, tcg_target_long offset) | |
654 | +static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, | |
655 | + tcg_target_long offset) | |
587 | 656 | { |
588 | - tcg_gen_op3(INDEX_op_ld8s_i64, ret, arg2, offset); | |
657 | + tcg_gen_op3i(INDEX_op_ld8s_i64, ret, arg2, offset); | |
589 | 658 | } |
590 | 659 | |
591 | -static inline void tcg_gen_ld16u_i64(int ret, int arg2, tcg_target_long offset) | |
660 | +static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, | |
661 | + tcg_target_long offset) | |
592 | 662 | { |
593 | - tcg_gen_op3(INDEX_op_ld16u_i64, ret, arg2, offset); | |
663 | + tcg_gen_op3i(INDEX_op_ld16u_i64, ret, arg2, offset); | |
594 | 664 | } |
595 | 665 | |
596 | -static inline void tcg_gen_ld16s_i64(int ret, int arg2, tcg_target_long offset) | |
666 | +static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, | |
667 | + tcg_target_long offset) | |
597 | 668 | { |
598 | - tcg_gen_op3(INDEX_op_ld16s_i64, ret, arg2, offset); | |
669 | + tcg_gen_op3i(INDEX_op_ld16s_i64, ret, arg2, offset); | |
599 | 670 | } |
600 | 671 | |
601 | -static inline void tcg_gen_ld32u_i64(int ret, int arg2, tcg_target_long offset) | |
672 | +static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, | |
673 | + tcg_target_long offset) | |
602 | 674 | { |
603 | - tcg_gen_op3(INDEX_op_ld32u_i64, ret, arg2, offset); | |
675 | + tcg_gen_op3i(INDEX_op_ld32u_i64, ret, arg2, offset); | |
604 | 676 | } |
605 | 677 | |
606 | -static inline void tcg_gen_ld32s_i64(int ret, int arg2, tcg_target_long offset) | |
678 | +static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, | |
679 | + tcg_target_long offset) | |
607 | 680 | { |
608 | - tcg_gen_op3(INDEX_op_ld32s_i64, ret, arg2, offset); | |
681 | + tcg_gen_op3i(INDEX_op_ld32s_i64, ret, arg2, offset); | |
609 | 682 | } |
610 | 683 | |
611 | -static inline void tcg_gen_ld_i64(int ret, int arg2, tcg_target_long offset) | |
684 | +static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset) | |
612 | 685 | { |
613 | - tcg_gen_op3(INDEX_op_ld_i64, ret, arg2, offset); | |
686 | + tcg_gen_op3i(INDEX_op_ld_i64, ret, arg2, offset); | |
614 | 687 | } |
615 | 688 | |
616 | -static inline void tcg_gen_st8_i64(int arg1, int arg2, tcg_target_long offset) | |
689 | +static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, | |
690 | + tcg_target_long offset) | |
617 | 691 | { |
618 | - tcg_gen_op3(INDEX_op_st8_i64, arg1, arg2, offset); | |
692 | + tcg_gen_op3i(INDEX_op_st8_i64, arg1, arg2, offset); | |
619 | 693 | } |
620 | 694 | |
621 | -static inline void tcg_gen_st16_i64(int arg1, int arg2, tcg_target_long offset) | |
695 | +static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, | |
696 | + tcg_target_long offset) | |
622 | 697 | { |
623 | - tcg_gen_op3(INDEX_op_st16_i64, arg1, arg2, offset); | |
698 | + tcg_gen_op3i(INDEX_op_st16_i64, arg1, arg2, offset); | |
624 | 699 | } |
625 | 700 | |
626 | -static inline void tcg_gen_st32_i64(int arg1, int arg2, tcg_target_long offset) | |
701 | +static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, | |
702 | + tcg_target_long offset) | |
627 | 703 | { |
628 | - tcg_gen_op3(INDEX_op_st32_i64, arg1, arg2, offset); | |
704 | + tcg_gen_op3i(INDEX_op_st32_i64, arg1, arg2, offset); | |
629 | 705 | } |
630 | 706 | |
631 | -static inline void tcg_gen_st_i64(int arg1, int arg2, tcg_target_long offset) | |
707 | +static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset) | |
632 | 708 | { |
633 | - tcg_gen_op3(INDEX_op_st_i64, arg1, arg2, offset); | |
709 | + tcg_gen_op3i(INDEX_op_st_i64, arg1, arg2, offset); | |
634 | 710 | } |
635 | 711 | |
636 | -static inline void tcg_gen_add_i64(int ret, int arg1, int arg2) | |
712 | +static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
637 | 713 | { |
638 | 714 | tcg_gen_op3(INDEX_op_add_i64, ret, arg1, arg2); |
639 | 715 | } |
640 | 716 | |
641 | -static inline void tcg_gen_addi_i64(int ret, int arg1, int64_t arg2) | |
717 | +static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
642 | 718 | { |
643 | 719 | tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2)); |
644 | 720 | } |
645 | 721 | |
646 | -static inline void tcg_gen_sub_i64(int ret, int arg1, int arg2) | |
722 | +static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
647 | 723 | { |
648 | 724 | tcg_gen_op3(INDEX_op_sub_i64, ret, arg1, arg2); |
649 | 725 | } |
650 | 726 | |
651 | -static inline void tcg_gen_subi_i64(int ret, int arg1, int64_t arg2) | |
727 | +static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
652 | 728 | { |
653 | 729 | tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2)); |
654 | 730 | } |
655 | 731 | |
656 | -static inline void tcg_gen_and_i64(int ret, int arg1, int arg2) | |
732 | +static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
657 | 733 | { |
658 | 734 | tcg_gen_op3(INDEX_op_and_i64, ret, arg1, arg2); |
659 | 735 | } |
660 | 736 | |
661 | -static inline void tcg_gen_andi_i64(int ret, int arg1, int64_t arg2) | |
737 | +static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
662 | 738 | { |
663 | 739 | tcg_gen_and_i64(ret, arg1, tcg_const_i64(arg2)); |
664 | 740 | } |
665 | 741 | |
666 | -static inline void tcg_gen_or_i64(int ret, int arg1, int arg2) | |
742 | +static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
667 | 743 | { |
668 | 744 | tcg_gen_op3(INDEX_op_or_i64, ret, arg1, arg2); |
669 | 745 | } |
670 | 746 | |
671 | -static inline void tcg_gen_ori_i64(int ret, int arg1, int64_t arg2) | |
747 | +static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
672 | 748 | { |
673 | 749 | tcg_gen_or_i64(ret, arg1, tcg_const_i64(arg2)); |
674 | 750 | } |
675 | 751 | |
676 | -static inline void tcg_gen_xor_i64(int ret, int arg1, int arg2) | |
752 | +static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
677 | 753 | { |
678 | 754 | tcg_gen_op3(INDEX_op_xor_i64, ret, arg1, arg2); |
679 | 755 | } |
680 | 756 | |
681 | -static inline void tcg_gen_xori_i64(int ret, int arg1, int64_t arg2) | |
757 | +static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
682 | 758 | { |
683 | 759 | tcg_gen_xor_i64(ret, arg1, tcg_const_i64(arg2)); |
684 | 760 | } |
685 | 761 | |
686 | -static inline void tcg_gen_shl_i64(int ret, int arg1, int arg2) | |
762 | +static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
687 | 763 | { |
688 | 764 | tcg_gen_op3(INDEX_op_shl_i64, ret, arg1, arg2); |
689 | 765 | } |
690 | 766 | |
691 | -static inline void tcg_gen_shli_i64(int ret, int arg1, int64_t arg2) | |
767 | +static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
692 | 768 | { |
693 | 769 | tcg_gen_shl_i64(ret, arg1, tcg_const_i64(arg2)); |
694 | 770 | } |
695 | 771 | |
696 | -static inline void tcg_gen_shr_i64(int ret, int arg1, int arg2) | |
772 | +static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
697 | 773 | { |
698 | 774 | tcg_gen_op3(INDEX_op_shr_i64, ret, arg1, arg2); |
699 | 775 | } |
700 | 776 | |
701 | -static inline void tcg_gen_shri_i64(int ret, int arg1, int64_t arg2) | |
777 | +static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
702 | 778 | { |
703 | 779 | tcg_gen_shr_i64(ret, arg1, tcg_const_i64(arg2)); |
704 | 780 | } |
705 | 781 | |
706 | -static inline void tcg_gen_sar_i64(int ret, int arg1, int arg2) | |
782 | +static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
707 | 783 | { |
708 | 784 | tcg_gen_op3(INDEX_op_sar_i64, ret, arg1, arg2); |
709 | 785 | } |
710 | 786 | |
711 | -static inline void tcg_gen_sari_i64(int ret, int arg1, int64_t arg2) | |
787 | +static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2) | |
712 | 788 | { |
713 | 789 | tcg_gen_sar_i64(ret, arg1, tcg_const_i64(arg2)); |
714 | 790 | } |
715 | 791 | |
716 | -static inline void tcg_gen_brcond_i64(int cond, TCGArg arg1, TCGArg arg2, | |
792 | +static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2, | |
717 | 793 | int label_index) |
718 | 794 | { |
719 | - tcg_gen_op4(INDEX_op_brcond_i64, arg1, arg2, cond, label_index); | |
795 | + tcg_gen_op4ii(INDEX_op_brcond_i64, arg1, arg2, cond, label_index); | |
720 | 796 | } |
721 | 797 | |
722 | -static inline void tcg_gen_mul_i64(int ret, int arg1, int arg2) | |
798 | +static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
723 | 799 | { |
724 | 800 | tcg_gen_op3(INDEX_op_mul_i64, ret, arg1, arg2); |
725 | 801 | } |
726 | 802 | |
727 | 803 | #ifdef TCG_TARGET_HAS_div_i64 |
728 | -static inline void tcg_gen_div_i64(int ret, int arg1, int arg2) | |
804 | +static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
729 | 805 | { |
730 | 806 | tcg_gen_op3(INDEX_op_div_i64, ret, arg1, arg2); |
731 | 807 | } |
732 | 808 | |
733 | -static inline void tcg_gen_rem_i64(int ret, int arg1, int arg2) | |
809 | +static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
734 | 810 | { |
735 | 811 | tcg_gen_op3(INDEX_op_rem_i64, ret, arg1, arg2); |
736 | 812 | } |
737 | 813 | |
738 | -static inline void tcg_gen_divu_i64(int ret, int arg1, int arg2) | |
814 | +static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
739 | 815 | { |
740 | 816 | tcg_gen_op3(INDEX_op_divu_i64, ret, arg1, arg2); |
741 | 817 | } |
742 | 818 | |
743 | -static inline void tcg_gen_remu_i64(int ret, int arg1, int arg2) | |
819 | +static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
744 | 820 | { |
745 | 821 | tcg_gen_op3(INDEX_op_remu_i64, ret, arg1, arg2); |
746 | 822 | } |
747 | 823 | #else |
748 | -static inline void tcg_gen_div_i64(int ret, int arg1, int arg2) | |
824 | +static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
749 | 825 | { |
750 | - int t0; | |
826 | + TCGv t0; | |
751 | 827 | t0 = tcg_temp_new(TCG_TYPE_I64); |
752 | 828 | tcg_gen_sari_i64(t0, arg1, 63); |
753 | 829 | tcg_gen_op5(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2); |
754 | 830 | } |
755 | 831 | |
756 | -static inline void tcg_gen_rem_i64(int ret, int arg1, int arg2) | |
832 | +static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
757 | 833 | { |
758 | - int t0; | |
834 | + TCGv t0; | |
759 | 835 | t0 = tcg_temp_new(TCG_TYPE_I64); |
760 | 836 | tcg_gen_sari_i64(t0, arg1, 63); |
761 | 837 | tcg_gen_op5(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2); |
762 | 838 | } |
763 | 839 | |
764 | -static inline void tcg_gen_divu_i64(int ret, int arg1, int arg2) | |
840 | +static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
765 | 841 | { |
766 | - int t0; | |
842 | + TCGv t0; | |
767 | 843 | t0 = tcg_temp_new(TCG_TYPE_I64); |
768 | 844 | tcg_gen_movi_i64(t0, 0); |
769 | 845 | tcg_gen_op5(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2); |
770 | 846 | } |
771 | 847 | |
772 | -static inline void tcg_gen_remu_i64(int ret, int arg1, int arg2) | |
848 | +static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2) | |
773 | 849 | { |
774 | - int t0; | |
850 | + TCGv t0; | |
775 | 851 | t0 = tcg_temp_new(TCG_TYPE_I64); |
776 | 852 | tcg_gen_movi_i64(t0, 0); |
777 | 853 | tcg_gen_op5(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2); |
... | ... | @@ -783,7 +859,7 @@ static inline void tcg_gen_remu_i64(int ret, int arg1, int arg2) |
783 | 859 | /***************************************/ |
784 | 860 | /* optional operations */ |
785 | 861 | |
786 | -static inline void tcg_gen_ext8s_i32(int ret, int arg) | |
862 | +static inline void tcg_gen_ext8s_i32(TCGv ret, TCGv arg) | |
787 | 863 | { |
788 | 864 | #ifdef TCG_TARGET_HAS_ext8s_i32 |
789 | 865 | tcg_gen_op2(INDEX_op_ext8s_i32, ret, arg); |
... | ... | @@ -793,7 +869,7 @@ static inline void tcg_gen_ext8s_i32(int ret, int arg) |
793 | 869 | #endif |
794 | 870 | } |
795 | 871 | |
796 | -static inline void tcg_gen_ext16s_i32(int ret, int arg) | |
872 | +static inline void tcg_gen_ext16s_i32(TCGv ret, TCGv arg) | |
797 | 873 | { |
798 | 874 | #ifdef TCG_TARGET_HAS_ext16s_i32 |
799 | 875 | tcg_gen_op2(INDEX_op_ext16s_i32, ret, arg); |
... | ... | @@ -804,12 +880,12 @@ static inline void tcg_gen_ext16s_i32(int ret, int arg) |
804 | 880 | } |
805 | 881 | |
806 | 882 | /* Note: we assume the two high bytes are set to zero */ |
807 | -static inline void tcg_gen_bswap16_i32(TCGArg ret, TCGArg arg) | |
883 | +static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg) | |
808 | 884 | { |
809 | 885 | #ifdef TCG_TARGET_HAS_bswap16_i32 |
810 | 886 | tcg_gen_op2(INDEX_op_bswap16_i32, ret, arg); |
811 | 887 | #else |
812 | - TCGArg t0, t1; | |
888 | + TCGv t0, t1; | |
813 | 889 | t0 = tcg_temp_new(TCG_TYPE_I32); |
814 | 890 | t1 = tcg_temp_new(TCG_TYPE_I32); |
815 | 891 | |
... | ... | @@ -820,12 +896,12 @@ static inline void tcg_gen_bswap16_i32(TCGArg ret, TCGArg arg) |
820 | 896 | #endif |
821 | 897 | } |
822 | 898 | |
823 | -static inline void tcg_gen_bswap_i32(TCGArg ret, TCGArg arg) | |
899 | +static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg) | |
824 | 900 | { |
825 | 901 | #ifdef TCG_TARGET_HAS_bswap_i32 |
826 | 902 | tcg_gen_op2(INDEX_op_bswap_i32, ret, arg); |
827 | 903 | #else |
828 | - TCGArg t0, t1; | |
904 | + TCGv t0, t1; | |
829 | 905 | t0 = tcg_temp_new(TCG_TYPE_I32); |
830 | 906 | t1 = tcg_temp_new(TCG_TYPE_I32); |
831 | 907 | |
... | ... | @@ -845,55 +921,55 @@ static inline void tcg_gen_bswap_i32(TCGArg ret, TCGArg arg) |
845 | 921 | } |
846 | 922 | |
847 | 923 | #if TCG_TARGET_REG_BITS == 32 |
848 | -static inline void tcg_gen_ext8s_i64(int ret, int arg) | |
924 | +static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg) | |
849 | 925 | { |
850 | 926 | tcg_gen_ext8s_i32(ret, arg); |
851 | - tcg_gen_sari_i32(ret + 1, ret, 31); | |
927 | + tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31); | |
852 | 928 | } |
853 | 929 | |
854 | -static inline void tcg_gen_ext16s_i64(int ret, int arg) | |
930 | +static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg) | |
855 | 931 | { |
856 | 932 | tcg_gen_ext16s_i32(ret, arg); |
857 | - tcg_gen_sari_i32(ret + 1, ret, 31); | |
933 | + tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31); | |
858 | 934 | } |
859 | 935 | |
860 | -static inline void tcg_gen_ext32s_i64(int ret, int arg) | |
936 | +static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg) | |
861 | 937 | { |
862 | 938 | tcg_gen_mov_i32(ret, arg); |
863 | - tcg_gen_sari_i32(ret + 1, ret, 31); | |
939 | + tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31); | |
864 | 940 | } |
865 | 941 | |
866 | -static inline void tcg_gen_trunc_i64_i32(int ret, int arg) | |
942 | +static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg) | |
867 | 943 | { |
868 | 944 | tcg_gen_mov_i32(ret, arg); |
869 | 945 | } |
870 | 946 | |
871 | -static inline void tcg_gen_extu_i32_i64(int ret, int arg) | |
947 | +static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg) | |
872 | 948 | { |
873 | 949 | tcg_gen_mov_i32(ret, arg); |
874 | - tcg_gen_movi_i32(ret + 1, 0); | |
950 | + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); | |
875 | 951 | } |
876 | 952 | |
877 | -static inline void tcg_gen_ext_i32_i64(int ret, int arg) | |
953 | +static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg) | |
878 | 954 | { |
879 | 955 | tcg_gen_mov_i32(ret, arg); |
880 | - tcg_gen_sari_i32(ret + 1, ret, 31); | |
956 | + tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31); | |
881 | 957 | } |
882 | 958 | |
883 | -static inline void tcg_gen_bswap_i64(int ret, int arg) | |
959 | +static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg) | |
884 | 960 | { |
885 | - int t0, t1; | |
961 | + TCGv t0, t1; | |
886 | 962 | t0 = tcg_temp_new(TCG_TYPE_I32); |
887 | 963 | t1 = tcg_temp_new(TCG_TYPE_I32); |
888 | 964 | |
889 | 965 | tcg_gen_bswap_i32(t0, arg); |
890 | - tcg_gen_bswap_i32(t1, arg + 1); | |
966 | + tcg_gen_bswap_i32(t1, TCGV_HIGH(arg)); | |
891 | 967 | tcg_gen_mov_i32(ret, t1); |
892 | - tcg_gen_mov_i32(ret + 1, t0); | |
968 | + tcg_gen_mov_i32(TCGV_HIGH(ret), t0); | |
893 | 969 | } |
894 | 970 | #else |
895 | 971 | |
896 | -static inline void tcg_gen_ext8s_i64(int ret, int arg) | |
972 | +static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg) | |
897 | 973 | { |
898 | 974 | #ifdef TCG_TARGET_HAS_ext8s_i64 |
899 | 975 | tcg_gen_op2(INDEX_op_ext8s_i64, ret, arg); |
... | ... | @@ -903,7 +979,7 @@ static inline void tcg_gen_ext8s_i64(int ret, int arg) |
903 | 979 | #endif |
904 | 980 | } |
905 | 981 | |
906 | -static inline void tcg_gen_ext16s_i64(int ret, int arg) | |
982 | +static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg) | |
907 | 983 | { |
908 | 984 | #ifdef TCG_TARGET_HAS_ext16s_i64 |
909 | 985 | tcg_gen_op2(INDEX_op_ext16s_i64, ret, arg); |
... | ... | @@ -913,7 +989,7 @@ static inline void tcg_gen_ext16s_i64(int ret, int arg) |
913 | 989 | #endif |
914 | 990 | } |
915 | 991 | |
916 | -static inline void tcg_gen_ext32s_i64(int ret, int arg) | |
992 | +static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg) | |
917 | 993 | { |
918 | 994 | #ifdef TCG_TARGET_HAS_ext32s_i64 |
919 | 995 | tcg_gen_op2(INDEX_op_ext32s_i64, ret, arg); |
... | ... | @@ -924,32 +1000,32 @@ static inline void tcg_gen_ext32s_i64(int ret, int arg) |
924 | 1000 | } |
925 | 1001 | |
926 | 1002 | /* Note: we assume the target supports move between 32 and 64 bit |
927 | - registers */ | |
928 | -static inline void tcg_gen_trunc_i64_i32(int ret, int arg) | |
1003 | + registers. This will probably break MIPS64 targets. */ | |
1004 | +static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg) | |
929 | 1005 | { |
930 | 1006 | tcg_gen_mov_i32(ret, arg); |
931 | 1007 | } |
932 | 1008 | |
933 | 1009 | /* Note: we assume the target supports move between 32 and 64 bit |
934 | 1010 | registers */ |
935 | -static inline void tcg_gen_extu_i32_i64(int ret, int arg) | |
1011 | +static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg) | |
936 | 1012 | { |
937 | 1013 | tcg_gen_andi_i64(ret, arg, 0xffffffff); |
938 | 1014 | } |
939 | 1015 | |
940 | 1016 | /* Note: we assume the target supports move between 32 and 64 bit |
941 | 1017 | registers */ |
942 | -static inline void tcg_gen_ext_i32_i64(int ret, int arg) | |
1018 | +static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg) | |
943 | 1019 | { |
944 | 1020 | tcg_gen_ext32s_i64(ret, arg); |
945 | 1021 | } |
946 | 1022 | |
947 | -static inline void tcg_gen_bswap_i64(TCGArg ret, TCGArg arg) | |
1023 | +static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg) | |
948 | 1024 | { |
949 | 1025 | #ifdef TCG_TARGET_HAS_bswap_i64 |
950 | 1026 | tcg_gen_op2(INDEX_op_bswap_i64, ret, arg); |
951 | 1027 | #else |
952 | - TCGArg t0, t1; | |
1028 | + TCGv t0, t1; | |
953 | 1029 | t0 = tcg_temp_new(TCG_TYPE_I32); |
954 | 1030 | t1 = tcg_temp_new(TCG_TYPE_I32); |
955 | 1031 | |
... | ... | @@ -987,9 +1063,9 @@ static inline void tcg_gen_bswap_i64(TCGArg ret, TCGArg arg) |
987 | 1063 | #endif |
988 | 1064 | |
989 | 1065 | /***************************************/ |
990 | -static inline void tcg_gen_macro_2(int ret0, int ret1, int macro_id) | |
1066 | +static inline void tcg_gen_macro_2(TCGv ret0, TCGv ret1, int macro_id) | |
991 | 1067 | { |
992 | - tcg_gen_op3(INDEX_op_macro_2, ret0, ret1, macro_id); | |
1068 | + tcg_gen_op3i(INDEX_op_macro_2, ret0, ret1, macro_id); | |
993 | 1069 | } |
994 | 1070 | |
995 | 1071 | /***************************************/ |
... | ... | @@ -1001,175 +1077,177 @@ static inline void tcg_gen_macro_2(int ret0, int ret1, int macro_id) |
1001 | 1077 | |
1002 | 1078 | static inline void tcg_gen_exit_tb(tcg_target_long val) |
1003 | 1079 | { |
1004 | - tcg_gen_op1(INDEX_op_exit_tb, val); | |
1080 | + tcg_gen_op1i(INDEX_op_exit_tb, val); | |
1005 | 1081 | } |
1006 | 1082 | |
1007 | 1083 | static inline void tcg_gen_goto_tb(int idx) |
1008 | 1084 | { |
1009 | - tcg_gen_op1(INDEX_op_goto_tb, idx); | |
1085 | + tcg_gen_op1i(INDEX_op_goto_tb, idx); | |
1010 | 1086 | } |
1011 | 1087 | |
1012 | 1088 | #if TCG_TARGET_REG_BITS == 32 |
1013 | -static inline void tcg_gen_qemu_ld8u(int ret, int addr, int mem_index) | |
1089 | +static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) | |
1014 | 1090 | { |
1015 | 1091 | #if TARGET_LONG_BITS == 32 |
1016 | - tcg_gen_op3(INDEX_op_qemu_ld8u, ret, addr, mem_index); | |
1092 | + tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index); | |
1017 | 1093 | #else |
1018 | - tcg_gen_op4(INDEX_op_qemu_ld8u, ret, addr, addr + 1, mem_index); | |
1019 | - tcg_gen_movi_i32(ret + 1, 0); | |
1094 | + tcg_gen_op4i(INDEX_op_qemu_ld8u, ret, addr, TCGV_HIGH(addr), mem_index); | |
1095 | + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); | |
1020 | 1096 | #endif |
1021 | 1097 | } |
1022 | 1098 | |
1023 | -static inline void tcg_gen_qemu_ld8s(int ret, int addr, int mem_index) | |
1099 | +static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index) | |
1024 | 1100 | { |
1025 | 1101 | #if TARGET_LONG_BITS == 32 |
1026 | - tcg_gen_op3(INDEX_op_qemu_ld8s, ret, addr, mem_index); | |
1102 | + tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index); | |
1027 | 1103 | #else |
1028 | - tcg_gen_op4(INDEX_op_qemu_ld8s, ret, addr, addr + 1, mem_index); | |
1029 | - tcg_gen_ext8s_i32(ret + 1, ret); | |
1104 | + tcg_gen_op4i(INDEX_op_qemu_ld8s, ret, addr, TCGV_HIGH(addr), mem_index); | |
1105 | + tcg_gen_ext8s_i32(TCGV_HIGH(ret), ret); | |
1030 | 1106 | #endif |
1031 | 1107 | } |
1032 | 1108 | |
1033 | -static inline void tcg_gen_qemu_ld16u(int ret, int addr, int mem_index) | |
1109 | +static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index) | |
1034 | 1110 | { |
1035 | 1111 | #if TARGET_LONG_BITS == 32 |
1036 | - tcg_gen_op3(INDEX_op_qemu_ld16u, ret, addr, mem_index); | |
1112 | + tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index); | |
1037 | 1113 | #else |
1038 | - tcg_gen_op4(INDEX_op_qemu_ld16u, ret, addr, addr + 1, mem_index); | |
1039 | - tcg_gen_movi_i32(ret + 1, 0); | |
1114 | + tcg_gen_op4i(INDEX_op_qemu_ld16u, ret, addr, TCGV_HIGH(addr), mem_index); | |
1115 | + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); | |
1040 | 1116 | #endif |
1041 | 1117 | } |
1042 | 1118 | |
1043 | -static inline void tcg_gen_qemu_ld16s(int ret, int addr, int mem_index) | |
1119 | +static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index) | |
1044 | 1120 | { |
1045 | 1121 | #if TARGET_LONG_BITS == 32 |
1046 | - tcg_gen_op3(INDEX_op_qemu_ld16s, ret, addr, mem_index); | |
1122 | + tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index); | |
1047 | 1123 | #else |
1048 | - tcg_gen_op4(INDEX_op_qemu_ld16s, ret, addr, addr + 1, mem_index); | |
1049 | - tcg_gen_ext16s_i32(ret + 1, ret); | |
1124 | + tcg_gen_op4i(INDEX_op_qemu_ld16s, ret, addr, TCGV_HIGH(addr), mem_index); | |
1125 | + tcg_gen_ext16s_i32(TCGV_HIGH(ret), ret); | |
1050 | 1126 | #endif |
1051 | 1127 | } |
1052 | 1128 | |
1053 | -static inline void tcg_gen_qemu_ld32u(int ret, int addr, int mem_index) | |
1129 | +static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index) | |
1054 | 1130 | { |
1055 | 1131 | #if TARGET_LONG_BITS == 32 |
1056 | - tcg_gen_op3(INDEX_op_qemu_ld32u, ret, addr, mem_index); | |
1132 | + tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index); | |
1057 | 1133 | #else |
1058 | - tcg_gen_op4(INDEX_op_qemu_ld32u, ret, addr, addr + 1, mem_index); | |
1059 | - tcg_gen_movi_i32(ret + 1, 0); | |
1134 | + tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index); | |
1135 | + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); | |
1060 | 1136 | #endif |
1061 | 1137 | } |
1062 | 1138 | |
1063 | -static inline void tcg_gen_qemu_ld32s(int ret, int addr, int mem_index) | |
1139 | +static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index) | |
1064 | 1140 | { |
1065 | 1141 | #if TARGET_LONG_BITS == 32 |
1066 | - tcg_gen_op3(INDEX_op_qemu_ld32u, ret, addr, mem_index); | |
1142 | + tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index); | |
1067 | 1143 | #else |
1068 | - tcg_gen_op4(INDEX_op_qemu_ld32u, ret, addr, addr + 1, mem_index); | |
1069 | - tcg_gen_sari_i32(ret + 1, ret, 31); | |
1144 | + tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index); | |
1145 | + tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31); | |
1070 | 1146 | #endif |
1071 | 1147 | } |
1072 | 1148 | |
1073 | -static inline void tcg_gen_qemu_ld64(int ret, int addr, int mem_index) | |
1149 | +static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index) | |
1074 | 1150 | { |
1075 | 1151 | #if TARGET_LONG_BITS == 32 |
1076 | - tcg_gen_op4(INDEX_op_qemu_ld64, ret, ret + 1, addr, mem_index); | |
1152 | + tcg_gen_op4i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), addr, mem_index); | |
1077 | 1153 | #else |
1078 | - tcg_gen_op5(INDEX_op_qemu_ld64, ret, ret + 1, addr, addr + 1, mem_index); | |
1154 | + tcg_gen_op5i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), | |
1155 | + addr, TCGV_HIGH(addr), mem_index); | |
1079 | 1156 | #endif |
1080 | 1157 | } |
1081 | 1158 | |
1082 | -static inline void tcg_gen_qemu_st8(int arg, int addr, int mem_index) | |
1159 | +static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index) | |
1083 | 1160 | { |
1084 | 1161 | #if TARGET_LONG_BITS == 32 |
1085 | - tcg_gen_op3(INDEX_op_qemu_st8, arg, addr, mem_index); | |
1162 | + tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index); | |
1086 | 1163 | #else |
1087 | - tcg_gen_op4(INDEX_op_qemu_st8, arg, addr, addr + 1, mem_index); | |
1164 | + tcg_gen_op4i(INDEX_op_qemu_st8, arg, addr, TCGV_HIGH(addr), mem_index); | |
1088 | 1165 | #endif |
1089 | 1166 | } |
1090 | 1167 | |
1091 | -static inline void tcg_gen_qemu_st16(int arg, int addr, int mem_index) | |
1168 | +static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index) | |
1092 | 1169 | { |
1093 | 1170 | #if TARGET_LONG_BITS == 32 |
1094 | - tcg_gen_op3(INDEX_op_qemu_st16, arg, addr, mem_index); | |
1171 | + tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index); | |
1095 | 1172 | #else |
1096 | - tcg_gen_op4(INDEX_op_qemu_st16, arg, addr, addr + 1, mem_index); | |
1173 | + tcg_gen_op4i(INDEX_op_qemu_st16, arg, addr, TCGV_HIGH(addr), mem_index); | |
1097 | 1174 | #endif |
1098 | 1175 | } |
1099 | 1176 | |
1100 | -static inline void tcg_gen_qemu_st32(int arg, int addr, int mem_index) | |
1177 | +static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index) | |
1101 | 1178 | { |
1102 | 1179 | #if TARGET_LONG_BITS == 32 |
1103 | - tcg_gen_op3(INDEX_op_qemu_st32, arg, addr, mem_index); | |
1180 | + tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index); | |
1104 | 1181 | #else |
1105 | - tcg_gen_op4(INDEX_op_qemu_st32, arg, addr, addr + 1, mem_index); | |
1182 | + tcg_gen_op4i(INDEX_op_qemu_st32, arg, addr, TCGV_HIGH(addr), mem_index); | |
1106 | 1183 | #endif |
1107 | 1184 | } |
1108 | 1185 | |
1109 | -static inline void tcg_gen_qemu_st64(int arg, int addr, int mem_index) | |
1186 | +static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index) | |
1110 | 1187 | { |
1111 | 1188 | #if TARGET_LONG_BITS == 32 |
1112 | - tcg_gen_op4(INDEX_op_qemu_st64, arg, arg + 1, addr, mem_index); | |
1189 | + tcg_gen_op4i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), addr, mem_index); | |
1113 | 1190 | #else |
1114 | - tcg_gen_op5(INDEX_op_qemu_st64, arg, arg + 1, addr, addr + 1, mem_index); | |
1191 | + tcg_gen_op5i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), | |
1192 | + addr, TCGV_HIGH(addr), mem_index); | |
1115 | 1193 | #endif |
1116 | 1194 | } |
1117 | 1195 | |
1118 | 1196 | #else /* TCG_TARGET_REG_BITS == 32 */ |
1119 | 1197 | |
1120 | -static inline void tcg_gen_qemu_ld8u(int ret, int addr, int mem_index) | |
1198 | +static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) | |
1121 | 1199 | { |
1122 | - tcg_gen_op3(INDEX_op_qemu_ld8u, ret, addr, mem_index); | |
1200 | + tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index); | |
1123 | 1201 | } |
1124 | 1202 | |
1125 | -static inline void tcg_gen_qemu_ld8s(int ret, int addr, int mem_index) | |
1203 | +static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index) | |
1126 | 1204 | { |
1127 | - tcg_gen_op3(INDEX_op_qemu_ld8s, ret, addr, mem_index); | |
1205 | + tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index); | |
1128 | 1206 | } |
1129 | 1207 | |
1130 | -static inline void tcg_gen_qemu_ld16u(int ret, int addr, int mem_index) | |
1208 | +static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index) | |
1131 | 1209 | { |
1132 | - tcg_gen_op3(INDEX_op_qemu_ld16u, ret, addr, mem_index); | |
1210 | + tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index); | |
1133 | 1211 | } |
1134 | 1212 | |
1135 | -static inline void tcg_gen_qemu_ld16s(int ret, int addr, int mem_index) | |
1213 | +static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index) | |
1136 | 1214 | { |
1137 | - tcg_gen_op3(INDEX_op_qemu_ld16s, ret, addr, mem_index); | |
1215 | + tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index); | |
1138 | 1216 | } |
1139 | 1217 | |
1140 | -static inline void tcg_gen_qemu_ld32u(int ret, int addr, int mem_index) | |
1218 | +static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index) | |
1141 | 1219 | { |
1142 | - tcg_gen_op3(INDEX_op_qemu_ld32u, ret, addr, mem_index); | |
1220 | + tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index); | |
1143 | 1221 | } |
1144 | 1222 | |
1145 | -static inline void tcg_gen_qemu_ld32s(int ret, int addr, int mem_index) | |
1223 | +static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index) | |
1146 | 1224 | { |
1147 | - tcg_gen_op3(INDEX_op_qemu_ld32s, ret, addr, mem_index); | |
1225 | + tcg_gen_op3i(INDEX_op_qemu_ld32s, ret, addr, mem_index); | |
1148 | 1226 | } |
1149 | 1227 | |
1150 | -static inline void tcg_gen_qemu_ld64(int ret, int addr, int mem_index) | |
1228 | +static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index) | |
1151 | 1229 | { |
1152 | - tcg_gen_op3(INDEX_op_qemu_ld64, ret, addr, mem_index); | |
1230 | + tcg_gen_op3i(INDEX_op_qemu_ld64, ret, addr, mem_index); | |
1153 | 1231 | } |
1154 | 1232 | |
1155 | -static inline void tcg_gen_qemu_st8(int arg, int addr, int mem_index) | |
1233 | +static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index) | |
1156 | 1234 | { |
1157 | - tcg_gen_op3(INDEX_op_qemu_st8, arg, addr, mem_index); | |
1235 | + tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index); | |
1158 | 1236 | } |
1159 | 1237 | |
1160 | -static inline void tcg_gen_qemu_st16(int arg, int addr, int mem_index) | |
1238 | +static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index) | |
1161 | 1239 | { |
1162 | - tcg_gen_op3(INDEX_op_qemu_st16, arg, addr, mem_index); | |
1240 | + tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index); | |
1163 | 1241 | } |
1164 | 1242 | |
1165 | -static inline void tcg_gen_qemu_st32(int arg, int addr, int mem_index) | |
1243 | +static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index) | |
1166 | 1244 | { |
1167 | - tcg_gen_op3(INDEX_op_qemu_st32, arg, addr, mem_index); | |
1245 | + tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index); | |
1168 | 1246 | } |
1169 | 1247 | |
1170 | -static inline void tcg_gen_qemu_st64(int arg, int addr, int mem_index) | |
1248 | +static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index) | |
1171 | 1249 | { |
1172 | - tcg_gen_op3(INDEX_op_qemu_st64, arg, addr, mem_index); | |
1250 | + tcg_gen_op3i(INDEX_op_qemu_st64, arg, addr, mem_index); | |
1173 | 1251 | } |
1174 | 1252 | |
1175 | 1253 | #endif /* TCG_TARGET_REG_BITS != 32 */ | ... | ... |
tcg/tcg.c
... | ... | @@ -299,7 +299,7 @@ static inline void tcg_temp_alloc(TCGContext *s, int n) |
299 | 299 | tcg_abort(); |
300 | 300 | } |
301 | 301 | |
302 | -int tcg_global_reg_new(TCGType type, int reg, const char *name) | |
302 | +TCGv tcg_global_reg_new(TCGType type, int reg, const char *name) | |
303 | 303 | { |
304 | 304 | TCGContext *s = &tcg_ctx; |
305 | 305 | TCGTemp *ts; |
... | ... | @@ -322,11 +322,11 @@ int tcg_global_reg_new(TCGType type, int reg, const char *name) |
322 | 322 | ts->name = name; |
323 | 323 | s->nb_globals++; |
324 | 324 | tcg_regset_set_reg(s->reserved_regs, reg); |
325 | - return idx; | |
325 | + return MAKE_TCGV(idx); | |
326 | 326 | } |
327 | 327 | |
328 | -int tcg_global_mem_new(TCGType type, int reg, tcg_target_long offset, | |
329 | - const char *name) | |
328 | +TCGv tcg_global_mem_new(TCGType type, int reg, tcg_target_long offset, | |
329 | + const char *name) | |
330 | 330 | { |
331 | 331 | TCGContext *s = &tcg_ctx; |
332 | 332 | TCGTemp *ts; |
... | ... | @@ -385,10 +385,10 @@ int tcg_global_mem_new(TCGType type, int reg, tcg_target_long offset, |
385 | 385 | ts->name = name; |
386 | 386 | s->nb_globals++; |
387 | 387 | } |
388 | - return idx; | |
388 | + return MAKE_TCGV(idx); | |
389 | 389 | } |
390 | 390 | |
391 | -int tcg_temp_new(TCGType type) | |
391 | +TCGv tcg_temp_new(TCGType type) | |
392 | 392 | { |
393 | 393 | TCGContext *s = &tcg_ctx; |
394 | 394 | TCGTemp *ts; |
... | ... | @@ -423,10 +423,10 @@ int tcg_temp_new(TCGType type) |
423 | 423 | ts->name = NULL; |
424 | 424 | s->nb_temps++; |
425 | 425 | } |
426 | - return idx; | |
426 | + return MAKE_TCGV(idx); | |
427 | 427 | } |
428 | 428 | |
429 | -int tcg_const_i32(int32_t val) | |
429 | +TCGv tcg_const_i32(int32_t val) | |
430 | 430 | { |
431 | 431 | TCGContext *s = &tcg_ctx; |
432 | 432 | TCGTemp *ts; |
... | ... | @@ -440,10 +440,10 @@ int tcg_const_i32(int32_t val) |
440 | 440 | ts->name = NULL; |
441 | 441 | ts->val = val; |
442 | 442 | s->nb_temps++; |
443 | - return idx; | |
443 | + return MAKE_TCGV(idx); | |
444 | 444 | } |
445 | 445 | |
446 | -int tcg_const_i64(int64_t val) | |
446 | +TCGv tcg_const_i64(int64_t val) | |
447 | 447 | { |
448 | 448 | TCGContext *s = &tcg_ctx; |
449 | 449 | TCGTemp *ts; |
... | ... | @@ -474,7 +474,7 @@ int tcg_const_i64(int64_t val) |
474 | 474 | ts->val = val; |
475 | 475 | s->nb_temps++; |
476 | 476 | #endif |
477 | - return idx; | |
477 | + return MAKE_TCGV(idx); | |
478 | 478 | } |
479 | 479 | |
480 | 480 | void tcg_register_helper(void *func, const char *name) |
... | ... | @@ -507,26 +507,26 @@ const char *tcg_helper_get_name(TCGContext *s, void *func) |
507 | 507 | return NULL; |
508 | 508 | } |
509 | 509 | |
510 | -static inline TCGType tcg_get_base_type(TCGContext *s, TCGArg arg) | |
510 | +static inline TCGType tcg_get_base_type(TCGContext *s, TCGv arg) | |
511 | 511 | { |
512 | - return s->temps[arg].base_type; | |
512 | + return s->temps[GET_TCGV(arg)].base_type; | |
513 | 513 | } |
514 | 514 | |
515 | -static void tcg_gen_call_internal(TCGContext *s, TCGArg func, | |
515 | +static void tcg_gen_call_internal(TCGContext *s, TCGv func, | |
516 | 516 | unsigned int flags, |
517 | - unsigned int nb_rets, const TCGArg *rets, | |
518 | - unsigned int nb_params, const TCGArg *params) | |
517 | + unsigned int nb_rets, const TCGv *rets, | |
518 | + unsigned int nb_params, const TCGv *params) | |
519 | 519 | { |
520 | 520 | int i; |
521 | 521 | *gen_opc_ptr++ = INDEX_op_call; |
522 | 522 | *gen_opparam_ptr++ = (nb_rets << 16) | (nb_params + 1); |
523 | 523 | for(i = 0; i < nb_rets; i++) { |
524 | - *gen_opparam_ptr++ = rets[i]; | |
524 | + *gen_opparam_ptr++ = GET_TCGV(rets[i]); | |
525 | 525 | } |
526 | 526 | for(i = 0; i < nb_params; i++) { |
527 | - *gen_opparam_ptr++ = params[i]; | |
527 | + *gen_opparam_ptr++ = GET_TCGV(params[i]); | |
528 | 528 | } |
529 | - *gen_opparam_ptr++ = func; | |
529 | + *gen_opparam_ptr++ = GET_TCGV(func); | |
530 | 530 | |
531 | 531 | *gen_opparam_ptr++ = flags; |
532 | 532 | /* total parameters, needed to go backward in the instruction stream */ |
... | ... | @@ -536,11 +536,11 @@ static void tcg_gen_call_internal(TCGContext *s, TCGArg func, |
536 | 536 | |
537 | 537 | #if TCG_TARGET_REG_BITS < 64 |
538 | 538 | /* Note: we convert the 64 bit args to 32 bit */ |
539 | -void tcg_gen_call(TCGContext *s, TCGArg func, unsigned int flags, | |
540 | - unsigned int nb_rets, const TCGArg *rets, | |
541 | - unsigned int nb_params, const TCGArg *args1) | |
539 | +void tcg_gen_call(TCGContext *s, TCGv func, unsigned int flags, | |
540 | + unsigned int nb_rets, const TCGv *rets, | |
541 | + unsigned int nb_params, const TCGv *args1) | |
542 | 542 | { |
543 | - TCGArg ret, *args2, rets_2[2], arg; | |
543 | + TCGv ret, *args2, rets_2[2], arg; | |
544 | 544 | int j, i, call_type; |
545 | 545 | |
546 | 546 | if (nb_rets == 1) { |
... | ... | @@ -548,11 +548,11 @@ void tcg_gen_call(TCGContext *s, TCGArg func, unsigned int flags, |
548 | 548 | if (tcg_get_base_type(s, ret) == TCG_TYPE_I64) { |
549 | 549 | nb_rets = 2; |
550 | 550 | rets_2[0] = ret; |
551 | - rets_2[1] = ret + 1; | |
551 | + rets_2[1] = TCGV_HIGH(ret); | |
552 | 552 | rets = rets_2; |
553 | 553 | } |
554 | 554 | } |
555 | - args2 = alloca((nb_params * 2) * sizeof(TCGArg)); | |
555 | + args2 = alloca((nb_params * 2) * sizeof(TCGv)); | |
556 | 556 | j = 0; |
557 | 557 | call_type = (flags & TCG_CALL_TYPE_MASK); |
558 | 558 | for(i = 0; i < nb_params; i++) { |
... | ... | @@ -566,14 +566,14 @@ void tcg_gen_call(TCGContext *s, TCGArg func, unsigned int flags, |
566 | 566 | flags = (flags & ~TCG_CALL_TYPE_MASK) | call_type; |
567 | 567 | } |
568 | 568 | args2[j++] = arg; |
569 | - args2[j++] = arg + 1; | |
569 | + args2[j++] = TCGV_HIGH(arg); | |
570 | 570 | #else |
571 | 571 | #ifdef TCG_TARGET_WORDS_BIGENDIAN |
572 | - args2[j++] = arg + 1; | |
572 | + args2[j++] = TCGV_HOGH(arg); | |
573 | 573 | args2[j++] = arg; |
574 | 574 | #else |
575 | 575 | args2[j++] = arg; |
576 | - args2[j++] = arg + 1; | |
576 | + args2[j++] = TCGV_HIGH(arg); | |
577 | 577 | #endif |
578 | 578 | #endif |
579 | 579 | } else { |
... | ... | @@ -584,16 +584,17 @@ void tcg_gen_call(TCGContext *s, TCGArg func, unsigned int flags, |
584 | 584 | nb_rets, rets, j, args2); |
585 | 585 | } |
586 | 586 | #else |
587 | -void tcg_gen_call(TCGContext *s, TCGArg func, unsigned int flags, | |
588 | - unsigned int nb_rets, const TCGArg *rets, | |
589 | - unsigned int nb_params, const TCGArg *args1) | |
587 | +void tcg_gen_call(TCGContext *s, TCGv func, unsigned int flags, | |
588 | + unsigned int nb_rets, const TCGv *rets, | |
589 | + unsigned int nb_params, const TCGv *args1) | |
590 | 590 | { |
591 | 591 | tcg_gen_call_internal(s, func, flags, |
592 | 592 | nb_rets, rets, nb_params, args1); |
593 | 593 | } |
594 | 594 | #endif |
595 | 595 | |
596 | -void tcg_gen_shifti_i64(TCGArg ret, TCGArg arg1, | |
596 | +#if TCG_TARGET_REG_BITS == 32 | |
597 | +void tcg_gen_shifti_i64(TCGv ret, TCGv arg1, | |
597 | 598 | int c, int right, int arith) |
598 | 599 | { |
599 | 600 | if (c == 0) |
... | ... | @@ -602,40 +603,41 @@ void tcg_gen_shifti_i64(TCGArg ret, TCGArg arg1, |
602 | 603 | c -= 32; |
603 | 604 | if (right) { |
604 | 605 | if (arith) { |
605 | - tcg_gen_sari_i32(ret, arg1 + 1, c); | |
606 | - tcg_gen_sari_i32(ret + 1, arg1 + 1, 31); | |
606 | + tcg_gen_sari_i32(ret, TCGV_HIGH(arg1), c); | |
607 | + tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), 31); | |
607 | 608 | } else { |
608 | - tcg_gen_shri_i32(ret, arg1 + 1, c); | |
609 | - tcg_gen_movi_i32(ret + 1, 0); | |
609 | + tcg_gen_shri_i32(ret, TCGV_HIGH(arg1), c); | |
610 | + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); | |
610 | 611 | } |
611 | 612 | } else { |
612 | - tcg_gen_shli_i32(ret + 1, arg1, c); | |
613 | + tcg_gen_shli_i32(TCGV_HIGH(ret), arg1, c); | |
613 | 614 | tcg_gen_movi_i32(ret, 0); |
614 | 615 | } |
615 | 616 | } else { |
616 | - int t0, t1; | |
617 | + TCGv t0, t1; | |
617 | 618 | |
618 | 619 | t0 = tcg_temp_new(TCG_TYPE_I32); |
619 | 620 | t1 = tcg_temp_new(TCG_TYPE_I32); |
620 | 621 | if (right) { |
621 | - tcg_gen_shli_i32(t0, arg1 + 1, 32 - c); | |
622 | + tcg_gen_shli_i32(t0, TCGV_HIGH(arg1), 32 - c); | |
622 | 623 | if (arith) |
623 | - tcg_gen_sari_i32(t1, arg1 + 1, c); | |
624 | + tcg_gen_sari_i32(t1, TCGV_HIGH(arg1), c); | |
624 | 625 | else |
625 | - tcg_gen_shri_i32(t1, arg1 + 1, c); | |
626 | + tcg_gen_shri_i32(t1, TCGV_HIGH(arg1), c); | |
626 | 627 | tcg_gen_shri_i32(ret, arg1, c); |
627 | 628 | tcg_gen_or_i32(ret, ret, t0); |
628 | - tcg_gen_mov_i32(ret + 1, t1); | |
629 | + tcg_gen_mov_i32(TCGV_HIGH(ret), t1); | |
629 | 630 | } else { |
630 | 631 | tcg_gen_shri_i32(t0, arg1, 32 - c); |
631 | 632 | /* Note: ret can be the same as arg1, so we use t1 */ |
632 | 633 | tcg_gen_shli_i32(t1, arg1, c); |
633 | - tcg_gen_shli_i32(ret + 1, arg1 + 1, c); | |
634 | - tcg_gen_or_i32(ret + 1, ret + 1, t0); | |
634 | + tcg_gen_shli_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), c); | |
635 | + tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), t0); | |
635 | 636 | tcg_gen_mov_i32(ret, t1); |
636 | 637 | } |
637 | 638 | } |
638 | 639 | } |
640 | +#endif | |
639 | 641 | |
640 | 642 | void tcg_reg_alloc_start(TCGContext *s) |
641 | 643 | { |
... | ... | @@ -654,22 +656,29 @@ void tcg_reg_alloc_start(TCGContext *s) |
654 | 656 | } |
655 | 657 | } |
656 | 658 | |
657 | -char *tcg_get_arg_str(TCGContext *s, char *buf, int buf_size, TCGArg arg) | |
659 | +static char *tcg_get_arg_str_idx(TCGContext *s, char *buf, int buf_size, | |
660 | + int idx) | |
658 | 661 | { |
659 | 662 | TCGTemp *ts; |
660 | - if (arg < s->nb_globals) { | |
661 | - pstrcpy(buf, buf_size, s->temps[arg].name); | |
663 | + | |
664 | + ts = &s->temps[idx]; | |
665 | + if (idx < s->nb_globals) { | |
666 | + pstrcpy(buf, buf_size, ts->name); | |
662 | 667 | } else { |
663 | - ts = &s->temps[arg]; | |
664 | 668 | if (ts->val_type == TEMP_VAL_CONST) { |
665 | 669 | snprintf(buf, buf_size, "$0x%" TCG_PRIlx , ts->val); |
666 | 670 | } else { |
667 | - snprintf(buf, buf_size, "tmp%d", (int)arg - s->nb_globals); | |
671 | + snprintf(buf, buf_size, "tmp%d", idx - s->nb_globals); | |
668 | 672 | } |
669 | 673 | } |
670 | 674 | return buf; |
671 | 675 | } |
672 | 676 | |
677 | +char *tcg_get_arg_str(TCGContext *s, char *buf, int buf_size, TCGv arg) | |
678 | +{ | |
679 | + return tcg_get_arg_str_idx(s, buf, buf_size, GET_TCGV(arg)); | |
680 | +} | |
681 | + | |
673 | 682 | void tcg_dump_ops(TCGContext *s, FILE *outfile) |
674 | 683 | { |
675 | 684 | const uint16_t *opc_ptr; |
... | ... | @@ -707,13 +716,15 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile) |
707 | 716 | for(i = 0; i < nb_oargs; i++) { |
708 | 717 | if (k != 0) |
709 | 718 | fprintf(outfile, ","); |
710 | - fprintf(outfile, "%s", tcg_get_arg_str(s, buf, sizeof(buf), args[k++])); | |
719 | + fprintf(outfile, "%s", | |
720 | + tcg_get_arg_str_idx(s, buf, sizeof(buf), args[k++])); | |
711 | 721 | } |
712 | 722 | for(i = 0; i < nb_iargs; i++) { |
713 | 723 | if (k != 0) |
714 | 724 | fprintf(outfile, ","); |
715 | 725 | /* XXX: dump helper name for call */ |
716 | - fprintf(outfile, "%s", tcg_get_arg_str(s, buf, sizeof(buf), args[k++])); | |
726 | + fprintf(outfile, "%s", | |
727 | + tcg_get_arg_str_idx(s, buf, sizeof(buf), args[k++])); | |
717 | 728 | } |
718 | 729 | for(i = 0; i < nb_cargs; i++) { |
719 | 730 | if (k != 0) |
... | ... | @@ -1082,7 +1093,7 @@ static void dump_regs(TCGContext *s) |
1082 | 1093 | |
1083 | 1094 | for(i = 0; i < s->nb_temps; i++) { |
1084 | 1095 | ts = &s->temps[i]; |
1085 | - printf(" %10s: ", tcg_get_arg_str(s, buf, sizeof(buf), i)); | |
1096 | + printf(" %10s: ", tcg_get_arg_str_idx(s, buf, sizeof(buf), i)); | |
1086 | 1097 | switch(ts->val_type) { |
1087 | 1098 | case TEMP_VAL_REG: |
1088 | 1099 | printf("%s", tcg_target_reg_names[ts->reg]); |
... | ... | @@ -1107,7 +1118,7 @@ static void dump_regs(TCGContext *s) |
1107 | 1118 | if (s->reg_to_temp[i] >= 0) { |
1108 | 1119 | printf("%s: %s\n", |
1109 | 1120 | tcg_target_reg_names[i], |
1110 | - tcg_get_arg_str(s, buf, sizeof(buf), s->reg_to_temp[i])); | |
1121 | + tcg_get_arg_str_idx(s, buf, sizeof(buf), s->reg_to_temp[i])); | |
1111 | 1122 | } |
1112 | 1123 | } |
1113 | 1124 | } |
... | ... | @@ -1138,7 +1149,7 @@ static void check_regs(TCGContext *s) |
1138 | 1149 | !ts->fixed_reg && |
1139 | 1150 | s->reg_to_temp[ts->reg] != k) { |
1140 | 1151 | printf("Inconsistency for temp %s:\n", |
1141 | - tcg_get_arg_str(s, buf, sizeof(buf), k)); | |
1152 | + tcg_get_arg_str_idx(s, buf, sizeof(buf), k)); | |
1142 | 1153 | printf("reg state:\n"); |
1143 | 1154 | dump_regs(s); |
1144 | 1155 | tcg_abort(); | ... | ... |
tcg/tcg.h
... | ... | @@ -103,6 +103,41 @@ typedef int TCGType; |
103 | 103 | |
104 | 104 | typedef tcg_target_ulong TCGArg; |
105 | 105 | |
106 | +/* Define a type and accessor macros for varables. Using a struct is | |
107 | + nice because it gives some level of type safely. Ideally the compiler | |
108 | + be able to see through all this. However in practice this is not true, | |
109 | + expecially on targets with braindamaged ABIs (e.g. i386). | |
110 | + We use plain int by default to avoid this runtime overhead. | |
111 | + Users of tcg_gen_* don't need to know about any of this, and should | |
112 | + treat TCGv as an opaque type. */ | |
113 | + | |
114 | +//#define DEBUG_TCGV 1 | |
115 | + | |
116 | +#ifdef DEBUG_TCGV | |
117 | + | |
118 | +typedef struct | |
119 | +{ | |
120 | + int n; | |
121 | +} TCGv; | |
122 | + | |
123 | +#define MAKE_TCGV(i) __extension__ \ | |
124 | + ({ TCGv make_tcgv_tmp = {i}; make_tcgv_tmp;}) | |
125 | +#define GET_TCGV(t) ((t).n) | |
126 | +#if TCG_TARGET_REG_BITS == 32 | |
127 | +#define TCGV_HIGH(t) MAKE_TCGV(GET_TCGV(t) + 1) | |
128 | +#endif | |
129 | + | |
130 | +#else /* !DEBUG_TCGV */ | |
131 | + | |
132 | +typedef int TCGv; | |
133 | +#define MAKE_TCGV(x) (x) | |
134 | +#define GET_TCGV(t) (t) | |
135 | +#if TCG_TARGET_REG_BITS == 32 | |
136 | +#define TCGV_HIGH(t) ((t) + 1) | |
137 | +#endif | |
138 | + | |
139 | +#endif /* DEBUG_TCGV */ | |
140 | + | |
106 | 141 | /* call flags */ |
107 | 142 | #define TCG_CALL_TYPE_MASK 0x000f |
108 | 143 | #define TCG_CALL_TYPE_STD 0x0000 /* standard C call */ |
... | ... | @@ -228,11 +263,11 @@ int dyngen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, |
228 | 263 | void tcg_set_frame(TCGContext *s, int reg, |
229 | 264 | tcg_target_long start, tcg_target_long size); |
230 | 265 | void tcg_set_macro_func(TCGContext *s, TCGMacroFunc *func); |
231 | -int tcg_global_reg_new(TCGType type, int reg, const char *name); | |
232 | -int tcg_global_mem_new(TCGType type, int reg, tcg_target_long offset, | |
233 | - const char *name); | |
234 | -int tcg_temp_new(TCGType type); | |
235 | -char *tcg_get_arg_str(TCGContext *s, char *buf, int buf_size, TCGArg arg); | |
266 | +TCGv tcg_global_reg_new(TCGType type, int reg, const char *name); | |
267 | +TCGv tcg_global_mem_new(TCGType type, int reg, tcg_target_long offset, | |
268 | + const char *name); | |
269 | +TCGv tcg_temp_new(TCGType type); | |
270 | +char *tcg_get_arg_str(TCGContext *s, char *buf, int buf_size, TCGv arg); | |
236 | 271 | |
237 | 272 | #define TCG_CT_ALIAS 0x80 |
238 | 273 | #define TCG_CT_IALIAS 0x40 |
... | ... | @@ -278,10 +313,10 @@ do {\ |
278 | 313 | |
279 | 314 | void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs); |
280 | 315 | |
281 | -void tcg_gen_call(TCGContext *s, TCGArg func, unsigned int flags, | |
282 | - unsigned int nb_rets, const TCGArg *rets, | |
283 | - unsigned int nb_params, const TCGArg *args1); | |
284 | -void tcg_gen_shifti_i64(TCGArg ret, TCGArg arg1, | |
316 | +void tcg_gen_call(TCGContext *s, TCGv func, unsigned int flags, | |
317 | + unsigned int nb_rets, const TCGv *rets, | |
318 | + unsigned int nb_params, const TCGv *args1); | |
319 | +void tcg_gen_shifti_i64(TCGv ret, TCGv arg1, | |
285 | 320 | int c, int right, int arith); |
286 | 321 | |
287 | 322 | /* only used for debugging purposes */ |
... | ... | @@ -291,8 +326,8 @@ const char *tcg_helper_get_name(TCGContext *s, void *func); |
291 | 326 | void tcg_dump_ops(TCGContext *s, FILE *outfile); |
292 | 327 | |
293 | 328 | void dump_ops(const uint16_t *opc_buf, const TCGArg *opparam_buf); |
294 | -int tcg_const_i32(int32_t val); | |
295 | -int tcg_const_i64(int64_t val); | |
329 | +TCGv tcg_const_i32(int32_t val); | |
330 | +TCGv tcg_const_i64(int64_t val); | |
296 | 331 | |
297 | 332 | #if TCG_TARGET_REG_BITS == 32 |
298 | 333 | #define tcg_const_ptr tcg_const_i32 | ... | ... |