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(TCGOpcode opc
, TCGv_i32 arg1
)
31 *gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
34 static inline void tcg_gen_op1_i64(TCGOpcode opc
, TCGv_i64 arg1
)
37 *gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
40 static inline void tcg_gen_op1i(TCGOpcode opc
, TCGArg arg1
)
43 *gen_opparam_ptr
++ = arg1
;
46 static inline void tcg_gen_op2_i32(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode opc
, TCGArg arg1
, TCGArg arg2
)
77 *gen_opparam_ptr
++ = arg1
;
78 *gen_opparam_ptr
++ = arg2
;
81 static inline void tcg_gen_op3_i32(TCGOpcode 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(TCGOpcode 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(TCGOpcode opc
, TCGv_i32 arg1
,
100 TCGv_i32 arg2
, TCGArg arg3
)
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(TCGOpcode opc
, TCGv_i64 arg1
,
109 TCGv_i64 arg2
, TCGArg arg3
)
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(TCGOpcode opc
, TCGv_i32 val
,
118 TCGv_ptr base
, TCGArg offset
)
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(TCGOpcode opc
, TCGv_i64 val
,
127 TCGv_ptr base
, TCGArg offset
)
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(TCGOpcode opc
, TCGv_i64 val
,
136 TCGv_i32 addr
, TCGArg mem_index
)
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(TCGOpcode opc
, TCGv_i64 val
,
145 TCGv_i64 addr
, TCGArg mem_index
)
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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode 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(TCGOpcode opc
, TCGv_i32 arg1
,
310 TCGv_i32 arg2
, TCGv_i32 arg3
,
311 TCGv_i32 arg4
, TCGArg arg5
, TCGArg arg6
)
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(TCGOpcode opc
, TCGv_i64 arg1
,
323 TCGv_i64 arg2
, TCGv_i64 arg3
,
324 TCGv_i64 arg4
, TCGArg arg5
, TCGArg arg6
)
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 /* Note: Both tcg_gen_helper32() and tcg_gen_helper64() are currently
368 reserved for helpers in tcg-runtime.c. These helpers are all const
369 and pure, hence the call to tcg_gen_callN() with TCG_CALL_CONST |
370 TCG_CALL_PURE. This may need to be adjusted if these functions
371 start to be used with other helpers. */
372 static inline void tcg_gen_helper32(void *func
, TCGv_i32 ret
,
373 TCGv_i32 a
, TCGv_i32 b
)
377 fn
= tcg_const_ptr((tcg_target_long
)func
);
378 args
[0] = GET_TCGV_I32(a
);
379 args
[1] = GET_TCGV_I32(b
);
380 tcg_gen_callN(&tcg_ctx
, fn
, TCG_CALL_CONST
| TCG_CALL_PURE
,
381 0, GET_TCGV_I32(ret
), 2, args
);
382 tcg_temp_free_ptr(fn
);
385 static inline void tcg_gen_helper64(void *func
, TCGv_i64 ret
,
386 TCGv_i64 a
, TCGv_i64 b
)
390 fn
= tcg_const_ptr((tcg_target_long
)func
);
391 args
[0] = GET_TCGV_I64(a
);
392 args
[1] = GET_TCGV_I64(b
);
393 tcg_gen_callN(&tcg_ctx
, fn
, TCG_CALL_CONST
| TCG_CALL_PURE
,
394 7, GET_TCGV_I64(ret
), 2, args
);
395 tcg_temp_free_ptr(fn
);
400 static inline void tcg_gen_ld8u_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
402 tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32
, ret
, arg2
, offset
);
405 static inline void tcg_gen_ld8s_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
407 tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32
, ret
, arg2
, offset
);
410 static inline void tcg_gen_ld16u_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
412 tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32
, ret
, arg2
, offset
);
415 static inline void tcg_gen_ld16s_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
417 tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32
, ret
, arg2
, offset
);
420 static inline void tcg_gen_ld_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
422 tcg_gen_ldst_op_i32(INDEX_op_ld_i32
, ret
, arg2
, offset
);
425 static inline void tcg_gen_st8_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
427 tcg_gen_ldst_op_i32(INDEX_op_st8_i32
, arg1
, arg2
, offset
);
430 static inline void tcg_gen_st16_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
432 tcg_gen_ldst_op_i32(INDEX_op_st16_i32
, arg1
, arg2
, offset
);
435 static inline void tcg_gen_st_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
437 tcg_gen_ldst_op_i32(INDEX_op_st_i32
, arg1
, arg2
, offset
);
440 static inline void tcg_gen_add_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
442 tcg_gen_op3_i32(INDEX_op_add_i32
, ret
, arg1
, arg2
);
445 static inline void tcg_gen_addi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
447 /* some cases can be optimized here */
449 tcg_gen_mov_i32(ret
, arg1
);
451 TCGv_i32 t0
= tcg_const_i32(arg2
);
452 tcg_gen_add_i32(ret
, arg1
, t0
);
453 tcg_temp_free_i32(t0
);
457 static inline void tcg_gen_sub_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
459 tcg_gen_op3_i32(INDEX_op_sub_i32
, ret
, arg1
, arg2
);
462 static inline void tcg_gen_subfi_i32(TCGv_i32 ret
, int32_t arg1
, TCGv_i32 arg2
)
464 TCGv_i32 t0
= tcg_const_i32(arg1
);
465 tcg_gen_sub_i32(ret
, t0
, arg2
);
466 tcg_temp_free_i32(t0
);
469 static inline void tcg_gen_subi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
471 /* some cases can be optimized here */
473 tcg_gen_mov_i32(ret
, arg1
);
475 TCGv_i32 t0
= tcg_const_i32(arg2
);
476 tcg_gen_sub_i32(ret
, arg1
, t0
);
477 tcg_temp_free_i32(t0
);
481 static inline void tcg_gen_and_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
483 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
484 tcg_gen_mov_i32(ret
, arg1
);
486 tcg_gen_op3_i32(INDEX_op_and_i32
, ret
, arg1
, arg2
);
490 static inline void tcg_gen_andi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
492 /* some cases can be optimized here */
494 tcg_gen_movi_i32(ret
, 0);
495 } else if (arg2
== 0xffffffff) {
496 tcg_gen_mov_i32(ret
, arg1
);
498 TCGv_i32 t0
= tcg_const_i32(arg2
);
499 tcg_gen_and_i32(ret
, arg1
, t0
);
500 tcg_temp_free_i32(t0
);
504 static inline void tcg_gen_or_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
506 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
507 tcg_gen_mov_i32(ret
, arg1
);
509 tcg_gen_op3_i32(INDEX_op_or_i32
, ret
, arg1
, arg2
);
513 static inline void tcg_gen_ori_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
515 /* some cases can be optimized here */
516 if (arg2
== 0xffffffff) {
517 tcg_gen_movi_i32(ret
, 0xffffffff);
518 } else if (arg2
== 0) {
519 tcg_gen_mov_i32(ret
, arg1
);
521 TCGv_i32 t0
= tcg_const_i32(arg2
);
522 tcg_gen_or_i32(ret
, arg1
, t0
);
523 tcg_temp_free_i32(t0
);
527 static inline void tcg_gen_xor_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
529 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
530 tcg_gen_movi_i32(ret
, 0);
532 tcg_gen_op3_i32(INDEX_op_xor_i32
, ret
, arg1
, arg2
);
536 static inline void tcg_gen_xori_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
538 /* some cases can be optimized here */
540 tcg_gen_mov_i32(ret
, arg1
);
542 TCGv_i32 t0
= tcg_const_i32(arg2
);
543 tcg_gen_xor_i32(ret
, arg1
, t0
);
544 tcg_temp_free_i32(t0
);
548 static inline void tcg_gen_shl_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
550 tcg_gen_op3_i32(INDEX_op_shl_i32
, ret
, arg1
, arg2
);
553 static inline void tcg_gen_shli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
556 tcg_gen_mov_i32(ret
, arg1
);
558 TCGv_i32 t0
= tcg_const_i32(arg2
);
559 tcg_gen_shl_i32(ret
, arg1
, t0
);
560 tcg_temp_free_i32(t0
);
564 static inline void tcg_gen_shr_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
566 tcg_gen_op3_i32(INDEX_op_shr_i32
, ret
, arg1
, arg2
);
569 static inline void tcg_gen_shri_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
572 tcg_gen_mov_i32(ret
, arg1
);
574 TCGv_i32 t0
= tcg_const_i32(arg2
);
575 tcg_gen_shr_i32(ret
, arg1
, t0
);
576 tcg_temp_free_i32(t0
);
580 static inline void tcg_gen_sar_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
582 tcg_gen_op3_i32(INDEX_op_sar_i32
, ret
, arg1
, arg2
);
585 static inline void tcg_gen_sari_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
588 tcg_gen_mov_i32(ret
, arg1
);
590 TCGv_i32 t0
= tcg_const_i32(arg2
);
591 tcg_gen_sar_i32(ret
, arg1
, t0
);
592 tcg_temp_free_i32(t0
);
596 static inline void tcg_gen_brcond_i32(TCGCond cond
, TCGv_i32 arg1
,
597 TCGv_i32 arg2
, int label_index
)
599 tcg_gen_op4ii_i32(INDEX_op_brcond_i32
, arg1
, arg2
, cond
, label_index
);
602 static inline void tcg_gen_brcondi_i32(TCGCond cond
, TCGv_i32 arg1
,
603 int32_t arg2
, int label_index
)
605 TCGv_i32 t0
= tcg_const_i32(arg2
);
606 tcg_gen_brcond_i32(cond
, arg1
, t0
, label_index
);
607 tcg_temp_free_i32(t0
);
610 static inline void tcg_gen_setcond_i32(TCGCond cond
, TCGv_i32 ret
,
611 TCGv_i32 arg1
, TCGv_i32 arg2
)
613 tcg_gen_op4i_i32(INDEX_op_setcond_i32
, ret
, arg1
, arg2
, cond
);
616 static inline void tcg_gen_setcondi_i32(TCGCond cond
, TCGv_i32 ret
,
617 TCGv_i32 arg1
, int32_t arg2
)
619 TCGv_i32 t0
= tcg_const_i32(arg2
);
620 tcg_gen_setcond_i32(cond
, ret
, arg1
, t0
);
621 tcg_temp_free_i32(t0
);
624 static inline void tcg_gen_mul_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
626 tcg_gen_op3_i32(INDEX_op_mul_i32
, ret
, arg1
, arg2
);
629 static inline void tcg_gen_muli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
631 TCGv_i32 t0
= tcg_const_i32(arg2
);
632 tcg_gen_mul_i32(ret
, arg1
, t0
);
633 tcg_temp_free_i32(t0
);
636 #ifdef TCG_TARGET_HAS_div_i32
637 static inline void tcg_gen_div_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
639 tcg_gen_op3_i32(INDEX_op_div_i32
, ret
, arg1
, arg2
);
642 static inline void tcg_gen_rem_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
644 tcg_gen_op3_i32(INDEX_op_rem_i32
, ret
, arg1
, arg2
);
647 static inline void tcg_gen_divu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
649 tcg_gen_op3_i32(INDEX_op_divu_i32
, ret
, arg1
, arg2
);
652 static inline void tcg_gen_remu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
654 tcg_gen_op3_i32(INDEX_op_remu_i32
, ret
, arg1
, arg2
);
656 #elif defined(TCG_TARGET_HAS_div2_i32)
657 static inline void tcg_gen_div_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
660 t0
= tcg_temp_new_i32();
661 tcg_gen_sari_i32(t0
, arg1
, 31);
662 tcg_gen_op5_i32(INDEX_op_div2_i32
, ret
, t0
, arg1
, t0
, arg2
);
663 tcg_temp_free_i32(t0
);
666 static inline void tcg_gen_rem_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
669 t0
= tcg_temp_new_i32();
670 tcg_gen_sari_i32(t0
, arg1
, 31);
671 tcg_gen_op5_i32(INDEX_op_div2_i32
, t0
, ret
, arg1
, t0
, arg2
);
672 tcg_temp_free_i32(t0
);
675 static inline void tcg_gen_divu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
678 t0
= tcg_temp_new_i32();
679 tcg_gen_movi_i32(t0
, 0);
680 tcg_gen_op5_i32(INDEX_op_divu2_i32
, ret
, t0
, arg1
, t0
, arg2
);
681 tcg_temp_free_i32(t0
);
684 static inline void tcg_gen_remu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
687 t0
= tcg_temp_new_i32();
688 tcg_gen_movi_i32(t0
, 0);
689 tcg_gen_op5_i32(INDEX_op_divu2_i32
, t0
, ret
, arg1
, t0
, arg2
);
690 tcg_temp_free_i32(t0
);
693 static inline void tcg_gen_div_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
695 tcg_gen_helper32(tcg_helper_div_i32
, ret
, arg1
, arg2
);
698 static inline void tcg_gen_rem_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
700 tcg_gen_helper32(tcg_helper_rem_i32
, ret
, arg1
, arg2
);
703 static inline void tcg_gen_divu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
705 tcg_gen_helper32(tcg_helper_divu_i32
, ret
, arg1
, arg2
);
708 static inline void tcg_gen_remu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
710 tcg_gen_helper32(tcg_helper_remu_i32
, ret
, arg1
, arg2
);
714 #if TCG_TARGET_REG_BITS == 32
716 static inline void tcg_gen_mov_i64(TCGv_i64 ret
, TCGv_i64 arg
)
718 if (!TCGV_EQUAL_I64(ret
, arg
)) {
719 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
720 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
724 static inline void tcg_gen_movi_i64(TCGv_i64 ret
, int64_t arg
)
726 tcg_gen_movi_i32(TCGV_LOW(ret
), arg
);
727 tcg_gen_movi_i32(TCGV_HIGH(ret
), arg
>> 32);
730 static inline void tcg_gen_ld8u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
731 tcg_target_long offset
)
733 tcg_gen_ld8u_i32(TCGV_LOW(ret
), arg2
, offset
);
734 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
737 static inline void tcg_gen_ld8s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
738 tcg_target_long offset
)
740 tcg_gen_ld8s_i32(TCGV_LOW(ret
), arg2
, offset
);
741 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_HIGH(ret
), 31);
744 static inline void tcg_gen_ld16u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
745 tcg_target_long offset
)
747 tcg_gen_ld16u_i32(TCGV_LOW(ret
), arg2
, offset
);
748 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
751 static inline void tcg_gen_ld16s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
752 tcg_target_long offset
)
754 tcg_gen_ld16s_i32(TCGV_LOW(ret
), arg2
, offset
);
755 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
758 static inline void tcg_gen_ld32u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
759 tcg_target_long offset
)
761 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
762 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
765 static inline void tcg_gen_ld32s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
766 tcg_target_long offset
)
768 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
769 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
772 static inline void tcg_gen_ld_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
773 tcg_target_long offset
)
775 /* since arg2 and ret have different types, they cannot be the
777 #ifdef TCG_TARGET_WORDS_BIGENDIAN
778 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
);
779 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
+ 4);
781 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
782 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
+ 4);
786 static inline void tcg_gen_st8_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
787 tcg_target_long offset
)
789 tcg_gen_st8_i32(TCGV_LOW(arg1
), arg2
, offset
);
792 static inline void tcg_gen_st16_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
793 tcg_target_long offset
)
795 tcg_gen_st16_i32(TCGV_LOW(arg1
), arg2
, offset
);
798 static inline void tcg_gen_st32_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
799 tcg_target_long offset
)
801 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
);
804 static inline void tcg_gen_st_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
805 tcg_target_long offset
)
807 #ifdef TCG_TARGET_WORDS_BIGENDIAN
808 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
);
809 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
+ 4);
811 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
);
812 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
+ 4);
816 static inline void tcg_gen_add_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
818 tcg_gen_op6_i32(INDEX_op_add2_i32
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
819 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
823 static inline void tcg_gen_sub_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
825 tcg_gen_op6_i32(INDEX_op_sub2_i32
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
826 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
830 static inline void tcg_gen_and_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
832 tcg_gen_and_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
833 tcg_gen_and_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
836 static inline void tcg_gen_andi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
838 tcg_gen_andi_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
839 tcg_gen_andi_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
842 static inline void tcg_gen_or_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
844 tcg_gen_or_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
845 tcg_gen_or_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
848 static inline void tcg_gen_ori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
850 tcg_gen_ori_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
851 tcg_gen_ori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
854 static inline void tcg_gen_xor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
856 tcg_gen_xor_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
857 tcg_gen_xor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
860 static inline void tcg_gen_xori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
862 tcg_gen_xori_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
863 tcg_gen_xori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
866 /* XXX: use generic code when basic block handling is OK or CPU
867 specific code (x86) */
868 static inline void tcg_gen_shl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
870 tcg_gen_helper64(tcg_helper_shl_i64
, ret
, arg1
, arg2
);
873 static inline void tcg_gen_shli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
875 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 0, 0);
878 static inline void tcg_gen_shr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
880 tcg_gen_helper64(tcg_helper_shr_i64
, ret
, arg1
, arg2
);
883 static inline void tcg_gen_shri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
885 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 0);
888 static inline void tcg_gen_sar_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
890 tcg_gen_helper64(tcg_helper_sar_i64
, ret
, arg1
, arg2
);
893 static inline void tcg_gen_sari_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
895 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 1);
898 static inline void tcg_gen_brcond_i64(TCGCond cond
, TCGv_i64 arg1
,
899 TCGv_i64 arg2
, int label_index
)
901 tcg_gen_op6ii_i32(INDEX_op_brcond2_i32
,
902 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
903 TCGV_HIGH(arg2
), cond
, label_index
);
906 static inline void tcg_gen_setcond_i64(TCGCond cond
, TCGv_i64 ret
,
907 TCGv_i64 arg1
, TCGv_i64 arg2
)
909 tcg_gen_op6i_i32(INDEX_op_setcond2_i32
, TCGV_LOW(ret
),
910 TCGV_LOW(arg1
), TCGV_HIGH(arg1
),
911 TCGV_LOW(arg2
), TCGV_HIGH(arg2
), cond
);
912 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
915 static inline void tcg_gen_mul_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
920 t0
= tcg_temp_new_i64();
921 t1
= tcg_temp_new_i32();
923 tcg_gen_op4_i32(INDEX_op_mulu2_i32
, TCGV_LOW(t0
), TCGV_HIGH(t0
),
924 TCGV_LOW(arg1
), TCGV_LOW(arg2
));
926 tcg_gen_mul_i32(t1
, TCGV_LOW(arg1
), TCGV_HIGH(arg2
));
927 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
928 tcg_gen_mul_i32(t1
, TCGV_HIGH(arg1
), TCGV_LOW(arg2
));
929 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
931 tcg_gen_mov_i64(ret
, t0
);
932 tcg_temp_free_i64(t0
);
933 tcg_temp_free_i32(t1
);
936 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
938 tcg_gen_helper64(tcg_helper_div_i64
, ret
, arg1
, arg2
);
941 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
943 tcg_gen_helper64(tcg_helper_rem_i64
, ret
, arg1
, arg2
);
946 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
948 tcg_gen_helper64(tcg_helper_divu_i64
, ret
, arg1
, arg2
);
951 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
953 tcg_gen_helper64(tcg_helper_remu_i64
, ret
, arg1
, arg2
);
958 static inline void tcg_gen_mov_i64(TCGv_i64 ret
, TCGv_i64 arg
)
960 if (!TCGV_EQUAL_I64(ret
, arg
))
961 tcg_gen_op2_i64(INDEX_op_mov_i64
, ret
, arg
);
964 static inline void tcg_gen_movi_i64(TCGv_i64 ret
, int64_t arg
)
966 tcg_gen_op2i_i64(INDEX_op_movi_i64
, ret
, arg
);
969 static inline void tcg_gen_ld8u_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
970 tcg_target_long offset
)
972 tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64
, ret
, arg2
, offset
);
975 static inline void tcg_gen_ld8s_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
976 tcg_target_long offset
)
978 tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64
, ret
, arg2
, offset
);
981 static inline void tcg_gen_ld16u_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
982 tcg_target_long offset
)
984 tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64
, ret
, arg2
, offset
);
987 static inline void tcg_gen_ld16s_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
988 tcg_target_long offset
)
990 tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64
, ret
, arg2
, offset
);
993 static inline void tcg_gen_ld32u_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
994 tcg_target_long offset
)
996 tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64
, ret
, arg2
, offset
);
999 static inline void tcg_gen_ld32s_i64(TCGv_i64 ret
, TCGv_i64 arg2
,
1000 tcg_target_long offset
)
1002 tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64
, ret
, arg2
, offset
);
1005 static inline void tcg_gen_ld_i64(TCGv_i64 ret
, TCGv_i64 arg2
, tcg_target_long offset
)
1007 tcg_gen_ldst_op_i64(INDEX_op_ld_i64
, ret
, arg2
, offset
);
1010 static inline void tcg_gen_st8_i64(TCGv_i64 arg1
, TCGv_i64 arg2
,
1011 tcg_target_long offset
)
1013 tcg_gen_ldst_op_i64(INDEX_op_st8_i64
, arg1
, arg2
, offset
);
1016 static inline void tcg_gen_st16_i64(TCGv_i64 arg1
, TCGv_i64 arg2
,
1017 tcg_target_long offset
)
1019 tcg_gen_ldst_op_i64(INDEX_op_st16_i64
, arg1
, arg2
, offset
);
1022 static inline void tcg_gen_st32_i64(TCGv_i64 arg1
, TCGv_i64 arg2
,
1023 tcg_target_long offset
)
1025 tcg_gen_ldst_op_i64(INDEX_op_st32_i64
, arg1
, arg2
, offset
);
1028 static inline void tcg_gen_st_i64(TCGv_i64 arg1
, TCGv_i64 arg2
, tcg_target_long offset
)
1030 tcg_gen_ldst_op_i64(INDEX_op_st_i64
, arg1
, arg2
, offset
);
1033 static inline void tcg_gen_add_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1035 tcg_gen_op3_i64(INDEX_op_add_i64
, ret
, arg1
, arg2
);
1038 static inline void tcg_gen_sub_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1040 tcg_gen_op3_i64(INDEX_op_sub_i64
, ret
, arg1
, arg2
);
1043 static inline void tcg_gen_and_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1045 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1046 tcg_gen_mov_i64(ret
, arg1
);
1048 tcg_gen_op3_i64(INDEX_op_and_i64
, ret
, arg1
, arg2
);
1052 static inline void tcg_gen_andi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1054 TCGv_i64 t0
= tcg_const_i64(arg2
);
1055 tcg_gen_and_i64(ret
, arg1
, t0
);
1056 tcg_temp_free_i64(t0
);
1059 static inline void tcg_gen_or_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1061 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1062 tcg_gen_mov_i64(ret
, arg1
);
1064 tcg_gen_op3_i64(INDEX_op_or_i64
, ret
, arg1
, arg2
);
1068 static inline void tcg_gen_ori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1070 TCGv_i64 t0
= tcg_const_i64(arg2
);
1071 tcg_gen_or_i64(ret
, arg1
, t0
);
1072 tcg_temp_free_i64(t0
);
1075 static inline void tcg_gen_xor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1077 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1078 tcg_gen_movi_i64(ret
, 0);
1080 tcg_gen_op3_i64(INDEX_op_xor_i64
, ret
, arg1
, arg2
);
1084 static inline void tcg_gen_xori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1086 TCGv_i64 t0
= tcg_const_i64(arg2
);
1087 tcg_gen_xor_i64(ret
, arg1
, t0
);
1088 tcg_temp_free_i64(t0
);
1091 static inline void tcg_gen_shl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1093 tcg_gen_op3_i64(INDEX_op_shl_i64
, ret
, arg1
, arg2
);
1096 static inline void tcg_gen_shli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1099 tcg_gen_mov_i64(ret
, arg1
);
1101 TCGv_i64 t0
= tcg_const_i64(arg2
);
1102 tcg_gen_shl_i64(ret
, arg1
, t0
);
1103 tcg_temp_free_i64(t0
);
1107 static inline void tcg_gen_shr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1109 tcg_gen_op3_i64(INDEX_op_shr_i64
, ret
, arg1
, arg2
);
1112 static inline void tcg_gen_shri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1115 tcg_gen_mov_i64(ret
, arg1
);
1117 TCGv_i64 t0
= tcg_const_i64(arg2
);
1118 tcg_gen_shr_i64(ret
, arg1
, t0
);
1119 tcg_temp_free_i64(t0
);
1123 static inline void tcg_gen_sar_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1125 tcg_gen_op3_i64(INDEX_op_sar_i64
, ret
, arg1
, arg2
);
1128 static inline void tcg_gen_sari_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1131 tcg_gen_mov_i64(ret
, arg1
);
1133 TCGv_i64 t0
= tcg_const_i64(arg2
);
1134 tcg_gen_sar_i64(ret
, arg1
, t0
);
1135 tcg_temp_free_i64(t0
);
1139 static inline void tcg_gen_brcond_i64(TCGCond cond
, TCGv_i64 arg1
,
1140 TCGv_i64 arg2
, int label_index
)
1142 tcg_gen_op4ii_i64(INDEX_op_brcond_i64
, arg1
, arg2
, cond
, label_index
);
1145 static inline void tcg_gen_setcond_i64(TCGCond cond
, TCGv_i64 ret
,
1146 TCGv_i64 arg1
, TCGv_i64 arg2
)
1148 tcg_gen_op4i_i64(INDEX_op_setcond_i64
, ret
, arg1
, arg2
, cond
);
1151 static inline void tcg_gen_mul_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1153 tcg_gen_op3_i64(INDEX_op_mul_i64
, ret
, arg1
, arg2
);
1156 #ifdef TCG_TARGET_HAS_div_i64
1157 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1159 tcg_gen_op3_i64(INDEX_op_div_i64
, ret
, arg1
, arg2
);
1162 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1164 tcg_gen_op3_i64(INDEX_op_rem_i64
, ret
, arg1
, arg2
);
1167 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1169 tcg_gen_op3_i64(INDEX_op_divu_i64
, ret
, arg1
, arg2
);
1172 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1174 tcg_gen_op3_i64(INDEX_op_remu_i64
, ret
, arg1
, arg2
);
1176 #elif defined(TCG_TARGET_HAS_div2_i64)
1177 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1180 t0
= tcg_temp_new_i64();
1181 tcg_gen_sari_i64(t0
, arg1
, 63);
1182 tcg_gen_op5_i64(INDEX_op_div2_i64
, ret
, t0
, arg1
, t0
, arg2
);
1183 tcg_temp_free_i64(t0
);
1186 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1189 t0
= tcg_temp_new_i64();
1190 tcg_gen_sari_i64(t0
, arg1
, 63);
1191 tcg_gen_op5_i64(INDEX_op_div2_i64
, t0
, ret
, arg1
, t0
, arg2
);
1192 tcg_temp_free_i64(t0
);
1195 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1198 t0
= tcg_temp_new_i64();
1199 tcg_gen_movi_i64(t0
, 0);
1200 tcg_gen_op5_i64(INDEX_op_divu2_i64
, ret
, t0
, arg1
, t0
, arg2
);
1201 tcg_temp_free_i64(t0
);
1204 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1207 t0
= tcg_temp_new_i64();
1208 tcg_gen_movi_i64(t0
, 0);
1209 tcg_gen_op5_i64(INDEX_op_divu2_i64
, t0
, ret
, arg1
, t0
, arg2
);
1210 tcg_temp_free_i64(t0
);
1213 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1215 tcg_gen_helper64(tcg_helper_div_i64
, ret
, arg1
, arg2
);
1218 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1220 tcg_gen_helper64(tcg_helper_rem_i64
, ret
, arg1
, arg2
);
1223 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1225 tcg_gen_helper64(tcg_helper_divu_i64
, ret
, arg1
, arg2
);
1228 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1230 tcg_gen_helper64(tcg_helper_remu_i64
, ret
, arg1
, arg2
);
1236 static inline void tcg_gen_addi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1238 /* some cases can be optimized here */
1240 tcg_gen_mov_i64(ret
, arg1
);
1242 TCGv_i64 t0
= tcg_const_i64(arg2
);
1243 tcg_gen_add_i64(ret
, arg1
, t0
);
1244 tcg_temp_free_i64(t0
);
1248 static inline void tcg_gen_subfi_i64(TCGv_i64 ret
, int64_t arg1
, TCGv_i64 arg2
)
1250 TCGv_i64 t0
= tcg_const_i64(arg1
);
1251 tcg_gen_sub_i64(ret
, t0
, arg2
);
1252 tcg_temp_free_i64(t0
);
1255 static inline void tcg_gen_subi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1257 /* some cases can be optimized here */
1259 tcg_gen_mov_i64(ret
, arg1
);
1261 TCGv_i64 t0
= tcg_const_i64(arg2
);
1262 tcg_gen_sub_i64(ret
, arg1
, t0
);
1263 tcg_temp_free_i64(t0
);
1266 static inline void tcg_gen_brcondi_i64(TCGCond cond
, TCGv_i64 arg1
,
1267 int64_t arg2
, int label_index
)
1269 TCGv_i64 t0
= tcg_const_i64(arg2
);
1270 tcg_gen_brcond_i64(cond
, arg1
, t0
, label_index
);
1271 tcg_temp_free_i64(t0
);
1274 static inline void tcg_gen_setcondi_i64(TCGCond cond
, TCGv_i64 ret
,
1275 TCGv_i64 arg1
, int64_t arg2
)
1277 TCGv_i64 t0
= tcg_const_i64(arg2
);
1278 tcg_gen_setcond_i64(cond
, ret
, arg1
, t0
);
1279 tcg_temp_free_i64(t0
);
1282 static inline void tcg_gen_muli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1284 TCGv_i64 t0
= tcg_const_i64(arg2
);
1285 tcg_gen_mul_i64(ret
, arg1
, t0
);
1286 tcg_temp_free_i64(t0
);
1290 /***************************************/
1291 /* optional operations */
1293 static inline void tcg_gen_ext8s_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1295 #ifdef TCG_TARGET_HAS_ext8s_i32
1296 tcg_gen_op2_i32(INDEX_op_ext8s_i32
, ret
, arg
);
1298 tcg_gen_shli_i32(ret
, arg
, 24);
1299 tcg_gen_sari_i32(ret
, ret
, 24);
1303 static inline void tcg_gen_ext16s_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1305 #ifdef TCG_TARGET_HAS_ext16s_i32
1306 tcg_gen_op2_i32(INDEX_op_ext16s_i32
, ret
, arg
);
1308 tcg_gen_shli_i32(ret
, arg
, 16);
1309 tcg_gen_sari_i32(ret
, ret
, 16);
1313 static inline void tcg_gen_ext8u_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1315 #ifdef TCG_TARGET_HAS_ext8u_i32
1316 tcg_gen_op2_i32(INDEX_op_ext8u_i32
, ret
, arg
);
1318 tcg_gen_andi_i32(ret
, arg
, 0xffu
);
1322 static inline void tcg_gen_ext16u_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1324 #ifdef TCG_TARGET_HAS_ext16u_i32
1325 tcg_gen_op2_i32(INDEX_op_ext16u_i32
, ret
, arg
);
1327 tcg_gen_andi_i32(ret
, arg
, 0xffffu
);
1331 /* Note: we assume the two high bytes are set to zero */
1332 static inline void tcg_gen_bswap16_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1334 #ifdef TCG_TARGET_HAS_bswap16_i32
1335 tcg_gen_op2_i32(INDEX_op_bswap16_i32
, ret
, arg
);
1337 TCGv_i32 t0
= tcg_temp_new_i32();
1339 tcg_gen_ext8u_i32(t0
, arg
);
1340 tcg_gen_shli_i32(t0
, t0
, 8);
1341 tcg_gen_shri_i32(ret
, arg
, 8);
1342 tcg_gen_or_i32(ret
, ret
, t0
);
1343 tcg_temp_free_i32(t0
);
1347 static inline void tcg_gen_bswap32_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1349 #ifdef TCG_TARGET_HAS_bswap32_i32
1350 tcg_gen_op2_i32(INDEX_op_bswap32_i32
, ret
, arg
);
1353 t0
= tcg_temp_new_i32();
1354 t1
= tcg_temp_new_i32();
1356 tcg_gen_shli_i32(t0
, arg
, 24);
1358 tcg_gen_andi_i32(t1
, arg
, 0x0000ff00);
1359 tcg_gen_shli_i32(t1
, t1
, 8);
1360 tcg_gen_or_i32(t0
, t0
, t1
);
1362 tcg_gen_shri_i32(t1
, arg
, 8);
1363 tcg_gen_andi_i32(t1
, t1
, 0x0000ff00);
1364 tcg_gen_or_i32(t0
, t0
, t1
);
1366 tcg_gen_shri_i32(t1
, arg
, 24);
1367 tcg_gen_or_i32(ret
, t0
, t1
);
1368 tcg_temp_free_i32(t0
);
1369 tcg_temp_free_i32(t1
);
1373 #if TCG_TARGET_REG_BITS == 32
1374 static inline void tcg_gen_ext8s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1376 tcg_gen_ext8s_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1377 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1380 static inline void tcg_gen_ext16s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1382 tcg_gen_ext16s_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1383 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1386 static inline void tcg_gen_ext32s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1388 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1389 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1392 static inline void tcg_gen_ext8u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1394 tcg_gen_ext8u_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1395 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1398 static inline void tcg_gen_ext16u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1400 tcg_gen_ext16u_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1401 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1404 static inline void tcg_gen_ext32u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1406 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1407 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1410 static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret
, TCGv_i64 arg
)
1412 tcg_gen_mov_i32(ret
, TCGV_LOW(arg
));
1415 static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1417 tcg_gen_mov_i32(TCGV_LOW(ret
), arg
);
1418 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1421 static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1423 tcg_gen_mov_i32(TCGV_LOW(ret
), arg
);
1424 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1427 /* Note: we assume the six high bytes are set to zero */
1428 static inline void tcg_gen_bswap16_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1430 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1431 tcg_gen_bswap16_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1434 /* Note: we assume the four high bytes are set to zero */
1435 static inline void tcg_gen_bswap32_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1437 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1438 tcg_gen_bswap32_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1441 static inline void tcg_gen_bswap64_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1444 t0
= tcg_temp_new_i32();
1445 t1
= tcg_temp_new_i32();
1447 tcg_gen_bswap32_i32(t0
, TCGV_LOW(arg
));
1448 tcg_gen_bswap32_i32(t1
, TCGV_HIGH(arg
));
1449 tcg_gen_mov_i32(TCGV_LOW(ret
), t1
);
1450 tcg_gen_mov_i32(TCGV_HIGH(ret
), t0
);
1451 tcg_temp_free_i32(t0
);
1452 tcg_temp_free_i32(t1
);
1456 static inline void tcg_gen_ext8s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1458 #ifdef TCG_TARGET_HAS_ext8s_i64
1459 tcg_gen_op2_i64(INDEX_op_ext8s_i64
, ret
, arg
);
1461 tcg_gen_shli_i64(ret
, arg
, 56);
1462 tcg_gen_sari_i64(ret
, ret
, 56);
1466 static inline void tcg_gen_ext16s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1468 #ifdef TCG_TARGET_HAS_ext16s_i64
1469 tcg_gen_op2_i64(INDEX_op_ext16s_i64
, ret
, arg
);
1471 tcg_gen_shli_i64(ret
, arg
, 48);
1472 tcg_gen_sari_i64(ret
, ret
, 48);
1476 static inline void tcg_gen_ext32s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1478 #ifdef TCG_TARGET_HAS_ext32s_i64
1479 tcg_gen_op2_i64(INDEX_op_ext32s_i64
, ret
, arg
);
1481 tcg_gen_shli_i64(ret
, arg
, 32);
1482 tcg_gen_sari_i64(ret
, ret
, 32);
1486 static inline void tcg_gen_ext8u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1488 #ifdef TCG_TARGET_HAS_ext8u_i64
1489 tcg_gen_op2_i64(INDEX_op_ext8u_i64
, ret
, arg
);
1491 tcg_gen_andi_i64(ret
, arg
, 0xffu
);
1495 static inline void tcg_gen_ext16u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1497 #ifdef TCG_TARGET_HAS_ext16u_i64
1498 tcg_gen_op2_i64(INDEX_op_ext16u_i64
, ret
, arg
);
1500 tcg_gen_andi_i64(ret
, arg
, 0xffffu
);
1504 static inline void tcg_gen_ext32u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1506 #ifdef TCG_TARGET_HAS_ext32u_i64
1507 tcg_gen_op2_i64(INDEX_op_ext32u_i64
, ret
, arg
);
1509 tcg_gen_andi_i64(ret
, arg
, 0xffffffffu
);
1513 /* Note: we assume the target supports move between 32 and 64 bit
1514 registers. This will probably break MIPS64 targets. */
1515 static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret
, TCGv_i64 arg
)
1517 tcg_gen_mov_i32(ret
, MAKE_TCGV_I32(GET_TCGV_I64(arg
)));
1520 /* Note: we assume the target supports move between 32 and 64 bit
1522 static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1524 tcg_gen_ext32u_i64(ret
, MAKE_TCGV_I64(GET_TCGV_I32(arg
)));
1527 /* Note: we assume the target supports move between 32 and 64 bit
1529 static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1531 tcg_gen_ext32s_i64(ret
, MAKE_TCGV_I64(GET_TCGV_I32(arg
)));
1534 /* Note: we assume the six high bytes are set to zero */
1535 static inline void tcg_gen_bswap16_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1537 #ifdef TCG_TARGET_HAS_bswap16_i64
1538 tcg_gen_op2_i64(INDEX_op_bswap16_i64
, ret
, arg
);
1540 TCGv_i64 t0
= tcg_temp_new_i64();
1542 tcg_gen_ext8u_i64(t0
, arg
);
1543 tcg_gen_shli_i64(t0
, t0
, 8);
1544 tcg_gen_shri_i64(ret
, arg
, 8);
1545 tcg_gen_or_i64(ret
, ret
, t0
);
1546 tcg_temp_free_i64(t0
);
1550 /* Note: we assume the four high bytes are set to zero */
1551 static inline void tcg_gen_bswap32_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1553 #ifdef TCG_TARGET_HAS_bswap32_i64
1554 tcg_gen_op2_i64(INDEX_op_bswap32_i64
, ret
, arg
);
1557 t0
= tcg_temp_new_i64();
1558 t1
= tcg_temp_new_i64();
1560 tcg_gen_shli_i64(t0
, arg
, 24);
1561 tcg_gen_ext32u_i64(t0
, t0
);
1563 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1564 tcg_gen_shli_i64(t1
, t1
, 8);
1565 tcg_gen_or_i64(t0
, t0
, t1
);
1567 tcg_gen_shri_i64(t1
, arg
, 8);
1568 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1569 tcg_gen_or_i64(t0
, t0
, t1
);
1571 tcg_gen_shri_i64(t1
, arg
, 24);
1572 tcg_gen_or_i64(ret
, t0
, t1
);
1573 tcg_temp_free_i64(t0
);
1574 tcg_temp_free_i64(t1
);
1578 static inline void tcg_gen_bswap64_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1580 #ifdef TCG_TARGET_HAS_bswap64_i64
1581 tcg_gen_op2_i64(INDEX_op_bswap64_i64
, ret
, arg
);
1583 TCGv_i64 t0
= tcg_temp_new_i64();
1584 TCGv_i64 t1
= tcg_temp_new_i64();
1586 tcg_gen_shli_i64(t0
, arg
, 56);
1588 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1589 tcg_gen_shli_i64(t1
, t1
, 40);
1590 tcg_gen_or_i64(t0
, t0
, t1
);
1592 tcg_gen_andi_i64(t1
, arg
, 0x00ff0000);
1593 tcg_gen_shli_i64(t1
, t1
, 24);
1594 tcg_gen_or_i64(t0
, t0
, t1
);
1596 tcg_gen_andi_i64(t1
, arg
, 0xff000000);
1597 tcg_gen_shli_i64(t1
, t1
, 8);
1598 tcg_gen_or_i64(t0
, t0
, t1
);
1600 tcg_gen_shri_i64(t1
, arg
, 8);
1601 tcg_gen_andi_i64(t1
, t1
, 0xff000000);
1602 tcg_gen_or_i64(t0
, t0
, t1
);
1604 tcg_gen_shri_i64(t1
, arg
, 24);
1605 tcg_gen_andi_i64(t1
, t1
, 0x00ff0000);
1606 tcg_gen_or_i64(t0
, t0
, t1
);
1608 tcg_gen_shri_i64(t1
, arg
, 40);
1609 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1610 tcg_gen_or_i64(t0
, t0
, t1
);
1612 tcg_gen_shri_i64(t1
, arg
, 56);
1613 tcg_gen_or_i64(ret
, t0
, t1
);
1614 tcg_temp_free_i64(t0
);
1615 tcg_temp_free_i64(t1
);
1621 static inline void tcg_gen_neg_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1623 #ifdef TCG_TARGET_HAS_neg_i32
1624 tcg_gen_op2_i32(INDEX_op_neg_i32
, ret
, arg
);
1626 TCGv_i32 t0
= tcg_const_i32(0);
1627 tcg_gen_sub_i32(ret
, t0
, arg
);
1628 tcg_temp_free_i32(t0
);
1632 static inline void tcg_gen_neg_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1634 #ifdef TCG_TARGET_HAS_neg_i64
1635 tcg_gen_op2_i64(INDEX_op_neg_i64
, ret
, arg
);
1637 TCGv_i64 t0
= tcg_const_i64(0);
1638 tcg_gen_sub_i64(ret
, t0
, arg
);
1639 tcg_temp_free_i64(t0
);
1643 static inline void tcg_gen_not_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1645 #ifdef TCG_TARGET_HAS_not_i32
1646 tcg_gen_op2_i32(INDEX_op_not_i32
, ret
, arg
);
1648 tcg_gen_xori_i32(ret
, arg
, -1);
1652 static inline void tcg_gen_not_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1654 #ifdef TCG_TARGET_HAS_not_i64
1655 tcg_gen_op2_i64(INDEX_op_not_i64
, ret
, arg
);
1656 #elif defined(TCG_TARGET_HAS_not_i32) && TCG_TARGET_REG_BITS == 32
1657 tcg_gen_not_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1658 tcg_gen_not_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1660 tcg_gen_xori_i64(ret
, arg
, -1);
1664 static inline void tcg_gen_discard_i32(TCGv_i32 arg
)
1666 tcg_gen_op1_i32(INDEX_op_discard
, arg
);
1669 #if TCG_TARGET_REG_BITS == 32
1670 static inline void tcg_gen_discard_i64(TCGv_i64 arg
)
1672 tcg_gen_discard_i32(TCGV_LOW(arg
));
1673 tcg_gen_discard_i32(TCGV_HIGH(arg
));
1676 static inline void tcg_gen_discard_i64(TCGv_i64 arg
)
1678 tcg_gen_op1_i64(INDEX_op_discard
, arg
);
1682 static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest
, TCGv_i32 low
, TCGv_i32 high
)
1684 #if TCG_TARGET_REG_BITS == 32
1685 tcg_gen_mov_i32(TCGV_LOW(dest
), low
);
1686 tcg_gen_mov_i32(TCGV_HIGH(dest
), high
);
1688 TCGv_i64 tmp
= tcg_temp_new_i64();
1689 /* This extension is only needed for type correctness.
1690 We may be able to do better given target specific information. */
1691 tcg_gen_extu_i32_i64(tmp
, high
);
1692 tcg_gen_shli_i64(tmp
, tmp
, 32);
1693 tcg_gen_extu_i32_i64(dest
, low
);
1694 tcg_gen_or_i64(dest
, dest
, tmp
);
1695 tcg_temp_free_i64(tmp
);
1699 static inline void tcg_gen_concat32_i64(TCGv_i64 dest
, TCGv_i64 low
, TCGv_i64 high
)
1701 #if TCG_TARGET_REG_BITS == 32
1702 tcg_gen_concat_i32_i64(dest
, TCGV_LOW(low
), TCGV_LOW(high
));
1704 TCGv_i64 tmp
= tcg_temp_new_i64();
1705 tcg_gen_ext32u_i64(dest
, low
);
1706 tcg_gen_shli_i64(tmp
, high
, 32);
1707 tcg_gen_or_i64(dest
, dest
, tmp
);
1708 tcg_temp_free_i64(tmp
);
1712 static inline void tcg_gen_andc_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1714 #ifdef TCG_TARGET_HAS_andc_i32
1715 tcg_gen_op3_i32(INDEX_op_andc_i32
, ret
, arg1
, arg2
);
1718 t0
= tcg_temp_new_i32();
1719 tcg_gen_not_i32(t0
, arg2
);
1720 tcg_gen_and_i32(ret
, arg1
, t0
);
1721 tcg_temp_free_i32(t0
);
1725 static inline void tcg_gen_andc_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1727 #ifdef TCG_TARGET_HAS_andc_i64
1728 tcg_gen_op3_i64(INDEX_op_andc_i64
, ret
, arg1
, arg2
);
1729 #elif defined(TCG_TARGET_HAS_andc_i32) && TCG_TARGET_REG_BITS == 32
1730 tcg_gen_andc_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1731 tcg_gen_andc_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1734 t0
= tcg_temp_new_i64();
1735 tcg_gen_not_i64(t0
, arg2
);
1736 tcg_gen_and_i64(ret
, arg1
, t0
);
1737 tcg_temp_free_i64(t0
);
1741 static inline void tcg_gen_eqv_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1743 #ifdef TCG_TARGET_HAS_eqv_i32
1744 tcg_gen_op3_i32(INDEX_op_eqv_i32
, ret
, arg1
, arg2
);
1746 tcg_gen_xor_i32(ret
, arg1
, arg2
);
1747 tcg_gen_not_i32(ret
, ret
);
1751 static inline void tcg_gen_eqv_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1753 #ifdef TCG_TARGET_HAS_eqv_i64
1754 tcg_gen_op3_i64(INDEX_op_eqv_i64
, ret
, arg1
, arg2
);
1755 #elif defined(TCG_TARGET_HAS_eqv_i32) && TCG_TARGET_REG_BITS == 32
1756 tcg_gen_eqv_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1757 tcg_gen_eqv_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1759 tcg_gen_xor_i64(ret
, arg1
, arg2
);
1760 tcg_gen_not_i64(ret
, ret
);
1764 static inline void tcg_gen_nand_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1766 #ifdef TCG_TARGET_HAS_nand_i32
1767 tcg_gen_op3_i32(INDEX_op_nand_i32
, ret
, arg1
, arg2
);
1769 tcg_gen_and_i32(ret
, arg1
, arg2
);
1770 tcg_gen_not_i32(ret
, ret
);
1774 static inline void tcg_gen_nand_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1776 #ifdef TCG_TARGET_HAS_nand_i64
1777 tcg_gen_op3_i64(INDEX_op_nand_i64
, ret
, arg1
, arg2
);
1778 #elif defined(TCG_TARGET_HAS_nand_i32) && TCG_TARGET_REG_BITS == 32
1779 tcg_gen_nand_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1780 tcg_gen_nand_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1782 tcg_gen_and_i64(ret
, arg1
, arg2
);
1783 tcg_gen_not_i64(ret
, ret
);
1787 static inline void tcg_gen_nor_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1789 #ifdef TCG_TARGET_HAS_nor_i32
1790 tcg_gen_op3_i32(INDEX_op_nor_i32
, ret
, arg1
, arg2
);
1792 tcg_gen_or_i32(ret
, arg1
, arg2
);
1793 tcg_gen_not_i32(ret
, ret
);
1797 static inline void tcg_gen_nor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1799 #ifdef TCG_TARGET_HAS_nor_i64
1800 tcg_gen_op3_i64(INDEX_op_nor_i64
, ret
, arg1
, arg2
);
1801 #elif defined(TCG_TARGET_HAS_nor_i32) && TCG_TARGET_REG_BITS == 32
1802 tcg_gen_nor_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1803 tcg_gen_nor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1805 tcg_gen_or_i64(ret
, arg1
, arg2
);
1806 tcg_gen_not_i64(ret
, ret
);
1810 static inline void tcg_gen_orc_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1812 #ifdef TCG_TARGET_HAS_orc_i32
1813 tcg_gen_op3_i32(INDEX_op_orc_i32
, ret
, arg1
, arg2
);
1816 t0
= tcg_temp_new_i32();
1817 tcg_gen_not_i32(t0
, arg2
);
1818 tcg_gen_or_i32(ret
, arg1
, t0
);
1819 tcg_temp_free_i32(t0
);
1823 static inline void tcg_gen_orc_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1825 #ifdef TCG_TARGET_HAS_orc_i64
1826 tcg_gen_op3_i64(INDEX_op_orc_i64
, ret
, arg1
, arg2
);
1827 #elif defined(TCG_TARGET_HAS_orc_i32) && TCG_TARGET_REG_BITS == 32
1828 tcg_gen_orc_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1829 tcg_gen_orc_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1832 t0
= tcg_temp_new_i64();
1833 tcg_gen_not_i64(t0
, arg2
);
1834 tcg_gen_or_i64(ret
, arg1
, t0
);
1835 tcg_temp_free_i64(t0
);
1839 static inline void tcg_gen_rotl_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1841 #ifdef TCG_TARGET_HAS_rot_i32
1842 tcg_gen_op3_i32(INDEX_op_rotl_i32
, ret
, arg1
, arg2
);
1846 t0
= tcg_temp_new_i32();
1847 t1
= tcg_temp_new_i32();
1848 tcg_gen_shl_i32(t0
, arg1
, arg2
);
1849 tcg_gen_subfi_i32(t1
, 32, arg2
);
1850 tcg_gen_shr_i32(t1
, arg1
, t1
);
1851 tcg_gen_or_i32(ret
, t0
, t1
);
1852 tcg_temp_free_i32(t0
);
1853 tcg_temp_free_i32(t1
);
1857 static inline void tcg_gen_rotl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1859 #ifdef TCG_TARGET_HAS_rot_i64
1860 tcg_gen_op3_i64(INDEX_op_rotl_i64
, ret
, arg1
, arg2
);
1864 t0
= tcg_temp_new_i64();
1865 t1
= tcg_temp_new_i64();
1866 tcg_gen_shl_i64(t0
, arg1
, arg2
);
1867 tcg_gen_subfi_i64(t1
, 64, arg2
);
1868 tcg_gen_shr_i64(t1
, arg1
, t1
);
1869 tcg_gen_or_i64(ret
, t0
, t1
);
1870 tcg_temp_free_i64(t0
);
1871 tcg_temp_free_i64(t1
);
1875 static inline void tcg_gen_rotli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
1877 /* some cases can be optimized here */
1879 tcg_gen_mov_i32(ret
, arg1
);
1881 #ifdef TCG_TARGET_HAS_rot_i32
1882 TCGv_i32 t0
= tcg_const_i32(arg2
);
1883 tcg_gen_rotl_i32(ret
, arg1
, t0
);
1884 tcg_temp_free_i32(t0
);
1887 t0
= tcg_temp_new_i32();
1888 t1
= tcg_temp_new_i32();
1889 tcg_gen_shli_i32(t0
, arg1
, arg2
);
1890 tcg_gen_shri_i32(t1
, arg1
, 32 - arg2
);
1891 tcg_gen_or_i32(ret
, t0
, t1
);
1892 tcg_temp_free_i32(t0
);
1893 tcg_temp_free_i32(t1
);
1898 static inline void tcg_gen_rotli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1900 /* some cases can be optimized here */
1902 tcg_gen_mov_i64(ret
, arg1
);
1904 #ifdef TCG_TARGET_HAS_rot_i64
1905 TCGv_i64 t0
= tcg_const_i64(arg2
);
1906 tcg_gen_rotl_i64(ret
, arg1
, t0
);
1907 tcg_temp_free_i64(t0
);
1910 t0
= tcg_temp_new_i64();
1911 t1
= tcg_temp_new_i64();
1912 tcg_gen_shli_i64(t0
, arg1
, arg2
);
1913 tcg_gen_shri_i64(t1
, arg1
, 64 - arg2
);
1914 tcg_gen_or_i64(ret
, t0
, t1
);
1915 tcg_temp_free_i64(t0
);
1916 tcg_temp_free_i64(t1
);
1921 static inline void tcg_gen_rotr_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1923 #ifdef TCG_TARGET_HAS_rot_i32
1924 tcg_gen_op3_i32(INDEX_op_rotr_i32
, ret
, arg1
, arg2
);
1928 t0
= tcg_temp_new_i32();
1929 t1
= tcg_temp_new_i32();
1930 tcg_gen_shr_i32(t0
, arg1
, arg2
);
1931 tcg_gen_subfi_i32(t1
, 32, arg2
);
1932 tcg_gen_shl_i32(t1
, arg1
, t1
);
1933 tcg_gen_or_i32(ret
, t0
, t1
);
1934 tcg_temp_free_i32(t0
);
1935 tcg_temp_free_i32(t1
);
1939 static inline void tcg_gen_rotr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1941 #ifdef TCG_TARGET_HAS_rot_i64
1942 tcg_gen_op3_i64(INDEX_op_rotr_i64
, ret
, arg1
, arg2
);
1946 t0
= tcg_temp_new_i64();
1947 t1
= tcg_temp_new_i64();
1948 tcg_gen_shr_i64(t0
, arg1
, arg2
);
1949 tcg_gen_subfi_i64(t1
, 64, arg2
);
1950 tcg_gen_shl_i64(t1
, arg1
, t1
);
1951 tcg_gen_or_i64(ret
, t0
, t1
);
1952 tcg_temp_free_i64(t0
);
1953 tcg_temp_free_i64(t1
);
1957 static inline void tcg_gen_rotri_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
1959 /* some cases can be optimized here */
1961 tcg_gen_mov_i32(ret
, arg1
);
1963 tcg_gen_rotli_i32(ret
, arg1
, 32 - arg2
);
1967 static inline void tcg_gen_rotri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1969 /* some cases can be optimized here */
1971 tcg_gen_mov_i64(ret
, arg1
);
1973 tcg_gen_rotli_i64(ret
, arg1
, 64 - arg2
);
1977 /***************************************/
1978 /* QEMU specific operations. Their type depend on the QEMU CPU
1980 #ifndef TARGET_LONG_BITS
1981 #error must include QEMU headers
1984 #if TARGET_LONG_BITS == 32
1985 #define TCGv TCGv_i32
1986 #define tcg_temp_new() tcg_temp_new_i32()
1987 #define tcg_global_reg_new tcg_global_reg_new_i32
1988 #define tcg_global_mem_new tcg_global_mem_new_i32
1989 #define tcg_temp_local_new() tcg_temp_local_new_i32()
1990 #define tcg_temp_free tcg_temp_free_i32
1991 #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32
1992 #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32
1993 #define TCGV_UNUSED(x) TCGV_UNUSED_I32(x)
1994 #define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b)
1996 #define TCGv TCGv_i64
1997 #define tcg_temp_new() tcg_temp_new_i64()
1998 #define tcg_global_reg_new tcg_global_reg_new_i64
1999 #define tcg_global_mem_new tcg_global_mem_new_i64
2000 #define tcg_temp_local_new() tcg_temp_local_new_i64()
2001 #define tcg_temp_free tcg_temp_free_i64
2002 #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64
2003 #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64
2004 #define TCGV_UNUSED(x) TCGV_UNUSED_I64(x)
2005 #define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b)
2008 /* debug info: write the PC of the corresponding QEMU CPU instruction */
2009 static inline void tcg_gen_debug_insn_start(uint64_t pc
)
2011 /* XXX: must really use a 32 bit size for TCGArg in all cases */
2012 #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
2013 tcg_gen_op2ii(INDEX_op_debug_insn_start
,
2014 (uint32_t)(pc
), (uint32_t)(pc
>> 32));
2016 tcg_gen_op1i(INDEX_op_debug_insn_start
, pc
);
2020 static inline void tcg_gen_exit_tb(tcg_target_long val
)
2022 tcg_gen_op1i(INDEX_op_exit_tb
, val
);
2025 static inline void tcg_gen_goto_tb(int idx
)
2027 tcg_gen_op1i(INDEX_op_goto_tb
, idx
);
2030 #if TCG_TARGET_REG_BITS == 32
2031 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
2033 #if TARGET_LONG_BITS == 32
2034 tcg_gen_op3i_i32(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
2036 tcg_gen_op4i_i32(INDEX_op_qemu_ld8u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2037 TCGV_HIGH(addr
), mem_index
);
2038 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
2042 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
2044 #if TARGET_LONG_BITS == 32
2045 tcg_gen_op3i_i32(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
2047 tcg_gen_op4i_i32(INDEX_op_qemu_ld8s
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2048 TCGV_HIGH(addr
), mem_index
);
2049 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2053 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
2055 #if TARGET_LONG_BITS == 32
2056 tcg_gen_op3i_i32(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
2058 tcg_gen_op4i_i32(INDEX_op_qemu_ld16u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2059 TCGV_HIGH(addr
), mem_index
);
2060 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
2064 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
2066 #if TARGET_LONG_BITS == 32
2067 tcg_gen_op3i_i32(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
2069 tcg_gen_op4i_i32(INDEX_op_qemu_ld16s
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2070 TCGV_HIGH(addr
), mem_index
);
2071 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2075 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
2077 #if TARGET_LONG_BITS == 32
2078 tcg_gen_op3i_i32(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2080 tcg_gen_op4i_i32(INDEX_op_qemu_ld32
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2081 TCGV_HIGH(addr
), mem_index
);
2082 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
2086 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
2088 #if TARGET_LONG_BITS == 32
2089 tcg_gen_op3i_i32(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2091 tcg_gen_op4i_i32(INDEX_op_qemu_ld32
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2092 TCGV_HIGH(addr
), mem_index
);
2093 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2097 static inline void tcg_gen_qemu_ld64(TCGv_i64 ret
, TCGv addr
, int mem_index
)
2099 #if TARGET_LONG_BITS == 32
2100 tcg_gen_op4i_i32(INDEX_op_qemu_ld64
, TCGV_LOW(ret
), TCGV_HIGH(ret
), addr
, mem_index
);
2102 tcg_gen_op5i_i32(INDEX_op_qemu_ld64
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
2103 TCGV_LOW(addr
), TCGV_HIGH(addr
), mem_index
);
2107 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
2109 #if TARGET_LONG_BITS == 32
2110 tcg_gen_op3i_i32(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
2112 tcg_gen_op4i_i32(INDEX_op_qemu_st8
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2113 TCGV_HIGH(addr
), mem_index
);
2117 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
2119 #if TARGET_LONG_BITS == 32
2120 tcg_gen_op3i_i32(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
2122 tcg_gen_op4i_i32(INDEX_op_qemu_st16
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2123 TCGV_HIGH(addr
), mem_index
);
2127 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
2129 #if TARGET_LONG_BITS == 32
2130 tcg_gen_op3i_i32(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
2132 tcg_gen_op4i_i32(INDEX_op_qemu_st32
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2133 TCGV_HIGH(addr
), mem_index
);
2137 static inline void tcg_gen_qemu_st64(TCGv_i64 arg
, TCGv addr
, int mem_index
)
2139 #if TARGET_LONG_BITS == 32
2140 tcg_gen_op4i_i32(INDEX_op_qemu_st64
, TCGV_LOW(arg
), TCGV_HIGH(arg
), addr
,
2143 tcg_gen_op5i_i32(INDEX_op_qemu_st64
, TCGV_LOW(arg
), TCGV_HIGH(arg
),
2144 TCGV_LOW(addr
), TCGV_HIGH(addr
), mem_index
);
2148 #define tcg_gen_ld_ptr tcg_gen_ld_i32
2149 #define tcg_gen_discard_ptr tcg_gen_discard_i32
2151 #else /* TCG_TARGET_REG_BITS == 32 */
2153 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
2155 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
2158 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
2160 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
2163 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
2165 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
2168 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
2170 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
2173 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
2175 #if TARGET_LONG_BITS == 32
2176 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2178 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
2182 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
2184 #if TARGET_LONG_BITS == 32
2185 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2187 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s
, ret
, addr
, mem_index
);
2191 static inline void tcg_gen_qemu_ld64(TCGv_i64 ret
, TCGv addr
, int mem_index
)
2193 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64
, ret
, addr
, mem_index
);
2196 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
2198 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
2201 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
2203 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
2206 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
2208 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
2211 static inline void tcg_gen_qemu_st64(TCGv_i64 arg
, TCGv addr
, int mem_index
)
2213 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64
, arg
, addr
, mem_index
);
2216 #define tcg_gen_ld_ptr tcg_gen_ld_i64
2217 #define tcg_gen_discard_ptr tcg_gen_discard_i64
2219 #endif /* TCG_TARGET_REG_BITS != 32 */
2221 #if TARGET_LONG_BITS == 64
2222 #define tcg_gen_movi_tl tcg_gen_movi_i64
2223 #define tcg_gen_mov_tl tcg_gen_mov_i64
2224 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
2225 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
2226 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
2227 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
2228 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
2229 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
2230 #define tcg_gen_ld_tl tcg_gen_ld_i64
2231 #define tcg_gen_st8_tl tcg_gen_st8_i64
2232 #define tcg_gen_st16_tl tcg_gen_st16_i64
2233 #define tcg_gen_st32_tl tcg_gen_st32_i64
2234 #define tcg_gen_st_tl tcg_gen_st_i64
2235 #define tcg_gen_add_tl tcg_gen_add_i64
2236 #define tcg_gen_addi_tl tcg_gen_addi_i64
2237 #define tcg_gen_sub_tl tcg_gen_sub_i64
2238 #define tcg_gen_neg_tl tcg_gen_neg_i64
2239 #define tcg_gen_subfi_tl tcg_gen_subfi_i64
2240 #define tcg_gen_subi_tl tcg_gen_subi_i64
2241 #define tcg_gen_and_tl tcg_gen_and_i64
2242 #define tcg_gen_andi_tl tcg_gen_andi_i64
2243 #define tcg_gen_or_tl tcg_gen_or_i64
2244 #define tcg_gen_ori_tl tcg_gen_ori_i64
2245 #define tcg_gen_xor_tl tcg_gen_xor_i64
2246 #define tcg_gen_xori_tl tcg_gen_xori_i64
2247 #define tcg_gen_not_tl tcg_gen_not_i64
2248 #define tcg_gen_shl_tl tcg_gen_shl_i64
2249 #define tcg_gen_shli_tl tcg_gen_shli_i64
2250 #define tcg_gen_shr_tl tcg_gen_shr_i64
2251 #define tcg_gen_shri_tl tcg_gen_shri_i64
2252 #define tcg_gen_sar_tl tcg_gen_sar_i64
2253 #define tcg_gen_sari_tl tcg_gen_sari_i64
2254 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
2255 #define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
2256 #define tcg_gen_setcond_tl tcg_gen_setcond_i64
2257 #define tcg_gen_setcondi_tl tcg_gen_setcondi_i64
2258 #define tcg_gen_mul_tl tcg_gen_mul_i64
2259 #define tcg_gen_muli_tl tcg_gen_muli_i64
2260 #define tcg_gen_div_tl tcg_gen_div_i64
2261 #define tcg_gen_rem_tl tcg_gen_rem_i64
2262 #define tcg_gen_divu_tl tcg_gen_divu_i64
2263 #define tcg_gen_remu_tl tcg_gen_remu_i64
2264 #define tcg_gen_discard_tl tcg_gen_discard_i64
2265 #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
2266 #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
2267 #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
2268 #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
2269 #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
2270 #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
2271 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
2272 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
2273 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
2274 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
2275 #define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
2276 #define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
2277 #define tcg_gen_bswap16_tl tcg_gen_bswap16_i64
2278 #define tcg_gen_bswap32_tl tcg_gen_bswap32_i64
2279 #define tcg_gen_bswap64_tl tcg_gen_bswap64_i64
2280 #define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
2281 #define tcg_gen_andc_tl tcg_gen_andc_i64
2282 #define tcg_gen_eqv_tl tcg_gen_eqv_i64
2283 #define tcg_gen_nand_tl tcg_gen_nand_i64
2284 #define tcg_gen_nor_tl tcg_gen_nor_i64
2285 #define tcg_gen_orc_tl tcg_gen_orc_i64
2286 #define tcg_gen_rotl_tl tcg_gen_rotl_i64
2287 #define tcg_gen_rotli_tl tcg_gen_rotli_i64
2288 #define tcg_gen_rotr_tl tcg_gen_rotr_i64
2289 #define tcg_gen_rotri_tl tcg_gen_rotri_i64
2290 #define tcg_const_tl tcg_const_i64
2291 #define tcg_const_local_tl tcg_const_local_i64
2293 #define tcg_gen_movi_tl tcg_gen_movi_i32
2294 #define tcg_gen_mov_tl tcg_gen_mov_i32
2295 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
2296 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
2297 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
2298 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
2299 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
2300 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
2301 #define tcg_gen_ld_tl tcg_gen_ld_i32
2302 #define tcg_gen_st8_tl tcg_gen_st8_i32
2303 #define tcg_gen_st16_tl tcg_gen_st16_i32
2304 #define tcg_gen_st32_tl tcg_gen_st_i32
2305 #define tcg_gen_st_tl tcg_gen_st_i32
2306 #define tcg_gen_add_tl tcg_gen_add_i32
2307 #define tcg_gen_addi_tl tcg_gen_addi_i32
2308 #define tcg_gen_sub_tl tcg_gen_sub_i32
2309 #define tcg_gen_neg_tl tcg_gen_neg_i32
2310 #define tcg_gen_subfi_tl tcg_gen_subfi_i32
2311 #define tcg_gen_subi_tl tcg_gen_subi_i32
2312 #define tcg_gen_and_tl tcg_gen_and_i32
2313 #define tcg_gen_andi_tl tcg_gen_andi_i32
2314 #define tcg_gen_or_tl tcg_gen_or_i32
2315 #define tcg_gen_ori_tl tcg_gen_ori_i32
2316 #define tcg_gen_xor_tl tcg_gen_xor_i32
2317 #define tcg_gen_xori_tl tcg_gen_xori_i32
2318 #define tcg_gen_not_tl tcg_gen_not_i32
2319 #define tcg_gen_shl_tl tcg_gen_shl_i32
2320 #define tcg_gen_shli_tl tcg_gen_shli_i32
2321 #define tcg_gen_shr_tl tcg_gen_shr_i32
2322 #define tcg_gen_shri_tl tcg_gen_shri_i32
2323 #define tcg_gen_sar_tl tcg_gen_sar_i32
2324 #define tcg_gen_sari_tl tcg_gen_sari_i32
2325 #define tcg_gen_brcond_tl tcg_gen_brcond_i32
2326 #define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
2327 #define tcg_gen_setcond_tl tcg_gen_setcond_i32
2328 #define tcg_gen_setcondi_tl tcg_gen_setcondi_i32
2329 #define tcg_gen_mul_tl tcg_gen_mul_i32
2330 #define tcg_gen_muli_tl tcg_gen_muli_i32
2331 #define tcg_gen_div_tl tcg_gen_div_i32
2332 #define tcg_gen_rem_tl tcg_gen_rem_i32
2333 #define tcg_gen_divu_tl tcg_gen_divu_i32
2334 #define tcg_gen_remu_tl tcg_gen_remu_i32
2335 #define tcg_gen_discard_tl tcg_gen_discard_i32
2336 #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
2337 #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
2338 #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
2339 #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
2340 #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
2341 #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
2342 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
2343 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
2344 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
2345 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
2346 #define tcg_gen_ext32u_tl tcg_gen_mov_i32
2347 #define tcg_gen_ext32s_tl tcg_gen_mov_i32
2348 #define tcg_gen_bswap16_tl tcg_gen_bswap16_i32
2349 #define tcg_gen_bswap32_tl tcg_gen_bswap32_i32
2350 #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
2351 #define tcg_gen_andc_tl tcg_gen_andc_i32
2352 #define tcg_gen_eqv_tl tcg_gen_eqv_i32
2353 #define tcg_gen_nand_tl tcg_gen_nand_i32
2354 #define tcg_gen_nor_tl tcg_gen_nor_i32
2355 #define tcg_gen_orc_tl tcg_gen_orc_i32
2356 #define tcg_gen_rotl_tl tcg_gen_rotl_i32
2357 #define tcg_gen_rotli_tl tcg_gen_rotli_i32
2358 #define tcg_gen_rotr_tl tcg_gen_rotr_i32
2359 #define tcg_gen_rotri_tl tcg_gen_rotri_i32
2360 #define tcg_const_tl tcg_const_i32
2361 #define tcg_const_local_tl tcg_const_local_i32
2364 #if TCG_TARGET_REG_BITS == 32
2365 #define tcg_gen_add_ptr tcg_gen_add_i32
2366 #define tcg_gen_addi_ptr tcg_gen_addi_i32
2367 #define tcg_gen_ext_i32_ptr tcg_gen_mov_i32
2368 #else /* TCG_TARGET_REG_BITS == 32 */
2369 #define tcg_gen_add_ptr tcg_gen_add_i64
2370 #define tcg_gen_addi_ptr tcg_gen_addi_i64
2371 #define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64
2372 #endif /* TCG_TARGET_REG_BITS != 32 */