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 int gen_new_label(void);
28 static inline void tcg_gen_op1_i32(int opc
, TCGv_i32 arg1
)
31 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
34 static inline void tcg_gen_op1_i64(int opc
, TCGv_i64 arg1
)
37 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
40 static inline void tcg_gen_op1i(int opc
, TCGArg arg1
)
43 *gen_opparam_ptr
++ = arg1
;
46 static inline void tcg_gen_op2_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
)
49 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
50 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
53 static inline void tcg_gen_op2_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
)
56 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
57 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
60 static inline void tcg_gen_op2i_i32(int opc
, TCGv_i32 arg1
, TCGArg arg2
)
63 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
64 *gen_opparam_ptr
++ = arg2
;
67 static inline void tcg_gen_op2i_i64(int opc
, TCGv_i64 arg1
, TCGArg arg2
)
70 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
71 *gen_opparam_ptr
++ = arg2
;
74 static inline void tcg_gen_op2ii(int opc
, TCGArg arg1
, TCGArg arg2
)
77 *gen_opparam_ptr
++ = arg1
;
78 *gen_opparam_ptr
++ = arg2
;
81 static inline void tcg_gen_op3_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
85 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
86 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
87 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
90 static inline void tcg_gen_op3_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
94 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
95 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
96 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
99 static inline void tcg_gen_op3i_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
102 *gen_opc_ptr
++ = opc
;
103 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
104 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
105 *gen_opparam_ptr
++ = arg3
;
108 static inline void tcg_gen_op3i_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
111 *gen_opc_ptr
++ = opc
;
112 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
113 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
114 *gen_opparam_ptr
++ = arg3
;
117 static inline void tcg_gen_ldst_op_i32(int opc
, TCGv_i32 val
, TCGv_ptr base
,
120 *gen_opc_ptr
++ = opc
;
121 *gen_opparam_ptr
++ = GET_TCGV_I32(val
);
122 *gen_opparam_ptr
++ = GET_TCGV_PTR(base
);
123 *gen_opparam_ptr
++ = offset
;
126 static inline void tcg_gen_ldst_op_i64(int opc
, TCGv_i64 val
, TCGv_ptr base
,
129 *gen_opc_ptr
++ = opc
;
130 *gen_opparam_ptr
++ = GET_TCGV_I64(val
);
131 *gen_opparam_ptr
++ = GET_TCGV_PTR(base
);
132 *gen_opparam_ptr
++ = offset
;
135 static inline void tcg_gen_qemu_ldst_op_i64_i32(int opc
, TCGv_i64 val
, TCGv_i32 addr
,
138 *gen_opc_ptr
++ = opc
;
139 *gen_opparam_ptr
++ = GET_TCGV_I64(val
);
140 *gen_opparam_ptr
++ = GET_TCGV_I32(addr
);
141 *gen_opparam_ptr
++ = mem_index
;
144 static inline void tcg_gen_qemu_ldst_op_i64_i64(int opc
, TCGv_i64 val
, TCGv_i64 addr
,
147 *gen_opc_ptr
++ = opc
;
148 *gen_opparam_ptr
++ = GET_TCGV_I64(val
);
149 *gen_opparam_ptr
++ = GET_TCGV_I64(addr
);
150 *gen_opparam_ptr
++ = mem_index
;
153 static inline void tcg_gen_op4_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
154 TCGv_i32 arg3
, TCGv_i32 arg4
)
156 *gen_opc_ptr
++ = opc
;
157 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
158 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
159 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
160 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
163 static inline void tcg_gen_op4_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
164 TCGv_i64 arg3
, TCGv_i64 arg4
)
166 *gen_opc_ptr
++ = opc
;
167 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
168 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
169 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
170 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
173 static inline void tcg_gen_op4i_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
174 TCGv_i32 arg3
, TCGArg arg4
)
176 *gen_opc_ptr
++ = opc
;
177 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
178 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
179 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
180 *gen_opparam_ptr
++ = arg4
;
183 static inline void tcg_gen_op4i_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
184 TCGv_i64 arg3
, TCGArg arg4
)
186 *gen_opc_ptr
++ = opc
;
187 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
188 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
189 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
190 *gen_opparam_ptr
++ = arg4
;
193 static inline void tcg_gen_op4ii_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
194 TCGArg arg3
, TCGArg arg4
)
196 *gen_opc_ptr
++ = opc
;
197 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
198 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
199 *gen_opparam_ptr
++ = arg3
;
200 *gen_opparam_ptr
++ = arg4
;
203 static inline void tcg_gen_op4ii_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
204 TCGArg arg3
, TCGArg arg4
)
206 *gen_opc_ptr
++ = opc
;
207 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
208 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
209 *gen_opparam_ptr
++ = arg3
;
210 *gen_opparam_ptr
++ = arg4
;
213 static inline void tcg_gen_op5_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
214 TCGv_i32 arg3
, TCGv_i32 arg4
, TCGv_i32 arg5
)
216 *gen_opc_ptr
++ = opc
;
217 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
218 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
219 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
220 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
221 *gen_opparam_ptr
++ = GET_TCGV_I32(arg5
);
224 static inline void tcg_gen_op5_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
225 TCGv_i64 arg3
, TCGv_i64 arg4
, TCGv_i64 arg5
)
227 *gen_opc_ptr
++ = opc
;
228 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
229 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
230 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
231 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
232 *gen_opparam_ptr
++ = GET_TCGV_I64(arg5
);
235 static inline void tcg_gen_op5i_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
236 TCGv_i32 arg3
, TCGv_i32 arg4
, TCGArg arg5
)
238 *gen_opc_ptr
++ = opc
;
239 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
240 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
241 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
242 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
243 *gen_opparam_ptr
++ = arg5
;
246 static inline void tcg_gen_op5i_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
247 TCGv_i64 arg3
, TCGv_i64 arg4
, TCGArg arg5
)
249 *gen_opc_ptr
++ = opc
;
250 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
251 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
252 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
253 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
254 *gen_opparam_ptr
++ = arg5
;
257 static inline void tcg_gen_op6_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
258 TCGv_i32 arg3
, TCGv_i32 arg4
, TCGv_i32 arg5
,
261 *gen_opc_ptr
++ = opc
;
262 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
263 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
264 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
265 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
266 *gen_opparam_ptr
++ = GET_TCGV_I32(arg5
);
267 *gen_opparam_ptr
++ = GET_TCGV_I32(arg6
);
270 static inline void tcg_gen_op6_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
271 TCGv_i64 arg3
, TCGv_i64 arg4
, TCGv_i64 arg5
,
274 *gen_opc_ptr
++ = opc
;
275 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
276 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
277 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
278 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
279 *gen_opparam_ptr
++ = GET_TCGV_I64(arg5
);
280 *gen_opparam_ptr
++ = GET_TCGV_I64(arg6
);
283 static inline void tcg_gen_op6i_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
284 TCGv_i32 arg3
, TCGv_i32 arg4
,
285 TCGv_i32 arg5
, TCGArg arg6
)
287 *gen_opc_ptr
++ = opc
;
288 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
289 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
290 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
291 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
292 *gen_opparam_ptr
++ = GET_TCGV_I32(arg5
);
293 *gen_opparam_ptr
++ = arg6
;
296 static inline void tcg_gen_op6i_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
297 TCGv_i64 arg3
, TCGv_i64 arg4
,
298 TCGv_i64 arg5
, TCGArg arg6
)
300 *gen_opc_ptr
++ = opc
;
301 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
302 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
303 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
304 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
305 *gen_opparam_ptr
++ = GET_TCGV_I64(arg5
);
306 *gen_opparam_ptr
++ = arg6
;
309 static inline void tcg_gen_op6ii_i32(int opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
310 TCGv_i32 arg3
, TCGv_i32 arg4
, TCGArg arg5
,
313 *gen_opc_ptr
++ = opc
;
314 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
315 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
316 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
317 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
318 *gen_opparam_ptr
++ = arg5
;
319 *gen_opparam_ptr
++ = arg6
;
322 static inline void tcg_gen_op6ii_i64(int opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
323 TCGv_i64 arg3
, TCGv_i64 arg4
, TCGArg arg5
,
326 *gen_opc_ptr
++ = opc
;
327 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
328 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
329 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
330 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
331 *gen_opparam_ptr
++ = arg5
;
332 *gen_opparam_ptr
++ = arg6
;
335 static inline void gen_set_label(int n
)
337 tcg_gen_op1i(INDEX_op_set_label
, n
);
340 static inline void tcg_gen_br(int label
)
342 tcg_gen_op1i(INDEX_op_br
, label
);
345 static inline void tcg_gen_mov_i32(TCGv_i32 ret
, TCGv_i32 arg
)
347 if (!TCGV_EQUAL_I32(ret
, arg
))
348 tcg_gen_op2_i32(INDEX_op_mov_i32
, ret
, arg
);
351 static inline void tcg_gen_movi_i32(TCGv_i32 ret
, int32_t arg
)
353 tcg_gen_op2i_i32(INDEX_op_movi_i32
, ret
, arg
);
357 static inline void tcg_gen_helperN(void *func
, int flags
, int sizemask
,
358 TCGArg ret
, int nargs
, TCGArg
*args
)
361 fn
= tcg_const_ptr((tcg_target_long
)func
);
362 tcg_gen_callN(&tcg_ctx
, fn
, flags
, sizemask
, ret
,
364 tcg_temp_free_ptr(fn
);
367 /* FIXME: Should this be pure? */
368 static inline void tcg_gen_helper64(void *func
, TCGv_i64 ret
,
369 TCGv_i64 a
, TCGv_i64 b
)
373 fn
= tcg_const_ptr((tcg_target_long
)func
);
374 args
[0] = GET_TCGV_I64(a
);
375 args
[1] = GET_TCGV_I64(b
);
376 tcg_gen_callN(&tcg_ctx
, fn
, 0, 7, GET_TCGV_I64(ret
), 2, args
);
377 tcg_temp_free_ptr(fn
);
382 static inline void tcg_gen_ld8u_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
384 tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32
, ret
, arg2
, offset
);
387 static inline void tcg_gen_ld8s_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
389 tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32
, ret
, arg2
, offset
);
392 static inline void tcg_gen_ld16u_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
394 tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32
, ret
, arg2
, offset
);
397 static inline void tcg_gen_ld16s_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
399 tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32
, ret
, arg2
, offset
);
402 static inline void tcg_gen_ld_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
404 tcg_gen_ldst_op_i32(INDEX_op_ld_i32
, ret
, arg2
, offset
);
407 static inline void tcg_gen_st8_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
409 tcg_gen_ldst_op_i32(INDEX_op_st8_i32
, arg1
, arg2
, offset
);
412 static inline void tcg_gen_st16_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
414 tcg_gen_ldst_op_i32(INDEX_op_st16_i32
, arg1
, arg2
, offset
);
417 static inline void tcg_gen_st_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
419 tcg_gen_ldst_op_i32(INDEX_op_st_i32
, arg1
, arg2
, offset
);
422 static inline void tcg_gen_add_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
424 tcg_gen_op3_i32(INDEX_op_add_i32
, ret
, arg1
, arg2
);
427 static inline void tcg_gen_addi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
429 /* some cases can be optimized here */
431 tcg_gen_mov_i32(ret
, arg1
);
433 TCGv_i32 t0
= tcg_const_i32(arg2
);
434 tcg_gen_add_i32(ret
, arg1
, t0
);
435 tcg_temp_free_i32(t0
);
439 static inline void tcg_gen_sub_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
441 tcg_gen_op3_i32(INDEX_op_sub_i32
, ret
, arg1
, arg2
);
444 static inline void tcg_gen_subfi_i32(TCGv_i32 ret
, int32_t arg1
, TCGv_i32 arg2
)
446 TCGv_i32 t0
= tcg_const_i32(arg1
);
447 tcg_gen_sub_i32(ret
, t0
, arg2
);
448 tcg_temp_free_i32(t0
);
451 static inline void tcg_gen_subi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
453 /* some cases can be optimized here */
455 tcg_gen_mov_i32(ret
, arg1
);
457 TCGv_i32 t0
= tcg_const_i32(arg2
);
458 tcg_gen_sub_i32(ret
, arg1
, t0
);
459 tcg_temp_free_i32(t0
);
463 static inline void tcg_gen_and_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
465 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
466 tcg_gen_mov_i32(ret
, arg1
);
468 tcg_gen_op3_i32(INDEX_op_and_i32
, ret
, arg1
, arg2
);
472 static inline void tcg_gen_andi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
474 /* some cases can be optimized here */
476 tcg_gen_movi_i32(ret
, 0);
477 } else if (arg2
== 0xffffffff) {
478 tcg_gen_mov_i32(ret
, arg1
);
480 TCGv_i32 t0
= tcg_const_i32(arg2
);
481 tcg_gen_and_i32(ret
, arg1
, t0
);
482 tcg_temp_free_i32(t0
);
486 static inline void tcg_gen_or_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
488 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
489 tcg_gen_mov_i32(ret
, arg1
);
491 tcg_gen_op3_i32(INDEX_op_or_i32
, ret
, arg1
, arg2
);
495 static inline void tcg_gen_ori_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
497 /* some cases can be optimized here */
498 if (arg2
== 0xffffffff) {
499 tcg_gen_movi_i32(ret
, 0xffffffff);
500 } else if (arg2
== 0) {
501 tcg_gen_mov_i32(ret
, arg1
);
503 TCGv_i32 t0
= tcg_const_i32(arg2
);
504 tcg_gen_or_i32(ret
, arg1
, t0
);
505 tcg_temp_free_i32(t0
);
509 static inline void tcg_gen_xor_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
511 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
512 tcg_gen_movi_i32(ret
, 0);
514 tcg_gen_op3_i32(INDEX_op_xor_i32
, ret
, arg1
, arg2
);
518 static inline void tcg_gen_xori_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
520 /* some cases can be optimized here */
522 tcg_gen_mov_i32(ret
, arg1
);
524 TCGv_i32 t0
= tcg_const_i32(arg2
);
525 tcg_gen_xor_i32(ret
, arg1
, t0
);
526 tcg_temp_free_i32(t0
);
530 static inline void tcg_gen_shl_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
532 tcg_gen_op3_i32(INDEX_op_shl_i32
, ret
, arg1
, arg2
);
535 static inline void tcg_gen_shli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
538 tcg_gen_mov_i32(ret
, arg1
);
540 TCGv_i32 t0
= tcg_const_i32(arg2
);
541 tcg_gen_shl_i32(ret
, arg1
, t0
);
542 tcg_temp_free_i32(t0
);
546 static inline void tcg_gen_shr_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
548 tcg_gen_op3_i32(INDEX_op_shr_i32
, ret
, arg1
, arg2
);
551 static inline void tcg_gen_shri_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
554 tcg_gen_mov_i32(ret
, arg1
);
556 TCGv_i32 t0
= tcg_const_i32(arg2
);
557 tcg_gen_shr_i32(ret
, arg1
, t0
);
558 tcg_temp_free_i32(t0
);
562 static inline void tcg_gen_sar_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
564 tcg_gen_op3_i32(INDEX_op_sar_i32
, ret
, arg1
, arg2
);
567 static inline void tcg_gen_sari_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
570 tcg_gen_mov_i32(ret
, arg1
);
572 TCGv_i32 t0
= tcg_const_i32(arg2
);
573 tcg_gen_sar_i32(ret
, arg1
, t0
);
574 tcg_temp_free_i32(t0
);
578 static inline void tcg_gen_brcond_i32(int cond
, TCGv_i32 arg1
, TCGv_i32 arg2
,
581 tcg_gen_op4ii_i32(INDEX_op_brcond_i32
, arg1
, arg2
, cond
, label_index
);
584 static inline void tcg_gen_brcondi_i32(int cond
, TCGv_i32 arg1
, int32_t arg2
,
587 TCGv_i32 t0
= tcg_const_i32(arg2
);
588 tcg_gen_brcond_i32(cond
, arg1
, t0
, label_index
);
589 tcg_temp_free_i32(t0
);
592 static inline void tcg_gen_setcond_i32(int cond
, TCGv_i32 ret
,
593 TCGv_i32 arg1
, TCGv_i32 arg2
)
595 tcg_gen_op4i_i32(INDEX_op_setcond_i32
, ret
, arg1
, arg2
, cond
);
598 static inline void tcg_gen_setcondi_i32(int cond
, TCGv_i32 ret
, TCGv_i32 arg1
,
601 TCGv_i32 t0
= tcg_const_i32(arg2
);
602 tcg_gen_setcond_i32(cond
, ret
, arg1
, t0
);
603 tcg_temp_free_i32(t0
);
606 static inline void tcg_gen_mul_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
608 tcg_gen_op3_i32(INDEX_op_mul_i32
, ret
, arg1
, arg2
);
611 static inline void tcg_gen_muli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
613 TCGv_i32 t0
= tcg_const_i32(arg2
);
614 tcg_gen_mul_i32(ret
, arg1
, t0
);
615 tcg_temp_free_i32(t0
);
618 #ifdef TCG_TARGET_HAS_div_i32
619 static inline void tcg_gen_div_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
621 tcg_gen_op3_i32(INDEX_op_div_i32
, ret
, arg1
, arg2
);
624 static inline void tcg_gen_rem_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
626 tcg_gen_op3_i32(INDEX_op_rem_i32
, ret
, arg1
, arg2
);
629 static inline void tcg_gen_divu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
631 tcg_gen_op3_i32(INDEX_op_divu_i32
, ret
, arg1
, arg2
);
634 static inline void tcg_gen_remu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
636 tcg_gen_op3_i32(INDEX_op_remu_i32
, ret
, arg1
, arg2
);
639 static inline void tcg_gen_div_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
642 t0
= tcg_temp_new_i32();
643 tcg_gen_sari_i32(t0
, arg1
, 31);
644 tcg_gen_op5_i32(INDEX_op_div2_i32
, ret
, t0
, arg1
, t0
, arg2
);
645 tcg_temp_free_i32(t0
);
648 static inline void tcg_gen_rem_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
651 t0
= tcg_temp_new_i32();
652 tcg_gen_sari_i32(t0
, arg1
, 31);
653 tcg_gen_op5_i32(INDEX_op_div2_i32
, t0
, ret
, arg1
, t0
, arg2
);
654 tcg_temp_free_i32(t0
);
657 static inline void tcg_gen_divu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
660 t0
= tcg_temp_new_i32();
661 tcg_gen_movi_i32(t0
, 0);
662 tcg_gen_op5_i32(INDEX_op_divu2_i32
, ret
, t0
, arg1
, t0
, arg2
);
663 tcg_temp_free_i32(t0
);
666 static inline void tcg_gen_remu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
669 t0
= tcg_temp_new_i32();
670 tcg_gen_movi_i32(t0
, 0);
671 tcg_gen_op5_i32(INDEX_op_divu2_i32
, t0
, ret
, arg1
, t0
, arg2
);
672 tcg_temp_free_i32(t0
);
676 #if TCG_TARGET_REG_BITS == 32
678 static inline void tcg_gen_mov_i64(TCGv_i64 ret
, TCGv_i64 arg
)
680 if (!TCGV_EQUAL_I64(ret
, arg
)) {
681 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
682 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
686 static inline void tcg_gen_movi_i64(TCGv_i64 ret
, int64_t arg
)
688 tcg_gen_movi_i32(TCGV_LOW(ret
), arg
);
689 tcg_gen_movi_i32(TCGV_HIGH(ret
), arg
>> 32);
692 static inline void tcg_gen_ld8u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
693 tcg_target_long offset
)
695 tcg_gen_ld8u_i32(TCGV_LOW(ret
), arg2
, offset
);
696 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
699 static inline void tcg_gen_ld8s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
700 tcg_target_long offset
)
702 tcg_gen_ld8s_i32(TCGV_LOW(ret
), arg2
, offset
);
703 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_HIGH(ret
), 31);
706 static inline void tcg_gen_ld16u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
707 tcg_target_long offset
)
709 tcg_gen_ld16u_i32(TCGV_LOW(ret
), arg2
, offset
);
710 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
713 static inline void tcg_gen_ld16s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
714 tcg_target_long offset
)
716 tcg_gen_ld16s_i32(TCGV_LOW(ret
), arg2
, offset
);
717 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
720 static inline void tcg_gen_ld32u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
721 tcg_target_long offset
)
723 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
724 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
727 static inline void tcg_gen_ld32s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
728 tcg_target_long offset
)
730 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
731 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
734 static inline void tcg_gen_ld_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
735 tcg_target_long offset
)
737 /* since arg2 and ret have different types, they cannot be the
739 #ifdef TCG_TARGET_WORDS_BIGENDIAN
740 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
);
741 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
+ 4);
743 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
744 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
+ 4);
748 static inline void tcg_gen_st8_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
749 tcg_target_long offset
)
751 tcg_gen_st8_i32(TCGV_LOW(arg1
), arg2
, offset
);
754 static inline void tcg_gen_st16_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
755 tcg_target_long offset
)
757 tcg_gen_st16_i32(TCGV_LOW(arg1
), arg2
, offset
);
760 static inline void tcg_gen_st32_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
761 tcg_target_long offset
)
763 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
);
766 static inline void tcg_gen_st_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
767 tcg_target_long offset
)
769 #ifdef TCG_TARGET_WORDS_BIGENDIAN
770 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
);
771 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
+ 4);
773 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
);
774 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
+ 4);
778 static inline void tcg_gen_add_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
780 tcg_gen_op6_i32(INDEX_op_add2_i32
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
781 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
785 static inline void tcg_gen_sub_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
787 tcg_gen_op6_i32(INDEX_op_sub2_i32
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
788 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
792 static inline void tcg_gen_and_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
794 tcg_gen_and_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
795 tcg_gen_and_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
798 static inline void tcg_gen_andi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
800 tcg_gen_andi_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
801 tcg_gen_andi_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
804 static inline void tcg_gen_or_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
806 tcg_gen_or_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
807 tcg_gen_or_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
810 static inline void tcg_gen_ori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
812 tcg_gen_ori_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
813 tcg_gen_ori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
816 static inline void tcg_gen_xor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
818 tcg_gen_xor_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
819 tcg_gen_xor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
822 static inline void tcg_gen_xori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
824 tcg_gen_xori_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
825 tcg_gen_xori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
828 /* XXX: use generic code when basic block handling is OK or CPU
829 specific code (x86) */
830 static inline void tcg_gen_shl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
832 tcg_gen_helper64(tcg_helper_shl_i64
, ret
, arg1
, arg2
);
835 static inline void tcg_gen_shli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
837 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 0, 0);
840 static inline void tcg_gen_shr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
842 tcg_gen_helper64(tcg_helper_shr_i64
, ret
, arg1
, arg2
);
845 static inline void tcg_gen_shri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
847 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 0);
850 static inline void tcg_gen_sar_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
852 tcg_gen_helper64(tcg_helper_sar_i64
, ret
, arg1
, arg2
);
855 static inline void tcg_gen_sari_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
857 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 1);
860 static inline void tcg_gen_brcond_i64(int cond
, TCGv_i64 arg1
, TCGv_i64 arg2
,
863 tcg_gen_op6ii_i32(INDEX_op_brcond2_i32
,
864 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
865 TCGV_HIGH(arg2
), cond
, label_index
);
868 static inline void tcg_gen_setcond_i64(int cond
, TCGv_i64 ret
,
869 TCGv_i64 arg1
, TCGv_i64 arg2
)
871 tcg_gen_op6i_i32(INDEX_op_setcond2_i32
, TCGV_LOW(ret
),
872 TCGV_LOW(arg1
), TCGV_HIGH(arg1
),
873 TCGV_LOW(arg2
), TCGV_HIGH(arg2
), cond
);
874 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
877 static inline void tcg_gen_mul_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
882 t0
= tcg_temp_new_i64();
883 t1
= tcg_temp_new_i32();
885 tcg_gen_op4_i32(INDEX_op_mulu2_i32
, TCGV_LOW(t0
), TCGV_HIGH(t0
),
886 TCGV_LOW(arg1
), TCGV_LOW(arg2
));
888 tcg_gen_mul_i32(t1
, TCGV_LOW(arg1
), TCGV_HIGH(arg2
));
889 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
890 tcg_gen_mul_i32(t1
, TCGV_HIGH(arg1
), TCGV_LOW(arg2
));
891 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
893 tcg_gen_mov_i64(ret
, t0
);
894 tcg_temp_free_i64(t0
);
895 tcg_temp_free_i32(t1
);
898 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
900 tcg_gen_helper64(tcg_helper_div_i64
, ret
, arg1
, arg2
);
903 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
905 tcg_gen_helper64(tcg_helper_rem_i64
, ret
, arg1
, arg2
);
908 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
910 tcg_gen_helper64(tcg_helper_divu_i64
, ret
, arg1
, arg2
);
913 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
915 tcg_gen_helper64(tcg_helper_remu_i64
, ret
, arg1
, arg2
);
920 static inline void tcg_gen_mov_i64(TCGv_i64 ret
, TCGv_i64 arg
)
922 if (!TCGV_EQUAL_I64(ret
, arg
))
923 tcg_gen_op2_i64(INDEX_op_mov_i64
, ret
, arg
);
926 static inline void tcg_gen_movi_i64(TCGv_i64 ret
, int64_t arg
)
928 tcg_gen_op2i_i64(INDEX_op_movi_i64
, ret
, arg
);
931 static inline void tcg_gen_ld8u_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
932 tcg_target_long offset
)
934 tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64
, ret
, arg2
, offset
);
937 static inline void tcg_gen_ld8s_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
938 tcg_target_long offset
)
940 tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64
, ret
, arg2
, offset
);
943 static inline void tcg_gen_ld16u_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
944 tcg_target_long offset
)
946 tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64
, ret
, arg2
, offset
);
949 static inline void tcg_gen_ld16s_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
950 tcg_target_long offset
)
952 tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64
, ret
, arg2
, offset
);
955 static inline void tcg_gen_ld32u_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
956 tcg_target_long offset
)
958 tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64
, ret
, arg2
, offset
);
961 static inline void tcg_gen_ld32s_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
962 tcg_target_long offset
)
964 tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64
, ret
, arg2
, offset
);
967 static inline void tcg_gen_ld_i64(TCGv_i64 ret
, TCGv_i64 arg2
, tcg_target_long offset
)
969 tcg_gen_ldst_op_i64(INDEX_op_ld_i64
, ret
, arg2
, offset
);
972 static inline void tcg_gen_st8_i64(TCGv_i64 arg1
, TCGv_i64 arg2
,
973 tcg_target_long offset
)
975 tcg_gen_ldst_op_i64(INDEX_op_st8_i64
, arg1
, arg2
, offset
);
978 static inline void tcg_gen_st16_i64(TCGv_i64 arg1
, TCGv_i64 arg2
,
979 tcg_target_long offset
)
981 tcg_gen_ldst_op_i64(INDEX_op_st16_i64
, arg1
, arg2
, offset
);
984 static inline void tcg_gen_st32_i64(TCGv_i64 arg1
, TCGv_i64 arg2
,
985 tcg_target_long offset
)
987 tcg_gen_ldst_op_i64(INDEX_op_st32_i64
, arg1
, arg2
, offset
);
990 static inline void tcg_gen_st_i64(TCGv_i64 arg1
, TCGv_i64 arg2
, tcg_target_long offset
)
992 tcg_gen_ldst_op_i64(INDEX_op_st_i64
, arg1
, arg2
, offset
);
995 static inline void tcg_gen_add_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
997 tcg_gen_op3_i64(INDEX_op_add_i64
, ret
, arg1
, arg2
);
1000 static inline void tcg_gen_sub_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1002 tcg_gen_op3_i64(INDEX_op_sub_i64
, ret
, arg1
, arg2
);
1005 static inline void tcg_gen_and_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1007 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1008 tcg_gen_mov_i64(ret
, arg1
);
1010 tcg_gen_op3_i64(INDEX_op_and_i64
, ret
, arg1
, arg2
);
1014 static inline void tcg_gen_andi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1016 TCGv_i64 t0
= tcg_const_i64(arg2
);
1017 tcg_gen_and_i64(ret
, arg1
, t0
);
1018 tcg_temp_free_i64(t0
);
1021 static inline void tcg_gen_or_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1023 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1024 tcg_gen_mov_i64(ret
, arg1
);
1026 tcg_gen_op3_i64(INDEX_op_or_i64
, ret
, arg1
, arg2
);
1030 static inline void tcg_gen_ori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1032 TCGv_i64 t0
= tcg_const_i64(arg2
);
1033 tcg_gen_or_i64(ret
, arg1
, t0
);
1034 tcg_temp_free_i64(t0
);
1037 static inline void tcg_gen_xor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1039 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1040 tcg_gen_movi_i64(ret
, 0);
1042 tcg_gen_op3_i64(INDEX_op_xor_i64
, ret
, arg1
, arg2
);
1046 static inline void tcg_gen_xori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1048 TCGv_i64 t0
= tcg_const_i64(arg2
);
1049 tcg_gen_xor_i64(ret
, arg1
, t0
);
1050 tcg_temp_free_i64(t0
);
1053 static inline void tcg_gen_shl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1055 tcg_gen_op3_i64(INDEX_op_shl_i64
, ret
, arg1
, arg2
);
1058 static inline void tcg_gen_shli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1061 tcg_gen_mov_i64(ret
, arg1
);
1063 TCGv_i64 t0
= tcg_const_i64(arg2
);
1064 tcg_gen_shl_i64(ret
, arg1
, t0
);
1065 tcg_temp_free_i64(t0
);
1069 static inline void tcg_gen_shr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1071 tcg_gen_op3_i64(INDEX_op_shr_i64
, ret
, arg1
, arg2
);
1074 static inline void tcg_gen_shri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1077 tcg_gen_mov_i64(ret
, arg1
);
1079 TCGv_i64 t0
= tcg_const_i64(arg2
);
1080 tcg_gen_shr_i64(ret
, arg1
, t0
);
1081 tcg_temp_free_i64(t0
);
1085 static inline void tcg_gen_sar_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1087 tcg_gen_op3_i64(INDEX_op_sar_i64
, ret
, arg1
, arg2
);
1090 static inline void tcg_gen_sari_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1093 tcg_gen_mov_i64(ret
, arg1
);
1095 TCGv_i64 t0
= tcg_const_i64(arg2
);
1096 tcg_gen_sar_i64(ret
, arg1
, t0
);
1097 tcg_temp_free_i64(t0
);
1101 static inline void tcg_gen_brcond_i64(int cond
, TCGv_i64 arg1
, TCGv_i64 arg2
,
1104 tcg_gen_op4ii_i64(INDEX_op_brcond_i64
, arg1
, arg2
, cond
, label_index
);
1107 static inline void tcg_gen_setcond_i64(int cond
, TCGv_i64 ret
,
1108 TCGv_i64 arg1
, TCGv_i64 arg2
)
1110 tcg_gen_op4i_i64(INDEX_op_setcond_i64
, ret
, arg1
, arg2
, cond
);
1113 static inline void tcg_gen_mul_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1115 tcg_gen_op3_i64(INDEX_op_mul_i64
, ret
, arg1
, arg2
);
1118 #ifdef TCG_TARGET_HAS_div_i64
1119 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1121 tcg_gen_op3_i64(INDEX_op_div_i64
, ret
, arg1
, arg2
);
1124 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1126 tcg_gen_op3_i64(INDEX_op_rem_i64
, ret
, arg1
, arg2
);
1129 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1131 tcg_gen_op3_i64(INDEX_op_divu_i64
, ret
, arg1
, arg2
);
1134 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1136 tcg_gen_op3_i64(INDEX_op_remu_i64
, ret
, arg1
, arg2
);
1139 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1142 t0
= tcg_temp_new_i64();
1143 tcg_gen_sari_i64(t0
, arg1
, 63);
1144 tcg_gen_op5_i64(INDEX_op_div2_i64
, ret
, t0
, arg1
, t0
, arg2
);
1145 tcg_temp_free_i64(t0
);
1148 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1151 t0
= tcg_temp_new_i64();
1152 tcg_gen_sari_i64(t0
, arg1
, 63);
1153 tcg_gen_op5_i64(INDEX_op_div2_i64
, t0
, ret
, arg1
, t0
, arg2
);
1154 tcg_temp_free_i64(t0
);
1157 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1160 t0
= tcg_temp_new_i64();
1161 tcg_gen_movi_i64(t0
, 0);
1162 tcg_gen_op5_i64(INDEX_op_divu2_i64
, ret
, t0
, arg1
, t0
, arg2
);
1163 tcg_temp_free_i64(t0
);
1166 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1169 t0
= tcg_temp_new_i64();
1170 tcg_gen_movi_i64(t0
, 0);
1171 tcg_gen_op5_i64(INDEX_op_divu2_i64
, t0
, ret
, arg1
, t0
, arg2
);
1172 tcg_temp_free_i64(t0
);
1178 static inline void tcg_gen_addi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1180 /* some cases can be optimized here */
1182 tcg_gen_mov_i64(ret
, arg1
);
1184 TCGv_i64 t0
= tcg_const_i64(arg2
);
1185 tcg_gen_add_i64(ret
, arg1
, t0
);
1186 tcg_temp_free_i64(t0
);
1190 static inline void tcg_gen_subfi_i64(TCGv_i64 ret
, int64_t arg1
, TCGv_i64 arg2
)
1192 TCGv_i64 t0
= tcg_const_i64(arg1
);
1193 tcg_gen_sub_i64(ret
, t0
, arg2
);
1194 tcg_temp_free_i64(t0
);
1197 static inline void tcg_gen_subi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1199 /* some cases can be optimized here */
1201 tcg_gen_mov_i64(ret
, arg1
);
1203 TCGv_i64 t0
= tcg_const_i64(arg2
);
1204 tcg_gen_sub_i64(ret
, arg1
, t0
);
1205 tcg_temp_free_i64(t0
);
1208 static inline void tcg_gen_brcondi_i64(int cond
, TCGv_i64 arg1
, int64_t arg2
,
1211 TCGv_i64 t0
= tcg_const_i64(arg2
);
1212 tcg_gen_brcond_i64(cond
, arg1
, t0
, label_index
);
1213 tcg_temp_free_i64(t0
);
1216 static inline void tcg_gen_setcondi_i64(int cond
, TCGv_i64 ret
, TCGv_i64 arg1
,
1219 TCGv_i64 t0
= tcg_const_i64(arg2
);
1220 tcg_gen_setcond_i64(cond
, ret
, arg1
, t0
);
1221 tcg_temp_free_i64(t0
);
1224 static inline void tcg_gen_muli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1226 TCGv_i64 t0
= tcg_const_i64(arg2
);
1227 tcg_gen_mul_i64(ret
, arg1
, t0
);
1228 tcg_temp_free_i64(t0
);
1232 /***************************************/
1233 /* optional operations */
1235 static inline void tcg_gen_ext8s_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1237 #ifdef TCG_TARGET_HAS_ext8s_i32
1238 tcg_gen_op2_i32(INDEX_op_ext8s_i32
, ret
, arg
);
1240 tcg_gen_shli_i32(ret
, arg
, 24);
1241 tcg_gen_sari_i32(ret
, ret
, 24);
1245 static inline void tcg_gen_ext16s_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1247 #ifdef TCG_TARGET_HAS_ext16s_i32
1248 tcg_gen_op2_i32(INDEX_op_ext16s_i32
, ret
, arg
);
1250 tcg_gen_shli_i32(ret
, arg
, 16);
1251 tcg_gen_sari_i32(ret
, ret
, 16);
1255 static inline void tcg_gen_ext8u_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1257 #ifdef TCG_TARGET_HAS_ext8u_i32
1258 tcg_gen_op2_i32(INDEX_op_ext8u_i32
, ret
, arg
);
1260 tcg_gen_andi_i32(ret
, arg
, 0xffu
);
1264 static inline void tcg_gen_ext16u_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1266 #ifdef TCG_TARGET_HAS_ext16u_i32
1267 tcg_gen_op2_i32(INDEX_op_ext16u_i32
, ret
, arg
);
1269 tcg_gen_andi_i32(ret
, arg
, 0xffffu
);
1273 /* Note: we assume the two high bytes are set to zero */
1274 static inline void tcg_gen_bswap16_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1276 #ifdef TCG_TARGET_HAS_bswap16_i32
1277 tcg_gen_op2_i32(INDEX_op_bswap16_i32
, ret
, arg
);
1279 TCGv_i32 t0
= tcg_temp_new_i32();
1281 tcg_gen_ext8u_i32(t0
, arg
);
1282 tcg_gen_shli_i32(t0
, t0
, 8);
1283 tcg_gen_shri_i32(ret
, arg
, 8);
1284 tcg_gen_or_i32(ret
, ret
, t0
);
1285 tcg_temp_free_i32(t0
);
1289 static inline void tcg_gen_bswap32_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1291 #ifdef TCG_TARGET_HAS_bswap32_i32
1292 tcg_gen_op2_i32(INDEX_op_bswap32_i32
, ret
, arg
);
1295 t0
= tcg_temp_new_i32();
1296 t1
= tcg_temp_new_i32();
1298 tcg_gen_shli_i32(t0
, arg
, 24);
1300 tcg_gen_andi_i32(t1
, arg
, 0x0000ff00);
1301 tcg_gen_shli_i32(t1
, t1
, 8);
1302 tcg_gen_or_i32(t0
, t0
, t1
);
1304 tcg_gen_shri_i32(t1
, arg
, 8);
1305 tcg_gen_andi_i32(t1
, t1
, 0x0000ff00);
1306 tcg_gen_or_i32(t0
, t0
, t1
);
1308 tcg_gen_shri_i32(t1
, arg
, 24);
1309 tcg_gen_or_i32(ret
, t0
, t1
);
1310 tcg_temp_free_i32(t0
);
1311 tcg_temp_free_i32(t1
);
1315 #if TCG_TARGET_REG_BITS == 32
1316 static inline void tcg_gen_ext8s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1318 tcg_gen_ext8s_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1319 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1322 static inline void tcg_gen_ext16s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1324 tcg_gen_ext16s_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1325 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1328 static inline void tcg_gen_ext32s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1330 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1331 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1334 static inline void tcg_gen_ext8u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1336 tcg_gen_ext8u_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1337 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1340 static inline void tcg_gen_ext16u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1342 tcg_gen_ext16u_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1343 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1346 static inline void tcg_gen_ext32u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1348 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1349 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1352 static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret
, TCGv_i64 arg
)
1354 tcg_gen_mov_i32(ret
, TCGV_LOW(arg
));
1357 static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1359 tcg_gen_mov_i32(TCGV_LOW(ret
), arg
);
1360 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1363 static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1365 tcg_gen_mov_i32(TCGV_LOW(ret
), arg
);
1366 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1369 /* Note: we assume the six high bytes are set to zero */
1370 static inline void tcg_gen_bswap16_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1372 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1373 tcg_gen_bswap16_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1376 /* Note: we assume the four high bytes are set to zero */
1377 static inline void tcg_gen_bswap32_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1379 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1380 tcg_gen_bswap32_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1383 static inline void tcg_gen_bswap64_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1386 t0
= tcg_temp_new_i32();
1387 t1
= tcg_temp_new_i32();
1389 tcg_gen_bswap32_i32(t0
, TCGV_LOW(arg
));
1390 tcg_gen_bswap32_i32(t1
, TCGV_HIGH(arg
));
1391 tcg_gen_mov_i32(TCGV_LOW(ret
), t1
);
1392 tcg_gen_mov_i32(TCGV_HIGH(ret
), t0
);
1393 tcg_temp_free_i32(t0
);
1394 tcg_temp_free_i32(t1
);
1398 static inline void tcg_gen_ext8s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1400 #ifdef TCG_TARGET_HAS_ext8s_i64
1401 tcg_gen_op2_i64(INDEX_op_ext8s_i64
, ret
, arg
);
1403 tcg_gen_shli_i64(ret
, arg
, 56);
1404 tcg_gen_sari_i64(ret
, ret
, 56);
1408 static inline void tcg_gen_ext16s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1410 #ifdef TCG_TARGET_HAS_ext16s_i64
1411 tcg_gen_op2_i64(INDEX_op_ext16s_i64
, ret
, arg
);
1413 tcg_gen_shli_i64(ret
, arg
, 48);
1414 tcg_gen_sari_i64(ret
, ret
, 48);
1418 static inline void tcg_gen_ext32s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1420 #ifdef TCG_TARGET_HAS_ext32s_i64
1421 tcg_gen_op2_i64(INDEX_op_ext32s_i64
, ret
, arg
);
1423 tcg_gen_shli_i64(ret
, arg
, 32);
1424 tcg_gen_sari_i64(ret
, ret
, 32);
1428 static inline void tcg_gen_ext8u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1430 #ifdef TCG_TARGET_HAS_ext8u_i64
1431 tcg_gen_op2_i64(INDEX_op_ext8u_i64
, ret
, arg
);
1433 tcg_gen_andi_i64(ret
, arg
, 0xffu
);
1437 static inline void tcg_gen_ext16u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1439 #ifdef TCG_TARGET_HAS_ext16u_i64
1440 tcg_gen_op2_i64(INDEX_op_ext16u_i64
, ret
, arg
);
1442 tcg_gen_andi_i64(ret
, arg
, 0xffffu
);
1446 static inline void tcg_gen_ext32u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1448 #ifdef TCG_TARGET_HAS_ext32u_i64
1449 tcg_gen_op2_i64(INDEX_op_ext32u_i64
, ret
, arg
);
1451 tcg_gen_andi_i64(ret
, arg
, 0xffffffffu
);
1455 /* Note: we assume the target supports move between 32 and 64 bit
1456 registers. This will probably break MIPS64 targets. */
1457 static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret
, TCGv_i64 arg
)
1459 tcg_gen_mov_i32(ret
, MAKE_TCGV_I32(GET_TCGV_I64(arg
)));
1462 /* Note: we assume the target supports move between 32 and 64 bit
1464 static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1466 tcg_gen_ext32u_i64(ret
, MAKE_TCGV_I64(GET_TCGV_I32(arg
)));
1469 /* Note: we assume the target supports move between 32 and 64 bit
1471 static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1473 tcg_gen_ext32s_i64(ret
, MAKE_TCGV_I64(GET_TCGV_I32(arg
)));
1476 /* Note: we assume the six high bytes are set to zero */
1477 static inline void tcg_gen_bswap16_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1479 #ifdef TCG_TARGET_HAS_bswap16_i64
1480 tcg_gen_op2_i64(INDEX_op_bswap16_i64
, ret
, arg
);
1482 TCGv_i64 t0
= tcg_temp_new_i64();
1484 tcg_gen_ext8u_i64(t0
, arg
);
1485 tcg_gen_shli_i64(t0
, t0
, 8);
1486 tcg_gen_shri_i64(ret
, arg
, 8);
1487 tcg_gen_or_i64(ret
, ret
, t0
);
1488 tcg_temp_free_i64(t0
);
1492 /* Note: we assume the four high bytes are set to zero */
1493 static inline void tcg_gen_bswap32_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1495 #ifdef TCG_TARGET_HAS_bswap32_i64
1496 tcg_gen_op2_i64(INDEX_op_bswap32_i64
, ret
, arg
);
1499 t0
= tcg_temp_new_i64();
1500 t1
= tcg_temp_new_i64();
1502 tcg_gen_shli_i64(t0
, arg
, 24);
1503 tcg_gen_ext32u_i64(t0
, t0
);
1505 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1506 tcg_gen_shli_i64(t1
, t1
, 8);
1507 tcg_gen_or_i64(t0
, t0
, t1
);
1509 tcg_gen_shri_i64(t1
, arg
, 8);
1510 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1511 tcg_gen_or_i64(t0
, t0
, t1
);
1513 tcg_gen_shri_i64(t1
, arg
, 24);
1514 tcg_gen_or_i64(ret
, t0
, t1
);
1515 tcg_temp_free_i64(t0
);
1516 tcg_temp_free_i64(t1
);
1520 static inline void tcg_gen_bswap64_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1522 #ifdef TCG_TARGET_HAS_bswap64_i64
1523 tcg_gen_op2_i64(INDEX_op_bswap64_i64
, ret
, arg
);
1525 TCGv_i64 t0
= tcg_temp_new_i64();
1526 TCGv_i64 t1
= tcg_temp_new_i64();
1528 tcg_gen_shli_i64(t0
, arg
, 56);
1530 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1531 tcg_gen_shli_i64(t1
, t1
, 40);
1532 tcg_gen_or_i64(t0
, t0
, t1
);
1534 tcg_gen_andi_i64(t1
, arg
, 0x00ff0000);
1535 tcg_gen_shli_i64(t1
, t1
, 24);
1536 tcg_gen_or_i64(t0
, t0
, t1
);
1538 tcg_gen_andi_i64(t1
, arg
, 0xff000000);
1539 tcg_gen_shli_i64(t1
, t1
, 8);
1540 tcg_gen_or_i64(t0
, t0
, t1
);
1542 tcg_gen_shri_i64(t1
, arg
, 8);
1543 tcg_gen_andi_i64(t1
, t1
, 0xff000000);
1544 tcg_gen_or_i64(t0
, t0
, t1
);
1546 tcg_gen_shri_i64(t1
, arg
, 24);
1547 tcg_gen_andi_i64(t1
, t1
, 0x00ff0000);
1548 tcg_gen_or_i64(t0
, t0
, t1
);
1550 tcg_gen_shri_i64(t1
, arg
, 40);
1551 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1552 tcg_gen_or_i64(t0
, t0
, t1
);
1554 tcg_gen_shri_i64(t1
, arg
, 56);
1555 tcg_gen_or_i64(ret
, t0
, t1
);
1556 tcg_temp_free_i64(t0
);
1557 tcg_temp_free_i64(t1
);
1563 static inline void tcg_gen_neg_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1565 #ifdef TCG_TARGET_HAS_neg_i32
1566 tcg_gen_op2_i32(INDEX_op_neg_i32
, ret
, arg
);
1568 TCGv_i32 t0
= tcg_const_i32(0);
1569 tcg_gen_sub_i32(ret
, t0
, arg
);
1570 tcg_temp_free_i32(t0
);
1574 static inline void tcg_gen_neg_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1576 #ifdef TCG_TARGET_HAS_neg_i64
1577 tcg_gen_op2_i64(INDEX_op_neg_i64
, ret
, arg
);
1579 TCGv_i64 t0
= tcg_const_i64(0);
1580 tcg_gen_sub_i64(ret
, t0
, arg
);
1581 tcg_temp_free_i64(t0
);
1585 static inline void tcg_gen_not_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1587 #ifdef TCG_TARGET_HAS_not_i32
1588 tcg_gen_op2_i32(INDEX_op_not_i32
, ret
, arg
);
1590 tcg_gen_xori_i32(ret
, arg
, -1);
1594 static inline void tcg_gen_not_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1596 #ifdef TCG_TARGET_HAS_not_i64
1597 tcg_gen_op2_i64(INDEX_op_not_i64
, ret
, arg
);
1599 tcg_gen_xori_i64(ret
, arg
, -1);
1603 static inline void tcg_gen_discard_i32(TCGv_i32 arg
)
1605 tcg_gen_op1_i32(INDEX_op_discard
, arg
);
1608 #if TCG_TARGET_REG_BITS == 32
1609 static inline void tcg_gen_discard_i64(TCGv_i64 arg
)
1611 tcg_gen_discard_i32(TCGV_LOW(arg
));
1612 tcg_gen_discard_i32(TCGV_HIGH(arg
));
1615 static inline void tcg_gen_discard_i64(TCGv_i64 arg
)
1617 tcg_gen_op1_i64(INDEX_op_discard
, arg
);
1621 static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest
, TCGv_i32 low
, TCGv_i32 high
)
1623 #if TCG_TARGET_REG_BITS == 32
1624 tcg_gen_mov_i32(TCGV_LOW(dest
), low
);
1625 tcg_gen_mov_i32(TCGV_HIGH(dest
), high
);
1627 TCGv_i64 tmp
= tcg_temp_new_i64();
1628 /* This extension is only needed for type correctness.
1629 We may be able to do better given target specific information. */
1630 tcg_gen_extu_i32_i64(tmp
, high
);
1631 tcg_gen_shli_i64(tmp
, tmp
, 32);
1632 tcg_gen_extu_i32_i64(dest
, low
);
1633 tcg_gen_or_i64(dest
, dest
, tmp
);
1634 tcg_temp_free_i64(tmp
);
1638 static inline void tcg_gen_concat32_i64(TCGv_i64 dest
, TCGv_i64 low
, TCGv_i64 high
)
1640 #if TCG_TARGET_REG_BITS == 32
1641 tcg_gen_concat_i32_i64(dest
, TCGV_LOW(low
), TCGV_LOW(high
));
1643 TCGv_i64 tmp
= tcg_temp_new_i64();
1644 tcg_gen_ext32u_i64(dest
, low
);
1645 tcg_gen_shli_i64(tmp
, high
, 32);
1646 tcg_gen_or_i64(dest
, dest
, tmp
);
1647 tcg_temp_free_i64(tmp
);
1651 static inline void tcg_gen_andc_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1653 #ifdef TCG_TARGET_HAS_andc_i32
1654 tcg_gen_op3_i32(INDEX_op_andc_i32
, ret
, arg1
, arg2
);
1657 t0
= tcg_temp_new_i32();
1658 tcg_gen_not_i32(t0
, arg2
);
1659 tcg_gen_and_i32(ret
, arg1
, t0
);
1660 tcg_temp_free_i32(t0
);
1664 static inline void tcg_gen_andc_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1666 #ifdef TCG_TARGET_HAS_andc_i64
1667 tcg_gen_op3_i64(INDEX_op_andc_i64
, ret
, arg1
, arg2
);
1668 #elif defined(TCG_TARGET_HAS_andc_i32) && TCG_TARGET_REG_BITS == 32
1669 tcg_gen_andc_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1670 tcg_gen_andc_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1673 t0
= tcg_temp_new_i64();
1674 tcg_gen_not_i64(t0
, arg2
);
1675 tcg_gen_and_i64(ret
, arg1
, t0
);
1676 tcg_temp_free_i64(t0
);
1680 static inline void tcg_gen_eqv_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1682 tcg_gen_xor_i32(ret
, arg1
, arg2
);
1683 tcg_gen_not_i32(ret
, ret
);
1686 static inline void tcg_gen_eqv_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1688 tcg_gen_xor_i64(ret
, arg1
, arg2
);
1689 tcg_gen_not_i64(ret
, ret
);
1692 static inline void tcg_gen_nand_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1694 tcg_gen_and_i32(ret
, arg1
, arg2
);
1695 tcg_gen_not_i32(ret
, ret
);
1698 static inline void tcg_gen_nand_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1700 tcg_gen_and_i64(ret
, arg1
, arg2
);
1701 tcg_gen_not_i64(ret
, ret
);
1704 static inline void tcg_gen_nor_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1706 tcg_gen_or_i32(ret
, arg1
, arg2
);
1707 tcg_gen_not_i32(ret
, ret
);
1710 static inline void tcg_gen_nor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1712 tcg_gen_or_i64(ret
, arg1
, arg2
);
1713 tcg_gen_not_i64(ret
, ret
);
1716 static inline void tcg_gen_orc_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1718 #ifdef TCG_TARGET_HAS_orc_i32
1719 tcg_gen_op3_i32(INDEX_op_orc_i32
, ret
, arg1
, arg2
);
1722 t0
= tcg_temp_new_i32();
1723 tcg_gen_not_i32(t0
, arg2
);
1724 tcg_gen_or_i32(ret
, arg1
, t0
);
1725 tcg_temp_free_i32(t0
);
1729 static inline void tcg_gen_orc_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1731 #ifdef TCG_TARGET_HAS_orc_i64
1732 tcg_gen_op3_i64(INDEX_op_orc_i64
, ret
, arg1
, arg2
);
1733 #elif defined(TCG_TARGET_HAS_orc_i32) && TCG_TARGET_REG_BITS == 32
1734 tcg_gen_orc_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1735 tcg_gen_orc_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1738 t0
= tcg_temp_new_i64();
1739 tcg_gen_not_i64(t0
, arg2
);
1740 tcg_gen_or_i64(ret
, arg1
, t0
);
1741 tcg_temp_free_i64(t0
);
1745 static inline void tcg_gen_rotl_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1747 #ifdef TCG_TARGET_HAS_rot_i32
1748 tcg_gen_op3_i32(INDEX_op_rotl_i32
, ret
, arg1
, arg2
);
1752 t0
= tcg_temp_new_i32();
1753 t1
= tcg_temp_new_i32();
1754 tcg_gen_shl_i32(t0
, arg1
, arg2
);
1755 tcg_gen_subfi_i32(t1
, 32, arg2
);
1756 tcg_gen_shr_i32(t1
, arg1
, t1
);
1757 tcg_gen_or_i32(ret
, t0
, t1
);
1758 tcg_temp_free_i32(t0
);
1759 tcg_temp_free_i32(t1
);
1763 static inline void tcg_gen_rotl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1765 #ifdef TCG_TARGET_HAS_rot_i64
1766 tcg_gen_op3_i64(INDEX_op_rotl_i64
, ret
, arg1
, arg2
);
1770 t0
= tcg_temp_new_i64();
1771 t1
= tcg_temp_new_i64();
1772 tcg_gen_shl_i64(t0
, arg1
, arg2
);
1773 tcg_gen_subfi_i64(t1
, 64, arg2
);
1774 tcg_gen_shr_i64(t1
, arg1
, t1
);
1775 tcg_gen_or_i64(ret
, t0
, t1
);
1776 tcg_temp_free_i64(t0
);
1777 tcg_temp_free_i64(t1
);
1781 static inline void tcg_gen_rotli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
1783 /* some cases can be optimized here */
1785 tcg_gen_mov_i32(ret
, arg1
);
1787 #ifdef TCG_TARGET_HAS_rot_i32
1788 TCGv_i32 t0
= tcg_const_i32(arg2
);
1789 tcg_gen_rotl_i32(ret
, arg1
, t0
);
1790 tcg_temp_free_i32(t0
);
1793 t0
= tcg_temp_new_i32();
1794 t1
= tcg_temp_new_i32();
1795 tcg_gen_shli_i32(t0
, arg1
, arg2
);
1796 tcg_gen_shri_i32(t1
, arg1
, 32 - arg2
);
1797 tcg_gen_or_i32(ret
, t0
, t1
);
1798 tcg_temp_free_i32(t0
);
1799 tcg_temp_free_i32(t1
);
1804 static inline void tcg_gen_rotli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1806 /* some cases can be optimized here */
1808 tcg_gen_mov_i64(ret
, arg1
);
1810 #ifdef TCG_TARGET_HAS_rot_i64
1811 TCGv_i64 t0
= tcg_const_i64(arg2
);
1812 tcg_gen_rotl_i64(ret
, arg1
, t0
);
1813 tcg_temp_free_i64(t0
);
1816 t0
= tcg_temp_new_i64();
1817 t1
= tcg_temp_new_i64();
1818 tcg_gen_shli_i64(t0
, arg1
, arg2
);
1819 tcg_gen_shri_i64(t1
, arg1
, 64 - arg2
);
1820 tcg_gen_or_i64(ret
, t0
, t1
);
1821 tcg_temp_free_i64(t0
);
1822 tcg_temp_free_i64(t1
);
1827 static inline void tcg_gen_rotr_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1829 #ifdef TCG_TARGET_HAS_rot_i32
1830 tcg_gen_op3_i32(INDEX_op_rotr_i32
, ret
, arg1
, arg2
);
1834 t0
= tcg_temp_new_i32();
1835 t1
= tcg_temp_new_i32();
1836 tcg_gen_shr_i32(t0
, arg1
, arg2
);
1837 tcg_gen_subfi_i32(t1
, 32, arg2
);
1838 tcg_gen_shl_i32(t1
, arg1
, t1
);
1839 tcg_gen_or_i32(ret
, t0
, t1
);
1840 tcg_temp_free_i32(t0
);
1841 tcg_temp_free_i32(t1
);
1845 static inline void tcg_gen_rotr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1847 #ifdef TCG_TARGET_HAS_rot_i64
1848 tcg_gen_op3_i64(INDEX_op_rotr_i64
, ret
, arg1
, arg2
);
1852 t0
= tcg_temp_new_i64();
1853 t1
= tcg_temp_new_i64();
1854 tcg_gen_shr_i64(t0
, arg1
, arg2
);
1855 tcg_gen_subfi_i64(t1
, 64, arg2
);
1856 tcg_gen_shl_i64(t1
, arg1
, t1
);
1857 tcg_gen_or_i64(ret
, t0
, t1
);
1858 tcg_temp_free_i64(t0
);
1859 tcg_temp_free_i64(t1
);
1863 static inline void tcg_gen_rotri_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
1865 /* some cases can be optimized here */
1867 tcg_gen_mov_i32(ret
, arg1
);
1869 tcg_gen_rotli_i32(ret
, arg1
, 32 - arg2
);
1873 static inline void tcg_gen_rotri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1875 /* some cases can be optimized here */
1877 tcg_gen_mov_i64(ret
, arg1
);
1879 tcg_gen_rotli_i64(ret
, arg1
, 64 - arg2
);
1883 /***************************************/
1884 /* QEMU specific operations. Their type depend on the QEMU CPU
1886 #ifndef TARGET_LONG_BITS
1887 #error must include QEMU headers
1890 #if TARGET_LONG_BITS == 32
1891 #define TCGv TCGv_i32
1892 #define tcg_temp_new() tcg_temp_new_i32()
1893 #define tcg_global_reg_new tcg_global_reg_new_i32
1894 #define tcg_global_mem_new tcg_global_mem_new_i32
1895 #define tcg_temp_local_new() tcg_temp_local_new_i32()
1896 #define tcg_temp_free tcg_temp_free_i32
1897 #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32
1898 #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32
1899 #define TCGV_UNUSED(x) TCGV_UNUSED_I32(x)
1900 #define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b)
1902 #define TCGv TCGv_i64
1903 #define tcg_temp_new() tcg_temp_new_i64()
1904 #define tcg_global_reg_new tcg_global_reg_new_i64
1905 #define tcg_global_mem_new tcg_global_mem_new_i64
1906 #define tcg_temp_local_new() tcg_temp_local_new_i64()
1907 #define tcg_temp_free tcg_temp_free_i64
1908 #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64
1909 #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64
1910 #define TCGV_UNUSED(x) TCGV_UNUSED_I64(x)
1911 #define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b)
1914 /* debug info: write the PC of the corresponding QEMU CPU instruction */
1915 static inline void tcg_gen_debug_insn_start(uint64_t pc
)
1917 /* XXX: must really use a 32 bit size for TCGArg in all cases */
1918 #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
1919 tcg_gen_op2ii(INDEX_op_debug_insn_start
,
1920 (uint32_t)(pc
), (uint32_t)(pc
>> 32));
1922 tcg_gen_op1i(INDEX_op_debug_insn_start
, pc
);
1926 static inline void tcg_gen_exit_tb(tcg_target_long val
)
1928 tcg_gen_op1i(INDEX_op_exit_tb
, val
);
1931 static inline void tcg_gen_goto_tb(int idx
)
1933 tcg_gen_op1i(INDEX_op_goto_tb
, idx
);
1936 #if TCG_TARGET_REG_BITS == 32
1937 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
1939 #if TARGET_LONG_BITS == 32
1940 tcg_gen_op3i_i32(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
1942 tcg_gen_op4i_i32(INDEX_op_qemu_ld8u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
1943 TCGV_HIGH(addr
), mem_index
);
1944 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1948 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
1950 #if TARGET_LONG_BITS == 32
1951 tcg_gen_op3i_i32(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
1953 tcg_gen_op4i_i32(INDEX_op_qemu_ld8s
, TCGV_LOW(ret
), TCGV_LOW(addr
),
1954 TCGV_HIGH(addr
), mem_index
);
1955 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1959 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
1961 #if TARGET_LONG_BITS == 32
1962 tcg_gen_op3i_i32(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
1964 tcg_gen_op4i_i32(INDEX_op_qemu_ld16u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
1965 TCGV_HIGH(addr
), mem_index
);
1966 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1970 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
1972 #if TARGET_LONG_BITS == 32
1973 tcg_gen_op3i_i32(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
1975 tcg_gen_op4i_i32(INDEX_op_qemu_ld16s
, TCGV_LOW(ret
), TCGV_LOW(addr
),
1976 TCGV_HIGH(addr
), mem_index
);
1977 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1981 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
1983 #if TARGET_LONG_BITS == 32
1984 tcg_gen_op3i_i32(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1986 tcg_gen_op4i_i32(INDEX_op_qemu_ld32u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
1987 TCGV_HIGH(addr
), mem_index
);
1988 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1992 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
1994 #if TARGET_LONG_BITS == 32
1995 tcg_gen_op3i_i32(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
1997 tcg_gen_op4i_i32(INDEX_op_qemu_ld32u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
1998 TCGV_HIGH(addr
), mem_index
);
1999 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2003 static inline void tcg_gen_qemu_ld64(TCGv_i64 ret
, TCGv addr
, int mem_index
)
2005 #if TARGET_LONG_BITS == 32
2006 tcg_gen_op4i_i32(INDEX_op_qemu_ld64
, TCGV_LOW(ret
), TCGV_HIGH(ret
), addr
, mem_index
);
2008 tcg_gen_op5i_i32(INDEX_op_qemu_ld64
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
2009 TCGV_LOW(addr
), TCGV_HIGH(addr
), mem_index
);
2013 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
2015 #if TARGET_LONG_BITS == 32
2016 tcg_gen_op3i_i32(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
2018 tcg_gen_op4i_i32(INDEX_op_qemu_st8
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2019 TCGV_HIGH(addr
), mem_index
);
2023 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
2025 #if TARGET_LONG_BITS == 32
2026 tcg_gen_op3i_i32(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
2028 tcg_gen_op4i_i32(INDEX_op_qemu_st16
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2029 TCGV_HIGH(addr
), mem_index
);
2033 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
2035 #if TARGET_LONG_BITS == 32
2036 tcg_gen_op3i_i32(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
2038 tcg_gen_op4i_i32(INDEX_op_qemu_st32
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2039 TCGV_HIGH(addr
), mem_index
);
2043 static inline void tcg_gen_qemu_st64(TCGv_i64 arg
, TCGv addr
, int mem_index
)
2045 #if TARGET_LONG_BITS == 32
2046 tcg_gen_op4i_i32(INDEX_op_qemu_st64
, TCGV_LOW(arg
), TCGV_HIGH(arg
), addr
,
2049 tcg_gen_op5i_i32(INDEX_op_qemu_st64
, TCGV_LOW(arg
), TCGV_HIGH(arg
),
2050 TCGV_LOW(addr
), TCGV_HIGH(addr
), mem_index
);
2054 #define tcg_gen_ld_ptr tcg_gen_ld_i32
2055 #define tcg_gen_discard_ptr tcg_gen_discard_i32
2057 #else /* TCG_TARGET_REG_BITS == 32 */
2059 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
2061 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
2064 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
2066 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
2069 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
2071 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
2074 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
2076 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
2079 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
2081 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
2084 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
2086 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s
, ret
, addr
, mem_index
);
2089 static inline void tcg_gen_qemu_ld64(TCGv_i64 ret
, TCGv addr
, int mem_index
)
2091 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64
, ret
, addr
, mem_index
);
2094 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
2096 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
2099 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
2101 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
2104 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
2106 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
2109 static inline void tcg_gen_qemu_st64(TCGv_i64 arg
, TCGv addr
, int mem_index
)
2111 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64
, arg
, addr
, mem_index
);
2114 #define tcg_gen_ld_ptr tcg_gen_ld_i64
2115 #define tcg_gen_discard_ptr tcg_gen_discard_i64
2117 #endif /* TCG_TARGET_REG_BITS != 32 */
2119 #if TARGET_LONG_BITS == 64
2120 #define TCG_TYPE_TL TCG_TYPE_I64
2121 #define tcg_gen_movi_tl tcg_gen_movi_i64
2122 #define tcg_gen_mov_tl tcg_gen_mov_i64
2123 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
2124 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
2125 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
2126 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
2127 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
2128 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
2129 #define tcg_gen_ld_tl tcg_gen_ld_i64
2130 #define tcg_gen_st8_tl tcg_gen_st8_i64
2131 #define tcg_gen_st16_tl tcg_gen_st16_i64
2132 #define tcg_gen_st32_tl tcg_gen_st32_i64
2133 #define tcg_gen_st_tl tcg_gen_st_i64
2134 #define tcg_gen_add_tl tcg_gen_add_i64
2135 #define tcg_gen_addi_tl tcg_gen_addi_i64
2136 #define tcg_gen_sub_tl tcg_gen_sub_i64
2137 #define tcg_gen_neg_tl tcg_gen_neg_i64
2138 #define tcg_gen_subfi_tl tcg_gen_subfi_i64
2139 #define tcg_gen_subi_tl tcg_gen_subi_i64
2140 #define tcg_gen_and_tl tcg_gen_and_i64
2141 #define tcg_gen_andi_tl tcg_gen_andi_i64
2142 #define tcg_gen_or_tl tcg_gen_or_i64
2143 #define tcg_gen_ori_tl tcg_gen_ori_i64
2144 #define tcg_gen_xor_tl tcg_gen_xor_i64
2145 #define tcg_gen_xori_tl tcg_gen_xori_i64
2146 #define tcg_gen_not_tl tcg_gen_not_i64
2147 #define tcg_gen_shl_tl tcg_gen_shl_i64
2148 #define tcg_gen_shli_tl tcg_gen_shli_i64
2149 #define tcg_gen_shr_tl tcg_gen_shr_i64
2150 #define tcg_gen_shri_tl tcg_gen_shri_i64
2151 #define tcg_gen_sar_tl tcg_gen_sar_i64
2152 #define tcg_gen_sari_tl tcg_gen_sari_i64
2153 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
2154 #define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
2155 #define tcg_gen_setcond_tl tcg_gen_setcond_i64
2156 #define tcg_gen_setcondi_tl tcg_gen_setcondi_i64
2157 #define tcg_gen_mul_tl tcg_gen_mul_i64
2158 #define tcg_gen_muli_tl tcg_gen_muli_i64
2159 #define tcg_gen_div_tl tcg_gen_div_i64
2160 #define tcg_gen_rem_tl tcg_gen_rem_i64
2161 #define tcg_gen_divu_tl tcg_gen_divu_i64
2162 #define tcg_gen_remu_tl tcg_gen_remu_i64
2163 #define tcg_gen_discard_tl tcg_gen_discard_i64
2164 #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
2165 #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
2166 #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
2167 #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
2168 #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
2169 #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
2170 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
2171 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
2172 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
2173 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
2174 #define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
2175 #define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
2176 #define tcg_gen_bswap16_tl tcg_gen_bswap16_i64
2177 #define tcg_gen_bswap32_tl tcg_gen_bswap32_i64
2178 #define tcg_gen_bswap64_tl tcg_gen_bswap64_i64
2179 #define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
2180 #define tcg_gen_andc_tl tcg_gen_andc_i64
2181 #define tcg_gen_eqv_tl tcg_gen_eqv_i64
2182 #define tcg_gen_nand_tl tcg_gen_nand_i64
2183 #define tcg_gen_nor_tl tcg_gen_nor_i64
2184 #define tcg_gen_orc_tl tcg_gen_orc_i64
2185 #define tcg_gen_rotl_tl tcg_gen_rotl_i64
2186 #define tcg_gen_rotli_tl tcg_gen_rotli_i64
2187 #define tcg_gen_rotr_tl tcg_gen_rotr_i64
2188 #define tcg_gen_rotri_tl tcg_gen_rotri_i64
2189 #define tcg_const_tl tcg_const_i64
2190 #define tcg_const_local_tl tcg_const_local_i64
2192 #define TCG_TYPE_TL TCG_TYPE_I32
2193 #define tcg_gen_movi_tl tcg_gen_movi_i32
2194 #define tcg_gen_mov_tl tcg_gen_mov_i32
2195 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
2196 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
2197 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
2198 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
2199 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
2200 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
2201 #define tcg_gen_ld_tl tcg_gen_ld_i32
2202 #define tcg_gen_st8_tl tcg_gen_st8_i32
2203 #define tcg_gen_st16_tl tcg_gen_st16_i32
2204 #define tcg_gen_st32_tl tcg_gen_st_i32
2205 #define tcg_gen_st_tl tcg_gen_st_i32
2206 #define tcg_gen_add_tl tcg_gen_add_i32
2207 #define tcg_gen_addi_tl tcg_gen_addi_i32
2208 #define tcg_gen_sub_tl tcg_gen_sub_i32
2209 #define tcg_gen_neg_tl tcg_gen_neg_i32
2210 #define tcg_gen_subfi_tl tcg_gen_subfi_i32
2211 #define tcg_gen_subi_tl tcg_gen_subi_i32
2212 #define tcg_gen_and_tl tcg_gen_and_i32
2213 #define tcg_gen_andi_tl tcg_gen_andi_i32
2214 #define tcg_gen_or_tl tcg_gen_or_i32
2215 #define tcg_gen_ori_tl tcg_gen_ori_i32
2216 #define tcg_gen_xor_tl tcg_gen_xor_i32
2217 #define tcg_gen_xori_tl tcg_gen_xori_i32
2218 #define tcg_gen_not_tl tcg_gen_not_i32
2219 #define tcg_gen_shl_tl tcg_gen_shl_i32
2220 #define tcg_gen_shli_tl tcg_gen_shli_i32
2221 #define tcg_gen_shr_tl tcg_gen_shr_i32
2222 #define tcg_gen_shri_tl tcg_gen_shri_i32
2223 #define tcg_gen_sar_tl tcg_gen_sar_i32
2224 #define tcg_gen_sari_tl tcg_gen_sari_i32
2225 #define tcg_gen_brcond_tl tcg_gen_brcond_i32
2226 #define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
2227 #define tcg_gen_setcond_tl tcg_gen_setcond_i32
2228 #define tcg_gen_setcondi_tl tcg_gen_setcondi_i32
2229 #define tcg_gen_mul_tl tcg_gen_mul_i32
2230 #define tcg_gen_muli_tl tcg_gen_muli_i32
2231 #define tcg_gen_div_tl tcg_gen_div_i32
2232 #define tcg_gen_rem_tl tcg_gen_rem_i32
2233 #define tcg_gen_divu_tl tcg_gen_divu_i32
2234 #define tcg_gen_remu_tl tcg_gen_remu_i32
2235 #define tcg_gen_discard_tl tcg_gen_discard_i32
2236 #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
2237 #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
2238 #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
2239 #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
2240 #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
2241 #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
2242 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
2243 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
2244 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
2245 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
2246 #define tcg_gen_ext32u_tl tcg_gen_mov_i32
2247 #define tcg_gen_ext32s_tl tcg_gen_mov_i32
2248 #define tcg_gen_bswap16_tl tcg_gen_bswap16_i32
2249 #define tcg_gen_bswap32_tl tcg_gen_bswap32_i32
2250 #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
2251 #define tcg_gen_andc_tl tcg_gen_andc_i32
2252 #define tcg_gen_eqv_tl tcg_gen_eqv_i32
2253 #define tcg_gen_nand_tl tcg_gen_nand_i32
2254 #define tcg_gen_nor_tl tcg_gen_nor_i32
2255 #define tcg_gen_orc_tl tcg_gen_orc_i32
2256 #define tcg_gen_rotl_tl tcg_gen_rotl_i32
2257 #define tcg_gen_rotli_tl tcg_gen_rotli_i32
2258 #define tcg_gen_rotr_tl tcg_gen_rotr_i32
2259 #define tcg_gen_rotri_tl tcg_gen_rotri_i32
2260 #define tcg_const_tl tcg_const_i32
2261 #define tcg_const_local_tl tcg_const_local_i32
2264 #if TCG_TARGET_REG_BITS == 32
2265 #define tcg_gen_add_ptr tcg_gen_add_i32
2266 #define tcg_gen_addi_ptr tcg_gen_addi_i32
2267 #define tcg_gen_ext_i32_ptr tcg_gen_mov_i32
2268 #else /* TCG_TARGET_REG_BITS == 32 */
2269 #define tcg_gen_add_ptr tcg_gen_add_i64
2270 #define tcg_gen_addi_ptr tcg_gen_addi_i64
2271 #define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64
2272 #endif /* TCG_TARGET_REG_BITS != 32 */