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
)
30 *tcg_ctx
.gen_opc_ptr
++ = opc
;
33 static inline void tcg_gen_op1_i32(TCGOpcode opc
, TCGv_i32 arg1
)
35 *tcg_ctx
.gen_opc_ptr
++ = opc
;
36 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
39 static inline void tcg_gen_op1_i64(TCGOpcode opc
, TCGv_i64 arg1
)
41 *tcg_ctx
.gen_opc_ptr
++ = opc
;
42 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
45 static inline void tcg_gen_op1i(TCGOpcode opc
, TCGArg arg1
)
47 *tcg_ctx
.gen_opc_ptr
++ = opc
;
48 *tcg_ctx
.gen_opparam_ptr
++ = arg1
;
51 static inline void tcg_gen_op2_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
)
53 *tcg_ctx
.gen_opc_ptr
++ = opc
;
54 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
55 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
58 static inline void tcg_gen_op2_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
)
60 *tcg_ctx
.gen_opc_ptr
++ = opc
;
61 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
62 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
65 static inline void tcg_gen_op2i_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGArg arg2
)
67 *tcg_ctx
.gen_opc_ptr
++ = opc
;
68 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
69 *tcg_ctx
.gen_opparam_ptr
++ = arg2
;
72 static inline void tcg_gen_op2i_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGArg arg2
)
74 *tcg_ctx
.gen_opc_ptr
++ = opc
;
75 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
76 *tcg_ctx
.gen_opparam_ptr
++ = arg2
;
79 static inline void tcg_gen_op2ii(TCGOpcode opc
, TCGArg arg1
, TCGArg arg2
)
81 *tcg_ctx
.gen_opc_ptr
++ = opc
;
82 *tcg_ctx
.gen_opparam_ptr
++ = arg1
;
83 *tcg_ctx
.gen_opparam_ptr
++ = arg2
;
86 static inline void tcg_gen_op3_i32(TCGOpcode opc
, TCGv_i32 arg1
, TCGv_i32 arg2
,
89 *tcg_ctx
.gen_opc_ptr
++ = opc
;
90 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
91 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
92 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
95 static inline void tcg_gen_op3_i64(TCGOpcode opc
, TCGv_i64 arg1
, TCGv_i64 arg2
,
98 *tcg_ctx
.gen_opc_ptr
++ = opc
;
99 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
100 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
101 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
108 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
109 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
110 *tcg_ctx
.gen_opparam_ptr
++ = arg3
;
113 static inline void tcg_gen_op3i_i64(TCGOpcode opc
, TCGv_i64 arg1
,
114 TCGv_i64 arg2
, TCGArg arg3
)
116 *tcg_ctx
.gen_opc_ptr
++ = opc
;
117 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
118 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
119 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
126 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(val
);
127 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_PTR(base
);
128 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
135 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(val
);
136 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_PTR(base
);
137 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
144 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(val
);
145 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(addr
);
146 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
153 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(val
);
154 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(addr
);
155 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
162 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
163 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
164 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
165 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
172 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
173 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
174 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
175 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
182 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
183 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
184 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
185 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
192 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
193 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
194 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
195 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
202 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
203 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
204 *tcg_ctx
.gen_opparam_ptr
++ = arg3
;
205 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
212 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
213 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
214 *tcg_ctx
.gen_opparam_ptr
++ = arg3
;
215 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
222 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
223 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
224 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
225 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
226 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
233 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
234 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
235 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
236 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
237 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
244 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
245 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
246 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
247 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
248 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
255 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
256 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
257 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
258 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
259 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
267 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
268 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
269 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
270 *tcg_ctx
.gen_opparam_ptr
++ = arg4
;
271 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
279 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
280 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
281 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
282 *tcg_ctx
.gen_opparam_ptr
++ = arg4
;
283 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
291 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
292 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
293 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
294 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
295 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg5
);
296 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
304 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
305 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
306 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
307 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
308 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg5
);
309 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
317 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
318 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
319 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
320 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
321 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg5
);
322 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
330 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
331 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
332 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
333 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
334 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg5
);
335 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
343 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg1
);
344 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg2
);
345 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg3
);
346 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I32(arg4
);
347 *tcg_ctx
.gen_opparam_ptr
++ = arg5
;
348 *tcg_ctx
.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 *tcg_ctx
.gen_opc_ptr
++ = opc
;
356 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg1
);
357 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg2
);
358 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg3
);
359 *tcg_ctx
.gen_opparam_ptr
++ = GET_TCGV_I64(arg4
);
360 *tcg_ctx
.gen_opparam_ptr
++ = arg5
;
361 *tcg_ctx
.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 all do not read
405 globals and do not have side effects, hence the call to tcg_gen_callN()
406 with TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_SIDE_EFFECTS. This may need
407 to be adjusted if these functions 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
,
417 TCG_CALL_NO_READ_GLOBALS
| TCG_CALL_NO_SIDE_EFFECTS
,
418 sizemask
, GET_TCGV_I32(ret
), 2, args
);
419 tcg_temp_free_ptr(fn
);
422 static inline void tcg_gen_helper64(void *func
, int sizemask
, TCGv_i64 ret
,
423 TCGv_i64 a
, TCGv_i64 b
)
427 fn
= tcg_const_ptr(func
);
428 args
[0] = GET_TCGV_I64(a
);
429 args
[1] = GET_TCGV_I64(b
);
430 tcg_gen_callN(&tcg_ctx
, fn
,
431 TCG_CALL_NO_READ_GLOBALS
| TCG_CALL_NO_SIDE_EFFECTS
,
432 sizemask
, GET_TCGV_I64(ret
), 2, args
);
433 tcg_temp_free_ptr(fn
);
438 static inline void tcg_gen_ld8u_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
440 tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32
, ret
, arg2
, offset
);
443 static inline void tcg_gen_ld8s_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
445 tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32
, ret
, arg2
, offset
);
448 static inline void tcg_gen_ld16u_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
450 tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32
, ret
, arg2
, offset
);
453 static inline void tcg_gen_ld16s_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
455 tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32
, ret
, arg2
, offset
);
458 static inline void tcg_gen_ld_i32(TCGv_i32 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
460 tcg_gen_ldst_op_i32(INDEX_op_ld_i32
, ret
, arg2
, offset
);
463 static inline void tcg_gen_st8_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
465 tcg_gen_ldst_op_i32(INDEX_op_st8_i32
, arg1
, arg2
, offset
);
468 static inline void tcg_gen_st16_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
470 tcg_gen_ldst_op_i32(INDEX_op_st16_i32
, arg1
, arg2
, offset
);
473 static inline void tcg_gen_st_i32(TCGv_i32 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
475 tcg_gen_ldst_op_i32(INDEX_op_st_i32
, arg1
, arg2
, offset
);
478 static inline void tcg_gen_add_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
480 tcg_gen_op3_i32(INDEX_op_add_i32
, ret
, arg1
, arg2
);
483 static inline void tcg_gen_addi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
485 /* some cases can be optimized here */
487 tcg_gen_mov_i32(ret
, arg1
);
489 TCGv_i32 t0
= tcg_const_i32(arg2
);
490 tcg_gen_add_i32(ret
, arg1
, t0
);
491 tcg_temp_free_i32(t0
);
495 static inline void tcg_gen_sub_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
497 tcg_gen_op3_i32(INDEX_op_sub_i32
, ret
, arg1
, arg2
);
500 static inline void tcg_gen_subfi_i32(TCGv_i32 ret
, int32_t arg1
, TCGv_i32 arg2
)
502 TCGv_i32 t0
= tcg_const_i32(arg1
);
503 tcg_gen_sub_i32(ret
, t0
, arg2
);
504 tcg_temp_free_i32(t0
);
507 static inline void tcg_gen_subi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
509 /* some cases can be optimized here */
511 tcg_gen_mov_i32(ret
, arg1
);
513 TCGv_i32 t0
= tcg_const_i32(arg2
);
514 tcg_gen_sub_i32(ret
, arg1
, t0
);
515 tcg_temp_free_i32(t0
);
519 static inline void tcg_gen_and_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
521 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
522 tcg_gen_mov_i32(ret
, arg1
);
524 tcg_gen_op3_i32(INDEX_op_and_i32
, ret
, arg1
, arg2
);
528 static inline void tcg_gen_andi_i32(TCGv_i32 ret
, TCGv_i32 arg1
, uint32_t arg2
)
531 /* Some cases can be optimized here. */
534 tcg_gen_movi_i32(ret
, 0);
537 tcg_gen_mov_i32(ret
, arg1
);
540 /* Don't recurse with tcg_gen_ext8u_i32. */
541 if (TCG_TARGET_HAS_ext8u_i32
) {
542 tcg_gen_op2_i32(INDEX_op_ext8u_i32
, ret
, arg1
);
547 if (TCG_TARGET_HAS_ext16u_i32
) {
548 tcg_gen_op2_i32(INDEX_op_ext16u_i32
, ret
, arg1
);
553 t0
= tcg_const_i32(arg2
);
554 tcg_gen_and_i32(ret
, arg1
, t0
);
555 tcg_temp_free_i32(t0
);
558 static inline void tcg_gen_or_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
560 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
561 tcg_gen_mov_i32(ret
, arg1
);
563 tcg_gen_op3_i32(INDEX_op_or_i32
, ret
, arg1
, arg2
);
567 static inline void tcg_gen_ori_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
569 /* Some cases can be optimized here. */
571 tcg_gen_movi_i32(ret
, -1);
572 } else if (arg2
== 0) {
573 tcg_gen_mov_i32(ret
, arg1
);
575 TCGv_i32 t0
= tcg_const_i32(arg2
);
576 tcg_gen_or_i32(ret
, arg1
, t0
);
577 tcg_temp_free_i32(t0
);
581 static inline void tcg_gen_xor_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
583 if (TCGV_EQUAL_I32(arg1
, arg2
)) {
584 tcg_gen_movi_i32(ret
, 0);
586 tcg_gen_op3_i32(INDEX_op_xor_i32
, ret
, arg1
, arg2
);
590 static inline void tcg_gen_xori_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
592 /* Some cases can be optimized here. */
594 tcg_gen_mov_i32(ret
, arg1
);
595 } else if (arg2
== -1 && TCG_TARGET_HAS_not_i32
) {
596 /* Don't recurse with tcg_gen_not_i32. */
597 tcg_gen_op2_i32(INDEX_op_not_i32
, ret
, arg1
);
599 TCGv_i32 t0
= tcg_const_i32(arg2
);
600 tcg_gen_xor_i32(ret
, arg1
, t0
);
601 tcg_temp_free_i32(t0
);
605 static inline void tcg_gen_shl_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
607 tcg_gen_op3_i32(INDEX_op_shl_i32
, ret
, arg1
, arg2
);
610 static inline void tcg_gen_shli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
613 tcg_gen_mov_i32(ret
, arg1
);
615 TCGv_i32 t0
= tcg_const_i32(arg2
);
616 tcg_gen_shl_i32(ret
, arg1
, t0
);
617 tcg_temp_free_i32(t0
);
621 static inline void tcg_gen_shr_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
623 tcg_gen_op3_i32(INDEX_op_shr_i32
, ret
, arg1
, arg2
);
626 static inline void tcg_gen_shri_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
629 tcg_gen_mov_i32(ret
, arg1
);
631 TCGv_i32 t0
= tcg_const_i32(arg2
);
632 tcg_gen_shr_i32(ret
, arg1
, t0
);
633 tcg_temp_free_i32(t0
);
637 static inline void tcg_gen_sar_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
639 tcg_gen_op3_i32(INDEX_op_sar_i32
, ret
, arg1
, arg2
);
642 static inline void tcg_gen_sari_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
645 tcg_gen_mov_i32(ret
, arg1
);
647 TCGv_i32 t0
= tcg_const_i32(arg2
);
648 tcg_gen_sar_i32(ret
, arg1
, t0
);
649 tcg_temp_free_i32(t0
);
653 static inline void tcg_gen_brcond_i32(TCGCond cond
, TCGv_i32 arg1
,
654 TCGv_i32 arg2
, int label_index
)
656 if (cond
== TCG_COND_ALWAYS
) {
657 tcg_gen_br(label_index
);
658 } else if (cond
!= TCG_COND_NEVER
) {
659 tcg_gen_op4ii_i32(INDEX_op_brcond_i32
, arg1
, arg2
, cond
, label_index
);
663 static inline void tcg_gen_brcondi_i32(TCGCond cond
, TCGv_i32 arg1
,
664 int32_t arg2
, int label_index
)
666 if (cond
== TCG_COND_ALWAYS
) {
667 tcg_gen_br(label_index
);
668 } else if (cond
!= TCG_COND_NEVER
) {
669 TCGv_i32 t0
= tcg_const_i32(arg2
);
670 tcg_gen_brcond_i32(cond
, arg1
, t0
, label_index
);
671 tcg_temp_free_i32(t0
);
675 static inline void tcg_gen_setcond_i32(TCGCond cond
, TCGv_i32 ret
,
676 TCGv_i32 arg1
, TCGv_i32 arg2
)
678 if (cond
== TCG_COND_ALWAYS
) {
679 tcg_gen_movi_i32(ret
, 1);
680 } else if (cond
== TCG_COND_NEVER
) {
681 tcg_gen_movi_i32(ret
, 0);
683 tcg_gen_op4i_i32(INDEX_op_setcond_i32
, ret
, arg1
, arg2
, cond
);
687 static inline void tcg_gen_setcondi_i32(TCGCond cond
, TCGv_i32 ret
,
688 TCGv_i32 arg1
, int32_t arg2
)
690 if (cond
== TCG_COND_ALWAYS
) {
691 tcg_gen_movi_i32(ret
, 1);
692 } else if (cond
== TCG_COND_NEVER
) {
693 tcg_gen_movi_i32(ret
, 0);
695 TCGv_i32 t0
= tcg_const_i32(arg2
);
696 tcg_gen_setcond_i32(cond
, ret
, arg1
, t0
);
697 tcg_temp_free_i32(t0
);
701 static inline void tcg_gen_mul_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
703 tcg_gen_op3_i32(INDEX_op_mul_i32
, ret
, arg1
, arg2
);
706 static inline void tcg_gen_muli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
708 TCGv_i32 t0
= tcg_const_i32(arg2
);
709 tcg_gen_mul_i32(ret
, arg1
, t0
);
710 tcg_temp_free_i32(t0
);
713 static inline void tcg_gen_div_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
715 if (TCG_TARGET_HAS_div_i32
) {
716 tcg_gen_op3_i32(INDEX_op_div_i32
, ret
, arg1
, arg2
);
717 } else if (TCG_TARGET_HAS_div2_i32
) {
718 TCGv_i32 t0
= tcg_temp_new_i32();
719 tcg_gen_sari_i32(t0
, arg1
, 31);
720 tcg_gen_op5_i32(INDEX_op_div2_i32
, ret
, t0
, arg1
, t0
, arg2
);
721 tcg_temp_free_i32(t0
);
724 /* Return value and both arguments are 32-bit and signed. */
725 sizemask
|= tcg_gen_sizemask(0, 0, 1);
726 sizemask
|= tcg_gen_sizemask(1, 0, 1);
727 sizemask
|= tcg_gen_sizemask(2, 0, 1);
728 tcg_gen_helper32(tcg_helper_div_i32
, sizemask
, ret
, arg1
, arg2
);
732 static inline void tcg_gen_rem_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
734 if (TCG_TARGET_HAS_rem_i32
) {
735 tcg_gen_op3_i32(INDEX_op_rem_i32
, ret
, arg1
, arg2
);
736 } else if (TCG_TARGET_HAS_div_i32
) {
737 TCGv_i32 t0
= tcg_temp_new_i32();
738 tcg_gen_op3_i32(INDEX_op_div_i32
, t0
, arg1
, arg2
);
739 tcg_gen_mul_i32(t0
, t0
, arg2
);
740 tcg_gen_sub_i32(ret
, arg1
, t0
);
741 tcg_temp_free_i32(t0
);
742 } else if (TCG_TARGET_HAS_div2_i32
) {
743 TCGv_i32 t0
= tcg_temp_new_i32();
744 tcg_gen_sari_i32(t0
, arg1
, 31);
745 tcg_gen_op5_i32(INDEX_op_div2_i32
, t0
, ret
, arg1
, t0
, arg2
);
746 tcg_temp_free_i32(t0
);
749 /* Return value and both arguments are 32-bit and signed. */
750 sizemask
|= tcg_gen_sizemask(0, 0, 1);
751 sizemask
|= tcg_gen_sizemask(1, 0, 1);
752 sizemask
|= tcg_gen_sizemask(2, 0, 1);
753 tcg_gen_helper32(tcg_helper_rem_i32
, sizemask
, ret
, arg1
, arg2
);
757 static inline void tcg_gen_divu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
759 if (TCG_TARGET_HAS_div_i32
) {
760 tcg_gen_op3_i32(INDEX_op_divu_i32
, ret
, arg1
, arg2
);
761 } else if (TCG_TARGET_HAS_div2_i32
) {
762 TCGv_i32 t0
= tcg_temp_new_i32();
763 tcg_gen_movi_i32(t0
, 0);
764 tcg_gen_op5_i32(INDEX_op_divu2_i32
, ret
, t0
, arg1
, t0
, arg2
);
765 tcg_temp_free_i32(t0
);
768 /* Return value and both arguments are 32-bit and unsigned. */
769 sizemask
|= tcg_gen_sizemask(0, 0, 0);
770 sizemask
|= tcg_gen_sizemask(1, 0, 0);
771 sizemask
|= tcg_gen_sizemask(2, 0, 0);
772 tcg_gen_helper32(tcg_helper_divu_i32
, sizemask
, ret
, arg1
, arg2
);
776 static inline void tcg_gen_remu_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
778 if (TCG_TARGET_HAS_rem_i32
) {
779 tcg_gen_op3_i32(INDEX_op_remu_i32
, ret
, arg1
, arg2
);
780 } else if (TCG_TARGET_HAS_div_i32
) {
781 TCGv_i32 t0
= tcg_temp_new_i32();
782 tcg_gen_op3_i32(INDEX_op_divu_i32
, t0
, arg1
, arg2
);
783 tcg_gen_mul_i32(t0
, t0
, arg2
);
784 tcg_gen_sub_i32(ret
, arg1
, t0
);
785 tcg_temp_free_i32(t0
);
786 } else if (TCG_TARGET_HAS_div2_i32
) {
787 TCGv_i32 t0
= tcg_temp_new_i32();
788 tcg_gen_movi_i32(t0
, 0);
789 tcg_gen_op5_i32(INDEX_op_divu2_i32
, t0
, ret
, arg1
, t0
, arg2
);
790 tcg_temp_free_i32(t0
);
793 /* Return value and both arguments are 32-bit and unsigned. */
794 sizemask
|= tcg_gen_sizemask(0, 0, 0);
795 sizemask
|= tcg_gen_sizemask(1, 0, 0);
796 sizemask
|= tcg_gen_sizemask(2, 0, 0);
797 tcg_gen_helper32(tcg_helper_remu_i32
, sizemask
, ret
, arg1
, arg2
);
801 #if TCG_TARGET_REG_BITS == 32
803 static inline void tcg_gen_mov_i64(TCGv_i64 ret
, TCGv_i64 arg
)
805 if (!TCGV_EQUAL_I64(ret
, arg
)) {
806 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
807 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
811 static inline void tcg_gen_movi_i64(TCGv_i64 ret
, int64_t arg
)
813 tcg_gen_movi_i32(TCGV_LOW(ret
), arg
);
814 tcg_gen_movi_i32(TCGV_HIGH(ret
), arg
>> 32);
817 static inline void tcg_gen_ld8u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
818 tcg_target_long offset
)
820 tcg_gen_ld8u_i32(TCGV_LOW(ret
), arg2
, offset
);
821 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
824 static inline void tcg_gen_ld8s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
825 tcg_target_long offset
)
827 tcg_gen_ld8s_i32(TCGV_LOW(ret
), arg2
, offset
);
828 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_HIGH(ret
), 31);
831 static inline void tcg_gen_ld16u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
832 tcg_target_long offset
)
834 tcg_gen_ld16u_i32(TCGV_LOW(ret
), arg2
, offset
);
835 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
838 static inline void tcg_gen_ld16s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
839 tcg_target_long offset
)
841 tcg_gen_ld16s_i32(TCGV_LOW(ret
), arg2
, offset
);
842 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
845 static inline void tcg_gen_ld32u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
846 tcg_target_long offset
)
848 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
849 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
852 static inline void tcg_gen_ld32s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
853 tcg_target_long offset
)
855 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
856 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
859 static inline void tcg_gen_ld_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
860 tcg_target_long offset
)
862 /* since arg2 and ret have different types, they cannot be the
864 #ifdef TCG_TARGET_WORDS_BIGENDIAN
865 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
);
866 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
+ 4);
868 tcg_gen_ld_i32(TCGV_LOW(ret
), arg2
, offset
);
869 tcg_gen_ld_i32(TCGV_HIGH(ret
), arg2
, offset
+ 4);
873 static inline void tcg_gen_st8_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
874 tcg_target_long offset
)
876 tcg_gen_st8_i32(TCGV_LOW(arg1
), arg2
, offset
);
879 static inline void tcg_gen_st16_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
880 tcg_target_long offset
)
882 tcg_gen_st16_i32(TCGV_LOW(arg1
), arg2
, offset
);
885 static inline void tcg_gen_st32_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
886 tcg_target_long offset
)
888 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
);
891 static inline void tcg_gen_st_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
892 tcg_target_long offset
)
894 #ifdef TCG_TARGET_WORDS_BIGENDIAN
895 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
);
896 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
+ 4);
898 tcg_gen_st_i32(TCGV_LOW(arg1
), arg2
, offset
);
899 tcg_gen_st_i32(TCGV_HIGH(arg1
), arg2
, offset
+ 4);
903 static inline void tcg_gen_add_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
905 tcg_gen_op6_i32(INDEX_op_add2_i32
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
906 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
908 /* Allow the optimizer room to replace add2 with two moves. */
909 tcg_gen_op0(INDEX_op_nop
);
912 static inline void tcg_gen_sub_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
914 tcg_gen_op6_i32(INDEX_op_sub2_i32
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
915 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
917 /* Allow the optimizer room to replace sub2 with two moves. */
918 tcg_gen_op0(INDEX_op_nop
);
921 static inline void tcg_gen_and_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
923 tcg_gen_and_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
924 tcg_gen_and_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
927 static inline void tcg_gen_andi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
929 tcg_gen_andi_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
930 tcg_gen_andi_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
933 static inline void tcg_gen_or_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
935 tcg_gen_or_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
936 tcg_gen_or_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
939 static inline void tcg_gen_ori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
941 tcg_gen_ori_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
942 tcg_gen_ori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
945 static inline void tcg_gen_xor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
947 tcg_gen_xor_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
948 tcg_gen_xor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
951 static inline void tcg_gen_xori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
953 tcg_gen_xori_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), arg2
);
954 tcg_gen_xori_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), arg2
>> 32);
957 /* XXX: use generic code when basic block handling is OK or CPU
958 specific code (x86) */
959 static inline void tcg_gen_shl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
962 /* Return value and both arguments are 64-bit and signed. */
963 sizemask
|= tcg_gen_sizemask(0, 1, 1);
964 sizemask
|= tcg_gen_sizemask(1, 1, 1);
965 sizemask
|= tcg_gen_sizemask(2, 1, 1);
967 tcg_gen_helper64(tcg_helper_shl_i64
, sizemask
, ret
, arg1
, arg2
);
970 static inline void tcg_gen_shli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
972 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 0, 0);
975 static inline void tcg_gen_shr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
978 /* Return value and both arguments are 64-bit and signed. */
979 sizemask
|= tcg_gen_sizemask(0, 1, 1);
980 sizemask
|= tcg_gen_sizemask(1, 1, 1);
981 sizemask
|= tcg_gen_sizemask(2, 1, 1);
983 tcg_gen_helper64(tcg_helper_shr_i64
, sizemask
, ret
, arg1
, arg2
);
986 static inline void tcg_gen_shri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
988 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 0);
991 static inline void tcg_gen_sar_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
994 /* Return value and both arguments are 64-bit and signed. */
995 sizemask
|= tcg_gen_sizemask(0, 1, 1);
996 sizemask
|= tcg_gen_sizemask(1, 1, 1);
997 sizemask
|= tcg_gen_sizemask(2, 1, 1);
999 tcg_gen_helper64(tcg_helper_sar_i64
, sizemask
, ret
, arg1
, arg2
);
1002 static inline void tcg_gen_sari_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1004 tcg_gen_shifti_i64(ret
, arg1
, arg2
, 1, 1);
1007 static inline void tcg_gen_brcond_i64(TCGCond cond
, TCGv_i64 arg1
,
1008 TCGv_i64 arg2
, int label_index
)
1010 if (cond
== TCG_COND_ALWAYS
) {
1011 tcg_gen_br(label_index
);
1012 } else if (cond
!= TCG_COND_NEVER
) {
1013 tcg_gen_op6ii_i32(INDEX_op_brcond2_i32
,
1014 TCGV_LOW(arg1
), TCGV_HIGH(arg1
), TCGV_LOW(arg2
),
1015 TCGV_HIGH(arg2
), cond
, label_index
);
1019 static inline void tcg_gen_setcond_i64(TCGCond cond
, TCGv_i64 ret
,
1020 TCGv_i64 arg1
, TCGv_i64 arg2
)
1022 if (cond
== TCG_COND_ALWAYS
) {
1023 tcg_gen_movi_i32(TCGV_LOW(ret
), 1);
1024 } else if (cond
== TCG_COND_NEVER
) {
1025 tcg_gen_movi_i32(TCGV_LOW(ret
), 0);
1027 tcg_gen_op6i_i32(INDEX_op_setcond2_i32
, TCGV_LOW(ret
),
1028 TCGV_LOW(arg1
), TCGV_HIGH(arg1
),
1029 TCGV_LOW(arg2
), TCGV_HIGH(arg2
), cond
);
1031 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1034 static inline void tcg_gen_mul_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1039 t0
= tcg_temp_new_i64();
1040 t1
= tcg_temp_new_i32();
1042 tcg_gen_op4_i32(INDEX_op_mulu2_i32
, TCGV_LOW(t0
), TCGV_HIGH(t0
),
1043 TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1044 /* Allow the optimizer room to replace mulu2 with two moves. */
1045 tcg_gen_op0(INDEX_op_nop
);
1047 tcg_gen_mul_i32(t1
, TCGV_LOW(arg1
), TCGV_HIGH(arg2
));
1048 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
1049 tcg_gen_mul_i32(t1
, TCGV_HIGH(arg1
), TCGV_LOW(arg2
));
1050 tcg_gen_add_i32(TCGV_HIGH(t0
), TCGV_HIGH(t0
), t1
);
1052 tcg_gen_mov_i64(ret
, t0
);
1053 tcg_temp_free_i64(t0
);
1054 tcg_temp_free_i32(t1
);
1057 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1060 /* Return value and both arguments are 64-bit and signed. */
1061 sizemask
|= tcg_gen_sizemask(0, 1, 1);
1062 sizemask
|= tcg_gen_sizemask(1, 1, 1);
1063 sizemask
|= tcg_gen_sizemask(2, 1, 1);
1065 tcg_gen_helper64(tcg_helper_div_i64
, sizemask
, ret
, arg1
, arg2
);
1068 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1071 /* Return value and both arguments are 64-bit and signed. */
1072 sizemask
|= tcg_gen_sizemask(0, 1, 1);
1073 sizemask
|= tcg_gen_sizemask(1, 1, 1);
1074 sizemask
|= tcg_gen_sizemask(2, 1, 1);
1076 tcg_gen_helper64(tcg_helper_rem_i64
, sizemask
, ret
, arg1
, arg2
);
1079 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1082 /* Return value and both arguments are 64-bit and unsigned. */
1083 sizemask
|= tcg_gen_sizemask(0, 1, 0);
1084 sizemask
|= tcg_gen_sizemask(1, 1, 0);
1085 sizemask
|= tcg_gen_sizemask(2, 1, 0);
1087 tcg_gen_helper64(tcg_helper_divu_i64
, sizemask
, ret
, arg1
, arg2
);
1090 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1093 /* Return value and both arguments are 64-bit and unsigned. */
1094 sizemask
|= tcg_gen_sizemask(0, 1, 0);
1095 sizemask
|= tcg_gen_sizemask(1, 1, 0);
1096 sizemask
|= tcg_gen_sizemask(2, 1, 0);
1098 tcg_gen_helper64(tcg_helper_remu_i64
, sizemask
, ret
, arg1
, arg2
);
1103 static inline void tcg_gen_mov_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1105 if (!TCGV_EQUAL_I64(ret
, arg
))
1106 tcg_gen_op2_i64(INDEX_op_mov_i64
, ret
, arg
);
1109 static inline void tcg_gen_movi_i64(TCGv_i64 ret
, int64_t arg
)
1111 tcg_gen_op2i_i64(INDEX_op_movi_i64
, ret
, arg
);
1114 static inline void tcg_gen_ld8u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1115 tcg_target_long offset
)
1117 tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64
, ret
, arg2
, offset
);
1120 static inline void tcg_gen_ld8s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1121 tcg_target_long offset
)
1123 tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64
, ret
, arg2
, offset
);
1126 static inline void tcg_gen_ld16u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1127 tcg_target_long offset
)
1129 tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64
, ret
, arg2
, offset
);
1132 static inline void tcg_gen_ld16s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1133 tcg_target_long offset
)
1135 tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64
, ret
, arg2
, offset
);
1138 static inline void tcg_gen_ld32u_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1139 tcg_target_long offset
)
1141 tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64
, ret
, arg2
, offset
);
1144 static inline void tcg_gen_ld32s_i64(TCGv_i64 ret
, TCGv_ptr arg2
,
1145 tcg_target_long offset
)
1147 tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64
, ret
, arg2
, offset
);
1150 static inline void tcg_gen_ld_i64(TCGv_i64 ret
, TCGv_ptr arg2
, tcg_target_long offset
)
1152 tcg_gen_ldst_op_i64(INDEX_op_ld_i64
, ret
, arg2
, offset
);
1155 static inline void tcg_gen_st8_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
1156 tcg_target_long offset
)
1158 tcg_gen_ldst_op_i64(INDEX_op_st8_i64
, arg1
, arg2
, offset
);
1161 static inline void tcg_gen_st16_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
1162 tcg_target_long offset
)
1164 tcg_gen_ldst_op_i64(INDEX_op_st16_i64
, arg1
, arg2
, offset
);
1167 static inline void tcg_gen_st32_i64(TCGv_i64 arg1
, TCGv_ptr arg2
,
1168 tcg_target_long offset
)
1170 tcg_gen_ldst_op_i64(INDEX_op_st32_i64
, arg1
, arg2
, offset
);
1173 static inline void tcg_gen_st_i64(TCGv_i64 arg1
, TCGv_ptr arg2
, tcg_target_long offset
)
1175 tcg_gen_ldst_op_i64(INDEX_op_st_i64
, arg1
, arg2
, offset
);
1178 static inline void tcg_gen_add_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1180 tcg_gen_op3_i64(INDEX_op_add_i64
, ret
, arg1
, arg2
);
1183 static inline void tcg_gen_sub_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1185 tcg_gen_op3_i64(INDEX_op_sub_i64
, ret
, arg1
, arg2
);
1188 static inline void tcg_gen_and_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1190 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1191 tcg_gen_mov_i64(ret
, arg1
);
1193 tcg_gen_op3_i64(INDEX_op_and_i64
, ret
, arg1
, arg2
);
1197 static inline void tcg_gen_andi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, uint64_t arg2
)
1200 /* Some cases can be optimized here. */
1203 tcg_gen_movi_i64(ret
, 0);
1205 case 0xffffffffffffffffull
:
1206 tcg_gen_mov_i64(ret
, arg1
);
1209 /* Don't recurse with tcg_gen_ext8u_i32. */
1210 if (TCG_TARGET_HAS_ext8u_i64
) {
1211 tcg_gen_op2_i64(INDEX_op_ext8u_i64
, ret
, arg1
);
1216 if (TCG_TARGET_HAS_ext16u_i64
) {
1217 tcg_gen_op2_i64(INDEX_op_ext16u_i64
, ret
, arg1
);
1222 if (TCG_TARGET_HAS_ext32u_i64
) {
1223 tcg_gen_op2_i64(INDEX_op_ext32u_i64
, ret
, arg1
);
1228 t0
= tcg_const_i64(arg2
);
1229 tcg_gen_and_i64(ret
, arg1
, t0
);
1230 tcg_temp_free_i64(t0
);
1233 static inline void tcg_gen_or_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1235 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1236 tcg_gen_mov_i64(ret
, arg1
);
1238 tcg_gen_op3_i64(INDEX_op_or_i64
, ret
, arg1
, arg2
);
1242 static inline void tcg_gen_ori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1244 /* Some cases can be optimized here. */
1246 tcg_gen_movi_i64(ret
, -1);
1247 } else if (arg2
== 0) {
1248 tcg_gen_mov_i64(ret
, arg1
);
1250 TCGv_i64 t0
= tcg_const_i64(arg2
);
1251 tcg_gen_or_i64(ret
, arg1
, t0
);
1252 tcg_temp_free_i64(t0
);
1256 static inline void tcg_gen_xor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1258 if (TCGV_EQUAL_I64(arg1
, arg2
)) {
1259 tcg_gen_movi_i64(ret
, 0);
1261 tcg_gen_op3_i64(INDEX_op_xor_i64
, ret
, arg1
, arg2
);
1265 static inline void tcg_gen_xori_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1267 /* Some cases can be optimized here. */
1269 tcg_gen_mov_i64(ret
, arg1
);
1270 } else if (arg2
== -1 && TCG_TARGET_HAS_not_i64
) {
1271 /* Don't recurse with tcg_gen_not_i64. */
1272 tcg_gen_op2_i64(INDEX_op_not_i64
, ret
, arg1
);
1274 TCGv_i64 t0
= tcg_const_i64(arg2
);
1275 tcg_gen_xor_i64(ret
, arg1
, t0
);
1276 tcg_temp_free_i64(t0
);
1280 static inline void tcg_gen_shl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1282 tcg_gen_op3_i64(INDEX_op_shl_i64
, ret
, arg1
, arg2
);
1285 static inline void tcg_gen_shli_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_shl_i64(ret
, arg1
, t0
);
1292 tcg_temp_free_i64(t0
);
1296 static inline void tcg_gen_shr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1298 tcg_gen_op3_i64(INDEX_op_shr_i64
, ret
, arg1
, arg2
);
1301 static inline void tcg_gen_shri_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_shr_i64(ret
, arg1
, t0
);
1308 tcg_temp_free_i64(t0
);
1312 static inline void tcg_gen_sar_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1314 tcg_gen_op3_i64(INDEX_op_sar_i64
, ret
, arg1
, arg2
);
1317 static inline void tcg_gen_sari_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1320 tcg_gen_mov_i64(ret
, arg1
);
1322 TCGv_i64 t0
= tcg_const_i64(arg2
);
1323 tcg_gen_sar_i64(ret
, arg1
, t0
);
1324 tcg_temp_free_i64(t0
);
1328 static inline void tcg_gen_brcond_i64(TCGCond cond
, TCGv_i64 arg1
,
1329 TCGv_i64 arg2
, int label_index
)
1331 if (cond
== TCG_COND_ALWAYS
) {
1332 tcg_gen_br(label_index
);
1333 } else if (cond
!= TCG_COND_NEVER
) {
1334 tcg_gen_op4ii_i64(INDEX_op_brcond_i64
, arg1
, arg2
, cond
, label_index
);
1338 static inline void tcg_gen_setcond_i64(TCGCond cond
, TCGv_i64 ret
,
1339 TCGv_i64 arg1
, TCGv_i64 arg2
)
1341 if (cond
== TCG_COND_ALWAYS
) {
1342 tcg_gen_movi_i64(ret
, 1);
1343 } else if (cond
== TCG_COND_NEVER
) {
1344 tcg_gen_movi_i64(ret
, 0);
1346 tcg_gen_op4i_i64(INDEX_op_setcond_i64
, ret
, arg1
, arg2
, cond
);
1350 static inline void tcg_gen_mul_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1352 tcg_gen_op3_i64(INDEX_op_mul_i64
, ret
, arg1
, arg2
);
1355 static inline void tcg_gen_div_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1357 if (TCG_TARGET_HAS_div_i64
) {
1358 tcg_gen_op3_i64(INDEX_op_div_i64
, ret
, arg1
, arg2
);
1359 } else if (TCG_TARGET_HAS_div2_i64
) {
1360 TCGv_i64 t0
= tcg_temp_new_i64();
1361 tcg_gen_sari_i64(t0
, arg1
, 63);
1362 tcg_gen_op5_i64(INDEX_op_div2_i64
, ret
, t0
, arg1
, t0
, arg2
);
1363 tcg_temp_free_i64(t0
);
1366 /* Return value and both arguments are 64-bit and signed. */
1367 sizemask
|= tcg_gen_sizemask(0, 1, 1);
1368 sizemask
|= tcg_gen_sizemask(1, 1, 1);
1369 sizemask
|= tcg_gen_sizemask(2, 1, 1);
1370 tcg_gen_helper64(tcg_helper_div_i64
, sizemask
, ret
, arg1
, arg2
);
1374 static inline void tcg_gen_rem_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1376 if (TCG_TARGET_HAS_rem_i64
) {
1377 tcg_gen_op3_i64(INDEX_op_rem_i64
, ret
, arg1
, arg2
);
1378 } else if (TCG_TARGET_HAS_div_i64
) {
1379 TCGv_i64 t0
= tcg_temp_new_i64();
1380 tcg_gen_op3_i64(INDEX_op_div_i64
, t0
, arg1
, arg2
);
1381 tcg_gen_mul_i64(t0
, t0
, arg2
);
1382 tcg_gen_sub_i64(ret
, arg1
, t0
);
1383 tcg_temp_free_i64(t0
);
1384 } else if (TCG_TARGET_HAS_div2_i64
) {
1385 TCGv_i64 t0
= tcg_temp_new_i64();
1386 tcg_gen_sari_i64(t0
, arg1
, 63);
1387 tcg_gen_op5_i64(INDEX_op_div2_i64
, t0
, ret
, arg1
, t0
, arg2
);
1388 tcg_temp_free_i64(t0
);
1391 /* Return value and both arguments are 64-bit and signed. */
1392 sizemask
|= tcg_gen_sizemask(0, 1, 1);
1393 sizemask
|= tcg_gen_sizemask(1, 1, 1);
1394 sizemask
|= tcg_gen_sizemask(2, 1, 1);
1395 tcg_gen_helper64(tcg_helper_rem_i64
, sizemask
, ret
, arg1
, arg2
);
1399 static inline void tcg_gen_divu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1401 if (TCG_TARGET_HAS_div_i64
) {
1402 tcg_gen_op3_i64(INDEX_op_divu_i64
, ret
, arg1
, arg2
);
1403 } else if (TCG_TARGET_HAS_div2_i64
) {
1404 TCGv_i64 t0
= tcg_temp_new_i64();
1405 tcg_gen_movi_i64(t0
, 0);
1406 tcg_gen_op5_i64(INDEX_op_divu2_i64
, ret
, t0
, arg1
, t0
, arg2
);
1407 tcg_temp_free_i64(t0
);
1410 /* Return value and both arguments are 64-bit and unsigned. */
1411 sizemask
|= tcg_gen_sizemask(0, 1, 0);
1412 sizemask
|= tcg_gen_sizemask(1, 1, 0);
1413 sizemask
|= tcg_gen_sizemask(2, 1, 0);
1414 tcg_gen_helper64(tcg_helper_divu_i64
, sizemask
, ret
, arg1
, arg2
);
1418 static inline void tcg_gen_remu_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1420 if (TCG_TARGET_HAS_rem_i64
) {
1421 tcg_gen_op3_i64(INDEX_op_remu_i64
, ret
, arg1
, arg2
);
1422 } else if (TCG_TARGET_HAS_div_i64
) {
1423 TCGv_i64 t0
= tcg_temp_new_i64();
1424 tcg_gen_op3_i64(INDEX_op_divu_i64
, t0
, arg1
, arg2
);
1425 tcg_gen_mul_i64(t0
, t0
, arg2
);
1426 tcg_gen_sub_i64(ret
, arg1
, t0
);
1427 tcg_temp_free_i64(t0
);
1428 } else if (TCG_TARGET_HAS_div2_i64
) {
1429 TCGv_i64 t0
= tcg_temp_new_i64();
1430 tcg_gen_movi_i64(t0
, 0);
1431 tcg_gen_op5_i64(INDEX_op_divu2_i64
, t0
, ret
, arg1
, t0
, arg2
);
1432 tcg_temp_free_i64(t0
);
1435 /* Return value and both arguments are 64-bit and unsigned. */
1436 sizemask
|= tcg_gen_sizemask(0, 1, 0);
1437 sizemask
|= tcg_gen_sizemask(1, 1, 0);
1438 sizemask
|= tcg_gen_sizemask(2, 1, 0);
1439 tcg_gen_helper64(tcg_helper_remu_i64
, sizemask
, ret
, arg1
, arg2
);
1442 #endif /* TCG_TARGET_REG_BITS == 32 */
1444 static inline void tcg_gen_addi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1446 /* some cases can be optimized here */
1448 tcg_gen_mov_i64(ret
, arg1
);
1450 TCGv_i64 t0
= tcg_const_i64(arg2
);
1451 tcg_gen_add_i64(ret
, arg1
, t0
);
1452 tcg_temp_free_i64(t0
);
1456 static inline void tcg_gen_subfi_i64(TCGv_i64 ret
, int64_t arg1
, TCGv_i64 arg2
)
1458 TCGv_i64 t0
= tcg_const_i64(arg1
);
1459 tcg_gen_sub_i64(ret
, t0
, arg2
);
1460 tcg_temp_free_i64(t0
);
1463 static inline void tcg_gen_subi_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1465 /* some cases can be optimized here */
1467 tcg_gen_mov_i64(ret
, arg1
);
1469 TCGv_i64 t0
= tcg_const_i64(arg2
);
1470 tcg_gen_sub_i64(ret
, arg1
, t0
);
1471 tcg_temp_free_i64(t0
);
1474 static inline void tcg_gen_brcondi_i64(TCGCond cond
, TCGv_i64 arg1
,
1475 int64_t arg2
, int label_index
)
1477 if (cond
== TCG_COND_ALWAYS
) {
1478 tcg_gen_br(label_index
);
1479 } else if (cond
!= TCG_COND_NEVER
) {
1480 TCGv_i64 t0
= tcg_const_i64(arg2
);
1481 tcg_gen_brcond_i64(cond
, arg1
, t0
, label_index
);
1482 tcg_temp_free_i64(t0
);
1486 static inline void tcg_gen_setcondi_i64(TCGCond cond
, TCGv_i64 ret
,
1487 TCGv_i64 arg1
, int64_t arg2
)
1489 TCGv_i64 t0
= tcg_const_i64(arg2
);
1490 tcg_gen_setcond_i64(cond
, ret
, arg1
, t0
);
1491 tcg_temp_free_i64(t0
);
1494 static inline void tcg_gen_muli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
1496 TCGv_i64 t0
= tcg_const_i64(arg2
);
1497 tcg_gen_mul_i64(ret
, arg1
, t0
);
1498 tcg_temp_free_i64(t0
);
1502 /***************************************/
1503 /* optional operations */
1505 static inline void tcg_gen_ext8s_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1507 if (TCG_TARGET_HAS_ext8s_i32
) {
1508 tcg_gen_op2_i32(INDEX_op_ext8s_i32
, ret
, arg
);
1510 tcg_gen_shli_i32(ret
, arg
, 24);
1511 tcg_gen_sari_i32(ret
, ret
, 24);
1515 static inline void tcg_gen_ext16s_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1517 if (TCG_TARGET_HAS_ext16s_i32
) {
1518 tcg_gen_op2_i32(INDEX_op_ext16s_i32
, ret
, arg
);
1520 tcg_gen_shli_i32(ret
, arg
, 16);
1521 tcg_gen_sari_i32(ret
, ret
, 16);
1525 static inline void tcg_gen_ext8u_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1527 if (TCG_TARGET_HAS_ext8u_i32
) {
1528 tcg_gen_op2_i32(INDEX_op_ext8u_i32
, ret
, arg
);
1530 tcg_gen_andi_i32(ret
, arg
, 0xffu
);
1534 static inline void tcg_gen_ext16u_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1536 if (TCG_TARGET_HAS_ext16u_i32
) {
1537 tcg_gen_op2_i32(INDEX_op_ext16u_i32
, ret
, arg
);
1539 tcg_gen_andi_i32(ret
, arg
, 0xffffu
);
1543 /* Note: we assume the two high bytes are set to zero */
1544 static inline void tcg_gen_bswap16_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1546 if (TCG_TARGET_HAS_bswap16_i32
) {
1547 tcg_gen_op2_i32(INDEX_op_bswap16_i32
, ret
, arg
);
1549 TCGv_i32 t0
= tcg_temp_new_i32();
1551 tcg_gen_ext8u_i32(t0
, arg
);
1552 tcg_gen_shli_i32(t0
, t0
, 8);
1553 tcg_gen_shri_i32(ret
, arg
, 8);
1554 tcg_gen_or_i32(ret
, ret
, t0
);
1555 tcg_temp_free_i32(t0
);
1559 static inline void tcg_gen_bswap32_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1561 if (TCG_TARGET_HAS_bswap32_i32
) {
1562 tcg_gen_op2_i32(INDEX_op_bswap32_i32
, ret
, arg
);
1565 t0
= tcg_temp_new_i32();
1566 t1
= tcg_temp_new_i32();
1568 tcg_gen_shli_i32(t0
, arg
, 24);
1570 tcg_gen_andi_i32(t1
, arg
, 0x0000ff00);
1571 tcg_gen_shli_i32(t1
, t1
, 8);
1572 tcg_gen_or_i32(t0
, t0
, t1
);
1574 tcg_gen_shri_i32(t1
, arg
, 8);
1575 tcg_gen_andi_i32(t1
, t1
, 0x0000ff00);
1576 tcg_gen_or_i32(t0
, t0
, t1
);
1578 tcg_gen_shri_i32(t1
, arg
, 24);
1579 tcg_gen_or_i32(ret
, t0
, t1
);
1580 tcg_temp_free_i32(t0
);
1581 tcg_temp_free_i32(t1
);
1585 #if TCG_TARGET_REG_BITS == 32
1586 static inline void tcg_gen_ext8s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1588 tcg_gen_ext8s_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1589 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1592 static inline void tcg_gen_ext16s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1594 tcg_gen_ext16s_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1595 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1598 static inline void tcg_gen_ext32s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1600 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1601 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1604 static inline void tcg_gen_ext8u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1606 tcg_gen_ext8u_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1607 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1610 static inline void tcg_gen_ext16u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1612 tcg_gen_ext16u_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1613 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1616 static inline void tcg_gen_ext32u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1618 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1619 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1622 static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret
, TCGv_i64 arg
)
1624 tcg_gen_mov_i32(ret
, TCGV_LOW(arg
));
1627 static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1629 tcg_gen_mov_i32(TCGV_LOW(ret
), arg
);
1630 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
1633 static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1635 tcg_gen_mov_i32(TCGV_LOW(ret
), arg
);
1636 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
1639 /* Note: we assume the six high bytes are set to zero */
1640 static inline void tcg_gen_bswap16_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1642 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1643 tcg_gen_bswap16_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1646 /* Note: we assume the four high bytes are set to zero */
1647 static inline void tcg_gen_bswap32_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1649 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1650 tcg_gen_bswap32_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1653 static inline void tcg_gen_bswap64_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1656 t0
= tcg_temp_new_i32();
1657 t1
= tcg_temp_new_i32();
1659 tcg_gen_bswap32_i32(t0
, TCGV_LOW(arg
));
1660 tcg_gen_bswap32_i32(t1
, TCGV_HIGH(arg
));
1661 tcg_gen_mov_i32(TCGV_LOW(ret
), t1
);
1662 tcg_gen_mov_i32(TCGV_HIGH(ret
), t0
);
1663 tcg_temp_free_i32(t0
);
1664 tcg_temp_free_i32(t1
);
1668 static inline void tcg_gen_ext8s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1670 if (TCG_TARGET_HAS_ext8s_i64
) {
1671 tcg_gen_op2_i64(INDEX_op_ext8s_i64
, ret
, arg
);
1673 tcg_gen_shli_i64(ret
, arg
, 56);
1674 tcg_gen_sari_i64(ret
, ret
, 56);
1678 static inline void tcg_gen_ext16s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1680 if (TCG_TARGET_HAS_ext16s_i64
) {
1681 tcg_gen_op2_i64(INDEX_op_ext16s_i64
, ret
, arg
);
1683 tcg_gen_shli_i64(ret
, arg
, 48);
1684 tcg_gen_sari_i64(ret
, ret
, 48);
1688 static inline void tcg_gen_ext32s_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1690 if (TCG_TARGET_HAS_ext32s_i64
) {
1691 tcg_gen_op2_i64(INDEX_op_ext32s_i64
, ret
, arg
);
1693 tcg_gen_shli_i64(ret
, arg
, 32);
1694 tcg_gen_sari_i64(ret
, ret
, 32);
1698 static inline void tcg_gen_ext8u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1700 if (TCG_TARGET_HAS_ext8u_i64
) {
1701 tcg_gen_op2_i64(INDEX_op_ext8u_i64
, ret
, arg
);
1703 tcg_gen_andi_i64(ret
, arg
, 0xffu
);
1707 static inline void tcg_gen_ext16u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1709 if (TCG_TARGET_HAS_ext16u_i64
) {
1710 tcg_gen_op2_i64(INDEX_op_ext16u_i64
, ret
, arg
);
1712 tcg_gen_andi_i64(ret
, arg
, 0xffffu
);
1716 static inline void tcg_gen_ext32u_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1718 if (TCG_TARGET_HAS_ext32u_i64
) {
1719 tcg_gen_op2_i64(INDEX_op_ext32u_i64
, ret
, arg
);
1721 tcg_gen_andi_i64(ret
, arg
, 0xffffffffu
);
1725 /* Note: we assume the target supports move between 32 and 64 bit
1726 registers. This will probably break MIPS64 targets. */
1727 static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret
, TCGv_i64 arg
)
1729 tcg_gen_mov_i32(ret
, MAKE_TCGV_I32(GET_TCGV_I64(arg
)));
1732 /* Note: we assume the target supports move between 32 and 64 bit
1734 static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1736 tcg_gen_ext32u_i64(ret
, MAKE_TCGV_I64(GET_TCGV_I32(arg
)));
1739 /* Note: we assume the target supports move between 32 and 64 bit
1741 static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret
, TCGv_i32 arg
)
1743 tcg_gen_ext32s_i64(ret
, MAKE_TCGV_I64(GET_TCGV_I32(arg
)));
1746 /* Note: we assume the six high bytes are set to zero */
1747 static inline void tcg_gen_bswap16_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1749 if (TCG_TARGET_HAS_bswap16_i64
) {
1750 tcg_gen_op2_i64(INDEX_op_bswap16_i64
, ret
, arg
);
1752 TCGv_i64 t0
= tcg_temp_new_i64();
1754 tcg_gen_ext8u_i64(t0
, arg
);
1755 tcg_gen_shli_i64(t0
, t0
, 8);
1756 tcg_gen_shri_i64(ret
, arg
, 8);
1757 tcg_gen_or_i64(ret
, ret
, t0
);
1758 tcg_temp_free_i64(t0
);
1762 /* Note: we assume the four high bytes are set to zero */
1763 static inline void tcg_gen_bswap32_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1765 if (TCG_TARGET_HAS_bswap32_i64
) {
1766 tcg_gen_op2_i64(INDEX_op_bswap32_i64
, ret
, arg
);
1769 t0
= tcg_temp_new_i64();
1770 t1
= tcg_temp_new_i64();
1772 tcg_gen_shli_i64(t0
, arg
, 24);
1773 tcg_gen_ext32u_i64(t0
, t0
);
1775 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1776 tcg_gen_shli_i64(t1
, t1
, 8);
1777 tcg_gen_or_i64(t0
, t0
, t1
);
1779 tcg_gen_shri_i64(t1
, arg
, 8);
1780 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1781 tcg_gen_or_i64(t0
, t0
, t1
);
1783 tcg_gen_shri_i64(t1
, arg
, 24);
1784 tcg_gen_or_i64(ret
, t0
, t1
);
1785 tcg_temp_free_i64(t0
);
1786 tcg_temp_free_i64(t1
);
1790 static inline void tcg_gen_bswap64_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1792 if (TCG_TARGET_HAS_bswap64_i64
) {
1793 tcg_gen_op2_i64(INDEX_op_bswap64_i64
, ret
, arg
);
1795 TCGv_i64 t0
= tcg_temp_new_i64();
1796 TCGv_i64 t1
= tcg_temp_new_i64();
1798 tcg_gen_shli_i64(t0
, arg
, 56);
1800 tcg_gen_andi_i64(t1
, arg
, 0x0000ff00);
1801 tcg_gen_shli_i64(t1
, t1
, 40);
1802 tcg_gen_or_i64(t0
, t0
, t1
);
1804 tcg_gen_andi_i64(t1
, arg
, 0x00ff0000);
1805 tcg_gen_shli_i64(t1
, t1
, 24);
1806 tcg_gen_or_i64(t0
, t0
, t1
);
1808 tcg_gen_andi_i64(t1
, arg
, 0xff000000);
1809 tcg_gen_shli_i64(t1
, t1
, 8);
1810 tcg_gen_or_i64(t0
, t0
, t1
);
1812 tcg_gen_shri_i64(t1
, arg
, 8);
1813 tcg_gen_andi_i64(t1
, t1
, 0xff000000);
1814 tcg_gen_or_i64(t0
, t0
, t1
);
1816 tcg_gen_shri_i64(t1
, arg
, 24);
1817 tcg_gen_andi_i64(t1
, t1
, 0x00ff0000);
1818 tcg_gen_or_i64(t0
, t0
, t1
);
1820 tcg_gen_shri_i64(t1
, arg
, 40);
1821 tcg_gen_andi_i64(t1
, t1
, 0x0000ff00);
1822 tcg_gen_or_i64(t0
, t0
, t1
);
1824 tcg_gen_shri_i64(t1
, arg
, 56);
1825 tcg_gen_or_i64(ret
, t0
, t1
);
1826 tcg_temp_free_i64(t0
);
1827 tcg_temp_free_i64(t1
);
1833 static inline void tcg_gen_neg_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1835 if (TCG_TARGET_HAS_neg_i32
) {
1836 tcg_gen_op2_i32(INDEX_op_neg_i32
, ret
, arg
);
1838 TCGv_i32 t0
= tcg_const_i32(0);
1839 tcg_gen_sub_i32(ret
, t0
, arg
);
1840 tcg_temp_free_i32(t0
);
1844 static inline void tcg_gen_neg_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1846 if (TCG_TARGET_HAS_neg_i64
) {
1847 tcg_gen_op2_i64(INDEX_op_neg_i64
, ret
, arg
);
1849 TCGv_i64 t0
= tcg_const_i64(0);
1850 tcg_gen_sub_i64(ret
, t0
, arg
);
1851 tcg_temp_free_i64(t0
);
1855 static inline void tcg_gen_not_i32(TCGv_i32 ret
, TCGv_i32 arg
)
1857 if (TCG_TARGET_HAS_not_i32
) {
1858 tcg_gen_op2_i32(INDEX_op_not_i32
, ret
, arg
);
1860 tcg_gen_xori_i32(ret
, arg
, -1);
1864 static inline void tcg_gen_not_i64(TCGv_i64 ret
, TCGv_i64 arg
)
1866 #if TCG_TARGET_REG_BITS == 64
1867 if (TCG_TARGET_HAS_not_i64
) {
1868 tcg_gen_op2_i64(INDEX_op_not_i64
, ret
, arg
);
1870 tcg_gen_xori_i64(ret
, arg
, -1);
1873 tcg_gen_not_i32(TCGV_LOW(ret
), TCGV_LOW(arg
));
1874 tcg_gen_not_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg
));
1878 static inline void tcg_gen_discard_i32(TCGv_i32 arg
)
1880 tcg_gen_op1_i32(INDEX_op_discard
, arg
);
1883 static inline void tcg_gen_discard_i64(TCGv_i64 arg
)
1885 #if TCG_TARGET_REG_BITS == 32
1886 tcg_gen_discard_i32(TCGV_LOW(arg
));
1887 tcg_gen_discard_i32(TCGV_HIGH(arg
));
1889 tcg_gen_op1_i64(INDEX_op_discard
, arg
);
1893 static inline void tcg_gen_andc_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1895 if (TCG_TARGET_HAS_andc_i32
) {
1896 tcg_gen_op3_i32(INDEX_op_andc_i32
, ret
, arg1
, arg2
);
1898 TCGv_i32 t0
= tcg_temp_new_i32();
1899 tcg_gen_not_i32(t0
, arg2
);
1900 tcg_gen_and_i32(ret
, arg1
, t0
);
1901 tcg_temp_free_i32(t0
);
1905 static inline void tcg_gen_andc_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1907 #if TCG_TARGET_REG_BITS == 64
1908 if (TCG_TARGET_HAS_andc_i64
) {
1909 tcg_gen_op3_i64(INDEX_op_andc_i64
, ret
, arg1
, arg2
);
1911 TCGv_i64 t0
= tcg_temp_new_i64();
1912 tcg_gen_not_i64(t0
, arg2
);
1913 tcg_gen_and_i64(ret
, arg1
, t0
);
1914 tcg_temp_free_i64(t0
);
1917 tcg_gen_andc_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1918 tcg_gen_andc_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1922 static inline void tcg_gen_eqv_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1924 if (TCG_TARGET_HAS_eqv_i32
) {
1925 tcg_gen_op3_i32(INDEX_op_eqv_i32
, ret
, arg1
, arg2
);
1927 tcg_gen_xor_i32(ret
, arg1
, arg2
);
1928 tcg_gen_not_i32(ret
, ret
);
1932 static inline void tcg_gen_eqv_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1934 #if TCG_TARGET_REG_BITS == 64
1935 if (TCG_TARGET_HAS_eqv_i64
) {
1936 tcg_gen_op3_i64(INDEX_op_eqv_i64
, ret
, arg1
, arg2
);
1938 tcg_gen_xor_i64(ret
, arg1
, arg2
);
1939 tcg_gen_not_i64(ret
, ret
);
1942 tcg_gen_eqv_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1943 tcg_gen_eqv_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1947 static inline void tcg_gen_nand_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1949 if (TCG_TARGET_HAS_nand_i32
) {
1950 tcg_gen_op3_i32(INDEX_op_nand_i32
, ret
, arg1
, arg2
);
1952 tcg_gen_and_i32(ret
, arg1
, arg2
);
1953 tcg_gen_not_i32(ret
, ret
);
1957 static inline void tcg_gen_nand_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1959 #if TCG_TARGET_REG_BITS == 64
1960 if (TCG_TARGET_HAS_nand_i64
) {
1961 tcg_gen_op3_i64(INDEX_op_nand_i64
, ret
, arg1
, arg2
);
1963 tcg_gen_and_i64(ret
, arg1
, arg2
);
1964 tcg_gen_not_i64(ret
, ret
);
1967 tcg_gen_nand_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1968 tcg_gen_nand_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1972 static inline void tcg_gen_nor_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1974 if (TCG_TARGET_HAS_nor_i32
) {
1975 tcg_gen_op3_i32(INDEX_op_nor_i32
, ret
, arg1
, arg2
);
1977 tcg_gen_or_i32(ret
, arg1
, arg2
);
1978 tcg_gen_not_i32(ret
, ret
);
1982 static inline void tcg_gen_nor_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
1984 #if TCG_TARGET_REG_BITS == 64
1985 if (TCG_TARGET_HAS_nor_i64
) {
1986 tcg_gen_op3_i64(INDEX_op_nor_i64
, ret
, arg1
, arg2
);
1988 tcg_gen_or_i64(ret
, arg1
, arg2
);
1989 tcg_gen_not_i64(ret
, ret
);
1992 tcg_gen_nor_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
1993 tcg_gen_nor_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
1997 static inline void tcg_gen_orc_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
1999 if (TCG_TARGET_HAS_orc_i32
) {
2000 tcg_gen_op3_i32(INDEX_op_orc_i32
, ret
, arg1
, arg2
);
2002 TCGv_i32 t0
= tcg_temp_new_i32();
2003 tcg_gen_not_i32(t0
, arg2
);
2004 tcg_gen_or_i32(ret
, arg1
, t0
);
2005 tcg_temp_free_i32(t0
);
2009 static inline void tcg_gen_orc_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
2011 #if TCG_TARGET_REG_BITS == 64
2012 if (TCG_TARGET_HAS_orc_i64
) {
2013 tcg_gen_op3_i64(INDEX_op_orc_i64
, ret
, arg1
, arg2
);
2015 TCGv_i64 t0
= tcg_temp_new_i64();
2016 tcg_gen_not_i64(t0
, arg2
);
2017 tcg_gen_or_i64(ret
, arg1
, t0
);
2018 tcg_temp_free_i64(t0
);
2021 tcg_gen_orc_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
), TCGV_LOW(arg2
));
2022 tcg_gen_orc_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
), TCGV_HIGH(arg2
));
2026 static inline void tcg_gen_rotl_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
2028 if (TCG_TARGET_HAS_rot_i32
) {
2029 tcg_gen_op3_i32(INDEX_op_rotl_i32
, ret
, arg1
, arg2
);
2033 t0
= tcg_temp_new_i32();
2034 t1
= tcg_temp_new_i32();
2035 tcg_gen_shl_i32(t0
, arg1
, arg2
);
2036 tcg_gen_subfi_i32(t1
, 32, arg2
);
2037 tcg_gen_shr_i32(t1
, arg1
, t1
);
2038 tcg_gen_or_i32(ret
, t0
, t1
);
2039 tcg_temp_free_i32(t0
);
2040 tcg_temp_free_i32(t1
);
2044 static inline void tcg_gen_rotl_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
2046 if (TCG_TARGET_HAS_rot_i64
) {
2047 tcg_gen_op3_i64(INDEX_op_rotl_i64
, ret
, arg1
, arg2
);
2050 t0
= tcg_temp_new_i64();
2051 t1
= tcg_temp_new_i64();
2052 tcg_gen_shl_i64(t0
, arg1
, arg2
);
2053 tcg_gen_subfi_i64(t1
, 64, arg2
);
2054 tcg_gen_shr_i64(t1
, arg1
, t1
);
2055 tcg_gen_or_i64(ret
, t0
, t1
);
2056 tcg_temp_free_i64(t0
);
2057 tcg_temp_free_i64(t1
);
2061 static inline void tcg_gen_rotli_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
2063 /* some cases can be optimized here */
2065 tcg_gen_mov_i32(ret
, arg1
);
2066 } else if (TCG_TARGET_HAS_rot_i32
) {
2067 TCGv_i32 t0
= tcg_const_i32(arg2
);
2068 tcg_gen_rotl_i32(ret
, arg1
, t0
);
2069 tcg_temp_free_i32(t0
);
2072 t0
= tcg_temp_new_i32();
2073 t1
= tcg_temp_new_i32();
2074 tcg_gen_shli_i32(t0
, arg1
, arg2
);
2075 tcg_gen_shri_i32(t1
, arg1
, 32 - arg2
);
2076 tcg_gen_or_i32(ret
, t0
, t1
);
2077 tcg_temp_free_i32(t0
);
2078 tcg_temp_free_i32(t1
);
2082 static inline void tcg_gen_rotli_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
2084 /* some cases can be optimized here */
2086 tcg_gen_mov_i64(ret
, arg1
);
2087 } else if (TCG_TARGET_HAS_rot_i64
) {
2088 TCGv_i64 t0
= tcg_const_i64(arg2
);
2089 tcg_gen_rotl_i64(ret
, arg1
, t0
);
2090 tcg_temp_free_i64(t0
);
2093 t0
= tcg_temp_new_i64();
2094 t1
= tcg_temp_new_i64();
2095 tcg_gen_shli_i64(t0
, arg1
, arg2
);
2096 tcg_gen_shri_i64(t1
, arg1
, 64 - arg2
);
2097 tcg_gen_or_i64(ret
, t0
, t1
);
2098 tcg_temp_free_i64(t0
);
2099 tcg_temp_free_i64(t1
);
2103 static inline void tcg_gen_rotr_i32(TCGv_i32 ret
, TCGv_i32 arg1
, TCGv_i32 arg2
)
2105 if (TCG_TARGET_HAS_rot_i32
) {
2106 tcg_gen_op3_i32(INDEX_op_rotr_i32
, ret
, arg1
, arg2
);
2110 t0
= tcg_temp_new_i32();
2111 t1
= tcg_temp_new_i32();
2112 tcg_gen_shr_i32(t0
, arg1
, arg2
);
2113 tcg_gen_subfi_i32(t1
, 32, arg2
);
2114 tcg_gen_shl_i32(t1
, arg1
, t1
);
2115 tcg_gen_or_i32(ret
, t0
, t1
);
2116 tcg_temp_free_i32(t0
);
2117 tcg_temp_free_i32(t1
);
2121 static inline void tcg_gen_rotr_i64(TCGv_i64 ret
, TCGv_i64 arg1
, TCGv_i64 arg2
)
2123 if (TCG_TARGET_HAS_rot_i64
) {
2124 tcg_gen_op3_i64(INDEX_op_rotr_i64
, ret
, arg1
, arg2
);
2127 t0
= tcg_temp_new_i64();
2128 t1
= tcg_temp_new_i64();
2129 tcg_gen_shr_i64(t0
, arg1
, arg2
);
2130 tcg_gen_subfi_i64(t1
, 64, arg2
);
2131 tcg_gen_shl_i64(t1
, arg1
, t1
);
2132 tcg_gen_or_i64(ret
, t0
, t1
);
2133 tcg_temp_free_i64(t0
);
2134 tcg_temp_free_i64(t1
);
2138 static inline void tcg_gen_rotri_i32(TCGv_i32 ret
, TCGv_i32 arg1
, int32_t arg2
)
2140 /* some cases can be optimized here */
2142 tcg_gen_mov_i32(ret
, arg1
);
2144 tcg_gen_rotli_i32(ret
, arg1
, 32 - arg2
);
2148 static inline void tcg_gen_rotri_i64(TCGv_i64 ret
, TCGv_i64 arg1
, int64_t arg2
)
2150 /* some cases can be optimized here */
2152 tcg_gen_mov_i64(ret
, arg1
);
2154 tcg_gen_rotli_i64(ret
, arg1
, 64 - arg2
);
2158 static inline void tcg_gen_deposit_i32(TCGv_i32 ret
, TCGv_i32 arg1
,
2159 TCGv_i32 arg2
, unsigned int ofs
,
2165 tcg_debug_assert(ofs
< 32);
2166 tcg_debug_assert(len
<= 32);
2167 tcg_debug_assert(ofs
+ len
<= 32);
2169 if (ofs
== 0 && len
== 32) {
2170 tcg_gen_mov_i32(ret
, arg2
);
2173 if (TCG_TARGET_HAS_deposit_i32
&& TCG_TARGET_deposit_i32_valid(ofs
, len
)) {
2174 tcg_gen_op5ii_i32(INDEX_op_deposit_i32
, ret
, arg1
, arg2
, ofs
, len
);
2178 mask
= (1u << len
) - 1;
2179 t1
= tcg_temp_new_i32();
2181 if (ofs
+ len
< 32) {
2182 tcg_gen_andi_i32(t1
, arg2
, mask
);
2183 tcg_gen_shli_i32(t1
, t1
, ofs
);
2185 tcg_gen_shli_i32(t1
, arg2
, ofs
);
2187 tcg_gen_andi_i32(ret
, arg1
, ~(mask
<< ofs
));
2188 tcg_gen_or_i32(ret
, ret
, t1
);
2190 tcg_temp_free_i32(t1
);
2193 static inline void tcg_gen_deposit_i64(TCGv_i64 ret
, TCGv_i64 arg1
,
2194 TCGv_i64 arg2
, unsigned int ofs
,
2200 tcg_debug_assert(ofs
< 64);
2201 tcg_debug_assert(len
<= 64);
2202 tcg_debug_assert(ofs
+ len
<= 64);
2204 if (ofs
== 0 && len
== 64) {
2205 tcg_gen_mov_i64(ret
, arg2
);
2208 if (TCG_TARGET_HAS_deposit_i64
&& TCG_TARGET_deposit_i64_valid(ofs
, len
)) {
2209 tcg_gen_op5ii_i64(INDEX_op_deposit_i64
, ret
, arg1
, arg2
, ofs
, len
);
2213 #if TCG_TARGET_REG_BITS == 32
2215 tcg_gen_deposit_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
),
2216 TCGV_LOW(arg2
), ofs
- 32, len
);
2217 tcg_gen_mov_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
));
2220 if (ofs
+ len
<= 32) {
2221 tcg_gen_deposit_i32(TCGV_LOW(ret
), TCGV_LOW(arg1
),
2222 TCGV_LOW(arg2
), ofs
, len
);
2223 tcg_gen_mov_i32(TCGV_HIGH(ret
), TCGV_HIGH(arg1
));
2228 mask
= (1ull << len
) - 1;
2229 t1
= tcg_temp_new_i64();
2231 if (ofs
+ len
< 64) {
2232 tcg_gen_andi_i64(t1
, arg2
, mask
);
2233 tcg_gen_shli_i64(t1
, t1
, ofs
);
2235 tcg_gen_shli_i64(t1
, arg2
, ofs
);
2237 tcg_gen_andi_i64(ret
, arg1
, ~(mask
<< ofs
));
2238 tcg_gen_or_i64(ret
, ret
, t1
);
2240 tcg_temp_free_i64(t1
);
2243 static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest
, TCGv_i32 low
,
2246 #if TCG_TARGET_REG_BITS == 32
2247 tcg_gen_mov_i32(TCGV_LOW(dest
), low
);
2248 tcg_gen_mov_i32(TCGV_HIGH(dest
), high
);
2250 TCGv_i64 tmp
= tcg_temp_new_i64();
2251 /* These extensions are only needed for type correctness.
2252 We may be able to do better given target specific information. */
2253 tcg_gen_extu_i32_i64(tmp
, high
);
2254 tcg_gen_extu_i32_i64(dest
, low
);
2255 /* If deposit is available, use it. Otherwise use the extra
2256 knowledge that we have of the zero-extensions above. */
2257 if (TCG_TARGET_HAS_deposit_i64
&& TCG_TARGET_deposit_i64_valid(32, 32)) {
2258 tcg_gen_deposit_i64(dest
, dest
, tmp
, 32, 32);
2260 tcg_gen_shli_i64(tmp
, tmp
, 32);
2261 tcg_gen_or_i64(dest
, dest
, tmp
);
2263 tcg_temp_free_i64(tmp
);
2267 static inline void tcg_gen_concat32_i64(TCGv_i64 dest
, TCGv_i64 low
,
2270 tcg_gen_deposit_i64(dest
, low
, high
, 32, 32);
2273 static inline void tcg_gen_extr_i64_i32(TCGv_i32 lo
, TCGv_i32 hi
, TCGv_i64 arg
)
2275 #if TCG_TARGET_REG_BITS == 32
2276 tcg_gen_mov_i32(lo
, TCGV_LOW(arg
));
2277 tcg_gen_mov_i32(hi
, TCGV_HIGH(arg
));
2279 TCGv_i64 t0
= tcg_temp_new_i64();
2280 tcg_gen_trunc_i64_i32(lo
, arg
);
2281 tcg_gen_shri_i64(t0
, arg
, 32);
2282 tcg_gen_trunc_i64_i32(hi
, t0
);
2283 tcg_temp_free_i64(t0
);
2287 static inline void tcg_gen_extr32_i64(TCGv_i64 lo
, TCGv_i64 hi
, TCGv_i64 arg
)
2289 tcg_gen_ext32u_i64(lo
, arg
);
2290 tcg_gen_shri_i64(hi
, arg
, 32);
2293 static inline void tcg_gen_movcond_i32(TCGCond cond
, TCGv_i32 ret
,
2294 TCGv_i32 c1
, TCGv_i32 c2
,
2295 TCGv_i32 v1
, TCGv_i32 v2
)
2297 if (TCG_TARGET_HAS_movcond_i32
) {
2298 tcg_gen_op6i_i32(INDEX_op_movcond_i32
, ret
, c1
, c2
, v1
, v2
, cond
);
2300 TCGv_i32 t0
= tcg_temp_new_i32();
2301 TCGv_i32 t1
= tcg_temp_new_i32();
2302 tcg_gen_setcond_i32(cond
, t0
, c1
, c2
);
2303 tcg_gen_neg_i32(t0
, t0
);
2304 tcg_gen_and_i32(t1
, v1
, t0
);
2305 tcg_gen_andc_i32(ret
, v2
, t0
);
2306 tcg_gen_or_i32(ret
, ret
, t1
);
2307 tcg_temp_free_i32(t0
);
2308 tcg_temp_free_i32(t1
);
2312 static inline void tcg_gen_movcond_i64(TCGCond cond
, TCGv_i64 ret
,
2313 TCGv_i64 c1
, TCGv_i64 c2
,
2314 TCGv_i64 v1
, TCGv_i64 v2
)
2316 #if TCG_TARGET_REG_BITS == 32
2317 TCGv_i32 t0
= tcg_temp_new_i32();
2318 TCGv_i32 t1
= tcg_temp_new_i32();
2319 tcg_gen_op6i_i32(INDEX_op_setcond2_i32
, t0
,
2320 TCGV_LOW(c1
), TCGV_HIGH(c1
),
2321 TCGV_LOW(c2
), TCGV_HIGH(c2
), cond
);
2323 if (TCG_TARGET_HAS_movcond_i32
) {
2324 tcg_gen_movi_i32(t1
, 0);
2325 tcg_gen_movcond_i32(TCG_COND_NE
, TCGV_LOW(ret
), t0
, t1
,
2326 TCGV_LOW(v1
), TCGV_LOW(v2
));
2327 tcg_gen_movcond_i32(TCG_COND_NE
, TCGV_HIGH(ret
), t0
, t1
,
2328 TCGV_HIGH(v1
), TCGV_HIGH(v2
));
2330 tcg_gen_neg_i32(t0
, t0
);
2332 tcg_gen_and_i32(t1
, TCGV_LOW(v1
), t0
);
2333 tcg_gen_andc_i32(TCGV_LOW(ret
), TCGV_LOW(v2
), t0
);
2334 tcg_gen_or_i32(TCGV_LOW(ret
), TCGV_LOW(ret
), t1
);
2336 tcg_gen_and_i32(t1
, TCGV_HIGH(v1
), t0
);
2337 tcg_gen_andc_i32(TCGV_HIGH(ret
), TCGV_HIGH(v2
), t0
);
2338 tcg_gen_or_i32(TCGV_HIGH(ret
), TCGV_HIGH(ret
), t1
);
2340 tcg_temp_free_i32(t0
);
2341 tcg_temp_free_i32(t1
);
2343 if (TCG_TARGET_HAS_movcond_i64
) {
2344 tcg_gen_op6i_i64(INDEX_op_movcond_i64
, ret
, c1
, c2
, v1
, v2
, cond
);
2346 TCGv_i64 t0
= tcg_temp_new_i64();
2347 TCGv_i64 t1
= tcg_temp_new_i64();
2348 tcg_gen_setcond_i64(cond
, t0
, c1
, c2
);
2349 tcg_gen_neg_i64(t0
, t0
);
2350 tcg_gen_and_i64(t1
, v1
, t0
);
2351 tcg_gen_andc_i64(ret
, v2
, t0
);
2352 tcg_gen_or_i64(ret
, ret
, t1
);
2353 tcg_temp_free_i64(t0
);
2354 tcg_temp_free_i64(t1
);
2359 static inline void tcg_gen_add2_i32(TCGv_i32 rl
, TCGv_i32 rh
, TCGv_i32 al
,
2360 TCGv_i32 ah
, TCGv_i32 bl
, TCGv_i32 bh
)
2362 if (TCG_TARGET_HAS_add2_i32
) {
2363 tcg_gen_op6_i32(INDEX_op_add2_i32
, rl
, rh
, al
, ah
, bl
, bh
);
2364 /* Allow the optimizer room to replace add2 with two moves. */
2365 tcg_gen_op0(INDEX_op_nop
);
2367 TCGv_i64 t0
= tcg_temp_new_i64();
2368 TCGv_i64 t1
= tcg_temp_new_i64();
2369 tcg_gen_concat_i32_i64(t0
, al
, ah
);
2370 tcg_gen_concat_i32_i64(t1
, bl
, bh
);
2371 tcg_gen_add_i64(t0
, t0
, t1
);
2372 tcg_gen_extr_i64_i32(rl
, rh
, t0
);
2373 tcg_temp_free_i64(t0
);
2374 tcg_temp_free_i64(t1
);
2378 static inline void tcg_gen_sub2_i32(TCGv_i32 rl
, TCGv_i32 rh
, TCGv_i32 al
,
2379 TCGv_i32 ah
, TCGv_i32 bl
, TCGv_i32 bh
)
2381 if (TCG_TARGET_HAS_sub2_i32
) {
2382 tcg_gen_op6_i32(INDEX_op_sub2_i32
, rl
, rh
, al
, ah
, bl
, bh
);
2383 /* Allow the optimizer room to replace sub2 with two moves. */
2384 tcg_gen_op0(INDEX_op_nop
);
2386 TCGv_i64 t0
= tcg_temp_new_i64();
2387 TCGv_i64 t1
= tcg_temp_new_i64();
2388 tcg_gen_concat_i32_i64(t0
, al
, ah
);
2389 tcg_gen_concat_i32_i64(t1
, bl
, bh
);
2390 tcg_gen_sub_i64(t0
, t0
, t1
);
2391 tcg_gen_extr_i64_i32(rl
, rh
, t0
);
2392 tcg_temp_free_i64(t0
);
2393 tcg_temp_free_i64(t1
);
2397 static inline void tcg_gen_mulu2_i32(TCGv_i32 rl
, TCGv_i32 rh
,
2398 TCGv_i32 arg1
, TCGv_i32 arg2
)
2400 if (TCG_TARGET_HAS_mulu2_i32
) {
2401 tcg_gen_op4_i32(INDEX_op_mulu2_i32
, rl
, rh
, arg1
, arg2
);
2402 /* Allow the optimizer room to replace mulu2 with two moves. */
2403 tcg_gen_op0(INDEX_op_nop
);
2405 TCGv_i64 t0
= tcg_temp_new_i64();
2406 TCGv_i64 t1
= tcg_temp_new_i64();
2407 tcg_gen_extu_i32_i64(t0
, arg1
);
2408 tcg_gen_extu_i32_i64(t1
, arg2
);
2409 tcg_gen_mul_i64(t0
, t0
, t1
);
2410 tcg_gen_extr_i64_i32(rl
, rh
, t0
);
2411 tcg_temp_free_i64(t0
);
2412 tcg_temp_free_i64(t1
);
2416 static inline void tcg_gen_muls2_i32(TCGv_i32 rl
, TCGv_i32 rh
,
2417 TCGv_i32 arg1
, TCGv_i32 arg2
)
2419 if (TCG_TARGET_HAS_muls2_i32
) {
2420 tcg_gen_op4_i32(INDEX_op_muls2_i32
, rl
, rh
, arg1
, arg2
);
2421 /* Allow the optimizer room to replace muls2 with two moves. */
2422 tcg_gen_op0(INDEX_op_nop
);
2423 } else if (TCG_TARGET_REG_BITS
== 32 && TCG_TARGET_HAS_mulu2_i32
) {
2424 TCGv_i32 t0
= tcg_temp_new_i32();
2425 TCGv_i32 t1
= tcg_temp_new_i32();
2426 TCGv_i32 t2
= tcg_temp_new_i32();
2427 TCGv_i32 t3
= tcg_temp_new_i32();
2428 tcg_gen_op4_i32(INDEX_op_mulu2_i32
, t0
, t1
, arg1
, arg2
);
2429 /* Allow the optimizer room to replace mulu2 with two moves. */
2430 tcg_gen_op0(INDEX_op_nop
);
2431 /* Adjust for negative inputs. */
2432 tcg_gen_sari_i32(t2
, arg1
, 31);
2433 tcg_gen_sari_i32(t3
, arg2
, 31);
2434 tcg_gen_and_i32(t2
, t2
, arg2
);
2435 tcg_gen_and_i32(t3
, t3
, arg1
);
2436 tcg_gen_sub_i32(rh
, t1
, t2
);
2437 tcg_gen_sub_i32(rh
, rh
, t3
);
2438 tcg_gen_mov_i32(rl
, t0
);
2439 tcg_temp_free_i32(t0
);
2440 tcg_temp_free_i32(t1
);
2441 tcg_temp_free_i32(t2
);
2442 tcg_temp_free_i32(t3
);
2444 TCGv_i64 t0
= tcg_temp_new_i64();
2445 TCGv_i64 t1
= tcg_temp_new_i64();
2446 tcg_gen_ext_i32_i64(t0
, arg1
);
2447 tcg_gen_ext_i32_i64(t1
, arg2
);
2448 tcg_gen_mul_i64(t0
, t0
, t1
);
2449 tcg_gen_extr_i64_i32(rl
, rh
, t0
);
2450 tcg_temp_free_i64(t0
);
2451 tcg_temp_free_i64(t1
);
2455 static inline void tcg_gen_add2_i64(TCGv_i64 rl
, TCGv_i64 rh
, TCGv_i64 al
,
2456 TCGv_i64 ah
, TCGv_i64 bl
, TCGv_i64 bh
)
2458 if (TCG_TARGET_HAS_add2_i64
) {
2459 tcg_gen_op6_i64(INDEX_op_add2_i64
, rl
, rh
, al
, ah
, bl
, bh
);
2460 /* Allow the optimizer room to replace add2 with two moves. */
2461 tcg_gen_op0(INDEX_op_nop
);
2463 TCGv_i64 t0
= tcg_temp_new_i64();
2464 TCGv_i64 t1
= tcg_temp_new_i64();
2465 tcg_gen_add_i64(t0
, al
, bl
);
2466 tcg_gen_setcond_i64(TCG_COND_LTU
, t1
, t0
, al
);
2467 tcg_gen_add_i64(rh
, ah
, bh
);
2468 tcg_gen_add_i64(rh
, rh
, t1
);
2469 tcg_gen_mov_i64(rl
, t0
);
2470 tcg_temp_free_i64(t0
);
2471 tcg_temp_free_i64(t1
);
2475 static inline void tcg_gen_sub2_i64(TCGv_i64 rl
, TCGv_i64 rh
, TCGv_i64 al
,
2476 TCGv_i64 ah
, TCGv_i64 bl
, TCGv_i64 bh
)
2478 if (TCG_TARGET_HAS_sub2_i64
) {
2479 tcg_gen_op6_i64(INDEX_op_sub2_i64
, rl
, rh
, al
, ah
, bl
, bh
);
2480 /* Allow the optimizer room to replace sub2 with two moves. */
2481 tcg_gen_op0(INDEX_op_nop
);
2483 TCGv_i64 t0
= tcg_temp_new_i64();
2484 TCGv_i64 t1
= tcg_temp_new_i64();
2485 tcg_gen_sub_i64(t0
, al
, bl
);
2486 tcg_gen_setcond_i64(TCG_COND_LTU
, t1
, al
, bl
);
2487 tcg_gen_sub_i64(rh
, ah
, bh
);
2488 tcg_gen_sub_i64(rh
, rh
, t1
);
2489 tcg_gen_mov_i64(rl
, t0
);
2490 tcg_temp_free_i64(t0
);
2491 tcg_temp_free_i64(t1
);
2495 static inline void tcg_gen_mulu2_i64(TCGv_i64 rl
, TCGv_i64 rh
,
2496 TCGv_i64 arg1
, TCGv_i64 arg2
)
2498 if (TCG_TARGET_HAS_mulu2_i64
) {
2499 tcg_gen_op4_i64(INDEX_op_mulu2_i64
, rl
, rh
, arg1
, arg2
);
2500 /* Allow the optimizer room to replace mulu2 with two moves. */
2501 tcg_gen_op0(INDEX_op_nop
);
2502 } else if (TCG_TARGET_HAS_mulu2_i64
) {
2503 TCGv_i64 t0
= tcg_temp_new_i64();
2504 TCGv_i64 t1
= tcg_temp_new_i64();
2505 TCGv_i64 t2
= tcg_temp_new_i64();
2506 TCGv_i64 t3
= tcg_temp_new_i64();
2507 tcg_gen_op4_i64(INDEX_op_mulu2_i64
, t0
, t1
, arg1
, arg2
);
2508 /* Allow the optimizer room to replace mulu2 with two moves. */
2509 tcg_gen_op0(INDEX_op_nop
);
2510 /* Adjust for negative inputs. */
2511 tcg_gen_sari_i64(t2
, arg1
, 63);
2512 tcg_gen_sari_i64(t3
, arg2
, 63);
2513 tcg_gen_and_i64(t2
, t2
, arg2
);
2514 tcg_gen_and_i64(t3
, t3
, arg1
);
2515 tcg_gen_sub_i64(rh
, t1
, t2
);
2516 tcg_gen_sub_i64(rh
, rh
, t3
);
2517 tcg_gen_mov_i64(rl
, t0
);
2518 tcg_temp_free_i64(t0
);
2519 tcg_temp_free_i64(t1
);
2520 tcg_temp_free_i64(t2
);
2521 tcg_temp_free_i64(t3
);
2523 TCGv_i64 t0
= tcg_temp_new_i64();
2525 /* Return value and both arguments are 64-bit and unsigned. */
2526 sizemask
|= tcg_gen_sizemask(0, 1, 0);
2527 sizemask
|= tcg_gen_sizemask(1, 1, 0);
2528 sizemask
|= tcg_gen_sizemask(2, 1, 0);
2529 tcg_gen_mul_i64(t0
, arg1
, arg2
);
2530 tcg_gen_helper64(tcg_helper_muluh_i64
, sizemask
, rh
, arg1
, arg2
);
2531 tcg_gen_mov_i64(rl
, t0
);
2532 tcg_temp_free_i64(t0
);
2536 static inline void tcg_gen_muls2_i64(TCGv_i64 rl
, TCGv_i64 rh
,
2537 TCGv_i64 arg1
, TCGv_i64 arg2
)
2539 if (TCG_TARGET_HAS_muls2_i64
) {
2540 tcg_gen_op4_i64(INDEX_op_muls2_i64
, rl
, rh
, arg1
, arg2
);
2541 /* Allow the optimizer room to replace muls2 with two moves. */
2542 tcg_gen_op0(INDEX_op_nop
);
2544 TCGv_i64 t0
= tcg_temp_new_i64();
2546 /* Return value and both arguments are 64-bit and signed. */
2547 sizemask
|= tcg_gen_sizemask(0, 1, 1);
2548 sizemask
|= tcg_gen_sizemask(1, 1, 1);
2549 sizemask
|= tcg_gen_sizemask(2, 1, 1);
2550 tcg_gen_mul_i64(t0
, arg1
, arg2
);
2551 tcg_gen_helper64(tcg_helper_mulsh_i64
, sizemask
, rh
, arg1
, arg2
);
2552 tcg_gen_mov_i64(rl
, t0
);
2553 tcg_temp_free_i64(t0
);
2557 /***************************************/
2558 /* QEMU specific operations. Their type depend on the QEMU CPU
2560 #ifndef TARGET_LONG_BITS
2561 #error must include QEMU headers
2564 #if TARGET_LONG_BITS == 32
2565 #define TCGv TCGv_i32
2566 #define tcg_temp_new() tcg_temp_new_i32()
2567 #define tcg_global_reg_new tcg_global_reg_new_i32
2568 #define tcg_global_mem_new tcg_global_mem_new_i32
2569 #define tcg_temp_local_new() tcg_temp_local_new_i32()
2570 #define tcg_temp_free tcg_temp_free_i32
2571 #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32
2572 #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32
2573 #define TCGV_UNUSED(x) TCGV_UNUSED_I32(x)
2574 #define TCGV_IS_UNUSED(x) TCGV_IS_UNUSED_I32(x)
2575 #define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b)
2577 #define TCGv TCGv_i64
2578 #define tcg_temp_new() tcg_temp_new_i64()
2579 #define tcg_global_reg_new tcg_global_reg_new_i64
2580 #define tcg_global_mem_new tcg_global_mem_new_i64
2581 #define tcg_temp_local_new() tcg_temp_local_new_i64()
2582 #define tcg_temp_free tcg_temp_free_i64
2583 #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64
2584 #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64
2585 #define TCGV_UNUSED(x) TCGV_UNUSED_I64(x)
2586 #define TCGV_IS_UNUSED(x) TCGV_IS_UNUSED_I64(x)
2587 #define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b)
2590 /* debug info: write the PC of the corresponding QEMU CPU instruction */
2591 static inline void tcg_gen_debug_insn_start(uint64_t pc
)
2593 /* XXX: must really use a 32 bit size for TCGArg in all cases */
2594 #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
2595 tcg_gen_op2ii(INDEX_op_debug_insn_start
,
2596 (uint32_t)(pc
), (uint32_t)(pc
>> 32));
2598 tcg_gen_op1i(INDEX_op_debug_insn_start
, pc
);
2602 static inline void tcg_gen_exit_tb(tcg_target_long val
)
2604 tcg_gen_op1i(INDEX_op_exit_tb
, val
);
2607 static inline void tcg_gen_goto_tb(unsigned idx
)
2609 /* We only support two chained exits. */
2610 tcg_debug_assert(idx
<= 1);
2611 #ifdef CONFIG_DEBUG_TCG
2612 /* Verify that we havn't seen this numbered exit before. */
2613 tcg_debug_assert((tcg_ctx
.goto_tb_issue_mask
& (1 << idx
)) == 0);
2614 tcg_ctx
.goto_tb_issue_mask
|= 1 << idx
;
2616 tcg_gen_op1i(INDEX_op_goto_tb
, idx
);
2619 #if TCG_TARGET_REG_BITS == 32
2620 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
2622 #if TARGET_LONG_BITS == 32
2623 tcg_gen_op3i_i32(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
2625 tcg_gen_op4i_i32(INDEX_op_qemu_ld8u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2626 TCGV_HIGH(addr
), mem_index
);
2627 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
2631 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
2633 #if TARGET_LONG_BITS == 32
2634 tcg_gen_op3i_i32(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
2636 tcg_gen_op4i_i32(INDEX_op_qemu_ld8s
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2637 TCGV_HIGH(addr
), mem_index
);
2638 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2642 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
2644 #if TARGET_LONG_BITS == 32
2645 tcg_gen_op3i_i32(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
2647 tcg_gen_op4i_i32(INDEX_op_qemu_ld16u
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2648 TCGV_HIGH(addr
), mem_index
);
2649 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
2653 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
2655 #if TARGET_LONG_BITS == 32
2656 tcg_gen_op3i_i32(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
2658 tcg_gen_op4i_i32(INDEX_op_qemu_ld16s
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2659 TCGV_HIGH(addr
), mem_index
);
2660 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2664 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
2666 #if TARGET_LONG_BITS == 32
2667 tcg_gen_op3i_i32(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2669 tcg_gen_op4i_i32(INDEX_op_qemu_ld32
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2670 TCGV_HIGH(addr
), mem_index
);
2671 tcg_gen_movi_i32(TCGV_HIGH(ret
), 0);
2675 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
2677 #if TARGET_LONG_BITS == 32
2678 tcg_gen_op3i_i32(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2680 tcg_gen_op4i_i32(INDEX_op_qemu_ld32
, TCGV_LOW(ret
), TCGV_LOW(addr
),
2681 TCGV_HIGH(addr
), mem_index
);
2682 tcg_gen_sari_i32(TCGV_HIGH(ret
), TCGV_LOW(ret
), 31);
2686 static inline void tcg_gen_qemu_ld64(TCGv_i64 ret
, TCGv addr
, int mem_index
)
2688 #if TARGET_LONG_BITS == 32
2689 tcg_gen_op4i_i32(INDEX_op_qemu_ld64
, TCGV_LOW(ret
), TCGV_HIGH(ret
), addr
, mem_index
);
2691 tcg_gen_op5i_i32(INDEX_op_qemu_ld64
, TCGV_LOW(ret
), TCGV_HIGH(ret
),
2692 TCGV_LOW(addr
), TCGV_HIGH(addr
), mem_index
);
2696 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
2698 #if TARGET_LONG_BITS == 32
2699 tcg_gen_op3i_i32(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
2701 tcg_gen_op4i_i32(INDEX_op_qemu_st8
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2702 TCGV_HIGH(addr
), mem_index
);
2706 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
2708 #if TARGET_LONG_BITS == 32
2709 tcg_gen_op3i_i32(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
2711 tcg_gen_op4i_i32(INDEX_op_qemu_st16
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2712 TCGV_HIGH(addr
), mem_index
);
2716 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
2718 #if TARGET_LONG_BITS == 32
2719 tcg_gen_op3i_i32(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
2721 tcg_gen_op4i_i32(INDEX_op_qemu_st32
, TCGV_LOW(arg
), TCGV_LOW(addr
),
2722 TCGV_HIGH(addr
), mem_index
);
2726 static inline void tcg_gen_qemu_st64(TCGv_i64 arg
, TCGv addr
, int mem_index
)
2728 #if TARGET_LONG_BITS == 32
2729 tcg_gen_op4i_i32(INDEX_op_qemu_st64
, TCGV_LOW(arg
), TCGV_HIGH(arg
), addr
,
2732 tcg_gen_op5i_i32(INDEX_op_qemu_st64
, TCGV_LOW(arg
), TCGV_HIGH(arg
),
2733 TCGV_LOW(addr
), TCGV_HIGH(addr
), mem_index
);
2737 #define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i32(TCGV_PTR_TO_NAT(R), (A), (O))
2738 #define tcg_gen_discard_ptr(A) tcg_gen_discard_i32(TCGV_PTR_TO_NAT(A))
2740 #else /* TCG_TARGET_REG_BITS == 32 */
2742 static inline void tcg_gen_qemu_ld8u(TCGv ret
, TCGv addr
, int mem_index
)
2744 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u
, ret
, addr
, mem_index
);
2747 static inline void tcg_gen_qemu_ld8s(TCGv ret
, TCGv addr
, int mem_index
)
2749 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s
, ret
, addr
, mem_index
);
2752 static inline void tcg_gen_qemu_ld16u(TCGv ret
, TCGv addr
, int mem_index
)
2754 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u
, ret
, addr
, mem_index
);
2757 static inline void tcg_gen_qemu_ld16s(TCGv ret
, TCGv addr
, int mem_index
)
2759 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s
, ret
, addr
, mem_index
);
2762 static inline void tcg_gen_qemu_ld32u(TCGv ret
, TCGv addr
, int mem_index
)
2764 #if TARGET_LONG_BITS == 32
2765 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2767 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u
, ret
, addr
, mem_index
);
2771 static inline void tcg_gen_qemu_ld32s(TCGv ret
, TCGv addr
, int mem_index
)
2773 #if TARGET_LONG_BITS == 32
2774 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32
, ret
, addr
, mem_index
);
2776 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s
, ret
, addr
, mem_index
);
2780 static inline void tcg_gen_qemu_ld64(TCGv_i64 ret
, TCGv addr
, int mem_index
)
2782 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64
, ret
, addr
, mem_index
);
2785 static inline void tcg_gen_qemu_st8(TCGv arg
, TCGv addr
, int mem_index
)
2787 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8
, arg
, addr
, mem_index
);
2790 static inline void tcg_gen_qemu_st16(TCGv arg
, TCGv addr
, int mem_index
)
2792 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16
, arg
, addr
, mem_index
);
2795 static inline void tcg_gen_qemu_st32(TCGv arg
, TCGv addr
, int mem_index
)
2797 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32
, arg
, addr
, mem_index
);
2800 static inline void tcg_gen_qemu_st64(TCGv_i64 arg
, TCGv addr
, int mem_index
)
2802 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64
, arg
, addr
, mem_index
);
2805 #define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i64(TCGV_PTR_TO_NAT(R), (A), (O))
2806 #define tcg_gen_discard_ptr(A) tcg_gen_discard_i64(TCGV_PTR_TO_NAT(A))
2808 #endif /* TCG_TARGET_REG_BITS != 32 */
2810 #if TARGET_LONG_BITS == 64
2811 #define tcg_gen_movi_tl tcg_gen_movi_i64
2812 #define tcg_gen_mov_tl tcg_gen_mov_i64
2813 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
2814 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
2815 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
2816 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
2817 #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
2818 #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
2819 #define tcg_gen_ld_tl tcg_gen_ld_i64
2820 #define tcg_gen_st8_tl tcg_gen_st8_i64
2821 #define tcg_gen_st16_tl tcg_gen_st16_i64
2822 #define tcg_gen_st32_tl tcg_gen_st32_i64
2823 #define tcg_gen_st_tl tcg_gen_st_i64
2824 #define tcg_gen_add_tl tcg_gen_add_i64
2825 #define tcg_gen_addi_tl tcg_gen_addi_i64
2826 #define tcg_gen_sub_tl tcg_gen_sub_i64
2827 #define tcg_gen_neg_tl tcg_gen_neg_i64
2828 #define tcg_gen_subfi_tl tcg_gen_subfi_i64
2829 #define tcg_gen_subi_tl tcg_gen_subi_i64
2830 #define tcg_gen_and_tl tcg_gen_and_i64
2831 #define tcg_gen_andi_tl tcg_gen_andi_i64
2832 #define tcg_gen_or_tl tcg_gen_or_i64
2833 #define tcg_gen_ori_tl tcg_gen_ori_i64
2834 #define tcg_gen_xor_tl tcg_gen_xor_i64
2835 #define tcg_gen_xori_tl tcg_gen_xori_i64
2836 #define tcg_gen_not_tl tcg_gen_not_i64
2837 #define tcg_gen_shl_tl tcg_gen_shl_i64
2838 #define tcg_gen_shli_tl tcg_gen_shli_i64
2839 #define tcg_gen_shr_tl tcg_gen_shr_i64
2840 #define tcg_gen_shri_tl tcg_gen_shri_i64
2841 #define tcg_gen_sar_tl tcg_gen_sar_i64
2842 #define tcg_gen_sari_tl tcg_gen_sari_i64
2843 #define tcg_gen_brcond_tl tcg_gen_brcond_i64
2844 #define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
2845 #define tcg_gen_setcond_tl tcg_gen_setcond_i64
2846 #define tcg_gen_setcondi_tl tcg_gen_setcondi_i64
2847 #define tcg_gen_mul_tl tcg_gen_mul_i64
2848 #define tcg_gen_muli_tl tcg_gen_muli_i64
2849 #define tcg_gen_div_tl tcg_gen_div_i64
2850 #define tcg_gen_rem_tl tcg_gen_rem_i64
2851 #define tcg_gen_divu_tl tcg_gen_divu_i64
2852 #define tcg_gen_remu_tl tcg_gen_remu_i64
2853 #define tcg_gen_discard_tl tcg_gen_discard_i64
2854 #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
2855 #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
2856 #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
2857 #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
2858 #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
2859 #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
2860 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
2861 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
2862 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
2863 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
2864 #define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
2865 #define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
2866 #define tcg_gen_bswap16_tl tcg_gen_bswap16_i64
2867 #define tcg_gen_bswap32_tl tcg_gen_bswap32_i64
2868 #define tcg_gen_bswap64_tl tcg_gen_bswap64_i64
2869 #define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
2870 #define tcg_gen_extr_i64_tl tcg_gen_extr32_i64
2871 #define tcg_gen_andc_tl tcg_gen_andc_i64
2872 #define tcg_gen_eqv_tl tcg_gen_eqv_i64
2873 #define tcg_gen_nand_tl tcg_gen_nand_i64
2874 #define tcg_gen_nor_tl tcg_gen_nor_i64
2875 #define tcg_gen_orc_tl tcg_gen_orc_i64
2876 #define tcg_gen_rotl_tl tcg_gen_rotl_i64
2877 #define tcg_gen_rotli_tl tcg_gen_rotli_i64
2878 #define tcg_gen_rotr_tl tcg_gen_rotr_i64
2879 #define tcg_gen_rotri_tl tcg_gen_rotri_i64
2880 #define tcg_gen_deposit_tl tcg_gen_deposit_i64
2881 #define tcg_const_tl tcg_const_i64
2882 #define tcg_const_local_tl tcg_const_local_i64
2883 #define tcg_gen_movcond_tl tcg_gen_movcond_i64
2884 #define tcg_gen_add2_tl tcg_gen_add2_i64
2885 #define tcg_gen_sub2_tl tcg_gen_sub2_i64
2886 #define tcg_gen_mulu2_tl tcg_gen_mulu2_i64
2887 #define tcg_gen_muls2_tl tcg_gen_muls2_i64
2889 #define tcg_gen_movi_tl tcg_gen_movi_i32
2890 #define tcg_gen_mov_tl tcg_gen_mov_i32
2891 #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
2892 #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
2893 #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
2894 #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
2895 #define tcg_gen_ld32u_tl tcg_gen_ld_i32
2896 #define tcg_gen_ld32s_tl tcg_gen_ld_i32
2897 #define tcg_gen_ld_tl tcg_gen_ld_i32
2898 #define tcg_gen_st8_tl tcg_gen_st8_i32
2899 #define tcg_gen_st16_tl tcg_gen_st16_i32
2900 #define tcg_gen_st32_tl tcg_gen_st_i32
2901 #define tcg_gen_st_tl tcg_gen_st_i32
2902 #define tcg_gen_add_tl tcg_gen_add_i32
2903 #define tcg_gen_addi_tl tcg_gen_addi_i32
2904 #define tcg_gen_sub_tl tcg_gen_sub_i32
2905 #define tcg_gen_neg_tl tcg_gen_neg_i32
2906 #define tcg_gen_subfi_tl tcg_gen_subfi_i32
2907 #define tcg_gen_subi_tl tcg_gen_subi_i32
2908 #define tcg_gen_and_tl tcg_gen_and_i32
2909 #define tcg_gen_andi_tl tcg_gen_andi_i32
2910 #define tcg_gen_or_tl tcg_gen_or_i32
2911 #define tcg_gen_ori_tl tcg_gen_ori_i32
2912 #define tcg_gen_xor_tl tcg_gen_xor_i32
2913 #define tcg_gen_xori_tl tcg_gen_xori_i32
2914 #define tcg_gen_not_tl tcg_gen_not_i32
2915 #define tcg_gen_shl_tl tcg_gen_shl_i32
2916 #define tcg_gen_shli_tl tcg_gen_shli_i32
2917 #define tcg_gen_shr_tl tcg_gen_shr_i32
2918 #define tcg_gen_shri_tl tcg_gen_shri_i32
2919 #define tcg_gen_sar_tl tcg_gen_sar_i32
2920 #define tcg_gen_sari_tl tcg_gen_sari_i32
2921 #define tcg_gen_brcond_tl tcg_gen_brcond_i32
2922 #define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
2923 #define tcg_gen_setcond_tl tcg_gen_setcond_i32
2924 #define tcg_gen_setcondi_tl tcg_gen_setcondi_i32
2925 #define tcg_gen_mul_tl tcg_gen_mul_i32
2926 #define tcg_gen_muli_tl tcg_gen_muli_i32
2927 #define tcg_gen_div_tl tcg_gen_div_i32
2928 #define tcg_gen_rem_tl tcg_gen_rem_i32
2929 #define tcg_gen_divu_tl tcg_gen_divu_i32
2930 #define tcg_gen_remu_tl tcg_gen_remu_i32
2931 #define tcg_gen_discard_tl tcg_gen_discard_i32
2932 #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
2933 #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
2934 #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
2935 #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
2936 #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
2937 #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
2938 #define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
2939 #define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
2940 #define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
2941 #define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
2942 #define tcg_gen_ext32u_tl tcg_gen_mov_i32
2943 #define tcg_gen_ext32s_tl tcg_gen_mov_i32
2944 #define tcg_gen_bswap16_tl tcg_gen_bswap16_i32
2945 #define tcg_gen_bswap32_tl tcg_gen_bswap32_i32
2946 #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
2947 #define tcg_gen_extr_tl_i64 tcg_gen_extr_i32_i64
2948 #define tcg_gen_andc_tl tcg_gen_andc_i32
2949 #define tcg_gen_eqv_tl tcg_gen_eqv_i32
2950 #define tcg_gen_nand_tl tcg_gen_nand_i32
2951 #define tcg_gen_nor_tl tcg_gen_nor_i32
2952 #define tcg_gen_orc_tl tcg_gen_orc_i32
2953 #define tcg_gen_rotl_tl tcg_gen_rotl_i32
2954 #define tcg_gen_rotli_tl tcg_gen_rotli_i32
2955 #define tcg_gen_rotr_tl tcg_gen_rotr_i32
2956 #define tcg_gen_rotri_tl tcg_gen_rotri_i32
2957 #define tcg_gen_deposit_tl tcg_gen_deposit_i32
2958 #define tcg_const_tl tcg_const_i32
2959 #define tcg_const_local_tl tcg_const_local_i32
2960 #define tcg_gen_movcond_tl tcg_gen_movcond_i32
2961 #define tcg_gen_add2_tl tcg_gen_add2_i32
2962 #define tcg_gen_sub2_tl tcg_gen_sub2_i32
2963 #define tcg_gen_mulu2_tl tcg_gen_mulu2_i32
2964 #define tcg_gen_muls2_tl tcg_gen_muls2_i32
2967 #if TCG_TARGET_REG_BITS == 32
2968 #define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i32(TCGV_PTR_TO_NAT(R), \
2969 TCGV_PTR_TO_NAT(A), \
2971 #define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i32(TCGV_PTR_TO_NAT(R), \
2972 TCGV_PTR_TO_NAT(A), (B))
2973 #define tcg_gen_ext_i32_ptr(R, A) tcg_gen_mov_i32(TCGV_PTR_TO_NAT(R), (A))
2974 #else /* TCG_TARGET_REG_BITS == 32 */
2975 #define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i64(TCGV_PTR_TO_NAT(R), \
2976 TCGV_PTR_TO_NAT(A), \
2978 #define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i64(TCGV_PTR_TO_NAT(R), \
2979 TCGV_PTR_TO_NAT(A), (B))
2980 #define tcg_gen_ext_i32_ptr(R, A) tcg_gen_ext_i32_i64(TCGV_PTR_TO_NAT(R), (A))
2981 #endif /* TCG_TARGET_REG_BITS != 32 */