]>
git.proxmox.com Git - mirror_qemu.git/blob - tcg/tcg-op.h
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
)
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
)
181 tcg_gen_call(&tcg_ctx
,
182 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
186 static inline void tcg_gen_helper_0_1(void *func
, TCGv arg
)
188 tcg_gen_call(&tcg_ctx
,
189 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
193 static inline void tcg_gen_helper_0_2(void *func
, TCGv arg1
, TCGv arg2
)
198 tcg_gen_call(&tcg_ctx
,
199 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
203 static inline void tcg_gen_helper_0_3(void *func
,
204 TCGv arg1
, TCGv arg2
, TCGv arg3
)
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_0_4(void *func
, TCGv arg1
, TCGv arg2
,
216 TCGv arg3
, TCGv arg4
)
223 tcg_gen_call(&tcg_ctx
,
224 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
228 static inline void tcg_gen_helper_1_0(void *func
, TCGv ret
)
230 tcg_gen_call(&tcg_ctx
,
231 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
235 static inline void tcg_gen_helper_1_1(void *func
, TCGv ret
, TCGv arg1
)
237 tcg_gen_call(&tcg_ctx
,
238 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
242 static inline void tcg_gen_helper_1_2(void *func
, TCGv ret
,
243 TCGv arg1
, TCGv arg2
)
248 tcg_gen_call(&tcg_ctx
,
249 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
253 static inline void tcg_gen_helper_1_3(void *func
, TCGv ret
,
254 TCGv arg1
, TCGv arg2
, TCGv arg3
)
260 tcg_gen_call(&tcg_ctx
,
261 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
265 static inline void tcg_gen_helper_1_4(void *func
, TCGv ret
,
266 TCGv arg1
, TCGv arg2
, TCGv arg3
,
274 tcg_gen_call(&tcg_ctx
,
275 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
281 static inline void tcg_gen_ld8u_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
283 tcg_gen_op3i(INDEX_op_ld8u_i32
, ret
, arg2
, offset
);
286 static inline void tcg_gen_ld8s_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
288 tcg_gen_op3i(INDEX_op_ld8s_i32
, ret
, arg2
, offset
);
291 static inline void tcg_gen_ld16u_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
293 tcg_gen_op3i(INDEX_op_ld16u_i32
, ret
, arg2
, offset
);
296 static inline void tcg_gen_ld16s_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
298 tcg_gen_op3i(INDEX_op_ld16s_i32
, ret
, arg2
, offset
);
301 static inline void tcg_gen_ld_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
303 tcg_gen_op3i(INDEX_op_ld_i32
, ret
, arg2
, offset
);
306 static inline void tcg_gen_st8_i32(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
308 tcg_gen_op3i(INDEX_op_st8_i32
, arg1
, arg2
, offset
);
311 static inline void tcg_gen_st16_i32(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
313 tcg_gen_op3i(INDEX_op_st16_i32
, arg1
, arg2
, offset
);
316 static inline void tcg_gen_st_i32(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
318 tcg_gen_op3i(INDEX_op_st_i32
, arg1
, arg2
, offset
);
321 static inline void tcg_gen_add_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
323 tcg_gen_op3(INDEX_op_add_i32
, ret
, arg1
, arg2
);
326 static inline void tcg_gen_addi_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
328 /* some cases can be optimized here */
330 tcg_gen_mov_i32(ret
, arg1
);
332 tcg_gen_add_i32(ret
, arg1
, tcg_const_i32(arg2
));
336 static inline void tcg_gen_sub_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
338 tcg_gen_op3(INDEX_op_sub_i32
, ret
, arg1
, arg2
);
341 static inline void tcg_gen_subi_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
343 /* some cases can be optimized here */
345 tcg_gen_mov_i32(ret
, arg1
);
347 tcg_gen_sub_i32(ret
, arg1
, tcg_const_i32(arg2
));
351 static inline void tcg_gen_and_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
353 tcg_gen_op3(INDEX_op_and_i32
, ret
, arg1
, arg2
);
356 static inline void tcg_gen_andi_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
358 /* some cases can be optimized here */
360 tcg_gen_movi_i32(ret
, 0);
361 } else if (arg2
== 0xffffffff) {
362 tcg_gen_mov_i32(ret
, arg1
);
364 tcg_gen_and_i32(ret
, arg1
, tcg_const_i32(arg2
));
368 static inline void tcg_gen_or_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
370 tcg_gen_op3(INDEX_op_or_i32
, ret
, arg1
, arg2
);
373 static inline void tcg_gen_ori_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
375 /* some cases can be optimized here */
376 if (arg2
== 0xffffffff) {
377 tcg_gen_movi_i32(ret
, 0xffffffff);
378 } else if (arg2
== 0) {
379 tcg_gen_mov_i32(ret
, arg1
);
381 tcg_gen_or_i32(ret
, arg1
, tcg_const_i32(arg2
));
385 static inline void tcg_gen_xor_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
387 tcg_gen_op3(INDEX_op_xor_i32
, ret
, arg1
, arg2
);
390 static inline void tcg_gen_xori_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
392 /* some cases can be optimized here */
394 tcg_gen_mov_i32(ret
, arg1
);
396 tcg_gen_xor_i32(ret
, arg1
, tcg_const_i32(arg2
));
400 static inline void tcg_gen_shl_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
402 tcg_gen_op3(INDEX_op_shl_i32
, ret
, arg1
, arg2
);
405 static inline void tcg_gen_shli_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
407 tcg_gen_shl_i32(ret
, arg1
, tcg_const_i32(arg2
));
410 static inline void tcg_gen_shr_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
412 tcg_gen_op3(INDEX_op_shr_i32
, ret
, arg1
, arg2
);
415 static inline void tcg_gen_shri_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
417 tcg_gen_shr_i32(ret
, arg1
, tcg_const_i32(arg2
));
420 static inline void tcg_gen_sar_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
422 tcg_gen_op3(INDEX_op_sar_i32
, ret
, arg1
, arg2
);
425 static inline void tcg_gen_sari_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
427 tcg_gen_sar_i32(ret
, arg1
, tcg_const_i32(arg2
));
430 static inline void tcg_gen_brcond_i32(int cond
, TCGv arg1
, TCGv arg2
,
433 tcg_gen_op4ii(INDEX_op_brcond_i32
, arg1
, arg2
, cond
, label_index
);
436 static inline void tcg_gen_mul_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
438 tcg_gen_op3(INDEX_op_mul_i32
, ret
, arg1
, arg2
);
441 #ifdef TCG_TARGET_HAS_div_i32
442 static inline void tcg_gen_div_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
444 tcg_gen_op3(INDEX_op_div_i32
, ret
, arg1
, arg2
);
447 static inline void tcg_gen_rem_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
449 tcg_gen_op3(INDEX_op_rem_i32
, ret
, arg1
, arg2
);
452 static inline void tcg_gen_divu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
454 tcg_gen_op3(INDEX_op_divu_i32
, ret
, arg1
, arg2
);
457 static inline void tcg_gen_remu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
459 tcg_gen_op3(INDEX_op_remu_i32
, ret
, arg1
, arg2
);
462 static inline void tcg_gen_div_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
465 t0
= tcg_temp_new(TCG_TYPE_I32
);
466 tcg_gen_sari_i32(t0
, arg1
, 31);
467 tcg_gen_op5(INDEX_op_div2_i32
, ret
, t0
, arg1
, t0
, arg2
);
470 static inline void tcg_gen_rem_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
473 t0
= tcg_temp_new(TCG_TYPE_I32
);
474 tcg_gen_sari_i32(t0
, arg1
, 31);
475 tcg_gen_op5(INDEX_op_div2_i32
, t0
, ret
, arg1
, t0
, arg2
);
478 static inline void tcg_gen_divu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
481 t0
= tcg_temp_new(TCG_TYPE_I32
);
482 tcg_gen_movi_i32(t0
, 0);
483 tcg_gen_op5(INDEX_op_divu2_i32
, ret
, t0
, arg1
, t0
, arg2
);
486 static inline void tcg_gen_remu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
489 t0
= tcg_temp_new(TCG_TYPE_I32
);
490 tcg_gen_movi_i32(t0
, 0);
491 tcg_gen_op5(INDEX_op_divu2_i32
, t0
, ret
, arg1
, t0
, arg2
);
495 #if TCG_TARGET_REG_BITS == 32
497 static inline void tcg_gen_mov_i64(TCGv ret
, TCGv arg
)
500 tcg_gen_mov_i32(ret
, arg
);
501 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
505 static inline void tcg_gen_movi_i64(TCGv ret
, int64_t arg
)
507 tcg_gen_movi_i32(ret
, arg
);
508 tcg_gen_movi_i32(TCGV_HIGH(ret
), arg
>> 32);
511 static inline void tcg_gen_ld8u_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
513 tcg_gen_ld8u_i32(ret
, arg2
, offset
);
514 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
517 static inline void tcg_gen_ld8s_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
519 tcg_gen_ld8s_i32(ret
, arg2
, offset
);
520 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
523 static inline void tcg_gen_ld16u_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
525 tcg_gen_ld16u_i32(ret
, arg2
, offset
);
526 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
529 static inline void tcg_gen_ld16s_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
531 tcg_gen_ld16s_i32(ret
, arg2
, offset
);
532 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
535 static inline void tcg_gen_ld32u_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
537 tcg_gen_ld_i32(ret
, arg2
, offset
);
538 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
541 static inline void tcg_gen_ld32s_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
543 tcg_gen_ld_i32(ret
, arg2
, offset
);
544 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
547 static inline void tcg_gen_ld_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
549 /* since arg2 and ret have different types, they cannot be the
551 #ifdef TCG_TARGET_WORDS_BIGENDIAN
552 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
);
553 tcg_gen_ld_i32(ret
, arg2
, offset
+ 4);
555 tcg_gen_ld_i32(ret
, arg2
, offset
);
556 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
+ 4);
560 static inline void tcg_gen_st8_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
562 tcg_gen_st8_i32(arg1
, arg2
, offset
);
565 static inline void tcg_gen_st16_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
567 tcg_gen_st16_i32(arg1
, arg2
, offset
);
570 static inline void tcg_gen_st32_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
572 tcg_gen_st_i32(arg1
, arg2
, offset
);
575 static inline void tcg_gen_st_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
577 #ifdef TCG_TARGET_WORDS_BIGENDIAN
578 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
);
579 tcg_gen_st_i32(arg1
, arg2
, offset
+ 4);
581 tcg_gen_st_i32(arg1
, arg2
, offset
);
582 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
+ 4);
586 static inline void tcg_gen_add_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
588 tcg_gen_op6(INDEX_op_add2_i32
, ret
, TCGV_HIGH(ret
),
589 arg1
, TCGV_HIGH(arg1
), arg2
, TCGV_HIGH(arg2
));
592 static inline void tcg_gen_addi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
594 tcg_gen_add_i64(ret
, arg1
, tcg_const_i64(arg2
));
597 static inline void tcg_gen_sub_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
599 tcg_gen_op6(INDEX_op_sub2_i32
, ret
, TCGV_HIGH(ret
),
600 arg1
, TCGV_HIGH(arg1
), arg2
, TCGV_HIGH(arg2
));
603 static inline void tcg_gen_subi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
605 tcg_gen_sub_i64(ret
, arg1
, tcg_const_i64(arg2
));
608 static inline void tcg_gen_and_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
610 tcg_gen_and_i32(ret
, arg1
, arg2
);
611 tcg_gen_and_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
614 static inline void tcg_gen_andi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
616 tcg_gen_andi_i32(ret
, arg1
, arg2
);
617 tcg_gen_andi_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
620 static inline void tcg_gen_or_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
622 tcg_gen_or_i32(ret
, arg1
, arg2
);
623 tcg_gen_or_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
626 static inline void tcg_gen_ori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
628 tcg_gen_ori_i32(ret
, arg1
, arg2
);
629 tcg_gen_ori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
632 static inline void tcg_gen_xor_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
634 tcg_gen_xor_i32(ret
, arg1
, arg2
);
635 tcg_gen_xor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
638 static inline void tcg_gen_xori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
640 tcg_gen_xori_i32(ret
, arg1
, arg2
);
641 tcg_gen_xori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
644 /* XXX: use generic code when basic block handling is OK or CPU
645 specific code (x86) */
646 static inline void tcg_gen_shl_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
648 tcg_gen_helper_1_2(tcg_helper_shl_i64
, ret
, arg1
, arg2
);
651 static inline void tcg_gen_shli_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
653 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 0, 0);
656 static inline void tcg_gen_shr_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
658 tcg_gen_helper_1_2(tcg_helper_shr_i64
, ret
, arg1
, arg2
);
661 static inline void tcg_gen_shri_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
663 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 0);
666 static inline void tcg_gen_sar_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
668 tcg_gen_helper_1_2(tcg_helper_sar_i64
, ret
, arg1
, arg2
);
671 static inline void tcg_gen_sari_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
673 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 1);
676 static inline void tcg_gen_brcond_i64(int cond
, TCGv arg1
, TCGv arg2
,
679 tcg_gen_op6ii(INDEX_op_brcond2_i32
,
680 arg1
, TCGV_HIGH(arg1
), arg2
, TCGV_HIGH(arg2
),
684 static inline void tcg_gen_mul_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
688 t0
= tcg_temp_new(TCG_TYPE_I64
);
689 t1
= tcg_temp_new(TCG_TYPE_I32
);
691 tcg_gen_op4(INDEX_op_mulu2_i32
, t0
, TCGV_HIGH(t0
), arg1
, arg2
);
693 tcg_gen_mul_i32(t1
, arg1
, TCGV_HIGH(arg2
));
694 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
695 tcg_gen_mul_i32(t1
, TCGV_HIGH(arg1
), arg2
);
696 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
698 tcg_gen_mov_i64(ret
, t0
);
701 static inline void tcg_gen_div_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
703 tcg_gen_helper_1_2(tcg_helper_div_i64
, ret
, arg1
, arg2
);
706 static inline void tcg_gen_rem_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
708 tcg_gen_helper_1_2(tcg_helper_rem_i64
, ret
, arg1
, arg2
);
711 static inline void tcg_gen_divu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
713 tcg_gen_helper_1_2(tcg_helper_divu_i64
, ret
, arg1
, arg2
);
716 static inline void tcg_gen_remu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
718 tcg_gen_helper_1_2(tcg_helper_remu_i64
, ret
, arg1
, arg2
);
723 static inline void tcg_gen_mov_i64(TCGv ret
, TCGv arg
)
726 tcg_gen_op2(INDEX_op_mov_i64
, ret
, arg
);
729 static inline void tcg_gen_movi_i64(TCGv ret
, int64_t arg
)
731 tcg_gen_op2i(INDEX_op_movi_i64
, ret
, arg
);
734 static inline void tcg_gen_ld8u_i64(TCGv ret
, TCGv arg2
,
735 tcg_target_long offset
)
737 tcg_gen_op3i(INDEX_op_ld8u_i64
, ret
, arg2
, offset
);
740 static inline void tcg_gen_ld8s_i64(TCGv ret
, TCGv arg2
,
741 tcg_target_long offset
)
743 tcg_gen_op3i(INDEX_op_ld8s_i64
, ret
, arg2
, offset
);
746 static inline void tcg_gen_ld16u_i64(TCGv ret
, TCGv arg2
,
747 tcg_target_long offset
)
749 tcg_gen_op3i(INDEX_op_ld16u_i64
, ret
, arg2
, offset
);
752 static inline void tcg_gen_ld16s_i64(TCGv ret
, TCGv arg2
,
753 tcg_target_long offset
)
755 tcg_gen_op3i(INDEX_op_ld16s_i64
, ret
, arg2
, offset
);
758 static inline void tcg_gen_ld32u_i64(TCGv ret
, TCGv arg2
,
759 tcg_target_long offset
)
761 tcg_gen_op3i(INDEX_op_ld32u_i64
, ret
, arg2
, offset
);
764 static inline void tcg_gen_ld32s_i64(TCGv ret
, TCGv arg2
,
765 tcg_target_long offset
)
767 tcg_gen_op3i(INDEX_op_ld32s_i64
, ret
, arg2
, offset
);
770 static inline void tcg_gen_ld_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
772 tcg_gen_op3i(INDEX_op_ld_i64
, ret
, arg2
, offset
);
775 static inline void tcg_gen_st8_i64(TCGv arg1
, TCGv arg2
,
776 tcg_target_long offset
)
778 tcg_gen_op3i(INDEX_op_st8_i64
, arg1
, arg2
, offset
);
781 static inline void tcg_gen_st16_i64(TCGv arg1
, TCGv arg2
,
782 tcg_target_long offset
)
784 tcg_gen_op3i(INDEX_op_st16_i64
, arg1
, arg2
, offset
);
787 static inline void tcg_gen_st32_i64(TCGv arg1
, TCGv arg2
,
788 tcg_target_long offset
)
790 tcg_gen_op3i(INDEX_op_st32_i64
, arg1
, arg2
, offset
);
793 static inline void tcg_gen_st_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
795 tcg_gen_op3i(INDEX_op_st_i64
, arg1
, arg2
, offset
);
798 static inline void tcg_gen_add_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
800 tcg_gen_op3(INDEX_op_add_i64
, ret
, arg1
, arg2
);
803 static inline void tcg_gen_addi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
805 tcg_gen_add_i64(ret
, arg1
, tcg_const_i64(arg2
));
808 static inline void tcg_gen_sub_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
810 tcg_gen_op3(INDEX_op_sub_i64
, ret
, arg1
, arg2
);
813 static inline void tcg_gen_subi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
815 tcg_gen_sub_i64(ret
, arg1
, tcg_const_i64(arg2
));
818 static inline void tcg_gen_and_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
820 tcg_gen_op3(INDEX_op_and_i64
, ret
, arg1
, arg2
);
823 static inline void tcg_gen_andi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
825 tcg_gen_and_i64(ret
, arg1
, tcg_const_i64(arg2
));
828 static inline void tcg_gen_or_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
830 tcg_gen_op3(INDEX_op_or_i64
, ret
, arg1
, arg2
);
833 static inline void tcg_gen_ori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
835 tcg_gen_or_i64(ret
, arg1
, tcg_const_i64(arg2
));
838 static inline void tcg_gen_xor_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
840 tcg_gen_op3(INDEX_op_xor_i64
, ret
, arg1
, arg2
);
843 static inline void tcg_gen_xori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
845 tcg_gen_xor_i64(ret
, arg1
, tcg_const_i64(arg2
));
848 static inline void tcg_gen_shl_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
850 tcg_gen_op3(INDEX_op_shl_i64
, ret
, arg1
, arg2
);
853 static inline void tcg_gen_shli_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
855 tcg_gen_shl_i64(ret
, arg1
, tcg_const_i64(arg2
));
858 static inline void tcg_gen_shr_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
860 tcg_gen_op3(INDEX_op_shr_i64
, ret
, arg1
, arg2
);
863 static inline void tcg_gen_shri_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
865 tcg_gen_shr_i64(ret
, arg1
, tcg_const_i64(arg2
));
868 static inline void tcg_gen_sar_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
870 tcg_gen_op3(INDEX_op_sar_i64
, ret
, arg1
, arg2
);
873 static inline void tcg_gen_sari_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
875 tcg_gen_sar_i64(ret
, arg1
, tcg_const_i64(arg2
));
878 static inline void tcg_gen_brcond_i64(int cond
, TCGv arg1
, TCGv arg2
,
881 tcg_gen_op4ii(INDEX_op_brcond_i64
, arg1
, arg2
, cond
, label_index
);
884 static inline void tcg_gen_mul_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
886 tcg_gen_op3(INDEX_op_mul_i64
, ret
, arg1
, arg2
);
889 #ifdef TCG_TARGET_HAS_div_i64
890 static inline void tcg_gen_div_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
892 tcg_gen_op3(INDEX_op_div_i64
, ret
, arg1
, arg2
);
895 static inline void tcg_gen_rem_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
897 tcg_gen_op3(INDEX_op_rem_i64
, ret
, arg1
, arg2
);
900 static inline void tcg_gen_divu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
902 tcg_gen_op3(INDEX_op_divu_i64
, ret
, arg1
, arg2
);
905 static inline void tcg_gen_remu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
907 tcg_gen_op3(INDEX_op_remu_i64
, ret
, arg1
, arg2
);
910 static inline void tcg_gen_div_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
913 t0
= tcg_temp_new(TCG_TYPE_I64
);
914 tcg_gen_sari_i64(t0
, arg1
, 63);
915 tcg_gen_op5(INDEX_op_div2_i64
, ret
, t0
, arg1
, t0
, arg2
);
918 static inline void tcg_gen_rem_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
921 t0
= tcg_temp_new(TCG_TYPE_I64
);
922 tcg_gen_sari_i64(t0
, arg1
, 63);
923 tcg_gen_op5(INDEX_op_div2_i64
, t0
, ret
, arg1
, t0
, arg2
);
926 static inline void tcg_gen_divu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
929 t0
= tcg_temp_new(TCG_TYPE_I64
);
930 tcg_gen_movi_i64(t0
, 0);
931 tcg_gen_op5(INDEX_op_divu2_i64
, ret
, t0
, arg1
, t0
, arg2
);
934 static inline void tcg_gen_remu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
937 t0
= tcg_temp_new(TCG_TYPE_I64
);
938 tcg_gen_movi_i64(t0
, 0);
939 tcg_gen_op5(INDEX_op_divu2_i64
, t0
, ret
, arg1
, t0
, arg2
);
945 /***************************************/
946 /* optional operations */
948 static inline void tcg_gen_ext8s_i32(TCGv ret
, TCGv arg
)
950 #ifdef TCG_TARGET_HAS_ext8s_i32
951 tcg_gen_op2(INDEX_op_ext8s_i32
, ret
, arg
);
953 tcg_gen_shli_i32(ret
, arg
, 24);
954 tcg_gen_sari_i32(ret
, ret
, 24);
958 static inline void tcg_gen_ext16s_i32(TCGv ret
, TCGv arg
)
960 #ifdef TCG_TARGET_HAS_ext16s_i32
961 tcg_gen_op2(INDEX_op_ext16s_i32
, ret
, arg
);
963 tcg_gen_shli_i32(ret
, arg
, 16);
964 tcg_gen_sari_i32(ret
, ret
, 16);
968 /* Note: we assume the two high bytes are set to zero */
969 static inline void tcg_gen_bswap16_i32(TCGv ret
, TCGv arg
)
971 #ifdef TCG_TARGET_HAS_bswap16_i32
972 tcg_gen_op2(INDEX_op_bswap16_i32
, ret
, arg
);
975 t0
= tcg_temp_new(TCG_TYPE_I32
);
976 t1
= tcg_temp_new(TCG_TYPE_I32
);
978 tcg_gen_shri_i32(t0
, arg
, 8);
979 tcg_gen_andi_i32(t1
, arg
, 0x000000ff);
980 tcg_gen_shli_i32(t1
, t1
, 8);
981 tcg_gen_or_i32(ret
, t0
, t1
);
985 static inline void tcg_gen_bswap_i32(TCGv ret
, TCGv arg
)
987 #ifdef TCG_TARGET_HAS_bswap_i32
988 tcg_gen_op2(INDEX_op_bswap_i32
, ret
, arg
);
991 t0
= tcg_temp_new(TCG_TYPE_I32
);
992 t1
= tcg_temp_new(TCG_TYPE_I32
);
994 tcg_gen_shli_i32(t0
, arg
, 24);
996 tcg_gen_andi_i32(t1
, arg
, 0x0000ff00);
997 tcg_gen_shli_i32(t1
, t1
, 8);
998 tcg_gen_or_i32(t0
, t0
, t1
);
1000 tcg_gen_shri_i32(t1
, arg
, 8);
1001 tcg_gen_andi_i32(t1
, t1
, 0x0000ff00);
1002 tcg_gen_or_i32(t0
, t0
, t1
);
1004 tcg_gen_shri_i32(t1
, arg
, 24);
1005 tcg_gen_or_i32(ret
, t0
, t1
);
1009 #if TCG_TARGET_REG_BITS == 32
1010 static inline void tcg_gen_ext8s_i64(TCGv ret
, TCGv arg
)
1012 tcg_gen_ext8s_i32(ret
, arg
);
1013 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1016 static inline void tcg_gen_ext16s_i64(TCGv ret
, TCGv arg
)
1018 tcg_gen_ext16s_i32(ret
, arg
);
1019 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1022 static inline void tcg_gen_ext32s_i64(TCGv ret
, TCGv arg
)
1024 tcg_gen_mov_i32(ret
, arg
);
1025 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1028 static inline void tcg_gen_trunc_i64_i32(TCGv ret
, TCGv arg
)
1030 tcg_gen_mov_i32(ret
, arg
);
1033 static inline void tcg_gen_extu_i32_i64(TCGv ret
, TCGv arg
)
1035 tcg_gen_mov_i32(ret
, arg
);
1036 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1039 static inline void tcg_gen_ext_i32_i64(TCGv ret
, TCGv arg
)
1041 tcg_gen_mov_i32(ret
, arg
);
1042 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1045 static inline void tcg_gen_bswap_i64(TCGv ret
, TCGv arg
)
1048 t0
= tcg_temp_new(TCG_TYPE_I32
);
1049 t1
= tcg_temp_new(TCG_TYPE_I32
);
1051 tcg_gen_bswap_i32(t0
, arg
);
1052 tcg_gen_bswap_i32(t1
, TCGV_HIGH(arg
));
1053 tcg_gen_mov_i32(ret
, t1
);
1054 tcg_gen_mov_i32(TCGV_HIGH(ret
), t0
);
1058 static inline void tcg_gen_ext8s_i64(TCGv ret
, TCGv arg
)
1060 #ifdef TCG_TARGET_HAS_ext8s_i64
1061 tcg_gen_op2(INDEX_op_ext8s_i64
, ret
, arg
);
1063 tcg_gen_shli_i64(ret
, arg
, 56);
1064 tcg_gen_sari_i64(ret
, ret
, 56);
1068 static inline void tcg_gen_ext16s_i64(TCGv ret
, TCGv arg
)
1070 #ifdef TCG_TARGET_HAS_ext16s_i64
1071 tcg_gen_op2(INDEX_op_ext16s_i64
, ret
, arg
);
1073 tcg_gen_shli_i64(ret
, arg
, 48);
1074 tcg_gen_sari_i64(ret
, ret
, 48);
1078 static inline void tcg_gen_ext32s_i64(TCGv ret
, TCGv arg
)
1080 #ifdef TCG_TARGET_HAS_ext32s_i64
1081 tcg_gen_op2(INDEX_op_ext32s_i64
, ret
, arg
);
1083 tcg_gen_shli_i64(ret
, arg
, 32);
1084 tcg_gen_sari_i64(ret
, ret
, 32);
1088 /* Note: we assume the target supports move between 32 and 64 bit
1089 registers. This will probably break MIPS64 targets. */
1090 static inline void tcg_gen_trunc_i64_i32(TCGv ret
, TCGv arg
)
1092 tcg_gen_mov_i32(ret
, arg
);
1095 /* Note: we assume the target supports move between 32 and 64 bit
1097 static inline void tcg_gen_extu_i32_i64(TCGv ret
, TCGv arg
)
1099 tcg_gen_andi_i64(ret
, arg
, 0xffffffff);
1102 /* Note: we assume the target supports move between 32 and 64 bit
1104 static inline void tcg_gen_ext_i32_i64(TCGv ret
, TCGv arg
)
1106 tcg_gen_ext32s_i64(ret
, arg
);
1109 static inline void tcg_gen_bswap_i64(TCGv ret
, TCGv arg
)
1111 #ifdef TCG_TARGET_HAS_bswap_i64
1112 tcg_gen_op2(INDEX_op_bswap_i64
, ret
, arg
);
1115 t0
= tcg_temp_new(TCG_TYPE_I32
);
1116 t1
= tcg_temp_new(TCG_TYPE_I32
);
1118 tcg_gen_shli_i64(t0
, arg
, 56);
1120 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1121 tcg_gen_shli_i64(t1
, t1
, 40);
1122 tcg_gen_or_i64(t0
, t0
, t1
);
1124 tcg_gen_andi_i64(t1
, arg
, 0x00ff0000);
1125 tcg_gen_shli_i64(t1
, t1
, 24);
1126 tcg_gen_or_i64(t0
, t0
, t1
);
1128 tcg_gen_andi_i64(t1
, arg
, 0xff000000);
1129 tcg_gen_shli_i64(t1
, t1
, 8);
1130 tcg_gen_or_i64(t0
, t0
, t1
);
1132 tcg_gen_shri_i64(t1
, arg
, 8);
1133 tcg_gen_andi_i64(t1
, t1
, 0xff000000);
1134 tcg_gen_or_i64(t0
, t0
, t1
);
1136 tcg_gen_shri_i64(t1
, arg
, 24);
1137 tcg_gen_andi_i64(t1
, t1
, 0x00ff0000);
1138 tcg_gen_or_i64(t0
, t0
, t1
);
1140 tcg_gen_shri_i64(t1
, arg
, 40);
1141 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1142 tcg_gen_or_i64(t0
, t0
, t1
);
1144 tcg_gen_shri_i64(t1
, arg
, 56);
1145 tcg_gen_or_i64(ret
, t0
, t1
);
1152 static inline void tcg_gen_discard_i32(TCGv arg
)
1154 tcg_gen_op1(INDEX_op_discard
, arg
);
1157 #if TCG_TARGET_REG_BITS == 32
1158 static inline void tcg_gen_discard_i64(TCGv arg
)
1160 tcg_gen_discard_i32(arg
);
1161 tcg_gen_discard_i32(TCGV_HIGH(arg
));
1164 static inline void tcg_gen_discard_i64(TCGv arg
)
1166 tcg_gen_op1(INDEX_op_discard
, arg
);
1170 /***************************************/
1171 static inline void tcg_gen_macro_2(TCGv ret0
, TCGv ret1
, int macro_id
)
1173 tcg_gen_op3i(INDEX_op_macro_2
, ret0
, ret1
, macro_id
);
1176 /***************************************/
1177 /* QEMU specific operations. Their type depend on the QEMU CPU
1179 #ifndef TARGET_LONG_BITS
1180 #error must include QEMU headers
1183 static inline void tcg_gen_exit_tb(tcg_target_long val
)
1185 tcg_gen_op1i(INDEX_op_exit_tb
, val
);
1188 static inline void tcg_gen_goto_tb(int idx
)
1190 tcg_gen_op1i(INDEX_op_goto_tb
, idx
);
1193 #if TCG_TARGET_REG_BITS == 32
1194 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
1196 #if TARGET_LONG_BITS == 32
1197 tcg_gen_op3i(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
1199 tcg_gen_op4i(INDEX_op_qemu_ld8u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1200 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1204 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
1206 #if TARGET_LONG_BITS == 32
1207 tcg_gen_op3i(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
1209 tcg_gen_op4i(INDEX_op_qemu_ld8s
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1210 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1214 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
1216 #if TARGET_LONG_BITS == 32
1217 tcg_gen_op3i(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
1219 tcg_gen_op4i(INDEX_op_qemu_ld16u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1220 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1224 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
1226 #if TARGET_LONG_BITS == 32
1227 tcg_gen_op3i(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
1229 tcg_gen_op4i(INDEX_op_qemu_ld16s
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1230 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1234 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
1236 #if TARGET_LONG_BITS == 32
1237 tcg_gen_op3i(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1239 tcg_gen_op4i(INDEX_op_qemu_ld32u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1240 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1244 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
1246 #if TARGET_LONG_BITS == 32
1247 tcg_gen_op3i(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1249 tcg_gen_op4i(INDEX_op_qemu_ld32u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1250 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1254 static inline void tcg_gen_qemu_ld64(TCGv ret
, TCGv addr
, int mem_index
)
1256 #if TARGET_LONG_BITS == 32
1257 tcg_gen_op4i(INDEX_op_qemu_ld64
, ret
, TCGV_HIGH(ret
), addr
, mem_index
);
1259 tcg_gen_op5i(INDEX_op_qemu_ld64
, ret
, TCGV_HIGH(ret
),
1260 addr
, TCGV_HIGH(addr
), mem_index
);
1264 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
1266 #if TARGET_LONG_BITS == 32
1267 tcg_gen_op3i(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
1269 tcg_gen_op4i(INDEX_op_qemu_st8
, arg
, addr
, TCGV_HIGH(addr
), mem_index
);
1273 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
1275 #if TARGET_LONG_BITS == 32
1276 tcg_gen_op3i(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
1278 tcg_gen_op4i(INDEX_op_qemu_st16
, arg
, addr
, TCGV_HIGH(addr
), mem_index
);
1282 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
1284 #if TARGET_LONG_BITS == 32
1285 tcg_gen_op3i(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
1287 tcg_gen_op4i(INDEX_op_qemu_st32
, arg
, addr
, TCGV_HIGH(addr
), mem_index
);
1291 static inline void tcg_gen_qemu_st64(TCGv arg
, TCGv addr
, int mem_index
)
1293 #if TARGET_LONG_BITS == 32
1294 tcg_gen_op4i(INDEX_op_qemu_st64
, arg
, TCGV_HIGH(arg
), addr
, mem_index
);
1296 tcg_gen_op5i(INDEX_op_qemu_st64
, arg
, TCGV_HIGH(arg
),
1297 addr
, TCGV_HIGH(addr
), mem_index
);
1301 #define tcg_gen_ld_ptr tcg_gen_ld_i32
1302 #define tcg_gen_discard_ptr tcg_gen_discard_i32
1304 #else /* TCG_TARGET_REG_BITS == 32 */
1306 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
1308 tcg_gen_op3i(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
1311 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
1313 tcg_gen_op3i(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
1316 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
1318 tcg_gen_op3i(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
1321 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
1323 tcg_gen_op3i(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
1326 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
1328 tcg_gen_op3i(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1331 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
1333 tcg_gen_op3i(INDEX_op_qemu_ld32s
, ret
, addr
, mem_index
);
1336 static inline void tcg_gen_qemu_ld64(TCGv ret
, TCGv addr
, int mem_index
)
1338 tcg_gen_op3i(INDEX_op_qemu_ld64
, ret
, addr
, mem_index
);
1341 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
1343 tcg_gen_op3i(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
1346 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
1348 tcg_gen_op3i(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
1351 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
1353 tcg_gen_op3i(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
1356 static inline void tcg_gen_qemu_st64(TCGv arg
, TCGv addr
, int mem_index
)
1358 tcg_gen_op3i(INDEX_op_qemu_st64
, arg
, addr
, mem_index
);
1361 #define tcg_gen_ld_ptr tcg_gen_ld_i64
1362 #define tcg_gen_discard_ptr tcg_gen_discard_i64
1364 #endif /* TCG_TARGET_REG_BITS != 32 */
1366 #if TARGET_LONG_BITS == 64
1367 #define TCG_TYPE_TL TCG_TYPE_I64
1368 #define tcg_gen_movi_tl tcg_gen_movi_i64
1369 #define tcg_gen_mov_tl tcg_gen_mov_i64
1370 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
1371 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
1372 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
1373 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
1374 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
1375 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
1376 #define tcg_gen_ld_tl tcg_gen_ld_i64
1377 #define tcg_gen_st8_tl tcg_gen_st8_i64
1378 #define tcg_gen_st16_tl tcg_gen_st16_i64
1379 #define tcg_gen_st32_tl tcg_gen_st32_i64
1380 #define tcg_gen_st_tl tcg_gen_st_i64
1381 #define tcg_gen_add_tl tcg_gen_add_i64
1382 #define tcg_gen_addi_tl tcg_gen_addi_i64
1383 #define tcg_gen_sub_tl tcg_gen_sub_i64
1384 #define tcg_gen_subi_tl tcg_gen_subi_i64
1385 #define tcg_gen_and_tl tcg_gen_and_i64
1386 #define tcg_gen_andi_tl tcg_gen_andi_i64
1387 #define tcg_gen_or_tl tcg_gen_or_i64
1388 #define tcg_gen_ori_tl tcg_gen_ori_i64
1389 #define tcg_gen_xor_tl tcg_gen_xor_i64
1390 #define tcg_gen_xori_tl tcg_gen_xori_i64
1391 #define tcg_gen_shl_tl tcg_gen_shl_i64
1392 #define tcg_gen_shli_tl tcg_gen_shli_i64
1393 #define tcg_gen_shr_tl tcg_gen_shr_i64
1394 #define tcg_gen_shri_tl tcg_gen_shri_i64
1395 #define tcg_gen_sar_tl tcg_gen_sar_i64
1396 #define tcg_gen_sari_tl tcg_gen_sari_i64
1397 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
1398 #define tcg_gen_discard_tl tcg_gen_discard_i64
1399 #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
1400 #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
1401 #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
1402 #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
1403 #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
1404 #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
1405 #define tcg_const_tl tcg_const_i64
1407 #define TCG_TYPE_TL TCG_TYPE_I32
1408 #define tcg_gen_movi_tl tcg_gen_movi_i32
1409 #define tcg_gen_mov_tl tcg_gen_mov_i32
1410 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
1411 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
1412 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
1413 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
1414 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
1415 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
1416 #define tcg_gen_ld_tl tcg_gen_ld_i32
1417 #define tcg_gen_st8_tl tcg_gen_st8_i32
1418 #define tcg_gen_st16_tl tcg_gen_st16_i32
1419 #define tcg_gen_st32_tl tcg_gen_st_i32
1420 #define tcg_gen_st_tl tcg_gen_st_i32
1421 #define tcg_gen_add_tl tcg_gen_add_i32
1422 #define tcg_gen_addi_tl tcg_gen_addi_i32
1423 #define tcg_gen_sub_tl tcg_gen_sub_i32
1424 #define tcg_gen_subi_tl tcg_gen_subi_i32
1425 #define tcg_gen_and_tl tcg_gen_and_i32
1426 #define tcg_gen_andi_tl tcg_gen_andi_i32
1427 #define tcg_gen_or_tl tcg_gen_or_i32
1428 #define tcg_gen_ori_tl tcg_gen_ori_i32
1429 #define tcg_gen_xor_tl tcg_gen_xor_i32
1430 #define tcg_gen_xori_tl tcg_gen_xori_i32
1431 #define tcg_gen_shl_tl tcg_gen_shl_i32
1432 #define tcg_gen_shli_tl tcg_gen_shli_i32
1433 #define tcg_gen_shr_tl tcg_gen_shr_i32
1434 #define tcg_gen_shri_tl tcg_gen_shri_i32
1435 #define tcg_gen_sar_tl tcg_gen_sar_i32
1436 #define tcg_gen_sari_tl tcg_gen_sari_i32
1437 #define tcg_gen_brcond_tl tcg_gen_brcond_i32
1438 #define tcg_gen_discard_tl tcg_gen_discard_i32
1439 #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
1440 #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
1441 #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
1442 #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
1443 #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
1444 #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
1445 #define tcg_const_tl tcg_const_i32
1448 #if TCG_TARGET_REG_BITS == 32
1449 #define tcg_gen_addi_ptr tcg_gen_addi_i32
1450 #else /* TCG_TARGET_REG_BITS == 32 */
1451 #define tcg_gen_addi_ptr tcg_gen_addi_i64
1452 #endif /* TCG_TARGET_REG_BITS != 32 */