VirtualBox

source: vbox/trunk/src/recompiler/tcg/tcg-op.h@ 24345

Last change on this file since 24345 was 18083, checked in by vboxsync, 16 years ago

eol

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette