2 * Tiny Code Generator for QEMU
4 * Copyright (c) 2008 Fabrice Bellard
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
26 #ifndef CONFIG_NO_DYNGEN_OP
27 /* legacy dyngen operations */
31 int gen_new_label(void);
33 static inline void tcg_gen_op1(int opc, TCGv arg1)
36 *gen_opparam_ptr++ = GET_TCGV(arg1);
39 static inline void tcg_gen_op1i(int opc, TCGArg arg1)
42 *gen_opparam_ptr++ = arg1;
45 static inline void tcg_gen_op2(int opc, TCGv arg1, TCGv arg2)
48 *gen_opparam_ptr++ = GET_TCGV(arg1);
49 *gen_opparam_ptr++ = GET_TCGV(arg2);
52 static inline void tcg_gen_op2i(int opc, TCGv arg1, TCGArg arg2)
55 *gen_opparam_ptr++ = GET_TCGV(arg1);
56 *gen_opparam_ptr++ = arg2;
59 static inline void tcg_gen_op3(int opc, TCGv arg1, TCGv arg2, TCGv arg3)
62 *gen_opparam_ptr++ = GET_TCGV(arg1);
63 *gen_opparam_ptr++ = GET_TCGV(arg2);
64 *gen_opparam_ptr++ = GET_TCGV(arg3);
67 static inline void tcg_gen_op3i(int opc, TCGv arg1, TCGv arg2, TCGArg arg3)
70 *gen_opparam_ptr++ = GET_TCGV(arg1);
71 *gen_opparam_ptr++ = GET_TCGV(arg2);
72 *gen_opparam_ptr++ = arg3;
75 static inline void tcg_gen_op4(int opc, TCGv arg1, TCGv arg2, TCGv arg3,
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);
85 static inline void tcg_gen_op4i(int opc, TCGv arg1, TCGv arg2, TCGv arg3,
89 *gen_opparam_ptr++ = GET_TCGV(arg1);
90 *gen_opparam_ptr++ = GET_TCGV(arg2);
91 *gen_opparam_ptr++ = GET_TCGV(arg3);
92 *gen_opparam_ptr++ = arg4;
95 static inline void tcg_gen_op4ii(int opc, TCGv arg1, TCGv arg2, TCGArg arg3,
99 *gen_opparam_ptr++ = GET_TCGV(arg1);
100 *gen_opparam_ptr++ = GET_TCGV(arg2);
101 *gen_opparam_ptr++ = arg3;
102 *gen_opparam_ptr++ = arg4;
105 static inline void tcg_gen_op5(int opc, TCGv arg1, TCGv arg2,
106 TCGv arg3, TCGv arg4,
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);
117 static inline void tcg_gen_op5i(int opc, TCGv arg1, TCGv arg2,
118 TCGv arg3, TCGv arg4,
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);
126 *gen_opparam_ptr++ = arg5;
129 static inline void tcg_gen_op6(int opc, TCGv arg1, TCGv arg2,
130 TCGv arg3, TCGv arg4,
131 TCGv arg5, TCGv arg6)
133 *gen_opc_ptr++ = opc;
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);
142 static inline void tcg_gen_op6ii(int opc, TCGv arg1, TCGv arg2,
143 TCGv arg3, TCGv arg4,
144 TCGArg arg5, TCGArg arg6)
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);
151 *gen_opparam_ptr++ = arg5;
152 *gen_opparam_ptr++ = arg6;
155 static inline void gen_set_label(int n)
157 tcg_gen_op1i(INDEX_op_set_label, n);
160 static inline void tcg_gen_br(int label)
162 tcg_gen_op1i(INDEX_op_br, label);
165 static inline void tcg_gen_mov_i32(TCGv ret, TCGv arg)
167 tcg_gen_op2(INDEX_op_mov_i32, ret, arg);
170 static inline void tcg_gen_movi_i32(TCGv ret, int32_t arg)
172 tcg_gen_op2i(INDEX_op_movi_i32, ret, arg);
176 #define TCG_HELPER_CALL_FLAGS 0
178 static inline void tcg_gen_helper_0_0(void *func)
180 tcg_gen_call(&tcg_ctx,
181 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
185 static inline void tcg_gen_helper_0_1(void *func, TCGv arg)
187 tcg_gen_call(&tcg_ctx,
188 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
192 static inline void tcg_gen_helper_0_2(void *func, TCGv arg1, TCGv arg2)
197 tcg_gen_call(&tcg_ctx,
198 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
202 static inline void tcg_gen_helper_0_4(void *func, TCGv arg1, TCGv arg2,
203 TCGv arg3, TCGv arg4)
210 tcg_gen_call(&tcg_ctx,
211 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
215 static inline void tcg_gen_helper_1_0(void *func, TCGv ret)
217 tcg_gen_call(&tcg_ctx,
218 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
222 static inline void tcg_gen_helper_1_1(void *func, TCGv ret, TCGv arg1)
224 tcg_gen_call(&tcg_ctx,
225 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
229 static inline void tcg_gen_helper_1_2(void *func, TCGv ret,
230 TCGv arg1, TCGv arg2)
235 tcg_gen_call(&tcg_ctx,
236 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
240 static inline void tcg_gen_helper_1_3(void *func, TCGv ret,
241 TCGv arg1, TCGv arg2, TCGv arg3)
247 tcg_gen_call(&tcg_ctx,
248 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
252 static inline void tcg_gen_helper_1_4(void *func, TCGv ret,
253 TCGv arg1, TCGv arg2, TCGv arg3,
261 tcg_gen_call(&tcg_ctx,
262 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
268 static inline void tcg_gen_ld8u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
270 tcg_gen_op3i(INDEX_op_ld8u_i32, ret, arg2, offset);
273 static inline void tcg_gen_ld8s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
275 tcg_gen_op3i(INDEX_op_ld8s_i32, ret, arg2, offset);
278 static inline void tcg_gen_ld16u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
280 tcg_gen_op3i(INDEX_op_ld16u_i32, ret, arg2, offset);
283 static inline void tcg_gen_ld16s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
285 tcg_gen_op3i(INDEX_op_ld16s_i32, ret, arg2, offset);
288 static inline void tcg_gen_ld_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
290 tcg_gen_op3i(INDEX_op_ld_i32, ret, arg2, offset);
293 static inline void tcg_gen_st8_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
295 tcg_gen_op3i(INDEX_op_st8_i32, arg1, arg2, offset);
298 static inline void tcg_gen_st16_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
300 tcg_gen_op3i(INDEX_op_st16_i32, arg1, arg2, offset);
303 static inline void tcg_gen_st_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
305 tcg_gen_op3i(INDEX_op_st_i32, arg1, arg2, offset);
308 static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2)
310 tcg_gen_op3(INDEX_op_add_i32, ret, arg1, arg2);
313 static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2)
315 /* some cases can be optimized here */
317 tcg_gen_mov_i32(ret, arg1);
319 tcg_gen_add_i32(ret, arg1, tcg_const_i32(arg2));
323 static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2)
325 tcg_gen_op3(INDEX_op_sub_i32, ret, arg1, arg2);
328 static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2)
330 /* some cases can be optimized here */
332 tcg_gen_mov_i32(ret, arg1);
334 tcg_gen_sub_i32(ret, arg1, tcg_const_i32(arg2));
338 static inline void tcg_gen_and_i32(TCGv ret, TCGv arg1, TCGv arg2)
340 tcg_gen_op3(INDEX_op_and_i32, ret, arg1, arg2);
343 static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2)
345 /* some cases can be optimized here */
347 tcg_gen_movi_i32(ret, 0);
348 } else if (arg2 == 0xffffffff) {
349 tcg_gen_mov_i32(ret, arg1);
351 tcg_gen_and_i32(ret, arg1, tcg_const_i32(arg2));
355 static inline void tcg_gen_or_i32(TCGv ret, TCGv arg1, TCGv arg2)
357 tcg_gen_op3(INDEX_op_or_i32, ret, arg1, arg2);
360 static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2)
362 /* some cases can be optimized here */
363 if (arg2 == 0xffffffff) {
364 tcg_gen_movi_i32(ret, 0xffffffff);
365 } else if (arg2 == 0) {
366 tcg_gen_mov_i32(ret, arg1);
368 tcg_gen_or_i32(ret, arg1, tcg_const_i32(arg2));
372 static inline void tcg_gen_xor_i32(TCGv ret, TCGv arg1, TCGv arg2)
374 tcg_gen_op3(INDEX_op_xor_i32, ret, arg1, arg2);
377 static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2)
379 /* some cases can be optimized here */
381 tcg_gen_mov_i32(ret, arg1);
383 tcg_gen_xor_i32(ret, arg1, tcg_const_i32(arg2));
387 static inline void tcg_gen_shl_i32(TCGv ret, TCGv arg1, TCGv arg2)
389 tcg_gen_op3(INDEX_op_shl_i32, ret, arg1, arg2);
392 static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2)
394 tcg_gen_shl_i32(ret, arg1, tcg_const_i32(arg2));
397 static inline void tcg_gen_shr_i32(TCGv ret, TCGv arg1, TCGv arg2)
399 tcg_gen_op3(INDEX_op_shr_i32, ret, arg1, arg2);
402 static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2)
404 tcg_gen_shr_i32(ret, arg1, tcg_const_i32(arg2));
407 static inline void tcg_gen_sar_i32(TCGv ret, TCGv arg1, TCGv arg2)
409 tcg_gen_op3(INDEX_op_sar_i32, ret, arg1, arg2);
412 static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2)
414 tcg_gen_sar_i32(ret, arg1, tcg_const_i32(arg2));
417 static inline void tcg_gen_brcond_i32(int cond, TCGv arg1, TCGv arg2,
420 tcg_gen_op4ii(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
423 static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2)
425 tcg_gen_op3(INDEX_op_mul_i32, ret, arg1, arg2);
428 #ifdef TCG_TARGET_HAS_div_i32
429 static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
431 tcg_gen_op3(INDEX_op_div_i32, ret, arg1, arg2);
434 static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
436 tcg_gen_op3(INDEX_op_rem_i32, ret, arg1, arg2);
439 static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
441 tcg_gen_op3(INDEX_op_divu_i32, ret, arg1, arg2);
444 static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
446 tcg_gen_op3(INDEX_op_remu_i32, ret, arg1, arg2);
449 static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
452 t0 = tcg_temp_new(TCG_TYPE_I32);
453 tcg_gen_sari_i32(t0, arg1, 31);
454 tcg_gen_op5(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
457 static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
460 t0 = tcg_temp_new(TCG_TYPE_I32);
461 tcg_gen_sari_i32(t0, arg1, 31);
462 tcg_gen_op5(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
465 static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
468 t0 = tcg_temp_new(TCG_TYPE_I32);
469 tcg_gen_movi_i32(t0, 0);
470 tcg_gen_op5(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
473 static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
476 t0 = tcg_temp_new(TCG_TYPE_I32);
477 tcg_gen_movi_i32(t0, 0);
478 tcg_gen_op5(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
482 #if TCG_TARGET_REG_BITS == 32
484 static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
486 tcg_gen_mov_i32(ret, arg);
487 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
490 static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
492 tcg_gen_movi_i32(ret, arg);
493 tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
496 static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
498 tcg_gen_ld8u_i32(ret, arg2, offset);
499 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
502 static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
504 tcg_gen_ld8s_i32(ret, arg2, offset);
505 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
508 static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
510 tcg_gen_ld16u_i32(ret, arg2, offset);
511 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
514 static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
516 tcg_gen_ld16s_i32(ret, arg2, offset);
517 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
520 static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
522 tcg_gen_ld_i32(ret, arg2, offset);
523 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
526 static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
528 tcg_gen_ld_i32(ret, arg2, offset);
529 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
532 static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
534 /* since arg2 and ret have different types, they cannot be the
536 #ifdef TCG_TARGET_WORDS_BIGENDIAN
537 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
538 tcg_gen_ld_i32(ret, arg2, offset + 4);
540 tcg_gen_ld_i32(ret, arg2, offset);
541 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
545 static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
547 tcg_gen_st8_i32(arg1, arg2, offset);
550 static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
552 tcg_gen_st16_i32(arg1, arg2, offset);
555 static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
557 tcg_gen_st_i32(arg1, arg2, offset);
560 static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
562 #ifdef TCG_TARGET_WORDS_BIGENDIAN
563 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
564 tcg_gen_st_i32(arg1, arg2, offset + 4);
566 tcg_gen_st_i32(arg1, arg2, offset);
567 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
571 static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
573 tcg_gen_op6(INDEX_op_add2_i32, ret, TCGV_HIGH(ret),
574 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
577 static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
579 tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
582 static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
584 tcg_gen_op6(INDEX_op_sub2_i32, ret, TCGV_HIGH(ret),
585 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
588 static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
590 tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
593 static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
595 tcg_gen_and_i32(ret, arg1, arg2);
596 tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
599 static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
601 tcg_gen_andi_i32(ret, arg1, arg2);
602 tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
605 static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
607 tcg_gen_or_i32(ret, arg1, arg2);
608 tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
611 static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
613 tcg_gen_ori_i32(ret, arg1, arg2);
614 tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
617 static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
619 tcg_gen_xor_i32(ret, arg1, arg2);
620 tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
623 static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
625 tcg_gen_xori_i32(ret, arg1, arg2);
626 tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
629 /* XXX: use generic code when basic block handling is OK or CPU
630 specific code (x86) */
631 static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
633 tcg_gen_helper_1_2(tcg_helper_shl_i64, ret, arg1, arg2);
636 static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
638 tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
641 static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
643 tcg_gen_helper_1_2(tcg_helper_shr_i64, ret, arg1, arg2);
646 static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
648 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
651 static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
653 tcg_gen_helper_1_2(tcg_helper_sar_i64, ret, arg1, arg2);
656 static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
658 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
661 static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
664 tcg_gen_op6ii(INDEX_op_brcond2_i32,
665 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2),
669 static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
673 t0 = tcg_temp_new(TCG_TYPE_I64);
674 t1 = tcg_temp_new(TCG_TYPE_I32);
676 tcg_gen_op4(INDEX_op_mulu2_i32, t0, TCGV_HIGH(t0), arg1, arg2);
678 tcg_gen_mul_i32(t1, arg1, TCGV_HIGH(arg2));
679 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
680 tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), arg2);
681 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
683 tcg_gen_mov_i64(ret, t0);
686 static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
688 tcg_gen_helper_1_2(tcg_helper_div_i64, ret, arg1, arg2);
691 static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
693 tcg_gen_helper_1_2(tcg_helper_rem_i64, ret, arg1, arg2);
696 static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
698 tcg_gen_helper_1_2(tcg_helper_divu_i64, ret, arg1, arg2);
701 static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
703 tcg_gen_helper_1_2(tcg_helper_remu_i64, ret, arg1, arg2);
708 static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
710 tcg_gen_op2(INDEX_op_mov_i64, ret, arg);
713 static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
715 tcg_gen_op2i(INDEX_op_movi_i64, ret, arg);
718 static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2,
719 tcg_target_long offset)
721 tcg_gen_op3i(INDEX_op_ld8u_i64, ret, arg2, offset);
724 static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2,
725 tcg_target_long offset)
727 tcg_gen_op3i(INDEX_op_ld8s_i64, ret, arg2, offset);
730 static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2,
731 tcg_target_long offset)
733 tcg_gen_op3i(INDEX_op_ld16u_i64, ret, arg2, offset);
736 static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2,
737 tcg_target_long offset)
739 tcg_gen_op3i(INDEX_op_ld16s_i64, ret, arg2, offset);
742 static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2,
743 tcg_target_long offset)
745 tcg_gen_op3i(INDEX_op_ld32u_i64, ret, arg2, offset);
748 static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2,
749 tcg_target_long offset)
751 tcg_gen_op3i(INDEX_op_ld32s_i64, ret, arg2, offset);
754 static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
756 tcg_gen_op3i(INDEX_op_ld_i64, ret, arg2, offset);
759 static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2,
760 tcg_target_long offset)
762 tcg_gen_op3i(INDEX_op_st8_i64, arg1, arg2, offset);
765 static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2,
766 tcg_target_long offset)
768 tcg_gen_op3i(INDEX_op_st16_i64, arg1, arg2, offset);
771 static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2,
772 tcg_target_long offset)
774 tcg_gen_op3i(INDEX_op_st32_i64, arg1, arg2, offset);
777 static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
779 tcg_gen_op3i(INDEX_op_st_i64, arg1, arg2, offset);
782 static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
784 tcg_gen_op3(INDEX_op_add_i64, ret, arg1, arg2);
787 static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
789 tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
792 static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
794 tcg_gen_op3(INDEX_op_sub_i64, ret, arg1, arg2);
797 static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
799 tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
802 static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
804 tcg_gen_op3(INDEX_op_and_i64, ret, arg1, arg2);
807 static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
809 tcg_gen_and_i64(ret, arg1, tcg_const_i64(arg2));
812 static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
814 tcg_gen_op3(INDEX_op_or_i64, ret, arg1, arg2);
817 static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
819 tcg_gen_or_i64(ret, arg1, tcg_const_i64(arg2));
822 static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
824 tcg_gen_op3(INDEX_op_xor_i64, ret, arg1, arg2);
827 static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
829 tcg_gen_xor_i64(ret, arg1, tcg_const_i64(arg2));
832 static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
834 tcg_gen_op3(INDEX_op_shl_i64, ret, arg1, arg2);
837 static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
839 tcg_gen_shl_i64(ret, arg1, tcg_const_i64(arg2));
842 static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
844 tcg_gen_op3(INDEX_op_shr_i64, ret, arg1, arg2);
847 static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
849 tcg_gen_shr_i64(ret, arg1, tcg_const_i64(arg2));
852 static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
854 tcg_gen_op3(INDEX_op_sar_i64, ret, arg1, arg2);
857 static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
859 tcg_gen_sar_i64(ret, arg1, tcg_const_i64(arg2));
862 static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
865 tcg_gen_op4ii(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
868 static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
870 tcg_gen_op3(INDEX_op_mul_i64, ret, arg1, arg2);
873 #ifdef TCG_TARGET_HAS_div_i64
874 static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
876 tcg_gen_op3(INDEX_op_div_i64, ret, arg1, arg2);
879 static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
881 tcg_gen_op3(INDEX_op_rem_i64, ret, arg1, arg2);
884 static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
886 tcg_gen_op3(INDEX_op_divu_i64, ret, arg1, arg2);
889 static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
891 tcg_gen_op3(INDEX_op_remu_i64, ret, arg1, arg2);
894 static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
897 t0 = tcg_temp_new(TCG_TYPE_I64);
898 tcg_gen_sari_i64(t0, arg1, 63);
899 tcg_gen_op5(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
902 static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
905 t0 = tcg_temp_new(TCG_TYPE_I64);
906 tcg_gen_sari_i64(t0, arg1, 63);
907 tcg_gen_op5(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
910 static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
913 t0 = tcg_temp_new(TCG_TYPE_I64);
914 tcg_gen_movi_i64(t0, 0);
915 tcg_gen_op5(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
918 static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
921 t0 = tcg_temp_new(TCG_TYPE_I64);
922 tcg_gen_movi_i64(t0, 0);
923 tcg_gen_op5(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
929 /***************************************/
930 /* optional operations */
932 static inline void tcg_gen_ext8s_i32(TCGv ret, TCGv arg)
934 #ifdef TCG_TARGET_HAS_ext8s_i32
935 tcg_gen_op2(INDEX_op_ext8s_i32, ret, arg);
937 tcg_gen_shli_i32(ret, arg, 24);
938 tcg_gen_sari_i32(ret, ret, 24);
942 static inline void tcg_gen_ext16s_i32(TCGv ret, TCGv arg)
944 #ifdef TCG_TARGET_HAS_ext16s_i32
945 tcg_gen_op2(INDEX_op_ext16s_i32, ret, arg);
947 tcg_gen_shli_i32(ret, arg, 16);
948 tcg_gen_sari_i32(ret, ret, 16);
952 /* Note: we assume the two high bytes are set to zero */
953 static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg)
955 #ifdef TCG_TARGET_HAS_bswap16_i32
956 tcg_gen_op2(INDEX_op_bswap16_i32, ret, arg);
959 t0 = tcg_temp_new(TCG_TYPE_I32);
960 t1 = tcg_temp_new(TCG_TYPE_I32);
962 tcg_gen_shri_i32(t0, arg, 8);
963 tcg_gen_andi_i32(t1, arg, 0x000000ff);
964 tcg_gen_shli_i32(t1, t1, 8);
965 tcg_gen_or_i32(ret, t0, t1);
969 static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg)
971 #ifdef TCG_TARGET_HAS_bswap_i32
972 tcg_gen_op2(INDEX_op_bswap_i32, ret, arg);
975 t0 = tcg_temp_new(TCG_TYPE_I32);
976 t1 = tcg_temp_new(TCG_TYPE_I32);
978 tcg_gen_shli_i32(t0, arg, 24);
980 tcg_gen_andi_i32(t1, arg, 0x0000ff00);
981 tcg_gen_shli_i32(t1, t1, 8);
982 tcg_gen_or_i32(t0, t0, t1);
984 tcg_gen_shri_i32(t1, arg, 8);
985 tcg_gen_andi_i32(t1, t1, 0x0000ff00);
986 tcg_gen_or_i32(t0, t0, t1);
988 tcg_gen_shri_i32(t1, arg, 24);
989 tcg_gen_or_i32(ret, t0, t1);
993 #if TCG_TARGET_REG_BITS == 32
994 static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
996 tcg_gen_ext8s_i32(ret, arg);
997 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1000 static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
1002 tcg_gen_ext16s_i32(ret, arg);
1003 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1006 static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
1008 tcg_gen_mov_i32(ret, arg);
1009 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1012 static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
1014 tcg_gen_mov_i32(ret, arg);
1017 static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
1019 tcg_gen_mov_i32(ret, arg);
1020 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1023 static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
1025 tcg_gen_mov_i32(ret, arg);
1026 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1029 static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
1032 t0 = tcg_temp_new(TCG_TYPE_I32);
1033 t1 = tcg_temp_new(TCG_TYPE_I32);
1035 tcg_gen_bswap_i32(t0, arg);
1036 tcg_gen_bswap_i32(t1, TCGV_HIGH(arg));
1037 tcg_gen_mov_i32(ret, t1);
1038 tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
1042 static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
1044 #ifdef TCG_TARGET_HAS_ext8s_i64
1045 tcg_gen_op2(INDEX_op_ext8s_i64, ret, arg);
1047 tcg_gen_shli_i64(ret, arg, 56);
1048 tcg_gen_sari_i64(ret, ret, 56);
1052 static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
1054 #ifdef TCG_TARGET_HAS_ext16s_i64
1055 tcg_gen_op2(INDEX_op_ext16s_i64, ret, arg);
1057 tcg_gen_shli_i64(ret, arg, 48);
1058 tcg_gen_sari_i64(ret, ret, 48);
1062 static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
1064 #ifdef TCG_TARGET_HAS_ext32s_i64
1065 tcg_gen_op2(INDEX_op_ext32s_i64, ret, arg);
1067 tcg_gen_shli_i64(ret, arg, 32);
1068 tcg_gen_sari_i64(ret, ret, 32);
1072 /* Note: we assume the target supports move between 32 and 64 bit
1073 registers. This will probably break MIPS64 targets. */
1074 static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
1076 tcg_gen_mov_i32(ret, arg);
1079 /* Note: we assume the target supports move between 32 and 64 bit
1081 static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
1083 tcg_gen_andi_i64(ret, arg, 0xffffffff);
1086 /* Note: we assume the target supports move between 32 and 64 bit
1088 static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
1090 tcg_gen_ext32s_i64(ret, arg);
1093 static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
1095 #ifdef TCG_TARGET_HAS_bswap_i64
1096 tcg_gen_op2(INDEX_op_bswap_i64, ret, arg);
1099 t0 = tcg_temp_new(TCG_TYPE_I32);
1100 t1 = tcg_temp_new(TCG_TYPE_I32);
1102 tcg_gen_shli_i64(t0, arg, 56);
1104 tcg_gen_andi_i64(t1, arg, 0x0000ff00);
1105 tcg_gen_shli_i64(t1, t1, 40);
1106 tcg_gen_or_i64(t0, t0, t1);
1108 tcg_gen_andi_i64(t1, arg, 0x00ff0000);
1109 tcg_gen_shli_i64(t1, t1, 24);
1110 tcg_gen_or_i64(t0, t0, t1);
1112 tcg_gen_andi_i64(t1, arg, 0xff000000);
1113 tcg_gen_shli_i64(t1, t1, 8);
1114 tcg_gen_or_i64(t0, t0, t1);
1116 tcg_gen_shri_i64(t1, arg, 8);
1117 tcg_gen_andi_i64(t1, t1, 0xff000000);
1118 tcg_gen_or_i64(t0, t0, t1);
1120 tcg_gen_shri_i64(t1, arg, 24);
1121 tcg_gen_andi_i64(t1, t1, 0x00ff0000);
1122 tcg_gen_or_i64(t0, t0, t1);
1124 tcg_gen_shri_i64(t1, arg, 40);
1125 tcg_gen_andi_i64(t1, t1, 0x0000ff00);
1126 tcg_gen_or_i64(t0, t0, t1);
1128 tcg_gen_shri_i64(t1, arg, 56);
1129 tcg_gen_or_i64(ret, t0, t1);
1136 static inline void tcg_gen_discard_i32(TCGv arg)
1138 tcg_gen_op1(INDEX_op_discard, arg);
1141 #if TCG_TARGET_REG_BITS == 32
1142 static inline void tcg_gen_discard_i64(TCGv arg)
1144 tcg_gen_discard_i32(arg);
1145 tcg_gen_discard_i32(TCGV_HIGH(arg));
1148 static inline void tcg_gen_discard_i64(TCGv arg)
1150 tcg_gen_op1(INDEX_op_discard, arg);
1154 /***************************************/
1155 static inline void tcg_gen_macro_2(TCGv ret0, TCGv ret1, int macro_id)
1157 tcg_gen_op3i(INDEX_op_macro_2, ret0, ret1, macro_id);
1160 /***************************************/
1161 /* QEMU specific operations. Their type depend on the QEMU CPU
1163 #ifndef TARGET_LONG_BITS
1164 #error must include QEMU headers
1167 static inline void tcg_gen_exit_tb(tcg_target_long val)
1169 tcg_gen_op1i(INDEX_op_exit_tb, val);
1172 static inline void tcg_gen_goto_tb(int idx)
1174 tcg_gen_op1i(INDEX_op_goto_tb, idx);
1177 #if TCG_TARGET_REG_BITS == 32
1178 static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
1180 #if TARGET_LONG_BITS == 32
1181 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
1183 tcg_gen_op4i(INDEX_op_qemu_ld8u, ret, addr, TCGV_HIGH(addr), mem_index);
1184 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1188 static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
1190 #if TARGET_LONG_BITS == 32
1191 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
1193 tcg_gen_op4i(INDEX_op_qemu_ld8s, ret, addr, TCGV_HIGH(addr), mem_index);
1194 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1198 static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
1200 #if TARGET_LONG_BITS == 32
1201 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
1203 tcg_gen_op4i(INDEX_op_qemu_ld16u, ret, addr, TCGV_HIGH(addr), mem_index);
1204 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1208 static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
1210 #if TARGET_LONG_BITS == 32
1211 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
1213 tcg_gen_op4i(INDEX_op_qemu_ld16s, ret, addr, TCGV_HIGH(addr), mem_index);
1214 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1218 static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
1220 #if TARGET_LONG_BITS == 32
1221 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1223 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1224 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1228 static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
1230 #if TARGET_LONG_BITS == 32
1231 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1233 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1234 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1238 static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
1240 #if TARGET_LONG_BITS == 32
1241 tcg_gen_op4i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), addr, mem_index);
1243 tcg_gen_op5i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret),
1244 addr, TCGV_HIGH(addr), mem_index);
1248 static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
1250 #if TARGET_LONG_BITS == 32
1251 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
1253 tcg_gen_op4i(INDEX_op_qemu_st8, arg, addr, TCGV_HIGH(addr), mem_index);
1257 static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
1259 #if TARGET_LONG_BITS == 32
1260 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
1262 tcg_gen_op4i(INDEX_op_qemu_st16, arg, addr, TCGV_HIGH(addr), mem_index);
1266 static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
1268 #if TARGET_LONG_BITS == 32
1269 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
1271 tcg_gen_op4i(INDEX_op_qemu_st32, arg, addr, TCGV_HIGH(addr), mem_index);
1275 static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
1277 #if TARGET_LONG_BITS == 32
1278 tcg_gen_op4i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), addr, mem_index);
1280 tcg_gen_op5i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg),
1281 addr, TCGV_HIGH(addr), mem_index);
1285 #define tcg_gen_ld_ptr tcg_gen_ld_i32
1286 #define tcg_gen_discard_ptr tcg_gen_discard_i32
1288 #else /* TCG_TARGET_REG_BITS == 32 */
1290 static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
1292 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
1295 static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
1297 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
1300 static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
1302 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
1305 static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
1307 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
1310 static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
1312 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1315 static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
1317 tcg_gen_op3i(INDEX_op_qemu_ld32s, ret, addr, mem_index);
1320 static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
1322 tcg_gen_op3i(INDEX_op_qemu_ld64, ret, addr, mem_index);
1325 static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
1327 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
1330 static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
1332 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
1335 static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
1337 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
1340 static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
1342 tcg_gen_op3i(INDEX_op_qemu_st64, arg, addr, mem_index);
1345 #define tcg_gen_ld_ptr tcg_gen_ld_i64
1346 #define tcg_gen_discard_ptr tcg_gen_discard_i64
1348 #endif /* TCG_TARGET_REG_BITS != 32 */
1350 #if TARGET_LONG_BITS == 64
1351 #define TCG_TYPE_TL TCG_TYPE_I64
1352 #define tcg_gen_movi_tl tcg_gen_movi_i64
1353 #define tcg_gen_mov_tl tcg_gen_mov_i64
1354 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
1355 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
1356 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
1357 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
1358 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
1359 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
1360 #define tcg_gen_ld_tl tcg_gen_ld_i64
1361 #define tcg_gen_st8_tl tcg_gen_st8_i64
1362 #define tcg_gen_st16_tl tcg_gen_st16_i64
1363 #define tcg_gen_st32_tl tcg_gen_st32_i64
1364 #define tcg_gen_st_tl tcg_gen_st_i64
1365 #define tcg_gen_add_tl tcg_gen_add_i64
1366 #define tcg_gen_addi_tl tcg_gen_addi_i64
1367 #define tcg_gen_sub_tl tcg_gen_sub_i64
1368 #define tcg_gen_subi_tl tcg_gen_subi_i64
1369 #define tcg_gen_and_tl tcg_gen_and_i64
1370 #define tcg_gen_andi_tl tcg_gen_andi_i64
1371 #define tcg_gen_or_tl tcg_gen_or_i64
1372 #define tcg_gen_ori_tl tcg_gen_ori_i64
1373 #define tcg_gen_xor_tl tcg_gen_xor_i64
1374 #define tcg_gen_xori_tl tcg_gen_xori_i64
1375 #define tcg_gen_shl_tl tcg_gen_shl_i64
1376 #define tcg_gen_shli_tl tcg_gen_shli_i64
1377 #define tcg_gen_shr_tl tcg_gen_shr_i64
1378 #define tcg_gen_shri_tl tcg_gen_shri_i64
1379 #define tcg_gen_sar_tl tcg_gen_sar_i64
1380 #define tcg_gen_sari_tl tcg_gen_sari_i64
1381 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
1382 #define tcg_gen_discard_tl tcg_gen_discard_i64
1383 #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
1384 #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
1385 #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
1386 #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
1387 #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
1388 #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
1389 #define tcg_const_tl tcg_const_i64
1391 #define TCG_TYPE_TL TCG_TYPE_I32
1392 #define tcg_gen_movi_tl tcg_gen_movi_i32
1393 #define tcg_gen_mov_tl tcg_gen_mov_i32
1394 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
1395 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
1396 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
1397 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
1398 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
1399 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
1400 #define tcg_gen_ld_tl tcg_gen_ld_i32
1401 #define tcg_gen_st8_tl tcg_gen_st8_i32
1402 #define tcg_gen_st16_tl tcg_gen_st16_i32
1403 #define tcg_gen_st32_tl tcg_gen_st_i32
1404 #define tcg_gen_st_tl tcg_gen_st_i32
1405 #define tcg_gen_add_tl tcg_gen_add_i32
1406 #define tcg_gen_addi_tl tcg_gen_addi_i32
1407 #define tcg_gen_sub_tl tcg_gen_sub_i32
1408 #define tcg_gen_subi_tl tcg_gen_subi_i32
1409 #define tcg_gen_and_tl tcg_gen_and_i32
1410 #define tcg_gen_andi_tl tcg_gen_andi_i32
1411 #define tcg_gen_or_tl tcg_gen_or_i32
1412 #define tcg_gen_ori_tl tcg_gen_ori_i32
1413 #define tcg_gen_xor_tl tcg_gen_xor_i32
1414 #define tcg_gen_xori_tl tcg_gen_xori_i32
1415 #define tcg_gen_shl_tl tcg_gen_shl_i32
1416 #define tcg_gen_shli_tl tcg_gen_shli_i32
1417 #define tcg_gen_shr_tl tcg_gen_shr_i32
1418 #define tcg_gen_shri_tl tcg_gen_shri_i32
1419 #define tcg_gen_sar_tl tcg_gen_sar_i32
1420 #define tcg_gen_sari_tl tcg_gen_sari_i32
1421 #define tcg_gen_brcond_tl tcg_gen_brcond_i32
1422 #define tcg_gen_discard_tl tcg_gen_discard_i32
1423 #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
1424 #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
1425 #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
1426 #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
1427 #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
1428 #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
1429 #define tcg_const_tl tcg_const_i32
1432 #if TCG_TARGET_REG_BITS == 32
1433 #define tcg_gen_addi_ptr tcg_gen_addi_i32
1434 #else /* TCG_TARGET_REG_BITS == 32 */
1435 #define tcg_gen_addi_ptr tcg_gen_addi_i64
1436 #endif /* TCG_TARGET_REG_BITS != 32 */