VirtualBox

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

最後變更 在這個檔案從36140是 36125,由 vboxsync 提交於 14 年 前

recompiler: Removing traces of attempts at making the recompiler compile with the microsoft compiler. (untested)

  • 屬性 svn:eol-style 設為 native
檔案大小: 46.9 KB
 
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
34static inline void tcg_gen_op1(int opc, TCGv arg1)
35{
36 *gen_opc_ptr++ = opc;
37 *gen_opparam_ptr++ = GET_TCGV(arg1);
38}
39
40static inline void tcg_gen_op1i(int opc, TCGArg arg1)
41{
42 *gen_opc_ptr++ = opc;
43 *gen_opparam_ptr++ = arg1;
44}
45
46static inline void tcg_gen_op2(int opc, TCGv arg1, TCGv arg2)
47{
48 *gen_opc_ptr++ = opc;
49 *gen_opparam_ptr++ = GET_TCGV(arg1);
50 *gen_opparam_ptr++ = GET_TCGV(arg2);
51}
52
53static inline void tcg_gen_op2i(int opc, TCGv arg1, TCGArg arg2)
54{
55 *gen_opc_ptr++ = opc;
56 *gen_opparam_ptr++ = GET_TCGV(arg1);
57 *gen_opparam_ptr++ = arg2;
58}
59
60static inline void tcg_gen_op2ii(int opc, TCGArg arg1, TCGArg arg2)
61{
62 *gen_opc_ptr++ = opc;
63 *gen_opparam_ptr++ = arg1;
64 *gen_opparam_ptr++ = arg2;
65}
66
67static inline void tcg_gen_op3(int opc, TCGv arg1, TCGv arg2, TCGv arg3)
68{
69 *gen_opc_ptr++ = opc;
70 *gen_opparam_ptr++ = GET_TCGV(arg1);
71 *gen_opparam_ptr++ = GET_TCGV(arg2);
72 *gen_opparam_ptr++ = GET_TCGV(arg3);
73}
74
75static inline void tcg_gen_op3i(int opc, TCGv arg1, TCGv arg2, TCGArg arg3)
76{
77 *gen_opc_ptr++ = opc;
78 *gen_opparam_ptr++ = GET_TCGV(arg1);
79 *gen_opparam_ptr++ = GET_TCGV(arg2);
80 *gen_opparam_ptr++ = arg3;
81}
82
83static inline void tcg_gen_op4(int opc, TCGv arg1, TCGv arg2, TCGv arg3,
84 TCGv arg4)
85{
86 *gen_opc_ptr++ = opc;
87 *gen_opparam_ptr++ = GET_TCGV(arg1);
88 *gen_opparam_ptr++ = GET_TCGV(arg2);
89 *gen_opparam_ptr++ = GET_TCGV(arg3);
90 *gen_opparam_ptr++ = GET_TCGV(arg4);
91}
92
93static inline void tcg_gen_op4i(int opc, TCGv arg1, TCGv arg2, TCGv arg3,
94 TCGArg arg4)
95{
96 *gen_opc_ptr++ = opc;
97 *gen_opparam_ptr++ = GET_TCGV(arg1);
98 *gen_opparam_ptr++ = GET_TCGV(arg2);
99 *gen_opparam_ptr++ = GET_TCGV(arg3);
100 *gen_opparam_ptr++ = arg4;
101}
102
103static inline void tcg_gen_op4ii(int opc, TCGv arg1, TCGv arg2, TCGArg arg3,
104 TCGArg arg4)
105{
106 *gen_opc_ptr++ = opc;
107 *gen_opparam_ptr++ = GET_TCGV(arg1);
108 *gen_opparam_ptr++ = GET_TCGV(arg2);
109 *gen_opparam_ptr++ = arg3;
110 *gen_opparam_ptr++ = arg4;
111}
112
113static inline void tcg_gen_op5(int opc, TCGv arg1, TCGv arg2,
114 TCGv arg3, TCGv arg4,
115 TCGv arg5)
116{
117 *gen_opc_ptr++ = opc;
118 *gen_opparam_ptr++ = GET_TCGV(arg1);
119 *gen_opparam_ptr++ = GET_TCGV(arg2);
120 *gen_opparam_ptr++ = GET_TCGV(arg3);
121 *gen_opparam_ptr++ = GET_TCGV(arg4);
122 *gen_opparam_ptr++ = GET_TCGV(arg5);
123}
124
125static inline void tcg_gen_op5i(int opc, TCGv arg1, TCGv arg2,
126 TCGv arg3, TCGv arg4,
127 TCGArg arg5)
128{
129 *gen_opc_ptr++ = opc;
130 *gen_opparam_ptr++ = GET_TCGV(arg1);
131 *gen_opparam_ptr++ = GET_TCGV(arg2);
132 *gen_opparam_ptr++ = GET_TCGV(arg3);
133 *gen_opparam_ptr++ = GET_TCGV(arg4);
134 *gen_opparam_ptr++ = arg5;
135}
136
137static inline void tcg_gen_op6(int opc, TCGv arg1, TCGv arg2,
138 TCGv arg3, TCGv arg4,
139 TCGv arg5, TCGv arg6)
140{
141 *gen_opc_ptr++ = opc;
142 *gen_opparam_ptr++ = GET_TCGV(arg1);
143 *gen_opparam_ptr++ = GET_TCGV(arg2);
144 *gen_opparam_ptr++ = GET_TCGV(arg3);
145 *gen_opparam_ptr++ = GET_TCGV(arg4);
146 *gen_opparam_ptr++ = GET_TCGV(arg5);
147 *gen_opparam_ptr++ = GET_TCGV(arg6);
148}
149
150static inline void tcg_gen_op6ii(int opc, TCGv arg1, TCGv arg2,
151 TCGv arg3, TCGv arg4,
152 TCGArg arg5, TCGArg arg6)
153{
154 *gen_opc_ptr++ = opc;
155 *gen_opparam_ptr++ = GET_TCGV(arg1);
156 *gen_opparam_ptr++ = GET_TCGV(arg2);
157 *gen_opparam_ptr++ = GET_TCGV(arg3);
158 *gen_opparam_ptr++ = GET_TCGV(arg4);
159 *gen_opparam_ptr++ = arg5;
160 *gen_opparam_ptr++ = arg6;
161}
162
163static inline void gen_set_label(int n)
164{
165 tcg_gen_op1i(INDEX_op_set_label, n);
166}
167
168static inline void tcg_gen_br(int label)
169{
170 tcg_gen_op1i(INDEX_op_br, label);
171}
172
173static inline void tcg_gen_mov_i32(TCGv ret, TCGv arg)
174{
175 if (GET_TCGV(ret) != GET_TCGV(arg))
176 tcg_gen_op2(INDEX_op_mov_i32, ret, arg);
177}
178
179static inline void tcg_gen_movi_i32(TCGv ret, int32_t arg)
180{
181 tcg_gen_op2i(INDEX_op_movi_i32, ret, arg);
182}
183
184/* helper calls */
185#define TCG_HELPER_CALL_FLAGS 0
186
187static inline void tcg_gen_helper_0_0(void *func)
188{
189 TCGv t0;
190 t0 = tcg_const_ptr((tcg_target_long)func);
191 tcg_gen_call(&tcg_ctx,
192 t0, TCG_HELPER_CALL_FLAGS,
193 0, NULL, 0, NULL);
194 tcg_temp_free(t0);
195}
196
197static inline void tcg_gen_helper_0_1(void *func, TCGv arg)
198{
199 TCGv t0;
200 t0 = tcg_const_ptr((tcg_target_long)func);
201 tcg_gen_call(&tcg_ctx,
202 t0, TCG_HELPER_CALL_FLAGS,
203 0, NULL, 1, &arg);
204 tcg_temp_free(t0);
205}
206
207static inline void tcg_gen_helper_0_2(void *func, TCGv arg1, TCGv arg2)
208{
209 TCGv args[2];
210 TCGv t0;
211 args[0] = arg1;
212 args[1] = arg2;
213 t0 = tcg_const_ptr((tcg_target_long)func);
214 tcg_gen_call(&tcg_ctx,
215 t0, TCG_HELPER_CALL_FLAGS,
216 0, NULL, 2, args);
217 tcg_temp_free(t0);
218}
219
220static inline void tcg_gen_helper_0_3(void *func,
221 TCGv arg1, TCGv arg2, TCGv arg3)
222{
223 TCGv args[3];
224 TCGv t0;
225 args[0] = arg1;
226 args[1] = arg2;
227 args[2] = arg3;
228 t0 = tcg_const_ptr((tcg_target_long)func);
229 tcg_gen_call(&tcg_ctx,
230 t0, TCG_HELPER_CALL_FLAGS,
231 0, NULL, 3, args);
232 tcg_temp_free(t0);
233}
234
235static inline void tcg_gen_helper_0_4(void *func, TCGv arg1, TCGv arg2,
236 TCGv arg3, TCGv arg4)
237{
238 TCGv args[4];
239 TCGv t0;
240 args[0] = arg1;
241 args[1] = arg2;
242 args[2] = arg3;
243 args[3] = arg4;
244 t0 = tcg_const_ptr((tcg_target_long)func);
245 tcg_gen_call(&tcg_ctx,
246 t0, TCG_HELPER_CALL_FLAGS,
247 0, NULL, 4, args);
248 tcg_temp_free(t0);
249}
250
251static inline void tcg_gen_helper_1_0(void *func, TCGv ret)
252{
253 TCGv t0;
254 t0 = tcg_const_ptr((tcg_target_long)func);
255 tcg_gen_call(&tcg_ctx,
256 t0, TCG_HELPER_CALL_FLAGS,
257 1, &ret, 0, NULL);
258 tcg_temp_free(t0);
259}
260
261static inline void tcg_gen_helper_1_1(void *func, TCGv ret, TCGv arg1)
262{
263 TCGv t0;
264 t0 = tcg_const_ptr((tcg_target_long)func);
265 tcg_gen_call(&tcg_ctx,
266 t0, TCG_HELPER_CALL_FLAGS,
267 1, &ret, 1, &arg1);
268 tcg_temp_free(t0);
269}
270
271static inline void tcg_gen_helper_1_2(void *func, TCGv ret,
272 TCGv arg1, TCGv arg2)
273{
274 TCGv args[2];
275 TCGv t0;
276 args[0] = arg1;
277 args[1] = arg2;
278 t0 = tcg_const_ptr((tcg_target_long)func);
279 tcg_gen_call(&tcg_ctx,
280 t0, TCG_HELPER_CALL_FLAGS,
281 1, &ret, 2, args);
282 tcg_temp_free(t0);
283}
284
285static inline void tcg_gen_helper_1_3(void *func, TCGv ret,
286 TCGv arg1, TCGv arg2, TCGv arg3)
287{
288 TCGv args[3];
289 TCGv t0;
290 args[0] = arg1;
291 args[1] = arg2;
292 args[2] = arg3;
293 t0 = tcg_const_ptr((tcg_target_long)func);
294 tcg_gen_call(&tcg_ctx,
295 t0, TCG_HELPER_CALL_FLAGS,
296 1, &ret, 3, args);
297 tcg_temp_free(t0);
298}
299
300static inline void tcg_gen_helper_1_4(void *func, TCGv ret,
301 TCGv arg1, TCGv arg2, TCGv arg3,
302 TCGv arg4)
303{
304 TCGv args[4];
305 TCGv t0;
306 args[0] = arg1;
307 args[1] = arg2;
308 args[2] = arg3;
309 args[3] = arg4;
310 t0 = tcg_const_ptr((tcg_target_long)func);
311 tcg_gen_call(&tcg_ctx,
312 t0, TCG_HELPER_CALL_FLAGS,
313 1, &ret, 4, args);
314 tcg_temp_free(t0);
315}
316
317/* 32 bit ops */
318
319static inline void tcg_gen_ld8u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
320{
321 tcg_gen_op3i(INDEX_op_ld8u_i32, ret, arg2, offset);
322}
323
324static inline void tcg_gen_ld8s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
325{
326 tcg_gen_op3i(INDEX_op_ld8s_i32, ret, arg2, offset);
327}
328
329static inline void tcg_gen_ld16u_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
330{
331 tcg_gen_op3i(INDEX_op_ld16u_i32, ret, arg2, offset);
332}
333
334static inline void tcg_gen_ld16s_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
335{
336 tcg_gen_op3i(INDEX_op_ld16s_i32, ret, arg2, offset);
337}
338
339static inline void tcg_gen_ld_i32(TCGv ret, TCGv arg2, tcg_target_long offset)
340{
341 tcg_gen_op3i(INDEX_op_ld_i32, ret, arg2, offset);
342}
343
344static inline void tcg_gen_st8_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
345{
346 tcg_gen_op3i(INDEX_op_st8_i32, arg1, arg2, offset);
347}
348
349static inline void tcg_gen_st16_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
350{
351 tcg_gen_op3i(INDEX_op_st16_i32, arg1, arg2, offset);
352}
353
354static inline void tcg_gen_st_i32(TCGv arg1, TCGv arg2, tcg_target_long offset)
355{
356 tcg_gen_op3i(INDEX_op_st_i32, arg1, arg2, offset);
357}
358
359static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2)
360{
361 tcg_gen_op3(INDEX_op_add_i32, ret, arg1, arg2);
362}
363
364static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2)
365{
366 /* some cases can be optimized here */
367 if (arg2 == 0) {
368 tcg_gen_mov_i32(ret, arg1);
369 } else {
370 TCGv t0 = tcg_const_i32(arg2);
371 tcg_gen_add_i32(ret, arg1, t0);
372 tcg_temp_free(t0);
373 }
374}
375
376static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2)
377{
378 tcg_gen_op3(INDEX_op_sub_i32, ret, arg1, arg2);
379}
380
381static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2)
382{
383 /* some cases can be optimized here */
384 if (arg2 == 0) {
385 tcg_gen_mov_i32(ret, arg1);
386 } else {
387 TCGv t0 = tcg_const_i32(arg2);
388 tcg_gen_sub_i32(ret, arg1, t0);
389 tcg_temp_free(t0);
390 }
391}
392
393static inline void tcg_gen_and_i32(TCGv ret, TCGv arg1, TCGv arg2)
394{
395 tcg_gen_op3(INDEX_op_and_i32, ret, arg1, arg2);
396}
397
398static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2)
399{
400 /* some cases can be optimized here */
401 if (arg2 == 0) {
402 tcg_gen_movi_i32(ret, 0);
403 } else if (arg2 == 0xffffffff) {
404 tcg_gen_mov_i32(ret, arg1);
405 } else {
406 TCGv t0 = tcg_const_i32(arg2);
407 tcg_gen_and_i32(ret, arg1, t0);
408 tcg_temp_free(t0);
409 }
410}
411
412static inline void tcg_gen_or_i32(TCGv ret, TCGv arg1, TCGv arg2)
413{
414 tcg_gen_op3(INDEX_op_or_i32, ret, arg1, arg2);
415}
416
417static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2)
418{
419 /* some cases can be optimized here */
420 if (arg2 == 0xffffffff) {
421 tcg_gen_movi_i32(ret, 0xffffffff);
422 } else if (arg2 == 0) {
423 tcg_gen_mov_i32(ret, arg1);
424 } else {
425 TCGv t0 = tcg_const_i32(arg2);
426 tcg_gen_or_i32(ret, arg1, t0);
427 tcg_temp_free(t0);
428 }
429}
430
431static inline void tcg_gen_xor_i32(TCGv ret, TCGv arg1, TCGv arg2)
432{
433 tcg_gen_op3(INDEX_op_xor_i32, ret, arg1, arg2);
434}
435
436static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2)
437{
438 /* some cases can be optimized here */
439 if (arg2 == 0) {
440 tcg_gen_mov_i32(ret, arg1);
441 } else {
442 TCGv t0 = tcg_const_i32(arg2);
443 tcg_gen_xor_i32(ret, arg1, t0);
444 tcg_temp_free(t0);
445 }
446}
447
448static inline void tcg_gen_shl_i32(TCGv ret, TCGv arg1, TCGv arg2)
449{
450 tcg_gen_op3(INDEX_op_shl_i32, ret, arg1, arg2);
451}
452
453static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2)
454{
455 if (arg2 == 0) {
456 tcg_gen_mov_i32(ret, arg1);
457 } else {
458 TCGv t0 = tcg_const_i32(arg2);
459 tcg_gen_shl_i32(ret, arg1, t0);
460 tcg_temp_free(t0);
461 }
462}
463
464static inline void tcg_gen_shr_i32(TCGv ret, TCGv arg1, TCGv arg2)
465{
466 tcg_gen_op3(INDEX_op_shr_i32, ret, arg1, arg2);
467}
468
469static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2)
470{
471 if (arg2 == 0) {
472 tcg_gen_mov_i32(ret, arg1);
473 } else {
474 TCGv t0 = tcg_const_i32(arg2);
475 tcg_gen_shr_i32(ret, arg1, t0);
476 tcg_temp_free(t0);
477 }
478}
479
480static inline void tcg_gen_sar_i32(TCGv ret, TCGv arg1, TCGv arg2)
481{
482 tcg_gen_op3(INDEX_op_sar_i32, ret, arg1, arg2);
483}
484
485static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2)
486{
487 if (arg2 == 0) {
488 tcg_gen_mov_i32(ret, arg1);
489 } else {
490 TCGv t0 = tcg_const_i32(arg2);
491 tcg_gen_sar_i32(ret, arg1, t0);
492 tcg_temp_free(t0);
493 }
494}
495
496static inline void tcg_gen_brcond_i32(int cond, TCGv arg1, TCGv arg2,
497 int label_index)
498{
499 tcg_gen_op4ii(INDEX_op_brcond_i32, arg1, arg2, cond, label_index);
500}
501
502static inline void tcg_gen_brcondi_i32(int cond, TCGv arg1, int32_t arg2,
503 int label_index)
504{
505 TCGv t0 = tcg_const_i32(arg2);
506 tcg_gen_brcond_i32(cond, arg1, t0, label_index);
507 tcg_temp_free(t0);
508}
509
510static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2)
511{
512 tcg_gen_op3(INDEX_op_mul_i32, ret, arg1, arg2);
513}
514
515static inline void tcg_gen_muli_i32(TCGv ret, TCGv arg1, int32_t arg2)
516{
517 TCGv t0 = tcg_const_i32(arg2);
518 tcg_gen_mul_i32(ret, arg1, t0);
519 tcg_temp_free(t0);
520}
521
522#ifdef TCG_TARGET_HAS_div_i32
523static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
524{
525 tcg_gen_op3(INDEX_op_div_i32, ret, arg1, arg2);
526}
527
528static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
529{
530 tcg_gen_op3(INDEX_op_rem_i32, ret, arg1, arg2);
531}
532
533static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
534{
535 tcg_gen_op3(INDEX_op_divu_i32, ret, arg1, arg2);
536}
537
538static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
539{
540 tcg_gen_op3(INDEX_op_remu_i32, ret, arg1, arg2);
541}
542#else
543static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2)
544{
545 TCGv t0;
546 t0 = tcg_temp_new(TCG_TYPE_I32);
547 tcg_gen_sari_i32(t0, arg1, 31);
548 tcg_gen_op5(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
549 tcg_temp_free(t0);
550}
551
552static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2)
553{
554 TCGv t0;
555 t0 = tcg_temp_new(TCG_TYPE_I32);
556 tcg_gen_sari_i32(t0, arg1, 31);
557 tcg_gen_op5(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2);
558 tcg_temp_free(t0);
559}
560
561static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2)
562{
563 TCGv t0;
564 t0 = tcg_temp_new(TCG_TYPE_I32);
565 tcg_gen_movi_i32(t0, 0);
566 tcg_gen_op5(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2);
567 tcg_temp_free(t0);
568}
569
570static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2)
571{
572 TCGv t0;
573 t0 = tcg_temp_new(TCG_TYPE_I32);
574 tcg_gen_movi_i32(t0, 0);
575 tcg_gen_op5(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2);
576 tcg_temp_free(t0);
577}
578#endif
579
580#if TCG_TARGET_REG_BITS == 32
581
582static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
583{
584 if (GET_TCGV(ret) != GET_TCGV(arg)) {
585 tcg_gen_mov_i32(ret, arg);
586 tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg));
587 }
588}
589
590static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
591{
592 tcg_gen_movi_i32(ret, arg);
593 tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32);
594}
595
596static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
597{
598 tcg_gen_ld8u_i32(ret, arg2, offset);
599 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
600}
601
602static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
603{
604 tcg_gen_ld8s_i32(ret, arg2, offset);
605 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
606}
607
608static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
609{
610 tcg_gen_ld16u_i32(ret, arg2, offset);
611 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
612}
613
614static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
615{
616 tcg_gen_ld16s_i32(ret, arg2, offset);
617 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
618}
619
620static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
621{
622 tcg_gen_ld_i32(ret, arg2, offset);
623 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
624}
625
626static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
627{
628 tcg_gen_ld_i32(ret, arg2, offset);
629 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
630}
631
632static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
633{
634 /* since arg2 and ret have different types, they cannot be the
635 same temporary */
636#ifdef TCG_TARGET_WORDS_BIGENDIAN
637 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset);
638 tcg_gen_ld_i32(ret, arg2, offset + 4);
639#else
640 tcg_gen_ld_i32(ret, arg2, offset);
641 tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4);
642#endif
643}
644
645static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
646{
647 tcg_gen_st8_i32(arg1, arg2, offset);
648}
649
650static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
651{
652 tcg_gen_st16_i32(arg1, arg2, offset);
653}
654
655static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
656{
657 tcg_gen_st_i32(arg1, arg2, offset);
658}
659
660static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
661{
662#ifdef TCG_TARGET_WORDS_BIGENDIAN
663 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset);
664 tcg_gen_st_i32(arg1, arg2, offset + 4);
665#else
666 tcg_gen_st_i32(arg1, arg2, offset);
667 tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4);
668#endif
669}
670
671static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
672{
673 tcg_gen_op6(INDEX_op_add2_i32, ret, TCGV_HIGH(ret),
674 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
675}
676
677static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
678{
679 TCGv t0 = tcg_const_i64(arg2);
680 tcg_gen_add_i64(ret, arg1, t0);
681 tcg_temp_free(t0);
682}
683
684static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
685{
686 tcg_gen_op6(INDEX_op_sub2_i32, ret, TCGV_HIGH(ret),
687 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2));
688}
689
690static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
691{
692 TCGv t0 = tcg_const_i64(arg2);
693 tcg_gen_sub_i64(ret, arg1, t0);
694 tcg_temp_free(t0);
695}
696
697static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
698{
699 tcg_gen_and_i32(ret, arg1, arg2);
700 tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
701}
702
703static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
704{
705 tcg_gen_andi_i32(ret, arg1, arg2);
706 tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
707}
708
709static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
710{
711 tcg_gen_or_i32(ret, arg1, arg2);
712 tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
713}
714
715static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
716{
717 tcg_gen_ori_i32(ret, arg1, arg2);
718 tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
719}
720
721static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
722{
723 tcg_gen_xor_i32(ret, arg1, arg2);
724 tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2));
725}
726
727static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
728{
729 tcg_gen_xori_i32(ret, arg1, arg2);
730 tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32);
731}
732
733/* XXX: use generic code when basic block handling is OK or CPU
734 specific code (x86) */
735static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
736{
737 tcg_gen_helper_1_2(tcg_helper_shl_i64, ret, arg1, arg2);
738}
739
740static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
741{
742 tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0);
743}
744
745static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
746{
747 tcg_gen_helper_1_2(tcg_helper_shr_i64, ret, arg1, arg2);
748}
749
750static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
751{
752 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0);
753}
754
755static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
756{
757 tcg_gen_helper_1_2(tcg_helper_sar_i64, ret, arg1, arg2);
758}
759
760static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
761{
762 tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1);
763}
764
765static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
766 int label_index)
767{
768 tcg_gen_op6ii(INDEX_op_brcond2_i32,
769 arg1, TCGV_HIGH(arg1), arg2, TCGV_HIGH(arg2),
770 cond, label_index);
771}
772
773static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
774{
775 TCGv t0, t1;
776
777 t0 = tcg_temp_new(TCG_TYPE_I64);
778 t1 = tcg_temp_new(TCG_TYPE_I32);
779
780 tcg_gen_op4(INDEX_op_mulu2_i32, t0, TCGV_HIGH(t0), arg1, arg2);
781
782 tcg_gen_mul_i32(t1, arg1, TCGV_HIGH(arg2));
783 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
784 tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), arg2);
785 tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1);
786
787 tcg_gen_mov_i64(ret, t0);
788 tcg_temp_free(t0);
789 tcg_temp_free(t1);
790}
791
792static inline void tcg_gen_muli_i64(TCGv ret, TCGv arg1, int64_t arg2)
793{
794 TCGv t0 = tcg_const_i64(arg2);
795 tcg_gen_mul_i64(ret, arg1, t0);
796 tcg_temp_free(t0);
797}
798
799static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
800{
801 tcg_gen_helper_1_2(tcg_helper_div_i64, ret, arg1, arg2);
802}
803
804static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
805{
806 tcg_gen_helper_1_2(tcg_helper_rem_i64, ret, arg1, arg2);
807}
808
809static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
810{
811 tcg_gen_helper_1_2(tcg_helper_divu_i64, ret, arg1, arg2);
812}
813
814static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
815{
816 tcg_gen_helper_1_2(tcg_helper_remu_i64, ret, arg1, arg2);
817}
818
819#else
820
821static inline void tcg_gen_mov_i64(TCGv ret, TCGv arg)
822{
823 if (GET_TCGV(ret) != GET_TCGV(arg))
824 tcg_gen_op2(INDEX_op_mov_i64, ret, arg);
825}
826
827static inline void tcg_gen_movi_i64(TCGv ret, int64_t arg)
828{
829 tcg_gen_op2i(INDEX_op_movi_i64, ret, arg);
830}
831
832static inline void tcg_gen_ld8u_i64(TCGv ret, TCGv arg2,
833 tcg_target_long offset)
834{
835 tcg_gen_op3i(INDEX_op_ld8u_i64, ret, arg2, offset);
836}
837
838static inline void tcg_gen_ld8s_i64(TCGv ret, TCGv arg2,
839 tcg_target_long offset)
840{
841 tcg_gen_op3i(INDEX_op_ld8s_i64, ret, arg2, offset);
842}
843
844static inline void tcg_gen_ld16u_i64(TCGv ret, TCGv arg2,
845 tcg_target_long offset)
846{
847 tcg_gen_op3i(INDEX_op_ld16u_i64, ret, arg2, offset);
848}
849
850static inline void tcg_gen_ld16s_i64(TCGv ret, TCGv arg2,
851 tcg_target_long offset)
852{
853 tcg_gen_op3i(INDEX_op_ld16s_i64, ret, arg2, offset);
854}
855
856static inline void tcg_gen_ld32u_i64(TCGv ret, TCGv arg2,
857 tcg_target_long offset)
858{
859 tcg_gen_op3i(INDEX_op_ld32u_i64, ret, arg2, offset);
860}
861
862static inline void tcg_gen_ld32s_i64(TCGv ret, TCGv arg2,
863 tcg_target_long offset)
864{
865 tcg_gen_op3i(INDEX_op_ld32s_i64, ret, arg2, offset);
866}
867
868static inline void tcg_gen_ld_i64(TCGv ret, TCGv arg2, tcg_target_long offset)
869{
870 tcg_gen_op3i(INDEX_op_ld_i64, ret, arg2, offset);
871}
872
873static inline void tcg_gen_st8_i64(TCGv arg1, TCGv arg2,
874 tcg_target_long offset)
875{
876 tcg_gen_op3i(INDEX_op_st8_i64, arg1, arg2, offset);
877}
878
879static inline void tcg_gen_st16_i64(TCGv arg1, TCGv arg2,
880 tcg_target_long offset)
881{
882 tcg_gen_op3i(INDEX_op_st16_i64, arg1, arg2, offset);
883}
884
885static inline void tcg_gen_st32_i64(TCGv arg1, TCGv arg2,
886 tcg_target_long offset)
887{
888 tcg_gen_op3i(INDEX_op_st32_i64, arg1, arg2, offset);
889}
890
891static inline void tcg_gen_st_i64(TCGv arg1, TCGv arg2, tcg_target_long offset)
892{
893 tcg_gen_op3i(INDEX_op_st_i64, arg1, arg2, offset);
894}
895
896static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2)
897{
898 tcg_gen_op3(INDEX_op_add_i64, ret, arg1, arg2);
899}
900
901static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2)
902{
903 TCGv t0 = tcg_const_i64(arg2);
904 tcg_gen_add_i64(ret, arg1, t0);
905 tcg_temp_free(t0);
906}
907
908static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2)
909{
910 tcg_gen_op3(INDEX_op_sub_i64, ret, arg1, arg2);
911}
912
913static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2)
914{
915 TCGv t0 = tcg_const_i64(arg2);
916 tcg_gen_sub_i64(ret, arg1, t0);
917 tcg_temp_free(t0);
918}
919
920static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2)
921{
922 tcg_gen_op3(INDEX_op_and_i64, ret, arg1, arg2);
923}
924
925static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2)
926{
927 TCGv t0 = tcg_const_i64(arg2);
928 tcg_gen_and_i64(ret, arg1, t0);
929 tcg_temp_free(t0);
930}
931
932static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2)
933{
934 tcg_gen_op3(INDEX_op_or_i64, ret, arg1, arg2);
935}
936
937static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2)
938{
939 TCGv t0 = tcg_const_i64(arg2);
940 tcg_gen_or_i64(ret, arg1, t0);
941 tcg_temp_free(t0);
942}
943
944static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2)
945{
946 tcg_gen_op3(INDEX_op_xor_i64, ret, arg1, arg2);
947}
948
949static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2)
950{
951 TCGv t0 = tcg_const_i64(arg2);
952 tcg_gen_xor_i64(ret, arg1, t0);
953 tcg_temp_free(t0);
954}
955
956static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2)
957{
958 tcg_gen_op3(INDEX_op_shl_i64, ret, arg1, arg2);
959}
960
961static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2)
962{
963 if (arg2 == 0) {
964 tcg_gen_mov_i64(ret, arg1);
965 } else {
966 TCGv t0 = tcg_const_i64(arg2);
967 tcg_gen_shl_i64(ret, arg1, t0);
968 tcg_temp_free(t0);
969 }
970}
971
972static inline void tcg_gen_shr_i64(TCGv ret, TCGv arg1, TCGv arg2)
973{
974 tcg_gen_op3(INDEX_op_shr_i64, ret, arg1, arg2);
975}
976
977static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2)
978{
979 if (arg2 == 0) {
980 tcg_gen_mov_i64(ret, arg1);
981 } else {
982 TCGv t0 = tcg_const_i64(arg2);
983 tcg_gen_shr_i64(ret, arg1, t0);
984 tcg_temp_free(t0);
985 }
986}
987
988static inline void tcg_gen_sar_i64(TCGv ret, TCGv arg1, TCGv arg2)
989{
990 tcg_gen_op3(INDEX_op_sar_i64, ret, arg1, arg2);
991}
992
993static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2)
994{
995 if (arg2 == 0) {
996 tcg_gen_mov_i64(ret, arg1);
997 } else {
998 TCGv t0 = tcg_const_i64(arg2);
999 tcg_gen_sar_i64(ret, arg1, t0);
1000 tcg_temp_free(t0);
1001 }
1002}
1003
1004static inline void tcg_gen_brcond_i64(int cond, TCGv arg1, TCGv arg2,
1005 int label_index)
1006{
1007 tcg_gen_op4ii(INDEX_op_brcond_i64, arg1, arg2, cond, label_index);
1008}
1009
1010static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2)
1011{
1012 tcg_gen_op3(INDEX_op_mul_i64, ret, arg1, arg2);
1013}
1014
1015static inline void tcg_gen_muli_i64(TCGv ret, TCGv arg1, int64_t arg2)
1016{
1017 TCGv t0 = tcg_const_i64(arg2);
1018 tcg_gen_mul_i64(ret, arg1, t0);
1019 tcg_temp_free(t0);
1020}
1021
1022#ifdef TCG_TARGET_HAS_div_i64
1023static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
1024{
1025 tcg_gen_op3(INDEX_op_div_i64, ret, arg1, arg2);
1026}
1027
1028static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
1029{
1030 tcg_gen_op3(INDEX_op_rem_i64, ret, arg1, arg2);
1031}
1032
1033static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
1034{
1035 tcg_gen_op3(INDEX_op_divu_i64, ret, arg1, arg2);
1036}
1037
1038static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
1039{
1040 tcg_gen_op3(INDEX_op_remu_i64, ret, arg1, arg2);
1041}
1042#else
1043static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2)
1044{
1045 TCGv t0;
1046 t0 = tcg_temp_new(TCG_TYPE_I64);
1047 tcg_gen_sari_i64(t0, arg1, 63);
1048 tcg_gen_op5(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2);
1049 tcg_temp_free(t0);
1050}
1051
1052static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2)
1053{
1054 TCGv t0;
1055 t0 = tcg_temp_new(TCG_TYPE_I64);
1056 tcg_gen_sari_i64(t0, arg1, 63);
1057 tcg_gen_op5(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2);
1058 tcg_temp_free(t0);
1059}
1060
1061static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2)
1062{
1063 TCGv t0;
1064 t0 = tcg_temp_new(TCG_TYPE_I64);
1065 tcg_gen_movi_i64(t0, 0);
1066 tcg_gen_op5(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2);
1067 tcg_temp_free(t0);
1068}
1069
1070static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2)
1071{
1072 TCGv t0;
1073 t0 = tcg_temp_new(TCG_TYPE_I64);
1074 tcg_gen_movi_i64(t0, 0);
1075 tcg_gen_op5(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2);
1076 tcg_temp_free(t0);
1077}
1078#endif
1079
1080#endif
1081
1082static inline void tcg_gen_brcondi_i64(int cond, TCGv arg1, int64_t arg2,
1083 int label_index)
1084{
1085 TCGv t0 = tcg_const_i64(arg2);
1086 tcg_gen_brcond_i64(cond, arg1, t0, label_index);
1087 tcg_temp_free(t0);
1088}
1089
1090/***************************************/
1091/* optional operations */
1092
1093static inline void tcg_gen_ext8s_i32(TCGv ret, TCGv arg)
1094{
1095#ifdef TCG_TARGET_HAS_ext8s_i32
1096 tcg_gen_op2(INDEX_op_ext8s_i32, ret, arg);
1097#else
1098 tcg_gen_shli_i32(ret, arg, 24);
1099 tcg_gen_sari_i32(ret, ret, 24);
1100#endif
1101}
1102
1103static inline void tcg_gen_ext16s_i32(TCGv ret, TCGv arg)
1104{
1105#ifdef TCG_TARGET_HAS_ext16s_i32
1106 tcg_gen_op2(INDEX_op_ext16s_i32, ret, arg);
1107#else
1108 tcg_gen_shli_i32(ret, arg, 16);
1109 tcg_gen_sari_i32(ret, ret, 16);
1110#endif
1111}
1112
1113/* These are currently just for convenience.
1114 We assume a target will recognise these automatically . */
1115static inline void tcg_gen_ext8u_i32(TCGv ret, TCGv arg)
1116{
1117 tcg_gen_andi_i32(ret, arg, 0xffu);
1118}
1119
1120static inline void tcg_gen_ext16u_i32(TCGv ret, TCGv arg)
1121{
1122 tcg_gen_andi_i32(ret, arg, 0xffffu);
1123}
1124
1125/* Note: we assume the two high bytes are set to zero */
1126static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg)
1127{
1128#ifdef TCG_TARGET_HAS_bswap16_i32
1129 tcg_gen_op2(INDEX_op_bswap16_i32, ret, arg);
1130#else
1131 TCGv t0, t1;
1132 t0 = tcg_temp_new(TCG_TYPE_I32);
1133 t1 = tcg_temp_new(TCG_TYPE_I32);
1134
1135 tcg_gen_shri_i32(t0, arg, 8);
1136 tcg_gen_andi_i32(t1, arg, 0x000000ff);
1137 tcg_gen_shli_i32(t1, t1, 8);
1138 tcg_gen_or_i32(ret, t0, t1);
1139 tcg_temp_free(t0);
1140 tcg_temp_free(t1);
1141#endif
1142}
1143
1144static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg)
1145{
1146#ifdef TCG_TARGET_HAS_bswap_i32
1147 tcg_gen_op2(INDEX_op_bswap_i32, ret, arg);
1148#else
1149 TCGv t0, t1;
1150 t0 = tcg_temp_new(TCG_TYPE_I32);
1151 t1 = tcg_temp_new(TCG_TYPE_I32);
1152
1153 tcg_gen_shli_i32(t0, arg, 24);
1154
1155 tcg_gen_andi_i32(t1, arg, 0x0000ff00);
1156 tcg_gen_shli_i32(t1, t1, 8);
1157 tcg_gen_or_i32(t0, t0, t1);
1158
1159 tcg_gen_shri_i32(t1, arg, 8);
1160 tcg_gen_andi_i32(t1, t1, 0x0000ff00);
1161 tcg_gen_or_i32(t0, t0, t1);
1162
1163 tcg_gen_shri_i32(t1, arg, 24);
1164 tcg_gen_or_i32(ret, t0, t1);
1165 tcg_temp_free(t0);
1166 tcg_temp_free(t1);
1167#endif
1168}
1169
1170#if TCG_TARGET_REG_BITS == 32
1171static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
1172{
1173 tcg_gen_ext8s_i32(ret, arg);
1174 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1175}
1176
1177static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
1178{
1179 tcg_gen_ext16s_i32(ret, arg);
1180 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1181}
1182
1183static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
1184{
1185 tcg_gen_mov_i32(ret, arg);
1186 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1187}
1188
1189static inline void tcg_gen_ext8u_i64(TCGv ret, TCGv arg)
1190{
1191 tcg_gen_ext8u_i32(ret, arg);
1192 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1193}
1194
1195static inline void tcg_gen_ext16u_i64(TCGv ret, TCGv arg)
1196{
1197 tcg_gen_ext16u_i32(ret, arg);
1198 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1199}
1200
1201static inline void tcg_gen_ext32u_i64(TCGv ret, TCGv arg)
1202{
1203 tcg_gen_mov_i32(ret, arg);
1204 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1205}
1206
1207static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
1208{
1209 tcg_gen_mov_i32(ret, arg);
1210}
1211
1212static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
1213{
1214 tcg_gen_mov_i32(ret, arg);
1215 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1216}
1217
1218static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
1219{
1220 tcg_gen_mov_i32(ret, arg);
1221 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1222}
1223
1224static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
1225{
1226 TCGv t0, t1;
1227 t0 = tcg_temp_new(TCG_TYPE_I32);
1228 t1 = tcg_temp_new(TCG_TYPE_I32);
1229
1230 tcg_gen_bswap_i32(t0, arg);
1231 tcg_gen_bswap_i32(t1, TCGV_HIGH(arg));
1232 tcg_gen_mov_i32(ret, t1);
1233 tcg_gen_mov_i32(TCGV_HIGH(ret), t0);
1234 tcg_temp_free(t0);
1235 tcg_temp_free(t1);
1236}
1237#else
1238
1239static inline void tcg_gen_ext8s_i64(TCGv ret, TCGv arg)
1240{
1241#ifdef TCG_TARGET_HAS_ext8s_i64
1242 tcg_gen_op2(INDEX_op_ext8s_i64, ret, arg);
1243#else
1244 tcg_gen_shli_i64(ret, arg, 56);
1245 tcg_gen_sari_i64(ret, ret, 56);
1246#endif
1247}
1248
1249static inline void tcg_gen_ext16s_i64(TCGv ret, TCGv arg)
1250{
1251#ifdef TCG_TARGET_HAS_ext16s_i64
1252 tcg_gen_op2(INDEX_op_ext16s_i64, ret, arg);
1253#else
1254 tcg_gen_shli_i64(ret, arg, 48);
1255 tcg_gen_sari_i64(ret, ret, 48);
1256#endif
1257}
1258
1259static inline void tcg_gen_ext32s_i64(TCGv ret, TCGv arg)
1260{
1261#ifdef TCG_TARGET_HAS_ext32s_i64
1262 tcg_gen_op2(INDEX_op_ext32s_i64, ret, arg);
1263#else
1264 tcg_gen_shli_i64(ret, arg, 32);
1265 tcg_gen_sari_i64(ret, ret, 32);
1266#endif
1267}
1268
1269static inline void tcg_gen_ext8u_i64(TCGv ret, TCGv arg)
1270{
1271 tcg_gen_andi_i64(ret, arg, 0xffu);
1272}
1273
1274static inline void tcg_gen_ext16u_i64(TCGv ret, TCGv arg)
1275{
1276 tcg_gen_andi_i64(ret, arg, 0xffffu);
1277}
1278
1279static inline void tcg_gen_ext32u_i64(TCGv ret, TCGv arg)
1280{
1281 tcg_gen_andi_i64(ret, arg, 0xffffffffu);
1282}
1283
1284/* Note: we assume the target supports move between 32 and 64 bit
1285 registers. This will probably break MIPS64 targets. */
1286static inline void tcg_gen_trunc_i64_i32(TCGv ret, TCGv arg)
1287{
1288 tcg_gen_mov_i32(ret, arg);
1289}
1290
1291/* Note: we assume the target supports move between 32 and 64 bit
1292 registers */
1293static inline void tcg_gen_extu_i32_i64(TCGv ret, TCGv arg)
1294{
1295 tcg_gen_andi_i64(ret, arg, 0xffffffffu);
1296}
1297
1298/* Note: we assume the target supports move between 32 and 64 bit
1299 registers */
1300static inline void tcg_gen_ext_i32_i64(TCGv ret, TCGv arg)
1301{
1302 tcg_gen_ext32s_i64(ret, arg);
1303}
1304
1305static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg)
1306{
1307#ifdef TCG_TARGET_HAS_bswap_i64
1308 tcg_gen_op2(INDEX_op_bswap_i64, ret, arg);
1309#else
1310 TCGv t0, t1;
1311 t0 = tcg_temp_new(TCG_TYPE_I32);
1312 t1 = tcg_temp_new(TCG_TYPE_I32);
1313
1314 tcg_gen_shli_i64(t0, arg, 56);
1315
1316 tcg_gen_andi_i64(t1, arg, 0x0000ff00);
1317 tcg_gen_shli_i64(t1, t1, 40);
1318 tcg_gen_or_i64(t0, t0, t1);
1319
1320 tcg_gen_andi_i64(t1, arg, 0x00ff0000);
1321 tcg_gen_shli_i64(t1, t1, 24);
1322 tcg_gen_or_i64(t0, t0, t1);
1323
1324 tcg_gen_andi_i64(t1, arg, 0xff000000);
1325 tcg_gen_shli_i64(t1, t1, 8);
1326 tcg_gen_or_i64(t0, t0, t1);
1327
1328 tcg_gen_shri_i64(t1, arg, 8);
1329 tcg_gen_andi_i64(t1, t1, 0xff000000);
1330 tcg_gen_or_i64(t0, t0, t1);
1331
1332 tcg_gen_shri_i64(t1, arg, 24);
1333 tcg_gen_andi_i64(t1, t1, 0x00ff0000);
1334 tcg_gen_or_i64(t0, t0, t1);
1335
1336 tcg_gen_shri_i64(t1, arg, 40);
1337 tcg_gen_andi_i64(t1, t1, 0x0000ff00);
1338 tcg_gen_or_i64(t0, t0, t1);
1339
1340 tcg_gen_shri_i64(t1, arg, 56);
1341 tcg_gen_or_i64(ret, t0, t1);
1342 tcg_temp_free(t0);
1343 tcg_temp_free(t1);
1344#endif
1345}
1346
1347#endif
1348
1349static inline void tcg_gen_neg_i32(TCGv ret, TCGv arg)
1350{
1351#ifdef TCG_TARGET_HAS_neg_i32
1352 tcg_gen_op2(INDEX_op_neg_i32, ret, arg);
1353#else
1354 TCGv t0 = tcg_const_i32(0);
1355 tcg_gen_sub_i32(ret, t0, arg);
1356 tcg_temp_free(t0);
1357#endif
1358}
1359
1360static inline void tcg_gen_neg_i64(TCGv ret, TCGv arg)
1361{
1362#ifdef TCG_TARGET_HAS_neg_i64
1363 tcg_gen_op2(INDEX_op_neg_i64, ret, arg);
1364#else
1365 TCGv t0 = tcg_const_i64(0);
1366 tcg_gen_sub_i64(ret, t0, arg);
1367 tcg_temp_free(t0);
1368#endif
1369}
1370
1371static inline void tcg_gen_not_i32(TCGv ret, TCGv arg)
1372{
1373 tcg_gen_xori_i32(ret, arg, -1);
1374}
1375
1376static inline void tcg_gen_not_i64(TCGv ret, TCGv arg)
1377{
1378 tcg_gen_xori_i64(ret, arg, -1);
1379}
1380
1381static inline void tcg_gen_discard_i32(TCGv arg)
1382{
1383 tcg_gen_op1(INDEX_op_discard, arg);
1384}
1385
1386#if TCG_TARGET_REG_BITS == 32
1387static inline void tcg_gen_discard_i64(TCGv arg)
1388{
1389 tcg_gen_discard_i32(arg);
1390 tcg_gen_discard_i32(TCGV_HIGH(arg));
1391}
1392#else
1393static inline void tcg_gen_discard_i64(TCGv arg)
1394{
1395 tcg_gen_op1(INDEX_op_discard, arg);
1396}
1397#endif
1398
1399static inline void tcg_gen_concat_i32_i64(TCGv dest, TCGv low, TCGv high)
1400{
1401#if TCG_TARGET_REG_BITS == 32
1402 tcg_gen_mov_i32(dest, low);
1403 tcg_gen_mov_i32(TCGV_HIGH(dest), high);
1404#else
1405 TCGv tmp = tcg_temp_new (TCG_TYPE_I64);
1406 /* This extension is only needed for type correctness.
1407 We may be able to do better given target specific information. */
1408 tcg_gen_extu_i32_i64(tmp, high);
1409 tcg_gen_shli_i64(tmp, tmp, 32);
1410 tcg_gen_extu_i32_i64(dest, low);
1411 tcg_gen_or_i64(dest, dest, tmp);
1412 tcg_temp_free(tmp);
1413#endif
1414}
1415
1416static inline void tcg_gen_concat32_i64(TCGv dest, TCGv low, TCGv high)
1417{
1418#if TCG_TARGET_REG_BITS == 32
1419 tcg_gen_concat_i32_i64(dest, low, high);
1420#else
1421 TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
1422 tcg_gen_ext32u_i64(dest, low);
1423 tcg_gen_shli_i64(tmp, high, 32);
1424 tcg_gen_or_i64(dest, dest, tmp);
1425 tcg_temp_free(tmp);
1426#endif
1427}
1428
1429/***************************************/
1430/* QEMU specific operations. Their type depend on the QEMU CPU
1431 type. */
1432#ifndef TARGET_LONG_BITS
1433#error must include QEMU headers
1434#endif
1435
1436/* debug info: write the PC of the corresponding QEMU CPU instruction */
1437static inline void tcg_gen_debug_insn_start(uint64_t pc)
1438{
1439 /* XXX: must really use a 32 bit size for TCGArg in all cases */
1440#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
1441 tcg_gen_op2ii(INDEX_op_debug_insn_start,
1442 (uint32_t)(pc), (uint32_t)(pc >> 32));
1443#else
1444 tcg_gen_op1i(INDEX_op_debug_insn_start, pc);
1445#endif
1446}
1447
1448static inline void tcg_gen_exit_tb(tcg_target_long val)
1449{
1450 tcg_gen_op1i(INDEX_op_exit_tb, val);
1451}
1452
1453static inline void tcg_gen_goto_tb(int idx)
1454{
1455 tcg_gen_op1i(INDEX_op_goto_tb, idx);
1456}
1457
1458#if TCG_TARGET_REG_BITS == 32
1459static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
1460{
1461#if TARGET_LONG_BITS == 32
1462 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
1463#else
1464 tcg_gen_op4i(INDEX_op_qemu_ld8u, ret, addr, TCGV_HIGH(addr), mem_index);
1465 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1466#endif
1467}
1468
1469static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
1470{
1471#if TARGET_LONG_BITS == 32
1472 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
1473#else
1474 tcg_gen_op4i(INDEX_op_qemu_ld8s, ret, addr, TCGV_HIGH(addr), mem_index);
1475 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1476#endif
1477}
1478
1479static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
1480{
1481#if TARGET_LONG_BITS == 32
1482 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
1483#else
1484 tcg_gen_op4i(INDEX_op_qemu_ld16u, ret, addr, TCGV_HIGH(addr), mem_index);
1485 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1486#endif
1487}
1488
1489static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
1490{
1491#if TARGET_LONG_BITS == 32
1492 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
1493#else
1494 tcg_gen_op4i(INDEX_op_qemu_ld16s, ret, addr, TCGV_HIGH(addr), mem_index);
1495 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1496#endif
1497}
1498
1499static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
1500{
1501#if TARGET_LONG_BITS == 32
1502 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1503#else
1504 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1505 tcg_gen_movi_i32(TCGV_HIGH(ret), 0);
1506#endif
1507}
1508
1509static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
1510{
1511#if TARGET_LONG_BITS == 32
1512 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1513#else
1514 tcg_gen_op4i(INDEX_op_qemu_ld32u, ret, addr, TCGV_HIGH(addr), mem_index);
1515 tcg_gen_sari_i32(TCGV_HIGH(ret), ret, 31);
1516#endif
1517}
1518
1519static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
1520{
1521#if TARGET_LONG_BITS == 32
1522 tcg_gen_op4i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret), addr, mem_index);
1523#else
1524 tcg_gen_op5i(INDEX_op_qemu_ld64, ret, TCGV_HIGH(ret),
1525 addr, TCGV_HIGH(addr), mem_index);
1526#endif
1527}
1528
1529static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
1530{
1531#if TARGET_LONG_BITS == 32
1532 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
1533#else
1534 tcg_gen_op4i(INDEX_op_qemu_st8, arg, addr, TCGV_HIGH(addr), mem_index);
1535#endif
1536}
1537
1538static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
1539{
1540#if TARGET_LONG_BITS == 32
1541 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
1542#else
1543 tcg_gen_op4i(INDEX_op_qemu_st16, arg, addr, TCGV_HIGH(addr), mem_index);
1544#endif
1545}
1546
1547static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
1548{
1549#if TARGET_LONG_BITS == 32
1550 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
1551#else
1552 tcg_gen_op4i(INDEX_op_qemu_st32, arg, addr, TCGV_HIGH(addr), mem_index);
1553#endif
1554}
1555
1556static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
1557{
1558#if TARGET_LONG_BITS == 32
1559 tcg_gen_op4i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg), addr, mem_index);
1560#else
1561 tcg_gen_op5i(INDEX_op_qemu_st64, arg, TCGV_HIGH(arg),
1562 addr, TCGV_HIGH(addr), mem_index);
1563#endif
1564}
1565
1566#define tcg_gen_ld_ptr tcg_gen_ld_i32
1567#define tcg_gen_discard_ptr tcg_gen_discard_i32
1568
1569#else /* TCG_TARGET_REG_BITS == 32 */
1570
1571static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
1572{
1573 tcg_gen_op3i(INDEX_op_qemu_ld8u, ret, addr, mem_index);
1574}
1575
1576static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
1577{
1578 tcg_gen_op3i(INDEX_op_qemu_ld8s, ret, addr, mem_index);
1579}
1580
1581static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
1582{
1583 tcg_gen_op3i(INDEX_op_qemu_ld16u, ret, addr, mem_index);
1584}
1585
1586static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
1587{
1588 tcg_gen_op3i(INDEX_op_qemu_ld16s, ret, addr, mem_index);
1589}
1590
1591static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
1592{
1593 tcg_gen_op3i(INDEX_op_qemu_ld32u, ret, addr, mem_index);
1594}
1595
1596static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
1597{
1598 tcg_gen_op3i(INDEX_op_qemu_ld32s, ret, addr, mem_index);
1599}
1600
1601static inline void tcg_gen_qemu_ld64(TCGv ret, TCGv addr, int mem_index)
1602{
1603 tcg_gen_op3i(INDEX_op_qemu_ld64, ret, addr, mem_index);
1604}
1605
1606static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
1607{
1608 tcg_gen_op3i(INDEX_op_qemu_st8, arg, addr, mem_index);
1609}
1610
1611static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
1612{
1613 tcg_gen_op3i(INDEX_op_qemu_st16, arg, addr, mem_index);
1614}
1615
1616static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
1617{
1618 tcg_gen_op3i(INDEX_op_qemu_st32, arg, addr, mem_index);
1619}
1620
1621static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
1622{
1623 tcg_gen_op3i(INDEX_op_qemu_st64, arg, addr, mem_index);
1624}
1625
1626#define tcg_gen_ld_ptr tcg_gen_ld_i64
1627#define tcg_gen_discard_ptr tcg_gen_discard_i64
1628
1629#endif /* TCG_TARGET_REG_BITS != 32 */
1630
1631#if TARGET_LONG_BITS == 64
1632#define TCG_TYPE_TL TCG_TYPE_I64
1633#define tcg_gen_movi_tl tcg_gen_movi_i64
1634#define tcg_gen_mov_tl tcg_gen_mov_i64
1635#define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
1636#define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
1637#define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
1638#define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
1639#define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
1640#define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
1641#define tcg_gen_ld_tl tcg_gen_ld_i64
1642#define tcg_gen_st8_tl tcg_gen_st8_i64
1643#define tcg_gen_st16_tl tcg_gen_st16_i64
1644#define tcg_gen_st32_tl tcg_gen_st32_i64
1645#define tcg_gen_st_tl tcg_gen_st_i64
1646#define tcg_gen_add_tl tcg_gen_add_i64
1647#define tcg_gen_addi_tl tcg_gen_addi_i64
1648#define tcg_gen_sub_tl tcg_gen_sub_i64
1649#define tcg_gen_neg_tl tcg_gen_neg_i64
1650#define tcg_gen_subi_tl tcg_gen_subi_i64
1651#define tcg_gen_and_tl tcg_gen_and_i64
1652#define tcg_gen_andi_tl tcg_gen_andi_i64
1653#define tcg_gen_or_tl tcg_gen_or_i64
1654#define tcg_gen_ori_tl tcg_gen_ori_i64
1655#define tcg_gen_xor_tl tcg_gen_xor_i64
1656#define tcg_gen_xori_tl tcg_gen_xori_i64
1657#define tcg_gen_not_tl tcg_gen_not_i64
1658#define tcg_gen_shl_tl tcg_gen_shl_i64
1659#define tcg_gen_shli_tl tcg_gen_shli_i64
1660#define tcg_gen_shr_tl tcg_gen_shr_i64
1661#define tcg_gen_shri_tl tcg_gen_shri_i64
1662#define tcg_gen_sar_tl tcg_gen_sar_i64
1663#define tcg_gen_sari_tl tcg_gen_sari_i64
1664#define tcg_gen_brcond_tl tcg_gen_brcond_i64
1665#define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
1666#define tcg_gen_mul_tl tcg_gen_mul_i64
1667#define tcg_gen_muli_tl tcg_gen_muli_i64
1668#define tcg_gen_discard_tl tcg_gen_discard_i64
1669#define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32
1670#define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
1671#define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
1672#define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
1673#define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
1674#define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
1675#define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
1676#define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
1677#define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
1678#define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
1679#define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
1680#define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
1681#define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
1682#define tcg_const_tl tcg_const_i64
1683#else
1684#define TCG_TYPE_TL TCG_TYPE_I32
1685#define tcg_gen_movi_tl tcg_gen_movi_i32
1686#define tcg_gen_mov_tl tcg_gen_mov_i32
1687#define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
1688#define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
1689#define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
1690#define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
1691#define tcg_gen_ld32u_tl tcg_gen_ld_i32
1692#define tcg_gen_ld32s_tl tcg_gen_ld_i32
1693#define tcg_gen_ld_tl tcg_gen_ld_i32
1694#define tcg_gen_st8_tl tcg_gen_st8_i32
1695#define tcg_gen_st16_tl tcg_gen_st16_i32
1696#define tcg_gen_st32_tl tcg_gen_st_i32
1697#define tcg_gen_st_tl tcg_gen_st_i32
1698#define tcg_gen_add_tl tcg_gen_add_i32
1699#define tcg_gen_addi_tl tcg_gen_addi_i32
1700#define tcg_gen_sub_tl tcg_gen_sub_i32
1701#define tcg_gen_neg_tl tcg_gen_neg_i32
1702#define tcg_gen_subi_tl tcg_gen_subi_i32
1703#define tcg_gen_and_tl tcg_gen_and_i32
1704#define tcg_gen_andi_tl tcg_gen_andi_i32
1705#define tcg_gen_or_tl tcg_gen_or_i32
1706#define tcg_gen_ori_tl tcg_gen_ori_i32
1707#define tcg_gen_xor_tl tcg_gen_xor_i32
1708#define tcg_gen_xori_tl tcg_gen_xori_i32
1709#define tcg_gen_not_tl tcg_gen_not_i32
1710#define tcg_gen_shl_tl tcg_gen_shl_i32
1711#define tcg_gen_shli_tl tcg_gen_shli_i32
1712#define tcg_gen_shr_tl tcg_gen_shr_i32
1713#define tcg_gen_shri_tl tcg_gen_shri_i32
1714#define tcg_gen_sar_tl tcg_gen_sar_i32
1715#define tcg_gen_sari_tl tcg_gen_sari_i32
1716#define tcg_gen_brcond_tl tcg_gen_brcond_i32
1717#define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
1718#define tcg_gen_mul_tl tcg_gen_mul_i32
1719#define tcg_gen_muli_tl tcg_gen_muli_i32
1720#define tcg_gen_discard_tl tcg_gen_discard_i32
1721#define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
1722#define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32
1723#define tcg_gen_extu_i32_tl tcg_gen_mov_i32
1724#define tcg_gen_ext_i32_tl tcg_gen_mov_i32
1725#define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
1726#define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
1727#define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
1728#define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
1729#define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
1730#define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
1731#define tcg_gen_ext32u_tl tcg_gen_mov_i32
1732#define tcg_gen_ext32s_tl tcg_gen_mov_i32
1733#define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
1734#define tcg_const_tl tcg_const_i32
1735#endif
1736
1737#if TCG_TARGET_REG_BITS == 32
1738#define tcg_gen_add_ptr tcg_gen_add_i32
1739#define tcg_gen_addi_ptr tcg_gen_addi_i32
1740#define tcg_gen_ext_i32_ptr tcg_gen_mov_i32
1741#else /* TCG_TARGET_REG_BITS == 32 */
1742#define tcg_gen_add_ptr tcg_gen_add_i64
1743#define tcg_gen_addi_ptr tcg_gen_addi_i64
1744#define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64
1745#endif /* TCG_TARGET_REG_BITS != 32 */
1746
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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