]>
git.proxmox.com Git - 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 /* legacy dyngen operations */
29 int gen_new_label(void);
31 static inline void tcg_gen_op1(int opc
, TCGv arg1
)
34 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
37 static inline void tcg_gen_op1i(int opc
, TCGArg arg1
)
40 *gen_opparam_ptr
++ = arg1
;
43 static inline void tcg_gen_op2(int opc
, TCGv arg1
, TCGv arg2
)
46 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
47 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
50 static inline void tcg_gen_op2i(int opc
, TCGv arg1
, TCGArg arg2
)
53 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
54 *gen_opparam_ptr
++ = arg2
;
57 static inline void tcg_gen_op3(int opc
, TCGv arg1
, TCGv arg2
, TCGv arg3
)
60 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
61 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
62 *gen_opparam_ptr
++ = GET_TCGV(arg3
);
65 static inline void tcg_gen_op3i(int opc
, TCGv arg1
, TCGv arg2
, TCGArg arg3
)
68 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
69 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
70 *gen_opparam_ptr
++ = arg3
;
73 static inline void tcg_gen_op4(int opc
, TCGv arg1
, TCGv arg2
, TCGv arg3
,
77 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
78 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
79 *gen_opparam_ptr
++ = GET_TCGV(arg3
);
80 *gen_opparam_ptr
++ = GET_TCGV(arg4
);
83 static inline void tcg_gen_op4i(int opc
, TCGv arg1
, TCGv arg2
, TCGv arg3
,
87 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
88 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
89 *gen_opparam_ptr
++ = GET_TCGV(arg3
);
90 *gen_opparam_ptr
++ = arg4
;
93 static inline void tcg_gen_op4ii(int opc
, TCGv arg1
, TCGv arg2
, TCGArg arg3
,
97 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
98 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
99 *gen_opparam_ptr
++ = arg3
;
100 *gen_opparam_ptr
++ = arg4
;
103 static inline void tcg_gen_op5(int opc
, TCGv arg1
, TCGv arg2
,
104 TCGv arg3
, TCGv arg4
,
107 *gen_opc_ptr
++ = opc
;
108 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
109 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
110 *gen_opparam_ptr
++ = GET_TCGV(arg3
);
111 *gen_opparam_ptr
++ = GET_TCGV(arg4
);
112 *gen_opparam_ptr
++ = GET_TCGV(arg5
);
115 static inline void tcg_gen_op5i(int opc
, TCGv arg1
, TCGv arg2
,
116 TCGv arg3
, TCGv arg4
,
119 *gen_opc_ptr
++ = opc
;
120 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
121 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
122 *gen_opparam_ptr
++ = GET_TCGV(arg3
);
123 *gen_opparam_ptr
++ = GET_TCGV(arg4
);
124 *gen_opparam_ptr
++ = arg5
;
127 static inline void tcg_gen_op6(int opc
, TCGv arg1
, TCGv arg2
,
128 TCGv arg3
, TCGv arg4
,
129 TCGv arg5
, TCGv arg6
)
131 *gen_opc_ptr
++ = opc
;
132 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
133 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
134 *gen_opparam_ptr
++ = GET_TCGV(arg3
);
135 *gen_opparam_ptr
++ = GET_TCGV(arg4
);
136 *gen_opparam_ptr
++ = GET_TCGV(arg5
);
137 *gen_opparam_ptr
++ = GET_TCGV(arg6
);
140 static inline void tcg_gen_op6ii(int opc
, TCGv arg1
, TCGv arg2
,
141 TCGv arg3
, TCGv arg4
,
142 TCGArg arg5
, TCGArg arg6
)
144 *gen_opc_ptr
++ = opc
;
145 *gen_opparam_ptr
++ = GET_TCGV(arg1
);
146 *gen_opparam_ptr
++ = GET_TCGV(arg2
);
147 *gen_opparam_ptr
++ = GET_TCGV(arg3
);
148 *gen_opparam_ptr
++ = GET_TCGV(arg4
);
149 *gen_opparam_ptr
++ = arg5
;
150 *gen_opparam_ptr
++ = arg6
;
153 static inline void gen_set_label(int n
)
155 tcg_gen_op1i(INDEX_op_set_label
, n
);
158 static inline void tcg_gen_mov_i32(TCGv ret
, TCGv arg
)
160 tcg_gen_op2(INDEX_op_mov_i32
, ret
, arg
);
163 static inline void tcg_gen_movi_i32(TCGv ret
, int32_t arg
)
165 tcg_gen_op2i(INDEX_op_movi_i32
, ret
, arg
);
169 #define TCG_HELPER_CALL_FLAGS 0
171 static inline void tcg_gen_helper_0_0(void *func
)
173 tcg_gen_call(&tcg_ctx
,
174 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
178 static inline void tcg_gen_helper_0_1(void *func
, TCGv arg
)
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_2(void *func
, TCGv arg1
, TCGv arg2
)
190 tcg_gen_call(&tcg_ctx
,
191 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
195 static inline void tcg_gen_helper_0_4(void *func
, TCGv arg1
, TCGv arg2
,
196 TCGv arg3
, TCGv arg4
)
203 tcg_gen_call(&tcg_ctx
,
204 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
208 static inline void tcg_gen_helper_1_0(void *func
, TCGv ret
)
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_1(void *func
, TCGv ret
, TCGv arg1
)
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_2(void *func
, TCGv ret
,
223 TCGv arg1
, TCGv arg2
)
228 tcg_gen_call(&tcg_ctx
,
229 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
233 static inline void tcg_gen_helper_1_4(void *func
, TCGv ret
,
234 TCGv arg1
, TCGv arg2
, TCGv arg3
,
242 tcg_gen_call(&tcg_ctx
,
243 tcg_const_ptr((tcg_target_long
)func
), TCG_HELPER_CALL_FLAGS
,
249 static inline void tcg_gen_ld8u_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
251 tcg_gen_op3i(INDEX_op_ld8u_i32
, ret
, arg2
, offset
);
254 static inline void tcg_gen_ld8s_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
256 tcg_gen_op3i(INDEX_op_ld8s_i32
, ret
, arg2
, offset
);
259 static inline void tcg_gen_ld16u_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
261 tcg_gen_op3i(INDEX_op_ld16u_i32
, ret
, arg2
, offset
);
264 static inline void tcg_gen_ld16s_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
266 tcg_gen_op3i(INDEX_op_ld16s_i32
, ret
, arg2
, offset
);
269 static inline void tcg_gen_ld_i32(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
271 tcg_gen_op3i(INDEX_op_ld_i32
, ret
, arg2
, offset
);
274 static inline void tcg_gen_st8_i32(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
276 tcg_gen_op3i(INDEX_op_st8_i32
, arg1
, arg2
, offset
);
279 static inline void tcg_gen_st16_i32(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
281 tcg_gen_op3i(INDEX_op_st16_i32
, arg1
, arg2
, offset
);
284 static inline void tcg_gen_st_i32(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
286 tcg_gen_op3i(INDEX_op_st_i32
, arg1
, arg2
, offset
);
289 static inline void tcg_gen_add_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
291 tcg_gen_op3(INDEX_op_add_i32
, ret
, arg1
, arg2
);
294 static inline void tcg_gen_addi_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
296 /* some cases can be optimized here */
298 tcg_gen_mov_i32(ret
, arg1
);
300 tcg_gen_add_i32(ret
, arg1
, tcg_const_i32(arg2
));
304 static inline void tcg_gen_sub_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
306 tcg_gen_op3(INDEX_op_sub_i32
, ret
, arg1
, arg2
);
309 static inline void tcg_gen_subi_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
311 /* some cases can be optimized here */
313 tcg_gen_mov_i32(ret
, arg1
);
315 tcg_gen_sub_i32(ret
, arg1
, tcg_const_i32(arg2
));
319 static inline void tcg_gen_and_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
321 tcg_gen_op3(INDEX_op_and_i32
, ret
, arg1
, arg2
);
324 static inline void tcg_gen_andi_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
326 /* some cases can be optimized here */
328 tcg_gen_movi_i32(ret
, 0);
329 } else if (arg2
== 0xffffffff) {
330 tcg_gen_mov_i32(ret
, arg1
);
332 tcg_gen_and_i32(ret
, arg1
, tcg_const_i32(arg2
));
336 static inline void tcg_gen_or_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
338 tcg_gen_op3(INDEX_op_or_i32
, ret
, arg1
, arg2
);
341 static inline void tcg_gen_ori_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
343 /* some cases can be optimized here */
344 if (arg2
== 0xffffffff) {
345 tcg_gen_movi_i32(ret
, 0xffffffff);
346 } else if (arg2
== 0) {
347 tcg_gen_mov_i32(ret
, arg1
);
349 tcg_gen_or_i32(ret
, arg1
, tcg_const_i32(arg2
));
353 static inline void tcg_gen_xor_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
355 tcg_gen_op3(INDEX_op_xor_i32
, ret
, arg1
, arg2
);
358 static inline void tcg_gen_xori_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
360 /* some cases can be optimized here */
362 tcg_gen_mov_i32(ret
, arg1
);
364 tcg_gen_xor_i32(ret
, arg1
, tcg_const_i32(arg2
));
368 static inline void tcg_gen_shl_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
370 tcg_gen_op3(INDEX_op_shl_i32
, ret
, arg1
, arg2
);
373 static inline void tcg_gen_shli_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
375 tcg_gen_shl_i32(ret
, arg1
, tcg_const_i32(arg2
));
378 static inline void tcg_gen_shr_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
380 tcg_gen_op3(INDEX_op_shr_i32
, ret
, arg1
, arg2
);
383 static inline void tcg_gen_shri_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
385 tcg_gen_shr_i32(ret
, arg1
, tcg_const_i32(arg2
));
388 static inline void tcg_gen_sar_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
390 tcg_gen_op3(INDEX_op_sar_i32
, ret
, arg1
, arg2
);
393 static inline void tcg_gen_sari_i32(TCGv ret
, TCGv arg1
, int32_t arg2
)
395 tcg_gen_sar_i32(ret
, arg1
, tcg_const_i32(arg2
));
398 static inline void tcg_gen_brcond_i32(int cond
, TCGv arg1
, TCGv arg2
,
401 tcg_gen_op4ii(INDEX_op_brcond_i32
, arg1
, arg2
, cond
, label_index
);
404 static inline void tcg_gen_mul_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
406 tcg_gen_op3(INDEX_op_mul_i32
, ret
, arg1
, arg2
);
409 #ifdef TCG_TARGET_HAS_div_i32
410 static inline void tcg_gen_div_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
412 tcg_gen_op3(INDEX_op_div_i32
, ret
, arg1
, arg2
);
415 static inline void tcg_gen_rem_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
417 tcg_gen_op3(INDEX_op_rem_i32
, ret
, arg1
, arg2
);
420 static inline void tcg_gen_divu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
422 tcg_gen_op3(INDEX_op_divu_i32
, ret
, arg1
, arg2
);
425 static inline void tcg_gen_remu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
427 tcg_gen_op3(INDEX_op_remu_i32
, ret
, arg1
, arg2
);
430 static inline void tcg_gen_div_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
433 t0
= tcg_temp_new(TCG_TYPE_I32
);
434 tcg_gen_sari_i32(t0
, arg1
, 31);
435 tcg_gen_op5(INDEX_op_div2_i32
, ret
, t0
, arg1
, t0
, arg2
);
438 static inline void tcg_gen_rem_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
441 t0
= tcg_temp_new(TCG_TYPE_I32
);
442 tcg_gen_sari_i32(t0
, arg1
, 31);
443 tcg_gen_op5(INDEX_op_div2_i32
, t0
, ret
, arg1
, t0
, arg2
);
446 static inline void tcg_gen_divu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
449 t0
= tcg_temp_new(TCG_TYPE_I32
);
450 tcg_gen_movi_i32(t0
, 0);
451 tcg_gen_op5(INDEX_op_divu2_i32
, ret
, t0
, arg1
, t0
, arg2
);
454 static inline void tcg_gen_remu_i32(TCGv ret
, TCGv arg1
, TCGv arg2
)
457 t0
= tcg_temp_new(TCG_TYPE_I32
);
458 tcg_gen_movi_i32(t0
, 0);
459 tcg_gen_op5(INDEX_op_divu2_i32
, t0
, ret
, arg1
, t0
, arg2
);
463 #if TCG_TARGET_REG_BITS == 32
465 static inline void tcg_gen_mov_i64(TCGv ret
, TCGv arg
)
467 tcg_gen_mov_i32(ret
, arg
);
468 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
471 static inline void tcg_gen_movi_i64(TCGv ret
, int64_t arg
)
473 tcg_gen_movi_i32(ret
, arg
);
474 tcg_gen_movi_i32(TCGV_HIGH(ret
), arg
>> 32);
477 static inline void tcg_gen_ld8u_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
479 tcg_gen_ld8u_i32(ret
, arg2
, offset
);
480 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
483 static inline void tcg_gen_ld8s_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
485 tcg_gen_ld8s_i32(ret
, arg2
, offset
);
486 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
489 static inline void tcg_gen_ld16u_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
491 tcg_gen_ld16u_i32(ret
, arg2
, offset
);
492 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
495 static inline void tcg_gen_ld16s_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
497 tcg_gen_ld16s_i32(ret
, arg2
, offset
);
498 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
501 static inline void tcg_gen_ld32u_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
503 tcg_gen_ld_i32(ret
, arg2
, offset
);
504 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
507 static inline void tcg_gen_ld32s_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
509 tcg_gen_ld_i32(ret
, arg2
, offset
);
510 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
513 static inline void tcg_gen_ld_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
515 /* since arg2 and ret have different types, they cannot be the
517 #ifdef TCG_TARGET_WORDS_BIGENDIAN
518 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
);
519 tcg_gen_ld_i32(ret
, arg2
, offset
+ 4);
521 tcg_gen_ld_i32(ret
, arg2
, offset
);
522 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
+ 4);
526 static inline void tcg_gen_st8_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
528 tcg_gen_st8_i32(arg1
, arg2
, offset
);
531 static inline void tcg_gen_st16_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
533 tcg_gen_st16_i32(arg1
, arg2
, offset
);
536 static inline void tcg_gen_st32_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
538 tcg_gen_st_i32(arg1
, arg2
, offset
);
541 static inline void tcg_gen_st_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
543 #ifdef TCG_TARGET_WORDS_BIGENDIAN
544 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
);
545 tcg_gen_st_i32(arg1
, arg2
, offset
+ 4);
547 tcg_gen_st_i32(arg1
, arg2
, offset
);
548 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
+ 4);
552 static inline void tcg_gen_add_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
554 tcg_gen_op6(INDEX_op_add2_i32
, ret
, TCGV_HIGH(ret
),
555 arg1
, TCGV_HIGH(arg1
), arg2
, TCGV_HIGH(arg2
));
558 static inline void tcg_gen_addi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
560 tcg_gen_add_i64(ret
, arg1
, tcg_const_i64(arg2
));
563 static inline void tcg_gen_sub_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
565 tcg_gen_op6(INDEX_op_sub2_i32
, ret
, TCGV_HIGH(ret
),
566 arg1
, TCGV_HIGH(arg1
), arg2
, TCGV_HIGH(arg2
));
569 static inline void tcg_gen_subi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
571 tcg_gen_sub_i64(ret
, arg1
, tcg_const_i64(arg2
));
574 static inline void tcg_gen_and_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
576 tcg_gen_and_i32(ret
, arg1
, arg2
);
577 tcg_gen_and_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
580 static inline void tcg_gen_andi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
582 tcg_gen_andi_i32(ret
, arg1
, arg2
);
583 tcg_gen_andi_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
586 static inline void tcg_gen_or_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
588 tcg_gen_or_i32(ret
, arg1
, arg2
);
589 tcg_gen_or_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
592 static inline void tcg_gen_ori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
594 tcg_gen_ori_i32(ret
, arg1
, arg2
);
595 tcg_gen_ori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
598 static inline void tcg_gen_xor_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
600 tcg_gen_xor_i32(ret
, arg1
, arg2
);
601 tcg_gen_xor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
604 static inline void tcg_gen_xori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
606 tcg_gen_xori_i32(ret
, arg1
, arg2
);
607 tcg_gen_xori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
610 /* XXX: use generic code when basic block handling is OK or CPU
611 specific code (x86) */
612 static inline void tcg_gen_shl_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
614 tcg_gen_helper_1_2(tcg_helper_shl_i64
, ret
, arg1
, arg2
);
617 static inline void tcg_gen_shli_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
619 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 0, 0);
622 static inline void tcg_gen_shr_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
624 tcg_gen_helper_1_2(tcg_helper_shr_i64
, ret
, arg1
, arg2
);
627 static inline void tcg_gen_shri_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
629 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 0);
632 static inline void tcg_gen_sar_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
634 tcg_gen_helper_1_2(tcg_helper_sar_i64
, ret
, arg1
, arg2
);
637 static inline void tcg_gen_sari_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
639 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 1);
642 static inline void tcg_gen_brcond_i64(int cond
, TCGv arg1
, TCGv arg2
,
645 tcg_gen_op6ii(INDEX_op_brcond2_i32
,
646 arg1
, TCGV_HIGH(arg1
), arg2
, TCGV_HIGH(arg2
),
650 static inline void tcg_gen_mul_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
654 t0
= tcg_temp_new(TCG_TYPE_I64
);
655 t1
= tcg_temp_new(TCG_TYPE_I32
);
657 tcg_gen_op4(INDEX_op_mulu2_i32
, t0
, TCGV_HIGH(t0
), arg1
, arg2
);
659 tcg_gen_mul_i32(t1
, arg1
, TCGV_HIGH(arg2
));
660 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
661 tcg_gen_mul_i32(t1
, TCGV_HIGH(arg1
), arg2
);
662 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
664 tcg_gen_mov_i64(ret
, t0
);
667 static inline void tcg_gen_div_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
669 tcg_gen_helper_1_2(tcg_helper_div_i64
, ret
, arg1
, arg2
);
672 static inline void tcg_gen_rem_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
674 tcg_gen_helper_1_2(tcg_helper_rem_i64
, ret
, arg1
, arg2
);
677 static inline void tcg_gen_divu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
679 tcg_gen_helper_1_2(tcg_helper_divu_i64
, ret
, arg1
, arg2
);
682 static inline void tcg_gen_remu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
684 tcg_gen_helper_1_2(tcg_helper_remu_i64
, ret
, arg1
, arg2
);
689 static inline void tcg_gen_mov_i64(TCGv ret
, TCGv arg
)
691 tcg_gen_op2(INDEX_op_mov_i64
, ret
, arg
);
694 static inline void tcg_gen_movi_i64(TCGv ret
, int64_t arg
)
696 tcg_gen_op2i(INDEX_op_movi_i64
, ret
, arg
);
699 static inline void tcg_gen_ld8u_i64(TCGv ret
, TCGv arg2
,
700 tcg_target_long offset
)
702 tcg_gen_op3i(INDEX_op_ld8u_i64
, ret
, arg2
, offset
);
705 static inline void tcg_gen_ld8s_i64(TCGv ret
, TCGv arg2
,
706 tcg_target_long offset
)
708 tcg_gen_op3i(INDEX_op_ld8s_i64
, ret
, arg2
, offset
);
711 static inline void tcg_gen_ld16u_i64(TCGv ret
, TCGv arg2
,
712 tcg_target_long offset
)
714 tcg_gen_op3i(INDEX_op_ld16u_i64
, ret
, arg2
, offset
);
717 static inline void tcg_gen_ld16s_i64(TCGv ret
, TCGv arg2
,
718 tcg_target_long offset
)
720 tcg_gen_op3i(INDEX_op_ld16s_i64
, ret
, arg2
, offset
);
723 static inline void tcg_gen_ld32u_i64(TCGv ret
, TCGv arg2
,
724 tcg_target_long offset
)
726 tcg_gen_op3i(INDEX_op_ld32u_i64
, ret
, arg2
, offset
);
729 static inline void tcg_gen_ld32s_i64(TCGv ret
, TCGv arg2
,
730 tcg_target_long offset
)
732 tcg_gen_op3i(INDEX_op_ld32s_i64
, ret
, arg2
, offset
);
735 static inline void tcg_gen_ld_i64(TCGv ret
, TCGv arg2
, tcg_target_long offset
)
737 tcg_gen_op3i(INDEX_op_ld_i64
, ret
, arg2
, offset
);
740 static inline void tcg_gen_st8_i64(TCGv arg1
, TCGv arg2
,
741 tcg_target_long offset
)
743 tcg_gen_op3i(INDEX_op_st8_i64
, arg1
, arg2
, offset
);
746 static inline void tcg_gen_st16_i64(TCGv arg1
, TCGv arg2
,
747 tcg_target_long offset
)
749 tcg_gen_op3i(INDEX_op_st16_i64
, arg1
, arg2
, offset
);
752 static inline void tcg_gen_st32_i64(TCGv arg1
, TCGv arg2
,
753 tcg_target_long offset
)
755 tcg_gen_op3i(INDEX_op_st32_i64
, arg1
, arg2
, offset
);
758 static inline void tcg_gen_st_i64(TCGv arg1
, TCGv arg2
, tcg_target_long offset
)
760 tcg_gen_op3i(INDEX_op_st_i64
, arg1
, arg2
, offset
);
763 static inline void tcg_gen_add_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
765 tcg_gen_op3(INDEX_op_add_i64
, ret
, arg1
, arg2
);
768 static inline void tcg_gen_addi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
770 tcg_gen_add_i64(ret
, arg1
, tcg_const_i64(arg2
));
773 static inline void tcg_gen_sub_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
775 tcg_gen_op3(INDEX_op_sub_i64
, ret
, arg1
, arg2
);
778 static inline void tcg_gen_subi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
780 tcg_gen_sub_i64(ret
, arg1
, tcg_const_i64(arg2
));
783 static inline void tcg_gen_and_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
785 tcg_gen_op3(INDEX_op_and_i64
, ret
, arg1
, arg2
);
788 static inline void tcg_gen_andi_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
790 tcg_gen_and_i64(ret
, arg1
, tcg_const_i64(arg2
));
793 static inline void tcg_gen_or_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
795 tcg_gen_op3(INDEX_op_or_i64
, ret
, arg1
, arg2
);
798 static inline void tcg_gen_ori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
800 tcg_gen_or_i64(ret
, arg1
, tcg_const_i64(arg2
));
803 static inline void tcg_gen_xor_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
805 tcg_gen_op3(INDEX_op_xor_i64
, ret
, arg1
, arg2
);
808 static inline void tcg_gen_xori_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
810 tcg_gen_xor_i64(ret
, arg1
, tcg_const_i64(arg2
));
813 static inline void tcg_gen_shl_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
815 tcg_gen_op3(INDEX_op_shl_i64
, ret
, arg1
, arg2
);
818 static inline void tcg_gen_shli_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
820 tcg_gen_shl_i64(ret
, arg1
, tcg_const_i64(arg2
));
823 static inline void tcg_gen_shr_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
825 tcg_gen_op3(INDEX_op_shr_i64
, ret
, arg1
, arg2
);
828 static inline void tcg_gen_shri_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
830 tcg_gen_shr_i64(ret
, arg1
, tcg_const_i64(arg2
));
833 static inline void tcg_gen_sar_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
835 tcg_gen_op3(INDEX_op_sar_i64
, ret
, arg1
, arg2
);
838 static inline void tcg_gen_sari_i64(TCGv ret
, TCGv arg1
, int64_t arg2
)
840 tcg_gen_sar_i64(ret
, arg1
, tcg_const_i64(arg2
));
843 static inline void tcg_gen_brcond_i64(int cond
, TCGv arg1
, TCGv arg2
,
846 tcg_gen_op4ii(INDEX_op_brcond_i64
, arg1
, arg2
, cond
, label_index
);
849 static inline void tcg_gen_mul_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
851 tcg_gen_op3(INDEX_op_mul_i64
, ret
, arg1
, arg2
);
854 #ifdef TCG_TARGET_HAS_div_i64
855 static inline void tcg_gen_div_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
857 tcg_gen_op3(INDEX_op_div_i64
, ret
, arg1
, arg2
);
860 static inline void tcg_gen_rem_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
862 tcg_gen_op3(INDEX_op_rem_i64
, ret
, arg1
, arg2
);
865 static inline void tcg_gen_divu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
867 tcg_gen_op3(INDEX_op_divu_i64
, ret
, arg1
, arg2
);
870 static inline void tcg_gen_remu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
872 tcg_gen_op3(INDEX_op_remu_i64
, ret
, arg1
, arg2
);
875 static inline void tcg_gen_div_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
878 t0
= tcg_temp_new(TCG_TYPE_I64
);
879 tcg_gen_sari_i64(t0
, arg1
, 63);
880 tcg_gen_op5(INDEX_op_div2_i64
, ret
, t0
, arg1
, t0
, arg2
);
883 static inline void tcg_gen_rem_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
886 t0
= tcg_temp_new(TCG_TYPE_I64
);
887 tcg_gen_sari_i64(t0
, arg1
, 63);
888 tcg_gen_op5(INDEX_op_div2_i64
, t0
, ret
, arg1
, t0
, arg2
);
891 static inline void tcg_gen_divu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
894 t0
= tcg_temp_new(TCG_TYPE_I64
);
895 tcg_gen_movi_i64(t0
, 0);
896 tcg_gen_op5(INDEX_op_divu2_i64
, ret
, t0
, arg1
, t0
, arg2
);
899 static inline void tcg_gen_remu_i64(TCGv ret
, TCGv arg1
, TCGv arg2
)
902 t0
= tcg_temp_new(TCG_TYPE_I64
);
903 tcg_gen_movi_i64(t0
, 0);
904 tcg_gen_op5(INDEX_op_divu2_i64
, t0
, ret
, arg1
, t0
, arg2
);
910 /***************************************/
911 /* optional operations */
913 static inline void tcg_gen_ext8s_i32(TCGv ret
, TCGv arg
)
915 #ifdef TCG_TARGET_HAS_ext8s_i32
916 tcg_gen_op2(INDEX_op_ext8s_i32
, ret
, arg
);
918 tcg_gen_shli_i32(ret
, arg
, 24);
919 tcg_gen_sari_i32(ret
, ret
, 24);
923 static inline void tcg_gen_ext16s_i32(TCGv ret
, TCGv arg
)
925 #ifdef TCG_TARGET_HAS_ext16s_i32
926 tcg_gen_op2(INDEX_op_ext16s_i32
, ret
, arg
);
928 tcg_gen_shli_i32(ret
, arg
, 16);
929 tcg_gen_sari_i32(ret
, ret
, 16);
933 /* Note: we assume the two high bytes are set to zero */
934 static inline void tcg_gen_bswap16_i32(TCGv ret
, TCGv arg
)
936 #ifdef TCG_TARGET_HAS_bswap16_i32
937 tcg_gen_op2(INDEX_op_bswap16_i32
, ret
, arg
);
940 t0
= tcg_temp_new(TCG_TYPE_I32
);
941 t1
= tcg_temp_new(TCG_TYPE_I32
);
943 tcg_gen_shri_i32(t0
, arg
, 8);
944 tcg_gen_andi_i32(t1
, arg
, 0x000000ff);
945 tcg_gen_shli_i32(t1
, t1
, 8);
946 tcg_gen_or_i32(ret
, t0
, t1
);
950 static inline void tcg_gen_bswap_i32(TCGv ret
, TCGv arg
)
952 #ifdef TCG_TARGET_HAS_bswap_i32
953 tcg_gen_op2(INDEX_op_bswap_i32
, ret
, arg
);
956 t0
= tcg_temp_new(TCG_TYPE_I32
);
957 t1
= tcg_temp_new(TCG_TYPE_I32
);
959 tcg_gen_shli_i32(t0
, arg
, 24);
961 tcg_gen_andi_i32(t1
, arg
, 0x0000ff00);
962 tcg_gen_shli_i32(t1
, t1
, 8);
963 tcg_gen_or_i32(t0
, t0
, t1
);
965 tcg_gen_shri_i32(t1
, arg
, 8);
966 tcg_gen_andi_i32(t1
, t1
, 0x0000ff00);
967 tcg_gen_or_i32(t0
, t0
, t1
);
969 tcg_gen_shri_i32(t1
, arg
, 24);
970 tcg_gen_or_i32(ret
, t0
, t1
);
974 #if TCG_TARGET_REG_BITS == 32
975 static inline void tcg_gen_ext8s_i64(TCGv ret
, TCGv arg
)
977 tcg_gen_ext8s_i32(ret
, arg
);
978 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
981 static inline void tcg_gen_ext16s_i64(TCGv ret
, TCGv arg
)
983 tcg_gen_ext16s_i32(ret
, arg
);
984 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
987 static inline void tcg_gen_ext32s_i64(TCGv ret
, TCGv arg
)
989 tcg_gen_mov_i32(ret
, arg
);
990 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
993 static inline void tcg_gen_trunc_i64_i32(TCGv ret
, TCGv arg
)
995 tcg_gen_mov_i32(ret
, arg
);
998 static inline void tcg_gen_extu_i32_i64(TCGv ret
, TCGv arg
)
1000 tcg_gen_mov_i32(ret
, arg
);
1001 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1004 static inline void tcg_gen_ext_i32_i64(TCGv ret
, TCGv arg
)
1006 tcg_gen_mov_i32(ret
, arg
);
1007 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1010 static inline void tcg_gen_bswap_i64(TCGv ret
, TCGv arg
)
1013 t0
= tcg_temp_new(TCG_TYPE_I32
);
1014 t1
= tcg_temp_new(TCG_TYPE_I32
);
1016 tcg_gen_bswap_i32(t0
, arg
);
1017 tcg_gen_bswap_i32(t1
, TCGV_HIGH(arg
));
1018 tcg_gen_mov_i32(ret
, t1
);
1019 tcg_gen_mov_i32(TCGV_HIGH(ret
), t0
);
1023 static inline void tcg_gen_ext8s_i64(TCGv ret
, TCGv arg
)
1025 #ifdef TCG_TARGET_HAS_ext8s_i64
1026 tcg_gen_op2(INDEX_op_ext8s_i64
, ret
, arg
);
1028 tcg_gen_shli_i64(ret
, arg
, 56);
1029 tcg_gen_sari_i64(ret
, ret
, 56);
1033 static inline void tcg_gen_ext16s_i64(TCGv ret
, TCGv arg
)
1035 #ifdef TCG_TARGET_HAS_ext16s_i64
1036 tcg_gen_op2(INDEX_op_ext16s_i64
, ret
, arg
);
1038 tcg_gen_shli_i64(ret
, arg
, 48);
1039 tcg_gen_sari_i64(ret
, ret
, 48);
1043 static inline void tcg_gen_ext32s_i64(TCGv ret
, TCGv arg
)
1045 #ifdef TCG_TARGET_HAS_ext32s_i64
1046 tcg_gen_op2(INDEX_op_ext32s_i64
, ret
, arg
);
1048 tcg_gen_shli_i64(ret
, arg
, 32);
1049 tcg_gen_sari_i64(ret
, ret
, 32);
1053 /* Note: we assume the target supports move between 32 and 64 bit
1054 registers. This will probably break MIPS64 targets. */
1055 static inline void tcg_gen_trunc_i64_i32(TCGv ret
, TCGv arg
)
1057 tcg_gen_mov_i32(ret
, arg
);
1060 /* Note: we assume the target supports move between 32 and 64 bit
1062 static inline void tcg_gen_extu_i32_i64(TCGv ret
, TCGv arg
)
1064 tcg_gen_andi_i64(ret
, arg
, 0xffffffff);
1067 /* Note: we assume the target supports move between 32 and 64 bit
1069 static inline void tcg_gen_ext_i32_i64(TCGv ret
, TCGv arg
)
1071 tcg_gen_ext32s_i64(ret
, arg
);
1074 static inline void tcg_gen_bswap_i64(TCGv ret
, TCGv arg
)
1076 #ifdef TCG_TARGET_HAS_bswap_i64
1077 tcg_gen_op2(INDEX_op_bswap_i64
, ret
, arg
);
1080 t0
= tcg_temp_new(TCG_TYPE_I32
);
1081 t1
= tcg_temp_new(TCG_TYPE_I32
);
1083 tcg_gen_shli_i64(t0
, arg
, 56);
1085 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1086 tcg_gen_shli_i64(t1
, t1
, 40);
1087 tcg_gen_or_i64(t0
, t0
, t1
);
1089 tcg_gen_andi_i64(t1
, arg
, 0x00ff0000);
1090 tcg_gen_shli_i64(t1
, t1
, 24);
1091 tcg_gen_or_i64(t0
, t0
, t1
);
1093 tcg_gen_andi_i64(t1
, arg
, 0xff000000);
1094 tcg_gen_shli_i64(t1
, t1
, 8);
1095 tcg_gen_or_i64(t0
, t0
, t1
);
1097 tcg_gen_shri_i64(t1
, arg
, 8);
1098 tcg_gen_andi_i64(t1
, t1
, 0xff000000);
1099 tcg_gen_or_i64(t0
, t0
, t1
);
1101 tcg_gen_shri_i64(t1
, arg
, 24);
1102 tcg_gen_andi_i64(t1
, t1
, 0x00ff0000);
1103 tcg_gen_or_i64(t0
, t0
, t1
);
1105 tcg_gen_shri_i64(t1
, arg
, 40);
1106 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1107 tcg_gen_or_i64(t0
, t0
, t1
);
1109 tcg_gen_shri_i64(t1
, arg
, 56);
1110 tcg_gen_or_i64(ret
, t0
, t1
);
1117 static inline void tcg_gen_discard_i32(TCGv arg
)
1119 tcg_gen_op1(INDEX_op_discard
, arg
);
1122 #if TCG_TARGET_REG_BITS == 32
1123 static inline void tcg_gen_discard_i64(TCGv arg
)
1125 tcg_gen_discard_i32(arg
);
1126 tcg_gen_discard_i32(TCGV_HIGH(arg
));
1129 static inline void tcg_gen_discard_i64(TCGv arg
)
1131 tcg_gen_op1(INDEX_op_discard
, arg
);
1135 /***************************************/
1136 static inline void tcg_gen_macro_2(TCGv ret0
, TCGv ret1
, int macro_id
)
1138 tcg_gen_op3i(INDEX_op_macro_2
, ret0
, ret1
, macro_id
);
1141 /***************************************/
1142 /* QEMU specific operations. Their type depend on the QEMU CPU
1144 #ifndef TARGET_LONG_BITS
1145 #error must include QEMU headers
1148 static inline void tcg_gen_exit_tb(tcg_target_long val
)
1150 tcg_gen_op1i(INDEX_op_exit_tb
, val
);
1153 static inline void tcg_gen_goto_tb(int idx
)
1155 tcg_gen_op1i(INDEX_op_goto_tb
, idx
);
1158 #if TCG_TARGET_REG_BITS == 32
1159 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
1161 #if TARGET_LONG_BITS == 32
1162 tcg_gen_op3i(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
1164 tcg_gen_op4i(INDEX_op_qemu_ld8u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1165 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1169 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
1171 #if TARGET_LONG_BITS == 32
1172 tcg_gen_op3i(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
1174 tcg_gen_op4i(INDEX_op_qemu_ld8s
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1175 tcg_gen_ext8s_i32(TCGV_HIGH(ret
), ret
);
1179 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
1181 #if TARGET_LONG_BITS == 32
1182 tcg_gen_op3i(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
1184 tcg_gen_op4i(INDEX_op_qemu_ld16u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1185 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1189 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
1191 #if TARGET_LONG_BITS == 32
1192 tcg_gen_op3i(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
1194 tcg_gen_op4i(INDEX_op_qemu_ld16s
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1195 tcg_gen_ext16s_i32(TCGV_HIGH(ret
), ret
);
1199 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
1201 #if TARGET_LONG_BITS == 32
1202 tcg_gen_op3i(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1204 tcg_gen_op4i(INDEX_op_qemu_ld32u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1205 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1209 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
1211 #if TARGET_LONG_BITS == 32
1212 tcg_gen_op3i(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1214 tcg_gen_op4i(INDEX_op_qemu_ld32u
, ret
, addr
, TCGV_HIGH(addr
), mem_index
);
1215 tcg_gen_sari_i32(TCGV_HIGH(ret
), ret
, 31);
1219 static inline void tcg_gen_qemu_ld64(TCGv ret
, TCGv addr
, int mem_index
)
1221 #if TARGET_LONG_BITS == 32
1222 tcg_gen_op4i(INDEX_op_qemu_ld64
, ret
, TCGV_HIGH(ret
), addr
, mem_index
);
1224 tcg_gen_op5i(INDEX_op_qemu_ld64
, ret
, TCGV_HIGH(ret
),
1225 addr
, TCGV_HIGH(addr
), mem_index
);
1229 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
1231 #if TARGET_LONG_BITS == 32
1232 tcg_gen_op3i(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
1234 tcg_gen_op4i(INDEX_op_qemu_st8
, arg
, addr
, TCGV_HIGH(addr
), mem_index
);
1238 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
1240 #if TARGET_LONG_BITS == 32
1241 tcg_gen_op3i(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
1243 tcg_gen_op4i(INDEX_op_qemu_st16
, arg
, addr
, TCGV_HIGH(addr
), mem_index
);
1247 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
1249 #if TARGET_LONG_BITS == 32
1250 tcg_gen_op3i(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
1252 tcg_gen_op4i(INDEX_op_qemu_st32
, arg
, addr
, TCGV_HIGH(addr
), mem_index
);
1256 static inline void tcg_gen_qemu_st64(TCGv arg
, TCGv addr
, int mem_index
)
1258 #if TARGET_LONG_BITS == 32
1259 tcg_gen_op4i(INDEX_op_qemu_st64
, arg
, TCGV_HIGH(arg
), addr
, mem_index
);
1261 tcg_gen_op5i(INDEX_op_qemu_st64
, arg
, TCGV_HIGH(arg
),
1262 addr
, TCGV_HIGH(addr
), mem_index
);
1266 #define tcg_gen_ld_ptr tcg_gen_ld_i32
1268 #else /* TCG_TARGET_REG_BITS == 32 */
1270 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
1272 tcg_gen_op3i(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
1275 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
1277 tcg_gen_op3i(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
1280 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
1282 tcg_gen_op3i(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
1285 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
1287 tcg_gen_op3i(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
1290 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
1292 tcg_gen_op3i(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1295 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
1297 tcg_gen_op3i(INDEX_op_qemu_ld32s
, ret
, addr
, mem_index
);
1300 static inline void tcg_gen_qemu_ld64(TCGv ret
, TCGv addr
, int mem_index
)
1302 tcg_gen_op3i(INDEX_op_qemu_ld64
, ret
, addr
, mem_index
);
1305 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
1307 tcg_gen_op3i(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
1310 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
1312 tcg_gen_op3i(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
1315 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
1317 tcg_gen_op3i(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
1320 static inline void tcg_gen_qemu_st64(TCGv arg
, TCGv addr
, int mem_index
)
1322 tcg_gen_op3i(INDEX_op_qemu_st64
, arg
, addr
, mem_index
);
1325 #define tcg_gen_ld_ptr tcg_gen_ld_i64
1327 #endif /* TCG_TARGET_REG_BITS != 32 */
1329 #if TARGET_LONG_BITS == 64
1330 #define TCG_TYPE_TL TCG_TYPE_I64
1331 #define tcg_gen_movi_tl tcg_gen_movi_i64
1332 #define tcg_gen_mov_tl tcg_gen_mov_i64
1333 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
1334 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
1335 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
1336 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
1337 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
1338 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
1339 #define tcg_gen_ld_tl tcg_gen_ld_i64
1340 #define tcg_gen_st8_tl tcg_gen_st8_i64
1341 #define tcg_gen_st16_tl tcg_gen_st16_i64
1342 #define tcg_gen_st32_tl tcg_gen_st32_i64
1343 #define tcg_gen_st_tl tcg_gen_st_i64
1344 #define tcg_gen_add_tl tcg_gen_add_i64
1345 #define tcg_gen_addi_tl tcg_gen_addi_i64
1346 #define tcg_gen_sub_tl tcg_gen_sub_i64
1347 #define tcg_gen_subi_tl tcg_gen_subi_i64
1348 #define tcg_gen_and_tl tcg_gen_and_i64
1349 #define tcg_gen_andi_tl tcg_gen_andi_i64
1350 #define tcg_gen_or_tl tcg_gen_or_i64
1351 #define tcg_gen_ori_tl tcg_gen_ori_i64
1352 #define tcg_gen_xor_tl tcg_gen_xor_i64
1353 #define tcg_gen_xori_tl tcg_gen_xori_i64
1354 #define tcg_gen_shl_tl tcg_gen_shl_i64
1355 #define tcg_gen_shli_tl tcg_gen_shli_i64
1356 #define tcg_gen_shr_tl tcg_gen_shr_i64
1357 #define tcg_gen_shri_tl tcg_gen_shri_i64
1358 #define tcg_gen_sar_tl tcg_gen_sar_i64
1359 #define tcg_gen_sari_tl tcg_gen_sari_i64
1360 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
1362 #define TCG_TYPE_TL TCG_TYPE_I32
1363 #define tcg_gen_movi_tl tcg_gen_movi_i32
1364 #define tcg_gen_mov_tl tcg_gen_mov_i32
1365 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
1366 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
1367 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
1368 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
1369 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
1370 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
1371 #define tcg_gen_ld_tl tcg_gen_ld_i32
1372 #define tcg_gen_st8_tl tcg_gen_st8_i32
1373 #define tcg_gen_st16_tl tcg_gen_st16_i32
1374 #define tcg_gen_st32_tl tcg_gen_st_i32
1375 #define tcg_gen_st_tl tcg_gen_st_i32
1376 #define tcg_gen_add_tl tcg_gen_add_i32
1377 #define tcg_gen_addi_tl tcg_gen_addi_i32
1378 #define tcg_gen_sub_tl tcg_gen_sub_i32
1379 #define tcg_gen_subi_tl tcg_gen_subi_i32
1380 #define tcg_gen_and_tl tcg_gen_and_i32
1381 #define tcg_gen_andi_tl tcg_gen_andi_i32
1382 #define tcg_gen_or_tl tcg_gen_or_i32
1383 #define tcg_gen_ori_tl tcg_gen_ori_i32
1384 #define tcg_gen_xor_tl tcg_gen_xor_i32
1385 #define tcg_gen_xori_tl tcg_gen_xori_i32
1386 #define tcg_gen_shl_tl tcg_gen_shl_i32
1387 #define tcg_gen_shli_tl tcg_gen_shli_i32
1388 #define tcg_gen_shr_tl tcg_gen_shr_i32
1389 #define tcg_gen_shri_tl tcg_gen_shri_i32
1390 #define tcg_gen_sar_tl tcg_gen_sar_i32
1391 #define tcg_gen_sari_tl tcg_gen_sari_i32
1392 #define tcg_gen_brcond_tl tcg_gen_brcond_i32