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_op0(TCGOpcode opc
)
33 static inline void tcg_gen_op1_i32(TCGOpcode opc
, TCGv_i32 arg1
)
36 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
39 static inline void tcg_gen_op1_i64(TCGOpcode opc
, TCGv_i64 arg1
)
42 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
45 static inline void tcg_gen_op1i(TCGOpcode opc
, TCGArg arg1
)
48 *gen_opparam_ptr
++ = arg1
;
51 static inline void tcg_gen_op2_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
)
54 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
55 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
58 static inline void tcg_gen_op2_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
)
61 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
62 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
65 static inline void tcg_gen_op2i_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGArg arg2
)
68 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
69 *gen_opparam_ptr
++ = arg2
;
72 static inline void tcg_gen_op2i_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGArg arg2
)
75 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
76 *gen_opparam_ptr
++ = arg2
;
79 static inline void tcg_gen_op2ii(TCGOpcode opc
, TCGArg arg1
, TCGArg arg2
)
82 *gen_opparam_ptr
++ = arg1
;
83 *gen_opparam_ptr
++ = arg2
;
86 static inline void tcg_gen_op3_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
90 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
91 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
92 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
95 static inline void tcg_gen_op3_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
99 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
100 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
101 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
104 static inline void tcg_gen_op3i_i32(TCGOpcode opc
, TCGv_i32 arg1
,
105 TCGv_i32 arg2
, TCGArg arg3
)
107 *gen_opc_ptr
++ = opc
;
108 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
109 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
110 *gen_opparam_ptr
++ = arg3
;
113 static inline void tcg_gen_op3i_i64(TCGOpcode opc
, TCGv_i64 arg1
,
114 TCGv_i64 arg2
, TCGArg arg3
)
116 *gen_opc_ptr
++ = opc
;
117 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
118 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
119 *gen_opparam_ptr
++ = arg3
;
122 static inline void tcg_gen_ldst_op_i32(TCGOpcode opc
, TCGv_i32 val
,
123 TCGv_ptr base
, TCGArg offset
)
125 *gen_opc_ptr
++ = opc
;
126 *gen_opparam_ptr
++ = GET_TCGV_I32(val
);
127 *gen_opparam_ptr
++ = GET_TCGV_PTR(base
);
128 *gen_opparam_ptr
++ = offset
;
131 static inline void tcg_gen_ldst_op_i64(TCGOpcode opc
, TCGv_i64 val
,
132 TCGv_ptr base
, TCGArg offset
)
134 *gen_opc_ptr
++ = opc
;
135 *gen_opparam_ptr
++ = GET_TCGV_I64(val
);
136 *gen_opparam_ptr
++ = GET_TCGV_PTR(base
);
137 *gen_opparam_ptr
++ = offset
;
140 static inline void tcg_gen_qemu_ldst_op_i64_i32(TCGOpcode opc
, TCGv_i64 val
,
141 TCGv_i32 addr
, TCGArg mem_index
)
143 *gen_opc_ptr
++ = opc
;
144 *gen_opparam_ptr
++ = GET_TCGV_I64(val
);
145 *gen_opparam_ptr
++ = GET_TCGV_I32(addr
);
146 *gen_opparam_ptr
++ = mem_index
;
149 static inline void tcg_gen_qemu_ldst_op_i64_i64(TCGOpcode opc
, TCGv_i64 val
,
150 TCGv_i64 addr
, TCGArg mem_index
)
152 *gen_opc_ptr
++ = opc
;
153 *gen_opparam_ptr
++ = GET_TCGV_I64(val
);
154 *gen_opparam_ptr
++ = GET_TCGV_I64(addr
);
155 *gen_opparam_ptr
++ = mem_index
;
158 static inline void tcg_gen_op4_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
159 TCGv_i32 arg3
, TCGv_i32 arg4
)
161 *gen_opc_ptr
++ = opc
;
162 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
163 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
164 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
165 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
168 static inline void tcg_gen_op4_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
169 TCGv_i64 arg3
, TCGv_i64 arg4
)
171 *gen_opc_ptr
++ = opc
;
172 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
173 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
174 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
175 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
178 static inline void tcg_gen_op4i_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
179 TCGv_i32 arg3
, TCGArg arg4
)
181 *gen_opc_ptr
++ = opc
;
182 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
183 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
184 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
185 *gen_opparam_ptr
++ = arg4
;
188 static inline void tcg_gen_op4i_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
189 TCGv_i64 arg3
, TCGArg arg4
)
191 *gen_opc_ptr
++ = opc
;
192 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
193 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
194 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
195 *gen_opparam_ptr
++ = arg4
;
198 static inline void tcg_gen_op4ii_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
199 TCGArg arg3
, TCGArg arg4
)
201 *gen_opc_ptr
++ = opc
;
202 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
203 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
204 *gen_opparam_ptr
++ = arg3
;
205 *gen_opparam_ptr
++ = arg4
;
208 static inline void tcg_gen_op4ii_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
209 TCGArg arg3
, TCGArg arg4
)
211 *gen_opc_ptr
++ = opc
;
212 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
213 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
214 *gen_opparam_ptr
++ = arg3
;
215 *gen_opparam_ptr
++ = arg4
;
218 static inline void tcg_gen_op5_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
219 TCGv_i32 arg3
, TCGv_i32 arg4
, TCGv_i32 arg5
)
221 *gen_opc_ptr
++ = opc
;
222 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
223 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
224 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
225 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
226 *gen_opparam_ptr
++ = GET_TCGV_I32(arg5
);
229 static inline void tcg_gen_op5_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
230 TCGv_i64 arg3
, TCGv_i64 arg4
, TCGv_i64 arg5
)
232 *gen_opc_ptr
++ = opc
;
233 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
234 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
235 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
236 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
237 *gen_opparam_ptr
++ = GET_TCGV_I64(arg5
);
240 static inline void tcg_gen_op5i_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
241 TCGv_i32 arg3
, TCGv_i32 arg4
, TCGArg arg5
)
243 *gen_opc_ptr
++ = opc
;
244 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
245 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
246 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
247 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
248 *gen_opparam_ptr
++ = arg5
;
251 static inline void tcg_gen_op5i_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
252 TCGv_i64 arg3
, TCGv_i64 arg4
, TCGArg arg5
)
254 *gen_opc_ptr
++ = opc
;
255 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
256 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
257 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
258 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
259 *gen_opparam_ptr
++ = arg5
;
262 static inline void tcg_gen_op5ii_i32(TCGOpcode opc
, TCGv_i32 arg1
,
263 TCGv_i32 arg2
, TCGv_i32 arg3
,
264 TCGArg arg4
, TCGArg arg5
)
266 *gen_opc_ptr
++ = opc
;
267 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
268 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
269 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
270 *gen_opparam_ptr
++ = arg4
;
271 *gen_opparam_ptr
++ = arg5
;
274 static inline void tcg_gen_op5ii_i64(TCGOpcode opc
, TCGv_i64 arg1
,
275 TCGv_i64 arg2
, TCGv_i64 arg3
,
276 TCGArg arg4
, TCGArg arg5
)
278 *gen_opc_ptr
++ = opc
;
279 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
280 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
281 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
282 *gen_opparam_ptr
++ = arg4
;
283 *gen_opparam_ptr
++ = arg5
;
286 static inline void tcg_gen_op6_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
287 TCGv_i32 arg3
, TCGv_i32 arg4
, TCGv_i32 arg5
,
290 *gen_opc_ptr
++ = opc
;
291 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
292 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
293 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
294 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
295 *gen_opparam_ptr
++ = GET_TCGV_I32(arg5
);
296 *gen_opparam_ptr
++ = GET_TCGV_I32(arg6
);
299 static inline void tcg_gen_op6_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
300 TCGv_i64 arg3
, TCGv_i64 arg4
, TCGv_i64 arg5
,
303 *gen_opc_ptr
++ = opc
;
304 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
305 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
306 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
307 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
308 *gen_opparam_ptr
++ = GET_TCGV_I64(arg5
);
309 *gen_opparam_ptr
++ = GET_TCGV_I64(arg6
);
312 static inline void tcg_gen_op6i_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
313 TCGv_i32 arg3
, TCGv_i32 arg4
,
314 TCGv_i32 arg5
, TCGArg arg6
)
316 *gen_opc_ptr
++ = opc
;
317 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
318 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
319 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
320 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
321 *gen_opparam_ptr
++ = GET_TCGV_I32(arg5
);
322 *gen_opparam_ptr
++ = arg6
;
325 static inline void tcg_gen_op6i_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
326 TCGv_i64 arg3
, TCGv_i64 arg4
,
327 TCGv_i64 arg5
, TCGArg arg6
)
329 *gen_opc_ptr
++ = opc
;
330 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
331 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
332 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
333 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
334 *gen_opparam_ptr
++ = GET_TCGV_I64(arg5
);
335 *gen_opparam_ptr
++ = arg6
;
338 static inline void tcg_gen_op6ii_i32(TCGOpcode opc
, TCGv_i32 arg1
,
339 TCGv_i32 arg2
, TCGv_i32 arg3
,
340 TCGv_i32 arg4
, TCGArg arg5
, TCGArg arg6
)
342 *gen_opc_ptr
++ = opc
;
343 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
344 *gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
345 *gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
346 *gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
347 *gen_opparam_ptr
++ = arg5
;
348 *gen_opparam_ptr
++ = arg6
;
351 static inline void tcg_gen_op6ii_i64(TCGOpcode opc
, TCGv_i64 arg1
,
352 TCGv_i64 arg2
, TCGv_i64 arg3
,
353 TCGv_i64 arg4
, TCGArg arg5
, TCGArg arg6
)
355 *gen_opc_ptr
++ = opc
;
356 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
357 *gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
358 *gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
359 *gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
360 *gen_opparam_ptr
++ = arg5
;
361 *gen_opparam_ptr
++ = arg6
;
364 static inline void gen_set_label(int n
)
366 tcg_gen_op1i(INDEX_op_set_label
, n
);
369 static inline void tcg_gen_br(int label
)
371 tcg_gen_op1i(INDEX_op_br
, label
);
374 static inline void tcg_gen_mov_i32(TCGv_i32 ret
, TCGv_i32 arg
)
376 if (!TCGV_EQUAL_I32(ret
, arg
))
377 tcg_gen_op2_i32(INDEX_op_mov_i32
, ret
, arg
);
380 static inline void tcg_gen_movi_i32(TCGv_i32 ret
, int32_t arg
)
382 tcg_gen_op2i_i32(INDEX_op_movi_i32
, ret
, arg
);
385 /* A version of dh_sizemask from def-helper.h that doesn't rely on
386 preprocessor magic. */
387 static inline int tcg_gen_sizemask(int n
, int is_64bit
, int is_signed
)
389 return (is_64bit
<< n
*2) | (is_signed
<< (n
*2 + 1));
393 static inline void tcg_gen_helperN(void *func
, int flags
, int sizemask
,
394 TCGArg ret
, int nargs
, TCGArg
*args
)
397 fn
= tcg_const_ptr(func
);
398 tcg_gen_callN(&tcg_ctx
, fn
, flags
, sizemask
, ret
,
400 tcg_temp_free_ptr(fn
);
403 /* Note: Both tcg_gen_helper32() and tcg_gen_helper64() are currently
404 reserved for helpers in tcg-runtime.c. These helpers are all const
405 and pure, hence the call to tcg_gen_callN() with TCG_CALL_CONST |
406 TCG_CALL_PURE. This may need to be adjusted if these functions
407 start to be used with other helpers. */
408 static inline void tcg_gen_helper32(void *func
, int sizemask
, TCGv_i32 ret
,
409 TCGv_i32 a
, TCGv_i32 b
)
413 fn
= tcg_const_ptr(func
);
414 args
[0] = GET_TCGV_I32(a
);
415 args
[1] = GET_TCGV_I32(b
);
416 tcg_gen_callN(&tcg_ctx
, fn
, TCG_CALL_CONST
| TCG_CALL_PURE
, sizemask
,
417 GET_TCGV_I32(ret
), 2, args
);
418 tcg_temp_free_ptr(fn
);
421 static inline void tcg_gen_helper64(void *func
, int sizemask
, TCGv_i64 ret
,
422 TCGv_i64 a
, TCGv_i64 b
)
426 fn
= tcg_const_ptr(func
);
427 args
[0] = GET_TCGV_I64(a
);
428 args
[1] = GET_TCGV_I64(b
);
429 tcg_gen_callN(&tcg_ctx
, fn
, TCG_CALL_CONST
| TCG_CALL_PURE
, sizemask
,
430 GET_TCGV_I64(ret
), 2, args
);
431 tcg_temp_free_ptr(fn
);
436 static inline void tcg_gen_ld8u_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
438 tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32
, ret
, arg2
, offset
);
441 static inline void tcg_gen_ld8s_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
443 tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32
, ret
, arg2
, offset
);
446 static inline void tcg_gen_ld16u_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
448 tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32
, ret
, arg2
, offset
);
451 static inline void tcg_gen_ld16s_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
453 tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32
, ret
, arg2
, offset
);
456 static inline void tcg_gen_ld_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
458 tcg_gen_ldst_op_i32(INDEX_op_ld_i32
, ret
, arg2
, offset
);
461 static inline void tcg_gen_st8_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
463 tcg_gen_ldst_op_i32(INDEX_op_st8_i32
, arg1
, arg2
, offset
);
466 static inline void tcg_gen_st16_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
468 tcg_gen_ldst_op_i32(INDEX_op_st16_i32
, arg1
, arg2
, offset
);
471 static inline void tcg_gen_st_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
473 tcg_gen_ldst_op_i32(INDEX_op_st_i32
, arg1
, arg2
, offset
);
476 static inline void tcg_gen_add_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
478 tcg_gen_op3_i32(INDEX_op_add_i32
, ret
, arg1
, arg2
);
481 static inline void tcg_gen_addi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
483 /* some cases can be optimized here */
485 tcg_gen_mov_i32(ret
, arg1
);
487 TCGv_i32 t0
= tcg_const_i32(arg2
);
488 tcg_gen_add_i32(ret
, arg1
, t0
);
489 tcg_temp_free_i32(t0
);
493 static inline void tcg_gen_sub_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
495 tcg_gen_op3_i32(INDEX_op_sub_i32
, ret
, arg1
, arg2
);
498 static inline void tcg_gen_subfi_i32(TCGv_i32 ret
, int32_t arg1
, TCGv_i32 arg2
)
500 TCGv_i32 t0
= tcg_const_i32(arg1
);
501 tcg_gen_sub_i32(ret
, t0
, arg2
);
502 tcg_temp_free_i32(t0
);
505 static inline void tcg_gen_subi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
507 /* some cases can be optimized here */
509 tcg_gen_mov_i32(ret
, arg1
);
511 TCGv_i32 t0
= tcg_const_i32(arg2
);
512 tcg_gen_sub_i32(ret
, arg1
, t0
);
513 tcg_temp_free_i32(t0
);
517 static inline void tcg_gen_and_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
519 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
520 tcg_gen_mov_i32(ret
, arg1
);
522 tcg_gen_op3_i32(INDEX_op_and_i32
, ret
, arg1
, arg2
);
526 static inline void tcg_gen_andi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, uint32_t arg2
)
529 /* Some cases can be optimized here. */
532 tcg_gen_movi_i32(ret
, 0);
535 tcg_gen_mov_i32(ret
, arg1
);
538 /* Don't recurse with tcg_gen_ext8u_i32. */
539 if (TCG_TARGET_HAS_ext8u_i32
) {
540 tcg_gen_op2_i32(INDEX_op_ext8u_i32
, ret
, arg1
);
545 if (TCG_TARGET_HAS_ext16u_i32
) {
546 tcg_gen_op2_i32(INDEX_op_ext16u_i32
, ret
, arg1
);
551 t0
= tcg_const_i32(arg2
);
552 tcg_gen_and_i32(ret
, arg1
, t0
);
553 tcg_temp_free_i32(t0
);
556 static inline void tcg_gen_or_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
558 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
559 tcg_gen_mov_i32(ret
, arg1
);
561 tcg_gen_op3_i32(INDEX_op_or_i32
, ret
, arg1
, arg2
);
565 static inline void tcg_gen_ori_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
567 /* Some cases can be optimized here. */
569 tcg_gen_movi_i32(ret
, -1);
570 } else if (arg2
== 0) {
571 tcg_gen_mov_i32(ret
, arg1
);
573 TCGv_i32 t0
= tcg_const_i32(arg2
);
574 tcg_gen_or_i32(ret
, arg1
, t0
);
575 tcg_temp_free_i32(t0
);
579 static inline void tcg_gen_xor_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
581 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
582 tcg_gen_movi_i32(ret
, 0);
584 tcg_gen_op3_i32(INDEX_op_xor_i32
, ret
, arg1
, arg2
);
588 static inline void tcg_gen_xori_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
590 /* Some cases can be optimized here. */
592 tcg_gen_mov_i32(ret
, arg1
);
593 } else if (arg2
== -1 && TCG_TARGET_HAS_not_i32
) {
594 /* Don't recurse with tcg_gen_not_i32. */
595 tcg_gen_op2_i32(INDEX_op_not_i32
, ret
, arg1
);
597 TCGv_i32 t0
= tcg_const_i32(arg2
);
598 tcg_gen_xor_i32(ret
, arg1
, t0
);
599 tcg_temp_free_i32(t0
);
603 static inline void tcg_gen_shl_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
605 tcg_gen_op3_i32(INDEX_op_shl_i32
, ret
, arg1
, arg2
);
608 static inline void tcg_gen_shli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
611 tcg_gen_mov_i32(ret
, arg1
);
613 TCGv_i32 t0
= tcg_const_i32(arg2
);
614 tcg_gen_shl_i32(ret
, arg1
, t0
);
615 tcg_temp_free_i32(t0
);
619 static inline void tcg_gen_shr_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
621 tcg_gen_op3_i32(INDEX_op_shr_i32
, ret
, arg1
, arg2
);
624 static inline void tcg_gen_shri_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
627 tcg_gen_mov_i32(ret
, arg1
);
629 TCGv_i32 t0
= tcg_const_i32(arg2
);
630 tcg_gen_shr_i32(ret
, arg1
, t0
);
631 tcg_temp_free_i32(t0
);
635 static inline void tcg_gen_sar_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
637 tcg_gen_op3_i32(INDEX_op_sar_i32
, ret
, arg1
, arg2
);
640 static inline void tcg_gen_sari_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
643 tcg_gen_mov_i32(ret
, arg1
);
645 TCGv_i32 t0
= tcg_const_i32(arg2
);
646 tcg_gen_sar_i32(ret
, arg1
, t0
);
647 tcg_temp_free_i32(t0
);
651 static inline void tcg_gen_brcond_i32(TCGCond cond
, TCGv_i32 arg1
,
652 TCGv_i32 arg2
, int label_index
)
654 if (cond
== TCG_COND_ALWAYS
) {
655 tcg_gen_br(label_index
);
656 } else if (cond
!= TCG_COND_NEVER
) {
657 tcg_gen_op4ii_i32(INDEX_op_brcond_i32
, arg1
, arg2
, cond
, label_index
);
661 static inline void tcg_gen_brcondi_i32(TCGCond cond
, TCGv_i32 arg1
,
662 int32_t arg2
, int label_index
)
664 if (cond
== TCG_COND_ALWAYS
) {
665 tcg_gen_br(label_index
);
666 } else if (cond
!= TCG_COND_NEVER
) {
667 TCGv_i32 t0
= tcg_const_i32(arg2
);
668 tcg_gen_brcond_i32(cond
, arg1
, t0
, label_index
);
669 tcg_temp_free_i32(t0
);
673 static inline void tcg_gen_setcond_i32(TCGCond cond
, TCGv_i32 ret
,
674 TCGv_i32 arg1
, TCGv_i32 arg2
)
676 if (cond
== TCG_COND_ALWAYS
) {
677 tcg_gen_movi_i32(ret
, 1);
678 } else if (cond
== TCG_COND_NEVER
) {
679 tcg_gen_movi_i32(ret
, 0);
681 tcg_gen_op4i_i32(INDEX_op_setcond_i32
, ret
, arg1
, arg2
, cond
);
685 static inline void tcg_gen_setcondi_i32(TCGCond cond
, TCGv_i32 ret
,
686 TCGv_i32 arg1
, int32_t arg2
)
688 if (cond
== TCG_COND_ALWAYS
) {
689 tcg_gen_movi_i32(ret
, 1);
690 } else if (cond
== TCG_COND_NEVER
) {
691 tcg_gen_movi_i32(ret
, 0);
693 TCGv_i32 t0
= tcg_const_i32(arg2
);
694 tcg_gen_setcond_i32(cond
, ret
, arg1
, t0
);
695 tcg_temp_free_i32(t0
);
699 static inline void tcg_gen_mul_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
701 tcg_gen_op3_i32(INDEX_op_mul_i32
, ret
, arg1
, arg2
);
704 static inline void tcg_gen_muli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
706 TCGv_i32 t0
= tcg_const_i32(arg2
);
707 tcg_gen_mul_i32(ret
, arg1
, t0
);
708 tcg_temp_free_i32(t0
);
711 static inline void tcg_gen_div_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
713 if (TCG_TARGET_HAS_div_i32
) {
714 tcg_gen_op3_i32(INDEX_op_div_i32
, ret
, arg1
, arg2
);
715 } else if (TCG_TARGET_HAS_div2_i32
) {
716 TCGv_i32 t0
= tcg_temp_new_i32();
717 tcg_gen_sari_i32(t0
, arg1
, 31);
718 tcg_gen_op5_i32(INDEX_op_div2_i32
, ret
, t0
, arg1
, t0
, arg2
);
719 tcg_temp_free_i32(t0
);
722 /* Return value and both arguments are 32-bit and signed. */
723 sizemask
|= tcg_gen_sizemask(0, 0, 1);
724 sizemask
|= tcg_gen_sizemask(1, 0, 1);
725 sizemask
|= tcg_gen_sizemask(2, 0, 1);
726 tcg_gen_helper32(tcg_helper_div_i32
, sizemask
, ret
, arg1
, arg2
);
730 static inline void tcg_gen_rem_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
732 if (TCG_TARGET_HAS_div_i32
) {
733 tcg_gen_op3_i32(INDEX_op_rem_i32
, ret
, arg1
, arg2
);
734 } else if (TCG_TARGET_HAS_div2_i32
) {
735 TCGv_i32 t0
= tcg_temp_new_i32();
736 tcg_gen_sari_i32(t0
, arg1
, 31);
737 tcg_gen_op5_i32(INDEX_op_div2_i32
, t0
, ret
, arg1
, t0
, arg2
);
738 tcg_temp_free_i32(t0
);
741 /* Return value and both arguments are 32-bit and signed. */
742 sizemask
|= tcg_gen_sizemask(0, 0, 1);
743 sizemask
|= tcg_gen_sizemask(1, 0, 1);
744 sizemask
|= tcg_gen_sizemask(2, 0, 1);
745 tcg_gen_helper32(tcg_helper_rem_i32
, sizemask
, ret
, arg1
, arg2
);
749 static inline void tcg_gen_divu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
751 if (TCG_TARGET_HAS_div_i32
) {
752 tcg_gen_op3_i32(INDEX_op_divu_i32
, ret
, arg1
, arg2
);
753 } else if (TCG_TARGET_HAS_div2_i32
) {
754 TCGv_i32 t0
= tcg_temp_new_i32();
755 tcg_gen_movi_i32(t0
, 0);
756 tcg_gen_op5_i32(INDEX_op_divu2_i32
, ret
, t0
, arg1
, t0
, arg2
);
757 tcg_temp_free_i32(t0
);
760 /* Return value and both arguments are 32-bit and unsigned. */
761 sizemask
|= tcg_gen_sizemask(0, 0, 0);
762 sizemask
|= tcg_gen_sizemask(1, 0, 0);
763 sizemask
|= tcg_gen_sizemask(2, 0, 0);
764 tcg_gen_helper32(tcg_helper_divu_i32
, sizemask
, ret
, arg1
, arg2
);
768 static inline void tcg_gen_remu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
770 if (TCG_TARGET_HAS_div_i32
) {
771 tcg_gen_op3_i32(INDEX_op_remu_i32
, ret
, arg1
, arg2
);
772 } else if (TCG_TARGET_HAS_div2_i32
) {
773 TCGv_i32 t0
= tcg_temp_new_i32();
774 tcg_gen_movi_i32(t0
, 0);
775 tcg_gen_op5_i32(INDEX_op_divu2_i32
, t0
, ret
, arg1
, t0
, arg2
);
776 tcg_temp_free_i32(t0
);
779 /* Return value and both arguments are 32-bit and unsigned. */
780 sizemask
|= tcg_gen_sizemask(0, 0, 0);
781 sizemask
|= tcg_gen_sizemask(1, 0, 0);
782 sizemask
|= tcg_gen_sizemask(2, 0, 0);
783 tcg_gen_helper32(tcg_helper_remu_i32
, sizemask
, ret
, arg1
, arg2
);
787 #if TCG_TARGET_REG_BITS == 32
789 static inline void tcg_gen_mov_i64(TCGv_i64 ret
, TCGv_i64 arg
)
791 if (!TCGV_EQUAL_I64(ret
, arg
)) {
792 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
793 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
797 static inline void tcg_gen_movi_i64(TCGv_i64 ret
, int64_t arg
)
799 tcg_gen_movi_i32(TCGV_LOW(ret
), arg
);
800 tcg_gen_movi_i32(TCGV_HIGH(ret
), arg
>> 32);
803 static inline void tcg_gen_ld8u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
804 tcg_target_long offset
)
806 tcg_gen_ld8u_i32(TCGV_LOW(ret
), arg2
, offset
);
807 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
810 static inline void tcg_gen_ld8s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
811 tcg_target_long offset
)
813 tcg_gen_ld8s_i32(TCGV_LOW(ret
), arg2
, offset
);
814 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_HIGH(ret
), 31);
817 static inline void tcg_gen_ld16u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
818 tcg_target_long offset
)
820 tcg_gen_ld16u_i32(TCGV_LOW(ret
), arg2
, offset
);
821 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
824 static inline void tcg_gen_ld16s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
825 tcg_target_long offset
)
827 tcg_gen_ld16s_i32(TCGV_LOW(ret
), arg2
, offset
);
828 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
831 static inline void tcg_gen_ld32u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
832 tcg_target_long offset
)
834 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
835 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
838 static inline void tcg_gen_ld32s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
839 tcg_target_long offset
)
841 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
842 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
845 static inline void tcg_gen_ld_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
846 tcg_target_long offset
)
848 /* since arg2 and ret have different types, they cannot be the
850 #ifdef TCG_TARGET_WORDS_BIGENDIAN
851 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
);
852 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
+ 4);
854 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
855 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
+ 4);
859 static inline void tcg_gen_st8_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
860 tcg_target_long offset
)
862 tcg_gen_st8_i32(TCGV_LOW(arg1
), arg2
, offset
);
865 static inline void tcg_gen_st16_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
866 tcg_target_long offset
)
868 tcg_gen_st16_i32(TCGV_LOW(arg1
), arg2
, offset
);
871 static inline void tcg_gen_st32_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
872 tcg_target_long offset
)
874 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
);
877 static inline void tcg_gen_st_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
878 tcg_target_long offset
)
880 #ifdef TCG_TARGET_WORDS_BIGENDIAN
881 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
);
882 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
+ 4);
884 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
);
885 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
+ 4);
889 static inline void tcg_gen_add_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
891 tcg_gen_op6_i32(INDEX_op_add2_i32
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
892 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
894 /* Allow the optimizer room to replace add2 with two moves. */
895 tcg_gen_op0(INDEX_op_nop
);
898 static inline void tcg_gen_sub_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
900 tcg_gen_op6_i32(INDEX_op_sub2_i32
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
901 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
903 /* Allow the optimizer room to replace sub2 with two moves. */
904 tcg_gen_op0(INDEX_op_nop
);
907 static inline void tcg_gen_and_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
909 tcg_gen_and_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
910 tcg_gen_and_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
913 static inline void tcg_gen_andi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
915 tcg_gen_andi_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
916 tcg_gen_andi_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
919 static inline void tcg_gen_or_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
921 tcg_gen_or_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
922 tcg_gen_or_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
925 static inline void tcg_gen_ori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
927 tcg_gen_ori_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
928 tcg_gen_ori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
931 static inline void tcg_gen_xor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
933 tcg_gen_xor_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
934 tcg_gen_xor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
937 static inline void tcg_gen_xori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
939 tcg_gen_xori_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
940 tcg_gen_xori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
943 /* XXX: use generic code when basic block handling is OK or CPU
944 specific code (x86) */
945 static inline void tcg_gen_shl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
948 /* Return value and both arguments are 64-bit and signed. */
949 sizemask
|= tcg_gen_sizemask(0, 1, 1);
950 sizemask
|= tcg_gen_sizemask(1, 1, 1);
951 sizemask
|= tcg_gen_sizemask(2, 1, 1);
953 tcg_gen_helper64(tcg_helper_shl_i64
, sizemask
, ret
, arg1
, arg2
);
956 static inline void tcg_gen_shli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
958 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 0, 0);
961 static inline void tcg_gen_shr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
964 /* Return value and both arguments are 64-bit and signed. */
965 sizemask
|= tcg_gen_sizemask(0, 1, 1);
966 sizemask
|= tcg_gen_sizemask(1, 1, 1);
967 sizemask
|= tcg_gen_sizemask(2, 1, 1);
969 tcg_gen_helper64(tcg_helper_shr_i64
, sizemask
, ret
, arg1
, arg2
);
972 static inline void tcg_gen_shri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
974 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 0);
977 static inline void tcg_gen_sar_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
980 /* Return value and both arguments are 64-bit and signed. */
981 sizemask
|= tcg_gen_sizemask(0, 1, 1);
982 sizemask
|= tcg_gen_sizemask(1, 1, 1);
983 sizemask
|= tcg_gen_sizemask(2, 1, 1);
985 tcg_gen_helper64(tcg_helper_sar_i64
, sizemask
, ret
, arg1
, arg2
);
988 static inline void tcg_gen_sari_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
990 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 1);
993 static inline void tcg_gen_brcond_i64(TCGCond cond
, TCGv_i64 arg1
,
994 TCGv_i64 arg2
, int label_index
)
996 if (cond
== TCG_COND_ALWAYS
) {
997 tcg_gen_br(label_index
);
998 } else if (cond
!= TCG_COND_NEVER
) {
999 tcg_gen_op6ii_i32(INDEX_op_brcond2_i32
,
1000 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
1001 TCGV_HIGH(arg2
), cond
, label_index
);
1005 static inline void tcg_gen_setcond_i64(TCGCond cond
, TCGv_i64 ret
,
1006 TCGv_i64 arg1
, TCGv_i64 arg2
)
1008 if (cond
== TCG_COND_ALWAYS
) {
1009 tcg_gen_movi_i32(TCGV_LOW(ret
), 1);
1010 } else if (cond
== TCG_COND_NEVER
) {
1011 tcg_gen_movi_i32(TCGV_LOW(ret
), 0);
1013 tcg_gen_op6i_i32(INDEX_op_setcond2_i32
, TCGV_LOW(ret
),
1014 TCGV_LOW(arg1
), TCGV_HIGH(arg1
),
1015 TCGV_LOW(arg2
), TCGV_HIGH(arg2
), cond
);
1017 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1020 static inline void tcg_gen_mul_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1025 t0
= tcg_temp_new_i64();
1026 t1
= tcg_temp_new_i32();
1028 tcg_gen_op4_i32(INDEX_op_mulu2_i32
, TCGV_LOW(t0
), TCGV_HIGH(t0
),
1029 TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1031 tcg_gen_mul_i32(t1
, TCGV_LOW(arg1
), TCGV_HIGH(arg2
));
1032 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
1033 tcg_gen_mul_i32(t1
, TCGV_HIGH(arg1
), TCGV_LOW(arg2
));
1034 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
1036 tcg_gen_mov_i64(ret
, t0
);
1037 tcg_temp_free_i64(t0
);
1038 tcg_temp_free_i32(t1
);
1041 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1044 /* Return value and both arguments are 64-bit and signed. */
1045 sizemask
|= tcg_gen_sizemask(0, 1, 1);
1046 sizemask
|= tcg_gen_sizemask(1, 1, 1);
1047 sizemask
|= tcg_gen_sizemask(2, 1, 1);
1049 tcg_gen_helper64(tcg_helper_div_i64
, sizemask
, ret
, arg1
, arg2
);
1052 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1055 /* Return value and both arguments are 64-bit and signed. */
1056 sizemask
|= tcg_gen_sizemask(0, 1, 1);
1057 sizemask
|= tcg_gen_sizemask(1, 1, 1);
1058 sizemask
|= tcg_gen_sizemask(2, 1, 1);
1060 tcg_gen_helper64(tcg_helper_rem_i64
, sizemask
, ret
, arg1
, arg2
);
1063 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1066 /* Return value and both arguments are 64-bit and unsigned. */
1067 sizemask
|= tcg_gen_sizemask(0, 1, 0);
1068 sizemask
|= tcg_gen_sizemask(1, 1, 0);
1069 sizemask
|= tcg_gen_sizemask(2, 1, 0);
1071 tcg_gen_helper64(tcg_helper_divu_i64
, sizemask
, ret
, arg1
, arg2
);
1074 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1077 /* Return value and both arguments are 64-bit and unsigned. */
1078 sizemask
|= tcg_gen_sizemask(0, 1, 0);
1079 sizemask
|= tcg_gen_sizemask(1, 1, 0);
1080 sizemask
|= tcg_gen_sizemask(2, 1, 0);
1082 tcg_gen_helper64(tcg_helper_remu_i64
, sizemask
, ret
, arg1
, arg2
);
1087 static inline void tcg_gen_mov_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1089 if (!TCGV_EQUAL_I64(ret
, arg
))
1090 tcg_gen_op2_i64(INDEX_op_mov_i64
, ret
, arg
);
1093 static inline void tcg_gen_movi_i64(TCGv_i64 ret
, int64_t arg
)
1095 tcg_gen_op2i_i64(INDEX_op_movi_i64
, ret
, arg
);
1098 static inline void tcg_gen_ld8u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1099 tcg_target_long offset
)
1101 tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64
, ret
, arg2
, offset
);
1104 static inline void tcg_gen_ld8s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1105 tcg_target_long offset
)
1107 tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64
, ret
, arg2
, offset
);
1110 static inline void tcg_gen_ld16u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1111 tcg_target_long offset
)
1113 tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64
, ret
, arg2
, offset
);
1116 static inline void tcg_gen_ld16s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1117 tcg_target_long offset
)
1119 tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64
, ret
, arg2
, offset
);
1122 static inline void tcg_gen_ld32u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1123 tcg_target_long offset
)
1125 tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64
, ret
, arg2
, offset
);
1128 static inline void tcg_gen_ld32s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1129 tcg_target_long offset
)
1131 tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64
, ret
, arg2
, offset
);
1134 static inline void tcg_gen_ld_i64(TCGv_i64 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
1136 tcg_gen_ldst_op_i64(INDEX_op_ld_i64
, ret
, arg2
, offset
);
1139 static inline void tcg_gen_st8_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
1140 tcg_target_long offset
)
1142 tcg_gen_ldst_op_i64(INDEX_op_st8_i64
, arg1
, arg2
, offset
);
1145 static inline void tcg_gen_st16_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
1146 tcg_target_long offset
)
1148 tcg_gen_ldst_op_i64(INDEX_op_st16_i64
, arg1
, arg2
, offset
);
1151 static inline void tcg_gen_st32_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
1152 tcg_target_long offset
)
1154 tcg_gen_ldst_op_i64(INDEX_op_st32_i64
, arg1
, arg2
, offset
);
1157 static inline void tcg_gen_st_i64(TCGv_i64 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
1159 tcg_gen_ldst_op_i64(INDEX_op_st_i64
, arg1
, arg2
, offset
);
1162 static inline void tcg_gen_add_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1164 tcg_gen_op3_i64(INDEX_op_add_i64
, ret
, arg1
, arg2
);
1167 static inline void tcg_gen_sub_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1169 tcg_gen_op3_i64(INDEX_op_sub_i64
, ret
, arg1
, arg2
);
1172 static inline void tcg_gen_and_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1174 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1175 tcg_gen_mov_i64(ret
, arg1
);
1177 tcg_gen_op3_i64(INDEX_op_and_i64
, ret
, arg1
, arg2
);
1181 static inline void tcg_gen_andi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, uint64_t arg2
)
1184 /* Some cases can be optimized here. */
1187 tcg_gen_movi_i64(ret
, 0);
1189 case 0xffffffffffffffffull
:
1190 tcg_gen_mov_i64(ret
, arg1
);
1193 /* Don't recurse with tcg_gen_ext8u_i32. */
1194 if (TCG_TARGET_HAS_ext8u_i64
) {
1195 tcg_gen_op2_i64(INDEX_op_ext8u_i64
, ret
, arg1
);
1200 if (TCG_TARGET_HAS_ext16u_i64
) {
1201 tcg_gen_op2_i64(INDEX_op_ext16u_i64
, ret
, arg1
);
1206 if (TCG_TARGET_HAS_ext32u_i64
) {
1207 tcg_gen_op2_i64(INDEX_op_ext32u_i64
, ret
, arg1
);
1212 t0
= tcg_const_i64(arg2
);
1213 tcg_gen_and_i64(ret
, arg1
, t0
);
1214 tcg_temp_free_i64(t0
);
1217 static inline void tcg_gen_or_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1219 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1220 tcg_gen_mov_i64(ret
, arg1
);
1222 tcg_gen_op3_i64(INDEX_op_or_i64
, ret
, arg1
, arg2
);
1226 static inline void tcg_gen_ori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1228 /* Some cases can be optimized here. */
1230 tcg_gen_movi_i64(ret
, -1);
1231 } else if (arg2
== 0) {
1232 tcg_gen_mov_i64(ret
, arg1
);
1234 TCGv_i64 t0
= tcg_const_i64(arg2
);
1235 tcg_gen_or_i64(ret
, arg1
, t0
);
1236 tcg_temp_free_i64(t0
);
1240 static inline void tcg_gen_xor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1242 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1243 tcg_gen_movi_i64(ret
, 0);
1245 tcg_gen_op3_i64(INDEX_op_xor_i64
, ret
, arg1
, arg2
);
1249 static inline void tcg_gen_xori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1251 /* Some cases can be optimized here. */
1253 tcg_gen_mov_i64(ret
, arg1
);
1254 } else if (arg2
== -1 && TCG_TARGET_HAS_not_i64
) {
1255 /* Don't recurse with tcg_gen_not_i64. */
1256 tcg_gen_op2_i64(INDEX_op_not_i64
, ret
, arg1
);
1258 TCGv_i64 t0
= tcg_const_i64(arg2
);
1259 tcg_gen_xor_i64(ret
, arg1
, t0
);
1260 tcg_temp_free_i64(t0
);
1264 static inline void tcg_gen_shl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1266 tcg_gen_op3_i64(INDEX_op_shl_i64
, ret
, arg1
, arg2
);
1269 static inline void tcg_gen_shli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1272 tcg_gen_mov_i64(ret
, arg1
);
1274 TCGv_i64 t0
= tcg_const_i64(arg2
);
1275 tcg_gen_shl_i64(ret
, arg1
, t0
);
1276 tcg_temp_free_i64(t0
);
1280 static inline void tcg_gen_shr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1282 tcg_gen_op3_i64(INDEX_op_shr_i64
, ret
, arg1
, arg2
);
1285 static inline void tcg_gen_shri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1288 tcg_gen_mov_i64(ret
, arg1
);
1290 TCGv_i64 t0
= tcg_const_i64(arg2
);
1291 tcg_gen_shr_i64(ret
, arg1
, t0
);
1292 tcg_temp_free_i64(t0
);
1296 static inline void tcg_gen_sar_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1298 tcg_gen_op3_i64(INDEX_op_sar_i64
, ret
, arg1
, arg2
);
1301 static inline void tcg_gen_sari_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1304 tcg_gen_mov_i64(ret
, arg1
);
1306 TCGv_i64 t0
= tcg_const_i64(arg2
);
1307 tcg_gen_sar_i64(ret
, arg1
, t0
);
1308 tcg_temp_free_i64(t0
);
1312 static inline void tcg_gen_brcond_i64(TCGCond cond
, TCGv_i64 arg1
,
1313 TCGv_i64 arg2
, int label_index
)
1315 if (cond
== TCG_COND_ALWAYS
) {
1316 tcg_gen_br(label_index
);
1317 } else if (cond
!= TCG_COND_NEVER
) {
1318 tcg_gen_op4ii_i64(INDEX_op_brcond_i64
, arg1
, arg2
, cond
, label_index
);
1322 static inline void tcg_gen_setcond_i64(TCGCond cond
, TCGv_i64 ret
,
1323 TCGv_i64 arg1
, TCGv_i64 arg2
)
1325 if (cond
== TCG_COND_ALWAYS
) {
1326 tcg_gen_movi_i64(ret
, 1);
1327 } else if (cond
== TCG_COND_NEVER
) {
1328 tcg_gen_movi_i64(ret
, 0);
1330 tcg_gen_op4i_i64(INDEX_op_setcond_i64
, ret
, arg1
, arg2
, cond
);
1334 static inline void tcg_gen_mul_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1336 tcg_gen_op3_i64(INDEX_op_mul_i64
, ret
, arg1
, arg2
);
1339 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1341 if (TCG_TARGET_HAS_div_i64
) {
1342 tcg_gen_op3_i64(INDEX_op_div_i64
, ret
, arg1
, arg2
);
1343 } else if (TCG_TARGET_HAS_div2_i64
) {
1344 TCGv_i64 t0
= tcg_temp_new_i64();
1345 tcg_gen_sari_i64(t0
, arg1
, 63);
1346 tcg_gen_op5_i64(INDEX_op_div2_i64
, ret
, t0
, arg1
, t0
, arg2
);
1347 tcg_temp_free_i64(t0
);
1350 /* Return value and both arguments are 64-bit and signed. */
1351 sizemask
|= tcg_gen_sizemask(0, 1, 1);
1352 sizemask
|= tcg_gen_sizemask(1, 1, 1);
1353 sizemask
|= tcg_gen_sizemask(2, 1, 1);
1354 tcg_gen_helper64(tcg_helper_div_i64
, sizemask
, ret
, arg1
, arg2
);
1358 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1360 if (TCG_TARGET_HAS_div_i64
) {
1361 tcg_gen_op3_i64(INDEX_op_rem_i64
, ret
, arg1
, arg2
);
1362 } else if (TCG_TARGET_HAS_div2_i64
) {
1363 TCGv_i64 t0
= tcg_temp_new_i64();
1364 tcg_gen_sari_i64(t0
, arg1
, 63);
1365 tcg_gen_op5_i64(INDEX_op_div2_i64
, t0
, ret
, arg1
, t0
, arg2
);
1366 tcg_temp_free_i64(t0
);
1369 /* Return value and both arguments are 64-bit and signed. */
1370 sizemask
|= tcg_gen_sizemask(0, 1, 1);
1371 sizemask
|= tcg_gen_sizemask(1, 1, 1);
1372 sizemask
|= tcg_gen_sizemask(2, 1, 1);
1373 tcg_gen_helper64(tcg_helper_rem_i64
, sizemask
, ret
, arg1
, arg2
);
1377 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1379 if (TCG_TARGET_HAS_div_i64
) {
1380 tcg_gen_op3_i64(INDEX_op_divu_i64
, ret
, arg1
, arg2
);
1381 } else if (TCG_TARGET_HAS_div2_i64
) {
1382 TCGv_i64 t0
= tcg_temp_new_i64();
1383 tcg_gen_movi_i64(t0
, 0);
1384 tcg_gen_op5_i64(INDEX_op_divu2_i64
, ret
, t0
, arg1
, t0
, arg2
);
1385 tcg_temp_free_i64(t0
);
1388 /* Return value and both arguments are 64-bit and unsigned. */
1389 sizemask
|= tcg_gen_sizemask(0, 1, 0);
1390 sizemask
|= tcg_gen_sizemask(1, 1, 0);
1391 sizemask
|= tcg_gen_sizemask(2, 1, 0);
1392 tcg_gen_helper64(tcg_helper_divu_i64
, sizemask
, ret
, arg1
, arg2
);
1396 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1398 if (TCG_TARGET_HAS_div_i64
) {
1399 tcg_gen_op3_i64(INDEX_op_remu_i64
, ret
, arg1
, arg2
);
1400 } else if (TCG_TARGET_HAS_div2_i64
) {
1401 TCGv_i64 t0
= tcg_temp_new_i64();
1402 tcg_gen_movi_i64(t0
, 0);
1403 tcg_gen_op5_i64(INDEX_op_divu2_i64
, t0
, ret
, arg1
, t0
, arg2
);
1404 tcg_temp_free_i64(t0
);
1407 /* Return value and both arguments are 64-bit and unsigned. */
1408 sizemask
|= tcg_gen_sizemask(0, 1, 0);
1409 sizemask
|= tcg_gen_sizemask(1, 1, 0);
1410 sizemask
|= tcg_gen_sizemask(2, 1, 0);
1411 tcg_gen_helper64(tcg_helper_remu_i64
, sizemask
, ret
, arg1
, arg2
);
1414 #endif /* TCG_TARGET_REG_BITS == 32 */
1416 static inline void tcg_gen_addi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1418 /* some cases can be optimized here */
1420 tcg_gen_mov_i64(ret
, arg1
);
1422 TCGv_i64 t0
= tcg_const_i64(arg2
);
1423 tcg_gen_add_i64(ret
, arg1
, t0
);
1424 tcg_temp_free_i64(t0
);
1428 static inline void tcg_gen_subfi_i64(TCGv_i64 ret
, int64_t arg1
, TCGv_i64 arg2
)
1430 TCGv_i64 t0
= tcg_const_i64(arg1
);
1431 tcg_gen_sub_i64(ret
, t0
, arg2
);
1432 tcg_temp_free_i64(t0
);
1435 static inline void tcg_gen_subi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1437 /* some cases can be optimized here */
1439 tcg_gen_mov_i64(ret
, arg1
);
1441 TCGv_i64 t0
= tcg_const_i64(arg2
);
1442 tcg_gen_sub_i64(ret
, arg1
, t0
);
1443 tcg_temp_free_i64(t0
);
1446 static inline void tcg_gen_brcondi_i64(TCGCond cond
, TCGv_i64 arg1
,
1447 int64_t arg2
, int label_index
)
1449 if (cond
== TCG_COND_ALWAYS
) {
1450 tcg_gen_br(label_index
);
1451 } else if (cond
!= TCG_COND_NEVER
) {
1452 TCGv_i64 t0
= tcg_const_i64(arg2
);
1453 tcg_gen_brcond_i64(cond
, arg1
, t0
, label_index
);
1454 tcg_temp_free_i64(t0
);
1458 static inline void tcg_gen_setcondi_i64(TCGCond cond
, TCGv_i64 ret
,
1459 TCGv_i64 arg1
, int64_t arg2
)
1461 TCGv_i64 t0
= tcg_const_i64(arg2
);
1462 tcg_gen_setcond_i64(cond
, ret
, arg1
, t0
);
1463 tcg_temp_free_i64(t0
);
1466 static inline void tcg_gen_muli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1468 TCGv_i64 t0
= tcg_const_i64(arg2
);
1469 tcg_gen_mul_i64(ret
, arg1
, t0
);
1470 tcg_temp_free_i64(t0
);
1474 /***************************************/
1475 /* optional operations */
1477 static inline void tcg_gen_ext8s_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1479 if (TCG_TARGET_HAS_ext8s_i32
) {
1480 tcg_gen_op2_i32(INDEX_op_ext8s_i32
, ret
, arg
);
1482 tcg_gen_shli_i32(ret
, arg
, 24);
1483 tcg_gen_sari_i32(ret
, ret
, 24);
1487 static inline void tcg_gen_ext16s_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1489 if (TCG_TARGET_HAS_ext16s_i32
) {
1490 tcg_gen_op2_i32(INDEX_op_ext16s_i32
, ret
, arg
);
1492 tcg_gen_shli_i32(ret
, arg
, 16);
1493 tcg_gen_sari_i32(ret
, ret
, 16);
1497 static inline void tcg_gen_ext8u_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1499 if (TCG_TARGET_HAS_ext8u_i32
) {
1500 tcg_gen_op2_i32(INDEX_op_ext8u_i32
, ret
, arg
);
1502 tcg_gen_andi_i32(ret
, arg
, 0xffu
);
1506 static inline void tcg_gen_ext16u_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1508 if (TCG_TARGET_HAS_ext16u_i32
) {
1509 tcg_gen_op2_i32(INDEX_op_ext16u_i32
, ret
, arg
);
1511 tcg_gen_andi_i32(ret
, arg
, 0xffffu
);
1515 /* Note: we assume the two high bytes are set to zero */
1516 static inline void tcg_gen_bswap16_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1518 if (TCG_TARGET_HAS_bswap16_i32
) {
1519 tcg_gen_op2_i32(INDEX_op_bswap16_i32
, ret
, arg
);
1521 TCGv_i32 t0
= tcg_temp_new_i32();
1523 tcg_gen_ext8u_i32(t0
, arg
);
1524 tcg_gen_shli_i32(t0
, t0
, 8);
1525 tcg_gen_shri_i32(ret
, arg
, 8);
1526 tcg_gen_or_i32(ret
, ret
, t0
);
1527 tcg_temp_free_i32(t0
);
1531 static inline void tcg_gen_bswap32_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1533 if (TCG_TARGET_HAS_bswap32_i32
) {
1534 tcg_gen_op2_i32(INDEX_op_bswap32_i32
, ret
, arg
);
1537 t0
= tcg_temp_new_i32();
1538 t1
= tcg_temp_new_i32();
1540 tcg_gen_shli_i32(t0
, arg
, 24);
1542 tcg_gen_andi_i32(t1
, arg
, 0x0000ff00);
1543 tcg_gen_shli_i32(t1
, t1
, 8);
1544 tcg_gen_or_i32(t0
, t0
, t1
);
1546 tcg_gen_shri_i32(t1
, arg
, 8);
1547 tcg_gen_andi_i32(t1
, t1
, 0x0000ff00);
1548 tcg_gen_or_i32(t0
, t0
, t1
);
1550 tcg_gen_shri_i32(t1
, arg
, 24);
1551 tcg_gen_or_i32(ret
, t0
, t1
);
1552 tcg_temp_free_i32(t0
);
1553 tcg_temp_free_i32(t1
);
1557 #if TCG_TARGET_REG_BITS == 32
1558 static inline void tcg_gen_ext8s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1560 tcg_gen_ext8s_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1561 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1564 static inline void tcg_gen_ext16s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1566 tcg_gen_ext16s_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1567 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1570 static inline void tcg_gen_ext32s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1572 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1573 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1576 static inline void tcg_gen_ext8u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1578 tcg_gen_ext8u_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1579 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1582 static inline void tcg_gen_ext16u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1584 tcg_gen_ext16u_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1585 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1588 static inline void tcg_gen_ext32u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1590 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1591 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1594 static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret
, TCGv_i64 arg
)
1596 tcg_gen_mov_i32(ret
, TCGV_LOW(arg
));
1599 static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1601 tcg_gen_mov_i32(TCGV_LOW(ret
), arg
);
1602 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1605 static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1607 tcg_gen_mov_i32(TCGV_LOW(ret
), arg
);
1608 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1611 /* Note: we assume the six high bytes are set to zero */
1612 static inline void tcg_gen_bswap16_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1614 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1615 tcg_gen_bswap16_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1618 /* Note: we assume the four high bytes are set to zero */
1619 static inline void tcg_gen_bswap32_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1621 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1622 tcg_gen_bswap32_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1625 static inline void tcg_gen_bswap64_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1628 t0
= tcg_temp_new_i32();
1629 t1
= tcg_temp_new_i32();
1631 tcg_gen_bswap32_i32(t0
, TCGV_LOW(arg
));
1632 tcg_gen_bswap32_i32(t1
, TCGV_HIGH(arg
));
1633 tcg_gen_mov_i32(TCGV_LOW(ret
), t1
);
1634 tcg_gen_mov_i32(TCGV_HIGH(ret
), t0
);
1635 tcg_temp_free_i32(t0
);
1636 tcg_temp_free_i32(t1
);
1640 static inline void tcg_gen_ext8s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1642 if (TCG_TARGET_HAS_ext8s_i64
) {
1643 tcg_gen_op2_i64(INDEX_op_ext8s_i64
, ret
, arg
);
1645 tcg_gen_shli_i64(ret
, arg
, 56);
1646 tcg_gen_sari_i64(ret
, ret
, 56);
1650 static inline void tcg_gen_ext16s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1652 if (TCG_TARGET_HAS_ext16s_i64
) {
1653 tcg_gen_op2_i64(INDEX_op_ext16s_i64
, ret
, arg
);
1655 tcg_gen_shli_i64(ret
, arg
, 48);
1656 tcg_gen_sari_i64(ret
, ret
, 48);
1660 static inline void tcg_gen_ext32s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1662 if (TCG_TARGET_HAS_ext32s_i64
) {
1663 tcg_gen_op2_i64(INDEX_op_ext32s_i64
, ret
, arg
);
1665 tcg_gen_shli_i64(ret
, arg
, 32);
1666 tcg_gen_sari_i64(ret
, ret
, 32);
1670 static inline void tcg_gen_ext8u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1672 if (TCG_TARGET_HAS_ext8u_i64
) {
1673 tcg_gen_op2_i64(INDEX_op_ext8u_i64
, ret
, arg
);
1675 tcg_gen_andi_i64(ret
, arg
, 0xffu
);
1679 static inline void tcg_gen_ext16u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1681 if (TCG_TARGET_HAS_ext16u_i64
) {
1682 tcg_gen_op2_i64(INDEX_op_ext16u_i64
, ret
, arg
);
1684 tcg_gen_andi_i64(ret
, arg
, 0xffffu
);
1688 static inline void tcg_gen_ext32u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1690 if (TCG_TARGET_HAS_ext32u_i64
) {
1691 tcg_gen_op2_i64(INDEX_op_ext32u_i64
, ret
, arg
);
1693 tcg_gen_andi_i64(ret
, arg
, 0xffffffffu
);
1697 /* Note: we assume the target supports move between 32 and 64 bit
1698 registers. This will probably break MIPS64 targets. */
1699 static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret
, TCGv_i64 arg
)
1701 tcg_gen_mov_i32(ret
, MAKE_TCGV_I32(GET_TCGV_I64(arg
)));
1704 /* Note: we assume the target supports move between 32 and 64 bit
1706 static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1708 tcg_gen_ext32u_i64(ret
, MAKE_TCGV_I64(GET_TCGV_I32(arg
)));
1711 /* Note: we assume the target supports move between 32 and 64 bit
1713 static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1715 tcg_gen_ext32s_i64(ret
, MAKE_TCGV_I64(GET_TCGV_I32(arg
)));
1718 /* Note: we assume the six high bytes are set to zero */
1719 static inline void tcg_gen_bswap16_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1721 if (TCG_TARGET_HAS_bswap16_i64
) {
1722 tcg_gen_op2_i64(INDEX_op_bswap16_i64
, ret
, arg
);
1724 TCGv_i64 t0
= tcg_temp_new_i64();
1726 tcg_gen_ext8u_i64(t0
, arg
);
1727 tcg_gen_shli_i64(t0
, t0
, 8);
1728 tcg_gen_shri_i64(ret
, arg
, 8);
1729 tcg_gen_or_i64(ret
, ret
, t0
);
1730 tcg_temp_free_i64(t0
);
1734 /* Note: we assume the four high bytes are set to zero */
1735 static inline void tcg_gen_bswap32_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1737 if (TCG_TARGET_HAS_bswap32_i64
) {
1738 tcg_gen_op2_i64(INDEX_op_bswap32_i64
, ret
, arg
);
1741 t0
= tcg_temp_new_i64();
1742 t1
= tcg_temp_new_i64();
1744 tcg_gen_shli_i64(t0
, arg
, 24);
1745 tcg_gen_ext32u_i64(t0
, t0
);
1747 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1748 tcg_gen_shli_i64(t1
, t1
, 8);
1749 tcg_gen_or_i64(t0
, t0
, t1
);
1751 tcg_gen_shri_i64(t1
, arg
, 8);
1752 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1753 tcg_gen_or_i64(t0
, t0
, t1
);
1755 tcg_gen_shri_i64(t1
, arg
, 24);
1756 tcg_gen_or_i64(ret
, t0
, t1
);
1757 tcg_temp_free_i64(t0
);
1758 tcg_temp_free_i64(t1
);
1762 static inline void tcg_gen_bswap64_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1764 if (TCG_TARGET_HAS_bswap64_i64
) {
1765 tcg_gen_op2_i64(INDEX_op_bswap64_i64
, ret
, arg
);
1767 TCGv_i64 t0
= tcg_temp_new_i64();
1768 TCGv_i64 t1
= tcg_temp_new_i64();
1770 tcg_gen_shli_i64(t0
, arg
, 56);
1772 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1773 tcg_gen_shli_i64(t1
, t1
, 40);
1774 tcg_gen_or_i64(t0
, t0
, t1
);
1776 tcg_gen_andi_i64(t1
, arg
, 0x00ff0000);
1777 tcg_gen_shli_i64(t1
, t1
, 24);
1778 tcg_gen_or_i64(t0
, t0
, t1
);
1780 tcg_gen_andi_i64(t1
, arg
, 0xff000000);
1781 tcg_gen_shli_i64(t1
, t1
, 8);
1782 tcg_gen_or_i64(t0
, t0
, t1
);
1784 tcg_gen_shri_i64(t1
, arg
, 8);
1785 tcg_gen_andi_i64(t1
, t1
, 0xff000000);
1786 tcg_gen_or_i64(t0
, t0
, t1
);
1788 tcg_gen_shri_i64(t1
, arg
, 24);
1789 tcg_gen_andi_i64(t1
, t1
, 0x00ff0000);
1790 tcg_gen_or_i64(t0
, t0
, t1
);
1792 tcg_gen_shri_i64(t1
, arg
, 40);
1793 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1794 tcg_gen_or_i64(t0
, t0
, t1
);
1796 tcg_gen_shri_i64(t1
, arg
, 56);
1797 tcg_gen_or_i64(ret
, t0
, t1
);
1798 tcg_temp_free_i64(t0
);
1799 tcg_temp_free_i64(t1
);
1805 static inline void tcg_gen_neg_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1807 if (TCG_TARGET_HAS_neg_i32
) {
1808 tcg_gen_op2_i32(INDEX_op_neg_i32
, ret
, arg
);
1810 TCGv_i32 t0
= tcg_const_i32(0);
1811 tcg_gen_sub_i32(ret
, t0
, arg
);
1812 tcg_temp_free_i32(t0
);
1816 static inline void tcg_gen_neg_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1818 if (TCG_TARGET_HAS_neg_i64
) {
1819 tcg_gen_op2_i64(INDEX_op_neg_i64
, ret
, arg
);
1821 TCGv_i64 t0
= tcg_const_i64(0);
1822 tcg_gen_sub_i64(ret
, t0
, arg
);
1823 tcg_temp_free_i64(t0
);
1827 static inline void tcg_gen_not_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1829 if (TCG_TARGET_HAS_not_i32
) {
1830 tcg_gen_op2_i32(INDEX_op_not_i32
, ret
, arg
);
1832 tcg_gen_xori_i32(ret
, arg
, -1);
1836 static inline void tcg_gen_not_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1838 #if TCG_TARGET_REG_BITS == 64
1839 if (TCG_TARGET_HAS_not_i64
) {
1840 tcg_gen_op2_i64(INDEX_op_not_i64
, ret
, arg
);
1842 tcg_gen_xori_i64(ret
, arg
, -1);
1845 tcg_gen_not_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1846 tcg_gen_not_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1850 static inline void tcg_gen_discard_i32(TCGv_i32 arg
)
1852 tcg_gen_op1_i32(INDEX_op_discard
, arg
);
1855 static inline void tcg_gen_discard_i64(TCGv_i64 arg
)
1857 #if TCG_TARGET_REG_BITS == 32
1858 tcg_gen_discard_i32(TCGV_LOW(arg
));
1859 tcg_gen_discard_i32(TCGV_HIGH(arg
));
1861 tcg_gen_op1_i64(INDEX_op_discard
, arg
);
1865 static inline void tcg_gen_andc_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1867 if (TCG_TARGET_HAS_andc_i32
) {
1868 tcg_gen_op3_i32(INDEX_op_andc_i32
, ret
, arg1
, arg2
);
1870 TCGv_i32 t0
= tcg_temp_new_i32();
1871 tcg_gen_not_i32(t0
, arg2
);
1872 tcg_gen_and_i32(ret
, arg1
, t0
);
1873 tcg_temp_free_i32(t0
);
1877 static inline void tcg_gen_andc_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1879 #if TCG_TARGET_REG_BITS == 64
1880 if (TCG_TARGET_HAS_andc_i64
) {
1881 tcg_gen_op3_i64(INDEX_op_andc_i64
, ret
, arg1
, arg2
);
1883 TCGv_i64 t0
= tcg_temp_new_i64();
1884 tcg_gen_not_i64(t0
, arg2
);
1885 tcg_gen_and_i64(ret
, arg1
, t0
);
1886 tcg_temp_free_i64(t0
);
1889 tcg_gen_andc_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1890 tcg_gen_andc_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1894 static inline void tcg_gen_eqv_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1896 if (TCG_TARGET_HAS_eqv_i32
) {
1897 tcg_gen_op3_i32(INDEX_op_eqv_i32
, ret
, arg1
, arg2
);
1899 tcg_gen_xor_i32(ret
, arg1
, arg2
);
1900 tcg_gen_not_i32(ret
, ret
);
1904 static inline void tcg_gen_eqv_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1906 #if TCG_TARGET_REG_BITS == 64
1907 if (TCG_TARGET_HAS_eqv_i64
) {
1908 tcg_gen_op3_i64(INDEX_op_eqv_i64
, ret
, arg1
, arg2
);
1910 tcg_gen_xor_i64(ret
, arg1
, arg2
);
1911 tcg_gen_not_i64(ret
, ret
);
1914 tcg_gen_eqv_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1915 tcg_gen_eqv_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1919 static inline void tcg_gen_nand_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1921 if (TCG_TARGET_HAS_nand_i32
) {
1922 tcg_gen_op3_i32(INDEX_op_nand_i32
, ret
, arg1
, arg2
);
1924 tcg_gen_and_i32(ret
, arg1
, arg2
);
1925 tcg_gen_not_i32(ret
, ret
);
1929 static inline void tcg_gen_nand_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1931 #if TCG_TARGET_REG_BITS == 64
1932 if (TCG_TARGET_HAS_nand_i64
) {
1933 tcg_gen_op3_i64(INDEX_op_nand_i64
, ret
, arg1
, arg2
);
1935 tcg_gen_and_i64(ret
, arg1
, arg2
);
1936 tcg_gen_not_i64(ret
, ret
);
1939 tcg_gen_nand_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1940 tcg_gen_nand_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1944 static inline void tcg_gen_nor_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1946 if (TCG_TARGET_HAS_nor_i32
) {
1947 tcg_gen_op3_i32(INDEX_op_nor_i32
, ret
, arg1
, arg2
);
1949 tcg_gen_or_i32(ret
, arg1
, arg2
);
1950 tcg_gen_not_i32(ret
, ret
);
1954 static inline void tcg_gen_nor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1956 #if TCG_TARGET_REG_BITS == 64
1957 if (TCG_TARGET_HAS_nor_i64
) {
1958 tcg_gen_op3_i64(INDEX_op_nor_i64
, ret
, arg1
, arg2
);
1960 tcg_gen_or_i64(ret
, arg1
, arg2
);
1961 tcg_gen_not_i64(ret
, ret
);
1964 tcg_gen_nor_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1965 tcg_gen_nor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1969 static inline void tcg_gen_orc_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1971 if (TCG_TARGET_HAS_orc_i32
) {
1972 tcg_gen_op3_i32(INDEX_op_orc_i32
, ret
, arg1
, arg2
);
1974 TCGv_i32 t0
= tcg_temp_new_i32();
1975 tcg_gen_not_i32(t0
, arg2
);
1976 tcg_gen_or_i32(ret
, arg1
, t0
);
1977 tcg_temp_free_i32(t0
);
1981 static inline void tcg_gen_orc_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1983 #if TCG_TARGET_REG_BITS == 64
1984 if (TCG_TARGET_HAS_orc_i64
) {
1985 tcg_gen_op3_i64(INDEX_op_orc_i64
, ret
, arg1
, arg2
);
1987 TCGv_i64 t0
= tcg_temp_new_i64();
1988 tcg_gen_not_i64(t0
, arg2
);
1989 tcg_gen_or_i64(ret
, arg1
, t0
);
1990 tcg_temp_free_i64(t0
);
1993 tcg_gen_orc_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1994 tcg_gen_orc_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1998 static inline void tcg_gen_rotl_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
2000 if (TCG_TARGET_HAS_rot_i32
) {
2001 tcg_gen_op3_i32(INDEX_op_rotl_i32
, ret
, arg1
, arg2
);
2005 t0
= tcg_temp_new_i32();
2006 t1
= tcg_temp_new_i32();
2007 tcg_gen_shl_i32(t0
, arg1
, arg2
);
2008 tcg_gen_subfi_i32(t1
, 32, arg2
);
2009 tcg_gen_shr_i32(t1
, arg1
, t1
);
2010 tcg_gen_or_i32(ret
, t0
, t1
);
2011 tcg_temp_free_i32(t0
);
2012 tcg_temp_free_i32(t1
);
2016 static inline void tcg_gen_rotl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
2018 if (TCG_TARGET_HAS_rot_i64
) {
2019 tcg_gen_op3_i64(INDEX_op_rotl_i64
, ret
, arg1
, arg2
);
2022 t0
= tcg_temp_new_i64();
2023 t1
= tcg_temp_new_i64();
2024 tcg_gen_shl_i64(t0
, arg1
, arg2
);
2025 tcg_gen_subfi_i64(t1
, 64, arg2
);
2026 tcg_gen_shr_i64(t1
, arg1
, t1
);
2027 tcg_gen_or_i64(ret
, t0
, t1
);
2028 tcg_temp_free_i64(t0
);
2029 tcg_temp_free_i64(t1
);
2033 static inline void tcg_gen_rotli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
2035 /* some cases can be optimized here */
2037 tcg_gen_mov_i32(ret
, arg1
);
2038 } else if (TCG_TARGET_HAS_rot_i32
) {
2039 TCGv_i32 t0
= tcg_const_i32(arg2
);
2040 tcg_gen_rotl_i32(ret
, arg1
, t0
);
2041 tcg_temp_free_i32(t0
);
2044 t0
= tcg_temp_new_i32();
2045 t1
= tcg_temp_new_i32();
2046 tcg_gen_shli_i32(t0
, arg1
, arg2
);
2047 tcg_gen_shri_i32(t1
, arg1
, 32 - arg2
);
2048 tcg_gen_or_i32(ret
, t0
, t1
);
2049 tcg_temp_free_i32(t0
);
2050 tcg_temp_free_i32(t1
);
2054 static inline void tcg_gen_rotli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
2056 /* some cases can be optimized here */
2058 tcg_gen_mov_i64(ret
, arg1
);
2059 } else if (TCG_TARGET_HAS_rot_i64
) {
2060 TCGv_i64 t0
= tcg_const_i64(arg2
);
2061 tcg_gen_rotl_i64(ret
, arg1
, t0
);
2062 tcg_temp_free_i64(t0
);
2065 t0
= tcg_temp_new_i64();
2066 t1
= tcg_temp_new_i64();
2067 tcg_gen_shli_i64(t0
, arg1
, arg2
);
2068 tcg_gen_shri_i64(t1
, arg1
, 64 - arg2
);
2069 tcg_gen_or_i64(ret
, t0
, t1
);
2070 tcg_temp_free_i64(t0
);
2071 tcg_temp_free_i64(t1
);
2075 static inline void tcg_gen_rotr_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
2077 if (TCG_TARGET_HAS_rot_i32
) {
2078 tcg_gen_op3_i32(INDEX_op_rotr_i32
, ret
, arg1
, arg2
);
2082 t0
= tcg_temp_new_i32();
2083 t1
= tcg_temp_new_i32();
2084 tcg_gen_shr_i32(t0
, arg1
, arg2
);
2085 tcg_gen_subfi_i32(t1
, 32, arg2
);
2086 tcg_gen_shl_i32(t1
, arg1
, t1
);
2087 tcg_gen_or_i32(ret
, t0
, t1
);
2088 tcg_temp_free_i32(t0
);
2089 tcg_temp_free_i32(t1
);
2093 static inline void tcg_gen_rotr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
2095 if (TCG_TARGET_HAS_rot_i64
) {
2096 tcg_gen_op3_i64(INDEX_op_rotr_i64
, ret
, arg1
, arg2
);
2099 t0
= tcg_temp_new_i64();
2100 t1
= tcg_temp_new_i64();
2101 tcg_gen_shr_i64(t0
, arg1
, arg2
);
2102 tcg_gen_subfi_i64(t1
, 64, arg2
);
2103 tcg_gen_shl_i64(t1
, arg1
, t1
);
2104 tcg_gen_or_i64(ret
, t0
, t1
);
2105 tcg_temp_free_i64(t0
);
2106 tcg_temp_free_i64(t1
);
2110 static inline void tcg_gen_rotri_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
2112 /* some cases can be optimized here */
2114 tcg_gen_mov_i32(ret
, arg1
);
2116 tcg_gen_rotli_i32(ret
, arg1
, 32 - arg2
);
2120 static inline void tcg_gen_rotri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
2122 /* some cases can be optimized here */
2124 tcg_gen_mov_i64(ret
, arg1
);
2126 tcg_gen_rotli_i64(ret
, arg1
, 64 - arg2
);
2130 static inline void tcg_gen_deposit_i32(TCGv_i32 ret
, TCGv_i32 arg1
,
2131 TCGv_i32 arg2
, unsigned int ofs
,
2137 tcg_debug_assert(ofs
< 32);
2138 tcg_debug_assert(len
<= 32);
2139 tcg_debug_assert(ofs
+ len
<= 32);
2141 if (ofs
== 0 && len
== 32) {
2142 tcg_gen_mov_i32(ret
, arg2
);
2145 if (TCG_TARGET_HAS_deposit_i32
&& TCG_TARGET_deposit_i32_valid(ofs
, len
)) {
2146 tcg_gen_op5ii_i32(INDEX_op_deposit_i32
, ret
, arg1
, arg2
, ofs
, len
);
2150 mask
= (1u << len
) - 1;
2151 t1
= tcg_temp_new_i32();
2153 if (ofs
+ len
< 32) {
2154 tcg_gen_andi_i32(t1
, arg2
, mask
);
2155 tcg_gen_shli_i32(t1
, t1
, ofs
);
2157 tcg_gen_shli_i32(t1
, arg2
, ofs
);
2159 tcg_gen_andi_i32(ret
, arg1
, ~(mask
<< ofs
));
2160 tcg_gen_or_i32(ret
, ret
, t1
);
2162 tcg_temp_free_i32(t1
);
2165 static inline void tcg_gen_deposit_i64(TCGv_i64 ret
, TCGv_i64 arg1
,
2166 TCGv_i64 arg2
, unsigned int ofs
,
2172 tcg_debug_assert(ofs
< 64);
2173 tcg_debug_assert(len
<= 64);
2174 tcg_debug_assert(ofs
+ len
<= 64);
2176 if (ofs
== 0 && len
== 64) {
2177 tcg_gen_mov_i64(ret
, arg2
);
2180 if (TCG_TARGET_HAS_deposit_i64
&& TCG_TARGET_deposit_i64_valid(ofs
, len
)) {
2181 tcg_gen_op5ii_i64(INDEX_op_deposit_i64
, ret
, arg1
, arg2
, ofs
, len
);
2185 #if TCG_TARGET_REG_BITS == 32
2187 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
));
2188 tcg_gen_deposit_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
),
2189 TCGV_LOW(arg2
), ofs
- 32, len
);
2192 if (ofs
+ len
<= 32) {
2193 tcg_gen_deposit_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
),
2194 TCGV_LOW(arg2
), ofs
, len
);
2195 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
));
2200 mask
= (1ull << len
) - 1;
2201 t1
= tcg_temp_new_i64();
2203 if (ofs
+ len
< 64) {
2204 tcg_gen_andi_i64(t1
, arg2
, mask
);
2205 tcg_gen_shli_i64(t1
, t1
, ofs
);
2207 tcg_gen_shli_i64(t1
, arg2
, ofs
);
2209 tcg_gen_andi_i64(ret
, arg1
, ~(mask
<< ofs
));
2210 tcg_gen_or_i64(ret
, ret
, t1
);
2212 tcg_temp_free_i64(t1
);
2215 static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest
, TCGv_i32 low
,
2218 #if TCG_TARGET_REG_BITS == 32
2219 tcg_gen_mov_i32(TCGV_LOW(dest
), low
);
2220 tcg_gen_mov_i32(TCGV_HIGH(dest
), high
);
2222 TCGv_i64 tmp
= tcg_temp_new_i64();
2223 /* These extensions are only needed for type correctness.
2224 We may be able to do better given target specific information. */
2225 tcg_gen_extu_i32_i64(tmp
, high
);
2226 tcg_gen_extu_i32_i64(dest
, low
);
2227 /* If deposit is available, use it. Otherwise use the extra
2228 knowledge that we have of the zero-extensions above. */
2229 if (TCG_TARGET_HAS_deposit_i64
&& TCG_TARGET_deposit_i64_valid(32, 32)) {
2230 tcg_gen_deposit_i64(dest
, dest
, tmp
, 32, 32);
2232 tcg_gen_shli_i64(tmp
, tmp
, 32);
2233 tcg_gen_or_i64(dest
, dest
, tmp
);
2235 tcg_temp_free_i64(tmp
);
2239 static inline void tcg_gen_concat32_i64(TCGv_i64 dest
, TCGv_i64 low
,
2242 tcg_gen_deposit_i64(dest
, low
, high
, 32, 32);
2245 static inline void tcg_gen_movcond_i32(TCGCond cond
, TCGv_i32 ret
,
2246 TCGv_i32 c1
, TCGv_i32 c2
,
2247 TCGv_i32 v1
, TCGv_i32 v2
)
2249 if (TCG_TARGET_HAS_movcond_i32
) {
2250 tcg_gen_op6i_i32(INDEX_op_movcond_i32
, ret
, c1
, c2
, v1
, v2
, cond
);
2252 TCGv_i32 t0
= tcg_temp_new_i32();
2253 TCGv_i32 t1
= tcg_temp_new_i32();
2254 tcg_gen_setcond_i32(cond
, t0
, c1
, c2
);
2255 tcg_gen_neg_i32(t0
, t0
);
2256 tcg_gen_and_i32(t1
, v1
, t0
);
2257 tcg_gen_andc_i32(ret
, v2
, t0
);
2258 tcg_gen_or_i32(ret
, ret
, t1
);
2259 tcg_temp_free_i32(t0
);
2260 tcg_temp_free_i32(t1
);
2264 static inline void tcg_gen_movcond_i64(TCGCond cond
, TCGv_i64 ret
,
2265 TCGv_i64 c1
, TCGv_i64 c2
,
2266 TCGv_i64 v1
, TCGv_i64 v2
)
2268 #if TCG_TARGET_REG_BITS == 32
2269 TCGv_i32 t0
= tcg_temp_new_i32();
2270 TCGv_i32 t1
= tcg_temp_new_i32();
2271 tcg_gen_op6i_i32(INDEX_op_setcond2_i32
, t0
,
2272 TCGV_LOW(c1
), TCGV_HIGH(c1
),
2273 TCGV_LOW(c2
), TCGV_HIGH(c2
), cond
);
2275 if (TCG_TARGET_HAS_movcond_i32
) {
2276 tcg_gen_movi_i32(t1
, 0);
2277 tcg_gen_movcond_i32(TCG_COND_NE
, TCGV_LOW(ret
), t0
, t1
,
2278 TCGV_LOW(v1
), TCGV_LOW(v2
));
2279 tcg_gen_movcond_i32(TCG_COND_NE
, TCGV_HIGH(ret
), t0
, t1
,
2280 TCGV_HIGH(v1
), TCGV_HIGH(v2
));
2282 tcg_gen_neg_i32(t0
, t0
);
2284 tcg_gen_and_i32(t1
, TCGV_LOW(v1
), t0
);
2285 tcg_gen_andc_i32(TCGV_LOW(ret
), TCGV_LOW(v2
), t0
);
2286 tcg_gen_or_i32(TCGV_LOW(ret
), TCGV_LOW(ret
), t1
);
2288 tcg_gen_and_i32(t1
, TCGV_HIGH(v1
), t0
);
2289 tcg_gen_andc_i32(TCGV_HIGH(ret
), TCGV_HIGH(v2
), t0
);
2290 tcg_gen_or_i32(TCGV_HIGH(ret
), TCGV_HIGH(ret
), t1
);
2292 tcg_temp_free_i32(t0
);
2293 tcg_temp_free_i32(t1
);
2295 if (TCG_TARGET_HAS_movcond_i64
) {
2296 tcg_gen_op6i_i64(INDEX_op_movcond_i64
, ret
, c1
, c2
, v1
, v2
, cond
);
2298 TCGv_i64 t0
= tcg_temp_new_i64();
2299 TCGv_i64 t1
= tcg_temp_new_i64();
2300 tcg_gen_setcond_i64(cond
, t0
, c1
, c2
);
2301 tcg_gen_neg_i64(t0
, t0
);
2302 tcg_gen_and_i64(t1
, v1
, t0
);
2303 tcg_gen_andc_i64(ret
, v2
, t0
);
2304 tcg_gen_or_i64(ret
, ret
, t1
);
2305 tcg_temp_free_i64(t0
);
2306 tcg_temp_free_i64(t1
);
2311 /***************************************/
2312 /* QEMU specific operations. Their type depend on the QEMU CPU
2314 #ifndef TARGET_LONG_BITS
2315 #error must include QEMU headers
2318 #if TARGET_LONG_BITS == 32
2319 #define TCGv TCGv_i32
2320 #define tcg_temp_new() tcg_temp_new_i32()
2321 #define tcg_global_reg_new tcg_global_reg_new_i32
2322 #define tcg_global_mem_new tcg_global_mem_new_i32
2323 #define tcg_temp_local_new() tcg_temp_local_new_i32()
2324 #define tcg_temp_free tcg_temp_free_i32
2325 #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32
2326 #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32
2327 #define TCGV_UNUSED(x) TCGV_UNUSED_I32(x)
2328 #define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b)
2330 #define TCGv TCGv_i64
2331 #define tcg_temp_new() tcg_temp_new_i64()
2332 #define tcg_global_reg_new tcg_global_reg_new_i64
2333 #define tcg_global_mem_new tcg_global_mem_new_i64
2334 #define tcg_temp_local_new() tcg_temp_local_new_i64()
2335 #define tcg_temp_free tcg_temp_free_i64
2336 #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64
2337 #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64
2338 #define TCGV_UNUSED(x) TCGV_UNUSED_I64(x)
2339 #define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b)
2342 /* debug info: write the PC of the corresponding QEMU CPU instruction */
2343 static inline void tcg_gen_debug_insn_start(uint64_t pc
)
2345 /* XXX: must really use a 32 bit size for TCGArg in all cases */
2346 #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
2347 tcg_gen_op2ii(INDEX_op_debug_insn_start
,
2348 (uint32_t)(pc
), (uint32_t)(pc
>> 32));
2350 tcg_gen_op1i(INDEX_op_debug_insn_start
, pc
);
2354 static inline void tcg_gen_exit_tb(tcg_target_long val
)
2356 tcg_gen_op1i(INDEX_op_exit_tb
, val
);
2359 static inline void tcg_gen_goto_tb(unsigned idx
)
2361 /* We only support two chained exits. */
2362 tcg_debug_assert(idx
<= 1);
2363 #ifdef CONFIG_DEBUG_TCG
2364 /* Verify that we havn't seen this numbered exit before. */
2365 tcg_debug_assert((tcg_ctx
.goto_tb_issue_mask
& (1 << idx
)) == 0);
2366 tcg_ctx
.goto_tb_issue_mask
|= 1 << idx
;
2368 tcg_gen_op1i(INDEX_op_goto_tb
, idx
);
2371 #if TCG_TARGET_REG_BITS == 32
2372 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
2374 #if TARGET_LONG_BITS == 32
2375 tcg_gen_op3i_i32(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
2377 tcg_gen_op4i_i32(INDEX_op_qemu_ld8u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2378 TCGV_HIGH(addr
), mem_index
);
2379 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
2383 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
2385 #if TARGET_LONG_BITS == 32
2386 tcg_gen_op3i_i32(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
2388 tcg_gen_op4i_i32(INDEX_op_qemu_ld8s
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2389 TCGV_HIGH(addr
), mem_index
);
2390 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2394 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
2396 #if TARGET_LONG_BITS == 32
2397 tcg_gen_op3i_i32(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
2399 tcg_gen_op4i_i32(INDEX_op_qemu_ld16u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2400 TCGV_HIGH(addr
), mem_index
);
2401 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
2405 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
2407 #if TARGET_LONG_BITS == 32
2408 tcg_gen_op3i_i32(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
2410 tcg_gen_op4i_i32(INDEX_op_qemu_ld16s
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2411 TCGV_HIGH(addr
), mem_index
);
2412 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2416 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
2418 #if TARGET_LONG_BITS == 32
2419 tcg_gen_op3i_i32(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2421 tcg_gen_op4i_i32(INDEX_op_qemu_ld32
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2422 TCGV_HIGH(addr
), mem_index
);
2423 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
2427 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
2429 #if TARGET_LONG_BITS == 32
2430 tcg_gen_op3i_i32(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2432 tcg_gen_op4i_i32(INDEX_op_qemu_ld32
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2433 TCGV_HIGH(addr
), mem_index
);
2434 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2438 static inline void tcg_gen_qemu_ld64(TCGv_i64 ret
, TCGv addr
, int mem_index
)
2440 #if TARGET_LONG_BITS == 32
2441 tcg_gen_op4i_i32(INDEX_op_qemu_ld64
, TCGV_LOW(ret
), TCGV_HIGH(ret
), addr
, mem_index
);
2443 tcg_gen_op5i_i32(INDEX_op_qemu_ld64
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
2444 TCGV_LOW(addr
), TCGV_HIGH(addr
), mem_index
);
2448 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
2450 #if TARGET_LONG_BITS == 32
2451 tcg_gen_op3i_i32(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
2453 tcg_gen_op4i_i32(INDEX_op_qemu_st8
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2454 TCGV_HIGH(addr
), mem_index
);
2458 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
2460 #if TARGET_LONG_BITS == 32
2461 tcg_gen_op3i_i32(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
2463 tcg_gen_op4i_i32(INDEX_op_qemu_st16
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2464 TCGV_HIGH(addr
), mem_index
);
2468 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
2470 #if TARGET_LONG_BITS == 32
2471 tcg_gen_op3i_i32(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
2473 tcg_gen_op4i_i32(INDEX_op_qemu_st32
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2474 TCGV_HIGH(addr
), mem_index
);
2478 static inline void tcg_gen_qemu_st64(TCGv_i64 arg
, TCGv addr
, int mem_index
)
2480 #if TARGET_LONG_BITS == 32
2481 tcg_gen_op4i_i32(INDEX_op_qemu_st64
, TCGV_LOW(arg
), TCGV_HIGH(arg
), addr
,
2484 tcg_gen_op5i_i32(INDEX_op_qemu_st64
, TCGV_LOW(arg
), TCGV_HIGH(arg
),
2485 TCGV_LOW(addr
), TCGV_HIGH(addr
), mem_index
);
2489 #define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i32(TCGV_PTR_TO_NAT(R), (A), (O))
2490 #define tcg_gen_discard_ptr(A) tcg_gen_discard_i32(TCGV_PTR_TO_NAT(A))
2492 #else /* TCG_TARGET_REG_BITS == 32 */
2494 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
2496 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
2499 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
2501 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
2504 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
2506 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
2509 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
2511 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
2514 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
2516 #if TARGET_LONG_BITS == 32
2517 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2519 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
2523 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
2525 #if TARGET_LONG_BITS == 32
2526 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2528 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s
, ret
, addr
, mem_index
);
2532 static inline void tcg_gen_qemu_ld64(TCGv_i64 ret
, TCGv addr
, int mem_index
)
2534 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64
, ret
, addr
, mem_index
);
2537 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
2539 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
2542 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
2544 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
2547 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
2549 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
2552 static inline void tcg_gen_qemu_st64(TCGv_i64 arg
, TCGv addr
, int mem_index
)
2554 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64
, arg
, addr
, mem_index
);
2557 #define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i64(TCGV_PTR_TO_NAT(R), (A), (O))
2558 #define tcg_gen_discard_ptr(A) tcg_gen_discard_i64(TCGV_PTR_TO_NAT(A))
2560 #endif /* TCG_TARGET_REG_BITS != 32 */
2562 #if TARGET_LONG_BITS == 64
2563 #define tcg_gen_movi_tl tcg_gen_movi_i64
2564 #define tcg_gen_mov_tl tcg_gen_mov_i64
2565 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
2566 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
2567 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
2568 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
2569 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
2570 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
2571 #define tcg_gen_ld_tl tcg_gen_ld_i64
2572 #define tcg_gen_st8_tl tcg_gen_st8_i64
2573 #define tcg_gen_st16_tl tcg_gen_st16_i64
2574 #define tcg_gen_st32_tl tcg_gen_st32_i64
2575 #define tcg_gen_st_tl tcg_gen_st_i64
2576 #define tcg_gen_add_tl tcg_gen_add_i64
2577 #define tcg_gen_addi_tl tcg_gen_addi_i64
2578 #define tcg_gen_sub_tl tcg_gen_sub_i64
2579 #define tcg_gen_neg_tl tcg_gen_neg_i64
2580 #define tcg_gen_subfi_tl tcg_gen_subfi_i64
2581 #define tcg_gen_subi_tl tcg_gen_subi_i64
2582 #define tcg_gen_and_tl tcg_gen_and_i64
2583 #define tcg_gen_andi_tl tcg_gen_andi_i64
2584 #define tcg_gen_or_tl tcg_gen_or_i64
2585 #define tcg_gen_ori_tl tcg_gen_ori_i64
2586 #define tcg_gen_xor_tl tcg_gen_xor_i64
2587 #define tcg_gen_xori_tl tcg_gen_xori_i64
2588 #define tcg_gen_not_tl tcg_gen_not_i64
2589 #define tcg_gen_shl_tl tcg_gen_shl_i64
2590 #define tcg_gen_shli_tl tcg_gen_shli_i64
2591 #define tcg_gen_shr_tl tcg_gen_shr_i64
2592 #define tcg_gen_shri_tl tcg_gen_shri_i64
2593 #define tcg_gen_sar_tl tcg_gen_sar_i64
2594 #define tcg_gen_sari_tl tcg_gen_sari_i64
2595 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
2596 #define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
2597 #define tcg_gen_setcond_tl tcg_gen_setcond_i64
2598 #define tcg_gen_setcondi_tl tcg_gen_setcondi_i64
2599 #define tcg_gen_mul_tl tcg_gen_mul_i64
2600 #define tcg_gen_muli_tl tcg_gen_muli_i64
2601 #define tcg_gen_div_tl tcg_gen_div_i64
2602 #define tcg_gen_rem_tl tcg_gen_rem_i64
2603 #define tcg_gen_divu_tl tcg_gen_divu_i64
2604 #define tcg_gen_remu_tl tcg_gen_remu_i64
2605 #define tcg_gen_discard_tl tcg_gen_discard_i64
2606 #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
2607 #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
2608 #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
2609 #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
2610 #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
2611 #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
2612 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
2613 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
2614 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
2615 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
2616 #define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
2617 #define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
2618 #define tcg_gen_bswap16_tl tcg_gen_bswap16_i64
2619 #define tcg_gen_bswap32_tl tcg_gen_bswap32_i64
2620 #define tcg_gen_bswap64_tl tcg_gen_bswap64_i64
2621 #define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
2622 #define tcg_gen_andc_tl tcg_gen_andc_i64
2623 #define tcg_gen_eqv_tl tcg_gen_eqv_i64
2624 #define tcg_gen_nand_tl tcg_gen_nand_i64
2625 #define tcg_gen_nor_tl tcg_gen_nor_i64
2626 #define tcg_gen_orc_tl tcg_gen_orc_i64
2627 #define tcg_gen_rotl_tl tcg_gen_rotl_i64
2628 #define tcg_gen_rotli_tl tcg_gen_rotli_i64
2629 #define tcg_gen_rotr_tl tcg_gen_rotr_i64
2630 #define tcg_gen_rotri_tl tcg_gen_rotri_i64
2631 #define tcg_gen_deposit_tl tcg_gen_deposit_i64
2632 #define tcg_const_tl tcg_const_i64
2633 #define tcg_const_local_tl tcg_const_local_i64
2634 #define tcg_gen_movcond_tl tcg_gen_movcond_i64
2636 #define tcg_gen_movi_tl tcg_gen_movi_i32
2637 #define tcg_gen_mov_tl tcg_gen_mov_i32
2638 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
2639 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
2640 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
2641 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
2642 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
2643 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
2644 #define tcg_gen_ld_tl tcg_gen_ld_i32
2645 #define tcg_gen_st8_tl tcg_gen_st8_i32
2646 #define tcg_gen_st16_tl tcg_gen_st16_i32
2647 #define tcg_gen_st32_tl tcg_gen_st_i32
2648 #define tcg_gen_st_tl tcg_gen_st_i32
2649 #define tcg_gen_add_tl tcg_gen_add_i32
2650 #define tcg_gen_addi_tl tcg_gen_addi_i32
2651 #define tcg_gen_sub_tl tcg_gen_sub_i32
2652 #define tcg_gen_neg_tl tcg_gen_neg_i32
2653 #define tcg_gen_subfi_tl tcg_gen_subfi_i32
2654 #define tcg_gen_subi_tl tcg_gen_subi_i32
2655 #define tcg_gen_and_tl tcg_gen_and_i32
2656 #define tcg_gen_andi_tl tcg_gen_andi_i32
2657 #define tcg_gen_or_tl tcg_gen_or_i32
2658 #define tcg_gen_ori_tl tcg_gen_ori_i32
2659 #define tcg_gen_xor_tl tcg_gen_xor_i32
2660 #define tcg_gen_xori_tl tcg_gen_xori_i32
2661 #define tcg_gen_not_tl tcg_gen_not_i32
2662 #define tcg_gen_shl_tl tcg_gen_shl_i32
2663 #define tcg_gen_shli_tl tcg_gen_shli_i32
2664 #define tcg_gen_shr_tl tcg_gen_shr_i32
2665 #define tcg_gen_shri_tl tcg_gen_shri_i32
2666 #define tcg_gen_sar_tl tcg_gen_sar_i32
2667 #define tcg_gen_sari_tl tcg_gen_sari_i32
2668 #define tcg_gen_brcond_tl tcg_gen_brcond_i32
2669 #define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
2670 #define tcg_gen_setcond_tl tcg_gen_setcond_i32
2671 #define tcg_gen_setcondi_tl tcg_gen_setcondi_i32
2672 #define tcg_gen_mul_tl tcg_gen_mul_i32
2673 #define tcg_gen_muli_tl tcg_gen_muli_i32
2674 #define tcg_gen_div_tl tcg_gen_div_i32
2675 #define tcg_gen_rem_tl tcg_gen_rem_i32
2676 #define tcg_gen_divu_tl tcg_gen_divu_i32
2677 #define tcg_gen_remu_tl tcg_gen_remu_i32
2678 #define tcg_gen_discard_tl tcg_gen_discard_i32
2679 #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
2680 #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
2681 #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
2682 #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
2683 #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
2684 #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
2685 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
2686 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
2687 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
2688 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
2689 #define tcg_gen_ext32u_tl tcg_gen_mov_i32
2690 #define tcg_gen_ext32s_tl tcg_gen_mov_i32
2691 #define tcg_gen_bswap16_tl tcg_gen_bswap16_i32
2692 #define tcg_gen_bswap32_tl tcg_gen_bswap32_i32
2693 #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
2694 #define tcg_gen_andc_tl tcg_gen_andc_i32
2695 #define tcg_gen_eqv_tl tcg_gen_eqv_i32
2696 #define tcg_gen_nand_tl tcg_gen_nand_i32
2697 #define tcg_gen_nor_tl tcg_gen_nor_i32
2698 #define tcg_gen_orc_tl tcg_gen_orc_i32
2699 #define tcg_gen_rotl_tl tcg_gen_rotl_i32
2700 #define tcg_gen_rotli_tl tcg_gen_rotli_i32
2701 #define tcg_gen_rotr_tl tcg_gen_rotr_i32
2702 #define tcg_gen_rotri_tl tcg_gen_rotri_i32
2703 #define tcg_gen_deposit_tl tcg_gen_deposit_i32
2704 #define tcg_const_tl tcg_const_i32
2705 #define tcg_const_local_tl tcg_const_local_i32
2706 #define tcg_gen_movcond_tl tcg_gen_movcond_i32
2709 #if TCG_TARGET_REG_BITS == 32
2710 #define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i32(TCGV_PTR_TO_NAT(R), \
2711 TCGV_PTR_TO_NAT(A), \
2713 #define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i32(TCGV_PTR_TO_NAT(R), \
2714 TCGV_PTR_TO_NAT(A), (B))
2715 #define tcg_gen_ext_i32_ptr(R, A) tcg_gen_mov_i32(TCGV_PTR_TO_NAT(R), (A))
2716 #else /* TCG_TARGET_REG_BITS == 32 */
2717 #define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i64(TCGV_PTR_TO_NAT(R), \
2718 TCGV_PTR_TO_NAT(A), \
2720 #define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i64(TCGV_PTR_TO_NAT(R), \
2721 TCGV_PTR_TO_NAT(A), (B))
2722 #define tcg_gen_ext_i32_ptr(R, A) tcg_gen_ext_i32_i64(TCGV_PTR_TO_NAT(R), (A))
2723 #endif /* TCG_TARGET_REG_BITS != 32 */