]> git.proxmox.com Git - mirror_qemu.git/blame - tcg/tcg-op.h
Skip register moves when the target and the source are the same
[mirror_qemu.git] / tcg / tcg-op.h
CommitLineData
c896fe29
FB
1/*
2 * Tiny Code Generator for QEMU
3 *
4 * Copyright (c) 2008 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#include "tcg.h"
25
cf2be984 26#ifndef CONFIG_NO_DYNGEN_OP
c896fe29
FB
27/* legacy dyngen operations */
28#include "gen-op.h"
cf2be984 29#endif
c896fe29
FB
30
31int gen_new_label(void);
32
ac56dd48 33static inline void tcg_gen_op1(int opc, TCGv arg1)
c896fe29
FB
34{
35 *gen_opc_ptr++ = opc;
ac56dd48 36 *gen_opparam_ptr++ = GET_TCGV(arg1);
c896fe29
FB
37}
38
ac56dd48 39static inline void tcg_gen_op1i(int opc, TCGArg arg1)
c896fe29
FB
40{
41 *gen_opc_ptr++ = opc;
42 *gen_opparam_ptr++ = arg1;
c896fe29
FB
43}
44
ac56dd48 45static inline void tcg_gen_op2(int opc, TCGv arg1, TCGv arg2)
c896fe29
FB
46{
47 *gen_opc_ptr++ = opc;
ac56dd48
PB
48 *gen_opparam_ptr++ = GET_TCGV(arg1);
49 *gen_opparam_ptr++ = GET_TCGV(arg2);
c896fe29
FB
50}
51
ac56dd48 52static inline void tcg_gen_op2i(int opc, TCGv arg1, TCGArg arg2)
c896fe29
FB
53{
54 *gen_opc_ptr++ = opc;
ac56dd48 55 *gen_opparam_ptr++ = GET_TCGV(arg1);
c896fe29 56 *gen_opparam_ptr++ = arg2;
ac56dd48
PB
57}
58
59static inline void tcg_gen_op3(int opc, TCGv arg1, TCGv arg2, TCGv arg3)
60{
61 *gen_opc_ptr++ = opc;
62 *gen_opparam_ptr++ = GET_TCGV(arg1);
63 *gen_opparam_ptr++ = GET_TCGV(arg2);
64 *gen_opparam_ptr++ = GET_TCGV(arg3);
65}
66
67static inline void tcg_gen_op3i(int opc, TCGv arg1, TCGv arg2, TCGArg arg3)
68{
69 *gen_opc_ptr++ = opc;
70 *gen_opparam_ptr++ = GET_TCGV(arg1);
71 *gen_opparam_ptr++ = GET_TCGV(arg2);
c896fe29 72 *gen_opparam_ptr++ = arg3;
ac56dd48
PB
73}
74
75static inline void tcg_gen_op4(int opc, TCGv arg1, TCGv arg2, TCGv arg3,
76 TCGv arg4)
77{
78 *gen_opc_ptr++ = opc;
79 *gen_opparam_ptr++ = GET_TCGV(arg1);
80 *gen_opparam_ptr++ = GET_TCGV(arg2);
81 *gen_opparam_ptr++ = GET_TCGV(arg3);
82 *gen_opparam_ptr++ = GET_TCGV(arg4);
83}
84
85static inline void tcg_gen_op4i(int opc, TCGv arg1, TCGv arg2, TCGv arg3,
86 TCGArg arg4)
87{
88 *gen_opc_ptr++ = opc;
89 *gen_opparam_ptr++ = GET_TCGV(arg1);
90 *gen_opparam_ptr++ = GET_TCGV(arg2);
91 *gen_opparam_ptr++ = GET_TCGV(arg3);
c896fe29
FB
92 *gen_opparam_ptr++ = arg4;
93}
94
ac56dd48
PB
95static inline void tcg_gen_op4ii(int opc, TCGv arg1, TCGv arg2, TCGArg arg3,
96 TCGArg arg4)
c896fe29
FB
97{
98 *gen_opc_ptr++ = opc;
ac56dd48
PB
99 *gen_opparam_ptr++ = GET_TCGV(arg1);
100 *gen_opparam_ptr++ = GET_TCGV(arg2);
c896fe29
FB
101 *gen_opparam_ptr++ = arg3;
102 *gen_opparam_ptr++ = arg4;
ac56dd48
PB
103}
104
105static inline void tcg_gen_op5(int opc, TCGv arg1, TCGv arg2,
106 TCGv arg3, TCGv arg4,
107 TCGv arg5)
108{
109 *gen_opc_ptr++ = opc;
110 *gen_opparam_ptr++ = GET_TCGV(arg1);
111 *gen_opparam_ptr++ = GET_TCGV(arg2);
112 *gen_opparam_ptr++ = GET_TCGV(arg3);
113 *gen_opparam_ptr++ = GET_TCGV(arg4);
114 *gen_opparam_ptr++ = GET_TCGV(arg5);
115}
116
117static inline void tcg_gen_op5i(int opc, TCGv arg1, TCGv arg2,
118 TCGv arg3, TCGv arg4,
119 TCGArg arg5)
120{
121 *gen_opc_ptr++ = opc;
122 *gen_opparam_ptr++ = GET_TCGV(arg1);
123 *gen_opparam_ptr++ = GET_TCGV(arg2);
124 *gen_opparam_ptr++ = GET_TCGV(arg3);
125 *gen_opparam_ptr++ = GET_TCGV(arg4);
c896fe29
FB
126 *gen_opparam_ptr++ = arg5;
127}
128
ac56dd48
PB
129static inline void tcg_gen_op6(int opc, TCGv arg1, TCGv arg2,
130 TCGv arg3, TCGv arg4,
131 TCGv arg5, TCGv arg6)
c896fe29
FB
132{
133 *gen_opc_ptr++ = opc;
ac56dd48
PB
134 *gen_opparam_ptr++ = GET_TCGV(arg1);
135 *gen_opparam_ptr++ = GET_TCGV(arg2);
136 *gen_opparam_ptr++ = GET_TCGV(arg3);
137 *gen_opparam_ptr++ = GET_TCGV(arg4);
138 *gen_opparam_ptr++ = GET_TCGV(arg5);
139 *gen_opparam_ptr++ = GET_TCGV(arg6);
140}
141
142static inline void tcg_gen_op6ii(int opc, TCGv arg1, TCGv arg2,
143 TCGv arg3, TCGv arg4,
144 TCGArg arg5, TCGArg arg6)
145{
146 *gen_opc_ptr++ = opc;
147 *gen_opparam_ptr++ = GET_TCGV(arg1);
148 *gen_opparam_ptr++ = GET_TCGV(arg2);
149 *gen_opparam_ptr++ = GET_TCGV(arg3);
150 *gen_opparam_ptr++ = GET_TCGV(arg4);
c896fe29
FB
151 *gen_opparam_ptr++ = arg5;
152 *gen_opparam_ptr++ = arg6;
153}
154
155static inline void gen_set_label(int n)
156{
ac56dd48 157 tcg_gen_op1i(INDEX_op_set_label, n);
c896fe29
FB
158}
159
fb50d413
BS
160static inline void tcg_gen_br(int label)
161{
162 tcg_gen_op1i(INDEX_op_br, label);
163}
164
ac56dd48 165static inline void tcg_gen_mov_i32(TCGv ret, TCGv arg)
c896fe29 166{
4d07272d
BS
167 if (ret != arg)
168 tcg_gen_op2(INDEX_op_mov_i32, ret, arg);
c896fe29
FB
169}
170
ac56dd48 171static inline void tcg_gen_movi_i32(TCGv ret, int32_t arg)
c896fe29 172{
ac56dd48 173 tcg_gen_op2i(INDEX_op_movi_i32, ret, arg);
c896fe29
FB
174}
175
176/* helper calls */
177#define TCG_HELPER_CALL_FLAGS 0
178
179static inline void tcg_gen_helper_0_0(void *func)
180{
181 tcg_gen_call(&tcg_ctx,
182 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
183 0, NULL, 0, NULL);
184}
185
ac56dd48 186static inline void tcg_gen_helper_0_1(void *func, TCGv arg)
c896fe29
FB
187{
188 tcg_gen_call(&tcg_ctx,
189 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
190 0, NULL, 1, &arg);
191}
192
ac56dd48 193static inline void tcg_gen_helper_0_2(void *func, TCGv arg1, TCGv arg2)
c896fe29 194{
ac56dd48 195 TCGv args[2];
c896fe29
FB
196 args[0] = arg1;
197 args[1] = arg2;
198 tcg_gen_call(&tcg_ctx,
199 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
200 0, NULL, 2, args);
201}
202
b0109805
PB
203static inline void tcg_gen_helper_0_3(void *func,
204 TCGv arg1, TCGv arg2, TCGv arg3)
205{
206 TCGv args[3];
207 args[0] = arg1;
208 args[1] = arg2;
209 args[2] = arg3;
210 tcg_gen_call(&tcg_ctx,
211 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
212 0, NULL, 3, args);
213}
214
f8422f52
BS
215static inline void tcg_gen_helper_0_4(void *func, TCGv arg1, TCGv arg2,
216 TCGv arg3, TCGv arg4)
217{
218 TCGv args[4];
219 args[0] = arg1;
220 args[1] = arg2;
221 args[2] = arg3;
222 args[3] = arg4;
223 tcg_gen_call(&tcg_ctx,
224 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
225 0, NULL, 4, args);
226}
227
228static inline void tcg_gen_helper_1_0(void *func, TCGv ret)
229{
230 tcg_gen_call(&tcg_ctx,
231 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
232 1, &ret, 0, NULL);
233}
234
235static inline void tcg_gen_helper_1_1(void *func, TCGv ret, TCGv arg1)
236{
237 tcg_gen_call(&tcg_ctx,
238 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
239 1, &ret, 1, &arg1);
240}
241
ac56dd48
PB
242static inline void tcg_gen_helper_1_2(void *func, TCGv ret,
243 TCGv arg1, TCGv arg2)
c896fe29 244{
ac56dd48 245 TCGv args[2];
c896fe29
FB
246 args[0] = arg1;
247 args[1] = arg2;
248 tcg_gen_call(&tcg_ctx,
249 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
250 1, &ret, 2, args);
251}
252
6ddbc6e4
PB
253static inline void tcg_gen_helper_1_3(void *func, TCGv ret,
254 TCGv arg1, TCGv arg2, TCGv arg3)
255{
256 TCGv args[3];
257 args[0] = arg1;
258 args[1] = arg2;
259 args[2] = arg3;
260 tcg_gen_call(&tcg_ctx,
261 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
262 1, &ret, 3, args);
263}
264
f8422f52
BS
265static inline void tcg_gen_helper_1_4(void *func, TCGv ret,
266 TCGv arg1, TCGv arg2, TCGv arg3,
267 TCGv arg4)
268{
269 TCGv args[4];
270 args[0] = arg1;
271 args[1] = arg2;
272 args[2] = arg3;
273 args[3] = arg4;
274 tcg_gen_call(&tcg_ctx,
275 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
276 1, &ret, 4, args);
277}
278
c896fe29
FB
279/* 32 bit ops */
280
ac56dd48 281static inline void tcg_gen_ld8u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29 282{
ac56dd48 283 tcg_gen_op3i(INDEX_op_ld8u_i32, ret, arg2, offset);
c896fe29
FB
284}
285
ac56dd48 286static inline void tcg_gen_ld8s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29 287{
ac56dd48 288 tcg_gen_op3i(INDEX_op_ld8s_i32, ret, arg2, offset);
c896fe29
FB
289}
290
ac56dd48 291static inline void tcg_gen_ld16u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29 292{
ac56dd48 293 tcg_gen_op3i(INDEX_op_ld16u_i32, ret, arg2, offset);
c896fe29
FB
294}
295
ac56dd48 296static inline void tcg_gen_ld16s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29 297{
ac56dd48 298 tcg_gen_op3i(INDEX_op_ld16s_i32, ret, arg2, offset);
c896fe29
FB
299}
300
ac56dd48 301static inline void tcg_gen_ld_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29 302{
ac56dd48 303 tcg_gen_op3i(INDEX_op_ld_i32, ret, arg2, offset);
c896fe29
FB
304}
305
ac56dd48 306static inline void tcg_gen_st8_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
c896fe29 307{
ac56dd48 308 tcg_gen_op3i(INDEX_op_st8_i32, arg1, arg2, offset);
c896fe29
FB
309}
310
ac56dd48 311static inline void tcg_gen_st16_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
c896fe29 312{
ac56dd48 313 tcg_gen_op3i(INDEX_op_st16_i32, arg1, arg2, offset);
c896fe29
FB
314}
315
ac56dd48 316static inline void tcg_gen_st_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
c896fe29 317{
ac56dd48 318 tcg_gen_op3i(INDEX_op_st_i32, arg1, arg2, offset);
c896fe29
FB
319}
320
ac56dd48 321static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
322{
323 tcg_gen_op3(INDEX_op_add_i32, ret, arg1, arg2);
324}
325
ac56dd48 326static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2)
c896fe29 327{
7089442c
BS
328 /* some cases can be optimized here */
329 if (arg2 == 0) {
330 tcg_gen_mov_i32(ret, arg1);
331 } else {
332 tcg_gen_add_i32(ret, arg1, tcg_const_i32(arg2));
333 }
c896fe29
FB
334}
335
ac56dd48 336static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
337{
338 tcg_gen_op3(INDEX_op_sub_i32, ret, arg1, arg2);
339}
340
ac56dd48 341static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2)
c896fe29 342{
7089442c
BS
343 /* some cases can be optimized here */
344 if (arg2 == 0) {
345 tcg_gen_mov_i32(ret, arg1);
346 } else {
347 tcg_gen_sub_i32(ret, arg1, tcg_const_i32(arg2));
348 }
c896fe29
FB
349}
350
ac56dd48 351static inline void tcg_gen_and_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
352{
353 tcg_gen_op3(INDEX_op_and_i32, ret, arg1, arg2);
354}
355
ac56dd48 356static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2)
c896fe29
FB
357{
358 /* some cases can be optimized here */
359 if (arg2 == 0) {
360 tcg_gen_movi_i32(ret, 0);
361 } else if (arg2 == 0xffffffff) {
362 tcg_gen_mov_i32(ret, arg1);
363 } else {
364 tcg_gen_and_i32(ret, arg1, tcg_const_i32(arg2));
365 }
366}
367
ac56dd48 368static inline void tcg_gen_or_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
369{
370 tcg_gen_op3(INDEX_op_or_i32, ret, arg1, arg2);
371}
372
ac56dd48 373static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2)
c896fe29
FB
374{
375 /* some cases can be optimized here */
376 if (arg2 == 0xffffffff) {
7089442c 377 tcg_gen_movi_i32(ret, 0xffffffff);
c896fe29
FB
378 } else if (arg2 == 0) {
379 tcg_gen_mov_i32(ret, arg1);
380 } else {
381 tcg_gen_or_i32(ret, arg1, tcg_const_i32(arg2));
382 }
383}
384
ac56dd48 385static inline void tcg_gen_xor_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
386{
387 tcg_gen_op3(INDEX_op_xor_i32, ret, arg1, arg2);
388}
389
ac56dd48 390static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2)
c896fe29
FB
391{
392 /* some cases can be optimized here */
393 if (arg2 == 0) {
394 tcg_gen_mov_i32(ret, arg1);
395 } else {
396 tcg_gen_xor_i32(ret, arg1, tcg_const_i32(arg2));
397 }
398}
399
ac56dd48 400static inline void tcg_gen_shl_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
401{
402 tcg_gen_op3(INDEX_op_shl_i32, ret, arg1, arg2);
403}
404
ac56dd48 405static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2)
c896fe29
FB
406{
407 tcg_gen_shl_i32(ret, arg1, tcg_const_i32(arg2));
408}
409
ac56dd48 410static inline void tcg_gen_shr_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
411{
412 tcg_gen_op3(INDEX_op_shr_i32, ret, arg1, arg2);
413}
414
ac56dd48 415static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2)
c896fe29
FB
416{
417 tcg_gen_shr_i32(ret, arg1, tcg_const_i32(arg2));
418}
419
ac56dd48 420static inline void tcg_gen_sar_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
421{
422 tcg_gen_op3(INDEX_op_sar_i32, ret, arg1, arg2);
423}
424
ac56dd48 425static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2)
c896fe29
FB
426{
427 tcg_gen_sar_i32(ret, arg1, tcg_const_i32(arg2));
428}
429
ac56dd48 430static inline void tcg_gen_brcond_i32(int cond, TCGv arg1, TCGv arg2,
c896fe29
FB
431 int label_index)
432{
ac56dd48 433 tcg_gen_op4ii(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
c896fe29
FB
434}
435
ac56dd48 436static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
437{
438 tcg_gen_op3(INDEX_op_mul_i32, ret, arg1, arg2);
439}
440
441#ifdef TCG_TARGET_HAS_div_i32
ac56dd48 442static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
443{
444 tcg_gen_op3(INDEX_op_div_i32, ret, arg1, arg2);
445}
446
ac56dd48 447static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
448{
449 tcg_gen_op3(INDEX_op_rem_i32, ret, arg1, arg2);
450}
451
ac56dd48 452static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
453{
454 tcg_gen_op3(INDEX_op_divu_i32, ret, arg1, arg2);
455}
456
ac56dd48 457static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
458{
459 tcg_gen_op3(INDEX_op_remu_i32, ret, arg1, arg2);
460}
461#else
ac56dd48 462static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 463{
ac56dd48 464 TCGv t0;
c896fe29
FB
465 t0 = tcg_temp_new(TCG_TYPE_I32);
466 tcg_gen_sari_i32(t0, arg1, 31);
467 tcg_gen_op5(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
468}
469
ac56dd48 470static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 471{
ac56dd48 472 TCGv t0;
c896fe29
FB
473 t0 = tcg_temp_new(TCG_TYPE_I32);
474 tcg_gen_sari_i32(t0, arg1, 31);
475 tcg_gen_op5(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
476}
477
ac56dd48 478static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 479{
ac56dd48 480 TCGv t0;
c896fe29
FB
481 t0 = tcg_temp_new(TCG_TYPE_I32);
482 tcg_gen_movi_i32(t0, 0);
483 tcg_gen_op5(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
484}
485
ac56dd48 486static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 487{
ac56dd48 488 TCGv t0;
c896fe29
FB
489 t0 = tcg_temp_new(TCG_TYPE_I32);
490 tcg_gen_movi_i32(t0, 0);
491 tcg_gen_op5(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
492}
493#endif
494
495#if TCG_TARGET_REG_BITS == 32
496
ac56dd48 497static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
c896fe29 498{
4d07272d
BS
499 if (ret != arg) {
500 tcg_gen_mov_i32(ret, arg);
501 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
502 }
c896fe29
FB
503}
504
ac56dd48 505static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
c896fe29
FB
506{
507 tcg_gen_movi_i32(ret, arg);
ac56dd48 508 tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
c896fe29
FB
509}
510
ac56dd48 511static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29
FB
512{
513 tcg_gen_ld8u_i32(ret, arg2, offset);
ac56dd48 514 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
515}
516
ac56dd48 517static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29
FB
518{
519 tcg_gen_ld8s_i32(ret, arg2, offset);
ac56dd48 520 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
521}
522
ac56dd48 523static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29
FB
524{
525 tcg_gen_ld16u_i32(ret, arg2, offset);
ac56dd48 526 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
527}
528
ac56dd48 529static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29
FB
530{
531 tcg_gen_ld16s_i32(ret, arg2, offset);
ac56dd48 532 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
533}
534
ac56dd48 535static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29
FB
536{
537 tcg_gen_ld_i32(ret, arg2, offset);
ac56dd48 538 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
539}
540
ac56dd48 541static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29
FB
542{
543 tcg_gen_ld_i32(ret, arg2, offset);
ac56dd48 544 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
545}
546
ac56dd48 547static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29
FB
548{
549 /* since arg2 and ret have different types, they cannot be the
550 same temporary */
551#ifdef TCG_TARGET_WORDS_BIGENDIAN
ac56dd48 552 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
c896fe29
FB
553 tcg_gen_ld_i32(ret, arg2, offset + 4);
554#else
555 tcg_gen_ld_i32(ret, arg2, offset);
ac56dd48 556 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
c896fe29
FB
557#endif
558}
559
ac56dd48 560static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
c896fe29
FB
561{
562 tcg_gen_st8_i32(arg1, arg2, offset);
563}
564
ac56dd48 565static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
c896fe29
FB
566{
567 tcg_gen_st16_i32(arg1, arg2, offset);
568}
569
ac56dd48 570static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
c896fe29
FB
571{
572 tcg_gen_st_i32(arg1, arg2, offset);
573}
574
ac56dd48 575static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
c896fe29
FB
576{
577#ifdef TCG_TARGET_WORDS_BIGENDIAN
ac56dd48 578 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
c896fe29
FB
579 tcg_gen_st_i32(arg1, arg2, offset + 4);
580#else
581 tcg_gen_st_i32(arg1, arg2, offset);
ac56dd48 582 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
c896fe29
FB
583#endif
584}
585
ac56dd48 586static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 587{
ac56dd48
PB
588 tcg_gen_op6(INDEX_op_add2_i32, ret, TCGV_HIGH(ret),
589 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
c896fe29
FB
590}
591
ac56dd48 592static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
593{
594 tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
595}
596
ac56dd48 597static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 598{
ac56dd48
PB
599 tcg_gen_op6(INDEX_op_sub2_i32, ret, TCGV_HIGH(ret),
600 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
c896fe29
FB
601}
602
ac56dd48 603static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
604{
605 tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
606}
607
ac56dd48 608static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
609{
610 tcg_gen_and_i32(ret, arg1, arg2);
ac56dd48 611 tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
c896fe29
FB
612}
613
ac56dd48 614static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
615{
616 tcg_gen_andi_i32(ret, arg1, arg2);
ac56dd48 617 tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
c896fe29
FB
618}
619
ac56dd48 620static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
621{
622 tcg_gen_or_i32(ret, arg1, arg2);
ac56dd48 623 tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
c896fe29
FB
624}
625
ac56dd48 626static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
627{
628 tcg_gen_ori_i32(ret, arg1, arg2);
ac56dd48 629 tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
c896fe29
FB
630}
631
ac56dd48 632static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
633{
634 tcg_gen_xor_i32(ret, arg1, arg2);
ac56dd48 635 tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
c896fe29
FB
636}
637
ac56dd48 638static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
639{
640 tcg_gen_xori_i32(ret, arg1, arg2);
ac56dd48 641 tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
c896fe29
FB
642}
643
644/* XXX: use generic code when basic block handling is OK or CPU
645 specific code (x86) */
ac56dd48 646static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
647{
648 tcg_gen_helper_1_2(tcg_helper_shl_i64, ret, arg1, arg2);
649}
650
ac56dd48 651static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
652{
653 tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
654}
655
ac56dd48 656static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
657{
658 tcg_gen_helper_1_2(tcg_helper_shr_i64, ret, arg1, arg2);
659}
660
ac56dd48 661static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
662{
663 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
664}
665
ac56dd48 666static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
667{
668 tcg_gen_helper_1_2(tcg_helper_sar_i64, ret, arg1, arg2);
669}
670
ac56dd48 671static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
672{
673 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
674}
675
ac56dd48 676static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
c896fe29
FB
677 int label_index)
678{
ac56dd48
PB
679 tcg_gen_op6ii(INDEX_op_brcond2_i32,
680 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2),
681 cond, label_index);
c896fe29
FB
682}
683
ac56dd48 684static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 685{
ac56dd48 686 TCGv t0, t1;
c896fe29
FB
687
688 t0 = tcg_temp_new(TCG_TYPE_I64);
689 t1 = tcg_temp_new(TCG_TYPE_I32);
690
ac56dd48 691 tcg_gen_op4(INDEX_op_mulu2_i32, t0, TCGV_HIGH(t0), arg1, arg2);
c896fe29 692
ac56dd48
PB
693 tcg_gen_mul_i32(t1, arg1, TCGV_HIGH(arg2));
694 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
695 tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), arg2);
696 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
c896fe29
FB
697
698 tcg_gen_mov_i64(ret, t0);
699}
700
ac56dd48 701static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
702{
703 tcg_gen_helper_1_2(tcg_helper_div_i64, ret, arg1, arg2);
704}
705
ac56dd48 706static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
707{
708 tcg_gen_helper_1_2(tcg_helper_rem_i64, ret, arg1, arg2);
709}
710
ac56dd48 711static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
712{
713 tcg_gen_helper_1_2(tcg_helper_divu_i64, ret, arg1, arg2);
714}
715
ac56dd48 716static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
717{
718 tcg_gen_helper_1_2(tcg_helper_remu_i64, ret, arg1, arg2);
719}
720
721#else
722
ac56dd48 723static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
c896fe29 724{
4d07272d
BS
725 if (ret != arg)
726 tcg_gen_op2(INDEX_op_mov_i64, ret, arg);
c896fe29
FB
727}
728
ac56dd48 729static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
c896fe29 730{
ac56dd48 731 tcg_gen_op2i(INDEX_op_movi_i64, ret, arg);
c896fe29
FB
732}
733
ac56dd48
PB
734static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2,
735 tcg_target_long offset)
c896fe29 736{
ac56dd48 737 tcg_gen_op3i(INDEX_op_ld8u_i64, ret, arg2, offset);
c896fe29
FB
738}
739
ac56dd48
PB
740static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2,
741 tcg_target_long offset)
c896fe29 742{
ac56dd48 743 tcg_gen_op3i(INDEX_op_ld8s_i64, ret, arg2, offset);
c896fe29
FB
744}
745
ac56dd48
PB
746static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2,
747 tcg_target_long offset)
c896fe29 748{
ac56dd48 749 tcg_gen_op3i(INDEX_op_ld16u_i64, ret, arg2, offset);
c896fe29
FB
750}
751
ac56dd48
PB
752static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2,
753 tcg_target_long offset)
c896fe29 754{
ac56dd48 755 tcg_gen_op3i(INDEX_op_ld16s_i64, ret, arg2, offset);
c896fe29
FB
756}
757
ac56dd48
PB
758static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2,
759 tcg_target_long offset)
c896fe29 760{
ac56dd48 761 tcg_gen_op3i(INDEX_op_ld32u_i64, ret, arg2, offset);
c896fe29
FB
762}
763
ac56dd48
PB
764static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2,
765 tcg_target_long offset)
c896fe29 766{
ac56dd48 767 tcg_gen_op3i(INDEX_op_ld32s_i64, ret, arg2, offset);
c896fe29
FB
768}
769
ac56dd48 770static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
c896fe29 771{
ac56dd48 772 tcg_gen_op3i(INDEX_op_ld_i64, ret, arg2, offset);
c896fe29
FB
773}
774
ac56dd48
PB
775static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2,
776 tcg_target_long offset)
c896fe29 777{
ac56dd48 778 tcg_gen_op3i(INDEX_op_st8_i64, arg1, arg2, offset);
c896fe29
FB
779}
780
ac56dd48
PB
781static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2,
782 tcg_target_long offset)
c896fe29 783{
ac56dd48 784 tcg_gen_op3i(INDEX_op_st16_i64, arg1, arg2, offset);
c896fe29
FB
785}
786
ac56dd48
PB
787static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2,
788 tcg_target_long offset)
c896fe29 789{
ac56dd48 790 tcg_gen_op3i(INDEX_op_st32_i64, arg1, arg2, offset);
c896fe29
FB
791}
792
ac56dd48 793static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
c896fe29 794{
ac56dd48 795 tcg_gen_op3i(INDEX_op_st_i64, arg1, arg2, offset);
c896fe29
FB
796}
797
ac56dd48 798static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
799{
800 tcg_gen_op3(INDEX_op_add_i64, ret, arg1, arg2);
801}
802
ac56dd48 803static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
804{
805 tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
806}
807
ac56dd48 808static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
809{
810 tcg_gen_op3(INDEX_op_sub_i64, ret, arg1, arg2);
811}
812
ac56dd48 813static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
814{
815 tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
816}
817
ac56dd48 818static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
819{
820 tcg_gen_op3(INDEX_op_and_i64, ret, arg1, arg2);
821}
822
ac56dd48 823static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
824{
825 tcg_gen_and_i64(ret, arg1, tcg_const_i64(arg2));
826}
827
ac56dd48 828static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
829{
830 tcg_gen_op3(INDEX_op_or_i64, ret, arg1, arg2);
831}
832
ac56dd48 833static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
834{
835 tcg_gen_or_i64(ret, arg1, tcg_const_i64(arg2));
836}
837
ac56dd48 838static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
839{
840 tcg_gen_op3(INDEX_op_xor_i64, ret, arg1, arg2);
841}
842
ac56dd48 843static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
844{
845 tcg_gen_xor_i64(ret, arg1, tcg_const_i64(arg2));
846}
847
ac56dd48 848static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
849{
850 tcg_gen_op3(INDEX_op_shl_i64, ret, arg1, arg2);
851}
852
ac56dd48 853static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
854{
855 tcg_gen_shl_i64(ret, arg1, tcg_const_i64(arg2));
856}
857
ac56dd48 858static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
859{
860 tcg_gen_op3(INDEX_op_shr_i64, ret, arg1, arg2);
861}
862
ac56dd48 863static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
864{
865 tcg_gen_shr_i64(ret, arg1, tcg_const_i64(arg2));
866}
867
ac56dd48 868static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
869{
870 tcg_gen_op3(INDEX_op_sar_i64, ret, arg1, arg2);
871}
872
ac56dd48 873static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
c896fe29
FB
874{
875 tcg_gen_sar_i64(ret, arg1, tcg_const_i64(arg2));
876}
877
ac56dd48 878static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
c896fe29
FB
879 int label_index)
880{
ac56dd48 881 tcg_gen_op4ii(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
c896fe29
FB
882}
883
ac56dd48 884static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
885{
886 tcg_gen_op3(INDEX_op_mul_i64, ret, arg1, arg2);
887}
888
889#ifdef TCG_TARGET_HAS_div_i64
ac56dd48 890static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
891{
892 tcg_gen_op3(INDEX_op_div_i64, ret, arg1, arg2);
893}
894
ac56dd48 895static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
896{
897 tcg_gen_op3(INDEX_op_rem_i64, ret, arg1, arg2);
898}
899
ac56dd48 900static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
901{
902 tcg_gen_op3(INDEX_op_divu_i64, ret, arg1, arg2);
903}
904
ac56dd48 905static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29
FB
906{
907 tcg_gen_op3(INDEX_op_remu_i64, ret, arg1, arg2);
908}
909#else
ac56dd48 910static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 911{
ac56dd48 912 TCGv t0;
c896fe29
FB
913 t0 = tcg_temp_new(TCG_TYPE_I64);
914 tcg_gen_sari_i64(t0, arg1, 63);
915 tcg_gen_op5(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
916}
917
ac56dd48 918static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 919{
ac56dd48 920 TCGv t0;
c896fe29
FB
921 t0 = tcg_temp_new(TCG_TYPE_I64);
922 tcg_gen_sari_i64(t0, arg1, 63);
923 tcg_gen_op5(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
924}
925
ac56dd48 926static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 927{
ac56dd48 928 TCGv t0;
c896fe29
FB
929 t0 = tcg_temp_new(TCG_TYPE_I64);
930 tcg_gen_movi_i64(t0, 0);
931 tcg_gen_op5(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
932}
933
ac56dd48 934static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
c896fe29 935{
ac56dd48 936 TCGv t0;
c896fe29
FB
937 t0 = tcg_temp_new(TCG_TYPE_I64);
938 tcg_gen_movi_i64(t0, 0);
939 tcg_gen_op5(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
940}
941#endif
942
943#endif
944
945/***************************************/
946/* optional operations */
947
ac56dd48 948static inline void tcg_gen_ext8s_i32(TCGv ret, TCGv arg)
c896fe29
FB
949{
950#ifdef TCG_TARGET_HAS_ext8s_i32
951 tcg_gen_op2(INDEX_op_ext8s_i32, ret, arg);
952#else
953 tcg_gen_shli_i32(ret, arg, 24);
5ff9d6a4 954 tcg_gen_sari_i32(ret, ret, 24);
c896fe29
FB
955#endif
956}
957
ac56dd48 958static inline void tcg_gen_ext16s_i32(TCGv ret, TCGv arg)
c896fe29
FB
959{
960#ifdef TCG_TARGET_HAS_ext16s_i32
961 tcg_gen_op2(INDEX_op_ext16s_i32, ret, arg);
962#else
963 tcg_gen_shli_i32(ret, arg, 16);
5ff9d6a4 964 tcg_gen_sari_i32(ret, ret, 16);
c896fe29
FB
965#endif
966}
967
968/* Note: we assume the two high bytes are set to zero */
ac56dd48 969static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg)
c896fe29
FB
970{
971#ifdef TCG_TARGET_HAS_bswap16_i32
972 tcg_gen_op2(INDEX_op_bswap16_i32, ret, arg);
973#else
ac56dd48 974 TCGv t0, t1;
c896fe29
FB
975 t0 = tcg_temp_new(TCG_TYPE_I32);
976 t1 = tcg_temp_new(TCG_TYPE_I32);
977
978 tcg_gen_shri_i32(t0, arg, 8);
979 tcg_gen_andi_i32(t1, arg, 0x000000ff);
980 tcg_gen_shli_i32(t1, t1, 8);
981 tcg_gen_or_i32(ret, t0, t1);
982#endif
983}
984
ac56dd48 985static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg)
c896fe29
FB
986{
987#ifdef TCG_TARGET_HAS_bswap_i32
988 tcg_gen_op2(INDEX_op_bswap_i32, ret, arg);
989#else
ac56dd48 990 TCGv t0, t1;
c896fe29
FB
991 t0 = tcg_temp_new(TCG_TYPE_I32);
992 t1 = tcg_temp_new(TCG_TYPE_I32);
993
994 tcg_gen_shli_i32(t0, arg, 24);
995
996 tcg_gen_andi_i32(t1, arg, 0x0000ff00);
997 tcg_gen_shli_i32(t1, t1, 8);
998 tcg_gen_or_i32(t0, t0, t1);
999
1000 tcg_gen_shri_i32(t1, arg, 8);
1001 tcg_gen_andi_i32(t1, t1, 0x0000ff00);
1002 tcg_gen_or_i32(t0, t0, t1);
1003
1004 tcg_gen_shri_i32(t1, arg, 24);
1005 tcg_gen_or_i32(ret, t0, t1);
1006#endif
1007}
1008
1009#if TCG_TARGET_REG_BITS == 32
ac56dd48 1010static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
c896fe29
FB
1011{
1012 tcg_gen_ext8s_i32(ret, arg);
ac56dd48 1013 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
1014}
1015
ac56dd48 1016static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
c896fe29
FB
1017{
1018 tcg_gen_ext16s_i32(ret, arg);
ac56dd48 1019 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
1020}
1021
ac56dd48 1022static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
c896fe29
FB
1023{
1024 tcg_gen_mov_i32(ret, arg);
ac56dd48 1025 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
1026}
1027
ac56dd48 1028static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
c896fe29
FB
1029{
1030 tcg_gen_mov_i32(ret, arg);
1031}
1032
ac56dd48 1033static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
c896fe29
FB
1034{
1035 tcg_gen_mov_i32(ret, arg);
ac56dd48 1036 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
1037}
1038
ac56dd48 1039static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
c896fe29
FB
1040{
1041 tcg_gen_mov_i32(ret, arg);
ac56dd48 1042 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
1043}
1044
ac56dd48 1045static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
c896fe29 1046{
ac56dd48 1047 TCGv t0, t1;
c896fe29
FB
1048 t0 = tcg_temp_new(TCG_TYPE_I32);
1049 t1 = tcg_temp_new(TCG_TYPE_I32);
1050
1051 tcg_gen_bswap_i32(t0, arg);
ac56dd48 1052 tcg_gen_bswap_i32(t1, TCGV_HIGH(arg));
c896fe29 1053 tcg_gen_mov_i32(ret, t1);
ac56dd48 1054 tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
c896fe29
FB
1055}
1056#else
1057
ac56dd48 1058static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
c896fe29
FB
1059{
1060#ifdef TCG_TARGET_HAS_ext8s_i64
1061 tcg_gen_op2(INDEX_op_ext8s_i64, ret, arg);
1062#else
1063 tcg_gen_shli_i64(ret, arg, 56);
5ff9d6a4 1064 tcg_gen_sari_i64(ret, ret, 56);
c896fe29
FB
1065#endif
1066}
1067
ac56dd48 1068static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
c896fe29
FB
1069{
1070#ifdef TCG_TARGET_HAS_ext16s_i64
1071 tcg_gen_op2(INDEX_op_ext16s_i64, ret, arg);
1072#else
1073 tcg_gen_shli_i64(ret, arg, 48);
5ff9d6a4 1074 tcg_gen_sari_i64(ret, ret, 48);
c896fe29
FB
1075#endif
1076}
1077
ac56dd48 1078static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
c896fe29
FB
1079{
1080#ifdef TCG_TARGET_HAS_ext32s_i64
1081 tcg_gen_op2(INDEX_op_ext32s_i64, ret, arg);
1082#else
1083 tcg_gen_shli_i64(ret, arg, 32);
5ff9d6a4 1084 tcg_gen_sari_i64(ret, ret, 32);
c896fe29
FB
1085#endif
1086}
1087
1088/* Note: we assume the target supports move between 32 and 64 bit
ac56dd48
PB
1089 registers. This will probably break MIPS64 targets. */
1090static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
c896fe29
FB
1091{
1092 tcg_gen_mov_i32(ret, arg);
1093}
1094
1095/* Note: we assume the target supports move between 32 and 64 bit
1096 registers */
ac56dd48 1097static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
c896fe29
FB
1098{
1099 tcg_gen_andi_i64(ret, arg, 0xffffffff);
1100}
1101
1102/* Note: we assume the target supports move between 32 and 64 bit
1103 registers */
ac56dd48 1104static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
c896fe29
FB
1105{
1106 tcg_gen_ext32s_i64(ret, arg);
1107}
1108
ac56dd48 1109static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
c896fe29
FB
1110{
1111#ifdef TCG_TARGET_HAS_bswap_i64
1112 tcg_gen_op2(INDEX_op_bswap_i64, ret, arg);
1113#else
ac56dd48 1114 TCGv t0, t1;
c896fe29
FB
1115 t0 = tcg_temp_new(TCG_TYPE_I32);
1116 t1 = tcg_temp_new(TCG_TYPE_I32);
1117
1118 tcg_gen_shli_i64(t0, arg, 56);
1119
1120 tcg_gen_andi_i64(t1, arg, 0x0000ff00);
1121 tcg_gen_shli_i64(t1, t1, 40);
1122 tcg_gen_or_i64(t0, t0, t1);
1123
1124 tcg_gen_andi_i64(t1, arg, 0x00ff0000);
1125 tcg_gen_shli_i64(t1, t1, 24);
1126 tcg_gen_or_i64(t0, t0, t1);
1127
1128 tcg_gen_andi_i64(t1, arg, 0xff000000);
1129 tcg_gen_shli_i64(t1, t1, 8);
1130 tcg_gen_or_i64(t0, t0, t1);
1131
1132 tcg_gen_shri_i64(t1, arg, 8);
1133 tcg_gen_andi_i64(t1, t1, 0xff000000);
1134 tcg_gen_or_i64(t0, t0, t1);
1135
1136 tcg_gen_shri_i64(t1, arg, 24);
1137 tcg_gen_andi_i64(t1, t1, 0x00ff0000);
1138 tcg_gen_or_i64(t0, t0, t1);
1139
1140 tcg_gen_shri_i64(t1, arg, 40);
1141 tcg_gen_andi_i64(t1, t1, 0x0000ff00);
1142 tcg_gen_or_i64(t0, t0, t1);
1143
1144 tcg_gen_shri_i64(t1, arg, 56);
1145 tcg_gen_or_i64(ret, t0, t1);
1146#endif
1147}
1148
1149#endif
1150
5ff9d6a4
FB
1151
1152static inline void tcg_gen_discard_i32(TCGv arg)
1153{
1154 tcg_gen_op1(INDEX_op_discard, arg);
1155}
1156
1157#if TCG_TARGET_REG_BITS == 32
1158static inline void tcg_gen_discard_i64(TCGv arg)
1159{
1160 tcg_gen_discard_i32(arg);
1161 tcg_gen_discard_i32(TCGV_HIGH(arg));
1162}
1163#else
1164static inline void tcg_gen_discard_i64(TCGv arg)
1165{
1166 tcg_gen_op1(INDEX_op_discard, arg);
1167}
1168#endif
1169
c896fe29 1170/***************************************/
ac56dd48 1171static inline void tcg_gen_macro_2(TCGv ret0, TCGv ret1, int macro_id)
c896fe29 1172{
ac56dd48 1173 tcg_gen_op3i(INDEX_op_macro_2, ret0, ret1, macro_id);
c896fe29
FB
1174}
1175
1176/***************************************/
1177/* QEMU specific operations. Their type depend on the QEMU CPU
1178 type. */
1179#ifndef TARGET_LONG_BITS
1180#error must include QEMU headers
1181#endif
1182
1183static inline void tcg_gen_exit_tb(tcg_target_long val)
1184{
ac56dd48 1185 tcg_gen_op1i(INDEX_op_exit_tb, val);
c896fe29
FB
1186}
1187
1188static inline void tcg_gen_goto_tb(int idx)
1189{
ac56dd48 1190 tcg_gen_op1i(INDEX_op_goto_tb, idx);
c896fe29
FB
1191}
1192
1193#if TCG_TARGET_REG_BITS == 32
ac56dd48 1194static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
1195{
1196#if TARGET_LONG_BITS == 32
ac56dd48 1197 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
c896fe29 1198#else
ac56dd48
PB
1199 tcg_gen_op4i(INDEX_op_qemu_ld8u, ret, addr, TCGV_HIGH(addr), mem_index);
1200 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
1201#endif
1202}
1203
ac56dd48 1204static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
1205{
1206#if TARGET_LONG_BITS == 32
ac56dd48 1207 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
c896fe29 1208#else
ac56dd48 1209 tcg_gen_op4i(INDEX_op_qemu_ld8s, ret, addr, TCGV_HIGH(addr), mem_index);
21fc3cfc 1210 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
1211#endif
1212}
1213
ac56dd48 1214static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
1215{
1216#if TARGET_LONG_BITS == 32
ac56dd48 1217 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
c896fe29 1218#else
ac56dd48
PB
1219 tcg_gen_op4i(INDEX_op_qemu_ld16u, ret, addr, TCGV_HIGH(addr), mem_index);
1220 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
1221#endif
1222}
1223
ac56dd48 1224static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
1225{
1226#if TARGET_LONG_BITS == 32
ac56dd48 1227 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
c896fe29 1228#else
ac56dd48 1229 tcg_gen_op4i(INDEX_op_qemu_ld16s, ret, addr, TCGV_HIGH(addr), mem_index);
21fc3cfc 1230 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
1231#endif
1232}
1233
ac56dd48 1234static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
1235{
1236#if TARGET_LONG_BITS == 32
ac56dd48 1237 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
c896fe29 1238#else
ac56dd48
PB
1239 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1240 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
1241#endif
1242}
1243
ac56dd48 1244static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
1245{
1246#if TARGET_LONG_BITS == 32
ac56dd48 1247 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
c896fe29 1248#else
ac56dd48
PB
1249 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1250 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
c896fe29
FB
1251#endif
1252}
1253
ac56dd48 1254static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
1255{
1256#if TARGET_LONG_BITS == 32
ac56dd48 1257 tcg_gen_op4i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), addr, mem_index);
c896fe29 1258#else
ac56dd48
PB
1259 tcg_gen_op5i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret),
1260 addr, TCGV_HIGH(addr), mem_index);
c896fe29
FB
1261#endif
1262}
1263
ac56dd48 1264static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
1265{
1266#if TARGET_LONG_BITS == 32
ac56dd48 1267 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
c896fe29 1268#else
ac56dd48 1269 tcg_gen_op4i(INDEX_op_qemu_st8, arg, addr, TCGV_HIGH(addr), mem_index);
c896fe29
FB
1270#endif
1271}
1272
ac56dd48 1273static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
1274{
1275#if TARGET_LONG_BITS == 32
ac56dd48 1276 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
c896fe29 1277#else
ac56dd48 1278 tcg_gen_op4i(INDEX_op_qemu_st16, arg, addr, TCGV_HIGH(addr), mem_index);
c896fe29
FB
1279#endif
1280}
1281
ac56dd48 1282static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
1283{
1284#if TARGET_LONG_BITS == 32
ac56dd48 1285 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
c896fe29 1286#else
ac56dd48 1287 tcg_gen_op4i(INDEX_op_qemu_st32, arg, addr, TCGV_HIGH(addr), mem_index);
c896fe29
FB
1288#endif
1289}
1290
ac56dd48 1291static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
1292{
1293#if TARGET_LONG_BITS == 32
ac56dd48 1294 tcg_gen_op4i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), addr, mem_index);
c896fe29 1295#else
ac56dd48
PB
1296 tcg_gen_op5i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg),
1297 addr, TCGV_HIGH(addr), mem_index);
c896fe29
FB
1298#endif
1299}
1300
56b8f567 1301#define tcg_gen_ld_ptr tcg_gen_ld_i32
a768e4b2 1302#define tcg_gen_discard_ptr tcg_gen_discard_i32
f8422f52 1303
c896fe29
FB
1304#else /* TCG_TARGET_REG_BITS == 32 */
1305
ac56dd48 1306static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
c896fe29 1307{
ac56dd48 1308 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
c896fe29
FB
1309}
1310
ac56dd48 1311static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
c896fe29 1312{
ac56dd48 1313 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
c896fe29
FB
1314}
1315
ac56dd48 1316static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
c896fe29 1317{
ac56dd48 1318 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
c896fe29
FB
1319}
1320
ac56dd48 1321static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
c896fe29 1322{
ac56dd48 1323 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
c896fe29
FB
1324}
1325
ac56dd48 1326static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
c896fe29 1327{
ac56dd48 1328 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
c896fe29
FB
1329}
1330
ac56dd48 1331static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
c896fe29 1332{
ac56dd48 1333 tcg_gen_op3i(INDEX_op_qemu_ld32s, ret, addr, mem_index);
c896fe29
FB
1334}
1335
ac56dd48 1336static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
c896fe29 1337{
ac56dd48 1338 tcg_gen_op3i(INDEX_op_qemu_ld64, ret, addr, mem_index);
c896fe29
FB
1339}
1340
ac56dd48 1341static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
c896fe29 1342{
ac56dd48 1343 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
c896fe29
FB
1344}
1345
ac56dd48 1346static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
c896fe29 1347{
ac56dd48 1348 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
c896fe29
FB
1349}
1350
ac56dd48 1351static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
c896fe29 1352{
ac56dd48 1353 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
c896fe29
FB
1354}
1355
ac56dd48 1356static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
c896fe29 1357{
ac56dd48 1358 tcg_gen_op3i(INDEX_op_qemu_st64, arg, addr, mem_index);
c896fe29
FB
1359}
1360
56b8f567 1361#define tcg_gen_ld_ptr tcg_gen_ld_i64
a768e4b2 1362#define tcg_gen_discard_ptr tcg_gen_discard_i64
f8422f52 1363
c896fe29 1364#endif /* TCG_TARGET_REG_BITS != 32 */
f8422f52
BS
1365
1366#if TARGET_LONG_BITS == 64
1367#define TCG_TYPE_TL TCG_TYPE_I64
1368#define tcg_gen_movi_tl tcg_gen_movi_i64
1369#define tcg_gen_mov_tl tcg_gen_mov_i64
1370#define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
1371#define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
1372#define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
1373#define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
1374#define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
1375#define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
1376#define tcg_gen_ld_tl tcg_gen_ld_i64
1377#define tcg_gen_st8_tl tcg_gen_st8_i64
1378#define tcg_gen_st16_tl tcg_gen_st16_i64
1379#define tcg_gen_st32_tl tcg_gen_st32_i64
1380#define tcg_gen_st_tl tcg_gen_st_i64
1381#define tcg_gen_add_tl tcg_gen_add_i64
1382#define tcg_gen_addi_tl tcg_gen_addi_i64
1383#define tcg_gen_sub_tl tcg_gen_sub_i64
1384#define tcg_gen_subi_tl tcg_gen_subi_i64
1385#define tcg_gen_and_tl tcg_gen_and_i64
1386#define tcg_gen_andi_tl tcg_gen_andi_i64
1387#define tcg_gen_or_tl tcg_gen_or_i64
1388#define tcg_gen_ori_tl tcg_gen_ori_i64
1389#define tcg_gen_xor_tl tcg_gen_xor_i64
1390#define tcg_gen_xori_tl tcg_gen_xori_i64
1391#define tcg_gen_shl_tl tcg_gen_shl_i64
1392#define tcg_gen_shli_tl tcg_gen_shli_i64
1393#define tcg_gen_shr_tl tcg_gen_shr_i64
1394#define tcg_gen_shri_tl tcg_gen_shri_i64
1395#define tcg_gen_sar_tl tcg_gen_sar_i64
1396#define tcg_gen_sari_tl tcg_gen_sari_i64
0cf767d6 1397#define tcg_gen_brcond_tl tcg_gen_brcond_i64
a768e4b2 1398#define tcg_gen_discard_tl tcg_gen_discard_i64
e429073d
BS
1399#define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
1400#define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
1401#define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
1402#define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
1403#define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
1404#define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
a98824ac 1405#define tcg_const_tl tcg_const_i64
f8422f52
BS
1406#else
1407#define TCG_TYPE_TL TCG_TYPE_I32
1408#define tcg_gen_movi_tl tcg_gen_movi_i32
1409#define tcg_gen_mov_tl tcg_gen_mov_i32
1410#define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
1411#define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
1412#define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
1413#define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
1414#define tcg_gen_ld32u_tl tcg_gen_ld_i32
1415#define tcg_gen_ld32s_tl tcg_gen_ld_i32
1416#define tcg_gen_ld_tl tcg_gen_ld_i32
1417#define tcg_gen_st8_tl tcg_gen_st8_i32
1418#define tcg_gen_st16_tl tcg_gen_st16_i32
1419#define tcg_gen_st32_tl tcg_gen_st_i32
1420#define tcg_gen_st_tl tcg_gen_st_i32
1421#define tcg_gen_add_tl tcg_gen_add_i32
1422#define tcg_gen_addi_tl tcg_gen_addi_i32
1423#define tcg_gen_sub_tl tcg_gen_sub_i32
1424#define tcg_gen_subi_tl tcg_gen_subi_i32
1425#define tcg_gen_and_tl tcg_gen_and_i32
1426#define tcg_gen_andi_tl tcg_gen_andi_i32
1427#define tcg_gen_or_tl tcg_gen_or_i32
1428#define tcg_gen_ori_tl tcg_gen_ori_i32
1429#define tcg_gen_xor_tl tcg_gen_xor_i32
1430#define tcg_gen_xori_tl tcg_gen_xori_i32
1431#define tcg_gen_shl_tl tcg_gen_shl_i32
1432#define tcg_gen_shli_tl tcg_gen_shli_i32
1433#define tcg_gen_shr_tl tcg_gen_shr_i32
1434#define tcg_gen_shri_tl tcg_gen_shri_i32
1435#define tcg_gen_sar_tl tcg_gen_sar_i32
1436#define tcg_gen_sari_tl tcg_gen_sari_i32
0cf767d6 1437#define tcg_gen_brcond_tl tcg_gen_brcond_i32
a768e4b2 1438#define tcg_gen_discard_tl tcg_gen_discard_i32
e429073d
BS
1439#define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
1440#define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
1441#define tcg_gen_extu_i32_tl tcg_gen_mov_i32
1442#define tcg_gen_ext_i32_tl tcg_gen_mov_i32
1443#define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
1444#define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
a98824ac 1445#define tcg_const_tl tcg_const_i32
f8422f52 1446#endif
6ddbc6e4
PB
1447
1448#if TCG_TARGET_REG_BITS == 32
1449#define tcg_gen_addi_ptr tcg_gen_addi_i32
1450#else /* TCG_TARGET_REG_BITS == 32 */
1451#define tcg_gen_addi_ptr tcg_gen_addi_i64
1452#endif /* TCG_TARGET_REG_BITS != 32 */
1453