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 #ifdef CONFIG_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 if (GET_TCGV(ret) != GET_TCGV(arg))
168 tcg_gen_op2(INDEX_op_mov_i32, ret, arg);
171 static inline void tcg_gen_movi_i32(TCGv ret, int32_t arg)
173 tcg_gen_op2i(INDEX_op_movi_i32, ret, arg);
177 #define TCG_HELPER_CALL_FLAGS 0
179 static inline void tcg_gen_helper_0_0(void *func)
182 t0 = tcg_const_ptr((tcg_target_long)func);
183 tcg_gen_call(&tcg_ctx,
184 t0, TCG_HELPER_CALL_FLAGS,
189 static inline void tcg_gen_helper_0_1(void *func, TCGv arg)
192 t0 = tcg_const_ptr((tcg_target_long)func);
193 tcg_gen_call(&tcg_ctx,
194 t0, TCG_HELPER_CALL_FLAGS,
199 static inline void tcg_gen_helper_0_2(void *func, TCGv arg1, TCGv arg2)
205 t0 = tcg_const_ptr((tcg_target_long)func);
206 tcg_gen_call(&tcg_ctx,
207 t0, TCG_HELPER_CALL_FLAGS,
212 static inline void tcg_gen_helper_0_3(void *func,
213 TCGv arg1, TCGv arg2, TCGv arg3)
220 t0 = tcg_const_ptr((tcg_target_long)func);
221 tcg_gen_call(&tcg_ctx,
222 t0, TCG_HELPER_CALL_FLAGS,
227 static inline void tcg_gen_helper_0_4(void *func, TCGv arg1, TCGv arg2,
228 TCGv arg3, TCGv arg4)
236 t0 = tcg_const_ptr((tcg_target_long)func);
237 tcg_gen_call(&tcg_ctx,
238 t0, TCG_HELPER_CALL_FLAGS,
243 static inline void tcg_gen_helper_1_0(void *func, TCGv ret)
246 t0 = tcg_const_ptr((tcg_target_long)func);
247 tcg_gen_call(&tcg_ctx,
248 t0, TCG_HELPER_CALL_FLAGS,
253 static inline void tcg_gen_helper_1_1(void *func, TCGv ret, TCGv arg1)
256 t0 = tcg_const_ptr((tcg_target_long)func);
257 tcg_gen_call(&tcg_ctx,
258 t0, TCG_HELPER_CALL_FLAGS,
263 static inline void tcg_gen_helper_1_2(void *func, TCGv ret,
264 TCGv arg1, TCGv arg2)
270 t0 = tcg_const_ptr((tcg_target_long)func);
271 tcg_gen_call(&tcg_ctx,
272 t0, TCG_HELPER_CALL_FLAGS,
277 static inline void tcg_gen_helper_1_3(void *func, TCGv ret,
278 TCGv arg1, TCGv arg2, TCGv arg3)
285 t0 = tcg_const_ptr((tcg_target_long)func);
286 tcg_gen_call(&tcg_ctx,
287 t0, TCG_HELPER_CALL_FLAGS,
292 static inline void tcg_gen_helper_1_4(void *func, TCGv ret,
293 TCGv arg1, TCGv arg2, TCGv arg3,
302 t0 = tcg_const_ptr((tcg_target_long)func);
303 tcg_gen_call(&tcg_ctx,
304 t0, TCG_HELPER_CALL_FLAGS,
311 static inline void tcg_gen_ld8u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
313 tcg_gen_op3i(INDEX_op_ld8u_i32, ret, arg2, offset);
316 static inline void tcg_gen_ld8s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
318 tcg_gen_op3i(INDEX_op_ld8s_i32, ret, arg2, offset);
321 static inline void tcg_gen_ld16u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
323 tcg_gen_op3i(INDEX_op_ld16u_i32, ret, arg2, offset);
326 static inline void tcg_gen_ld16s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
328 tcg_gen_op3i(INDEX_op_ld16s_i32, ret, arg2, offset);
331 static inline void tcg_gen_ld_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
333 tcg_gen_op3i(INDEX_op_ld_i32, ret, arg2, offset);
336 static inline void tcg_gen_st8_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
338 tcg_gen_op3i(INDEX_op_st8_i32, arg1, arg2, offset);
341 static inline void tcg_gen_st16_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
343 tcg_gen_op3i(INDEX_op_st16_i32, arg1, arg2, offset);
346 static inline void tcg_gen_st_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
348 tcg_gen_op3i(INDEX_op_st_i32, arg1, arg2, offset);
351 static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2)
353 tcg_gen_op3(INDEX_op_add_i32, ret, arg1, arg2);
356 static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2)
358 /* some cases can be optimized here */
360 tcg_gen_mov_i32(ret, arg1);
362 TCGv t0 = tcg_const_i32(arg2);
363 tcg_gen_add_i32(ret, arg1, t0);
368 static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2)
370 tcg_gen_op3(INDEX_op_sub_i32, ret, arg1, arg2);
373 static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2)
375 /* some cases can be optimized here */
377 tcg_gen_mov_i32(ret, arg1);
379 TCGv t0 = tcg_const_i32(arg2);
380 tcg_gen_sub_i32(ret, arg1, t0);
385 static inline void tcg_gen_and_i32(TCGv ret, TCGv arg1, TCGv arg2)
387 tcg_gen_op3(INDEX_op_and_i32, ret, arg1, arg2);
390 static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2)
392 /* some cases can be optimized here */
394 tcg_gen_movi_i32(ret, 0);
395 } else if (arg2 == 0xffffffff) {
396 tcg_gen_mov_i32(ret, arg1);
398 TCGv t0 = tcg_const_i32(arg2);
399 tcg_gen_and_i32(ret, arg1, t0);
404 static inline void tcg_gen_or_i32(TCGv ret, TCGv arg1, TCGv arg2)
406 tcg_gen_op3(INDEX_op_or_i32, ret, arg1, arg2);
409 static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2)
411 /* some cases can be optimized here */
412 if (arg2 == 0xffffffff) {
413 tcg_gen_movi_i32(ret, 0xffffffff);
414 } else if (arg2 == 0) {
415 tcg_gen_mov_i32(ret, arg1);
417 TCGv t0 = tcg_const_i32(arg2);
418 tcg_gen_or_i32(ret, arg1, t0);
423 static inline void tcg_gen_xor_i32(TCGv ret, TCGv arg1, TCGv arg2)
425 tcg_gen_op3(INDEX_op_xor_i32, ret, arg1, arg2);
428 static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2)
430 /* some cases can be optimized here */
432 tcg_gen_mov_i32(ret, arg1);
434 TCGv t0 = tcg_const_i32(arg2);
435 tcg_gen_xor_i32(ret, arg1, t0);
440 static inline void tcg_gen_shl_i32(TCGv ret, TCGv arg1, TCGv arg2)
442 tcg_gen_op3(INDEX_op_shl_i32, ret, arg1, arg2);
445 static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2)
448 tcg_gen_mov_i32(ret, arg1);
450 TCGv t0 = tcg_const_i32(arg2);
451 tcg_gen_shl_i32(ret, arg1, t0);
456 static inline void tcg_gen_shr_i32(TCGv ret, TCGv arg1, TCGv arg2)
458 tcg_gen_op3(INDEX_op_shr_i32, ret, arg1, arg2);
461 static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2)
464 tcg_gen_mov_i32(ret, arg1);
466 TCGv t0 = tcg_const_i32(arg2);
467 tcg_gen_shr_i32(ret, arg1, t0);
472 static inline void tcg_gen_sar_i32(TCGv ret, TCGv arg1, TCGv arg2)
474 tcg_gen_op3(INDEX_op_sar_i32, ret, arg1, arg2);
477 static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2)
480 tcg_gen_mov_i32(ret, arg1);
482 TCGv t0 = tcg_const_i32(arg2);
483 tcg_gen_sar_i32(ret, arg1, t0);
488 static inline void tcg_gen_brcond_i32(int cond, TCGv arg1, TCGv arg2,
491 tcg_gen_op4ii(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
494 static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2)
496 tcg_gen_op3(INDEX_op_mul_i32, ret, arg1, arg2);
499 static inline void tcg_gen_muli_i32(TCGv ret, TCGv arg1, int32_t arg2)
501 TCGv t0 = tcg_const_i32(arg2);
502 tcg_gen_mul_i32(ret, arg1, t0);
506 #ifdef TCG_TARGET_HAS_div_i32
507 static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
509 tcg_gen_op3(INDEX_op_div_i32, ret, arg1, arg2);
512 static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
514 tcg_gen_op3(INDEX_op_rem_i32, ret, arg1, arg2);
517 static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
519 tcg_gen_op3(INDEX_op_divu_i32, ret, arg1, arg2);
522 static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
524 tcg_gen_op3(INDEX_op_remu_i32, ret, arg1, arg2);
527 static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
530 t0 = tcg_temp_new(TCG_TYPE_I32);
531 tcg_gen_sari_i32(t0, arg1, 31);
532 tcg_gen_op5(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
536 static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
539 t0 = tcg_temp_new(TCG_TYPE_I32);
540 tcg_gen_sari_i32(t0, arg1, 31);
541 tcg_gen_op5(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
545 static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
548 t0 = tcg_temp_new(TCG_TYPE_I32);
549 tcg_gen_movi_i32(t0, 0);
550 tcg_gen_op5(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
554 static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
557 t0 = tcg_temp_new(TCG_TYPE_I32);
558 tcg_gen_movi_i32(t0, 0);
559 tcg_gen_op5(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
564 #if TCG_TARGET_REG_BITS == 32
566 static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
568 if (GET_TCGV(ret) != GET_TCGV(arg)) {
569 tcg_gen_mov_i32(ret, arg);
570 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
574 static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
576 tcg_gen_movi_i32(ret, arg);
577 tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
580 static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
582 tcg_gen_ld8u_i32(ret, arg2, offset);
583 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
586 static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
588 tcg_gen_ld8s_i32(ret, arg2, offset);
589 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
592 static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
594 tcg_gen_ld16u_i32(ret, arg2, offset);
595 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
598 static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
600 tcg_gen_ld16s_i32(ret, arg2, offset);
601 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
604 static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
606 tcg_gen_ld_i32(ret, arg2, offset);
607 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
610 static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
612 tcg_gen_ld_i32(ret, arg2, offset);
613 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
616 static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
618 /* since arg2 and ret have different types, they cannot be the
620 #ifdef TCG_TARGET_WORDS_BIGENDIAN
621 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
622 tcg_gen_ld_i32(ret, arg2, offset + 4);
624 tcg_gen_ld_i32(ret, arg2, offset);
625 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
629 static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
631 tcg_gen_st8_i32(arg1, arg2, offset);
634 static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
636 tcg_gen_st16_i32(arg1, arg2, offset);
639 static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
641 tcg_gen_st_i32(arg1, arg2, offset);
644 static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
646 #ifdef TCG_TARGET_WORDS_BIGENDIAN
647 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
648 tcg_gen_st_i32(arg1, arg2, offset + 4);
650 tcg_gen_st_i32(arg1, arg2, offset);
651 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
655 static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
657 tcg_gen_op6(INDEX_op_add2_i32, ret, TCGV_HIGH(ret),
658 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
661 static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
663 TCGv t0 = tcg_const_i64(arg2);
664 tcg_gen_add_i64(ret, arg1, t0);
668 static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
670 tcg_gen_op6(INDEX_op_sub2_i32, ret, TCGV_HIGH(ret),
671 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
674 static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
676 TCGv t0 = tcg_const_i64(arg2);
677 tcg_gen_sub_i64(ret, arg1, t0);
681 static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
683 tcg_gen_and_i32(ret, arg1, arg2);
684 tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
687 static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
689 tcg_gen_andi_i32(ret, arg1, arg2);
690 tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
693 static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
695 tcg_gen_or_i32(ret, arg1, arg2);
696 tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
699 static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
701 tcg_gen_ori_i32(ret, arg1, arg2);
702 tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
705 static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
707 tcg_gen_xor_i32(ret, arg1, arg2);
708 tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
711 static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
713 tcg_gen_xori_i32(ret, arg1, arg2);
714 tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
717 /* XXX: use generic code when basic block handling is OK or CPU
718 specific code (x86) */
719 static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
721 tcg_gen_helper_1_2(tcg_helper_shl_i64, ret, arg1, arg2);
724 static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
726 tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
729 static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
731 tcg_gen_helper_1_2(tcg_helper_shr_i64, ret, arg1, arg2);
734 static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
736 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
739 static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
741 tcg_gen_helper_1_2(tcg_helper_sar_i64, ret, arg1, arg2);
744 static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
746 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
749 static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
752 tcg_gen_op6ii(INDEX_op_brcond2_i32,
753 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2),
757 static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
761 t0 = tcg_temp_new(TCG_TYPE_I64);
762 t1 = tcg_temp_new(TCG_TYPE_I32);
764 tcg_gen_op4(INDEX_op_mulu2_i32, t0, TCGV_HIGH(t0), arg1, arg2);
766 tcg_gen_mul_i32(t1, arg1, TCGV_HIGH(arg2));
767 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
768 tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), arg2);
769 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
771 tcg_gen_mov_i64(ret, t0);
776 static inline void tcg_gen_muli_i64(TCGv ret, TCGv arg1, int64_t arg2)
778 TCGv t0 = tcg_const_i64(arg2);
779 tcg_gen_mul_i64(ret, arg1, t0);
783 static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
785 tcg_gen_helper_1_2(tcg_helper_div_i64, ret, arg1, arg2);
788 static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
790 tcg_gen_helper_1_2(tcg_helper_rem_i64, ret, arg1, arg2);
793 static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
795 tcg_gen_helper_1_2(tcg_helper_divu_i64, ret, arg1, arg2);
798 static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
800 tcg_gen_helper_1_2(tcg_helper_remu_i64, ret, arg1, arg2);
805 static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
807 if (GET_TCGV(ret) != GET_TCGV(arg))
808 tcg_gen_op2(INDEX_op_mov_i64, ret, arg);
811 static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
813 tcg_gen_op2i(INDEX_op_movi_i64, ret, arg);
816 static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2,
817 tcg_target_long offset)
819 tcg_gen_op3i(INDEX_op_ld8u_i64, ret, arg2, offset);
822 static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2,
823 tcg_target_long offset)
825 tcg_gen_op3i(INDEX_op_ld8s_i64, ret, arg2, offset);
828 static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2,
829 tcg_target_long offset)
831 tcg_gen_op3i(INDEX_op_ld16u_i64, ret, arg2, offset);
834 static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2,
835 tcg_target_long offset)
837 tcg_gen_op3i(INDEX_op_ld16s_i64, ret, arg2, offset);
840 static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2,
841 tcg_target_long offset)
843 tcg_gen_op3i(INDEX_op_ld32u_i64, ret, arg2, offset);
846 static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2,
847 tcg_target_long offset)
849 tcg_gen_op3i(INDEX_op_ld32s_i64, ret, arg2, offset);
852 static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
854 tcg_gen_op3i(INDEX_op_ld_i64, ret, arg2, offset);
857 static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2,
858 tcg_target_long offset)
860 tcg_gen_op3i(INDEX_op_st8_i64, arg1, arg2, offset);
863 static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2,
864 tcg_target_long offset)
866 tcg_gen_op3i(INDEX_op_st16_i64, arg1, arg2, offset);
869 static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2,
870 tcg_target_long offset)
872 tcg_gen_op3i(INDEX_op_st32_i64, arg1, arg2, offset);
875 static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
877 tcg_gen_op3i(INDEX_op_st_i64, arg1, arg2, offset);
880 static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
882 tcg_gen_op3(INDEX_op_add_i64, ret, arg1, arg2);
885 static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
887 TCGv t0 = tcg_const_i64(arg2);
888 tcg_gen_add_i64(ret, arg1, t0);
892 static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
894 tcg_gen_op3(INDEX_op_sub_i64, ret, arg1, arg2);
897 static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
899 TCGv t0 = tcg_const_i64(arg2);
900 tcg_gen_sub_i64(ret, arg1, t0);
904 static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
906 tcg_gen_op3(INDEX_op_and_i64, ret, arg1, arg2);
909 static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
911 TCGv t0 = tcg_const_i64(arg2);
912 tcg_gen_and_i64(ret, arg1, t0);
916 static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
918 tcg_gen_op3(INDEX_op_or_i64, ret, arg1, arg2);
921 static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
923 TCGv t0 = tcg_const_i64(arg2);
924 tcg_gen_or_i64(ret, arg1, t0);
928 static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
930 tcg_gen_op3(INDEX_op_xor_i64, ret, arg1, arg2);
933 static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
935 TCGv t0 = tcg_const_i64(arg2);
936 tcg_gen_xor_i64(ret, arg1, t0);
940 static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
942 tcg_gen_op3(INDEX_op_shl_i64, ret, arg1, arg2);
945 static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
948 tcg_gen_mov_i64(ret, arg1);
950 TCGv t0 = tcg_const_i64(arg2);
951 tcg_gen_shl_i64(ret, arg1, t0);
956 static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
958 tcg_gen_op3(INDEX_op_shr_i64, ret, arg1, arg2);
961 static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
964 tcg_gen_mov_i64(ret, arg1);
966 TCGv t0 = tcg_const_i64(arg2);
967 tcg_gen_shr_i64(ret, arg1, t0);
972 static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
974 tcg_gen_op3(INDEX_op_sar_i64, ret, arg1, arg2);
977 static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
980 tcg_gen_mov_i64(ret, arg1);
982 TCGv t0 = tcg_const_i64(arg2);
983 tcg_gen_sar_i64(ret, arg1, t0);
988 static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
991 tcg_gen_op4ii(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
994 static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
996 tcg_gen_op3(INDEX_op_mul_i64, ret, arg1, arg2);
999 static inline void tcg_gen_muli_i64(TCGv ret, TCGv arg1, int64_t arg2)
1001 TCGv t0 = tcg_const_i64(arg2);
1002 tcg_gen_mul_i64(ret, arg1, t0);
1006 #ifdef TCG_TARGET_HAS_div_i64
1007 static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
1009 tcg_gen_op3(INDEX_op_div_i64, ret, arg1, arg2);
1012 static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
1014 tcg_gen_op3(INDEX_op_rem_i64, ret, arg1, arg2);
1017 static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
1019 tcg_gen_op3(INDEX_op_divu_i64, ret, arg1, arg2);
1022 static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
1024 tcg_gen_op3(INDEX_op_remu_i64, ret, arg1, arg2);
1027 static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
1030 t0 = tcg_temp_new(TCG_TYPE_I64);
1031 tcg_gen_sari_i64(t0, arg1, 63);
1032 tcg_gen_op5(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
1036 static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
1039 t0 = tcg_temp_new(TCG_TYPE_I64);
1040 tcg_gen_sari_i64(t0, arg1, 63);
1041 tcg_gen_op5(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
1045 static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
1048 t0 = tcg_temp_new(TCG_TYPE_I64);
1049 tcg_gen_movi_i64(t0, 0);
1050 tcg_gen_op5(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
1054 static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
1057 t0 = tcg_temp_new(TCG_TYPE_I64);
1058 tcg_gen_movi_i64(t0, 0);
1059 tcg_gen_op5(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
1066 /***************************************/
1067 /* optional operations */
1069 static inline void tcg_gen_ext8s_i32(TCGv ret, TCGv arg)
1071 #ifdef TCG_TARGET_HAS_ext8s_i32
1072 tcg_gen_op2(INDEX_op_ext8s_i32, ret, arg);
1074 tcg_gen_shli_i32(ret, arg, 24);
1075 tcg_gen_sari_i32(ret, ret, 24);
1079 static inline void tcg_gen_ext16s_i32(TCGv ret, TCGv arg)
1081 #ifdef TCG_TARGET_HAS_ext16s_i32
1082 tcg_gen_op2(INDEX_op_ext16s_i32, ret, arg);
1084 tcg_gen_shli_i32(ret, arg, 16);
1085 tcg_gen_sari_i32(ret, ret, 16);
1089 /* These are currently just for convenience.
1090 We assume a target will recognise these automatically . */
1091 static inline void tcg_gen_ext8u_i32(TCGv ret, TCGv arg)
1093 tcg_gen_andi_i32(ret, arg, 0xffu);
1096 static inline void tcg_gen_ext16u_i32(TCGv ret, TCGv arg)
1098 tcg_gen_andi_i32(ret, arg, 0xffffu);
1101 /* Note: we assume the two high bytes are set to zero */
1102 static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg)
1104 #ifdef TCG_TARGET_HAS_bswap16_i32
1105 tcg_gen_op2(INDEX_op_bswap16_i32, ret, arg);
1108 t0 = tcg_temp_new(TCG_TYPE_I32);
1109 t1 = tcg_temp_new(TCG_TYPE_I32);
1111 tcg_gen_shri_i32(t0, arg, 8);
1112 tcg_gen_andi_i32(t1, arg, 0x000000ff);
1113 tcg_gen_shli_i32(t1, t1, 8);
1114 tcg_gen_or_i32(ret, t0, t1);
1120 static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg)
1122 #ifdef TCG_TARGET_HAS_bswap_i32
1123 tcg_gen_op2(INDEX_op_bswap_i32, ret, arg);
1126 t0 = tcg_temp_new(TCG_TYPE_I32);
1127 t1 = tcg_temp_new(TCG_TYPE_I32);
1129 tcg_gen_shli_i32(t0, arg, 24);
1131 tcg_gen_andi_i32(t1, arg, 0x0000ff00);
1132 tcg_gen_shli_i32(t1, t1, 8);
1133 tcg_gen_or_i32(t0, t0, t1);
1135 tcg_gen_shri_i32(t1, arg, 8);
1136 tcg_gen_andi_i32(t1, t1, 0x0000ff00);
1137 tcg_gen_or_i32(t0, t0, t1);
1139 tcg_gen_shri_i32(t1, arg, 24);
1140 tcg_gen_or_i32(ret, t0, t1);
1146 #if TCG_TARGET_REG_BITS == 32
1147 static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
1149 tcg_gen_ext8s_i32(ret, arg);
1150 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1153 static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
1155 tcg_gen_ext16s_i32(ret, arg);
1156 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1159 static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
1161 tcg_gen_mov_i32(ret, arg);
1162 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1165 static inline void tcg_gen_ext8u_i64(TCGv ret, TCGv arg)
1167 tcg_gen_ext8u_i32(ret, arg);
1168 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1171 static inline void tcg_gen_ext16u_i64(TCGv ret, TCGv arg)
1173 tcg_gen_ext16u_i32(ret, arg);
1174 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1177 static inline void tcg_gen_ext32u_i64(TCGv ret, TCGv arg)
1179 tcg_gen_mov_i32(ret, arg);
1180 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1183 static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
1185 tcg_gen_mov_i32(ret, arg);
1188 static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
1190 tcg_gen_mov_i32(ret, arg);
1191 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1194 static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
1196 tcg_gen_mov_i32(ret, arg);
1197 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1200 static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
1203 t0 = tcg_temp_new(TCG_TYPE_I32);
1204 t1 = tcg_temp_new(TCG_TYPE_I32);
1206 tcg_gen_bswap_i32(t0, arg);
1207 tcg_gen_bswap_i32(t1, TCGV_HIGH(arg));
1208 tcg_gen_mov_i32(ret, t1);
1209 tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
1215 static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
1217 #ifdef TCG_TARGET_HAS_ext8s_i64
1218 tcg_gen_op2(INDEX_op_ext8s_i64, ret, arg);
1220 tcg_gen_shli_i64(ret, arg, 56);
1221 tcg_gen_sari_i64(ret, ret, 56);
1225 static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
1227 #ifdef TCG_TARGET_HAS_ext16s_i64
1228 tcg_gen_op2(INDEX_op_ext16s_i64, ret, arg);
1230 tcg_gen_shli_i64(ret, arg, 48);
1231 tcg_gen_sari_i64(ret, ret, 48);
1235 static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
1237 #ifdef TCG_TARGET_HAS_ext32s_i64
1238 tcg_gen_op2(INDEX_op_ext32s_i64, ret, arg);
1240 tcg_gen_shli_i64(ret, arg, 32);
1241 tcg_gen_sari_i64(ret, ret, 32);
1245 static inline void tcg_gen_ext8u_i64(TCGv ret, TCGv arg)
1247 tcg_gen_andi_i64(ret, arg, 0xffu);
1250 static inline void tcg_gen_ext16u_i64(TCGv ret, TCGv arg)
1252 tcg_gen_andi_i64(ret, arg, 0xffffu);
1255 static inline void tcg_gen_ext32u_i64(TCGv ret, TCGv arg)
1257 tcg_gen_andi_i64(ret, arg, 0xffffffffu);
1260 /* Note: we assume the target supports move between 32 and 64 bit
1261 registers. This will probably break MIPS64 targets. */
1262 static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
1264 tcg_gen_mov_i32(ret, arg);
1267 /* Note: we assume the target supports move between 32 and 64 bit
1269 static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
1271 tcg_gen_andi_i64(ret, arg, 0xffffffffu);
1274 /* Note: we assume the target supports move between 32 and 64 bit
1276 static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
1278 tcg_gen_ext32s_i64(ret, arg);
1281 static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
1283 #ifdef TCG_TARGET_HAS_bswap_i64
1284 tcg_gen_op2(INDEX_op_bswap_i64, ret, arg);
1287 t0 = tcg_temp_new(TCG_TYPE_I32);
1288 t1 = tcg_temp_new(TCG_TYPE_I32);
1290 tcg_gen_shli_i64(t0, arg, 56);
1292 tcg_gen_andi_i64(t1, arg, 0x0000ff00);
1293 tcg_gen_shli_i64(t1, t1, 40);
1294 tcg_gen_or_i64(t0, t0, t1);
1296 tcg_gen_andi_i64(t1, arg, 0x00ff0000);
1297 tcg_gen_shli_i64(t1, t1, 24);
1298 tcg_gen_or_i64(t0, t0, t1);
1300 tcg_gen_andi_i64(t1, arg, 0xff000000);
1301 tcg_gen_shli_i64(t1, t1, 8);
1302 tcg_gen_or_i64(t0, t0, t1);
1304 tcg_gen_shri_i64(t1, arg, 8);
1305 tcg_gen_andi_i64(t1, t1, 0xff000000);
1306 tcg_gen_or_i64(t0, t0, t1);
1308 tcg_gen_shri_i64(t1, arg, 24);
1309 tcg_gen_andi_i64(t1, t1, 0x00ff0000);
1310 tcg_gen_or_i64(t0, t0, t1);
1312 tcg_gen_shri_i64(t1, arg, 40);
1313 tcg_gen_andi_i64(t1, t1, 0x0000ff00);
1314 tcg_gen_or_i64(t0, t0, t1);
1316 tcg_gen_shri_i64(t1, arg, 56);
1317 tcg_gen_or_i64(ret, t0, t1);
1325 static inline void tcg_gen_neg_i32(TCGv ret, TCGv arg)
1327 #ifdef TCG_TARGET_HAS_neg_i32
1328 tcg_gen_op2(INDEX_op_neg_i32, ret, arg);
1330 TCGv t0 = tcg_const_i32(0);
1331 tcg_gen_sub_i32(ret, t0, arg);
1336 static inline void tcg_gen_neg_i64(TCGv ret, TCGv arg)
1338 #ifdef TCG_TARGET_HAS_neg_i64
1339 tcg_gen_op2(INDEX_op_neg_i64, ret, arg);
1341 TCGv t0 = tcg_const_i64(0);
1342 tcg_gen_sub_i64(ret, t0, arg);
1347 static inline void tcg_gen_not_i32(TCGv ret, TCGv arg)
1349 tcg_gen_xori_i32(ret, arg, -1);
1352 static inline void tcg_gen_not_i64(TCGv ret, TCGv arg)
1354 tcg_gen_xori_i64(ret, arg, -1);
1357 static inline void tcg_gen_discard_i32(TCGv arg)
1359 tcg_gen_op1(INDEX_op_discard, arg);
1362 #if TCG_TARGET_REG_BITS == 32
1363 static inline void tcg_gen_discard_i64(TCGv arg)
1365 tcg_gen_discard_i32(arg);
1366 tcg_gen_discard_i32(TCGV_HIGH(arg));
1369 static inline void tcg_gen_discard_i64(TCGv arg)
1371 tcg_gen_op1(INDEX_op_discard, arg);
1375 /***************************************/
1376 static inline void tcg_gen_macro_2(TCGv ret0, TCGv ret1, int macro_id)
1378 tcg_gen_op3i(INDEX_op_macro_2, ret0, ret1, macro_id);
1381 /***************************************/
1382 /* QEMU specific operations. Their type depend on the QEMU CPU
1384 #ifndef TARGET_LONG_BITS
1385 #error must include QEMU headers
1388 /* debug info: write the PC of the corresponding QEMU CPU instruction */
1389 static inline void tcg_gen_debug_insn_start(uint64_t pc)
1391 /* XXX: must really use a 32 bit size for TCGArg in all cases */
1392 #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
1393 tcg_gen_op2i(INDEX_op_debug_insn_start,
1394 (uint32_t)(pc), (uint32_t)(pc >> 32));
1396 tcg_gen_op1i(INDEX_op_debug_insn_start, pc);
1400 static inline void tcg_gen_exit_tb(tcg_target_long val)
1402 tcg_gen_op1i(INDEX_op_exit_tb, val);
1405 static inline void tcg_gen_goto_tb(int idx)
1407 tcg_gen_op1i(INDEX_op_goto_tb, idx);
1410 #if TCG_TARGET_REG_BITS == 32
1411 static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
1413 #if TARGET_LONG_BITS == 32
1414 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
1416 tcg_gen_op4i(INDEX_op_qemu_ld8u, ret, addr, TCGV_HIGH(addr), mem_index);
1417 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1421 static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
1423 #if TARGET_LONG_BITS == 32
1424 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
1426 tcg_gen_op4i(INDEX_op_qemu_ld8s, ret, addr, TCGV_HIGH(addr), mem_index);
1427 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1431 static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
1433 #if TARGET_LONG_BITS == 32
1434 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
1436 tcg_gen_op4i(INDEX_op_qemu_ld16u, ret, addr, TCGV_HIGH(addr), mem_index);
1437 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1441 static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
1443 #if TARGET_LONG_BITS == 32
1444 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
1446 tcg_gen_op4i(INDEX_op_qemu_ld16s, ret, addr, TCGV_HIGH(addr), mem_index);
1447 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1451 static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
1453 #if TARGET_LONG_BITS == 32
1454 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1456 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1457 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1461 static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
1463 #if TARGET_LONG_BITS == 32
1464 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1466 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1467 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1471 static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
1473 #if TARGET_LONG_BITS == 32
1474 tcg_gen_op4i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), addr, mem_index);
1476 tcg_gen_op5i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret),
1477 addr, TCGV_HIGH(addr), mem_index);
1481 static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
1483 #if TARGET_LONG_BITS == 32
1484 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
1486 tcg_gen_op4i(INDEX_op_qemu_st8, arg, addr, TCGV_HIGH(addr), mem_index);
1490 static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
1492 #if TARGET_LONG_BITS == 32
1493 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
1495 tcg_gen_op4i(INDEX_op_qemu_st16, arg, addr, TCGV_HIGH(addr), mem_index);
1499 static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
1501 #if TARGET_LONG_BITS == 32
1502 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
1504 tcg_gen_op4i(INDEX_op_qemu_st32, arg, addr, TCGV_HIGH(addr), mem_index);
1508 static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
1510 #if TARGET_LONG_BITS == 32
1511 tcg_gen_op4i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), addr, mem_index);
1513 tcg_gen_op5i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg),
1514 addr, TCGV_HIGH(addr), mem_index);
1518 #define tcg_gen_ld_ptr tcg_gen_ld_i32
1519 #define tcg_gen_discard_ptr tcg_gen_discard_i32
1521 #else /* TCG_TARGET_REG_BITS == 32 */
1523 static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
1525 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
1528 static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
1530 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
1533 static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
1535 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
1538 static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
1540 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
1543 static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
1545 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1548 static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
1550 tcg_gen_op3i(INDEX_op_qemu_ld32s, ret, addr, mem_index);
1553 static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
1555 tcg_gen_op3i(INDEX_op_qemu_ld64, ret, addr, mem_index);
1558 static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
1560 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
1563 static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
1565 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
1568 static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
1570 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
1573 static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
1575 tcg_gen_op3i(INDEX_op_qemu_st64, arg, addr, mem_index);
1578 #define tcg_gen_ld_ptr tcg_gen_ld_i64
1579 #define tcg_gen_discard_ptr tcg_gen_discard_i64
1581 #endif /* TCG_TARGET_REG_BITS != 32 */
1583 #if TARGET_LONG_BITS == 64
1584 #define TCG_TYPE_TL TCG_TYPE_I64
1585 #define tcg_gen_movi_tl tcg_gen_movi_i64
1586 #define tcg_gen_mov_tl tcg_gen_mov_i64
1587 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
1588 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
1589 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
1590 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
1591 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
1592 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
1593 #define tcg_gen_ld_tl tcg_gen_ld_i64
1594 #define tcg_gen_st8_tl tcg_gen_st8_i64
1595 #define tcg_gen_st16_tl tcg_gen_st16_i64
1596 #define tcg_gen_st32_tl tcg_gen_st32_i64
1597 #define tcg_gen_st_tl tcg_gen_st_i64
1598 #define tcg_gen_add_tl tcg_gen_add_i64
1599 #define tcg_gen_addi_tl tcg_gen_addi_i64
1600 #define tcg_gen_sub_tl tcg_gen_sub_i64
1601 #define tcg_gen_neg_tl tcg_gen_neg_i64
1602 #define tcg_gen_subi_tl tcg_gen_subi_i64
1603 #define tcg_gen_and_tl tcg_gen_and_i64
1604 #define tcg_gen_andi_tl tcg_gen_andi_i64
1605 #define tcg_gen_or_tl tcg_gen_or_i64
1606 #define tcg_gen_ori_tl tcg_gen_ori_i64
1607 #define tcg_gen_xor_tl tcg_gen_xor_i64
1608 #define tcg_gen_xori_tl tcg_gen_xori_i64
1609 #define tcg_gen_not_tl tcg_gen_not_i64
1610 #define tcg_gen_shl_tl tcg_gen_shl_i64
1611 #define tcg_gen_shli_tl tcg_gen_shli_i64
1612 #define tcg_gen_shr_tl tcg_gen_shr_i64
1613 #define tcg_gen_shri_tl tcg_gen_shri_i64
1614 #define tcg_gen_sar_tl tcg_gen_sar_i64
1615 #define tcg_gen_sari_tl tcg_gen_sari_i64
1616 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
1617 #define tcg_gen_mul_tl tcg_gen_mul_i64
1618 #define tcg_gen_muli_tl tcg_gen_muli_i64
1619 #define tcg_gen_discard_tl tcg_gen_discard_i64
1620 #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
1621 #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
1622 #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
1623 #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
1624 #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
1625 #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
1626 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
1627 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
1628 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
1629 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
1630 #define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
1631 #define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
1632 #define tcg_const_tl tcg_const_i64
1634 #define TCG_TYPE_TL TCG_TYPE_I32
1635 #define tcg_gen_movi_tl tcg_gen_movi_i32
1636 #define tcg_gen_mov_tl tcg_gen_mov_i32
1637 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
1638 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
1639 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
1640 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
1641 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
1642 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
1643 #define tcg_gen_ld_tl tcg_gen_ld_i32
1644 #define tcg_gen_st8_tl tcg_gen_st8_i32
1645 #define tcg_gen_st16_tl tcg_gen_st16_i32
1646 #define tcg_gen_st32_tl tcg_gen_st_i32
1647 #define tcg_gen_st_tl tcg_gen_st_i32
1648 #define tcg_gen_add_tl tcg_gen_add_i32
1649 #define tcg_gen_addi_tl tcg_gen_addi_i32
1650 #define tcg_gen_sub_tl tcg_gen_sub_i32
1651 #define tcg_gen_neg_tl tcg_gen_neg_i32
1652 #define tcg_gen_subi_tl tcg_gen_subi_i32
1653 #define tcg_gen_and_tl tcg_gen_and_i32
1654 #define tcg_gen_andi_tl tcg_gen_andi_i32
1655 #define tcg_gen_or_tl tcg_gen_or_i32
1656 #define tcg_gen_ori_tl tcg_gen_ori_i32
1657 #define tcg_gen_xor_tl tcg_gen_xor_i32
1658 #define tcg_gen_xori_tl tcg_gen_xori_i32
1659 #define tcg_gen_not_tl tcg_gen_not_i32
1660 #define tcg_gen_shl_tl tcg_gen_shl_i32
1661 #define tcg_gen_shli_tl tcg_gen_shli_i32
1662 #define tcg_gen_shr_tl tcg_gen_shr_i32
1663 #define tcg_gen_shri_tl tcg_gen_shri_i32
1664 #define tcg_gen_sar_tl tcg_gen_sar_i32
1665 #define tcg_gen_sari_tl tcg_gen_sari_i32
1666 #define tcg_gen_brcond_tl tcg_gen_brcond_i32
1667 #define tcg_gen_mul_tl tcg_gen_mul_i32
1668 #define tcg_gen_muli_tl tcg_gen_muli_i32
1669 #define tcg_gen_discard_tl tcg_gen_discard_i32
1670 #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
1671 #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
1672 #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
1673 #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
1674 #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
1675 #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
1676 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
1677 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
1678 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
1679 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
1680 #define tcg_gen_ext32u_tl tcg_gen_mov_i32
1681 #define tcg_gen_ext32s_tl tcg_gen_mov_i32
1682 #define tcg_const_tl tcg_const_i32
1685 #if TCG_TARGET_REG_BITS == 32
1686 #define tcg_gen_add_ptr tcg_gen_add_i32
1687 #define tcg_gen_addi_ptr tcg_gen_addi_i32
1688 #define tcg_gen_ext_i32_ptr tcg_gen_mov_i32
1689 #else /* TCG_TARGET_REG_BITS == 32 */
1690 #define tcg_gen_add_ptr tcg_gen_add_i64
1691 #define tcg_gen_addi_ptr tcg_gen_addi_i64
1692 #define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64
1693 #endif /* TCG_TARGET_REG_BITS != 32 */