]> git.proxmox.com Git - mirror_qemu.git/blame - tcg/tcg-op.h
tcg: make tcg_const_ptr actually accept a pointer argument
[mirror_qemu.git] / tcg / tcg-op.h
CommitLineData
c896fe29
FB
1/*
2 * Tiny Code Generator for QEMU
3 *
4 * Copyright (c) 2008 Fabrice Bellard
5 *
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:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
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
22 * THE SOFTWARE.
23 */
24#include "tcg.h"
25
c896fe29
FB
26int gen_new_label(void);
27
a9751609 28static inline void tcg_gen_op1_i32(TCGOpcode opc, TCGv_i32 arg1)
c896fe29
FB
29{
30 *gen_opc_ptr++ = opc;
a7812ae4
PB
31 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
32}
33
a9751609 34static inline void tcg_gen_op1_i64(TCGOpcode opc, TCGv_i64 arg1)
a7812ae4
PB
35{
36 *gen_opc_ptr++ = opc;
37 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
c896fe29
FB
38}
39
a9751609 40static inline void tcg_gen_op1i(TCGOpcode opc, TCGArg arg1)
c896fe29
FB
41{
42 *gen_opc_ptr++ = opc;
43 *gen_opparam_ptr++ = arg1;
c896fe29
FB
44}
45
a9751609 46static inline void tcg_gen_op2_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2)
a7812ae4
PB
47{
48 *gen_opc_ptr++ = opc;
49 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
50 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
51}
52
a9751609 53static inline void tcg_gen_op2_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2)
a7812ae4
PB
54{
55 *gen_opc_ptr++ = opc;
56 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
57 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
58}
59
a9751609 60static inline void tcg_gen_op2i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGArg arg2)
c896fe29
FB
61{
62 *gen_opc_ptr++ = opc;
a7812ae4
PB
63 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
64 *gen_opparam_ptr++ = arg2;
c896fe29
FB
65}
66
a9751609 67static inline void tcg_gen_op2i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGArg arg2)
c896fe29
FB
68{
69 *gen_opc_ptr++ = opc;
a7812ae4 70 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
c896fe29 71 *gen_opparam_ptr++ = arg2;
ac56dd48
PB
72}
73
a9751609 74static inline void tcg_gen_op2ii(TCGOpcode opc, TCGArg arg1, TCGArg arg2)
bcb0126f
PB
75{
76 *gen_opc_ptr++ = opc;
77 *gen_opparam_ptr++ = arg1;
78 *gen_opparam_ptr++ = arg2;
79}
80
a9751609 81static inline void tcg_gen_op3_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
a7812ae4
PB
82 TCGv_i32 arg3)
83{
84 *gen_opc_ptr++ = opc;
85 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
86 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
87 *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
88}
89
a9751609 90static inline void tcg_gen_op3_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
a7812ae4
PB
91 TCGv_i64 arg3)
92{
93 *gen_opc_ptr++ = opc;
94 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
95 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
96 *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
97}
98
a9751609
RH
99static inline void tcg_gen_op3i_i32(TCGOpcode opc, TCGv_i32 arg1,
100 TCGv_i32 arg2, TCGArg arg3)
ac56dd48
PB
101{
102 *gen_opc_ptr++ = opc;
a7812ae4
PB
103 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
104 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
105 *gen_opparam_ptr++ = arg3;
ac56dd48
PB
106}
107
a9751609
RH
108static inline void tcg_gen_op3i_i64(TCGOpcode opc, TCGv_i64 arg1,
109 TCGv_i64 arg2, TCGArg arg3)
ac56dd48
PB
110{
111 *gen_opc_ptr++ = opc;
a7812ae4
PB
112 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
113 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
c896fe29 114 *gen_opparam_ptr++ = arg3;
ac56dd48
PB
115}
116
a9751609
RH
117static inline void tcg_gen_ldst_op_i32(TCGOpcode opc, TCGv_i32 val,
118 TCGv_ptr base, TCGArg offset)
a7812ae4
PB
119{
120 *gen_opc_ptr++ = opc;
121 *gen_opparam_ptr++ = GET_TCGV_I32(val);
122 *gen_opparam_ptr++ = GET_TCGV_PTR(base);
123 *gen_opparam_ptr++ = offset;
124}
125
a9751609
RH
126static inline void tcg_gen_ldst_op_i64(TCGOpcode opc, TCGv_i64 val,
127 TCGv_ptr base, TCGArg offset)
a7812ae4
PB
128{
129 *gen_opc_ptr++ = opc;
a810a2de 130 *gen_opparam_ptr++ = GET_TCGV_I64(val);
a7812ae4
PB
131 *gen_opparam_ptr++ = GET_TCGV_PTR(base);
132 *gen_opparam_ptr++ = offset;
133}
134
a9751609
RH
135static inline void tcg_gen_qemu_ldst_op_i64_i32(TCGOpcode opc, TCGv_i64 val,
136 TCGv_i32 addr, TCGArg mem_index)
a7812ae4
PB
137{
138 *gen_opc_ptr++ = opc;
139 *gen_opparam_ptr++ = GET_TCGV_I64(val);
140 *gen_opparam_ptr++ = GET_TCGV_I32(addr);
141 *gen_opparam_ptr++ = mem_index;
142}
143
a9751609
RH
144static inline void tcg_gen_qemu_ldst_op_i64_i64(TCGOpcode opc, TCGv_i64 val,
145 TCGv_i64 addr, TCGArg mem_index)
a7812ae4
PB
146{
147 *gen_opc_ptr++ = opc;
148 *gen_opparam_ptr++ = GET_TCGV_I64(val);
149 *gen_opparam_ptr++ = GET_TCGV_I64(addr);
150 *gen_opparam_ptr++ = mem_index;
151}
152
a9751609 153static inline void tcg_gen_op4_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
a7812ae4
PB
154 TCGv_i32 arg3, TCGv_i32 arg4)
155{
156 *gen_opc_ptr++ = opc;
157 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
158 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
159 *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
160 *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
161}
162
a9751609 163static inline void tcg_gen_op4_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
a810a2de 164 TCGv_i64 arg3, TCGv_i64 arg4)
a7812ae4
PB
165{
166 *gen_opc_ptr++ = opc;
167 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
168 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
169 *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
170 *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
171}
172
a9751609 173static inline void tcg_gen_op4i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
a7812ae4
PB
174 TCGv_i32 arg3, TCGArg arg4)
175{
176 *gen_opc_ptr++ = opc;
177 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
178 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
179 *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
180 *gen_opparam_ptr++ = arg4;
181}
182
a9751609 183static inline void tcg_gen_op4i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
a7812ae4 184 TCGv_i64 arg3, TCGArg arg4)
ac56dd48
PB
185{
186 *gen_opc_ptr++ = opc;
a7812ae4
PB
187 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
188 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
189 *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
190 *gen_opparam_ptr++ = arg4;
ac56dd48
PB
191}
192
a9751609 193static inline void tcg_gen_op4ii_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
a7812ae4 194 TCGArg arg3, TCGArg arg4)
ac56dd48
PB
195{
196 *gen_opc_ptr++ = opc;
a7812ae4
PB
197 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
198 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
199 *gen_opparam_ptr++ = arg3;
c896fe29
FB
200 *gen_opparam_ptr++ = arg4;
201}
202
a9751609 203static inline void tcg_gen_op4ii_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
a7812ae4 204 TCGArg arg3, TCGArg arg4)
c896fe29
FB
205{
206 *gen_opc_ptr++ = opc;
a7812ae4
PB
207 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
208 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
c896fe29
FB
209 *gen_opparam_ptr++ = arg3;
210 *gen_opparam_ptr++ = arg4;
ac56dd48
PB
211}
212
a9751609 213static inline void tcg_gen_op5_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
a7812ae4
PB
214 TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5)
215{
216 *gen_opc_ptr++ = opc;
217 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
218 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
219 *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
220 *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
221 *gen_opparam_ptr++ = GET_TCGV_I32(arg5);
222}
223
a9751609 224static inline void tcg_gen_op5_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
a7812ae4
PB
225 TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5)
226{
227 *gen_opc_ptr++ = opc;
228 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
229 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
230 *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
231 *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
232 *gen_opparam_ptr++ = GET_TCGV_I64(arg5);
233}
234
a9751609 235static inline void tcg_gen_op5i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
a7812ae4 236 TCGv_i32 arg3, TCGv_i32 arg4, TCGArg arg5)
ac56dd48
PB
237{
238 *gen_opc_ptr++ = opc;
a7812ae4
PB
239 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
240 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
241 *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
242 *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
243 *gen_opparam_ptr++ = arg5;
ac56dd48
PB
244}
245
a9751609 246static inline void tcg_gen_op5i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
a7812ae4 247 TCGv_i64 arg3, TCGv_i64 arg4, TCGArg arg5)
ac56dd48
PB
248{
249 *gen_opc_ptr++ = opc;
a7812ae4
PB
250 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
251 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
252 *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
253 *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
c896fe29
FB
254 *gen_opparam_ptr++ = arg5;
255}
256
b7767f0f
RH
257static inline void tcg_gen_op5ii_i32(TCGOpcode opc, TCGv_i32 arg1,
258 TCGv_i32 arg2, TCGv_i32 arg3,
259 TCGArg arg4, TCGArg arg5)
260{
261 *gen_opc_ptr++ = opc;
262 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
263 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
264 *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
265 *gen_opparam_ptr++ = arg4;
266 *gen_opparam_ptr++ = arg5;
267}
268
269static inline void tcg_gen_op5ii_i64(TCGOpcode opc, TCGv_i64 arg1,
270 TCGv_i64 arg2, TCGv_i64 arg3,
271 TCGArg arg4, TCGArg arg5)
272{
273 *gen_opc_ptr++ = opc;
274 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
275 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
276 *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
277 *gen_opparam_ptr++ = arg4;
278 *gen_opparam_ptr++ = arg5;
279}
280
a9751609 281static inline void tcg_gen_op6_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
a7812ae4
PB
282 TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5,
283 TCGv_i32 arg6)
284{
285 *gen_opc_ptr++ = opc;
286 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
287 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
288 *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
289 *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
290 *gen_opparam_ptr++ = GET_TCGV_I32(arg5);
291 *gen_opparam_ptr++ = GET_TCGV_I32(arg6);
292}
293
a9751609 294static inline void tcg_gen_op6_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
a7812ae4
PB
295 TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5,
296 TCGv_i64 arg6)
c896fe29
FB
297{
298 *gen_opc_ptr++ = opc;
a7812ae4
PB
299 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
300 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
301 *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
302 *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
303 *gen_opparam_ptr++ = GET_TCGV_I64(arg5);
304 *gen_opparam_ptr++ = GET_TCGV_I64(arg6);
ac56dd48
PB
305}
306
a9751609 307static inline void tcg_gen_op6i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2,
be210acb
RH
308 TCGv_i32 arg3, TCGv_i32 arg4,
309 TCGv_i32 arg5, TCGArg arg6)
310{
311 *gen_opc_ptr++ = opc;
312 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
313 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
314 *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
315 *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
316 *gen_opparam_ptr++ = GET_TCGV_I32(arg5);
317 *gen_opparam_ptr++ = arg6;
318}
319
a9751609 320static inline void tcg_gen_op6i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2,
be210acb
RH
321 TCGv_i64 arg3, TCGv_i64 arg4,
322 TCGv_i64 arg5, TCGArg arg6)
323{
324 *gen_opc_ptr++ = opc;
325 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
326 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
327 *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
328 *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
329 *gen_opparam_ptr++ = GET_TCGV_I64(arg5);
330 *gen_opparam_ptr++ = arg6;
331}
332
a9751609
RH
333static inline void tcg_gen_op6ii_i32(TCGOpcode opc, TCGv_i32 arg1,
334 TCGv_i32 arg2, TCGv_i32 arg3,
335 TCGv_i32 arg4, TCGArg arg5, TCGArg arg6)
ac56dd48
PB
336{
337 *gen_opc_ptr++ = opc;
a7812ae4
PB
338 *gen_opparam_ptr++ = GET_TCGV_I32(arg1);
339 *gen_opparam_ptr++ = GET_TCGV_I32(arg2);
340 *gen_opparam_ptr++ = GET_TCGV_I32(arg3);
341 *gen_opparam_ptr++ = GET_TCGV_I32(arg4);
342 *gen_opparam_ptr++ = arg5;
343 *gen_opparam_ptr++ = arg6;
344}
345
a9751609
RH
346static inline void tcg_gen_op6ii_i64(TCGOpcode opc, TCGv_i64 arg1,
347 TCGv_i64 arg2, TCGv_i64 arg3,
348 TCGv_i64 arg4, TCGArg arg5, TCGArg arg6)
a7812ae4
PB
349{
350 *gen_opc_ptr++ = opc;
351 *gen_opparam_ptr++ = GET_TCGV_I64(arg1);
352 *gen_opparam_ptr++ = GET_TCGV_I64(arg2);
353 *gen_opparam_ptr++ = GET_TCGV_I64(arg3);
354 *gen_opparam_ptr++ = GET_TCGV_I64(arg4);
c896fe29
FB
355 *gen_opparam_ptr++ = arg5;
356 *gen_opparam_ptr++ = arg6;
357}
358
359static inline void gen_set_label(int n)
360{
ac56dd48 361 tcg_gen_op1i(INDEX_op_set_label, n);
c896fe29
FB
362}
363
fb50d413
BS
364static inline void tcg_gen_br(int label)
365{
366 tcg_gen_op1i(INDEX_op_br, label);
367}
368
a7812ae4 369static inline void tcg_gen_mov_i32(TCGv_i32 ret, TCGv_i32 arg)
c896fe29 370{
fe75bcf7 371 if (!TCGV_EQUAL_I32(ret, arg))
a7812ae4 372 tcg_gen_op2_i32(INDEX_op_mov_i32, ret, arg);
c896fe29
FB
373}
374
a7812ae4 375static inline void tcg_gen_movi_i32(TCGv_i32 ret, int32_t arg)
c896fe29 376{
a7812ae4 377 tcg_gen_op2i_i32(INDEX_op_movi_i32, ret, arg);
c896fe29
FB
378}
379
2bece2c8
RH
380/* A version of dh_sizemask from def-helper.h that doesn't rely on
381 preprocessor magic. */
382static inline int tcg_gen_sizemask(int n, int is_64bit, int is_signed)
383{
384 return (is_64bit << n*2) | (is_signed << (n*2 + 1));
385}
386
c896fe29 387/* helper calls */
a7812ae4
PB
388static inline void tcg_gen_helperN(void *func, int flags, int sizemask,
389 TCGArg ret, int nargs, TCGArg *args)
390{
391 TCGv_ptr fn;
73f5e313 392 fn = tcg_const_ptr(func);
a7812ae4
PB
393 tcg_gen_callN(&tcg_ctx, fn, flags, sizemask, ret,
394 nargs, args);
395 tcg_temp_free_ptr(fn);
396}
c896fe29 397
dbfff4de
AJ
398/* Note: Both tcg_gen_helper32() and tcg_gen_helper64() are currently
399 reserved for helpers in tcg-runtime.c. These helpers are all const
400 and pure, hence the call to tcg_gen_callN() with TCG_CALL_CONST |
401 TCG_CALL_PURE. This may need to be adjusted if these functions
402 start to be used with other helpers. */
2bece2c8 403static inline void tcg_gen_helper32(void *func, int sizemask, TCGv_i32 ret,
31d66551
AJ
404 TCGv_i32 a, TCGv_i32 b)
405{
406 TCGv_ptr fn;
407 TCGArg args[2];
73f5e313 408 fn = tcg_const_ptr(func);
31d66551
AJ
409 args[0] = GET_TCGV_I32(a);
410 args[1] = GET_TCGV_I32(b);
2bece2c8
RH
411 tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,
412 GET_TCGV_I32(ret), 2, args);
31d66551
AJ
413 tcg_temp_free_ptr(fn);
414}
415
2bece2c8 416static inline void tcg_gen_helper64(void *func, int sizemask, TCGv_i64 ret,
a7812ae4 417 TCGv_i64 a, TCGv_i64 b)
c896fe29 418{
a7812ae4
PB
419 TCGv_ptr fn;
420 TCGArg args[2];
73f5e313 421 fn = tcg_const_ptr(func);
a7812ae4
PB
422 args[0] = GET_TCGV_I64(a);
423 args[1] = GET_TCGV_I64(b);
2bece2c8
RH
424 tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,
425 GET_TCGV_I64(ret), 2, args);
a7812ae4 426 tcg_temp_free_ptr(fn);
f8422f52
BS
427}
428
c896fe29
FB
429/* 32 bit ops */
430
a7812ae4 431static inline void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 432{
a7812ae4 433 tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32, ret, arg2, offset);
c896fe29
FB
434}
435
a7812ae4 436static inline void tcg_gen_ld8s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 437{
a7812ae4 438 tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32, ret, arg2, offset);
c896fe29
FB
439}
440
a7812ae4 441static inline void tcg_gen_ld16u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 442{
a7812ae4 443 tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32, ret, arg2, offset);
c896fe29
FB
444}
445
a7812ae4 446static inline void tcg_gen_ld16s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 447{
a7812ae4 448 tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32, ret, arg2, offset);
c896fe29
FB
449}
450
a7812ae4 451static inline void tcg_gen_ld_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 452{
a7812ae4 453 tcg_gen_ldst_op_i32(INDEX_op_ld_i32, ret, arg2, offset);
c896fe29
FB
454}
455
a7812ae4 456static inline void tcg_gen_st8_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 457{
a7812ae4 458 tcg_gen_ldst_op_i32(INDEX_op_st8_i32, arg1, arg2, offset);
c896fe29
FB
459}
460
a7812ae4 461static inline void tcg_gen_st16_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 462{
a7812ae4 463 tcg_gen_ldst_op_i32(INDEX_op_st16_i32, arg1, arg2, offset);
c896fe29
FB
464}
465
a7812ae4 466static inline void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 467{
a7812ae4 468 tcg_gen_ldst_op_i32(INDEX_op_st_i32, arg1, arg2, offset);
c896fe29
FB
469}
470
a7812ae4 471static inline void tcg_gen_add_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 472{
a7812ae4 473 tcg_gen_op3_i32(INDEX_op_add_i32, ret, arg1, arg2);
c896fe29
FB
474}
475
a7812ae4 476static inline void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29 477{
7089442c
BS
478 /* some cases can be optimized here */
479 if (arg2 == 0) {
480 tcg_gen_mov_i32(ret, arg1);
481 } else {
a7812ae4 482 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 483 tcg_gen_add_i32(ret, arg1, t0);
a7812ae4 484 tcg_temp_free_i32(t0);
7089442c 485 }
c896fe29
FB
486}
487
a7812ae4 488static inline void tcg_gen_sub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 489{
a7812ae4 490 tcg_gen_op3_i32(INDEX_op_sub_i32, ret, arg1, arg2);
c896fe29
FB
491}
492
a7812ae4 493static inline void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2)
0045734a 494{
a7812ae4 495 TCGv_i32 t0 = tcg_const_i32(arg1);
0045734a 496 tcg_gen_sub_i32(ret, t0, arg2);
a7812ae4 497 tcg_temp_free_i32(t0);
0045734a
AJ
498}
499
a7812ae4 500static inline void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29 501{
7089442c
BS
502 /* some cases can be optimized here */
503 if (arg2 == 0) {
504 tcg_gen_mov_i32(ret, arg1);
505 } else {
a7812ae4 506 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 507 tcg_gen_sub_i32(ret, arg1, t0);
a7812ae4 508 tcg_temp_free_i32(t0);
7089442c 509 }
c896fe29
FB
510}
511
a7812ae4 512static inline void tcg_gen_and_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 513{
7fc81051
AJ
514 if (TCGV_EQUAL_I32(arg1, arg2)) {
515 tcg_gen_mov_i32(ret, arg1);
516 } else {
517 tcg_gen_op3_i32(INDEX_op_and_i32, ret, arg1, arg2);
518 }
c896fe29
FB
519}
520
a7812ae4 521static inline void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29
FB
522{
523 /* some cases can be optimized here */
524 if (arg2 == 0) {
525 tcg_gen_movi_i32(ret, 0);
526 } else if (arg2 == 0xffffffff) {
527 tcg_gen_mov_i32(ret, arg1);
528 } else {
a7812ae4 529 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 530 tcg_gen_and_i32(ret, arg1, t0);
a7812ae4 531 tcg_temp_free_i32(t0);
c896fe29
FB
532 }
533}
534
a7812ae4 535static inline void tcg_gen_or_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 536{
7fc81051
AJ
537 if (TCGV_EQUAL_I32(arg1, arg2)) {
538 tcg_gen_mov_i32(ret, arg1);
539 } else {
540 tcg_gen_op3_i32(INDEX_op_or_i32, ret, arg1, arg2);
541 }
c896fe29
FB
542}
543
a7812ae4 544static inline void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29
FB
545{
546 /* some cases can be optimized here */
547 if (arg2 == 0xffffffff) {
7089442c 548 tcg_gen_movi_i32(ret, 0xffffffff);
c896fe29
FB
549 } else if (arg2 == 0) {
550 tcg_gen_mov_i32(ret, arg1);
551 } else {
a7812ae4 552 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 553 tcg_gen_or_i32(ret, arg1, t0);
a7812ae4 554 tcg_temp_free_i32(t0);
c896fe29
FB
555 }
556}
557
a7812ae4 558static inline void tcg_gen_xor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 559{
7fc81051
AJ
560 if (TCGV_EQUAL_I32(arg1, arg2)) {
561 tcg_gen_movi_i32(ret, 0);
562 } else {
563 tcg_gen_op3_i32(INDEX_op_xor_i32, ret, arg1, arg2);
564 }
c896fe29
FB
565}
566
a7812ae4 567static inline void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29
FB
568{
569 /* some cases can be optimized here */
570 if (arg2 == 0) {
571 tcg_gen_mov_i32(ret, arg1);
572 } else {
a7812ae4 573 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 574 tcg_gen_xor_i32(ret, arg1, t0);
a7812ae4 575 tcg_temp_free_i32(t0);
c896fe29
FB
576 }
577}
578
a7812ae4 579static inline void tcg_gen_shl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 580{
a7812ae4 581 tcg_gen_op3_i32(INDEX_op_shl_i32, ret, arg1, arg2);
c896fe29
FB
582}
583
a7812ae4 584static inline void tcg_gen_shli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29 585{
34151a20
FB
586 if (arg2 == 0) {
587 tcg_gen_mov_i32(ret, arg1);
588 } else {
a7812ae4 589 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 590 tcg_gen_shl_i32(ret, arg1, t0);
a7812ae4 591 tcg_temp_free_i32(t0);
34151a20 592 }
c896fe29
FB
593}
594
a7812ae4 595static inline void tcg_gen_shr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 596{
a7812ae4 597 tcg_gen_op3_i32(INDEX_op_shr_i32, ret, arg1, arg2);
c896fe29
FB
598}
599
a7812ae4 600static inline void tcg_gen_shri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29 601{
34151a20
FB
602 if (arg2 == 0) {
603 tcg_gen_mov_i32(ret, arg1);
604 } else {
a7812ae4 605 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 606 tcg_gen_shr_i32(ret, arg1, t0);
a7812ae4 607 tcg_temp_free_i32(t0);
34151a20 608 }
c896fe29
FB
609}
610
a7812ae4 611static inline void tcg_gen_sar_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 612{
a7812ae4 613 tcg_gen_op3_i32(INDEX_op_sar_i32, ret, arg1, arg2);
c896fe29
FB
614}
615
a7812ae4 616static inline void tcg_gen_sari_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29 617{
34151a20
FB
618 if (arg2 == 0) {
619 tcg_gen_mov_i32(ret, arg1);
620 } else {
a7812ae4 621 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 622 tcg_gen_sar_i32(ret, arg1, t0);
a7812ae4 623 tcg_temp_free_i32(t0);
34151a20 624 }
c896fe29
FB
625}
626
8a56e840
RH
627static inline void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1,
628 TCGv_i32 arg2, int label_index)
c896fe29 629{
a7812ae4 630 tcg_gen_op4ii_i32(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
c896fe29
FB
631}
632
8a56e840
RH
633static inline void tcg_gen_brcondi_i32(TCGCond cond, TCGv_i32 arg1,
634 int32_t arg2, int label_index)
cb63669a 635{
a7812ae4 636 TCGv_i32 t0 = tcg_const_i32(arg2);
cb63669a 637 tcg_gen_brcond_i32(cond, arg1, t0, label_index);
a7812ae4 638 tcg_temp_free_i32(t0);
cb63669a
PB
639}
640
8a56e840 641static inline void tcg_gen_setcond_i32(TCGCond cond, TCGv_i32 ret,
5105c556
AJ
642 TCGv_i32 arg1, TCGv_i32 arg2)
643{
644 tcg_gen_op4i_i32(INDEX_op_setcond_i32, ret, arg1, arg2, cond);
645}
646
8a56e840
RH
647static inline void tcg_gen_setcondi_i32(TCGCond cond, TCGv_i32 ret,
648 TCGv_i32 arg1, int32_t arg2)
5105c556
AJ
649{
650 TCGv_i32 t0 = tcg_const_i32(arg2);
651 tcg_gen_setcond_i32(cond, ret, arg1, t0);
652 tcg_temp_free_i32(t0);
653}
654
a7812ae4 655static inline void tcg_gen_mul_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 656{
a7812ae4 657 tcg_gen_op3_i32(INDEX_op_mul_i32, ret, arg1, arg2);
c896fe29
FB
658}
659
a7812ae4 660static inline void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
f730fd27 661{
a7812ae4 662 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 663 tcg_gen_mul_i32(ret, arg1, t0);
a7812ae4 664 tcg_temp_free_i32(t0);
f730fd27
TS
665}
666
a7812ae4 667static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 668{
25c4d9cc
RH
669 if (TCG_TARGET_HAS_div_i32) {
670 tcg_gen_op3_i32(INDEX_op_div_i32, ret, arg1, arg2);
671 } else if (TCG_TARGET_HAS_div2_i32) {
672 TCGv_i32 t0 = tcg_temp_new_i32();
673 tcg_gen_sari_i32(t0, arg1, 31);
674 tcg_gen_op5_i32(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
675 tcg_temp_free_i32(t0);
676 } else {
677 int sizemask = 0;
678 /* Return value and both arguments are 32-bit and signed. */
679 sizemask |= tcg_gen_sizemask(0, 0, 1);
680 sizemask |= tcg_gen_sizemask(1, 0, 1);
681 sizemask |= tcg_gen_sizemask(2, 0, 1);
682 tcg_gen_helper32(tcg_helper_div_i32, sizemask, ret, arg1, arg2);
683 }
31d66551
AJ
684}
685
686static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
687{
25c4d9cc
RH
688 if (TCG_TARGET_HAS_div_i32) {
689 tcg_gen_op3_i32(INDEX_op_rem_i32, ret, arg1, arg2);
690 } else if (TCG_TARGET_HAS_div2_i32) {
691 TCGv_i32 t0 = tcg_temp_new_i32();
692 tcg_gen_sari_i32(t0, arg1, 31);
693 tcg_gen_op5_i32(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
694 tcg_temp_free_i32(t0);
695 } else {
696 int sizemask = 0;
697 /* Return value and both arguments are 32-bit and signed. */
698 sizemask |= tcg_gen_sizemask(0, 0, 1);
699 sizemask |= tcg_gen_sizemask(1, 0, 1);
700 sizemask |= tcg_gen_sizemask(2, 0, 1);
701 tcg_gen_helper32(tcg_helper_rem_i32, sizemask, ret, arg1, arg2);
702 }
31d66551
AJ
703}
704
705static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
706{
25c4d9cc
RH
707 if (TCG_TARGET_HAS_div_i32) {
708 tcg_gen_op3_i32(INDEX_op_divu_i32, ret, arg1, arg2);
709 } else if (TCG_TARGET_HAS_div2_i32) {
710 TCGv_i32 t0 = tcg_temp_new_i32();
711 tcg_gen_movi_i32(t0, 0);
712 tcg_gen_op5_i32(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
713 tcg_temp_free_i32(t0);
714 } else {
715 int sizemask = 0;
716 /* Return value and both arguments are 32-bit and unsigned. */
717 sizemask |= tcg_gen_sizemask(0, 0, 0);
718 sizemask |= tcg_gen_sizemask(1, 0, 0);
719 sizemask |= tcg_gen_sizemask(2, 0, 0);
720 tcg_gen_helper32(tcg_helper_divu_i32, sizemask, ret, arg1, arg2);
721 }
31d66551
AJ
722}
723
724static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
725{
25c4d9cc
RH
726 if (TCG_TARGET_HAS_div_i32) {
727 tcg_gen_op3_i32(INDEX_op_remu_i32, ret, arg1, arg2);
728 } else if (TCG_TARGET_HAS_div2_i32) {
729 TCGv_i32 t0 = tcg_temp_new_i32();
730 tcg_gen_movi_i32(t0, 0);
731 tcg_gen_op5_i32(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
732 tcg_temp_free_i32(t0);
733 } else {
734 int sizemask = 0;
735 /* Return value and both arguments are 32-bit and unsigned. */
736 sizemask |= tcg_gen_sizemask(0, 0, 0);
737 sizemask |= tcg_gen_sizemask(1, 0, 0);
738 sizemask |= tcg_gen_sizemask(2, 0, 0);
739 tcg_gen_helper32(tcg_helper_remu_i32, sizemask, ret, arg1, arg2);
740 }
31d66551 741}
c896fe29
FB
742
743#if TCG_TARGET_REG_BITS == 32
744
a7812ae4 745static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 746{
fe75bcf7 747 if (!TCGV_EQUAL_I64(ret, arg)) {
a7812ae4 748 tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
4d07272d
BS
749 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
750 }
c896fe29
FB
751}
752
a7812ae4 753static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
c896fe29 754{
a7812ae4 755 tcg_gen_movi_i32(TCGV_LOW(ret), arg);
ac56dd48 756 tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
c896fe29
FB
757}
758
a7812ae4
PB
759static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2,
760 tcg_target_long offset)
c896fe29 761{
a7812ae4 762 tcg_gen_ld8u_i32(TCGV_LOW(ret), arg2, offset);
ac56dd48 763 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
764}
765
a7812ae4
PB
766static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2,
767 tcg_target_long offset)
c896fe29 768{
a7812ae4
PB
769 tcg_gen_ld8s_i32(TCGV_LOW(ret), arg2, offset);
770 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), 31);
c896fe29
FB
771}
772
a7812ae4
PB
773static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2,
774 tcg_target_long offset)
c896fe29 775{
a747723b 776 tcg_gen_ld16u_i32(TCGV_LOW(ret), arg2, offset);
ac56dd48 777 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
778}
779
a7812ae4
PB
780static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2,
781 tcg_target_long offset)
c896fe29 782{
a7812ae4
PB
783 tcg_gen_ld16s_i32(TCGV_LOW(ret), arg2, offset);
784 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
785}
786
a7812ae4
PB
787static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2,
788 tcg_target_long offset)
c896fe29 789{
a7812ae4 790 tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
ac56dd48 791 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
792}
793
a7812ae4
PB
794static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2,
795 tcg_target_long offset)
c896fe29 796{
a7812ae4
PB
797 tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
798 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
799}
800
a7812ae4
PB
801static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2,
802 tcg_target_long offset)
c896fe29
FB
803{
804 /* since arg2 and ret have different types, they cannot be the
805 same temporary */
806#ifdef TCG_TARGET_WORDS_BIGENDIAN
ac56dd48 807 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
a7812ae4 808 tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset + 4);
c896fe29 809#else
a7812ae4 810 tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
ac56dd48 811 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
c896fe29
FB
812#endif
813}
814
a7812ae4
PB
815static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2,
816 tcg_target_long offset)
c896fe29 817{
a7812ae4 818 tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset);
c896fe29
FB
819}
820
a7812ae4
PB
821static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2,
822 tcg_target_long offset)
c896fe29 823{
a7812ae4 824 tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset);
c896fe29
FB
825}
826
a7812ae4
PB
827static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2,
828 tcg_target_long offset)
c896fe29 829{
a7812ae4 830 tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
c896fe29
FB
831}
832
a7812ae4
PB
833static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2,
834 tcg_target_long offset)
c896fe29
FB
835{
836#ifdef TCG_TARGET_WORDS_BIGENDIAN
ac56dd48 837 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
a7812ae4 838 tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset + 4);
c896fe29 839#else
a7812ae4 840 tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
ac56dd48 841 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
c896fe29
FB
842#endif
843}
844
a7812ae4 845static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 846{
a7812ae4
PB
847 tcg_gen_op6_i32(INDEX_op_add2_i32, TCGV_LOW(ret), TCGV_HIGH(ret),
848 TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
849 TCGV_HIGH(arg2));
c896fe29
FB
850}
851
a7812ae4 852static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 853{
a7812ae4
PB
854 tcg_gen_op6_i32(INDEX_op_sub2_i32, TCGV_LOW(ret), TCGV_HIGH(ret),
855 TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
856 TCGV_HIGH(arg2));
c896fe29
FB
857}
858
a7812ae4 859static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 860{
a7812ae4 861 tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
ac56dd48 862 tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
c896fe29
FB
863}
864
a7812ae4 865static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 866{
e5105083
AJ
867 tcg_gen_andi_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
868 tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
c896fe29
FB
869}
870
a7812ae4 871static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 872{
e5105083
AJ
873 tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
874 tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
c896fe29
FB
875}
876
a7812ae4 877static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 878{
a7812ae4 879 tcg_gen_ori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
ac56dd48 880 tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
c896fe29
FB
881}
882
a7812ae4 883static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 884{
e5105083
AJ
885 tcg_gen_xor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
886 tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
c896fe29
FB
887}
888
a7812ae4 889static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 890{
a7812ae4 891 tcg_gen_xori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
ac56dd48 892 tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
c896fe29
FB
893}
894
895/* XXX: use generic code when basic block handling is OK or CPU
896 specific code (x86) */
a7812ae4 897static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 898{
2bece2c8
RH
899 int sizemask = 0;
900 /* Return value and both arguments are 64-bit and signed. */
901 sizemask |= tcg_gen_sizemask(0, 1, 1);
902 sizemask |= tcg_gen_sizemask(1, 1, 1);
903 sizemask |= tcg_gen_sizemask(2, 1, 1);
904
905 tcg_gen_helper64(tcg_helper_shl_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
906}
907
a7812ae4 908static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29
FB
909{
910 tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
911}
912
a7812ae4 913static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 914{
2bece2c8
RH
915 int sizemask = 0;
916 /* Return value and both arguments are 64-bit and signed. */
917 sizemask |= tcg_gen_sizemask(0, 1, 1);
918 sizemask |= tcg_gen_sizemask(1, 1, 1);
919 sizemask |= tcg_gen_sizemask(2, 1, 1);
920
921 tcg_gen_helper64(tcg_helper_shr_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
922}
923
a7812ae4 924static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29
FB
925{
926 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
927}
928
a7812ae4 929static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 930{
2bece2c8
RH
931 int sizemask = 0;
932 /* Return value and both arguments are 64-bit and signed. */
933 sizemask |= tcg_gen_sizemask(0, 1, 1);
934 sizemask |= tcg_gen_sizemask(1, 1, 1);
935 sizemask |= tcg_gen_sizemask(2, 1, 1);
936
937 tcg_gen_helper64(tcg_helper_sar_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
938}
939
a7812ae4 940static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29
FB
941{
942 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
943}
944
8a56e840
RH
945static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1,
946 TCGv_i64 arg2, int label_index)
c896fe29 947{
a7812ae4
PB
948 tcg_gen_op6ii_i32(INDEX_op_brcond2_i32,
949 TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
950 TCGV_HIGH(arg2), cond, label_index);
c896fe29
FB
951}
952
8a56e840 953static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret,
5105c556
AJ
954 TCGv_i64 arg1, TCGv_i64 arg2)
955{
956 tcg_gen_op6i_i32(INDEX_op_setcond2_i32, TCGV_LOW(ret),
957 TCGV_LOW(arg1), TCGV_HIGH(arg1),
958 TCGV_LOW(arg2), TCGV_HIGH(arg2), cond);
959 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
960}
961
a7812ae4 962static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 963{
a7812ae4
PB
964 TCGv_i64 t0;
965 TCGv_i32 t1;
c896fe29 966
a7812ae4
PB
967 t0 = tcg_temp_new_i64();
968 t1 = tcg_temp_new_i32();
969
970 tcg_gen_op4_i32(INDEX_op_mulu2_i32, TCGV_LOW(t0), TCGV_HIGH(t0),
971 TCGV_LOW(arg1), TCGV_LOW(arg2));
972
973 tcg_gen_mul_i32(t1, TCGV_LOW(arg1), TCGV_HIGH(arg2));
ac56dd48 974 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
a7812ae4 975 tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), TCGV_LOW(arg2));
ac56dd48 976 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
a7812ae4 977
c896fe29 978 tcg_gen_mov_i64(ret, t0);
a7812ae4
PB
979 tcg_temp_free_i64(t0);
980 tcg_temp_free_i32(t1);
c896fe29
FB
981}
982
a7812ae4 983static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 984{
2bece2c8
RH
985 int sizemask = 0;
986 /* Return value and both arguments are 64-bit and signed. */
987 sizemask |= tcg_gen_sizemask(0, 1, 1);
988 sizemask |= tcg_gen_sizemask(1, 1, 1);
989 sizemask |= tcg_gen_sizemask(2, 1, 1);
990
991 tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
992}
993
a7812ae4 994static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 995{
2bece2c8
RH
996 int sizemask = 0;
997 /* Return value and both arguments are 64-bit and signed. */
998 sizemask |= tcg_gen_sizemask(0, 1, 1);
999 sizemask |= tcg_gen_sizemask(1, 1, 1);
1000 sizemask |= tcg_gen_sizemask(2, 1, 1);
1001
1002 tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
1003}
1004
a7812ae4 1005static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1006{
2bece2c8
RH
1007 int sizemask = 0;
1008 /* Return value and both arguments are 64-bit and unsigned. */
1009 sizemask |= tcg_gen_sizemask(0, 1, 0);
1010 sizemask |= tcg_gen_sizemask(1, 1, 0);
1011 sizemask |= tcg_gen_sizemask(2, 1, 0);
1012
1013 tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
1014}
1015
a7812ae4 1016static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1017{
2bece2c8
RH
1018 int sizemask = 0;
1019 /* Return value and both arguments are 64-bit and unsigned. */
1020 sizemask |= tcg_gen_sizemask(0, 1, 0);
1021 sizemask |= tcg_gen_sizemask(1, 1, 0);
1022 sizemask |= tcg_gen_sizemask(2, 1, 0);
1023
1024 tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
1025}
1026
1027#else
1028
a7812ae4 1029static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1030{
fe75bcf7 1031 if (!TCGV_EQUAL_I64(ret, arg))
a7812ae4 1032 tcg_gen_op2_i64(INDEX_op_mov_i64, ret, arg);
c896fe29
FB
1033}
1034
a7812ae4 1035static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
c896fe29 1036{
a7812ae4 1037 tcg_gen_op2i_i64(INDEX_op_movi_i64, ret, arg);
c896fe29
FB
1038}
1039
6bd4b08a 1040static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1041 tcg_target_long offset)
c896fe29 1042{
a7812ae4 1043 tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64, ret, arg2, offset);
c896fe29
FB
1044}
1045
6bd4b08a 1046static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1047 tcg_target_long offset)
c896fe29 1048{
a7812ae4 1049 tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64, ret, arg2, offset);
c896fe29
FB
1050}
1051
6bd4b08a 1052static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1053 tcg_target_long offset)
c896fe29 1054{
a7812ae4 1055 tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64, ret, arg2, offset);
c896fe29
FB
1056}
1057
6bd4b08a 1058static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1059 tcg_target_long offset)
c896fe29 1060{
a7812ae4 1061 tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64, ret, arg2, offset);
c896fe29
FB
1062}
1063
6bd4b08a 1064static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1065 tcg_target_long offset)
c896fe29 1066{
a7812ae4 1067 tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64, ret, arg2, offset);
c896fe29
FB
1068}
1069
6bd4b08a 1070static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1071 tcg_target_long offset)
c896fe29 1072{
a7812ae4 1073 tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64, ret, arg2, offset);
c896fe29
FB
1074}
1075
6bd4b08a 1076static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 1077{
a7812ae4 1078 tcg_gen_ldst_op_i64(INDEX_op_ld_i64, ret, arg2, offset);
c896fe29
FB
1079}
1080
6bd4b08a 1081static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2,
ac56dd48 1082 tcg_target_long offset)
c896fe29 1083{
a7812ae4 1084 tcg_gen_ldst_op_i64(INDEX_op_st8_i64, arg1, arg2, offset);
c896fe29
FB
1085}
1086
6bd4b08a 1087static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2,
ac56dd48 1088 tcg_target_long offset)
c896fe29 1089{
a7812ae4 1090 tcg_gen_ldst_op_i64(INDEX_op_st16_i64, arg1, arg2, offset);
c896fe29
FB
1091}
1092
6bd4b08a 1093static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2,
ac56dd48 1094 tcg_target_long offset)
c896fe29 1095{
a7812ae4 1096 tcg_gen_ldst_op_i64(INDEX_op_st32_i64, arg1, arg2, offset);
c896fe29
FB
1097}
1098
6bd4b08a 1099static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 1100{
a7812ae4 1101 tcg_gen_ldst_op_i64(INDEX_op_st_i64, arg1, arg2, offset);
c896fe29
FB
1102}
1103
a7812ae4 1104static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1105{
a7812ae4 1106 tcg_gen_op3_i64(INDEX_op_add_i64, ret, arg1, arg2);
c896fe29
FB
1107}
1108
a7812ae4 1109static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1110{
a7812ae4 1111 tcg_gen_op3_i64(INDEX_op_sub_i64, ret, arg1, arg2);
c896fe29
FB
1112}
1113
a7812ae4 1114static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1115{
7fc81051
AJ
1116 if (TCGV_EQUAL_I64(arg1, arg2)) {
1117 tcg_gen_mov_i64(ret, arg1);
1118 } else {
1119 tcg_gen_op3_i64(INDEX_op_and_i64, ret, arg1, arg2);
1120 }
c896fe29
FB
1121}
1122
a7812ae4 1123static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1124{
a7812ae4 1125 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1126 tcg_gen_and_i64(ret, arg1, t0);
a7812ae4 1127 tcg_temp_free_i64(t0);
c896fe29
FB
1128}
1129
a7812ae4 1130static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1131{
7fc81051
AJ
1132 if (TCGV_EQUAL_I64(arg1, arg2)) {
1133 tcg_gen_mov_i64(ret, arg1);
1134 } else {
1135 tcg_gen_op3_i64(INDEX_op_or_i64, ret, arg1, arg2);
1136 }
c896fe29
FB
1137}
1138
a7812ae4 1139static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1140{
a7812ae4 1141 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1142 tcg_gen_or_i64(ret, arg1, t0);
a7812ae4 1143 tcg_temp_free_i64(t0);
c896fe29
FB
1144}
1145
a7812ae4 1146static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1147{
7fc81051
AJ
1148 if (TCGV_EQUAL_I64(arg1, arg2)) {
1149 tcg_gen_movi_i64(ret, 0);
1150 } else {
1151 tcg_gen_op3_i64(INDEX_op_xor_i64, ret, arg1, arg2);
1152 }
c896fe29
FB
1153}
1154
a7812ae4 1155static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1156{
a7812ae4 1157 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1158 tcg_gen_xor_i64(ret, arg1, t0);
a7812ae4 1159 tcg_temp_free_i64(t0);
c896fe29
FB
1160}
1161
a7812ae4 1162static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1163{
a7812ae4 1164 tcg_gen_op3_i64(INDEX_op_shl_i64, ret, arg1, arg2);
c896fe29
FB
1165}
1166
a7812ae4 1167static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1168{
34151a20
FB
1169 if (arg2 == 0) {
1170 tcg_gen_mov_i64(ret, arg1);
1171 } else {
a7812ae4 1172 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1173 tcg_gen_shl_i64(ret, arg1, t0);
a7812ae4 1174 tcg_temp_free_i64(t0);
34151a20 1175 }
c896fe29
FB
1176}
1177
a7812ae4 1178static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1179{
a7812ae4 1180 tcg_gen_op3_i64(INDEX_op_shr_i64, ret, arg1, arg2);
c896fe29
FB
1181}
1182
a7812ae4 1183static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1184{
34151a20
FB
1185 if (arg2 == 0) {
1186 tcg_gen_mov_i64(ret, arg1);
1187 } else {
a7812ae4 1188 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1189 tcg_gen_shr_i64(ret, arg1, t0);
a7812ae4 1190 tcg_temp_free_i64(t0);
34151a20 1191 }
c896fe29
FB
1192}
1193
a7812ae4 1194static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1195{
a7812ae4 1196 tcg_gen_op3_i64(INDEX_op_sar_i64, ret, arg1, arg2);
c896fe29
FB
1197}
1198
a7812ae4 1199static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1200{
34151a20
FB
1201 if (arg2 == 0) {
1202 tcg_gen_mov_i64(ret, arg1);
1203 } else {
a7812ae4 1204 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1205 tcg_gen_sar_i64(ret, arg1, t0);
a7812ae4 1206 tcg_temp_free_i64(t0);
34151a20 1207 }
c896fe29
FB
1208}
1209
8a56e840
RH
1210static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1,
1211 TCGv_i64 arg2, int label_index)
c896fe29 1212{
a7812ae4 1213 tcg_gen_op4ii_i64(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
c896fe29
FB
1214}
1215
8a56e840 1216static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret,
5105c556
AJ
1217 TCGv_i64 arg1, TCGv_i64 arg2)
1218{
1219 tcg_gen_op4i_i64(INDEX_op_setcond_i64, ret, arg1, arg2, cond);
1220}
1221
a7812ae4 1222static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1223{
a7812ae4 1224 tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2);
c896fe29
FB
1225}
1226
31d66551
AJ
1227static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1228{
25c4d9cc
RH
1229 if (TCG_TARGET_HAS_div_i64) {
1230 tcg_gen_op3_i64(INDEX_op_div_i64, ret, arg1, arg2);
1231 } else if (TCG_TARGET_HAS_div2_i64) {
1232 TCGv_i64 t0 = tcg_temp_new_i64();
1233 tcg_gen_sari_i64(t0, arg1, 63);
1234 tcg_gen_op5_i64(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
1235 tcg_temp_free_i64(t0);
1236 } else {
1237 int sizemask = 0;
1238 /* Return value and both arguments are 64-bit and signed. */
1239 sizemask |= tcg_gen_sizemask(0, 1, 1);
1240 sizemask |= tcg_gen_sizemask(1, 1, 1);
1241 sizemask |= tcg_gen_sizemask(2, 1, 1);
1242 tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
1243 }
31d66551
AJ
1244}
1245
1246static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1247{
25c4d9cc
RH
1248 if (TCG_TARGET_HAS_div_i64) {
1249 tcg_gen_op3_i64(INDEX_op_rem_i64, ret, arg1, arg2);
1250 } else if (TCG_TARGET_HAS_div2_i64) {
1251 TCGv_i64 t0 = tcg_temp_new_i64();
1252 tcg_gen_sari_i64(t0, arg1, 63);
1253 tcg_gen_op5_i64(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
1254 tcg_temp_free_i64(t0);
1255 } else {
1256 int sizemask = 0;
1257 /* Return value and both arguments are 64-bit and signed. */
1258 sizemask |= tcg_gen_sizemask(0, 1, 1);
1259 sizemask |= tcg_gen_sizemask(1, 1, 1);
1260 sizemask |= tcg_gen_sizemask(2, 1, 1);
1261 tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
1262 }
31d66551
AJ
1263}
1264
1265static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1266{
25c4d9cc
RH
1267 if (TCG_TARGET_HAS_div_i64) {
1268 tcg_gen_op3_i64(INDEX_op_divu_i64, ret, arg1, arg2);
1269 } else if (TCG_TARGET_HAS_div2_i64) {
1270 TCGv_i64 t0 = tcg_temp_new_i64();
1271 tcg_gen_movi_i64(t0, 0);
1272 tcg_gen_op5_i64(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
1273 tcg_temp_free_i64(t0);
1274 } else {
1275 int sizemask = 0;
1276 /* Return value and both arguments are 64-bit and unsigned. */
1277 sizemask |= tcg_gen_sizemask(0, 1, 0);
1278 sizemask |= tcg_gen_sizemask(1, 1, 0);
1279 sizemask |= tcg_gen_sizemask(2, 1, 0);
1280 tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
1281 }
31d66551
AJ
1282}
1283
1284static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1285{
25c4d9cc
RH
1286 if (TCG_TARGET_HAS_div_i64) {
1287 tcg_gen_op3_i64(INDEX_op_remu_i64, ret, arg1, arg2);
1288 } else if (TCG_TARGET_HAS_div2_i64) {
1289 TCGv_i64 t0 = tcg_temp_new_i64();
1290 tcg_gen_movi_i64(t0, 0);
1291 tcg_gen_op5_i64(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
1292 tcg_temp_free_i64(t0);
1293 } else {
1294 int sizemask = 0;
1295 /* Return value and both arguments are 64-bit and unsigned. */
1296 sizemask |= tcg_gen_sizemask(0, 1, 0);
1297 sizemask |= tcg_gen_sizemask(1, 1, 0);
1298 sizemask |= tcg_gen_sizemask(2, 1, 0);
1299 tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
1300 }
31d66551 1301}
25c4d9cc 1302#endif /* TCG_TARGET_REG_BITS == 32 */
c896fe29 1303
a7812ae4 1304static inline void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
6359706f
AJ
1305{
1306 /* some cases can be optimized here */
1307 if (arg2 == 0) {
1308 tcg_gen_mov_i64(ret, arg1);
1309 } else {
a7812ae4 1310 TCGv_i64 t0 = tcg_const_i64(arg2);
6359706f 1311 tcg_gen_add_i64(ret, arg1, t0);
a7812ae4 1312 tcg_temp_free_i64(t0);
6359706f
AJ
1313 }
1314}
1315
a7812ae4 1316static inline void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2)
0045734a 1317{
a7812ae4 1318 TCGv_i64 t0 = tcg_const_i64(arg1);
0045734a 1319 tcg_gen_sub_i64(ret, t0, arg2);
a7812ae4 1320 tcg_temp_free_i64(t0);
0045734a
AJ
1321}
1322
a7812ae4 1323static inline void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
6359706f
AJ
1324{
1325 /* some cases can be optimized here */
1326 if (arg2 == 0) {
1327 tcg_gen_mov_i64(ret, arg1);
1328 } else {
a7812ae4 1329 TCGv_i64 t0 = tcg_const_i64(arg2);
6359706f 1330 tcg_gen_sub_i64(ret, arg1, t0);
a7812ae4 1331 tcg_temp_free_i64(t0);
6359706f
AJ
1332 }
1333}
8a56e840
RH
1334static inline void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1,
1335 int64_t arg2, int label_index)
f02bb954 1336{
a7812ae4 1337 TCGv_i64 t0 = tcg_const_i64(arg2);
f02bb954 1338 tcg_gen_brcond_i64(cond, arg1, t0, label_index);
a7812ae4 1339 tcg_temp_free_i64(t0);
f02bb954
AJ
1340}
1341
8a56e840
RH
1342static inline void tcg_gen_setcondi_i64(TCGCond cond, TCGv_i64 ret,
1343 TCGv_i64 arg1, int64_t arg2)
5105c556
AJ
1344{
1345 TCGv_i64 t0 = tcg_const_i64(arg2);
1346 tcg_gen_setcond_i64(cond, ret, arg1, t0);
1347 tcg_temp_free_i64(t0);
1348}
1349
a7812ae4 1350static inline void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
f02bb954 1351{
a7812ae4 1352 TCGv_i64 t0 = tcg_const_i64(arg2);
f02bb954 1353 tcg_gen_mul_i64(ret, arg1, t0);
a7812ae4 1354 tcg_temp_free_i64(t0);
f02bb954
AJ
1355}
1356
6359706f 1357
c896fe29
FB
1358/***************************************/
1359/* optional operations */
1360
a7812ae4 1361static inline void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg)
c896fe29 1362{
25c4d9cc
RH
1363 if (TCG_TARGET_HAS_ext8s_i32) {
1364 tcg_gen_op2_i32(INDEX_op_ext8s_i32, ret, arg);
1365 } else {
1366 tcg_gen_shli_i32(ret, arg, 24);
1367 tcg_gen_sari_i32(ret, ret, 24);
1368 }
c896fe29
FB
1369}
1370
a7812ae4 1371static inline void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg)
c896fe29 1372{
25c4d9cc
RH
1373 if (TCG_TARGET_HAS_ext16s_i32) {
1374 tcg_gen_op2_i32(INDEX_op_ext16s_i32, ret, arg);
1375 } else {
1376 tcg_gen_shli_i32(ret, arg, 16);
1377 tcg_gen_sari_i32(ret, ret, 16);
1378 }
c896fe29
FB
1379}
1380
a7812ae4 1381static inline void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg)
86831435 1382{
25c4d9cc
RH
1383 if (TCG_TARGET_HAS_ext8u_i32) {
1384 tcg_gen_op2_i32(INDEX_op_ext8u_i32, ret, arg);
1385 } else {
1386 tcg_gen_andi_i32(ret, arg, 0xffu);
1387 }
86831435
PB
1388}
1389
a7812ae4 1390static inline void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg)
86831435 1391{
25c4d9cc
RH
1392 if (TCG_TARGET_HAS_ext16u_i32) {
1393 tcg_gen_op2_i32(INDEX_op_ext16u_i32, ret, arg);
1394 } else {
1395 tcg_gen_andi_i32(ret, arg, 0xffffu);
1396 }
86831435
PB
1397}
1398
c896fe29 1399/* Note: we assume the two high bytes are set to zero */
a7812ae4 1400static inline void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg)
c896fe29 1401{
25c4d9cc
RH
1402 if (TCG_TARGET_HAS_bswap16_i32) {
1403 tcg_gen_op2_i32(INDEX_op_bswap16_i32, ret, arg);
1404 } else {
1405 TCGv_i32 t0 = tcg_temp_new_i32();
c896fe29 1406
25c4d9cc
RH
1407 tcg_gen_ext8u_i32(t0, arg);
1408 tcg_gen_shli_i32(t0, t0, 8);
1409 tcg_gen_shri_i32(ret, arg, 8);
1410 tcg_gen_or_i32(ret, ret, t0);
1411 tcg_temp_free_i32(t0);
1412 }
c896fe29
FB
1413}
1414
66896cb8 1415static inline void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg)
c896fe29 1416{
25c4d9cc
RH
1417 if (TCG_TARGET_HAS_bswap32_i32) {
1418 tcg_gen_op2_i32(INDEX_op_bswap32_i32, ret, arg);
1419 } else {
1420 TCGv_i32 t0, t1;
1421 t0 = tcg_temp_new_i32();
1422 t1 = tcg_temp_new_i32();
c896fe29 1423
25c4d9cc 1424 tcg_gen_shli_i32(t0, arg, 24);
c896fe29 1425
25c4d9cc
RH
1426 tcg_gen_andi_i32(t1, arg, 0x0000ff00);
1427 tcg_gen_shli_i32(t1, t1, 8);
1428 tcg_gen_or_i32(t0, t0, t1);
c896fe29 1429
25c4d9cc
RH
1430 tcg_gen_shri_i32(t1, arg, 8);
1431 tcg_gen_andi_i32(t1, t1, 0x0000ff00);
1432 tcg_gen_or_i32(t0, t0, t1);
c896fe29 1433
25c4d9cc
RH
1434 tcg_gen_shri_i32(t1, arg, 24);
1435 tcg_gen_or_i32(ret, t0, t1);
1436 tcg_temp_free_i32(t0);
1437 tcg_temp_free_i32(t1);
1438 }
c896fe29
FB
1439}
1440
1441#if TCG_TARGET_REG_BITS == 32
a7812ae4 1442static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1443{
a7812ae4
PB
1444 tcg_gen_ext8s_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1445 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
1446}
1447
a7812ae4 1448static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1449{
a7812ae4
PB
1450 tcg_gen_ext16s_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1451 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
1452}
1453
a7812ae4 1454static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1455{
a7812ae4
PB
1456 tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1457 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
1458}
1459
a7812ae4 1460static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1461{
a7812ae4 1462 tcg_gen_ext8u_i32(TCGV_LOW(ret), TCGV_LOW(arg));
86831435
PB
1463 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1464}
1465
a7812ae4 1466static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1467{
a7812ae4 1468 tcg_gen_ext16u_i32(TCGV_LOW(ret), TCGV_LOW(arg));
86831435
PB
1469 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1470}
1471
a7812ae4 1472static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1473{
a7812ae4 1474 tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
86831435
PB
1475 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1476}
1477
a7812ae4 1478static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
c896fe29 1479{
a7812ae4 1480 tcg_gen_mov_i32(ret, TCGV_LOW(arg));
c896fe29
FB
1481}
1482
a7812ae4 1483static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
c896fe29 1484{
a7812ae4 1485 tcg_gen_mov_i32(TCGV_LOW(ret), arg);
ac56dd48 1486 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
1487}
1488
a7812ae4 1489static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
c896fe29 1490{
a7812ae4
PB
1491 tcg_gen_mov_i32(TCGV_LOW(ret), arg);
1492 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
1493}
1494
9a5c57fd
AJ
1495/* Note: we assume the six high bytes are set to zero */
1496static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg)
1497{
1498 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
1499 tcg_gen_bswap16_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1500}
1501
1502/* Note: we assume the four high bytes are set to zero */
1503static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg)
1504{
1505 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
1506 tcg_gen_bswap32_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1507}
1508
66896cb8 1509static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1510{
a7812ae4
PB
1511 TCGv_i32 t0, t1;
1512 t0 = tcg_temp_new_i32();
1513 t1 = tcg_temp_new_i32();
c896fe29 1514
66896cb8
AJ
1515 tcg_gen_bswap32_i32(t0, TCGV_LOW(arg));
1516 tcg_gen_bswap32_i32(t1, TCGV_HIGH(arg));
a7812ae4 1517 tcg_gen_mov_i32(TCGV_LOW(ret), t1);
ac56dd48 1518 tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
a7812ae4
PB
1519 tcg_temp_free_i32(t0);
1520 tcg_temp_free_i32(t1);
c896fe29
FB
1521}
1522#else
1523
a7812ae4 1524static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1525{
25c4d9cc
RH
1526 if (TCG_TARGET_HAS_ext8s_i64) {
1527 tcg_gen_op2_i64(INDEX_op_ext8s_i64, ret, arg);
1528 } else {
1529 tcg_gen_shli_i64(ret, arg, 56);
1530 tcg_gen_sari_i64(ret, ret, 56);
1531 }
c896fe29
FB
1532}
1533
a7812ae4 1534static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1535{
25c4d9cc
RH
1536 if (TCG_TARGET_HAS_ext16s_i64) {
1537 tcg_gen_op2_i64(INDEX_op_ext16s_i64, ret, arg);
1538 } else {
1539 tcg_gen_shli_i64(ret, arg, 48);
1540 tcg_gen_sari_i64(ret, ret, 48);
1541 }
c896fe29
FB
1542}
1543
a7812ae4 1544static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1545{
25c4d9cc
RH
1546 if (TCG_TARGET_HAS_ext32s_i64) {
1547 tcg_gen_op2_i64(INDEX_op_ext32s_i64, ret, arg);
1548 } else {
1549 tcg_gen_shli_i64(ret, arg, 32);
1550 tcg_gen_sari_i64(ret, ret, 32);
1551 }
c896fe29
FB
1552}
1553
a7812ae4 1554static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1555{
25c4d9cc
RH
1556 if (TCG_TARGET_HAS_ext8u_i64) {
1557 tcg_gen_op2_i64(INDEX_op_ext8u_i64, ret, arg);
1558 } else {
1559 tcg_gen_andi_i64(ret, arg, 0xffu);
1560 }
86831435
PB
1561}
1562
a7812ae4 1563static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1564{
25c4d9cc
RH
1565 if (TCG_TARGET_HAS_ext16u_i64) {
1566 tcg_gen_op2_i64(INDEX_op_ext16u_i64, ret, arg);
1567 } else {
1568 tcg_gen_andi_i64(ret, arg, 0xffffu);
1569 }
86831435
PB
1570}
1571
a7812ae4 1572static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1573{
25c4d9cc
RH
1574 if (TCG_TARGET_HAS_ext32u_i64) {
1575 tcg_gen_op2_i64(INDEX_op_ext32u_i64, ret, arg);
1576 } else {
1577 tcg_gen_andi_i64(ret, arg, 0xffffffffu);
1578 }
86831435
PB
1579}
1580
c896fe29 1581/* Note: we assume the target supports move between 32 and 64 bit
ac56dd48 1582 registers. This will probably break MIPS64 targets. */
a7812ae4 1583static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
c896fe29 1584{
a7812ae4 1585 tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg)));
c896fe29
FB
1586}
1587
1588/* Note: we assume the target supports move between 32 and 64 bit
1589 registers */
a7812ae4 1590static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
c896fe29 1591{
cfc86988 1592 tcg_gen_ext32u_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg)));
c896fe29
FB
1593}
1594
1595/* Note: we assume the target supports move between 32 and 64 bit
1596 registers */
a7812ae4 1597static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
c896fe29 1598{
a7812ae4 1599 tcg_gen_ext32s_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg)));
c896fe29
FB
1600}
1601
9a5c57fd
AJ
1602/* Note: we assume the six high bytes are set to zero */
1603static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg)
1604{
25c4d9cc
RH
1605 if (TCG_TARGET_HAS_bswap16_i64) {
1606 tcg_gen_op2_i64(INDEX_op_bswap16_i64, ret, arg);
1607 } else {
1608 TCGv_i64 t0 = tcg_temp_new_i64();
9a5c57fd 1609
25c4d9cc
RH
1610 tcg_gen_ext8u_i64(t0, arg);
1611 tcg_gen_shli_i64(t0, t0, 8);
1612 tcg_gen_shri_i64(ret, arg, 8);
1613 tcg_gen_or_i64(ret, ret, t0);
1614 tcg_temp_free_i64(t0);
1615 }
9a5c57fd
AJ
1616}
1617
1618/* Note: we assume the four high bytes are set to zero */
1619static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg)
1620{
25c4d9cc
RH
1621 if (TCG_TARGET_HAS_bswap32_i64) {
1622 tcg_gen_op2_i64(INDEX_op_bswap32_i64, ret, arg);
1623 } else {
1624 TCGv_i64 t0, t1;
1625 t0 = tcg_temp_new_i64();
1626 t1 = tcg_temp_new_i64();
9a5c57fd 1627
25c4d9cc
RH
1628 tcg_gen_shli_i64(t0, arg, 24);
1629 tcg_gen_ext32u_i64(t0, t0);
9a5c57fd 1630
25c4d9cc
RH
1631 tcg_gen_andi_i64(t1, arg, 0x0000ff00);
1632 tcg_gen_shli_i64(t1, t1, 8);
1633 tcg_gen_or_i64(t0, t0, t1);
9a5c57fd 1634
25c4d9cc
RH
1635 tcg_gen_shri_i64(t1, arg, 8);
1636 tcg_gen_andi_i64(t1, t1, 0x0000ff00);
1637 tcg_gen_or_i64(t0, t0, t1);
9a5c57fd 1638
25c4d9cc
RH
1639 tcg_gen_shri_i64(t1, arg, 24);
1640 tcg_gen_or_i64(ret, t0, t1);
1641 tcg_temp_free_i64(t0);
1642 tcg_temp_free_i64(t1);
1643 }
9a5c57fd
AJ
1644}
1645
66896cb8 1646static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1647{
25c4d9cc
RH
1648 if (TCG_TARGET_HAS_bswap64_i64) {
1649 tcg_gen_op2_i64(INDEX_op_bswap64_i64, ret, arg);
1650 } else {
1651 TCGv_i64 t0 = tcg_temp_new_i64();
1652 TCGv_i64 t1 = tcg_temp_new_i64();
c896fe29 1653
25c4d9cc 1654 tcg_gen_shli_i64(t0, arg, 56);
c896fe29 1655
25c4d9cc
RH
1656 tcg_gen_andi_i64(t1, arg, 0x0000ff00);
1657 tcg_gen_shli_i64(t1, t1, 40);
1658 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1659
25c4d9cc
RH
1660 tcg_gen_andi_i64(t1, arg, 0x00ff0000);
1661 tcg_gen_shli_i64(t1, t1, 24);
1662 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1663
25c4d9cc
RH
1664 tcg_gen_andi_i64(t1, arg, 0xff000000);
1665 tcg_gen_shli_i64(t1, t1, 8);
1666 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1667
25c4d9cc
RH
1668 tcg_gen_shri_i64(t1, arg, 8);
1669 tcg_gen_andi_i64(t1, t1, 0xff000000);
1670 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1671
25c4d9cc
RH
1672 tcg_gen_shri_i64(t1, arg, 24);
1673 tcg_gen_andi_i64(t1, t1, 0x00ff0000);
1674 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1675
25c4d9cc
RH
1676 tcg_gen_shri_i64(t1, arg, 40);
1677 tcg_gen_andi_i64(t1, t1, 0x0000ff00);
1678 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1679
25c4d9cc
RH
1680 tcg_gen_shri_i64(t1, arg, 56);
1681 tcg_gen_or_i64(ret, t0, t1);
1682 tcg_temp_free_i64(t0);
1683 tcg_temp_free_i64(t1);
1684 }
c896fe29
FB
1685}
1686
1687#endif
1688
a7812ae4 1689static inline void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg)
390efc54 1690{
25c4d9cc
RH
1691 if (TCG_TARGET_HAS_neg_i32) {
1692 tcg_gen_op2_i32(INDEX_op_neg_i32, ret, arg);
1693 } else {
1694 TCGv_i32 t0 = tcg_const_i32(0);
1695 tcg_gen_sub_i32(ret, t0, arg);
1696 tcg_temp_free_i32(t0);
1697 }
390efc54
PB
1698}
1699
a7812ae4 1700static inline void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg)
390efc54 1701{
25c4d9cc
RH
1702 if (TCG_TARGET_HAS_neg_i64) {
1703 tcg_gen_op2_i64(INDEX_op_neg_i64, ret, arg);
1704 } else {
1705 TCGv_i64 t0 = tcg_const_i64(0);
1706 tcg_gen_sub_i64(ret, t0, arg);
1707 tcg_temp_free_i64(t0);
1708 }
390efc54
PB
1709}
1710
a7812ae4 1711static inline void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg)
0b6ce4cf 1712{
25c4d9cc
RH
1713 if (TCG_TARGET_HAS_not_i32) {
1714 tcg_gen_op2_i32(INDEX_op_not_i32, ret, arg);
1715 } else {
1716 tcg_gen_xori_i32(ret, arg, -1);
1717 }
0b6ce4cf
FB
1718}
1719
a7812ae4 1720static inline void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg)
0b6ce4cf 1721{
25c4d9cc
RH
1722#if TCG_TARGET_REG_BITS == 64
1723 if (TCG_TARGET_HAS_not_i64) {
1724 tcg_gen_op2_i64(INDEX_op_not_i64, ret, arg);
1725 } else {
1726 tcg_gen_xori_i64(ret, arg, -1);
1727 }
1728#else
a10f9f4f
RH
1729 tcg_gen_not_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1730 tcg_gen_not_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
d2604285 1731#endif
0b6ce4cf 1732}
5ff9d6a4 1733
a7812ae4 1734static inline void tcg_gen_discard_i32(TCGv_i32 arg)
5ff9d6a4 1735{
a7812ae4 1736 tcg_gen_op1_i32(INDEX_op_discard, arg);
5ff9d6a4
FB
1737}
1738
a7812ae4 1739static inline void tcg_gen_discard_i64(TCGv_i64 arg)
5ff9d6a4 1740{
25c4d9cc 1741#if TCG_TARGET_REG_BITS == 32
a7812ae4 1742 tcg_gen_discard_i32(TCGV_LOW(arg));
5ff9d6a4 1743 tcg_gen_discard_i32(TCGV_HIGH(arg));
5ff9d6a4 1744#else
a7812ae4 1745 tcg_gen_op1_i64(INDEX_op_discard, arg);
5ff9d6a4 1746#endif
25c4d9cc 1747}
5ff9d6a4 1748
a7812ae4 1749static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high)
36aa55dc
PB
1750{
1751#if TCG_TARGET_REG_BITS == 32
a7812ae4 1752 tcg_gen_mov_i32(TCGV_LOW(dest), low);
36aa55dc
PB
1753 tcg_gen_mov_i32(TCGV_HIGH(dest), high);
1754#else
a7812ae4 1755 TCGv_i64 tmp = tcg_temp_new_i64();
36aa55dc
PB
1756 /* This extension is only needed for type correctness.
1757 We may be able to do better given target specific information. */
1758 tcg_gen_extu_i32_i64(tmp, high);
1759 tcg_gen_shli_i64(tmp, tmp, 32);
1760 tcg_gen_extu_i32_i64(dest, low);
1761 tcg_gen_or_i64(dest, dest, tmp);
a7812ae4 1762 tcg_temp_free_i64(tmp);
36aa55dc
PB
1763#endif
1764}
1765
a7812ae4 1766static inline void tcg_gen_concat32_i64(TCGv_i64 dest, TCGv_i64 low, TCGv_i64 high)
945ca823
BS
1767{
1768#if TCG_TARGET_REG_BITS == 32
a7812ae4 1769 tcg_gen_concat_i32_i64(dest, TCGV_LOW(low), TCGV_LOW(high));
945ca823 1770#else
a7812ae4 1771 TCGv_i64 tmp = tcg_temp_new_i64();
88422e2e 1772 tcg_gen_ext32u_i64(dest, low);
945ca823 1773 tcg_gen_shli_i64(tmp, high, 32);
88422e2e 1774 tcg_gen_or_i64(dest, dest, tmp);
a7812ae4 1775 tcg_temp_free_i64(tmp);
945ca823
BS
1776#endif
1777}
1778
a7812ae4 1779static inline void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1780{
25c4d9cc
RH
1781 if (TCG_TARGET_HAS_andc_i32) {
1782 tcg_gen_op3_i32(INDEX_op_andc_i32, ret, arg1, arg2);
1783 } else {
1784 TCGv_i32 t0 = tcg_temp_new_i32();
1785 tcg_gen_not_i32(t0, arg2);
1786 tcg_gen_and_i32(ret, arg1, t0);
1787 tcg_temp_free_i32(t0);
1788 }
f24cb33e
AJ
1789}
1790
a7812ae4 1791static inline void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
f24cb33e 1792{
25c4d9cc
RH
1793#if TCG_TARGET_REG_BITS == 64
1794 if (TCG_TARGET_HAS_andc_i64) {
1795 tcg_gen_op3_i64(INDEX_op_andc_i64, ret, arg1, arg2);
1796 } else {
1797 TCGv_i64 t0 = tcg_temp_new_i64();
1798 tcg_gen_not_i64(t0, arg2);
1799 tcg_gen_and_i64(ret, arg1, t0);
1800 tcg_temp_free_i64(t0);
1801 }
1802#else
241cbed4
RH
1803 tcg_gen_andc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1804 tcg_gen_andc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
241cbed4 1805#endif
f24cb33e
AJ
1806}
1807
a7812ae4 1808static inline void tcg_gen_eqv_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1809{
25c4d9cc
RH
1810 if (TCG_TARGET_HAS_eqv_i32) {
1811 tcg_gen_op3_i32(INDEX_op_eqv_i32, ret, arg1, arg2);
1812 } else {
1813 tcg_gen_xor_i32(ret, arg1, arg2);
1814 tcg_gen_not_i32(ret, ret);
1815 }
f24cb33e
AJ
1816}
1817
a7812ae4 1818static inline void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
f24cb33e 1819{
25c4d9cc
RH
1820#if TCG_TARGET_REG_BITS == 64
1821 if (TCG_TARGET_HAS_eqv_i64) {
1822 tcg_gen_op3_i64(INDEX_op_eqv_i64, ret, arg1, arg2);
1823 } else {
1824 tcg_gen_xor_i64(ret, arg1, arg2);
1825 tcg_gen_not_i64(ret, ret);
1826 }
1827#else
8d625cf1
RH
1828 tcg_gen_eqv_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1829 tcg_gen_eqv_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
8d625cf1 1830#endif
f24cb33e
AJ
1831}
1832
a7812ae4 1833static inline void tcg_gen_nand_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1834{
25c4d9cc
RH
1835 if (TCG_TARGET_HAS_nand_i32) {
1836 tcg_gen_op3_i32(INDEX_op_nand_i32, ret, arg1, arg2);
1837 } else {
1838 tcg_gen_and_i32(ret, arg1, arg2);
1839 tcg_gen_not_i32(ret, ret);
1840 }
f24cb33e
AJ
1841}
1842
a7812ae4 1843static inline void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
f24cb33e 1844{
25c4d9cc
RH
1845#if TCG_TARGET_REG_BITS == 64
1846 if (TCG_TARGET_HAS_nand_i64) {
1847 tcg_gen_op3_i64(INDEX_op_nand_i64, ret, arg1, arg2);
1848 } else {
1849 tcg_gen_and_i64(ret, arg1, arg2);
1850 tcg_gen_not_i64(ret, ret);
1851 }
1852#else
9940a96b
RH
1853 tcg_gen_nand_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1854 tcg_gen_nand_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
9940a96b 1855#endif
f24cb33e
AJ
1856}
1857
a7812ae4 1858static inline void tcg_gen_nor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1859{
25c4d9cc
RH
1860 if (TCG_TARGET_HAS_nor_i32) {
1861 tcg_gen_op3_i32(INDEX_op_nor_i32, ret, arg1, arg2);
1862 } else {
1863 tcg_gen_or_i32(ret, arg1, arg2);
1864 tcg_gen_not_i32(ret, ret);
1865 }
f24cb33e
AJ
1866}
1867
a7812ae4 1868static inline void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
f24cb33e 1869{
25c4d9cc
RH
1870#if TCG_TARGET_REG_BITS == 64
1871 if (TCG_TARGET_HAS_nor_i64) {
1872 tcg_gen_op3_i64(INDEX_op_nor_i64, ret, arg1, arg2);
1873 } else {
1874 tcg_gen_or_i64(ret, arg1, arg2);
1875 tcg_gen_not_i64(ret, ret);
1876 }
1877#else
32d98fbd
RH
1878 tcg_gen_nor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1879 tcg_gen_nor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
32d98fbd 1880#endif
f24cb33e
AJ
1881}
1882
a7812ae4 1883static inline void tcg_gen_orc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1884{
25c4d9cc
RH
1885 if (TCG_TARGET_HAS_orc_i32) {
1886 tcg_gen_op3_i32(INDEX_op_orc_i32, ret, arg1, arg2);
1887 } else {
1888 TCGv_i32 t0 = tcg_temp_new_i32();
1889 tcg_gen_not_i32(t0, arg2);
1890 tcg_gen_or_i32(ret, arg1, t0);
1891 tcg_temp_free_i32(t0);
1892 }
f24cb33e
AJ
1893}
1894
a7812ae4 1895static inline void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
f24cb33e 1896{
25c4d9cc
RH
1897#if TCG_TARGET_REG_BITS == 64
1898 if (TCG_TARGET_HAS_orc_i64) {
1899 tcg_gen_op3_i64(INDEX_op_orc_i64, ret, arg1, arg2);
1900 } else {
1901 TCGv_i64 t0 = tcg_temp_new_i64();
1902 tcg_gen_not_i64(t0, arg2);
1903 tcg_gen_or_i64(ret, arg1, t0);
1904 tcg_temp_free_i64(t0);
1905 }
1906#else
791d1262
RH
1907 tcg_gen_orc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1908 tcg_gen_orc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
791d1262 1909#endif
f24cb33e
AJ
1910}
1911
a7812ae4 1912static inline void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
15824571 1913{
25c4d9cc
RH
1914 if (TCG_TARGET_HAS_rot_i32) {
1915 tcg_gen_op3_i32(INDEX_op_rotl_i32, ret, arg1, arg2);
1916 } else {
1917 TCGv_i32 t0, t1;
15824571 1918
25c4d9cc
RH
1919 t0 = tcg_temp_new_i32();
1920 t1 = tcg_temp_new_i32();
1921 tcg_gen_shl_i32(t0, arg1, arg2);
1922 tcg_gen_subfi_i32(t1, 32, arg2);
1923 tcg_gen_shr_i32(t1, arg1, t1);
1924 tcg_gen_or_i32(ret, t0, t1);
1925 tcg_temp_free_i32(t0);
1926 tcg_temp_free_i32(t1);
1927 }
15824571
AJ
1928}
1929
a7812ae4 1930static inline void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
15824571 1931{
25c4d9cc
RH
1932 if (TCG_TARGET_HAS_rot_i64) {
1933 tcg_gen_op3_i64(INDEX_op_rotl_i64, ret, arg1, arg2);
1934 } else {
1935 TCGv_i64 t0, t1;
1936 t0 = tcg_temp_new_i64();
1937 t1 = tcg_temp_new_i64();
1938 tcg_gen_shl_i64(t0, arg1, arg2);
1939 tcg_gen_subfi_i64(t1, 64, arg2);
1940 tcg_gen_shr_i64(t1, arg1, t1);
1941 tcg_gen_or_i64(ret, t0, t1);
1942 tcg_temp_free_i64(t0);
1943 tcg_temp_free_i64(t1);
1944 }
15824571
AJ
1945}
1946
a7812ae4 1947static inline void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
15824571
AJ
1948{
1949 /* some cases can be optimized here */
1950 if (arg2 == 0) {
1951 tcg_gen_mov_i32(ret, arg1);
25c4d9cc 1952 } else if (TCG_TARGET_HAS_rot_i32) {
d42f183c
AJ
1953 TCGv_i32 t0 = tcg_const_i32(arg2);
1954 tcg_gen_rotl_i32(ret, arg1, t0);
1955 tcg_temp_free_i32(t0);
25c4d9cc 1956 } else {
a7812ae4
PB
1957 TCGv_i32 t0, t1;
1958 t0 = tcg_temp_new_i32();
1959 t1 = tcg_temp_new_i32();
15824571
AJ
1960 tcg_gen_shli_i32(t0, arg1, arg2);
1961 tcg_gen_shri_i32(t1, arg1, 32 - arg2);
1962 tcg_gen_or_i32(ret, t0, t1);
a7812ae4
PB
1963 tcg_temp_free_i32(t0);
1964 tcg_temp_free_i32(t1);
15824571
AJ
1965 }
1966}
1967
a7812ae4 1968static inline void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
15824571
AJ
1969{
1970 /* some cases can be optimized here */
1971 if (arg2 == 0) {
1972 tcg_gen_mov_i64(ret, arg1);
25c4d9cc 1973 } else if (TCG_TARGET_HAS_rot_i64) {
d42f183c
AJ
1974 TCGv_i64 t0 = tcg_const_i64(arg2);
1975 tcg_gen_rotl_i64(ret, arg1, t0);
1976 tcg_temp_free_i64(t0);
25c4d9cc 1977 } else {
a7812ae4
PB
1978 TCGv_i64 t0, t1;
1979 t0 = tcg_temp_new_i64();
1980 t1 = tcg_temp_new_i64();
15824571
AJ
1981 tcg_gen_shli_i64(t0, arg1, arg2);
1982 tcg_gen_shri_i64(t1, arg1, 64 - arg2);
1983 tcg_gen_or_i64(ret, t0, t1);
a7812ae4
PB
1984 tcg_temp_free_i64(t0);
1985 tcg_temp_free_i64(t1);
15824571
AJ
1986 }
1987}
1988
a7812ae4 1989static inline void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
15824571 1990{
25c4d9cc
RH
1991 if (TCG_TARGET_HAS_rot_i32) {
1992 tcg_gen_op3_i32(INDEX_op_rotr_i32, ret, arg1, arg2);
1993 } else {
1994 TCGv_i32 t0, t1;
15824571 1995
25c4d9cc
RH
1996 t0 = tcg_temp_new_i32();
1997 t1 = tcg_temp_new_i32();
1998 tcg_gen_shr_i32(t0, arg1, arg2);
1999 tcg_gen_subfi_i32(t1, 32, arg2);
2000 tcg_gen_shl_i32(t1, arg1, t1);
2001 tcg_gen_or_i32(ret, t0, t1);
2002 tcg_temp_free_i32(t0);
2003 tcg_temp_free_i32(t1);
2004 }
15824571
AJ
2005}
2006
a7812ae4 2007static inline void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
15824571 2008{
25c4d9cc
RH
2009 if (TCG_TARGET_HAS_rot_i64) {
2010 tcg_gen_op3_i64(INDEX_op_rotr_i64, ret, arg1, arg2);
2011 } else {
2012 TCGv_i64 t0, t1;
2013 t0 = tcg_temp_new_i64();
2014 t1 = tcg_temp_new_i64();
2015 tcg_gen_shr_i64(t0, arg1, arg2);
2016 tcg_gen_subfi_i64(t1, 64, arg2);
2017 tcg_gen_shl_i64(t1, arg1, t1);
2018 tcg_gen_or_i64(ret, t0, t1);
2019 tcg_temp_free_i64(t0);
2020 tcg_temp_free_i64(t1);
2021 }
15824571
AJ
2022}
2023
a7812ae4 2024static inline void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
15824571
AJ
2025{
2026 /* some cases can be optimized here */
2027 if (arg2 == 0) {
2028 tcg_gen_mov_i32(ret, arg1);
2029 } else {
2030 tcg_gen_rotli_i32(ret, arg1, 32 - arg2);
2031 }
2032}
2033
a7812ae4 2034static inline void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
15824571
AJ
2035{
2036 /* some cases can be optimized here */
2037 if (arg2 == 0) {
de3526b2 2038 tcg_gen_mov_i64(ret, arg1);
15824571
AJ
2039 } else {
2040 tcg_gen_rotli_i64(ret, arg1, 64 - arg2);
2041 }
2042}
2043
b7767f0f 2044static inline void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1,
0756e71c
RH
2045 TCGv_i32 arg2, unsigned int ofs,
2046 unsigned int len)
b7767f0f 2047{
df072774
RH
2048 uint32_t mask;
2049 TCGv_i32 t1;
2050
2051 if (ofs == 0 && len == 32) {
2052 tcg_gen_mov_i32(ret, arg2);
2053 return;
2054 }
a4773324 2055 if (TCG_TARGET_HAS_deposit_i32 && TCG_TARGET_deposit_i32_valid(ofs, len)) {
25c4d9cc 2056 tcg_gen_op5ii_i32(INDEX_op_deposit_i32, ret, arg1, arg2, ofs, len);
df072774
RH
2057 return;
2058 }
2059
2060 mask = (1u << len) - 1;
2061 t1 = tcg_temp_new_i32();
b7767f0f 2062
df072774 2063 if (ofs + len < 32) {
25c4d9cc
RH
2064 tcg_gen_andi_i32(t1, arg2, mask);
2065 tcg_gen_shli_i32(t1, t1, ofs);
df072774
RH
2066 } else {
2067 tcg_gen_shli_i32(t1, arg2, ofs);
25c4d9cc 2068 }
df072774
RH
2069 tcg_gen_andi_i32(ret, arg1, ~(mask << ofs));
2070 tcg_gen_or_i32(ret, ret, t1);
2071
2072 tcg_temp_free_i32(t1);
b7767f0f
RH
2073}
2074
2075static inline void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1,
0756e71c
RH
2076 TCGv_i64 arg2, unsigned int ofs,
2077 unsigned int len)
b7767f0f 2078{
df072774
RH
2079 uint64_t mask;
2080 TCGv_i64 t1;
2081
2082 if (ofs == 0 && len == 64) {
2083 tcg_gen_mov_i64(ret, arg2);
2084 return;
2085 }
a4773324 2086 if (TCG_TARGET_HAS_deposit_i64 && TCG_TARGET_deposit_i64_valid(ofs, len)) {
25c4d9cc 2087 tcg_gen_op5ii_i64(INDEX_op_deposit_i64, ret, arg1, arg2, ofs, len);
df072774
RH
2088 return;
2089 }
b7767f0f 2090
df072774
RH
2091#if TCG_TARGET_REG_BITS == 32
2092 if (ofs >= 32) {
2f98c9db 2093 tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg1));
df072774
RH
2094 tcg_gen_deposit_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1),
2095 TCGV_LOW(arg2), ofs - 32, len);
2096 return;
2097 }
2098 if (ofs + len <= 32) {
2099 tcg_gen_deposit_i32(TCGV_LOW(ret), TCGV_LOW(arg1),
2100 TCGV_LOW(arg2), ofs, len);
2f98c9db 2101 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1));
df072774
RH
2102 return;
2103 }
2104#endif
2105
2106 mask = (1ull << len) - 1;
2107 t1 = tcg_temp_new_i64();
2108
2109 if (ofs + len < 64) {
25c4d9cc
RH
2110 tcg_gen_andi_i64(t1, arg2, mask);
2111 tcg_gen_shli_i64(t1, t1, ofs);
df072774
RH
2112 } else {
2113 tcg_gen_shli_i64(t1, arg2, ofs);
25c4d9cc 2114 }
df072774
RH
2115 tcg_gen_andi_i64(ret, arg1, ~(mask << ofs));
2116 tcg_gen_or_i64(ret, ret, t1);
2117
2118 tcg_temp_free_i64(t1);
b7767f0f
RH
2119}
2120
c896fe29
FB
2121/***************************************/
2122/* QEMU specific operations. Their type depend on the QEMU CPU
2123 type. */
2124#ifndef TARGET_LONG_BITS
2125#error must include QEMU headers
2126#endif
2127
a7812ae4
PB
2128#if TARGET_LONG_BITS == 32
2129#define TCGv TCGv_i32
2130#define tcg_temp_new() tcg_temp_new_i32()
2131#define tcg_global_reg_new tcg_global_reg_new_i32
2132#define tcg_global_mem_new tcg_global_mem_new_i32
df9247b2 2133#define tcg_temp_local_new() tcg_temp_local_new_i32()
a7812ae4
PB
2134#define tcg_temp_free tcg_temp_free_i32
2135#define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32
2136#define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32
2137#define TCGV_UNUSED(x) TCGV_UNUSED_I32(x)
fe75bcf7 2138#define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b)
a7812ae4
PB
2139#else
2140#define TCGv TCGv_i64
2141#define tcg_temp_new() tcg_temp_new_i64()
2142#define tcg_global_reg_new tcg_global_reg_new_i64
2143#define tcg_global_mem_new tcg_global_mem_new_i64
df9247b2 2144#define tcg_temp_local_new() tcg_temp_local_new_i64()
a7812ae4
PB
2145#define tcg_temp_free tcg_temp_free_i64
2146#define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64
2147#define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64
2148#define TCGV_UNUSED(x) TCGV_UNUSED_I64(x)
fe75bcf7 2149#define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b)
a7812ae4
PB
2150#endif
2151
7e4597d7
FB
2152/* debug info: write the PC of the corresponding QEMU CPU instruction */
2153static inline void tcg_gen_debug_insn_start(uint64_t pc)
2154{
2155 /* XXX: must really use a 32 bit size for TCGArg in all cases */
2156#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
bcb0126f
PB
2157 tcg_gen_op2ii(INDEX_op_debug_insn_start,
2158 (uint32_t)(pc), (uint32_t)(pc >> 32));
7e4597d7
FB
2159#else
2160 tcg_gen_op1i(INDEX_op_debug_insn_start, pc);
2161#endif
2162}
2163
c896fe29
FB
2164static inline void tcg_gen_exit_tb(tcg_target_long val)
2165{
ac56dd48 2166 tcg_gen_op1i(INDEX_op_exit_tb, val);
c896fe29
FB
2167}
2168
2169static inline void tcg_gen_goto_tb(int idx)
2170{
ac56dd48 2171 tcg_gen_op1i(INDEX_op_goto_tb, idx);
c896fe29
FB
2172}
2173
2174#if TCG_TARGET_REG_BITS == 32
ac56dd48 2175static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2176{
2177#if TARGET_LONG_BITS == 32
a7812ae4 2178 tcg_gen_op3i_i32(INDEX_op_qemu_ld8u, ret, addr, mem_index);
c896fe29 2179#else
a7812ae4
PB
2180 tcg_gen_op4i_i32(INDEX_op_qemu_ld8u, TCGV_LOW(ret), TCGV_LOW(addr),
2181 TCGV_HIGH(addr), mem_index);
ac56dd48 2182 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
2183#endif
2184}
2185
ac56dd48 2186static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2187{
2188#if TARGET_LONG_BITS == 32
a7812ae4 2189 tcg_gen_op3i_i32(INDEX_op_qemu_ld8s, ret, addr, mem_index);
c896fe29 2190#else
a7812ae4
PB
2191 tcg_gen_op4i_i32(INDEX_op_qemu_ld8s, TCGV_LOW(ret), TCGV_LOW(addr),
2192 TCGV_HIGH(addr), mem_index);
2193 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
2194#endif
2195}
2196
ac56dd48 2197static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2198{
2199#if TARGET_LONG_BITS == 32
a7812ae4 2200 tcg_gen_op3i_i32(INDEX_op_qemu_ld16u, ret, addr, mem_index);
c896fe29 2201#else
a7812ae4
PB
2202 tcg_gen_op4i_i32(INDEX_op_qemu_ld16u, TCGV_LOW(ret), TCGV_LOW(addr),
2203 TCGV_HIGH(addr), mem_index);
ac56dd48 2204 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
2205#endif
2206}
2207
ac56dd48 2208static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2209{
2210#if TARGET_LONG_BITS == 32
a7812ae4 2211 tcg_gen_op3i_i32(INDEX_op_qemu_ld16s, ret, addr, mem_index);
c896fe29 2212#else
a7812ae4
PB
2213 tcg_gen_op4i_i32(INDEX_op_qemu_ld16s, TCGV_LOW(ret), TCGV_LOW(addr),
2214 TCGV_HIGH(addr), mem_index);
2215 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
2216#endif
2217}
2218
ac56dd48 2219static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2220{
2221#if TARGET_LONG_BITS == 32
86feb1c8 2222 tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index);
c896fe29 2223#else
86feb1c8 2224 tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr),
a7812ae4 2225 TCGV_HIGH(addr), mem_index);
ac56dd48 2226 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
2227#endif
2228}
2229
ac56dd48 2230static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2231{
2232#if TARGET_LONG_BITS == 32
86feb1c8 2233 tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index);
c896fe29 2234#else
86feb1c8 2235 tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr),
a7812ae4
PB
2236 TCGV_HIGH(addr), mem_index);
2237 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
2238#endif
2239}
2240
a7812ae4 2241static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index)
c896fe29
FB
2242{
2243#if TARGET_LONG_BITS == 32
a7812ae4 2244 tcg_gen_op4i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), addr, mem_index);
c896fe29 2245#else
a7812ae4
PB
2246 tcg_gen_op5i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret),
2247 TCGV_LOW(addr), TCGV_HIGH(addr), mem_index);
c896fe29
FB
2248#endif
2249}
2250
ac56dd48 2251static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
2252{
2253#if TARGET_LONG_BITS == 32
a7812ae4 2254 tcg_gen_op3i_i32(INDEX_op_qemu_st8, arg, addr, mem_index);
c896fe29 2255#else
a7812ae4
PB
2256 tcg_gen_op4i_i32(INDEX_op_qemu_st8, TCGV_LOW(arg), TCGV_LOW(addr),
2257 TCGV_HIGH(addr), mem_index);
c896fe29
FB
2258#endif
2259}
2260
ac56dd48 2261static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
2262{
2263#if TARGET_LONG_BITS == 32
a7812ae4 2264 tcg_gen_op3i_i32(INDEX_op_qemu_st16, arg, addr, mem_index);
c896fe29 2265#else
a7812ae4
PB
2266 tcg_gen_op4i_i32(INDEX_op_qemu_st16, TCGV_LOW(arg), TCGV_LOW(addr),
2267 TCGV_HIGH(addr), mem_index);
c896fe29
FB
2268#endif
2269}
2270
ac56dd48 2271static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
2272{
2273#if TARGET_LONG_BITS == 32
a7812ae4 2274 tcg_gen_op3i_i32(INDEX_op_qemu_st32, arg, addr, mem_index);
c896fe29 2275#else
a7812ae4
PB
2276 tcg_gen_op4i_i32(INDEX_op_qemu_st32, TCGV_LOW(arg), TCGV_LOW(addr),
2277 TCGV_HIGH(addr), mem_index);
c896fe29
FB
2278#endif
2279}
2280
a7812ae4 2281static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
c896fe29
FB
2282{
2283#if TARGET_LONG_BITS == 32
a7812ae4
PB
2284 tcg_gen_op4i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), addr,
2285 mem_index);
c896fe29 2286#else
a7812ae4
PB
2287 tcg_gen_op5i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg),
2288 TCGV_LOW(addr), TCGV_HIGH(addr), mem_index);
c896fe29
FB
2289#endif
2290}
2291
ebecf363
PM
2292#define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i32(TCGV_PTR_TO_NAT(R), (A), (O))
2293#define tcg_gen_discard_ptr(A) tcg_gen_discard_i32(TCGV_PTR_TO_NAT(A))
f8422f52 2294
c896fe29
FB
2295#else /* TCG_TARGET_REG_BITS == 32 */
2296
ac56dd48 2297static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
c896fe29 2298{
a7812ae4 2299 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u, ret, addr, mem_index);
c896fe29
FB
2300}
2301
ac56dd48 2302static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
c896fe29 2303{
a7812ae4 2304 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s, ret, addr, mem_index);
c896fe29
FB
2305}
2306
ac56dd48 2307static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
c896fe29 2308{
a7812ae4 2309 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u, ret, addr, mem_index);
c896fe29
FB
2310}
2311
ac56dd48 2312static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
c896fe29 2313{
a7812ae4 2314 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s, ret, addr, mem_index);
c896fe29
FB
2315}
2316
ac56dd48 2317static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
c896fe29 2318{
3e1dbadd
RH
2319#if TARGET_LONG_BITS == 32
2320 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index);
2321#else
a7812ae4 2322 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u, ret, addr, mem_index);
3e1dbadd 2323#endif
c896fe29
FB
2324}
2325
ac56dd48 2326static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
c896fe29 2327{
3e1dbadd
RH
2328#if TARGET_LONG_BITS == 32
2329 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index);
2330#else
a7812ae4 2331 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s, ret, addr, mem_index);
3e1dbadd 2332#endif
c896fe29
FB
2333}
2334
a7812ae4 2335static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index)
c896fe29 2336{
a7812ae4 2337 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64, ret, addr, mem_index);
c896fe29
FB
2338}
2339
ac56dd48 2340static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
c896fe29 2341{
a7812ae4 2342 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8, arg, addr, mem_index);
c896fe29
FB
2343}
2344
ac56dd48 2345static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
c896fe29 2346{
a7812ae4 2347 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16, arg, addr, mem_index);
c896fe29
FB
2348}
2349
ac56dd48 2350static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
c896fe29 2351{
a7812ae4 2352 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32, arg, addr, mem_index);
c896fe29
FB
2353}
2354
a7812ae4 2355static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
c896fe29 2356{
a7812ae4 2357 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64, arg, addr, mem_index);
c896fe29
FB
2358}
2359
ebecf363
PM
2360#define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i64(TCGV_PTR_TO_NAT(R), (A), (O))
2361#define tcg_gen_discard_ptr(A) tcg_gen_discard_i64(TCGV_PTR_TO_NAT(A))
f8422f52 2362
c896fe29 2363#endif /* TCG_TARGET_REG_BITS != 32 */
f8422f52
BS
2364
2365#if TARGET_LONG_BITS == 64
f8422f52
BS
2366#define tcg_gen_movi_tl tcg_gen_movi_i64
2367#define tcg_gen_mov_tl tcg_gen_mov_i64
2368#define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
2369#define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
2370#define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
2371#define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
2372#define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
2373#define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
2374#define tcg_gen_ld_tl tcg_gen_ld_i64
2375#define tcg_gen_st8_tl tcg_gen_st8_i64
2376#define tcg_gen_st16_tl tcg_gen_st16_i64
2377#define tcg_gen_st32_tl tcg_gen_st32_i64
2378#define tcg_gen_st_tl tcg_gen_st_i64
2379#define tcg_gen_add_tl tcg_gen_add_i64
2380#define tcg_gen_addi_tl tcg_gen_addi_i64
2381#define tcg_gen_sub_tl tcg_gen_sub_i64
390efc54 2382#define tcg_gen_neg_tl tcg_gen_neg_i64
10460c8a 2383#define tcg_gen_subfi_tl tcg_gen_subfi_i64
f8422f52
BS
2384#define tcg_gen_subi_tl tcg_gen_subi_i64
2385#define tcg_gen_and_tl tcg_gen_and_i64
2386#define tcg_gen_andi_tl tcg_gen_andi_i64
2387#define tcg_gen_or_tl tcg_gen_or_i64
2388#define tcg_gen_ori_tl tcg_gen_ori_i64
2389#define tcg_gen_xor_tl tcg_gen_xor_i64
2390#define tcg_gen_xori_tl tcg_gen_xori_i64
0b6ce4cf 2391#define tcg_gen_not_tl tcg_gen_not_i64
f8422f52
BS
2392#define tcg_gen_shl_tl tcg_gen_shl_i64
2393#define tcg_gen_shli_tl tcg_gen_shli_i64
2394#define tcg_gen_shr_tl tcg_gen_shr_i64
2395#define tcg_gen_shri_tl tcg_gen_shri_i64
2396#define tcg_gen_sar_tl tcg_gen_sar_i64
2397#define tcg_gen_sari_tl tcg_gen_sari_i64
0cf767d6 2398#define tcg_gen_brcond_tl tcg_gen_brcond_i64
cb63669a 2399#define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
be210acb 2400#define tcg_gen_setcond_tl tcg_gen_setcond_i64
add1e7ea 2401#define tcg_gen_setcondi_tl tcg_gen_setcondi_i64
f730fd27
TS
2402#define tcg_gen_mul_tl tcg_gen_mul_i64
2403#define tcg_gen_muli_tl tcg_gen_muli_i64
ab36421e
AJ
2404#define tcg_gen_div_tl tcg_gen_div_i64
2405#define tcg_gen_rem_tl tcg_gen_rem_i64
864951af
AJ
2406#define tcg_gen_divu_tl tcg_gen_divu_i64
2407#define tcg_gen_remu_tl tcg_gen_remu_i64
a768e4b2 2408#define tcg_gen_discard_tl tcg_gen_discard_i64
e429073d
BS
2409#define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
2410#define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
2411#define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
2412#define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
2413#define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
2414#define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
0b6ce4cf
FB
2415#define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
2416#define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
2417#define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
2418#define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
2419#define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
2420#define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
911d79ba
AJ
2421#define tcg_gen_bswap16_tl tcg_gen_bswap16_i64
2422#define tcg_gen_bswap32_tl tcg_gen_bswap32_i64
2423#define tcg_gen_bswap64_tl tcg_gen_bswap64_i64
945ca823 2424#define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
f24cb33e
AJ
2425#define tcg_gen_andc_tl tcg_gen_andc_i64
2426#define tcg_gen_eqv_tl tcg_gen_eqv_i64
2427#define tcg_gen_nand_tl tcg_gen_nand_i64
2428#define tcg_gen_nor_tl tcg_gen_nor_i64
2429#define tcg_gen_orc_tl tcg_gen_orc_i64
15824571
AJ
2430#define tcg_gen_rotl_tl tcg_gen_rotl_i64
2431#define tcg_gen_rotli_tl tcg_gen_rotli_i64
2432#define tcg_gen_rotr_tl tcg_gen_rotr_i64
2433#define tcg_gen_rotri_tl tcg_gen_rotri_i64
b7767f0f 2434#define tcg_gen_deposit_tl tcg_gen_deposit_i64
a98824ac 2435#define tcg_const_tl tcg_const_i64
bdffd4a9 2436#define tcg_const_local_tl tcg_const_local_i64
f8422f52 2437#else
f8422f52
BS
2438#define tcg_gen_movi_tl tcg_gen_movi_i32
2439#define tcg_gen_mov_tl tcg_gen_mov_i32
2440#define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
2441#define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
2442#define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
2443#define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
2444#define tcg_gen_ld32u_tl tcg_gen_ld_i32
2445#define tcg_gen_ld32s_tl tcg_gen_ld_i32
2446#define tcg_gen_ld_tl tcg_gen_ld_i32
2447#define tcg_gen_st8_tl tcg_gen_st8_i32
2448#define tcg_gen_st16_tl tcg_gen_st16_i32
2449#define tcg_gen_st32_tl tcg_gen_st_i32
2450#define tcg_gen_st_tl tcg_gen_st_i32
2451#define tcg_gen_add_tl tcg_gen_add_i32
2452#define tcg_gen_addi_tl tcg_gen_addi_i32
2453#define tcg_gen_sub_tl tcg_gen_sub_i32
390efc54 2454#define tcg_gen_neg_tl tcg_gen_neg_i32
0045734a 2455#define tcg_gen_subfi_tl tcg_gen_subfi_i32
f8422f52
BS
2456#define tcg_gen_subi_tl tcg_gen_subi_i32
2457#define tcg_gen_and_tl tcg_gen_and_i32
2458#define tcg_gen_andi_tl tcg_gen_andi_i32
2459#define tcg_gen_or_tl tcg_gen_or_i32
2460#define tcg_gen_ori_tl tcg_gen_ori_i32
2461#define tcg_gen_xor_tl tcg_gen_xor_i32
2462#define tcg_gen_xori_tl tcg_gen_xori_i32
0b6ce4cf 2463#define tcg_gen_not_tl tcg_gen_not_i32
f8422f52
BS
2464#define tcg_gen_shl_tl tcg_gen_shl_i32
2465#define tcg_gen_shli_tl tcg_gen_shli_i32
2466#define tcg_gen_shr_tl tcg_gen_shr_i32
2467#define tcg_gen_shri_tl tcg_gen_shri_i32
2468#define tcg_gen_sar_tl tcg_gen_sar_i32
2469#define tcg_gen_sari_tl tcg_gen_sari_i32
0cf767d6 2470#define tcg_gen_brcond_tl tcg_gen_brcond_i32
cb63669a 2471#define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
be210acb 2472#define tcg_gen_setcond_tl tcg_gen_setcond_i32
add1e7ea 2473#define tcg_gen_setcondi_tl tcg_gen_setcondi_i32
f730fd27
TS
2474#define tcg_gen_mul_tl tcg_gen_mul_i32
2475#define tcg_gen_muli_tl tcg_gen_muli_i32
ab36421e
AJ
2476#define tcg_gen_div_tl tcg_gen_div_i32
2477#define tcg_gen_rem_tl tcg_gen_rem_i32
864951af
AJ
2478#define tcg_gen_divu_tl tcg_gen_divu_i32
2479#define tcg_gen_remu_tl tcg_gen_remu_i32
a768e4b2 2480#define tcg_gen_discard_tl tcg_gen_discard_i32
e429073d
BS
2481#define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
2482#define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
2483#define tcg_gen_extu_i32_tl tcg_gen_mov_i32
2484#define tcg_gen_ext_i32_tl tcg_gen_mov_i32
2485#define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
2486#define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
0b6ce4cf
FB
2487#define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
2488#define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
2489#define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
2490#define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
2491#define tcg_gen_ext32u_tl tcg_gen_mov_i32
2492#define tcg_gen_ext32s_tl tcg_gen_mov_i32
911d79ba
AJ
2493#define tcg_gen_bswap16_tl tcg_gen_bswap16_i32
2494#define tcg_gen_bswap32_tl tcg_gen_bswap32_i32
945ca823 2495#define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
f24cb33e
AJ
2496#define tcg_gen_andc_tl tcg_gen_andc_i32
2497#define tcg_gen_eqv_tl tcg_gen_eqv_i32
2498#define tcg_gen_nand_tl tcg_gen_nand_i32
2499#define tcg_gen_nor_tl tcg_gen_nor_i32
2500#define tcg_gen_orc_tl tcg_gen_orc_i32
15824571
AJ
2501#define tcg_gen_rotl_tl tcg_gen_rotl_i32
2502#define tcg_gen_rotli_tl tcg_gen_rotli_i32
2503#define tcg_gen_rotr_tl tcg_gen_rotr_i32
2504#define tcg_gen_rotri_tl tcg_gen_rotri_i32
b7767f0f 2505#define tcg_gen_deposit_tl tcg_gen_deposit_i32
a98824ac 2506#define tcg_const_tl tcg_const_i32
bdffd4a9 2507#define tcg_const_local_tl tcg_const_local_i32
f8422f52 2508#endif
6ddbc6e4
PB
2509
2510#if TCG_TARGET_REG_BITS == 32
ebecf363
PM
2511#define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i32(TCGV_PTR_TO_NAT(R), \
2512 TCGV_PTR_TO_NAT(A), \
2513 TCGV_PTR_TO_NAT(B))
2514#define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i32(TCGV_PTR_TO_NAT(R), \
2515 TCGV_PTR_TO_NAT(A), (B))
2516#define tcg_gen_ext_i32_ptr(R, A) tcg_gen_mov_i32(TCGV_PTR_TO_NAT(R), (A))
6ddbc6e4 2517#else /* TCG_TARGET_REG_BITS == 32 */
ebecf363
PM
2518#define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i64(TCGV_PTR_TO_NAT(R), \
2519 TCGV_PTR_TO_NAT(A), \
2520 TCGV_PTR_TO_NAT(B))
2521#define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i64(TCGV_PTR_TO_NAT(R), \
2522 TCGV_PTR_TO_NAT(A), (B))
2523#define tcg_gen_ext_i32_ptr(R, A) tcg_gen_ext_i32_i64(TCGV_PTR_TO_NAT(R), (A))
6ddbc6e4 2524#endif /* TCG_TARGET_REG_BITS != 32 */