]>
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
)
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_3(void *func
,
203 TCGv arg1
, TCGv arg2
, TCGv arg3
)
209 tcg_gen_call(&tcg_ctx
,
210 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
214 static inline void tcg_gen_helper_0_4(void *func
, TCGv arg1
, TCGv arg2
,
215 TCGv arg3
, TCGv arg4
)
222 tcg_gen_call(&tcg_ctx
,
223 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
227 static inline void tcg_gen_helper_1_0(void *func
, TCGv ret
)
229 tcg_gen_call(&tcg_ctx
,
230 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
234 static inline void tcg_gen_helper_1_1(void *func
, TCGv ret
, TCGv arg1
)
236 tcg_gen_call(&tcg_ctx
,
237 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
241 static inline void tcg_gen_helper_1_2(void *func
, TCGv ret
,
242 TCGv arg1
, TCGv arg2
)
247 tcg_gen_call(&tcg_ctx
,
248 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
252 static inline void tcg_gen_helper_1_3(void *func
, TCGv ret
,
253 TCGv arg1
, TCGv arg2
, TCGv arg3
)
259 tcg_gen_call(&tcg_ctx
,
260 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
264 static inline void tcg_gen_helper_1_4(void *func
, TCGv ret
,
265 TCGv arg1
, TCGv arg2
, TCGv arg3
,
273 tcg_gen_call(&tcg_ctx
,
274 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
280 static inline void tcg_gen_ld8u_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
282 tcg_gen_op3i(INDEX_op_ld8u_i32
, ret
, arg2
, offset
);
285 static inline void tcg_gen_ld8s_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
287 tcg_gen_op3i(INDEX_op_ld8s_i32
, ret
, arg2
, offset
);
290 static inline void tcg_gen_ld16u_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
292 tcg_gen_op3i(INDEX_op_ld16u_i32
, ret
, arg2
, offset
);
295 static inline void tcg_gen_ld16s_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
297 tcg_gen_op3i(INDEX_op_ld16s_i32
, ret
, arg2
, offset
);
300 static inline void tcg_gen_ld_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
302 tcg_gen_op3i(INDEX_op_ld_i32
, ret
, arg2
, offset
);
305 static inline void tcg_gen_st8_i32(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
307 tcg_gen_op3i(INDEX_op_st8_i32
, arg1
, arg2
, offset
);
310 static inline void tcg_gen_st16_i32(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
312 tcg_gen_op3i(INDEX_op_st16_i32
, arg1
, arg2
, offset
);
315 static inline void tcg_gen_st_i32(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
317 tcg_gen_op3i(INDEX_op_st_i32
, arg1
, arg2
, offset
);
320 static inline void tcg_gen_add_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
322 tcg_gen_op3(INDEX_op_add_i32
, ret
, arg1
, arg2
);
325 static inline void tcg_gen_addi_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
327 /* some cases can be optimized here */
329 tcg_gen_mov_i32(ret
, arg1
);
331 tcg_gen_add_i32(ret
, arg1
, tcg_const_i32(arg2
));
335 static inline void tcg_gen_sub_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
337 tcg_gen_op3(INDEX_op_sub_i32
, ret
, arg1
, arg2
);
340 static inline void tcg_gen_subi_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
342 /* some cases can be optimized here */
344 tcg_gen_mov_i32(ret
, arg1
);
346 tcg_gen_sub_i32(ret
, arg1
, tcg_const_i32(arg2
));
350 static inline void tcg_gen_and_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
352 tcg_gen_op3(INDEX_op_and_i32
, ret
, arg1
, arg2
);
355 static inline void tcg_gen_andi_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
357 /* some cases can be optimized here */
359 tcg_gen_movi_i32(ret
, 0);
360 } else if (arg2
== 0xffffffff) {
361 tcg_gen_mov_i32(ret
, arg1
);
363 tcg_gen_and_i32(ret
, arg1
, tcg_const_i32(arg2
));
367 static inline void tcg_gen_or_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
369 tcg_gen_op3(INDEX_op_or_i32
, ret
, arg1
, arg2
);
372 static inline void tcg_gen_ori_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
374 /* some cases can be optimized here */
375 if (arg2
== 0xffffffff) {
376 tcg_gen_movi_i32(ret
, 0xffffffff);
377 } else if (arg2
== 0) {
378 tcg_gen_mov_i32(ret
, arg1
);
380 tcg_gen_or_i32(ret
, arg1
, tcg_const_i32(arg2
));
384 static inline void tcg_gen_xor_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
386 tcg_gen_op3(INDEX_op_xor_i32
, ret
, arg1
, arg2
);
389 static inline void tcg_gen_xori_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
391 /* some cases can be optimized here */
393 tcg_gen_mov_i32(ret
, arg1
);
395 tcg_gen_xor_i32(ret
, arg1
, tcg_const_i32(arg2
));
399 static inline void tcg_gen_shl_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
401 tcg_gen_op3(INDEX_op_shl_i32
, ret
, arg1
, arg2
);
404 static inline void tcg_gen_shli_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
406 tcg_gen_shl_i32(ret
, arg1
, tcg_const_i32(arg2
));
409 static inline void tcg_gen_shr_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
411 tcg_gen_op3(INDEX_op_shr_i32
, ret
, arg1
, arg2
);
414 static inline void tcg_gen_shri_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
416 tcg_gen_shr_i32(ret
, arg1
, tcg_const_i32(arg2
));
419 static inline void tcg_gen_sar_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
421 tcg_gen_op3(INDEX_op_sar_i32
, ret
, arg1
, arg2
);
424 static inline void tcg_gen_sari_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
426 tcg_gen_sar_i32(ret
, arg1
, tcg_const_i32(arg2
));
429 static inline void tcg_gen_brcond_i32(int cond
, TCGv arg1
, TCGv arg2
,
432 tcg_gen_op4ii(INDEX_op_brcond_i32
, arg1
, arg2
, cond
, label_index
);
435 static inline void tcg_gen_mul_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
437 tcg_gen_op3(INDEX_op_mul_i32
, ret
, arg1
, arg2
);
440 #ifdef TCG_TARGET_HAS_div_i32
441 static inline void tcg_gen_div_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
443 tcg_gen_op3(INDEX_op_div_i32
, ret
, arg1
, arg2
);
446 static inline void tcg_gen_rem_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
448 tcg_gen_op3(INDEX_op_rem_i32
, ret
, arg1
, arg2
);
451 static inline void tcg_gen_divu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
453 tcg_gen_op3(INDEX_op_divu_i32
, ret
, arg1
, arg2
);
456 static inline void tcg_gen_remu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
458 tcg_gen_op3(INDEX_op_remu_i32
, ret
, arg1
, arg2
);
461 static inline void tcg_gen_div_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
464 t0
= tcg_temp_new(TCG_TYPE_I32
);
465 tcg_gen_sari_i32(t0
, arg1
, 31);
466 tcg_gen_op5(INDEX_op_div2_i32
, ret
, t0
, arg1
, t0
, arg2
);
469 static inline void tcg_gen_rem_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
472 t0
= tcg_temp_new(TCG_TYPE_I32
);
473 tcg_gen_sari_i32(t0
, arg1
, 31);
474 tcg_gen_op5(INDEX_op_div2_i32
, t0
, ret
, arg1
, t0
, arg2
);
477 static inline void tcg_gen_divu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
480 t0
= tcg_temp_new(TCG_TYPE_I32
);
481 tcg_gen_movi_i32(t0
, 0);
482 tcg_gen_op5(INDEX_op_divu2_i32
, ret
, t0
, arg1
, t0
, arg2
);
485 static inline void tcg_gen_remu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
488 t0
= tcg_temp_new(TCG_TYPE_I32
);
489 tcg_gen_movi_i32(t0
, 0);
490 tcg_gen_op5(INDEX_op_divu2_i32
, t0
, ret
, arg1
, t0
, arg2
);
494 #if TCG_TARGET_REG_BITS == 32
496 static inline void tcg_gen_mov_i64(TCGv ret
, TCGv arg
)
498 tcg_gen_mov_i32(ret
, arg
);
499 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
502 static inline void tcg_gen_movi_i64(TCGv ret
, int64_t arg
)
504 tcg_gen_movi_i32(ret
, arg
);
505 tcg_gen_movi_i32(TCGV_HIGH(ret
), arg
>> 32);
508 static inline void tcg_gen_ld8u_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
510 tcg_gen_ld8u_i32(ret
, arg2
, offset
);
511 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
514 static inline void tcg_gen_ld8s_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
516 tcg_gen_ld8s_i32(ret
, arg2
, offset
);
517 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
520 static inline void tcg_gen_ld16u_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
522 tcg_gen_ld16u_i32(ret
, arg2
, offset
);
523 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
526 static inline void tcg_gen_ld16s_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
528 tcg_gen_ld16s_i32(ret
, arg2
, offset
);
529 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
532 static inline void tcg_gen_ld32u_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
534 tcg_gen_ld_i32(ret
, arg2
, offset
);
535 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
538 static inline void tcg_gen_ld32s_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
540 tcg_gen_ld_i32(ret
, arg2
, offset
);
541 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
544 static inline void tcg_gen_ld_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
546 /* since arg2 and ret have different types, they cannot be the
548 #ifdef TCG_TARGET_WORDS_BIGENDIAN
549 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
);
550 tcg_gen_ld_i32(ret
, arg2
, offset
+ 4);
552 tcg_gen_ld_i32(ret
, arg2
, offset
);
553 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
+ 4);
557 static inline void tcg_gen_st8_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
559 tcg_gen_st8_i32(arg1
, arg2
, offset
);
562 static inline void tcg_gen_st16_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
564 tcg_gen_st16_i32(arg1
, arg2
, offset
);
567 static inline void tcg_gen_st32_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
569 tcg_gen_st_i32(arg1
, arg2
, offset
);
572 static inline void tcg_gen_st_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
574 #ifdef TCG_TARGET_WORDS_BIGENDIAN
575 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
);
576 tcg_gen_st_i32(arg1
, arg2
, offset
+ 4);
578 tcg_gen_st_i32(arg1
, arg2
, offset
);
579 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
+ 4);
583 static inline void tcg_gen_add_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
585 tcg_gen_op6(INDEX_op_add2_i32
, ret
, TCGV_HIGH(ret
),
586 arg1
, TCGV_HIGH(arg1
), arg2
, TCGV_HIGH(arg2
));
589 static inline void tcg_gen_addi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
591 tcg_gen_add_i64(ret
, arg1
, tcg_const_i64(arg2
));
594 static inline void tcg_gen_sub_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
596 tcg_gen_op6(INDEX_op_sub2_i32
, ret
, TCGV_HIGH(ret
),
597 arg1
, TCGV_HIGH(arg1
), arg2
, TCGV_HIGH(arg2
));
600 static inline void tcg_gen_subi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
602 tcg_gen_sub_i64(ret
, arg1
, tcg_const_i64(arg2
));
605 static inline void tcg_gen_and_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
607 tcg_gen_and_i32(ret
, arg1
, arg2
);
608 tcg_gen_and_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
611 static inline void tcg_gen_andi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
613 tcg_gen_andi_i32(ret
, arg1
, arg2
);
614 tcg_gen_andi_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
617 static inline void tcg_gen_or_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
619 tcg_gen_or_i32(ret
, arg1
, arg2
);
620 tcg_gen_or_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
623 static inline void tcg_gen_ori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
625 tcg_gen_ori_i32(ret
, arg1
, arg2
);
626 tcg_gen_ori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
629 static inline void tcg_gen_xor_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
631 tcg_gen_xor_i32(ret
, arg1
, arg2
);
632 tcg_gen_xor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
635 static inline void tcg_gen_xori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
637 tcg_gen_xori_i32(ret
, arg1
, arg2
);
638 tcg_gen_xori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
641 /* XXX: use generic code when basic block handling is OK or CPU
642 specific code (x86) */
643 static inline void tcg_gen_shl_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
645 tcg_gen_helper_1_2(tcg_helper_shl_i64
, ret
, arg1
, arg2
);
648 static inline void tcg_gen_shli_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
650 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 0, 0);
653 static inline void tcg_gen_shr_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
655 tcg_gen_helper_1_2(tcg_helper_shr_i64
, ret
, arg1
, arg2
);
658 static inline void tcg_gen_shri_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
660 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 0);
663 static inline void tcg_gen_sar_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
665 tcg_gen_helper_1_2(tcg_helper_sar_i64
, ret
, arg1
, arg2
);
668 static inline void tcg_gen_sari_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
670 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 1);
673 static inline void tcg_gen_brcond_i64(int cond
, TCGv arg1
, TCGv arg2
,
676 tcg_gen_op6ii(INDEX_op_brcond2_i32
,
677 arg1
, TCGV_HIGH(arg1
), arg2
, TCGV_HIGH(arg2
),
681 static inline void tcg_gen_mul_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
685 t0
= tcg_temp_new(TCG_TYPE_I64
);
686 t1
= tcg_temp_new(TCG_TYPE_I32
);
688 tcg_gen_op4(INDEX_op_mulu2_i32
, t0
, TCGV_HIGH(t0
), arg1
, arg2
);
690 tcg_gen_mul_i32(t1
, arg1
, TCGV_HIGH(arg2
));
691 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
692 tcg_gen_mul_i32(t1
, TCGV_HIGH(arg1
), arg2
);
693 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
695 tcg_gen_mov_i64(ret
, t0
);
698 static inline void tcg_gen_div_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
700 tcg_gen_helper_1_2(tcg_helper_div_i64
, ret
, arg1
, arg2
);
703 static inline void tcg_gen_rem_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
705 tcg_gen_helper_1_2(tcg_helper_rem_i64
, ret
, arg1
, arg2
);
708 static inline void tcg_gen_divu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
710 tcg_gen_helper_1_2(tcg_helper_divu_i64
, ret
, arg1
, arg2
);
713 static inline void tcg_gen_remu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
715 tcg_gen_helper_1_2(tcg_helper_remu_i64
, ret
, arg1
, arg2
);
720 static inline void tcg_gen_mov_i64(TCGv ret
, TCGv arg
)
722 tcg_gen_op2(INDEX_op_mov_i64
, ret
, arg
);
725 static inline void tcg_gen_movi_i64(TCGv ret
, int64_t arg
)
727 tcg_gen_op2i(INDEX_op_movi_i64
, ret
, arg
);
730 static inline void tcg_gen_ld8u_i64(TCGv ret
, TCGv arg2
,
731 tcg_target_long offset
)
733 tcg_gen_op3i(INDEX_op_ld8u_i64
, ret
, arg2
, offset
);
736 static inline void tcg_gen_ld8s_i64(TCGv ret
, TCGv arg2
,
737 tcg_target_long offset
)
739 tcg_gen_op3i(INDEX_op_ld8s_i64
, ret
, arg2
, offset
);
742 static inline void tcg_gen_ld16u_i64(TCGv ret
, TCGv arg2
,
743 tcg_target_long offset
)
745 tcg_gen_op3i(INDEX_op_ld16u_i64
, ret
, arg2
, offset
);
748 static inline void tcg_gen_ld16s_i64(TCGv ret
, TCGv arg2
,
749 tcg_target_long offset
)
751 tcg_gen_op3i(INDEX_op_ld16s_i64
, ret
, arg2
, offset
);
754 static inline void tcg_gen_ld32u_i64(TCGv ret
, TCGv arg2
,
755 tcg_target_long offset
)
757 tcg_gen_op3i(INDEX_op_ld32u_i64
, ret
, arg2
, offset
);
760 static inline void tcg_gen_ld32s_i64(TCGv ret
, TCGv arg2
,
761 tcg_target_long offset
)
763 tcg_gen_op3i(INDEX_op_ld32s_i64
, ret
, arg2
, offset
);
766 static inline void tcg_gen_ld_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
768 tcg_gen_op3i(INDEX_op_ld_i64
, ret
, arg2
, offset
);
771 static inline void tcg_gen_st8_i64(TCGv arg1
, TCGv arg2
,
772 tcg_target_long offset
)
774 tcg_gen_op3i(INDEX_op_st8_i64
, arg1
, arg2
, offset
);
777 static inline void tcg_gen_st16_i64(TCGv arg1
, TCGv arg2
,
778 tcg_target_long offset
)
780 tcg_gen_op3i(INDEX_op_st16_i64
, arg1
, arg2
, offset
);
783 static inline void tcg_gen_st32_i64(TCGv arg1
, TCGv arg2
,
784 tcg_target_long offset
)
786 tcg_gen_op3i(INDEX_op_st32_i64
, arg1
, arg2
, offset
);
789 static inline void tcg_gen_st_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
791 tcg_gen_op3i(INDEX_op_st_i64
, arg1
, arg2
, offset
);
794 static inline void tcg_gen_add_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
796 tcg_gen_op3(INDEX_op_add_i64
, ret
, arg1
, arg2
);
799 static inline void tcg_gen_addi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
801 tcg_gen_add_i64(ret
, arg1
, tcg_const_i64(arg2
));
804 static inline void tcg_gen_sub_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
806 tcg_gen_op3(INDEX_op_sub_i64
, ret
, arg1
, arg2
);
809 static inline void tcg_gen_subi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
811 tcg_gen_sub_i64(ret
, arg1
, tcg_const_i64(arg2
));
814 static inline void tcg_gen_and_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
816 tcg_gen_op3(INDEX_op_and_i64
, ret
, arg1
, arg2
);
819 static inline void tcg_gen_andi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
821 tcg_gen_and_i64(ret
, arg1
, tcg_const_i64(arg2
));
824 static inline void tcg_gen_or_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
826 tcg_gen_op3(INDEX_op_or_i64
, ret
, arg1
, arg2
);
829 static inline void tcg_gen_ori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
831 tcg_gen_or_i64(ret
, arg1
, tcg_const_i64(arg2
));
834 static inline void tcg_gen_xor_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
836 tcg_gen_op3(INDEX_op_xor_i64
, ret
, arg1
, arg2
);
839 static inline void tcg_gen_xori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
841 tcg_gen_xor_i64(ret
, arg1
, tcg_const_i64(arg2
));
844 static inline void tcg_gen_shl_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
846 tcg_gen_op3(INDEX_op_shl_i64
, ret
, arg1
, arg2
);
849 static inline void tcg_gen_shli_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
851 tcg_gen_shl_i64(ret
, arg1
, tcg_const_i64(arg2
));
854 static inline void tcg_gen_shr_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
856 tcg_gen_op3(INDEX_op_shr_i64
, ret
, arg1
, arg2
);
859 static inline void tcg_gen_shri_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
861 tcg_gen_shr_i64(ret
, arg1
, tcg_const_i64(arg2
));
864 static inline void tcg_gen_sar_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
866 tcg_gen_op3(INDEX_op_sar_i64
, ret
, arg1
, arg2
);
869 static inline void tcg_gen_sari_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
871 tcg_gen_sar_i64(ret
, arg1
, tcg_const_i64(arg2
));
874 static inline void tcg_gen_brcond_i64(int cond
, TCGv arg1
, TCGv arg2
,
877 tcg_gen_op4ii(INDEX_op_brcond_i64
, arg1
, arg2
, cond
, label_index
);
880 static inline void tcg_gen_mul_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
882 tcg_gen_op3(INDEX_op_mul_i64
, ret
, arg1
, arg2
);
885 #ifdef TCG_TARGET_HAS_div_i64
886 static inline void tcg_gen_div_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
888 tcg_gen_op3(INDEX_op_div_i64
, ret
, arg1
, arg2
);
891 static inline void tcg_gen_rem_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
893 tcg_gen_op3(INDEX_op_rem_i64
, ret
, arg1
, arg2
);
896 static inline void tcg_gen_divu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
898 tcg_gen_op3(INDEX_op_divu_i64
, ret
, arg1
, arg2
);
901 static inline void tcg_gen_remu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
903 tcg_gen_op3(INDEX_op_remu_i64
, ret
, arg1
, arg2
);
906 static inline void tcg_gen_div_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
909 t0
= tcg_temp_new(TCG_TYPE_I64
);
910 tcg_gen_sari_i64(t0
, arg1
, 63);
911 tcg_gen_op5(INDEX_op_div2_i64
, ret
, t0
, arg1
, t0
, arg2
);
914 static inline void tcg_gen_rem_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
917 t0
= tcg_temp_new(TCG_TYPE_I64
);
918 tcg_gen_sari_i64(t0
, arg1
, 63);
919 tcg_gen_op5(INDEX_op_div2_i64
, t0
, ret
, arg1
, t0
, arg2
);
922 static inline void tcg_gen_divu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
925 t0
= tcg_temp_new(TCG_TYPE_I64
);
926 tcg_gen_movi_i64(t0
, 0);
927 tcg_gen_op5(INDEX_op_divu2_i64
, ret
, t0
, arg1
, t0
, arg2
);
930 static inline void tcg_gen_remu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
933 t0
= tcg_temp_new(TCG_TYPE_I64
);
934 tcg_gen_movi_i64(t0
, 0);
935 tcg_gen_op5(INDEX_op_divu2_i64
, t0
, ret
, arg1
, t0
, arg2
);
941 /***************************************/
942 /* optional operations */
944 static inline void tcg_gen_ext8s_i32(TCGv ret
, TCGv arg
)
946 #ifdef TCG_TARGET_HAS_ext8s_i32
947 tcg_gen_op2(INDEX_op_ext8s_i32
, ret
, arg
);
949 tcg_gen_shli_i32(ret
, arg
, 24);
950 tcg_gen_sari_i32(ret
, ret
, 24);
954 static inline void tcg_gen_ext16s_i32(TCGv ret
, TCGv arg
)
956 #ifdef TCG_TARGET_HAS_ext16s_i32
957 tcg_gen_op2(INDEX_op_ext16s_i32
, ret
, arg
);
959 tcg_gen_shli_i32(ret
, arg
, 16);
960 tcg_gen_sari_i32(ret
, ret
, 16);
964 /* Note: we assume the two high bytes are set to zero */
965 static inline void tcg_gen_bswap16_i32(TCGv ret
, TCGv arg
)
967 #ifdef TCG_TARGET_HAS_bswap16_i32
968 tcg_gen_op2(INDEX_op_bswap16_i32
, ret
, arg
);
971 t0
= tcg_temp_new(TCG_TYPE_I32
);
972 t1
= tcg_temp_new(TCG_TYPE_I32
);
974 tcg_gen_shri_i32(t0
, arg
, 8);
975 tcg_gen_andi_i32(t1
, arg
, 0x000000ff);
976 tcg_gen_shli_i32(t1
, t1
, 8);
977 tcg_gen_or_i32(ret
, t0
, t1
);
981 static inline void tcg_gen_bswap_i32(TCGv ret
, TCGv arg
)
983 #ifdef TCG_TARGET_HAS_bswap_i32
984 tcg_gen_op2(INDEX_op_bswap_i32
, ret
, arg
);
987 t0
= tcg_temp_new(TCG_TYPE_I32
);
988 t1
= tcg_temp_new(TCG_TYPE_I32
);
990 tcg_gen_shli_i32(t0
, arg
, 24);
992 tcg_gen_andi_i32(t1
, arg
, 0x0000ff00);
993 tcg_gen_shli_i32(t1
, t1
, 8);
994 tcg_gen_or_i32(t0
, t0
, t1
);
996 tcg_gen_shri_i32(t1
, arg
, 8);
997 tcg_gen_andi_i32(t1
, t1
, 0x0000ff00);
998 tcg_gen_or_i32(t0
, t0
, t1
);
1000 tcg_gen_shri_i32(t1
, arg
, 24);
1001 tcg_gen_or_i32(ret
, t0
, t1
);
1005 #if TCG_TARGET_REG_BITS == 32
1006 static inline void tcg_gen_ext8s_i64(TCGv ret
, TCGv arg
)
1008 tcg_gen_ext8s_i32(ret
, arg
);
1009 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1012 static inline void tcg_gen_ext16s_i64(TCGv ret
, TCGv arg
)
1014 tcg_gen_ext16s_i32(ret
, arg
);
1015 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1018 static inline void tcg_gen_ext32s_i64(TCGv ret
, TCGv arg
)
1020 tcg_gen_mov_i32(ret
, arg
);
1021 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1024 static inline void tcg_gen_trunc_i64_i32(TCGv ret
, TCGv arg
)
1026 tcg_gen_mov_i32(ret
, arg
);
1029 static inline void tcg_gen_extu_i32_i64(TCGv ret
, TCGv arg
)
1031 tcg_gen_mov_i32(ret
, arg
);
1032 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1035 static inline void tcg_gen_ext_i32_i64(TCGv ret
, TCGv arg
)
1037 tcg_gen_mov_i32(ret
, arg
);
1038 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1041 static inline void tcg_gen_bswap_i64(TCGv ret
, TCGv arg
)
1044 t0
= tcg_temp_new(TCG_TYPE_I32
);
1045 t1
= tcg_temp_new(TCG_TYPE_I32
);
1047 tcg_gen_bswap_i32(t0
, arg
);
1048 tcg_gen_bswap_i32(t1
, TCGV_HIGH(arg
));
1049 tcg_gen_mov_i32(ret
, t1
);
1050 tcg_gen_mov_i32(TCGV_HIGH(ret
), t0
);
1054 static inline void tcg_gen_ext8s_i64(TCGv ret
, TCGv arg
)
1056 #ifdef TCG_TARGET_HAS_ext8s_i64
1057 tcg_gen_op2(INDEX_op_ext8s_i64
, ret
, arg
);
1059 tcg_gen_shli_i64(ret
, arg
, 56);
1060 tcg_gen_sari_i64(ret
, ret
, 56);
1064 static inline void tcg_gen_ext16s_i64(TCGv ret
, TCGv arg
)
1066 #ifdef TCG_TARGET_HAS_ext16s_i64
1067 tcg_gen_op2(INDEX_op_ext16s_i64
, ret
, arg
);
1069 tcg_gen_shli_i64(ret
, arg
, 48);
1070 tcg_gen_sari_i64(ret
, ret
, 48);
1074 static inline void tcg_gen_ext32s_i64(TCGv ret
, TCGv arg
)
1076 #ifdef TCG_TARGET_HAS_ext32s_i64
1077 tcg_gen_op2(INDEX_op_ext32s_i64
, ret
, arg
);
1079 tcg_gen_shli_i64(ret
, arg
, 32);
1080 tcg_gen_sari_i64(ret
, ret
, 32);
1084 /* Note: we assume the target supports move between 32 and 64 bit
1085 registers. This will probably break MIPS64 targets. */
1086 static inline void tcg_gen_trunc_i64_i32(TCGv ret
, TCGv arg
)
1088 tcg_gen_mov_i32(ret
, arg
);
1091 /* Note: we assume the target supports move between 32 and 64 bit
1093 static inline void tcg_gen_extu_i32_i64(TCGv ret
, TCGv arg
)
1095 tcg_gen_andi_i64(ret
, arg
, 0xffffffff);
1098 /* Note: we assume the target supports move between 32 and 64 bit
1100 static inline void tcg_gen_ext_i32_i64(TCGv ret
, TCGv arg
)
1102 tcg_gen_ext32s_i64(ret
, arg
);
1105 static inline void tcg_gen_bswap_i64(TCGv ret
, TCGv arg
)
1107 #ifdef TCG_TARGET_HAS_bswap_i64
1108 tcg_gen_op2(INDEX_op_bswap_i64
, ret
, arg
);
1111 t0
= tcg_temp_new(TCG_TYPE_I32
);
1112 t1
= tcg_temp_new(TCG_TYPE_I32
);
1114 tcg_gen_shli_i64(t0
, arg
, 56);
1116 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1117 tcg_gen_shli_i64(t1
, t1
, 40);
1118 tcg_gen_or_i64(t0
, t0
, t1
);
1120 tcg_gen_andi_i64(t1
, arg
, 0x00ff0000);
1121 tcg_gen_shli_i64(t1
, t1
, 24);
1122 tcg_gen_or_i64(t0
, t0
, t1
);
1124 tcg_gen_andi_i64(t1
, arg
, 0xff000000);
1125 tcg_gen_shli_i64(t1
, t1
, 8);
1126 tcg_gen_or_i64(t0
, t0
, t1
);
1128 tcg_gen_shri_i64(t1
, arg
, 8);
1129 tcg_gen_andi_i64(t1
, t1
, 0xff000000);
1130 tcg_gen_or_i64(t0
, t0
, t1
);
1132 tcg_gen_shri_i64(t1
, arg
, 24);
1133 tcg_gen_andi_i64(t1
, t1
, 0x00ff0000);
1134 tcg_gen_or_i64(t0
, t0
, t1
);
1136 tcg_gen_shri_i64(t1
, arg
, 40);
1137 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1138 tcg_gen_or_i64(t0
, t0
, t1
);
1140 tcg_gen_shri_i64(t1
, arg
, 56);
1141 tcg_gen_or_i64(ret
, t0
, t1
);
1148 static inline void tcg_gen_discard_i32(TCGv arg
)
1150 tcg_gen_op1(INDEX_op_discard
, arg
);
1153 #if TCG_TARGET_REG_BITS == 32
1154 static inline void tcg_gen_discard_i64(TCGv arg
)
1156 tcg_gen_discard_i32(arg
);
1157 tcg_gen_discard_i32(TCGV_HIGH(arg
));
1160 static inline void tcg_gen_discard_i64(TCGv arg
)
1162 tcg_gen_op1(INDEX_op_discard
, arg
);
1166 /***************************************/
1167 static inline void tcg_gen_macro_2(TCGv ret0
, TCGv ret1
, int macro_id
)
1169 tcg_gen_op3i(INDEX_op_macro_2
, ret0
, ret1
, macro_id
);
1172 /***************************************/
1173 /* QEMU specific operations. Their type depend on the QEMU CPU
1175 #ifndef TARGET_LONG_BITS
1176 #error must include QEMU headers
1179 static inline void tcg_gen_exit_tb(tcg_target_long val
)
1181 tcg_gen_op1i(INDEX_op_exit_tb
, val
);
1184 static inline void tcg_gen_goto_tb(int idx
)
1186 tcg_gen_op1i(INDEX_op_goto_tb
, idx
);
1189 #if TCG_TARGET_REG_BITS == 32
1190 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
1192 #if TARGET_LONG_BITS == 32
1193 tcg_gen_op3i(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
1195 tcg_gen_op4i(INDEX_op_qemu_ld8u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1196 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1200 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
1202 #if TARGET_LONG_BITS == 32
1203 tcg_gen_op3i(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
1205 tcg_gen_op4i(INDEX_op_qemu_ld8s
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1206 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1210 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
1212 #if TARGET_LONG_BITS == 32
1213 tcg_gen_op3i(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
1215 tcg_gen_op4i(INDEX_op_qemu_ld16u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1216 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1220 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
1222 #if TARGET_LONG_BITS == 32
1223 tcg_gen_op3i(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
1225 tcg_gen_op4i(INDEX_op_qemu_ld16s
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1226 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1230 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
1232 #if TARGET_LONG_BITS == 32
1233 tcg_gen_op3i(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1235 tcg_gen_op4i(INDEX_op_qemu_ld32u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1236 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1240 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
1242 #if TARGET_LONG_BITS == 32
1243 tcg_gen_op3i(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1245 tcg_gen_op4i(INDEX_op_qemu_ld32u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1246 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1250 static inline void tcg_gen_qemu_ld64(TCGv ret
, TCGv addr
, int mem_index
)
1252 #if TARGET_LONG_BITS == 32
1253 tcg_gen_op4i(INDEX_op_qemu_ld64
, ret
, TCGV_HIGH(ret
), addr
, mem_index
);
1255 tcg_gen_op5i(INDEX_op_qemu_ld64
, ret
, TCGV_HIGH(ret
),
1256 addr
, TCGV_HIGH(addr
), mem_index
);
1260 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
1262 #if TARGET_LONG_BITS == 32
1263 tcg_gen_op3i(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
1265 tcg_gen_op4i(INDEX_op_qemu_st8
, arg
, addr
, TCGV_HIGH(addr
), mem_index
);
1269 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
1271 #if TARGET_LONG_BITS == 32
1272 tcg_gen_op3i(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
1274 tcg_gen_op4i(INDEX_op_qemu_st16
, arg
, addr
, TCGV_HIGH(addr
), mem_index
);
1278 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
1280 #if TARGET_LONG_BITS == 32
1281 tcg_gen_op3i(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
1283 tcg_gen_op4i(INDEX_op_qemu_st32
, arg
, addr
, TCGV_HIGH(addr
), mem_index
);
1287 static inline void tcg_gen_qemu_st64(TCGv arg
, TCGv addr
, int mem_index
)
1289 #if TARGET_LONG_BITS == 32
1290 tcg_gen_op4i(INDEX_op_qemu_st64
, arg
, TCGV_HIGH(arg
), addr
, mem_index
);
1292 tcg_gen_op5i(INDEX_op_qemu_st64
, arg
, TCGV_HIGH(arg
),
1293 addr
, TCGV_HIGH(addr
), mem_index
);
1297 #define tcg_gen_ld_ptr tcg_gen_ld_i32
1298 #define tcg_gen_discard_ptr tcg_gen_discard_i32
1300 #else /* TCG_TARGET_REG_BITS == 32 */
1302 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
1304 tcg_gen_op3i(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
1307 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
1309 tcg_gen_op3i(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
1312 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
1314 tcg_gen_op3i(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
1317 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
1319 tcg_gen_op3i(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
1322 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
1324 tcg_gen_op3i(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1327 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
1329 tcg_gen_op3i(INDEX_op_qemu_ld32s
, ret
, addr
, mem_index
);
1332 static inline void tcg_gen_qemu_ld64(TCGv ret
, TCGv addr
, int mem_index
)
1334 tcg_gen_op3i(INDEX_op_qemu_ld64
, ret
, addr
, mem_index
);
1337 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
1339 tcg_gen_op3i(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
1342 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
1344 tcg_gen_op3i(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
1347 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
1349 tcg_gen_op3i(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
1352 static inline void tcg_gen_qemu_st64(TCGv arg
, TCGv addr
, int mem_index
)
1354 tcg_gen_op3i(INDEX_op_qemu_st64
, arg
, addr
, mem_index
);
1357 #define tcg_gen_ld_ptr tcg_gen_ld_i64
1358 #define tcg_gen_discard_ptr tcg_gen_discard_i64
1360 #endif /* TCG_TARGET_REG_BITS != 32 */
1362 #if TARGET_LONG_BITS == 64
1363 #define TCG_TYPE_TL TCG_TYPE_I64
1364 #define tcg_gen_movi_tl tcg_gen_movi_i64
1365 #define tcg_gen_mov_tl tcg_gen_mov_i64
1366 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
1367 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
1368 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
1369 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
1370 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
1371 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
1372 #define tcg_gen_ld_tl tcg_gen_ld_i64
1373 #define tcg_gen_st8_tl tcg_gen_st8_i64
1374 #define tcg_gen_st16_tl tcg_gen_st16_i64
1375 #define tcg_gen_st32_tl tcg_gen_st32_i64
1376 #define tcg_gen_st_tl tcg_gen_st_i64
1377 #define tcg_gen_add_tl tcg_gen_add_i64
1378 #define tcg_gen_addi_tl tcg_gen_addi_i64
1379 #define tcg_gen_sub_tl tcg_gen_sub_i64
1380 #define tcg_gen_subi_tl tcg_gen_subi_i64
1381 #define tcg_gen_and_tl tcg_gen_and_i64
1382 #define tcg_gen_andi_tl tcg_gen_andi_i64
1383 #define tcg_gen_or_tl tcg_gen_or_i64
1384 #define tcg_gen_ori_tl tcg_gen_ori_i64
1385 #define tcg_gen_xor_tl tcg_gen_xor_i64
1386 #define tcg_gen_xori_tl tcg_gen_xori_i64
1387 #define tcg_gen_shl_tl tcg_gen_shl_i64
1388 #define tcg_gen_shli_tl tcg_gen_shli_i64
1389 #define tcg_gen_shr_tl tcg_gen_shr_i64
1390 #define tcg_gen_shri_tl tcg_gen_shri_i64
1391 #define tcg_gen_sar_tl tcg_gen_sar_i64
1392 #define tcg_gen_sari_tl tcg_gen_sari_i64
1393 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
1394 #define tcg_gen_discard_tl tcg_gen_discard_i64
1395 #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
1396 #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
1397 #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
1398 #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
1399 #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
1400 #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
1401 #define tcg_const_tl tcg_const_i64
1403 #define TCG_TYPE_TL TCG_TYPE_I32
1404 #define tcg_gen_movi_tl tcg_gen_movi_i32
1405 #define tcg_gen_mov_tl tcg_gen_mov_i32
1406 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
1407 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
1408 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
1409 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
1410 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
1411 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
1412 #define tcg_gen_ld_tl tcg_gen_ld_i32
1413 #define tcg_gen_st8_tl tcg_gen_st8_i32
1414 #define tcg_gen_st16_tl tcg_gen_st16_i32
1415 #define tcg_gen_st32_tl tcg_gen_st_i32
1416 #define tcg_gen_st_tl tcg_gen_st_i32
1417 #define tcg_gen_add_tl tcg_gen_add_i32
1418 #define tcg_gen_addi_tl tcg_gen_addi_i32
1419 #define tcg_gen_sub_tl tcg_gen_sub_i32
1420 #define tcg_gen_subi_tl tcg_gen_subi_i32
1421 #define tcg_gen_and_tl tcg_gen_and_i32
1422 #define tcg_gen_andi_tl tcg_gen_andi_i32
1423 #define tcg_gen_or_tl tcg_gen_or_i32
1424 #define tcg_gen_ori_tl tcg_gen_ori_i32
1425 #define tcg_gen_xor_tl tcg_gen_xor_i32
1426 #define tcg_gen_xori_tl tcg_gen_xori_i32
1427 #define tcg_gen_shl_tl tcg_gen_shl_i32
1428 #define tcg_gen_shli_tl tcg_gen_shli_i32
1429 #define tcg_gen_shr_tl tcg_gen_shr_i32
1430 #define tcg_gen_shri_tl tcg_gen_shri_i32
1431 #define tcg_gen_sar_tl tcg_gen_sar_i32
1432 #define tcg_gen_sari_tl tcg_gen_sari_i32
1433 #define tcg_gen_brcond_tl tcg_gen_brcond_i32
1434 #define tcg_gen_discard_tl tcg_gen_discard_i32
1435 #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
1436 #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
1437 #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
1438 #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
1439 #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
1440 #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
1441 #define tcg_const_tl tcg_const_i32
1444 #if TCG_TARGET_REG_BITS == 32
1445 #define tcg_gen_addi_ptr tcg_gen_addi_i32
1446 #else /* TCG_TARGET_REG_BITS == 32 */
1447 #define tcg_gen_addi_ptr tcg_gen_addi_i64
1448 #endif /* TCG_TARGET_REG_BITS != 32 */