]> Git Repo - qemu.git/blame - tcg/tcg-op.h
tcg: Optimize initial inputs for ori_i64
[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
42ce3e20 521static inline void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, uint32_t arg2)
c896fe29 522{
42ce3e20
RH
523 TCGv_i32 t0;
524 /* Some cases can be optimized here. */
525 switch (arg2) {
526 case 0:
c896fe29 527 tcg_gen_movi_i32(ret, 0);
42ce3e20
RH
528 return;
529 case 0xffffffffu:
c896fe29 530 tcg_gen_mov_i32(ret, arg1);
42ce3e20
RH
531 return;
532 case 0xffu:
533 /* Don't recurse with tcg_gen_ext8u_i32. */
534 if (TCG_TARGET_HAS_ext8u_i32) {
535 tcg_gen_op2_i32(INDEX_op_ext8u_i32, ret, arg1);
536 return;
537 }
538 break;
539 case 0xffffu:
540 if (TCG_TARGET_HAS_ext16u_i32) {
541 tcg_gen_op2_i32(INDEX_op_ext16u_i32, ret, arg1);
542 return;
543 }
544 break;
c896fe29 545 }
42ce3e20
RH
546 t0 = tcg_const_i32(arg2);
547 tcg_gen_and_i32(ret, arg1, t0);
548 tcg_temp_free_i32(t0);
c896fe29
FB
549}
550
a7812ae4 551static inline void tcg_gen_or_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 552{
7fc81051
AJ
553 if (TCGV_EQUAL_I32(arg1, arg2)) {
554 tcg_gen_mov_i32(ret, arg1);
555 } else {
556 tcg_gen_op3_i32(INDEX_op_or_i32, ret, arg1, arg2);
557 }
c896fe29
FB
558}
559
a7812ae4 560static inline void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29 561{
d81ada7f
RH
562 /* Some cases can be optimized here. */
563 if (arg2 == -1) {
564 tcg_gen_movi_i32(ret, -1);
c896fe29
FB
565 } else if (arg2 == 0) {
566 tcg_gen_mov_i32(ret, arg1);
567 } else {
a7812ae4 568 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 569 tcg_gen_or_i32(ret, arg1, t0);
a7812ae4 570 tcg_temp_free_i32(t0);
c896fe29
FB
571 }
572}
573
a7812ae4 574static inline void tcg_gen_xor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 575{
7fc81051
AJ
576 if (TCGV_EQUAL_I32(arg1, arg2)) {
577 tcg_gen_movi_i32(ret, 0);
578 } else {
579 tcg_gen_op3_i32(INDEX_op_xor_i32, ret, arg1, arg2);
580 }
c896fe29
FB
581}
582
a7812ae4 583static inline void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29
FB
584{
585 /* some cases can be optimized here */
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_xor_i32(ret, arg1, t0);
a7812ae4 591 tcg_temp_free_i32(t0);
c896fe29
FB
592 }
593}
594
a7812ae4 595static inline void tcg_gen_shl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 596{
a7812ae4 597 tcg_gen_op3_i32(INDEX_op_shl_i32, ret, arg1, arg2);
c896fe29
FB
598}
599
a7812ae4 600static inline void tcg_gen_shli_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_shl_i32(ret, arg1, t0);
a7812ae4 607 tcg_temp_free_i32(t0);
34151a20 608 }
c896fe29
FB
609}
610
a7812ae4 611static inline void tcg_gen_shr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 612{
a7812ae4 613 tcg_gen_op3_i32(INDEX_op_shr_i32, ret, arg1, arg2);
c896fe29
FB
614}
615
a7812ae4 616static inline void tcg_gen_shri_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_shr_i32(ret, arg1, t0);
a7812ae4 623 tcg_temp_free_i32(t0);
34151a20 624 }
c896fe29
FB
625}
626
a7812ae4 627static inline void tcg_gen_sar_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 628{
a7812ae4 629 tcg_gen_op3_i32(INDEX_op_sar_i32, ret, arg1, arg2);
c896fe29
FB
630}
631
a7812ae4 632static inline void tcg_gen_sari_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
c896fe29 633{
34151a20
FB
634 if (arg2 == 0) {
635 tcg_gen_mov_i32(ret, arg1);
636 } else {
a7812ae4 637 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 638 tcg_gen_sar_i32(ret, arg1, t0);
a7812ae4 639 tcg_temp_free_i32(t0);
34151a20 640 }
c896fe29
FB
641}
642
8a56e840
RH
643static inline void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1,
644 TCGv_i32 arg2, int label_index)
c896fe29 645{
a7812ae4 646 tcg_gen_op4ii_i32(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
c896fe29
FB
647}
648
8a56e840
RH
649static inline void tcg_gen_brcondi_i32(TCGCond cond, TCGv_i32 arg1,
650 int32_t arg2, int label_index)
cb63669a 651{
a7812ae4 652 TCGv_i32 t0 = tcg_const_i32(arg2);
cb63669a 653 tcg_gen_brcond_i32(cond, arg1, t0, label_index);
a7812ae4 654 tcg_temp_free_i32(t0);
cb63669a
PB
655}
656
8a56e840 657static inline void tcg_gen_setcond_i32(TCGCond cond, TCGv_i32 ret,
5105c556
AJ
658 TCGv_i32 arg1, TCGv_i32 arg2)
659{
660 tcg_gen_op4i_i32(INDEX_op_setcond_i32, ret, arg1, arg2, cond);
661}
662
8a56e840
RH
663static inline void tcg_gen_setcondi_i32(TCGCond cond, TCGv_i32 ret,
664 TCGv_i32 arg1, int32_t arg2)
5105c556
AJ
665{
666 TCGv_i32 t0 = tcg_const_i32(arg2);
667 tcg_gen_setcond_i32(cond, ret, arg1, t0);
668 tcg_temp_free_i32(t0);
669}
670
a7812ae4 671static inline void tcg_gen_mul_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 672{
a7812ae4 673 tcg_gen_op3_i32(INDEX_op_mul_i32, ret, arg1, arg2);
c896fe29
FB
674}
675
a7812ae4 676static inline void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
f730fd27 677{
a7812ae4 678 TCGv_i32 t0 = tcg_const_i32(arg2);
e8996ee0 679 tcg_gen_mul_i32(ret, arg1, t0);
a7812ae4 680 tcg_temp_free_i32(t0);
f730fd27
TS
681}
682
a7812ae4 683static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
c896fe29 684{
25c4d9cc
RH
685 if (TCG_TARGET_HAS_div_i32) {
686 tcg_gen_op3_i32(INDEX_op_div_i32, ret, arg1, arg2);
687 } else if (TCG_TARGET_HAS_div2_i32) {
688 TCGv_i32 t0 = tcg_temp_new_i32();
689 tcg_gen_sari_i32(t0, arg1, 31);
690 tcg_gen_op5_i32(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
691 tcg_temp_free_i32(t0);
692 } else {
693 int sizemask = 0;
694 /* Return value and both arguments are 32-bit and signed. */
695 sizemask |= tcg_gen_sizemask(0, 0, 1);
696 sizemask |= tcg_gen_sizemask(1, 0, 1);
697 sizemask |= tcg_gen_sizemask(2, 0, 1);
698 tcg_gen_helper32(tcg_helper_div_i32, sizemask, ret, arg1, arg2);
699 }
31d66551
AJ
700}
701
702static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
703{
25c4d9cc
RH
704 if (TCG_TARGET_HAS_div_i32) {
705 tcg_gen_op3_i32(INDEX_op_rem_i32, ret, arg1, arg2);
706 } else if (TCG_TARGET_HAS_div2_i32) {
707 TCGv_i32 t0 = tcg_temp_new_i32();
708 tcg_gen_sari_i32(t0, arg1, 31);
709 tcg_gen_op5_i32(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
710 tcg_temp_free_i32(t0);
711 } else {
712 int sizemask = 0;
713 /* Return value and both arguments are 32-bit and signed. */
714 sizemask |= tcg_gen_sizemask(0, 0, 1);
715 sizemask |= tcg_gen_sizemask(1, 0, 1);
716 sizemask |= tcg_gen_sizemask(2, 0, 1);
717 tcg_gen_helper32(tcg_helper_rem_i32, sizemask, ret, arg1, arg2);
718 }
31d66551
AJ
719}
720
721static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
722{
25c4d9cc
RH
723 if (TCG_TARGET_HAS_div_i32) {
724 tcg_gen_op3_i32(INDEX_op_divu_i32, ret, arg1, arg2);
725 } else if (TCG_TARGET_HAS_div2_i32) {
726 TCGv_i32 t0 = tcg_temp_new_i32();
727 tcg_gen_movi_i32(t0, 0);
728 tcg_gen_op5_i32(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
729 tcg_temp_free_i32(t0);
730 } else {
731 int sizemask = 0;
732 /* Return value and both arguments are 32-bit and unsigned. */
733 sizemask |= tcg_gen_sizemask(0, 0, 0);
734 sizemask |= tcg_gen_sizemask(1, 0, 0);
735 sizemask |= tcg_gen_sizemask(2, 0, 0);
736 tcg_gen_helper32(tcg_helper_divu_i32, sizemask, ret, arg1, arg2);
737 }
31d66551
AJ
738}
739
740static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
741{
25c4d9cc
RH
742 if (TCG_TARGET_HAS_div_i32) {
743 tcg_gen_op3_i32(INDEX_op_remu_i32, ret, arg1, arg2);
744 } else if (TCG_TARGET_HAS_div2_i32) {
745 TCGv_i32 t0 = tcg_temp_new_i32();
746 tcg_gen_movi_i32(t0, 0);
747 tcg_gen_op5_i32(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
748 tcg_temp_free_i32(t0);
749 } else {
750 int sizemask = 0;
751 /* Return value and both arguments are 32-bit and unsigned. */
752 sizemask |= tcg_gen_sizemask(0, 0, 0);
753 sizemask |= tcg_gen_sizemask(1, 0, 0);
754 sizemask |= tcg_gen_sizemask(2, 0, 0);
755 tcg_gen_helper32(tcg_helper_remu_i32, sizemask, ret, arg1, arg2);
756 }
31d66551 757}
c896fe29
FB
758
759#if TCG_TARGET_REG_BITS == 32
760
a7812ae4 761static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 762{
fe75bcf7 763 if (!TCGV_EQUAL_I64(ret, arg)) {
a7812ae4 764 tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
4d07272d
BS
765 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
766 }
c896fe29
FB
767}
768
a7812ae4 769static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
c896fe29 770{
a7812ae4 771 tcg_gen_movi_i32(TCGV_LOW(ret), arg);
ac56dd48 772 tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
c896fe29
FB
773}
774
a7812ae4
PB
775static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2,
776 tcg_target_long offset)
c896fe29 777{
a7812ae4 778 tcg_gen_ld8u_i32(TCGV_LOW(ret), arg2, offset);
ac56dd48 779 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
780}
781
a7812ae4
PB
782static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2,
783 tcg_target_long offset)
c896fe29 784{
a7812ae4
PB
785 tcg_gen_ld8s_i32(TCGV_LOW(ret), arg2, offset);
786 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), 31);
c896fe29
FB
787}
788
a7812ae4
PB
789static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2,
790 tcg_target_long offset)
c896fe29 791{
a747723b 792 tcg_gen_ld16u_i32(TCGV_LOW(ret), arg2, offset);
ac56dd48 793 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
794}
795
a7812ae4
PB
796static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2,
797 tcg_target_long offset)
c896fe29 798{
a7812ae4
PB
799 tcg_gen_ld16s_i32(TCGV_LOW(ret), arg2, offset);
800 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
801}
802
a7812ae4
PB
803static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2,
804 tcg_target_long offset)
c896fe29 805{
a7812ae4 806 tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
ac56dd48 807 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
808}
809
a7812ae4
PB
810static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2,
811 tcg_target_long offset)
c896fe29 812{
a7812ae4
PB
813 tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
814 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
815}
816
a7812ae4
PB
817static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2,
818 tcg_target_long offset)
c896fe29
FB
819{
820 /* since arg2 and ret have different types, they cannot be the
821 same temporary */
822#ifdef TCG_TARGET_WORDS_BIGENDIAN
ac56dd48 823 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
a7812ae4 824 tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset + 4);
c896fe29 825#else
a7812ae4 826 tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset);
ac56dd48 827 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
c896fe29
FB
828#endif
829}
830
a7812ae4
PB
831static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2,
832 tcg_target_long offset)
c896fe29 833{
a7812ae4 834 tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset);
c896fe29
FB
835}
836
a7812ae4
PB
837static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2,
838 tcg_target_long offset)
c896fe29 839{
a7812ae4 840 tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset);
c896fe29
FB
841}
842
a7812ae4
PB
843static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2,
844 tcg_target_long offset)
c896fe29 845{
a7812ae4 846 tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
c896fe29
FB
847}
848
a7812ae4
PB
849static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2,
850 tcg_target_long offset)
c896fe29
FB
851{
852#ifdef TCG_TARGET_WORDS_BIGENDIAN
ac56dd48 853 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
a7812ae4 854 tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset + 4);
c896fe29 855#else
a7812ae4 856 tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
ac56dd48 857 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
c896fe29
FB
858#endif
859}
860
a7812ae4 861static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 862{
a7812ae4
PB
863 tcg_gen_op6_i32(INDEX_op_add2_i32, TCGV_LOW(ret), TCGV_HIGH(ret),
864 TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
865 TCGV_HIGH(arg2));
c896fe29
FB
866}
867
a7812ae4 868static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 869{
a7812ae4
PB
870 tcg_gen_op6_i32(INDEX_op_sub2_i32, TCGV_LOW(ret), TCGV_HIGH(ret),
871 TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
872 TCGV_HIGH(arg2));
c896fe29
FB
873}
874
a7812ae4 875static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 876{
a7812ae4 877 tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
ac56dd48 878 tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
c896fe29
FB
879}
880
a7812ae4 881static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 882{
e5105083
AJ
883 tcg_gen_andi_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
884 tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
c896fe29
FB
885}
886
a7812ae4 887static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 888{
e5105083
AJ
889 tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
890 tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
c896fe29
FB
891}
892
a7812ae4 893static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 894{
a7812ae4 895 tcg_gen_ori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
ac56dd48 896 tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
c896fe29
FB
897}
898
a7812ae4 899static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 900{
e5105083
AJ
901 tcg_gen_xor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
902 tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
c896fe29
FB
903}
904
a7812ae4 905static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 906{
a7812ae4 907 tcg_gen_xori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2);
ac56dd48 908 tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
c896fe29
FB
909}
910
911/* XXX: use generic code when basic block handling is OK or CPU
912 specific code (x86) */
a7812ae4 913static inline void tcg_gen_shl_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_shl_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
922}
923
a7812ae4 924static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29
FB
925{
926 tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
927}
928
a7812ae4 929static inline void tcg_gen_shr_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_shr_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
938}
939
a7812ae4 940static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29
FB
941{
942 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
943}
944
a7812ae4 945static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 946{
2bece2c8
RH
947 int sizemask = 0;
948 /* Return value and both arguments are 64-bit and signed. */
949 sizemask |= tcg_gen_sizemask(0, 1, 1);
950 sizemask |= tcg_gen_sizemask(1, 1, 1);
951 sizemask |= tcg_gen_sizemask(2, 1, 1);
952
953 tcg_gen_helper64(tcg_helper_sar_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
954}
955
a7812ae4 956static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29
FB
957{
958 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
959}
960
8a56e840
RH
961static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1,
962 TCGv_i64 arg2, int label_index)
c896fe29 963{
a7812ae4
PB
964 tcg_gen_op6ii_i32(INDEX_op_brcond2_i32,
965 TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2),
966 TCGV_HIGH(arg2), cond, label_index);
c896fe29
FB
967}
968
8a56e840 969static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret,
5105c556
AJ
970 TCGv_i64 arg1, TCGv_i64 arg2)
971{
972 tcg_gen_op6i_i32(INDEX_op_setcond2_i32, TCGV_LOW(ret),
973 TCGV_LOW(arg1), TCGV_HIGH(arg1),
974 TCGV_LOW(arg2), TCGV_HIGH(arg2), cond);
975 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
976}
977
a7812ae4 978static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 979{
a7812ae4
PB
980 TCGv_i64 t0;
981 TCGv_i32 t1;
c896fe29 982
a7812ae4
PB
983 t0 = tcg_temp_new_i64();
984 t1 = tcg_temp_new_i32();
985
986 tcg_gen_op4_i32(INDEX_op_mulu2_i32, TCGV_LOW(t0), TCGV_HIGH(t0),
987 TCGV_LOW(arg1), TCGV_LOW(arg2));
988
989 tcg_gen_mul_i32(t1, TCGV_LOW(arg1), TCGV_HIGH(arg2));
ac56dd48 990 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
a7812ae4 991 tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), TCGV_LOW(arg2));
ac56dd48 992 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
a7812ae4 993
c896fe29 994 tcg_gen_mov_i64(ret, t0);
a7812ae4
PB
995 tcg_temp_free_i64(t0);
996 tcg_temp_free_i32(t1);
c896fe29
FB
997}
998
a7812ae4 999static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1000{
2bece2c8
RH
1001 int sizemask = 0;
1002 /* Return value and both arguments are 64-bit and signed. */
1003 sizemask |= tcg_gen_sizemask(0, 1, 1);
1004 sizemask |= tcg_gen_sizemask(1, 1, 1);
1005 sizemask |= tcg_gen_sizemask(2, 1, 1);
1006
1007 tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
1008}
1009
a7812ae4 1010static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1011{
2bece2c8
RH
1012 int sizemask = 0;
1013 /* Return value and both arguments are 64-bit and signed. */
1014 sizemask |= tcg_gen_sizemask(0, 1, 1);
1015 sizemask |= tcg_gen_sizemask(1, 1, 1);
1016 sizemask |= tcg_gen_sizemask(2, 1, 1);
1017
1018 tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
1019}
1020
a7812ae4 1021static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1022{
2bece2c8
RH
1023 int sizemask = 0;
1024 /* Return value and both arguments are 64-bit and unsigned. */
1025 sizemask |= tcg_gen_sizemask(0, 1, 0);
1026 sizemask |= tcg_gen_sizemask(1, 1, 0);
1027 sizemask |= tcg_gen_sizemask(2, 1, 0);
1028
1029 tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
1030}
1031
a7812ae4 1032static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1033{
2bece2c8
RH
1034 int sizemask = 0;
1035 /* Return value and both arguments are 64-bit and unsigned. */
1036 sizemask |= tcg_gen_sizemask(0, 1, 0);
1037 sizemask |= tcg_gen_sizemask(1, 1, 0);
1038 sizemask |= tcg_gen_sizemask(2, 1, 0);
1039
1040 tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
c896fe29
FB
1041}
1042
1043#else
1044
a7812ae4 1045static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1046{
fe75bcf7 1047 if (!TCGV_EQUAL_I64(ret, arg))
a7812ae4 1048 tcg_gen_op2_i64(INDEX_op_mov_i64, ret, arg);
c896fe29
FB
1049}
1050
a7812ae4 1051static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
c896fe29 1052{
a7812ae4 1053 tcg_gen_op2i_i64(INDEX_op_movi_i64, ret, arg);
c896fe29
FB
1054}
1055
6bd4b08a 1056static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1057 tcg_target_long offset)
c896fe29 1058{
a7812ae4 1059 tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64, ret, arg2, offset);
c896fe29
FB
1060}
1061
6bd4b08a 1062static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1063 tcg_target_long offset)
c896fe29 1064{
a7812ae4 1065 tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64, ret, arg2, offset);
c896fe29
FB
1066}
1067
6bd4b08a 1068static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1069 tcg_target_long offset)
c896fe29 1070{
a7812ae4 1071 tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64, ret, arg2, offset);
c896fe29
FB
1072}
1073
6bd4b08a 1074static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1075 tcg_target_long offset)
c896fe29 1076{
a7812ae4 1077 tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64, ret, arg2, offset);
c896fe29
FB
1078}
1079
6bd4b08a 1080static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1081 tcg_target_long offset)
c896fe29 1082{
a7812ae4 1083 tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64, ret, arg2, offset);
c896fe29
FB
1084}
1085
6bd4b08a 1086static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2,
ac56dd48 1087 tcg_target_long offset)
c896fe29 1088{
a7812ae4 1089 tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64, ret, arg2, offset);
c896fe29
FB
1090}
1091
6bd4b08a 1092static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 1093{
a7812ae4 1094 tcg_gen_ldst_op_i64(INDEX_op_ld_i64, ret, arg2, offset);
c896fe29
FB
1095}
1096
6bd4b08a 1097static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2,
ac56dd48 1098 tcg_target_long offset)
c896fe29 1099{
a7812ae4 1100 tcg_gen_ldst_op_i64(INDEX_op_st8_i64, arg1, arg2, offset);
c896fe29
FB
1101}
1102
6bd4b08a 1103static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2,
ac56dd48 1104 tcg_target_long offset)
c896fe29 1105{
a7812ae4 1106 tcg_gen_ldst_op_i64(INDEX_op_st16_i64, arg1, arg2, offset);
c896fe29
FB
1107}
1108
6bd4b08a 1109static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2,
ac56dd48 1110 tcg_target_long offset)
c896fe29 1111{
a7812ae4 1112 tcg_gen_ldst_op_i64(INDEX_op_st32_i64, arg1, arg2, offset);
c896fe29
FB
1113}
1114
6bd4b08a 1115static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset)
c896fe29 1116{
a7812ae4 1117 tcg_gen_ldst_op_i64(INDEX_op_st_i64, arg1, arg2, offset);
c896fe29
FB
1118}
1119
a7812ae4 1120static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1121{
a7812ae4 1122 tcg_gen_op3_i64(INDEX_op_add_i64, ret, arg1, arg2);
c896fe29
FB
1123}
1124
a7812ae4 1125static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1126{
a7812ae4 1127 tcg_gen_op3_i64(INDEX_op_sub_i64, ret, arg1, arg2);
c896fe29
FB
1128}
1129
a7812ae4 1130static inline void tcg_gen_and_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_and_i64, ret, arg1, arg2);
1136 }
c896fe29
FB
1137}
1138
42ce3e20 1139static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2)
c896fe29 1140{
42ce3e20
RH
1141 TCGv_i64 t0;
1142 /* Some cases can be optimized here. */
1143 switch (arg2) {
1144 case 0:
1145 tcg_gen_movi_i64(ret, 0);
1146 return;
1147 case 0xffffffffffffffffull:
1148 tcg_gen_mov_i64(ret, arg1);
1149 return;
1150 case 0xffull:
1151 /* Don't recurse with tcg_gen_ext8u_i32. */
1152 if (TCG_TARGET_HAS_ext8u_i64) {
1153 tcg_gen_op2_i64(INDEX_op_ext8u_i64, ret, arg1);
1154 return;
1155 }
1156 break;
1157 case 0xffffu:
1158 if (TCG_TARGET_HAS_ext16u_i64) {
1159 tcg_gen_op2_i64(INDEX_op_ext16u_i64, ret, arg1);
1160 return;
1161 }
1162 break;
1163 case 0xffffffffull:
1164 if (TCG_TARGET_HAS_ext32u_i64) {
1165 tcg_gen_op2_i64(INDEX_op_ext32u_i64, ret, arg1);
1166 return;
1167 }
1168 break;
1169 }
1170 t0 = tcg_const_i64(arg2);
e8996ee0 1171 tcg_gen_and_i64(ret, arg1, t0);
a7812ae4 1172 tcg_temp_free_i64(t0);
c896fe29
FB
1173}
1174
a7812ae4 1175static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1176{
7fc81051
AJ
1177 if (TCGV_EQUAL_I64(arg1, arg2)) {
1178 tcg_gen_mov_i64(ret, arg1);
1179 } else {
1180 tcg_gen_op3_i64(INDEX_op_or_i64, ret, arg1, arg2);
1181 }
c896fe29
FB
1182}
1183
a7812ae4 1184static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1185{
d81ada7f
RH
1186 /* Some cases can be optimized here. */
1187 if (arg2 == -1) {
1188 tcg_gen_movi_i64(ret, -1);
1189 } else if (arg2 == 0) {
1190 tcg_gen_mov_i64(ret, arg1);
1191 } else {
1192 TCGv_i64 t0 = tcg_const_i64(arg2);
1193 tcg_gen_or_i64(ret, arg1, t0);
1194 tcg_temp_free_i64(t0);
1195 }
c896fe29
FB
1196}
1197
a7812ae4 1198static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1199{
7fc81051
AJ
1200 if (TCGV_EQUAL_I64(arg1, arg2)) {
1201 tcg_gen_movi_i64(ret, 0);
1202 } else {
1203 tcg_gen_op3_i64(INDEX_op_xor_i64, ret, arg1, arg2);
1204 }
c896fe29
FB
1205}
1206
a7812ae4 1207static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1208{
a7812ae4 1209 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1210 tcg_gen_xor_i64(ret, arg1, t0);
a7812ae4 1211 tcg_temp_free_i64(t0);
c896fe29
FB
1212}
1213
a7812ae4 1214static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1215{
a7812ae4 1216 tcg_gen_op3_i64(INDEX_op_shl_i64, ret, arg1, arg2);
c896fe29
FB
1217}
1218
a7812ae4 1219static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1220{
34151a20
FB
1221 if (arg2 == 0) {
1222 tcg_gen_mov_i64(ret, arg1);
1223 } else {
a7812ae4 1224 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1225 tcg_gen_shl_i64(ret, arg1, t0);
a7812ae4 1226 tcg_temp_free_i64(t0);
34151a20 1227 }
c896fe29
FB
1228}
1229
a7812ae4 1230static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1231{
a7812ae4 1232 tcg_gen_op3_i64(INDEX_op_shr_i64, ret, arg1, arg2);
c896fe29
FB
1233}
1234
a7812ae4 1235static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1236{
34151a20
FB
1237 if (arg2 == 0) {
1238 tcg_gen_mov_i64(ret, arg1);
1239 } else {
a7812ae4 1240 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1241 tcg_gen_shr_i64(ret, arg1, t0);
a7812ae4 1242 tcg_temp_free_i64(t0);
34151a20 1243 }
c896fe29
FB
1244}
1245
a7812ae4 1246static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1247{
a7812ae4 1248 tcg_gen_op3_i64(INDEX_op_sar_i64, ret, arg1, arg2);
c896fe29
FB
1249}
1250
a7812ae4 1251static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
c896fe29 1252{
34151a20
FB
1253 if (arg2 == 0) {
1254 tcg_gen_mov_i64(ret, arg1);
1255 } else {
a7812ae4 1256 TCGv_i64 t0 = tcg_const_i64(arg2);
e8996ee0 1257 tcg_gen_sar_i64(ret, arg1, t0);
a7812ae4 1258 tcg_temp_free_i64(t0);
34151a20 1259 }
c896fe29
FB
1260}
1261
8a56e840
RH
1262static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1,
1263 TCGv_i64 arg2, int label_index)
c896fe29 1264{
a7812ae4 1265 tcg_gen_op4ii_i64(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
c896fe29
FB
1266}
1267
8a56e840 1268static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret,
5105c556
AJ
1269 TCGv_i64 arg1, TCGv_i64 arg2)
1270{
1271 tcg_gen_op4i_i64(INDEX_op_setcond_i64, ret, arg1, arg2, cond);
1272}
1273
a7812ae4 1274static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
c896fe29 1275{
a7812ae4 1276 tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2);
c896fe29
FB
1277}
1278
31d66551
AJ
1279static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1280{
25c4d9cc
RH
1281 if (TCG_TARGET_HAS_div_i64) {
1282 tcg_gen_op3_i64(INDEX_op_div_i64, ret, arg1, arg2);
1283 } else if (TCG_TARGET_HAS_div2_i64) {
1284 TCGv_i64 t0 = tcg_temp_new_i64();
1285 tcg_gen_sari_i64(t0, arg1, 63);
1286 tcg_gen_op5_i64(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
1287 tcg_temp_free_i64(t0);
1288 } else {
1289 int sizemask = 0;
1290 /* Return value and both arguments are 64-bit and signed. */
1291 sizemask |= tcg_gen_sizemask(0, 1, 1);
1292 sizemask |= tcg_gen_sizemask(1, 1, 1);
1293 sizemask |= tcg_gen_sizemask(2, 1, 1);
1294 tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
1295 }
31d66551
AJ
1296}
1297
1298static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1299{
25c4d9cc
RH
1300 if (TCG_TARGET_HAS_div_i64) {
1301 tcg_gen_op3_i64(INDEX_op_rem_i64, ret, arg1, arg2);
1302 } else if (TCG_TARGET_HAS_div2_i64) {
1303 TCGv_i64 t0 = tcg_temp_new_i64();
1304 tcg_gen_sari_i64(t0, arg1, 63);
1305 tcg_gen_op5_i64(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
1306 tcg_temp_free_i64(t0);
1307 } else {
1308 int sizemask = 0;
1309 /* Return value and both arguments are 64-bit and signed. */
1310 sizemask |= tcg_gen_sizemask(0, 1, 1);
1311 sizemask |= tcg_gen_sizemask(1, 1, 1);
1312 sizemask |= tcg_gen_sizemask(2, 1, 1);
1313 tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
1314 }
31d66551
AJ
1315}
1316
1317static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1318{
25c4d9cc
RH
1319 if (TCG_TARGET_HAS_div_i64) {
1320 tcg_gen_op3_i64(INDEX_op_divu_i64, ret, arg1, arg2);
1321 } else if (TCG_TARGET_HAS_div2_i64) {
1322 TCGv_i64 t0 = tcg_temp_new_i64();
1323 tcg_gen_movi_i64(t0, 0);
1324 tcg_gen_op5_i64(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
1325 tcg_temp_free_i64(t0);
1326 } else {
1327 int sizemask = 0;
1328 /* Return value and both arguments are 64-bit and unsigned. */
1329 sizemask |= tcg_gen_sizemask(0, 1, 0);
1330 sizemask |= tcg_gen_sizemask(1, 1, 0);
1331 sizemask |= tcg_gen_sizemask(2, 1, 0);
1332 tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
1333 }
31d66551
AJ
1334}
1335
1336static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1337{
25c4d9cc
RH
1338 if (TCG_TARGET_HAS_div_i64) {
1339 tcg_gen_op3_i64(INDEX_op_remu_i64, ret, arg1, arg2);
1340 } else if (TCG_TARGET_HAS_div2_i64) {
1341 TCGv_i64 t0 = tcg_temp_new_i64();
1342 tcg_gen_movi_i64(t0, 0);
1343 tcg_gen_op5_i64(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
1344 tcg_temp_free_i64(t0);
1345 } else {
1346 int sizemask = 0;
1347 /* Return value and both arguments are 64-bit and unsigned. */
1348 sizemask |= tcg_gen_sizemask(0, 1, 0);
1349 sizemask |= tcg_gen_sizemask(1, 1, 0);
1350 sizemask |= tcg_gen_sizemask(2, 1, 0);
1351 tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
1352 }
31d66551 1353}
25c4d9cc 1354#endif /* TCG_TARGET_REG_BITS == 32 */
c896fe29 1355
a7812ae4 1356static inline void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
6359706f
AJ
1357{
1358 /* some cases can be optimized here */
1359 if (arg2 == 0) {
1360 tcg_gen_mov_i64(ret, arg1);
1361 } else {
a7812ae4 1362 TCGv_i64 t0 = tcg_const_i64(arg2);
6359706f 1363 tcg_gen_add_i64(ret, arg1, t0);
a7812ae4 1364 tcg_temp_free_i64(t0);
6359706f
AJ
1365 }
1366}
1367
a7812ae4 1368static inline void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2)
0045734a 1369{
a7812ae4 1370 TCGv_i64 t0 = tcg_const_i64(arg1);
0045734a 1371 tcg_gen_sub_i64(ret, t0, arg2);
a7812ae4 1372 tcg_temp_free_i64(t0);
0045734a
AJ
1373}
1374
a7812ae4 1375static inline void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
6359706f
AJ
1376{
1377 /* some cases can be optimized here */
1378 if (arg2 == 0) {
1379 tcg_gen_mov_i64(ret, arg1);
1380 } else {
a7812ae4 1381 TCGv_i64 t0 = tcg_const_i64(arg2);
6359706f 1382 tcg_gen_sub_i64(ret, arg1, t0);
a7812ae4 1383 tcg_temp_free_i64(t0);
6359706f
AJ
1384 }
1385}
8a56e840
RH
1386static inline void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1,
1387 int64_t arg2, int label_index)
f02bb954 1388{
a7812ae4 1389 TCGv_i64 t0 = tcg_const_i64(arg2);
f02bb954 1390 tcg_gen_brcond_i64(cond, arg1, t0, label_index);
a7812ae4 1391 tcg_temp_free_i64(t0);
f02bb954
AJ
1392}
1393
8a56e840
RH
1394static inline void tcg_gen_setcondi_i64(TCGCond cond, TCGv_i64 ret,
1395 TCGv_i64 arg1, int64_t arg2)
5105c556
AJ
1396{
1397 TCGv_i64 t0 = tcg_const_i64(arg2);
1398 tcg_gen_setcond_i64(cond, ret, arg1, t0);
1399 tcg_temp_free_i64(t0);
1400}
1401
a7812ae4 1402static inline void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
f02bb954 1403{
a7812ae4 1404 TCGv_i64 t0 = tcg_const_i64(arg2);
f02bb954 1405 tcg_gen_mul_i64(ret, arg1, t0);
a7812ae4 1406 tcg_temp_free_i64(t0);
f02bb954
AJ
1407}
1408
6359706f 1409
c896fe29
FB
1410/***************************************/
1411/* optional operations */
1412
a7812ae4 1413static inline void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg)
c896fe29 1414{
25c4d9cc
RH
1415 if (TCG_TARGET_HAS_ext8s_i32) {
1416 tcg_gen_op2_i32(INDEX_op_ext8s_i32, ret, arg);
1417 } else {
1418 tcg_gen_shli_i32(ret, arg, 24);
1419 tcg_gen_sari_i32(ret, ret, 24);
1420 }
c896fe29
FB
1421}
1422
a7812ae4 1423static inline void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg)
c896fe29 1424{
25c4d9cc
RH
1425 if (TCG_TARGET_HAS_ext16s_i32) {
1426 tcg_gen_op2_i32(INDEX_op_ext16s_i32, ret, arg);
1427 } else {
1428 tcg_gen_shli_i32(ret, arg, 16);
1429 tcg_gen_sari_i32(ret, ret, 16);
1430 }
c896fe29
FB
1431}
1432
a7812ae4 1433static inline void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg)
86831435 1434{
25c4d9cc
RH
1435 if (TCG_TARGET_HAS_ext8u_i32) {
1436 tcg_gen_op2_i32(INDEX_op_ext8u_i32, ret, arg);
1437 } else {
1438 tcg_gen_andi_i32(ret, arg, 0xffu);
1439 }
86831435
PB
1440}
1441
a7812ae4 1442static inline void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg)
86831435 1443{
25c4d9cc
RH
1444 if (TCG_TARGET_HAS_ext16u_i32) {
1445 tcg_gen_op2_i32(INDEX_op_ext16u_i32, ret, arg);
1446 } else {
1447 tcg_gen_andi_i32(ret, arg, 0xffffu);
1448 }
86831435
PB
1449}
1450
c896fe29 1451/* Note: we assume the two high bytes are set to zero */
a7812ae4 1452static inline void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg)
c896fe29 1453{
25c4d9cc
RH
1454 if (TCG_TARGET_HAS_bswap16_i32) {
1455 tcg_gen_op2_i32(INDEX_op_bswap16_i32, ret, arg);
1456 } else {
1457 TCGv_i32 t0 = tcg_temp_new_i32();
c896fe29 1458
25c4d9cc
RH
1459 tcg_gen_ext8u_i32(t0, arg);
1460 tcg_gen_shli_i32(t0, t0, 8);
1461 tcg_gen_shri_i32(ret, arg, 8);
1462 tcg_gen_or_i32(ret, ret, t0);
1463 tcg_temp_free_i32(t0);
1464 }
c896fe29
FB
1465}
1466
66896cb8 1467static inline void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg)
c896fe29 1468{
25c4d9cc
RH
1469 if (TCG_TARGET_HAS_bswap32_i32) {
1470 tcg_gen_op2_i32(INDEX_op_bswap32_i32, ret, arg);
1471 } else {
1472 TCGv_i32 t0, t1;
1473 t0 = tcg_temp_new_i32();
1474 t1 = tcg_temp_new_i32();
c896fe29 1475
25c4d9cc 1476 tcg_gen_shli_i32(t0, arg, 24);
c896fe29 1477
25c4d9cc
RH
1478 tcg_gen_andi_i32(t1, arg, 0x0000ff00);
1479 tcg_gen_shli_i32(t1, t1, 8);
1480 tcg_gen_or_i32(t0, t0, t1);
c896fe29 1481
25c4d9cc
RH
1482 tcg_gen_shri_i32(t1, arg, 8);
1483 tcg_gen_andi_i32(t1, t1, 0x0000ff00);
1484 tcg_gen_or_i32(t0, t0, t1);
c896fe29 1485
25c4d9cc
RH
1486 tcg_gen_shri_i32(t1, arg, 24);
1487 tcg_gen_or_i32(ret, t0, t1);
1488 tcg_temp_free_i32(t0);
1489 tcg_temp_free_i32(t1);
1490 }
c896fe29
FB
1491}
1492
1493#if TCG_TARGET_REG_BITS == 32
a7812ae4 1494static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1495{
a7812ae4
PB
1496 tcg_gen_ext8s_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1497 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
1498}
1499
a7812ae4 1500static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1501{
a7812ae4
PB
1502 tcg_gen_ext16s_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1503 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
1504}
1505
a7812ae4 1506static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1507{
a7812ae4
PB
1508 tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1509 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
1510}
1511
a7812ae4 1512static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1513{
a7812ae4 1514 tcg_gen_ext8u_i32(TCGV_LOW(ret), TCGV_LOW(arg));
86831435
PB
1515 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1516}
1517
a7812ae4 1518static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1519{
a7812ae4 1520 tcg_gen_ext16u_i32(TCGV_LOW(ret), TCGV_LOW(arg));
86831435
PB
1521 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1522}
1523
a7812ae4 1524static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1525{
a7812ae4 1526 tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg));
86831435
PB
1527 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1528}
1529
a7812ae4 1530static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
c896fe29 1531{
a7812ae4 1532 tcg_gen_mov_i32(ret, TCGV_LOW(arg));
c896fe29
FB
1533}
1534
a7812ae4 1535static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
c896fe29 1536{
a7812ae4 1537 tcg_gen_mov_i32(TCGV_LOW(ret), arg);
ac56dd48 1538 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
1539}
1540
a7812ae4 1541static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
c896fe29 1542{
a7812ae4
PB
1543 tcg_gen_mov_i32(TCGV_LOW(ret), arg);
1544 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
1545}
1546
9a5c57fd
AJ
1547/* Note: we assume the six high bytes are set to zero */
1548static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg)
1549{
1550 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
1551 tcg_gen_bswap16_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1552}
1553
1554/* Note: we assume the four high bytes are set to zero */
1555static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg)
1556{
1557 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
1558 tcg_gen_bswap32_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1559}
1560
66896cb8 1561static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1562{
a7812ae4
PB
1563 TCGv_i32 t0, t1;
1564 t0 = tcg_temp_new_i32();
1565 t1 = tcg_temp_new_i32();
c896fe29 1566
66896cb8
AJ
1567 tcg_gen_bswap32_i32(t0, TCGV_LOW(arg));
1568 tcg_gen_bswap32_i32(t1, TCGV_HIGH(arg));
a7812ae4 1569 tcg_gen_mov_i32(TCGV_LOW(ret), t1);
ac56dd48 1570 tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
a7812ae4
PB
1571 tcg_temp_free_i32(t0);
1572 tcg_temp_free_i32(t1);
c896fe29
FB
1573}
1574#else
1575
a7812ae4 1576static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1577{
25c4d9cc
RH
1578 if (TCG_TARGET_HAS_ext8s_i64) {
1579 tcg_gen_op2_i64(INDEX_op_ext8s_i64, ret, arg);
1580 } else {
1581 tcg_gen_shli_i64(ret, arg, 56);
1582 tcg_gen_sari_i64(ret, ret, 56);
1583 }
c896fe29
FB
1584}
1585
a7812ae4 1586static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1587{
25c4d9cc
RH
1588 if (TCG_TARGET_HAS_ext16s_i64) {
1589 tcg_gen_op2_i64(INDEX_op_ext16s_i64, ret, arg);
1590 } else {
1591 tcg_gen_shli_i64(ret, arg, 48);
1592 tcg_gen_sari_i64(ret, ret, 48);
1593 }
c896fe29
FB
1594}
1595
a7812ae4 1596static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1597{
25c4d9cc
RH
1598 if (TCG_TARGET_HAS_ext32s_i64) {
1599 tcg_gen_op2_i64(INDEX_op_ext32s_i64, ret, arg);
1600 } else {
1601 tcg_gen_shli_i64(ret, arg, 32);
1602 tcg_gen_sari_i64(ret, ret, 32);
1603 }
c896fe29
FB
1604}
1605
a7812ae4 1606static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1607{
25c4d9cc
RH
1608 if (TCG_TARGET_HAS_ext8u_i64) {
1609 tcg_gen_op2_i64(INDEX_op_ext8u_i64, ret, arg);
1610 } else {
1611 tcg_gen_andi_i64(ret, arg, 0xffu);
1612 }
86831435
PB
1613}
1614
a7812ae4 1615static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1616{
25c4d9cc
RH
1617 if (TCG_TARGET_HAS_ext16u_i64) {
1618 tcg_gen_op2_i64(INDEX_op_ext16u_i64, ret, arg);
1619 } else {
1620 tcg_gen_andi_i64(ret, arg, 0xffffu);
1621 }
86831435
PB
1622}
1623
a7812ae4 1624static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg)
86831435 1625{
25c4d9cc
RH
1626 if (TCG_TARGET_HAS_ext32u_i64) {
1627 tcg_gen_op2_i64(INDEX_op_ext32u_i64, ret, arg);
1628 } else {
1629 tcg_gen_andi_i64(ret, arg, 0xffffffffu);
1630 }
86831435
PB
1631}
1632
c896fe29 1633/* Note: we assume the target supports move between 32 and 64 bit
ac56dd48 1634 registers. This will probably break MIPS64 targets. */
a7812ae4 1635static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
c896fe29 1636{
a7812ae4 1637 tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg)));
c896fe29
FB
1638}
1639
1640/* Note: we assume the target supports move between 32 and 64 bit
1641 registers */
a7812ae4 1642static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
c896fe29 1643{
cfc86988 1644 tcg_gen_ext32u_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg)));
c896fe29
FB
1645}
1646
1647/* Note: we assume the target supports move between 32 and 64 bit
1648 registers */
a7812ae4 1649static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg)
c896fe29 1650{
a7812ae4 1651 tcg_gen_ext32s_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg)));
c896fe29
FB
1652}
1653
9a5c57fd
AJ
1654/* Note: we assume the six high bytes are set to zero */
1655static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg)
1656{
25c4d9cc
RH
1657 if (TCG_TARGET_HAS_bswap16_i64) {
1658 tcg_gen_op2_i64(INDEX_op_bswap16_i64, ret, arg);
1659 } else {
1660 TCGv_i64 t0 = tcg_temp_new_i64();
9a5c57fd 1661
25c4d9cc
RH
1662 tcg_gen_ext8u_i64(t0, arg);
1663 tcg_gen_shli_i64(t0, t0, 8);
1664 tcg_gen_shri_i64(ret, arg, 8);
1665 tcg_gen_or_i64(ret, ret, t0);
1666 tcg_temp_free_i64(t0);
1667 }
9a5c57fd
AJ
1668}
1669
1670/* Note: we assume the four high bytes are set to zero */
1671static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg)
1672{
25c4d9cc
RH
1673 if (TCG_TARGET_HAS_bswap32_i64) {
1674 tcg_gen_op2_i64(INDEX_op_bswap32_i64, ret, arg);
1675 } else {
1676 TCGv_i64 t0, t1;
1677 t0 = tcg_temp_new_i64();
1678 t1 = tcg_temp_new_i64();
9a5c57fd 1679
25c4d9cc
RH
1680 tcg_gen_shli_i64(t0, arg, 24);
1681 tcg_gen_ext32u_i64(t0, t0);
9a5c57fd 1682
25c4d9cc
RH
1683 tcg_gen_andi_i64(t1, arg, 0x0000ff00);
1684 tcg_gen_shli_i64(t1, t1, 8);
1685 tcg_gen_or_i64(t0, t0, t1);
9a5c57fd 1686
25c4d9cc
RH
1687 tcg_gen_shri_i64(t1, arg, 8);
1688 tcg_gen_andi_i64(t1, t1, 0x0000ff00);
1689 tcg_gen_or_i64(t0, t0, t1);
9a5c57fd 1690
25c4d9cc
RH
1691 tcg_gen_shri_i64(t1, arg, 24);
1692 tcg_gen_or_i64(ret, t0, t1);
1693 tcg_temp_free_i64(t0);
1694 tcg_temp_free_i64(t1);
1695 }
9a5c57fd
AJ
1696}
1697
66896cb8 1698static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg)
c896fe29 1699{
25c4d9cc
RH
1700 if (TCG_TARGET_HAS_bswap64_i64) {
1701 tcg_gen_op2_i64(INDEX_op_bswap64_i64, ret, arg);
1702 } else {
1703 TCGv_i64 t0 = tcg_temp_new_i64();
1704 TCGv_i64 t1 = tcg_temp_new_i64();
c896fe29 1705
25c4d9cc 1706 tcg_gen_shli_i64(t0, arg, 56);
c896fe29 1707
25c4d9cc
RH
1708 tcg_gen_andi_i64(t1, arg, 0x0000ff00);
1709 tcg_gen_shli_i64(t1, t1, 40);
1710 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1711
25c4d9cc
RH
1712 tcg_gen_andi_i64(t1, arg, 0x00ff0000);
1713 tcg_gen_shli_i64(t1, t1, 24);
1714 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1715
25c4d9cc
RH
1716 tcg_gen_andi_i64(t1, arg, 0xff000000);
1717 tcg_gen_shli_i64(t1, t1, 8);
1718 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1719
25c4d9cc
RH
1720 tcg_gen_shri_i64(t1, arg, 8);
1721 tcg_gen_andi_i64(t1, t1, 0xff000000);
1722 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1723
25c4d9cc
RH
1724 tcg_gen_shri_i64(t1, arg, 24);
1725 tcg_gen_andi_i64(t1, t1, 0x00ff0000);
1726 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1727
25c4d9cc
RH
1728 tcg_gen_shri_i64(t1, arg, 40);
1729 tcg_gen_andi_i64(t1, t1, 0x0000ff00);
1730 tcg_gen_or_i64(t0, t0, t1);
c896fe29 1731
25c4d9cc
RH
1732 tcg_gen_shri_i64(t1, arg, 56);
1733 tcg_gen_or_i64(ret, t0, t1);
1734 tcg_temp_free_i64(t0);
1735 tcg_temp_free_i64(t1);
1736 }
c896fe29
FB
1737}
1738
1739#endif
1740
a7812ae4 1741static inline void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg)
390efc54 1742{
25c4d9cc
RH
1743 if (TCG_TARGET_HAS_neg_i32) {
1744 tcg_gen_op2_i32(INDEX_op_neg_i32, ret, arg);
1745 } else {
1746 TCGv_i32 t0 = tcg_const_i32(0);
1747 tcg_gen_sub_i32(ret, t0, arg);
1748 tcg_temp_free_i32(t0);
1749 }
390efc54
PB
1750}
1751
a7812ae4 1752static inline void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg)
390efc54 1753{
25c4d9cc
RH
1754 if (TCG_TARGET_HAS_neg_i64) {
1755 tcg_gen_op2_i64(INDEX_op_neg_i64, ret, arg);
1756 } else {
1757 TCGv_i64 t0 = tcg_const_i64(0);
1758 tcg_gen_sub_i64(ret, t0, arg);
1759 tcg_temp_free_i64(t0);
1760 }
390efc54
PB
1761}
1762
a7812ae4 1763static inline void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg)
0b6ce4cf 1764{
25c4d9cc
RH
1765 if (TCG_TARGET_HAS_not_i32) {
1766 tcg_gen_op2_i32(INDEX_op_not_i32, ret, arg);
1767 } else {
1768 tcg_gen_xori_i32(ret, arg, -1);
1769 }
0b6ce4cf
FB
1770}
1771
a7812ae4 1772static inline void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg)
0b6ce4cf 1773{
25c4d9cc
RH
1774#if TCG_TARGET_REG_BITS == 64
1775 if (TCG_TARGET_HAS_not_i64) {
1776 tcg_gen_op2_i64(INDEX_op_not_i64, ret, arg);
1777 } else {
1778 tcg_gen_xori_i64(ret, arg, -1);
1779 }
1780#else
a10f9f4f
RH
1781 tcg_gen_not_i32(TCGV_LOW(ret), TCGV_LOW(arg));
1782 tcg_gen_not_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
d2604285 1783#endif
0b6ce4cf 1784}
5ff9d6a4 1785
a7812ae4 1786static inline void tcg_gen_discard_i32(TCGv_i32 arg)
5ff9d6a4 1787{
a7812ae4 1788 tcg_gen_op1_i32(INDEX_op_discard, arg);
5ff9d6a4
FB
1789}
1790
a7812ae4 1791static inline void tcg_gen_discard_i64(TCGv_i64 arg)
5ff9d6a4 1792{
25c4d9cc 1793#if TCG_TARGET_REG_BITS == 32
a7812ae4 1794 tcg_gen_discard_i32(TCGV_LOW(arg));
5ff9d6a4 1795 tcg_gen_discard_i32(TCGV_HIGH(arg));
5ff9d6a4 1796#else
a7812ae4 1797 tcg_gen_op1_i64(INDEX_op_discard, arg);
5ff9d6a4 1798#endif
25c4d9cc 1799}
5ff9d6a4 1800
a7812ae4 1801static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high)
36aa55dc
PB
1802{
1803#if TCG_TARGET_REG_BITS == 32
a7812ae4 1804 tcg_gen_mov_i32(TCGV_LOW(dest), low);
36aa55dc
PB
1805 tcg_gen_mov_i32(TCGV_HIGH(dest), high);
1806#else
a7812ae4 1807 TCGv_i64 tmp = tcg_temp_new_i64();
36aa55dc
PB
1808 /* This extension is only needed for type correctness.
1809 We may be able to do better given target specific information. */
1810 tcg_gen_extu_i32_i64(tmp, high);
1811 tcg_gen_shli_i64(tmp, tmp, 32);
1812 tcg_gen_extu_i32_i64(dest, low);
1813 tcg_gen_or_i64(dest, dest, tmp);
a7812ae4 1814 tcg_temp_free_i64(tmp);
36aa55dc
PB
1815#endif
1816}
1817
a7812ae4 1818static inline void tcg_gen_concat32_i64(TCGv_i64 dest, TCGv_i64 low, TCGv_i64 high)
945ca823
BS
1819{
1820#if TCG_TARGET_REG_BITS == 32
a7812ae4 1821 tcg_gen_concat_i32_i64(dest, TCGV_LOW(low), TCGV_LOW(high));
945ca823 1822#else
a7812ae4 1823 TCGv_i64 tmp = tcg_temp_new_i64();
88422e2e 1824 tcg_gen_ext32u_i64(dest, low);
945ca823 1825 tcg_gen_shli_i64(tmp, high, 32);
88422e2e 1826 tcg_gen_or_i64(dest, dest, tmp);
a7812ae4 1827 tcg_temp_free_i64(tmp);
945ca823
BS
1828#endif
1829}
1830
a7812ae4 1831static inline void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1832{
25c4d9cc
RH
1833 if (TCG_TARGET_HAS_andc_i32) {
1834 tcg_gen_op3_i32(INDEX_op_andc_i32, ret, arg1, arg2);
1835 } else {
1836 TCGv_i32 t0 = tcg_temp_new_i32();
1837 tcg_gen_not_i32(t0, arg2);
1838 tcg_gen_and_i32(ret, arg1, t0);
1839 tcg_temp_free_i32(t0);
1840 }
f24cb33e
AJ
1841}
1842
a7812ae4 1843static inline void tcg_gen_andc_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_andc_i64) {
1847 tcg_gen_op3_i64(INDEX_op_andc_i64, ret, arg1, arg2);
1848 } else {
1849 TCGv_i64 t0 = tcg_temp_new_i64();
1850 tcg_gen_not_i64(t0, arg2);
1851 tcg_gen_and_i64(ret, arg1, t0);
1852 tcg_temp_free_i64(t0);
1853 }
1854#else
241cbed4
RH
1855 tcg_gen_andc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1856 tcg_gen_andc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
241cbed4 1857#endif
f24cb33e
AJ
1858}
1859
a7812ae4 1860static inline void tcg_gen_eqv_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1861{
25c4d9cc
RH
1862 if (TCG_TARGET_HAS_eqv_i32) {
1863 tcg_gen_op3_i32(INDEX_op_eqv_i32, ret, arg1, arg2);
1864 } else {
1865 tcg_gen_xor_i32(ret, arg1, arg2);
1866 tcg_gen_not_i32(ret, ret);
1867 }
f24cb33e
AJ
1868}
1869
a7812ae4 1870static inline void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
f24cb33e 1871{
25c4d9cc
RH
1872#if TCG_TARGET_REG_BITS == 64
1873 if (TCG_TARGET_HAS_eqv_i64) {
1874 tcg_gen_op3_i64(INDEX_op_eqv_i64, ret, arg1, arg2);
1875 } else {
1876 tcg_gen_xor_i64(ret, arg1, arg2);
1877 tcg_gen_not_i64(ret, ret);
1878 }
1879#else
8d625cf1
RH
1880 tcg_gen_eqv_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1881 tcg_gen_eqv_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
8d625cf1 1882#endif
f24cb33e
AJ
1883}
1884
a7812ae4 1885static inline void tcg_gen_nand_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1886{
25c4d9cc
RH
1887 if (TCG_TARGET_HAS_nand_i32) {
1888 tcg_gen_op3_i32(INDEX_op_nand_i32, ret, arg1, arg2);
1889 } else {
1890 tcg_gen_and_i32(ret, arg1, arg2);
1891 tcg_gen_not_i32(ret, ret);
1892 }
f24cb33e
AJ
1893}
1894
a7812ae4 1895static inline void tcg_gen_nand_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_nand_i64) {
1899 tcg_gen_op3_i64(INDEX_op_nand_i64, ret, arg1, arg2);
1900 } else {
1901 tcg_gen_and_i64(ret, arg1, arg2);
1902 tcg_gen_not_i64(ret, ret);
1903 }
1904#else
9940a96b
RH
1905 tcg_gen_nand_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1906 tcg_gen_nand_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
9940a96b 1907#endif
f24cb33e
AJ
1908}
1909
a7812ae4 1910static inline void tcg_gen_nor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1911{
25c4d9cc
RH
1912 if (TCG_TARGET_HAS_nor_i32) {
1913 tcg_gen_op3_i32(INDEX_op_nor_i32, ret, arg1, arg2);
1914 } else {
1915 tcg_gen_or_i32(ret, arg1, arg2);
1916 tcg_gen_not_i32(ret, ret);
1917 }
f24cb33e
AJ
1918}
1919
a7812ae4 1920static inline void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
f24cb33e 1921{
25c4d9cc
RH
1922#if TCG_TARGET_REG_BITS == 64
1923 if (TCG_TARGET_HAS_nor_i64) {
1924 tcg_gen_op3_i64(INDEX_op_nor_i64, ret, arg1, arg2);
1925 } else {
1926 tcg_gen_or_i64(ret, arg1, arg2);
1927 tcg_gen_not_i64(ret, ret);
1928 }
1929#else
32d98fbd
RH
1930 tcg_gen_nor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1931 tcg_gen_nor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
32d98fbd 1932#endif
f24cb33e
AJ
1933}
1934
a7812ae4 1935static inline void tcg_gen_orc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
f24cb33e 1936{
25c4d9cc
RH
1937 if (TCG_TARGET_HAS_orc_i32) {
1938 tcg_gen_op3_i32(INDEX_op_orc_i32, ret, arg1, arg2);
1939 } else {
1940 TCGv_i32 t0 = tcg_temp_new_i32();
1941 tcg_gen_not_i32(t0, arg2);
1942 tcg_gen_or_i32(ret, arg1, t0);
1943 tcg_temp_free_i32(t0);
1944 }
f24cb33e
AJ
1945}
1946
a7812ae4 1947static inline void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
f24cb33e 1948{
25c4d9cc
RH
1949#if TCG_TARGET_REG_BITS == 64
1950 if (TCG_TARGET_HAS_orc_i64) {
1951 tcg_gen_op3_i64(INDEX_op_orc_i64, ret, arg1, arg2);
1952 } else {
1953 TCGv_i64 t0 = tcg_temp_new_i64();
1954 tcg_gen_not_i64(t0, arg2);
1955 tcg_gen_or_i64(ret, arg1, t0);
1956 tcg_temp_free_i64(t0);
1957 }
1958#else
791d1262
RH
1959 tcg_gen_orc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2));
1960 tcg_gen_orc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
791d1262 1961#endif
f24cb33e
AJ
1962}
1963
a7812ae4 1964static inline void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
15824571 1965{
25c4d9cc
RH
1966 if (TCG_TARGET_HAS_rot_i32) {
1967 tcg_gen_op3_i32(INDEX_op_rotl_i32, ret, arg1, arg2);
1968 } else {
1969 TCGv_i32 t0, t1;
15824571 1970
25c4d9cc
RH
1971 t0 = tcg_temp_new_i32();
1972 t1 = tcg_temp_new_i32();
1973 tcg_gen_shl_i32(t0, arg1, arg2);
1974 tcg_gen_subfi_i32(t1, 32, arg2);
1975 tcg_gen_shr_i32(t1, arg1, t1);
1976 tcg_gen_or_i32(ret, t0, t1);
1977 tcg_temp_free_i32(t0);
1978 tcg_temp_free_i32(t1);
1979 }
15824571
AJ
1980}
1981
a7812ae4 1982static inline void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
15824571 1983{
25c4d9cc
RH
1984 if (TCG_TARGET_HAS_rot_i64) {
1985 tcg_gen_op3_i64(INDEX_op_rotl_i64, ret, arg1, arg2);
1986 } else {
1987 TCGv_i64 t0, t1;
1988 t0 = tcg_temp_new_i64();
1989 t1 = tcg_temp_new_i64();
1990 tcg_gen_shl_i64(t0, arg1, arg2);
1991 tcg_gen_subfi_i64(t1, 64, arg2);
1992 tcg_gen_shr_i64(t1, arg1, t1);
1993 tcg_gen_or_i64(ret, t0, t1);
1994 tcg_temp_free_i64(t0);
1995 tcg_temp_free_i64(t1);
1996 }
15824571
AJ
1997}
1998
a7812ae4 1999static inline void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
15824571
AJ
2000{
2001 /* some cases can be optimized here */
2002 if (arg2 == 0) {
2003 tcg_gen_mov_i32(ret, arg1);
25c4d9cc 2004 } else if (TCG_TARGET_HAS_rot_i32) {
d42f183c
AJ
2005 TCGv_i32 t0 = tcg_const_i32(arg2);
2006 tcg_gen_rotl_i32(ret, arg1, t0);
2007 tcg_temp_free_i32(t0);
25c4d9cc 2008 } else {
a7812ae4
PB
2009 TCGv_i32 t0, t1;
2010 t0 = tcg_temp_new_i32();
2011 t1 = tcg_temp_new_i32();
15824571
AJ
2012 tcg_gen_shli_i32(t0, arg1, arg2);
2013 tcg_gen_shri_i32(t1, arg1, 32 - arg2);
2014 tcg_gen_or_i32(ret, t0, t1);
a7812ae4
PB
2015 tcg_temp_free_i32(t0);
2016 tcg_temp_free_i32(t1);
15824571
AJ
2017 }
2018}
2019
a7812ae4 2020static inline void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
15824571
AJ
2021{
2022 /* some cases can be optimized here */
2023 if (arg2 == 0) {
2024 tcg_gen_mov_i64(ret, arg1);
25c4d9cc 2025 } else if (TCG_TARGET_HAS_rot_i64) {
d42f183c
AJ
2026 TCGv_i64 t0 = tcg_const_i64(arg2);
2027 tcg_gen_rotl_i64(ret, arg1, t0);
2028 tcg_temp_free_i64(t0);
25c4d9cc 2029 } else {
a7812ae4
PB
2030 TCGv_i64 t0, t1;
2031 t0 = tcg_temp_new_i64();
2032 t1 = tcg_temp_new_i64();
15824571
AJ
2033 tcg_gen_shli_i64(t0, arg1, arg2);
2034 tcg_gen_shri_i64(t1, arg1, 64 - arg2);
2035 tcg_gen_or_i64(ret, t0, t1);
a7812ae4
PB
2036 tcg_temp_free_i64(t0);
2037 tcg_temp_free_i64(t1);
15824571
AJ
2038 }
2039}
2040
a7812ae4 2041static inline void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
15824571 2042{
25c4d9cc
RH
2043 if (TCG_TARGET_HAS_rot_i32) {
2044 tcg_gen_op3_i32(INDEX_op_rotr_i32, ret, arg1, arg2);
2045 } else {
2046 TCGv_i32 t0, t1;
15824571 2047
25c4d9cc
RH
2048 t0 = tcg_temp_new_i32();
2049 t1 = tcg_temp_new_i32();
2050 tcg_gen_shr_i32(t0, arg1, arg2);
2051 tcg_gen_subfi_i32(t1, 32, arg2);
2052 tcg_gen_shl_i32(t1, arg1, t1);
2053 tcg_gen_or_i32(ret, t0, t1);
2054 tcg_temp_free_i32(t0);
2055 tcg_temp_free_i32(t1);
2056 }
15824571
AJ
2057}
2058
a7812ae4 2059static inline void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
15824571 2060{
25c4d9cc
RH
2061 if (TCG_TARGET_HAS_rot_i64) {
2062 tcg_gen_op3_i64(INDEX_op_rotr_i64, ret, arg1, arg2);
2063 } else {
2064 TCGv_i64 t0, t1;
2065 t0 = tcg_temp_new_i64();
2066 t1 = tcg_temp_new_i64();
2067 tcg_gen_shr_i64(t0, arg1, arg2);
2068 tcg_gen_subfi_i64(t1, 64, arg2);
2069 tcg_gen_shl_i64(t1, arg1, t1);
2070 tcg_gen_or_i64(ret, t0, t1);
2071 tcg_temp_free_i64(t0);
2072 tcg_temp_free_i64(t1);
2073 }
15824571
AJ
2074}
2075
a7812ae4 2076static inline void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
15824571
AJ
2077{
2078 /* some cases can be optimized here */
2079 if (arg2 == 0) {
2080 tcg_gen_mov_i32(ret, arg1);
2081 } else {
2082 tcg_gen_rotli_i32(ret, arg1, 32 - arg2);
2083 }
2084}
2085
a7812ae4 2086static inline void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
15824571
AJ
2087{
2088 /* some cases can be optimized here */
2089 if (arg2 == 0) {
de3526b2 2090 tcg_gen_mov_i64(ret, arg1);
15824571
AJ
2091 } else {
2092 tcg_gen_rotli_i64(ret, arg1, 64 - arg2);
2093 }
2094}
2095
b7767f0f 2096static inline void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1,
0756e71c
RH
2097 TCGv_i32 arg2, unsigned int ofs,
2098 unsigned int len)
b7767f0f 2099{
df072774
RH
2100 uint32_t mask;
2101 TCGv_i32 t1;
2102
2103 if (ofs == 0 && len == 32) {
2104 tcg_gen_mov_i32(ret, arg2);
2105 return;
2106 }
a4773324 2107 if (TCG_TARGET_HAS_deposit_i32 && TCG_TARGET_deposit_i32_valid(ofs, len)) {
25c4d9cc 2108 tcg_gen_op5ii_i32(INDEX_op_deposit_i32, ret, arg1, arg2, ofs, len);
df072774
RH
2109 return;
2110 }
2111
2112 mask = (1u << len) - 1;
2113 t1 = tcg_temp_new_i32();
b7767f0f 2114
df072774 2115 if (ofs + len < 32) {
25c4d9cc
RH
2116 tcg_gen_andi_i32(t1, arg2, mask);
2117 tcg_gen_shli_i32(t1, t1, ofs);
df072774
RH
2118 } else {
2119 tcg_gen_shli_i32(t1, arg2, ofs);
25c4d9cc 2120 }
df072774
RH
2121 tcg_gen_andi_i32(ret, arg1, ~(mask << ofs));
2122 tcg_gen_or_i32(ret, ret, t1);
2123
2124 tcg_temp_free_i32(t1);
b7767f0f
RH
2125}
2126
2127static inline void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1,
0756e71c
RH
2128 TCGv_i64 arg2, unsigned int ofs,
2129 unsigned int len)
b7767f0f 2130{
df072774
RH
2131 uint64_t mask;
2132 TCGv_i64 t1;
2133
2134 if (ofs == 0 && len == 64) {
2135 tcg_gen_mov_i64(ret, arg2);
2136 return;
2137 }
a4773324 2138 if (TCG_TARGET_HAS_deposit_i64 && TCG_TARGET_deposit_i64_valid(ofs, len)) {
25c4d9cc 2139 tcg_gen_op5ii_i64(INDEX_op_deposit_i64, ret, arg1, arg2, ofs, len);
df072774
RH
2140 return;
2141 }
b7767f0f 2142
df072774
RH
2143#if TCG_TARGET_REG_BITS == 32
2144 if (ofs >= 32) {
2f98c9db 2145 tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg1));
df072774
RH
2146 tcg_gen_deposit_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1),
2147 TCGV_LOW(arg2), ofs - 32, len);
2148 return;
2149 }
2150 if (ofs + len <= 32) {
2151 tcg_gen_deposit_i32(TCGV_LOW(ret), TCGV_LOW(arg1),
2152 TCGV_LOW(arg2), ofs, len);
2f98c9db 2153 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1));
df072774
RH
2154 return;
2155 }
2156#endif
2157
2158 mask = (1ull << len) - 1;
2159 t1 = tcg_temp_new_i64();
2160
2161 if (ofs + len < 64) {
25c4d9cc
RH
2162 tcg_gen_andi_i64(t1, arg2, mask);
2163 tcg_gen_shli_i64(t1, t1, ofs);
df072774
RH
2164 } else {
2165 tcg_gen_shli_i64(t1, arg2, ofs);
25c4d9cc 2166 }
df072774
RH
2167 tcg_gen_andi_i64(ret, arg1, ~(mask << ofs));
2168 tcg_gen_or_i64(ret, ret, t1);
2169
2170 tcg_temp_free_i64(t1);
b7767f0f
RH
2171}
2172
ffc5ea09
RH
2173static inline void tcg_gen_movcond_i32(TCGCond cond, TCGv_i32 ret,
2174 TCGv_i32 c1, TCGv_i32 c2,
2175 TCGv_i32 v1, TCGv_i32 v2)
2176{
2177 if (TCG_TARGET_HAS_movcond_i32) {
2178 tcg_gen_op6i_i32(INDEX_op_movcond_i32, ret, c1, c2, v1, v2, cond);
2179 } else {
2180 TCGv_i32 t0 = tcg_temp_new_i32();
2181 TCGv_i32 t1 = tcg_temp_new_i32();
2182 tcg_gen_setcond_i32(cond, t0, c1, c2);
2183 tcg_gen_neg_i32(t0, t0);
2184 tcg_gen_and_i32(t1, v1, t0);
2185 tcg_gen_andc_i32(ret, v2, t0);
2186 tcg_gen_or_i32(ret, ret, t1);
2187 tcg_temp_free_i32(t0);
2188 tcg_temp_free_i32(t1);
2189 }
2190}
2191
2192static inline void tcg_gen_movcond_i64(TCGCond cond, TCGv_i64 ret,
2193 TCGv_i64 c1, TCGv_i64 c2,
2194 TCGv_i64 v1, TCGv_i64 v2)
2195{
2196 if (TCG_TARGET_HAS_movcond_i64) {
2197 tcg_gen_op6i_i64(INDEX_op_movcond_i64, ret, c1, c2, v1, v2, cond);
2198 } else {
2199 TCGv_i64 t0 = tcg_temp_new_i64();
2200 TCGv_i64 t1 = tcg_temp_new_i64();
2201 tcg_gen_setcond_i64(cond, t0, c1, c2);
2202 tcg_gen_neg_i64(t0, t0);
2203 tcg_gen_and_i64(t1, v1, t0);
2204 tcg_gen_andc_i64(ret, v2, t0);
2205 tcg_gen_or_i64(ret, ret, t1);
2206 tcg_temp_free_i64(t0);
2207 tcg_temp_free_i64(t1);
2208 }
2209}
2210
c896fe29
FB
2211/***************************************/
2212/* QEMU specific operations. Their type depend on the QEMU CPU
2213 type. */
2214#ifndef TARGET_LONG_BITS
2215#error must include QEMU headers
2216#endif
2217
a7812ae4
PB
2218#if TARGET_LONG_BITS == 32
2219#define TCGv TCGv_i32
2220#define tcg_temp_new() tcg_temp_new_i32()
2221#define tcg_global_reg_new tcg_global_reg_new_i32
2222#define tcg_global_mem_new tcg_global_mem_new_i32
df9247b2 2223#define tcg_temp_local_new() tcg_temp_local_new_i32()
a7812ae4
PB
2224#define tcg_temp_free tcg_temp_free_i32
2225#define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32
2226#define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32
2227#define TCGV_UNUSED(x) TCGV_UNUSED_I32(x)
fe75bcf7 2228#define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b)
a7812ae4
PB
2229#else
2230#define TCGv TCGv_i64
2231#define tcg_temp_new() tcg_temp_new_i64()
2232#define tcg_global_reg_new tcg_global_reg_new_i64
2233#define tcg_global_mem_new tcg_global_mem_new_i64
df9247b2 2234#define tcg_temp_local_new() tcg_temp_local_new_i64()
a7812ae4
PB
2235#define tcg_temp_free tcg_temp_free_i64
2236#define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64
2237#define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64
2238#define TCGV_UNUSED(x) TCGV_UNUSED_I64(x)
fe75bcf7 2239#define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b)
a7812ae4
PB
2240#endif
2241
7e4597d7
FB
2242/* debug info: write the PC of the corresponding QEMU CPU instruction */
2243static inline void tcg_gen_debug_insn_start(uint64_t pc)
2244{
2245 /* XXX: must really use a 32 bit size for TCGArg in all cases */
2246#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
bcb0126f
PB
2247 tcg_gen_op2ii(INDEX_op_debug_insn_start,
2248 (uint32_t)(pc), (uint32_t)(pc >> 32));
7e4597d7
FB
2249#else
2250 tcg_gen_op1i(INDEX_op_debug_insn_start, pc);
2251#endif
2252}
2253
c896fe29
FB
2254static inline void tcg_gen_exit_tb(tcg_target_long val)
2255{
ac56dd48 2256 tcg_gen_op1i(INDEX_op_exit_tb, val);
c896fe29
FB
2257}
2258
2259static inline void tcg_gen_goto_tb(int idx)
2260{
ac56dd48 2261 tcg_gen_op1i(INDEX_op_goto_tb, idx);
c896fe29
FB
2262}
2263
2264#if TCG_TARGET_REG_BITS == 32
ac56dd48 2265static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2266{
2267#if TARGET_LONG_BITS == 32
a7812ae4 2268 tcg_gen_op3i_i32(INDEX_op_qemu_ld8u, ret, addr, mem_index);
c896fe29 2269#else
a7812ae4
PB
2270 tcg_gen_op4i_i32(INDEX_op_qemu_ld8u, TCGV_LOW(ret), TCGV_LOW(addr),
2271 TCGV_HIGH(addr), mem_index);
ac56dd48 2272 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
2273#endif
2274}
2275
ac56dd48 2276static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2277{
2278#if TARGET_LONG_BITS == 32
a7812ae4 2279 tcg_gen_op3i_i32(INDEX_op_qemu_ld8s, ret, addr, mem_index);
c896fe29 2280#else
a7812ae4
PB
2281 tcg_gen_op4i_i32(INDEX_op_qemu_ld8s, TCGV_LOW(ret), TCGV_LOW(addr),
2282 TCGV_HIGH(addr), mem_index);
2283 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
2284#endif
2285}
2286
ac56dd48 2287static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2288{
2289#if TARGET_LONG_BITS == 32
a7812ae4 2290 tcg_gen_op3i_i32(INDEX_op_qemu_ld16u, ret, addr, mem_index);
c896fe29 2291#else
a7812ae4
PB
2292 tcg_gen_op4i_i32(INDEX_op_qemu_ld16u, TCGV_LOW(ret), TCGV_LOW(addr),
2293 TCGV_HIGH(addr), mem_index);
ac56dd48 2294 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
2295#endif
2296}
2297
ac56dd48 2298static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2299{
2300#if TARGET_LONG_BITS == 32
a7812ae4 2301 tcg_gen_op3i_i32(INDEX_op_qemu_ld16s, ret, addr, mem_index);
c896fe29 2302#else
a7812ae4
PB
2303 tcg_gen_op4i_i32(INDEX_op_qemu_ld16s, TCGV_LOW(ret), TCGV_LOW(addr),
2304 TCGV_HIGH(addr), mem_index);
2305 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
2306#endif
2307}
2308
ac56dd48 2309static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2310{
2311#if TARGET_LONG_BITS == 32
86feb1c8 2312 tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index);
c896fe29 2313#else
86feb1c8 2314 tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr),
a7812ae4 2315 TCGV_HIGH(addr), mem_index);
ac56dd48 2316 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
c896fe29
FB
2317#endif
2318}
2319
ac56dd48 2320static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
c896fe29
FB
2321{
2322#if TARGET_LONG_BITS == 32
86feb1c8 2323 tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index);
c896fe29 2324#else
86feb1c8 2325 tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr),
a7812ae4
PB
2326 TCGV_HIGH(addr), mem_index);
2327 tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31);
c896fe29
FB
2328#endif
2329}
2330
a7812ae4 2331static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index)
c896fe29
FB
2332{
2333#if TARGET_LONG_BITS == 32
a7812ae4 2334 tcg_gen_op4i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), addr, mem_index);
c896fe29 2335#else
a7812ae4
PB
2336 tcg_gen_op5i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret),
2337 TCGV_LOW(addr), TCGV_HIGH(addr), mem_index);
c896fe29
FB
2338#endif
2339}
2340
ac56dd48 2341static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
2342{
2343#if TARGET_LONG_BITS == 32
a7812ae4 2344 tcg_gen_op3i_i32(INDEX_op_qemu_st8, arg, addr, mem_index);
c896fe29 2345#else
a7812ae4
PB
2346 tcg_gen_op4i_i32(INDEX_op_qemu_st8, TCGV_LOW(arg), TCGV_LOW(addr),
2347 TCGV_HIGH(addr), mem_index);
c896fe29
FB
2348#endif
2349}
2350
ac56dd48 2351static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
2352{
2353#if TARGET_LONG_BITS == 32
a7812ae4 2354 tcg_gen_op3i_i32(INDEX_op_qemu_st16, arg, addr, mem_index);
c896fe29 2355#else
a7812ae4
PB
2356 tcg_gen_op4i_i32(INDEX_op_qemu_st16, TCGV_LOW(arg), TCGV_LOW(addr),
2357 TCGV_HIGH(addr), mem_index);
c896fe29
FB
2358#endif
2359}
2360
ac56dd48 2361static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
c896fe29
FB
2362{
2363#if TARGET_LONG_BITS == 32
a7812ae4 2364 tcg_gen_op3i_i32(INDEX_op_qemu_st32, arg, addr, mem_index);
c896fe29 2365#else
a7812ae4
PB
2366 tcg_gen_op4i_i32(INDEX_op_qemu_st32, TCGV_LOW(arg), TCGV_LOW(addr),
2367 TCGV_HIGH(addr), mem_index);
c896fe29
FB
2368#endif
2369}
2370
a7812ae4 2371static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
c896fe29
FB
2372{
2373#if TARGET_LONG_BITS == 32
a7812ae4
PB
2374 tcg_gen_op4i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), addr,
2375 mem_index);
c896fe29 2376#else
a7812ae4
PB
2377 tcg_gen_op5i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg),
2378 TCGV_LOW(addr), TCGV_HIGH(addr), mem_index);
c896fe29
FB
2379#endif
2380}
2381
ebecf363
PM
2382#define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i32(TCGV_PTR_TO_NAT(R), (A), (O))
2383#define tcg_gen_discard_ptr(A) tcg_gen_discard_i32(TCGV_PTR_TO_NAT(A))
f8422f52 2384
c896fe29
FB
2385#else /* TCG_TARGET_REG_BITS == 32 */
2386
ac56dd48 2387static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
c896fe29 2388{
a7812ae4 2389 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u, ret, addr, mem_index);
c896fe29
FB
2390}
2391
ac56dd48 2392static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
c896fe29 2393{
a7812ae4 2394 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s, ret, addr, mem_index);
c896fe29
FB
2395}
2396
ac56dd48 2397static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
c896fe29 2398{
a7812ae4 2399 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u, ret, addr, mem_index);
c896fe29
FB
2400}
2401
ac56dd48 2402static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
c896fe29 2403{
a7812ae4 2404 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s, ret, addr, mem_index);
c896fe29
FB
2405}
2406
ac56dd48 2407static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
c896fe29 2408{
3e1dbadd
RH
2409#if TARGET_LONG_BITS == 32
2410 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index);
2411#else
a7812ae4 2412 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u, ret, addr, mem_index);
3e1dbadd 2413#endif
c896fe29
FB
2414}
2415
ac56dd48 2416static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
c896fe29 2417{
3e1dbadd
RH
2418#if TARGET_LONG_BITS == 32
2419 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index);
2420#else
a7812ae4 2421 tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s, ret, addr, mem_index);
3e1dbadd 2422#endif
c896fe29
FB
2423}
2424
a7812ae4 2425static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index)
c896fe29 2426{
a7812ae4 2427 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64, ret, addr, mem_index);
c896fe29
FB
2428}
2429
ac56dd48 2430static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
c896fe29 2431{
a7812ae4 2432 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8, arg, addr, mem_index);
c896fe29
FB
2433}
2434
ac56dd48 2435static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
c896fe29 2436{
a7812ae4 2437 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16, arg, addr, mem_index);
c896fe29
FB
2438}
2439
ac56dd48 2440static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
c896fe29 2441{
a7812ae4 2442 tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32, arg, addr, mem_index);
c896fe29
FB
2443}
2444
a7812ae4 2445static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
c896fe29 2446{
a7812ae4 2447 tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64, arg, addr, mem_index);
c896fe29
FB
2448}
2449
ebecf363
PM
2450#define tcg_gen_ld_ptr(R, A, O) tcg_gen_ld_i64(TCGV_PTR_TO_NAT(R), (A), (O))
2451#define tcg_gen_discard_ptr(A) tcg_gen_discard_i64(TCGV_PTR_TO_NAT(A))
f8422f52 2452
c896fe29 2453#endif /* TCG_TARGET_REG_BITS != 32 */
f8422f52
BS
2454
2455#if TARGET_LONG_BITS == 64
f8422f52
BS
2456#define tcg_gen_movi_tl tcg_gen_movi_i64
2457#define tcg_gen_mov_tl tcg_gen_mov_i64
2458#define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
2459#define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
2460#define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
2461#define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
2462#define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
2463#define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
2464#define tcg_gen_ld_tl tcg_gen_ld_i64
2465#define tcg_gen_st8_tl tcg_gen_st8_i64
2466#define tcg_gen_st16_tl tcg_gen_st16_i64
2467#define tcg_gen_st32_tl tcg_gen_st32_i64
2468#define tcg_gen_st_tl tcg_gen_st_i64
2469#define tcg_gen_add_tl tcg_gen_add_i64
2470#define tcg_gen_addi_tl tcg_gen_addi_i64
2471#define tcg_gen_sub_tl tcg_gen_sub_i64
390efc54 2472#define tcg_gen_neg_tl tcg_gen_neg_i64
10460c8a 2473#define tcg_gen_subfi_tl tcg_gen_subfi_i64
f8422f52
BS
2474#define tcg_gen_subi_tl tcg_gen_subi_i64
2475#define tcg_gen_and_tl tcg_gen_and_i64
2476#define tcg_gen_andi_tl tcg_gen_andi_i64
2477#define tcg_gen_or_tl tcg_gen_or_i64
2478#define tcg_gen_ori_tl tcg_gen_ori_i64
2479#define tcg_gen_xor_tl tcg_gen_xor_i64
2480#define tcg_gen_xori_tl tcg_gen_xori_i64
0b6ce4cf 2481#define tcg_gen_not_tl tcg_gen_not_i64
f8422f52
BS
2482#define tcg_gen_shl_tl tcg_gen_shl_i64
2483#define tcg_gen_shli_tl tcg_gen_shli_i64
2484#define tcg_gen_shr_tl tcg_gen_shr_i64
2485#define tcg_gen_shri_tl tcg_gen_shri_i64
2486#define tcg_gen_sar_tl tcg_gen_sar_i64
2487#define tcg_gen_sari_tl tcg_gen_sari_i64
0cf767d6 2488#define tcg_gen_brcond_tl tcg_gen_brcond_i64
cb63669a 2489#define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
be210acb 2490#define tcg_gen_setcond_tl tcg_gen_setcond_i64
add1e7ea 2491#define tcg_gen_setcondi_tl tcg_gen_setcondi_i64
f730fd27
TS
2492#define tcg_gen_mul_tl tcg_gen_mul_i64
2493#define tcg_gen_muli_tl tcg_gen_muli_i64
ab36421e
AJ
2494#define tcg_gen_div_tl tcg_gen_div_i64
2495#define tcg_gen_rem_tl tcg_gen_rem_i64
864951af
AJ
2496#define tcg_gen_divu_tl tcg_gen_divu_i64
2497#define tcg_gen_remu_tl tcg_gen_remu_i64
a768e4b2 2498#define tcg_gen_discard_tl tcg_gen_discard_i64
e429073d
BS
2499#define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
2500#define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
2501#define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
2502#define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
2503#define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
2504#define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
0b6ce4cf
FB
2505#define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
2506#define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
2507#define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
2508#define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
2509#define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
2510#define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
911d79ba
AJ
2511#define tcg_gen_bswap16_tl tcg_gen_bswap16_i64
2512#define tcg_gen_bswap32_tl tcg_gen_bswap32_i64
2513#define tcg_gen_bswap64_tl tcg_gen_bswap64_i64
945ca823 2514#define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
f24cb33e
AJ
2515#define tcg_gen_andc_tl tcg_gen_andc_i64
2516#define tcg_gen_eqv_tl tcg_gen_eqv_i64
2517#define tcg_gen_nand_tl tcg_gen_nand_i64
2518#define tcg_gen_nor_tl tcg_gen_nor_i64
2519#define tcg_gen_orc_tl tcg_gen_orc_i64
15824571
AJ
2520#define tcg_gen_rotl_tl tcg_gen_rotl_i64
2521#define tcg_gen_rotli_tl tcg_gen_rotli_i64
2522#define tcg_gen_rotr_tl tcg_gen_rotr_i64
2523#define tcg_gen_rotri_tl tcg_gen_rotri_i64
b7767f0f 2524#define tcg_gen_deposit_tl tcg_gen_deposit_i64
a98824ac 2525#define tcg_const_tl tcg_const_i64
bdffd4a9 2526#define tcg_const_local_tl tcg_const_local_i64
ffc5ea09 2527#define tcg_gen_movcond_tl tcg_gen_movcond_i64
f8422f52 2528#else
f8422f52
BS
2529#define tcg_gen_movi_tl tcg_gen_movi_i32
2530#define tcg_gen_mov_tl tcg_gen_mov_i32
2531#define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
2532#define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
2533#define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
2534#define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
2535#define tcg_gen_ld32u_tl tcg_gen_ld_i32
2536#define tcg_gen_ld32s_tl tcg_gen_ld_i32
2537#define tcg_gen_ld_tl tcg_gen_ld_i32
2538#define tcg_gen_st8_tl tcg_gen_st8_i32
2539#define tcg_gen_st16_tl tcg_gen_st16_i32
2540#define tcg_gen_st32_tl tcg_gen_st_i32
2541#define tcg_gen_st_tl tcg_gen_st_i32
2542#define tcg_gen_add_tl tcg_gen_add_i32
2543#define tcg_gen_addi_tl tcg_gen_addi_i32
2544#define tcg_gen_sub_tl tcg_gen_sub_i32
390efc54 2545#define tcg_gen_neg_tl tcg_gen_neg_i32
0045734a 2546#define tcg_gen_subfi_tl tcg_gen_subfi_i32
f8422f52
BS
2547#define tcg_gen_subi_tl tcg_gen_subi_i32
2548#define tcg_gen_and_tl tcg_gen_and_i32
2549#define tcg_gen_andi_tl tcg_gen_andi_i32
2550#define tcg_gen_or_tl tcg_gen_or_i32
2551#define tcg_gen_ori_tl tcg_gen_ori_i32
2552#define tcg_gen_xor_tl tcg_gen_xor_i32
2553#define tcg_gen_xori_tl tcg_gen_xori_i32
0b6ce4cf 2554#define tcg_gen_not_tl tcg_gen_not_i32
f8422f52
BS
2555#define tcg_gen_shl_tl tcg_gen_shl_i32
2556#define tcg_gen_shli_tl tcg_gen_shli_i32
2557#define tcg_gen_shr_tl tcg_gen_shr_i32
2558#define tcg_gen_shri_tl tcg_gen_shri_i32
2559#define tcg_gen_sar_tl tcg_gen_sar_i32
2560#define tcg_gen_sari_tl tcg_gen_sari_i32
0cf767d6 2561#define tcg_gen_brcond_tl tcg_gen_brcond_i32
cb63669a 2562#define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
be210acb 2563#define tcg_gen_setcond_tl tcg_gen_setcond_i32
add1e7ea 2564#define tcg_gen_setcondi_tl tcg_gen_setcondi_i32
f730fd27
TS
2565#define tcg_gen_mul_tl tcg_gen_mul_i32
2566#define tcg_gen_muli_tl tcg_gen_muli_i32
ab36421e
AJ
2567#define tcg_gen_div_tl tcg_gen_div_i32
2568#define tcg_gen_rem_tl tcg_gen_rem_i32
864951af
AJ
2569#define tcg_gen_divu_tl tcg_gen_divu_i32
2570#define tcg_gen_remu_tl tcg_gen_remu_i32
a768e4b2 2571#define tcg_gen_discard_tl tcg_gen_discard_i32
e429073d
BS
2572#define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
2573#define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
2574#define tcg_gen_extu_i32_tl tcg_gen_mov_i32
2575#define tcg_gen_ext_i32_tl tcg_gen_mov_i32
2576#define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
2577#define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
0b6ce4cf
FB
2578#define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
2579#define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
2580#define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
2581#define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
2582#define tcg_gen_ext32u_tl tcg_gen_mov_i32
2583#define tcg_gen_ext32s_tl tcg_gen_mov_i32
911d79ba
AJ
2584#define tcg_gen_bswap16_tl tcg_gen_bswap16_i32
2585#define tcg_gen_bswap32_tl tcg_gen_bswap32_i32
945ca823 2586#define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
f24cb33e
AJ
2587#define tcg_gen_andc_tl tcg_gen_andc_i32
2588#define tcg_gen_eqv_tl tcg_gen_eqv_i32
2589#define tcg_gen_nand_tl tcg_gen_nand_i32
2590#define tcg_gen_nor_tl tcg_gen_nor_i32
2591#define tcg_gen_orc_tl tcg_gen_orc_i32
15824571
AJ
2592#define tcg_gen_rotl_tl tcg_gen_rotl_i32
2593#define tcg_gen_rotli_tl tcg_gen_rotli_i32
2594#define tcg_gen_rotr_tl tcg_gen_rotr_i32
2595#define tcg_gen_rotri_tl tcg_gen_rotri_i32
b7767f0f 2596#define tcg_gen_deposit_tl tcg_gen_deposit_i32
a98824ac 2597#define tcg_const_tl tcg_const_i32
bdffd4a9 2598#define tcg_const_local_tl tcg_const_local_i32
ffc5ea09 2599#define tcg_gen_movcond_tl tcg_gen_movcond_i32
f8422f52 2600#endif
6ddbc6e4
PB
2601
2602#if TCG_TARGET_REG_BITS == 32
ebecf363
PM
2603#define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i32(TCGV_PTR_TO_NAT(R), \
2604 TCGV_PTR_TO_NAT(A), \
2605 TCGV_PTR_TO_NAT(B))
2606#define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i32(TCGV_PTR_TO_NAT(R), \
2607 TCGV_PTR_TO_NAT(A), (B))
2608#define tcg_gen_ext_i32_ptr(R, A) tcg_gen_mov_i32(TCGV_PTR_TO_NAT(R), (A))
6ddbc6e4 2609#else /* TCG_TARGET_REG_BITS == 32 */
ebecf363
PM
2610#define tcg_gen_add_ptr(R, A, B) tcg_gen_add_i64(TCGV_PTR_TO_NAT(R), \
2611 TCGV_PTR_TO_NAT(A), \
2612 TCGV_PTR_TO_NAT(B))
2613#define tcg_gen_addi_ptr(R, A, B) tcg_gen_addi_i64(TCGV_PTR_TO_NAT(R), \
2614 TCGV_PTR_TO_NAT(A), (B))
2615#define tcg_gen_ext_i32_ptr(R, A) tcg_gen_ext_i32_i64(TCGV_PTR_TO_NAT(R), (A))
6ddbc6e4 2616#endif /* TCG_TARGET_REG_BITS != 32 */
This page took 0.96821 seconds and 4 git commands to generate.