VirtualBox

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

Last change on this file since 33995 was 29520, checked in by vboxsync, 15 years ago

fix wrong license headers

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