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_4(void *func, TCGv ret,
241 TCGv arg1, TCGv arg2, TCGv arg3,
249 tcg_gen_call(&tcg_ctx,
250 tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS,
256 static inline void tcg_gen_ld8u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
258 tcg_gen_op3i(INDEX_op_ld8u_i32, ret, arg2, offset);
261 static inline void tcg_gen_ld8s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
263 tcg_gen_op3i(INDEX_op_ld8s_i32, ret, arg2, offset);
266 static inline void tcg_gen_ld16u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
268 tcg_gen_op3i(INDEX_op_ld16u_i32, ret, arg2, offset);
271 static inline void tcg_gen_ld16s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
273 tcg_gen_op3i(INDEX_op_ld16s_i32, ret, arg2, offset);
276 static inline void tcg_gen_ld_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
278 tcg_gen_op3i(INDEX_op_ld_i32, ret, arg2, offset);
281 static inline void tcg_gen_st8_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
283 tcg_gen_op3i(INDEX_op_st8_i32, arg1, arg2, offset);
286 static inline void tcg_gen_st16_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
288 tcg_gen_op3i(INDEX_op_st16_i32, arg1, arg2, offset);
291 static inline void tcg_gen_st_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
293 tcg_gen_op3i(INDEX_op_st_i32, arg1, arg2, offset);
296 static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2)
298 tcg_gen_op3(INDEX_op_add_i32, ret, arg1, arg2);
301 static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2)
303 /* some cases can be optimized here */
305 tcg_gen_mov_i32(ret, arg1);
307 tcg_gen_add_i32(ret, arg1, tcg_const_i32(arg2));
311 static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2)
313 tcg_gen_op3(INDEX_op_sub_i32, ret, arg1, arg2);
316 static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2)
318 /* some cases can be optimized here */
320 tcg_gen_mov_i32(ret, arg1);
322 tcg_gen_sub_i32(ret, arg1, tcg_const_i32(arg2));
326 static inline void tcg_gen_and_i32(TCGv ret, TCGv arg1, TCGv arg2)
328 tcg_gen_op3(INDEX_op_and_i32, ret, arg1, arg2);
331 static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2)
333 /* some cases can be optimized here */
335 tcg_gen_movi_i32(ret, 0);
336 } else if (arg2 == 0xffffffff) {
337 tcg_gen_mov_i32(ret, arg1);
339 tcg_gen_and_i32(ret, arg1, tcg_const_i32(arg2));
343 static inline void tcg_gen_or_i32(TCGv ret, TCGv arg1, TCGv arg2)
345 tcg_gen_op3(INDEX_op_or_i32, ret, arg1, arg2);
348 static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2)
350 /* some cases can be optimized here */
351 if (arg2 == 0xffffffff) {
352 tcg_gen_movi_i32(ret, 0xffffffff);
353 } else if (arg2 == 0) {
354 tcg_gen_mov_i32(ret, arg1);
356 tcg_gen_or_i32(ret, arg1, tcg_const_i32(arg2));
360 static inline void tcg_gen_xor_i32(TCGv ret, TCGv arg1, TCGv arg2)
362 tcg_gen_op3(INDEX_op_xor_i32, ret, arg1, arg2);
365 static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2)
367 /* some cases can be optimized here */
369 tcg_gen_mov_i32(ret, arg1);
371 tcg_gen_xor_i32(ret, arg1, tcg_const_i32(arg2));
375 static inline void tcg_gen_shl_i32(TCGv ret, TCGv arg1, TCGv arg2)
377 tcg_gen_op3(INDEX_op_shl_i32, ret, arg1, arg2);
380 static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2)
382 tcg_gen_shl_i32(ret, arg1, tcg_const_i32(arg2));
385 static inline void tcg_gen_shr_i32(TCGv ret, TCGv arg1, TCGv arg2)
387 tcg_gen_op3(INDEX_op_shr_i32, ret, arg1, arg2);
390 static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2)
392 tcg_gen_shr_i32(ret, arg1, tcg_const_i32(arg2));
395 static inline void tcg_gen_sar_i32(TCGv ret, TCGv arg1, TCGv arg2)
397 tcg_gen_op3(INDEX_op_sar_i32, ret, arg1, arg2);
400 static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2)
402 tcg_gen_sar_i32(ret, arg1, tcg_const_i32(arg2));
405 static inline void tcg_gen_brcond_i32(int cond, TCGv arg1, TCGv arg2,
408 tcg_gen_op4ii(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
411 static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2)
413 tcg_gen_op3(INDEX_op_mul_i32, ret, arg1, arg2);
416 #ifdef TCG_TARGET_HAS_div_i32
417 static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
419 tcg_gen_op3(INDEX_op_div_i32, ret, arg1, arg2);
422 static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
424 tcg_gen_op3(INDEX_op_rem_i32, ret, arg1, arg2);
427 static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
429 tcg_gen_op3(INDEX_op_divu_i32, ret, arg1, arg2);
432 static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
434 tcg_gen_op3(INDEX_op_remu_i32, ret, arg1, arg2);
437 static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
440 t0 = tcg_temp_new(TCG_TYPE_I32);
441 tcg_gen_sari_i32(t0, arg1, 31);
442 tcg_gen_op5(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
445 static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
448 t0 = tcg_temp_new(TCG_TYPE_I32);
449 tcg_gen_sari_i32(t0, arg1, 31);
450 tcg_gen_op5(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
453 static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
456 t0 = tcg_temp_new(TCG_TYPE_I32);
457 tcg_gen_movi_i32(t0, 0);
458 tcg_gen_op5(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
461 static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
464 t0 = tcg_temp_new(TCG_TYPE_I32);
465 tcg_gen_movi_i32(t0, 0);
466 tcg_gen_op5(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
470 #if TCG_TARGET_REG_BITS == 32
472 static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
474 tcg_gen_mov_i32(ret, arg);
475 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
478 static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
480 tcg_gen_movi_i32(ret, arg);
481 tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
484 static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
486 tcg_gen_ld8u_i32(ret, arg2, offset);
487 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
490 static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
492 tcg_gen_ld8s_i32(ret, arg2, offset);
493 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
496 static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
498 tcg_gen_ld16u_i32(ret, arg2, offset);
499 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
502 static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
504 tcg_gen_ld16s_i32(ret, arg2, offset);
505 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
508 static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
510 tcg_gen_ld_i32(ret, arg2, offset);
511 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
514 static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
516 tcg_gen_ld_i32(ret, arg2, offset);
517 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
520 static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
522 /* since arg2 and ret have different types, they cannot be the
524 #ifdef TCG_TARGET_WORDS_BIGENDIAN
525 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
526 tcg_gen_ld_i32(ret, arg2, offset + 4);
528 tcg_gen_ld_i32(ret, arg2, offset);
529 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
533 static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
535 tcg_gen_st8_i32(arg1, arg2, offset);
538 static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
540 tcg_gen_st16_i32(arg1, arg2, offset);
543 static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
545 tcg_gen_st_i32(arg1, arg2, offset);
548 static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
550 #ifdef TCG_TARGET_WORDS_BIGENDIAN
551 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
552 tcg_gen_st_i32(arg1, arg2, offset + 4);
554 tcg_gen_st_i32(arg1, arg2, offset);
555 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
559 static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
561 tcg_gen_op6(INDEX_op_add2_i32, ret, TCGV_HIGH(ret),
562 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
565 static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
567 tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
570 static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
572 tcg_gen_op6(INDEX_op_sub2_i32, ret, TCGV_HIGH(ret),
573 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
576 static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
578 tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
581 static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
583 tcg_gen_and_i32(ret, arg1, arg2);
584 tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
587 static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
589 tcg_gen_andi_i32(ret, arg1, arg2);
590 tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
593 static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
595 tcg_gen_or_i32(ret, arg1, arg2);
596 tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
599 static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
601 tcg_gen_ori_i32(ret, arg1, arg2);
602 tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
605 static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
607 tcg_gen_xor_i32(ret, arg1, arg2);
608 tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
611 static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
613 tcg_gen_xori_i32(ret, arg1, arg2);
614 tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
617 /* XXX: use generic code when basic block handling is OK or CPU
618 specific code (x86) */
619 static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
621 tcg_gen_helper_1_2(tcg_helper_shl_i64, ret, arg1, arg2);
624 static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
626 tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
629 static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
631 tcg_gen_helper_1_2(tcg_helper_shr_i64, ret, arg1, arg2);
634 static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
636 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
639 static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
641 tcg_gen_helper_1_2(tcg_helper_sar_i64, ret, arg1, arg2);
644 static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
646 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
649 static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
652 tcg_gen_op6ii(INDEX_op_brcond2_i32,
653 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2),
657 static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
661 t0 = tcg_temp_new(TCG_TYPE_I64);
662 t1 = tcg_temp_new(TCG_TYPE_I32);
664 tcg_gen_op4(INDEX_op_mulu2_i32, t0, TCGV_HIGH(t0), arg1, arg2);
666 tcg_gen_mul_i32(t1, arg1, TCGV_HIGH(arg2));
667 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
668 tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), arg2);
669 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
671 tcg_gen_mov_i64(ret, t0);
674 static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
676 tcg_gen_helper_1_2(tcg_helper_div_i64, ret, arg1, arg2);
679 static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
681 tcg_gen_helper_1_2(tcg_helper_rem_i64, ret, arg1, arg2);
684 static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
686 tcg_gen_helper_1_2(tcg_helper_divu_i64, ret, arg1, arg2);
689 static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
691 tcg_gen_helper_1_2(tcg_helper_remu_i64, ret, arg1, arg2);
696 static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
698 tcg_gen_op2(INDEX_op_mov_i64, ret, arg);
701 static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
703 tcg_gen_op2i(INDEX_op_movi_i64, ret, arg);
706 static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2,
707 tcg_target_long offset)
709 tcg_gen_op3i(INDEX_op_ld8u_i64, ret, arg2, offset);
712 static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2,
713 tcg_target_long offset)
715 tcg_gen_op3i(INDEX_op_ld8s_i64, ret, arg2, offset);
718 static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2,
719 tcg_target_long offset)
721 tcg_gen_op3i(INDEX_op_ld16u_i64, ret, arg2, offset);
724 static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2,
725 tcg_target_long offset)
727 tcg_gen_op3i(INDEX_op_ld16s_i64, ret, arg2, offset);
730 static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2,
731 tcg_target_long offset)
733 tcg_gen_op3i(INDEX_op_ld32u_i64, ret, arg2, offset);
736 static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2,
737 tcg_target_long offset)
739 tcg_gen_op3i(INDEX_op_ld32s_i64, ret, arg2, offset);
742 static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
744 tcg_gen_op3i(INDEX_op_ld_i64, ret, arg2, offset);
747 static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2,
748 tcg_target_long offset)
750 tcg_gen_op3i(INDEX_op_st8_i64, arg1, arg2, offset);
753 static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2,
754 tcg_target_long offset)
756 tcg_gen_op3i(INDEX_op_st16_i64, arg1, arg2, offset);
759 static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2,
760 tcg_target_long offset)
762 tcg_gen_op3i(INDEX_op_st32_i64, arg1, arg2, offset);
765 static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
767 tcg_gen_op3i(INDEX_op_st_i64, arg1, arg2, offset);
770 static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
772 tcg_gen_op3(INDEX_op_add_i64, ret, arg1, arg2);
775 static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
777 tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2));
780 static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
782 tcg_gen_op3(INDEX_op_sub_i64, ret, arg1, arg2);
785 static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
787 tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2));
790 static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
792 tcg_gen_op3(INDEX_op_and_i64, ret, arg1, arg2);
795 static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
797 tcg_gen_and_i64(ret, arg1, tcg_const_i64(arg2));
800 static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
802 tcg_gen_op3(INDEX_op_or_i64, ret, arg1, arg2);
805 static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
807 tcg_gen_or_i64(ret, arg1, tcg_const_i64(arg2));
810 static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
812 tcg_gen_op3(INDEX_op_xor_i64, ret, arg1, arg2);
815 static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
817 tcg_gen_xor_i64(ret, arg1, tcg_const_i64(arg2));
820 static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
822 tcg_gen_op3(INDEX_op_shl_i64, ret, arg1, arg2);
825 static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
827 tcg_gen_shl_i64(ret, arg1, tcg_const_i64(arg2));
830 static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
832 tcg_gen_op3(INDEX_op_shr_i64, ret, arg1, arg2);
835 static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
837 tcg_gen_shr_i64(ret, arg1, tcg_const_i64(arg2));
840 static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
842 tcg_gen_op3(INDEX_op_sar_i64, ret, arg1, arg2);
845 static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
847 tcg_gen_sar_i64(ret, arg1, tcg_const_i64(arg2));
850 static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
853 tcg_gen_op4ii(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
856 static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
858 tcg_gen_op3(INDEX_op_mul_i64, ret, arg1, arg2);
861 #ifdef TCG_TARGET_HAS_div_i64
862 static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
864 tcg_gen_op3(INDEX_op_div_i64, ret, arg1, arg2);
867 static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
869 tcg_gen_op3(INDEX_op_rem_i64, ret, arg1, arg2);
872 static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
874 tcg_gen_op3(INDEX_op_divu_i64, ret, arg1, arg2);
877 static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
879 tcg_gen_op3(INDEX_op_remu_i64, ret, arg1, arg2);
882 static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
885 t0 = tcg_temp_new(TCG_TYPE_I64);
886 tcg_gen_sari_i64(t0, arg1, 63);
887 tcg_gen_op5(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
890 static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
893 t0 = tcg_temp_new(TCG_TYPE_I64);
894 tcg_gen_sari_i64(t0, arg1, 63);
895 tcg_gen_op5(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
898 static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
901 t0 = tcg_temp_new(TCG_TYPE_I64);
902 tcg_gen_movi_i64(t0, 0);
903 tcg_gen_op5(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
906 static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
909 t0 = tcg_temp_new(TCG_TYPE_I64);
910 tcg_gen_movi_i64(t0, 0);
911 tcg_gen_op5(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
917 /***************************************/
918 /* optional operations */
920 static inline void tcg_gen_ext8s_i32(TCGv ret, TCGv arg)
922 #ifdef TCG_TARGET_HAS_ext8s_i32
923 tcg_gen_op2(INDEX_op_ext8s_i32, ret, arg);
925 tcg_gen_shli_i32(ret, arg, 24);
926 tcg_gen_sari_i32(ret, ret, 24);
930 static inline void tcg_gen_ext16s_i32(TCGv ret, TCGv arg)
932 #ifdef TCG_TARGET_HAS_ext16s_i32
933 tcg_gen_op2(INDEX_op_ext16s_i32, ret, arg);
935 tcg_gen_shli_i32(ret, arg, 16);
936 tcg_gen_sari_i32(ret, ret, 16);
940 /* Note: we assume the two high bytes are set to zero */
941 static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg)
943 #ifdef TCG_TARGET_HAS_bswap16_i32
944 tcg_gen_op2(INDEX_op_bswap16_i32, ret, arg);
947 t0 = tcg_temp_new(TCG_TYPE_I32);
948 t1 = tcg_temp_new(TCG_TYPE_I32);
950 tcg_gen_shri_i32(t0, arg, 8);
951 tcg_gen_andi_i32(t1, arg, 0x000000ff);
952 tcg_gen_shli_i32(t1, t1, 8);
953 tcg_gen_or_i32(ret, t0, t1);
957 static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg)
959 #ifdef TCG_TARGET_HAS_bswap_i32
960 tcg_gen_op2(INDEX_op_bswap_i32, ret, arg);
963 t0 = tcg_temp_new(TCG_TYPE_I32);
964 t1 = tcg_temp_new(TCG_TYPE_I32);
966 tcg_gen_shli_i32(t0, arg, 24);
968 tcg_gen_andi_i32(t1, arg, 0x0000ff00);
969 tcg_gen_shli_i32(t1, t1, 8);
970 tcg_gen_or_i32(t0, t0, t1);
972 tcg_gen_shri_i32(t1, arg, 8);
973 tcg_gen_andi_i32(t1, t1, 0x0000ff00);
974 tcg_gen_or_i32(t0, t0, t1);
976 tcg_gen_shri_i32(t1, arg, 24);
977 tcg_gen_or_i32(ret, t0, t1);
981 #if TCG_TARGET_REG_BITS == 32
982 static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
984 tcg_gen_ext8s_i32(ret, arg);
985 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
988 static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
990 tcg_gen_ext16s_i32(ret, arg);
991 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
994 static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
996 tcg_gen_mov_i32(ret, arg);
997 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1000 static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
1002 tcg_gen_mov_i32(ret, arg);
1005 static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
1007 tcg_gen_mov_i32(ret, arg);
1008 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1011 static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
1013 tcg_gen_mov_i32(ret, arg);
1014 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1017 static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
1020 t0 = tcg_temp_new(TCG_TYPE_I32);
1021 t1 = tcg_temp_new(TCG_TYPE_I32);
1023 tcg_gen_bswap_i32(t0, arg);
1024 tcg_gen_bswap_i32(t1, TCGV_HIGH(arg));
1025 tcg_gen_mov_i32(ret, t1);
1026 tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
1030 static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
1032 #ifdef TCG_TARGET_HAS_ext8s_i64
1033 tcg_gen_op2(INDEX_op_ext8s_i64, ret, arg);
1035 tcg_gen_shli_i64(ret, arg, 56);
1036 tcg_gen_sari_i64(ret, ret, 56);
1040 static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
1042 #ifdef TCG_TARGET_HAS_ext16s_i64
1043 tcg_gen_op2(INDEX_op_ext16s_i64, ret, arg);
1045 tcg_gen_shli_i64(ret, arg, 48);
1046 tcg_gen_sari_i64(ret, ret, 48);
1050 static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
1052 #ifdef TCG_TARGET_HAS_ext32s_i64
1053 tcg_gen_op2(INDEX_op_ext32s_i64, ret, arg);
1055 tcg_gen_shli_i64(ret, arg, 32);
1056 tcg_gen_sari_i64(ret, ret, 32);
1060 /* Note: we assume the target supports move between 32 and 64 bit
1061 registers. This will probably break MIPS64 targets. */
1062 static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
1064 tcg_gen_mov_i32(ret, arg);
1067 /* Note: we assume the target supports move between 32 and 64 bit
1069 static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
1071 tcg_gen_andi_i64(ret, arg, 0xffffffff);
1074 /* Note: we assume the target supports move between 32 and 64 bit
1076 static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
1078 tcg_gen_ext32s_i64(ret, arg);
1081 static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
1083 #ifdef TCG_TARGET_HAS_bswap_i64
1084 tcg_gen_op2(INDEX_op_bswap_i64, ret, arg);
1087 t0 = tcg_temp_new(TCG_TYPE_I32);
1088 t1 = tcg_temp_new(TCG_TYPE_I32);
1090 tcg_gen_shli_i64(t0, arg, 56);
1092 tcg_gen_andi_i64(t1, arg, 0x0000ff00);
1093 tcg_gen_shli_i64(t1, t1, 40);
1094 tcg_gen_or_i64(t0, t0, t1);
1096 tcg_gen_andi_i64(t1, arg, 0x00ff0000);
1097 tcg_gen_shli_i64(t1, t1, 24);
1098 tcg_gen_or_i64(t0, t0, t1);
1100 tcg_gen_andi_i64(t1, arg, 0xff000000);
1101 tcg_gen_shli_i64(t1, t1, 8);
1102 tcg_gen_or_i64(t0, t0, t1);
1104 tcg_gen_shri_i64(t1, arg, 8);
1105 tcg_gen_andi_i64(t1, t1, 0xff000000);
1106 tcg_gen_or_i64(t0, t0, t1);
1108 tcg_gen_shri_i64(t1, arg, 24);
1109 tcg_gen_andi_i64(t1, t1, 0x00ff0000);
1110 tcg_gen_or_i64(t0, t0, t1);
1112 tcg_gen_shri_i64(t1, arg, 40);
1113 tcg_gen_andi_i64(t1, t1, 0x0000ff00);
1114 tcg_gen_or_i64(t0, t0, t1);
1116 tcg_gen_shri_i64(t1, arg, 56);
1117 tcg_gen_or_i64(ret, t0, t1);
1124 static inline void tcg_gen_discard_i32(TCGv arg)
1126 tcg_gen_op1(INDEX_op_discard, arg);
1129 #if TCG_TARGET_REG_BITS == 32
1130 static inline void tcg_gen_discard_i64(TCGv arg)
1132 tcg_gen_discard_i32(arg);
1133 tcg_gen_discard_i32(TCGV_HIGH(arg));
1136 static inline void tcg_gen_discard_i64(TCGv arg)
1138 tcg_gen_op1(INDEX_op_discard, arg);
1142 /***************************************/
1143 static inline void tcg_gen_macro_2(TCGv ret0, TCGv ret1, int macro_id)
1145 tcg_gen_op3i(INDEX_op_macro_2, ret0, ret1, macro_id);
1148 /***************************************/
1149 /* QEMU specific operations. Their type depend on the QEMU CPU
1151 #ifndef TARGET_LONG_BITS
1152 #error must include QEMU headers
1155 static inline void tcg_gen_exit_tb(tcg_target_long val)
1157 tcg_gen_op1i(INDEX_op_exit_tb, val);
1160 static inline void tcg_gen_goto_tb(int idx)
1162 tcg_gen_op1i(INDEX_op_goto_tb, idx);
1165 #if TCG_TARGET_REG_BITS == 32
1166 static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
1168 #if TARGET_LONG_BITS == 32
1169 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
1171 tcg_gen_op4i(INDEX_op_qemu_ld8u, ret, addr, TCGV_HIGH(addr), mem_index);
1172 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1176 static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
1178 #if TARGET_LONG_BITS == 32
1179 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
1181 tcg_gen_op4i(INDEX_op_qemu_ld8s, ret, addr, TCGV_HIGH(addr), mem_index);
1182 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1186 static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
1188 #if TARGET_LONG_BITS == 32
1189 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
1191 tcg_gen_op4i(INDEX_op_qemu_ld16u, ret, addr, TCGV_HIGH(addr), mem_index);
1192 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1196 static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
1198 #if TARGET_LONG_BITS == 32
1199 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
1201 tcg_gen_op4i(INDEX_op_qemu_ld16s, ret, addr, TCGV_HIGH(addr), mem_index);
1202 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1206 static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
1208 #if TARGET_LONG_BITS == 32
1209 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1211 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1212 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1216 static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
1218 #if TARGET_LONG_BITS == 32
1219 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1221 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1222 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1226 static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
1228 #if TARGET_LONG_BITS == 32
1229 tcg_gen_op4i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), addr, mem_index);
1231 tcg_gen_op5i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret),
1232 addr, TCGV_HIGH(addr), mem_index);
1236 static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
1238 #if TARGET_LONG_BITS == 32
1239 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
1241 tcg_gen_op4i(INDEX_op_qemu_st8, arg, addr, TCGV_HIGH(addr), mem_index);
1245 static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
1247 #if TARGET_LONG_BITS == 32
1248 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
1250 tcg_gen_op4i(INDEX_op_qemu_st16, arg, addr, TCGV_HIGH(addr), mem_index);
1254 static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
1256 #if TARGET_LONG_BITS == 32
1257 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
1259 tcg_gen_op4i(INDEX_op_qemu_st32, arg, addr, TCGV_HIGH(addr), mem_index);
1263 static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
1265 #if TARGET_LONG_BITS == 32
1266 tcg_gen_op4i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), addr, mem_index);
1268 tcg_gen_op5i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg),
1269 addr, TCGV_HIGH(addr), mem_index);
1273 #define tcg_gen_ld_ptr tcg_gen_ld_i32
1274 #define tcg_gen_discard_ptr tcg_gen_discard_i32
1276 #else /* TCG_TARGET_REG_BITS == 32 */
1278 static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
1280 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
1283 static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
1285 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
1288 static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
1290 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
1293 static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
1295 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
1298 static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
1300 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1303 static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
1305 tcg_gen_op3i(INDEX_op_qemu_ld32s, ret, addr, mem_index);
1308 static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
1310 tcg_gen_op3i(INDEX_op_qemu_ld64, ret, addr, mem_index);
1313 static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
1315 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
1318 static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
1320 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
1323 static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
1325 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
1328 static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
1330 tcg_gen_op3i(INDEX_op_qemu_st64, arg, addr, mem_index);
1333 #define tcg_gen_ld_ptr tcg_gen_ld_i64
1334 #define tcg_gen_discard_ptr tcg_gen_discard_i64
1336 #endif /* TCG_TARGET_REG_BITS != 32 */
1338 #if TARGET_LONG_BITS == 64
1339 #define TCG_TYPE_TL TCG_TYPE_I64
1340 #define tcg_gen_movi_tl tcg_gen_movi_i64
1341 #define tcg_gen_mov_tl tcg_gen_mov_i64
1342 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
1343 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
1344 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
1345 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
1346 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
1347 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
1348 #define tcg_gen_ld_tl tcg_gen_ld_i64
1349 #define tcg_gen_st8_tl tcg_gen_st8_i64
1350 #define tcg_gen_st16_tl tcg_gen_st16_i64
1351 #define tcg_gen_st32_tl tcg_gen_st32_i64
1352 #define tcg_gen_st_tl tcg_gen_st_i64
1353 #define tcg_gen_add_tl tcg_gen_add_i64
1354 #define tcg_gen_addi_tl tcg_gen_addi_i64
1355 #define tcg_gen_sub_tl tcg_gen_sub_i64
1356 #define tcg_gen_subi_tl tcg_gen_subi_i64
1357 #define tcg_gen_and_tl tcg_gen_and_i64
1358 #define tcg_gen_andi_tl tcg_gen_andi_i64
1359 #define tcg_gen_or_tl tcg_gen_or_i64
1360 #define tcg_gen_ori_tl tcg_gen_ori_i64
1361 #define tcg_gen_xor_tl tcg_gen_xor_i64
1362 #define tcg_gen_xori_tl tcg_gen_xori_i64
1363 #define tcg_gen_shl_tl tcg_gen_shl_i64
1364 #define tcg_gen_shli_tl tcg_gen_shli_i64
1365 #define tcg_gen_shr_tl tcg_gen_shr_i64
1366 #define tcg_gen_shri_tl tcg_gen_shri_i64
1367 #define tcg_gen_sar_tl tcg_gen_sar_i64
1368 #define tcg_gen_sari_tl tcg_gen_sari_i64
1369 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
1370 #define tcg_gen_discard_tl tcg_gen_discard_i64
1371 #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
1372 #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
1373 #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
1374 #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
1375 #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
1376 #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
1377 #define tcg_const_tl tcg_const_i64
1379 #define TCG_TYPE_TL TCG_TYPE_I32
1380 #define tcg_gen_movi_tl tcg_gen_movi_i32
1381 #define tcg_gen_mov_tl tcg_gen_mov_i32
1382 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
1383 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
1384 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
1385 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
1386 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
1387 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
1388 #define tcg_gen_ld_tl tcg_gen_ld_i32
1389 #define tcg_gen_st8_tl tcg_gen_st8_i32
1390 #define tcg_gen_st16_tl tcg_gen_st16_i32
1391 #define tcg_gen_st32_tl tcg_gen_st_i32
1392 #define tcg_gen_st_tl tcg_gen_st_i32
1393 #define tcg_gen_add_tl tcg_gen_add_i32
1394 #define tcg_gen_addi_tl tcg_gen_addi_i32
1395 #define tcg_gen_sub_tl tcg_gen_sub_i32
1396 #define tcg_gen_subi_tl tcg_gen_subi_i32
1397 #define tcg_gen_and_tl tcg_gen_and_i32
1398 #define tcg_gen_andi_tl tcg_gen_andi_i32
1399 #define tcg_gen_or_tl tcg_gen_or_i32
1400 #define tcg_gen_ori_tl tcg_gen_ori_i32
1401 #define tcg_gen_xor_tl tcg_gen_xor_i32
1402 #define tcg_gen_xori_tl tcg_gen_xori_i32
1403 #define tcg_gen_shl_tl tcg_gen_shl_i32
1404 #define tcg_gen_shli_tl tcg_gen_shli_i32
1405 #define tcg_gen_shr_tl tcg_gen_shr_i32
1406 #define tcg_gen_shri_tl tcg_gen_shri_i32
1407 #define tcg_gen_sar_tl tcg_gen_sar_i32
1408 #define tcg_gen_sari_tl tcg_gen_sari_i32
1409 #define tcg_gen_brcond_tl tcg_gen_brcond_i32
1410 #define tcg_gen_discard_tl tcg_gen_discard_i32
1411 #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
1412 #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
1413 #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
1414 #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
1415 #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
1416 #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
1417 #define tcg_const_tl tcg_const_i32