2 * Tiny Code Generator for QEMU
4 * Copyright (c) 2009-2010 Aurelien Jarno <aurelien@aurel32.net>
5 * Based on i386/tcg-target.c - Copyright (c) 2008 Fabrice Bellard
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 #include "tcg-be-null.h"
29 * Register definitions
33 static const char * const tcg_target_reg_names
[TCG_TARGET_NB_REGS
] = {
34 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
35 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
36 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
37 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
38 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39",
39 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47",
40 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55",
41 "r56", "r57", "r58", "r59", "r60", "r61", "r62", "r63",
45 #ifdef CONFIG_USE_GUEST_BASE
46 #define TCG_GUEST_BASE_REG TCG_REG_R55
48 #define TCG_GUEST_BASE_REG TCG_REG_R0
54 /* Branch registers */
66 /* Floating point registers */
86 /* Predicate registers */
106 /* Application registers */
111 static const int tcg_target_reg_alloc_order
[] = {
165 static const int tcg_target_call_iarg_regs
[8] = {
176 static const int tcg_target_call_oarg_regs
[] = {
184 /* bundle templates: stops (double bar in the IA64 manual) are marked with
185 an uppercase letter. */
214 OPC_ADD_A1
= 0x10000000000ull
,
215 OPC_AND_A1
= 0x10060000000ull
,
216 OPC_AND_A3
= 0x10160000000ull
,
217 OPC_ANDCM_A1
= 0x10068000000ull
,
218 OPC_ANDCM_A3
= 0x10168000000ull
,
219 OPC_ADDS_A4
= 0x10800000000ull
,
220 OPC_ADDL_A5
= 0x12000000000ull
,
221 OPC_ALLOC_M34
= 0x02c00000000ull
,
222 OPC_BR_DPTK_FEW_B1
= 0x08400000000ull
,
223 OPC_BR_SPTK_MANY_B1
= 0x08000001000ull
,
224 OPC_BR_SPTK_MANY_B4
= 0x00100001000ull
,
225 OPC_BR_CALL_SPTK_MANY_B5
= 0x02100001000ull
,
226 OPC_BR_RET_SPTK_MANY_B4
= 0x00108001100ull
,
227 OPC_BRL_SPTK_MANY_X3
= 0x18000001000ull
,
228 OPC_BRL_CALL_SPTK_MANY_X4
= 0x1a000001000ull
,
229 OPC_CMP_LT_A6
= 0x18000000000ull
,
230 OPC_CMP_LTU_A6
= 0x1a000000000ull
,
231 OPC_CMP_EQ_A6
= 0x1c000000000ull
,
232 OPC_CMP4_LT_A6
= 0x18400000000ull
,
233 OPC_CMP4_LTU_A6
= 0x1a400000000ull
,
234 OPC_CMP4_EQ_A6
= 0x1c400000000ull
,
235 OPC_DEP_I14
= 0x0ae00000000ull
,
236 OPC_DEP_I15
= 0x08000000000ull
,
237 OPC_DEP_Z_I12
= 0x0a600000000ull
,
238 OPC_EXTR_I11
= 0x0a400002000ull
,
239 OPC_EXTR_U_I11
= 0x0a400000000ull
,
240 OPC_FCVT_FX_TRUNC_S1_F10
= 0x004d0000000ull
,
241 OPC_FCVT_FXU_TRUNC_S1_F10
= 0x004d8000000ull
,
242 OPC_FCVT_XF_F11
= 0x000e0000000ull
,
243 OPC_FMA_S1_F1
= 0x10400000000ull
,
244 OPC_FNMA_S1_F1
= 0x18400000000ull
,
245 OPC_FRCPA_S1_F6
= 0x00600000000ull
,
246 OPC_GETF_SIG_M19
= 0x08708000000ull
,
247 OPC_LD1_M1
= 0x08000000000ull
,
248 OPC_LD1_M3
= 0x0a000000000ull
,
249 OPC_LD2_M1
= 0x08040000000ull
,
250 OPC_LD2_M3
= 0x0a040000000ull
,
251 OPC_LD4_M1
= 0x08080000000ull
,
252 OPC_LD4_M3
= 0x0a080000000ull
,
253 OPC_LD8_M1
= 0x080c0000000ull
,
254 OPC_LD8_M3
= 0x0a0c0000000ull
,
255 OPC_MUX1_I3
= 0x0eca0000000ull
,
256 OPC_NOP_B9
= 0x04008000000ull
,
257 OPC_NOP_F16
= 0x00008000000ull
,
258 OPC_NOP_I18
= 0x00008000000ull
,
259 OPC_NOP_M48
= 0x00008000000ull
,
260 OPC_MOV_I21
= 0x00e00100000ull
,
261 OPC_MOV_RET_I21
= 0x00e00500000ull
,
262 OPC_MOV_I22
= 0x00188000000ull
,
263 OPC_MOV_I_I26
= 0x00150000000ull
,
264 OPC_MOVL_X2
= 0x0c000000000ull
,
265 OPC_OR_A1
= 0x10070000000ull
,
266 OPC_SETF_EXP_M18
= 0x0c748000000ull
,
267 OPC_SETF_SIG_M18
= 0x0c708000000ull
,
268 OPC_SHL_I7
= 0x0f240000000ull
,
269 OPC_SHR_I5
= 0x0f220000000ull
,
270 OPC_SHR_U_I5
= 0x0f200000000ull
,
271 OPC_SHRP_I10
= 0x0ac00000000ull
,
272 OPC_SXT1_I29
= 0x000a0000000ull
,
273 OPC_SXT2_I29
= 0x000a8000000ull
,
274 OPC_SXT4_I29
= 0x000b0000000ull
,
275 OPC_ST1_M4
= 0x08c00000000ull
,
276 OPC_ST2_M4
= 0x08c40000000ull
,
277 OPC_ST4_M4
= 0x08c80000000ull
,
278 OPC_ST8_M4
= 0x08cc0000000ull
,
279 OPC_SUB_A1
= 0x10028000000ull
,
280 OPC_SUB_A3
= 0x10128000000ull
,
281 OPC_UNPACK4_L_I2
= 0x0f860000000ull
,
282 OPC_XMA_L_F2
= 0x1d000000000ull
,
283 OPC_XOR_A1
= 0x10078000000ull
,
284 OPC_ZXT1_I29
= 0x00080000000ull
,
285 OPC_ZXT2_I29
= 0x00088000000ull
,
286 OPC_ZXT4_I29
= 0x00090000000ull
,
288 INSN_NOP_M
= OPC_NOP_M48
, /* nop.m 0 */
289 INSN_NOP_I
= OPC_NOP_I18
, /* nop.i 0 */
292 static inline uint64_t tcg_opc_a1(int qp
, uint64_t opc
, int r1
,
296 | ((r3
& 0x7f) << 20)
297 | ((r2
& 0x7f) << 13)
302 static inline uint64_t tcg_opc_a3(int qp
, uint64_t opc
, int r1
,
303 uint64_t imm
, int r3
)
306 | ((imm
& 0x80) << 29) /* s */
307 | ((imm
& 0x7f) << 13) /* imm7b */
308 | ((r3
& 0x7f) << 20)
313 static inline uint64_t tcg_opc_a4(int qp
, uint64_t opc
, int r1
,
314 uint64_t imm
, int r3
)
317 | ((imm
& 0x2000) << 23) /* s */
318 | ((imm
& 0x1f80) << 20) /* imm6d */
319 | ((imm
& 0x007f) << 13) /* imm7b */
320 | ((r3
& 0x7f) << 20)
325 static inline uint64_t tcg_opc_a5(int qp
, uint64_t opc
, int r1
,
326 uint64_t imm
, int r3
)
329 | ((imm
& 0x200000) << 15) /* s */
330 | ((imm
& 0x1f0000) << 6) /* imm5c */
331 | ((imm
& 0x00ff80) << 20) /* imm9d */
332 | ((imm
& 0x00007f) << 13) /* imm7b */
333 | ((r3
& 0x03) << 20)
338 static inline uint64_t tcg_opc_a6(int qp
, uint64_t opc
, int p1
,
339 int p2
, int r2
, int r3
)
342 | ((p2
& 0x3f) << 27)
343 | ((r3
& 0x7f) << 20)
344 | ((r2
& 0x7f) << 13)
349 static inline uint64_t tcg_opc_b1(int qp
, uint64_t opc
, uint64_t imm
)
352 | ((imm
& 0x100000) << 16) /* s */
353 | ((imm
& 0x0fffff) << 13) /* imm20b */
357 static inline uint64_t tcg_opc_b4(int qp
, uint64_t opc
, int b2
)
364 static inline uint64_t tcg_opc_b5(int qp
, uint64_t opc
, int b1
, int b2
)
373 static inline uint64_t tcg_opc_b9(int qp
, uint64_t opc
, uint64_t imm
)
376 | ((imm
& 0x100000) << 16) /* i */
377 | ((imm
& 0x0fffff) << 6) /* imm20a */
381 static inline uint64_t tcg_opc_f1(int qp
, uint64_t opc
, int f1
,
382 int f3
, int f4
, int f2
)
385 | ((f4
& 0x7f) << 27)
386 | ((f3
& 0x7f) << 20)
387 | ((f2
& 0x7f) << 13)
392 static inline uint64_t tcg_opc_f2(int qp
, uint64_t opc
, int f1
,
393 int f3
, int f4
, int f2
)
396 | ((f4
& 0x7f) << 27)
397 | ((f3
& 0x7f) << 20)
398 | ((f2
& 0x7f) << 13)
403 static inline uint64_t tcg_opc_f6(int qp
, uint64_t opc
, int f1
,
404 int p2
, int f2
, int f3
)
407 | ((p2
& 0x3f) << 27)
408 | ((f3
& 0x7f) << 20)
409 | ((f2
& 0x7f) << 13)
414 static inline uint64_t tcg_opc_f10(int qp
, uint64_t opc
, int f1
, int f2
)
417 | ((f2
& 0x7f) << 13)
422 static inline uint64_t tcg_opc_f11(int qp
, uint64_t opc
, int f1
, int f2
)
425 | ((f2
& 0x7f) << 13)
430 static inline uint64_t tcg_opc_f16(int qp
, uint64_t opc
, uint64_t imm
)
433 | ((imm
& 0x100000) << 16) /* i */
434 | ((imm
& 0x0fffff) << 6) /* imm20a */
438 static inline uint64_t tcg_opc_i2(int qp
, uint64_t opc
, int r1
,
442 | ((r3
& 0x7f) << 20)
443 | ((r2
& 0x7f) << 13)
448 static inline uint64_t tcg_opc_i3(int qp
, uint64_t opc
, int r1
,
452 | ((mbtype
& 0x0f) << 20)
453 | ((r2
& 0x7f) << 13)
458 static inline uint64_t tcg_opc_i5(int qp
, uint64_t opc
, int r1
,
462 | ((r3
& 0x7f) << 20)
463 | ((r2
& 0x7f) << 13)
468 static inline uint64_t tcg_opc_i7(int qp
, uint64_t opc
, int r1
,
472 | ((r3
& 0x7f) << 20)
473 | ((r2
& 0x7f) << 13)
478 static inline uint64_t tcg_opc_i10(int qp
, uint64_t opc
, int r1
,
479 int r2
, int r3
, uint64_t count
)
482 | ((count
& 0x3f) << 27)
483 | ((r3
& 0x7f) << 20)
484 | ((r2
& 0x7f) << 13)
489 static inline uint64_t tcg_opc_i11(int qp
, uint64_t opc
, int r1
,
490 int r3
, uint64_t pos
, uint64_t len
)
493 | ((len
& 0x3f) << 27)
494 | ((r3
& 0x7f) << 20)
495 | ((pos
& 0x3f) << 14)
500 static inline uint64_t tcg_opc_i12(int qp
, uint64_t opc
, int r1
,
501 int r2
, uint64_t pos
, uint64_t len
)
504 | ((len
& 0x3f) << 27)
505 | ((pos
& 0x3f) << 20)
506 | ((r2
& 0x7f) << 13)
511 static inline uint64_t tcg_opc_i14(int qp
, uint64_t opc
, int r1
, uint64_t imm
,
512 int r3
, uint64_t pos
, uint64_t len
)
515 | ((imm
& 0x01) << 36)
516 | ((len
& 0x3f) << 27)
517 | ((r3
& 0x7f) << 20)
518 | ((pos
& 0x3f) << 14)
523 static inline uint64_t tcg_opc_i15(int qp
, uint64_t opc
, int r1
, int r2
,
524 int r3
, uint64_t pos
, uint64_t len
)
527 | ((pos
& 0x3f) << 31)
528 | ((len
& 0x0f) << 27)
529 | ((r3
& 0x7f) << 20)
530 | ((r2
& 0x7f) << 13)
535 static inline uint64_t tcg_opc_i18(int qp
, uint64_t opc
, uint64_t imm
)
538 | ((imm
& 0x100000) << 16) /* i */
539 | ((imm
& 0x0fffff) << 6) /* imm20a */
543 static inline uint64_t tcg_opc_i21(int qp
, uint64_t opc
, int b1
,
544 int r2
, uint64_t imm
)
547 | ((imm
& 0x1ff) << 24)
548 | ((r2
& 0x7f) << 13)
553 static inline uint64_t tcg_opc_i22(int qp
, uint64_t opc
, int r1
, int b2
)
561 static inline uint64_t tcg_opc_i26(int qp
, uint64_t opc
, int ar3
, int r2
)
564 | ((ar3
& 0x7f) << 20)
565 | ((r2
& 0x7f) << 13)
569 static inline uint64_t tcg_opc_i29(int qp
, uint64_t opc
, int r1
, int r3
)
572 | ((r3
& 0x7f) << 20)
577 static inline uint64_t tcg_opc_l2(uint64_t imm
)
579 return (imm
& 0x7fffffffffc00000ull
) >> 22;
582 static inline uint64_t tcg_opc_l3(uint64_t imm
)
584 return (imm
& 0x07fffffffff00000ull
) >> 18;
587 #define tcg_opc_l4 tcg_opc_l3
589 static inline uint64_t tcg_opc_m1(int qp
, uint64_t opc
, int r1
, int r3
)
592 | ((r3
& 0x7f) << 20)
597 static inline uint64_t tcg_opc_m3(int qp
, uint64_t opc
, int r1
,
598 int r3
, uint64_t imm
)
601 | ((imm
& 0x100) << 28) /* s */
602 | ((imm
& 0x080) << 20) /* i */
603 | ((imm
& 0x07f) << 13) /* imm7b */
604 | ((r3
& 0x7f) << 20)
609 static inline uint64_t tcg_opc_m4(int qp
, uint64_t opc
, int r2
, int r3
)
612 | ((r3
& 0x7f) << 20)
613 | ((r2
& 0x7f) << 13)
617 static inline uint64_t tcg_opc_m18(int qp
, uint64_t opc
, int f1
, int r2
)
620 | ((r2
& 0x7f) << 13)
625 static inline uint64_t tcg_opc_m19(int qp
, uint64_t opc
, int r1
, int f2
)
628 | ((f2
& 0x7f) << 13)
633 static inline uint64_t tcg_opc_m34(int qp
, uint64_t opc
, int r1
,
634 int sof
, int sol
, int sor
)
637 | ((sor
& 0x0f) << 27)
638 | ((sol
& 0x7f) << 20)
639 | ((sof
& 0x7f) << 13)
644 static inline uint64_t tcg_opc_m48(int qp
, uint64_t opc
, uint64_t imm
)
647 | ((imm
& 0x100000) << 16) /* i */
648 | ((imm
& 0x0fffff) << 6) /* imm20a */
652 static inline uint64_t tcg_opc_x2(int qp
, uint64_t opc
,
653 int r1
, uint64_t imm
)
656 | ((imm
& 0x8000000000000000ull
) >> 27) /* i */
657 | (imm
& 0x0000000000200000ull
) /* ic */
658 | ((imm
& 0x00000000001f0000ull
) << 6) /* imm5c */
659 | ((imm
& 0x000000000000ff80ull
) << 20) /* imm9d */
660 | ((imm
& 0x000000000000007full
) << 13) /* imm7b */
665 static inline uint64_t tcg_opc_x3(int qp
, uint64_t opc
, uint64_t imm
)
668 | ((imm
& 0x0800000000000000ull
) >> 23) /* i */
669 | ((imm
& 0x00000000000fffffull
) << 13) /* imm20b */
673 static inline uint64_t tcg_opc_x4(int qp
, uint64_t opc
, int b1
, uint64_t imm
)
676 | ((imm
& 0x0800000000000000ull
) >> 23) /* i */
677 | ((imm
& 0x00000000000fffffull
) << 13) /* imm20b */
687 static inline void reloc_pcrel21b(void *pc
, intptr_t target
)
693 slot
= (intptr_t)pc
& 3;
694 pc
= (void *)((intptr_t)pc
& ~3);
696 disp
= target
- (intptr_t)pc
;
697 imm
= (uint64_t) disp
>> 4;
701 *(uint64_t *)(pc
+ 0) = (*(uint64_t *)(pc
+ 8) & 0xfffffdc00003ffffull
)
702 | ((imm
& 0x100000) << 21) /* s */
703 | ((imm
& 0x0fffff) << 18); /* imm20b */
706 *(uint64_t *)(pc
+ 8) = (*(uint64_t *)(pc
+ 8) & 0xfffffffffffb8000ull
)
707 | ((imm
& 0x100000) >> 2) /* s */
708 | ((imm
& 0x0fffe0) >> 5); /* imm20b */
709 *(uint64_t *)(pc
+ 0) = (*(uint64_t *)(pc
+ 0) & 0x07ffffffffffffffull
)
710 | ((imm
& 0x00001f) << 59); /* imm20b */
713 *(uint64_t *)(pc
+ 8) = (*(uint64_t *)(pc
+ 8) & 0xf700000fffffffffull
)
714 | ((imm
& 0x100000) << 39) /* s */
715 | ((imm
& 0x0fffff) << 36); /* imm20b */
720 static inline uint64_t get_reloc_pcrel21b (void *pc
)
725 slot
= (tcg_target_long
) pc
& 3;
726 pc
= (void *)((tcg_target_long
) pc
& ~3);
728 low
= (*(uint64_t *)(pc
+ 0));
729 high
= (*(uint64_t *)(pc
+ 8));
733 return ((low
>> 21) & 0x100000) + /* s */
734 ((low
>> 18) & 0x0fffff); /* imm20b */
736 return ((high
<< 2) & 0x100000) + /* s */
737 ((high
<< 5) & 0x0fffe0) + /* imm20b */
738 ((low
>> 59) & 0x00001f); /* imm20b */
740 return ((high
>> 39) & 0x100000) + /* s */
741 ((high
>> 36) & 0x0fffff); /* imm20b */
747 static inline void reloc_pcrel60b(void *pc
, intptr_t target
)
752 disp
= target
- (intptr_t)pc
;
753 imm
= (uint64_t) disp
>> 4;
755 *(uint64_t *)(pc
+ 8) = (*(uint64_t *)(pc
+ 8) & 0xf700000fff800000ull
)
756 | (imm
& 0x0800000000000000ull
) /* s */
757 | ((imm
& 0x07fffff000000000ull
) >> 36) /* imm39 */
758 | ((imm
& 0x00000000000fffffull
) << 36); /* imm20b */
759 *(uint64_t *)(pc
+ 0) = (*(uint64_t *)(pc
+ 0) & 0x00003fffffffffffull
)
760 | ((imm
& 0x0000000ffff00000ull
) << 28); /* imm39 */
763 static inline uint64_t get_reloc_pcrel60b (void *pc
)
767 low
= (*(uint64_t *)(pc
+ 0));
768 high
= (*(uint64_t *)(pc
+ 8));
770 return ((high
) & 0x0800000000000000ull
) + /* s */
771 ((high
>> 36) & 0x00000000000fffffull
) + /* imm20b */
772 ((high
<< 36) & 0x07fffff000000000ull
) + /* imm39 */
773 ((low
>> 28) & 0x0000000ffff00000ull
); /* imm39 */
777 static void patch_reloc(uint8_t *code_ptr
, int type
,
778 intptr_t value
, intptr_t addend
)
782 case R_IA64_PCREL21B
:
783 reloc_pcrel21b(code_ptr
, value
);
785 case R_IA64_PCREL60B
:
786 reloc_pcrel60b(code_ptr
, value
);
796 /* parse target specific constraints */
797 static int target_parse_constraint(TCGArgConstraint
*ct
, const char **pct_str
)
804 ct
->ct
|= TCG_CT_REG
;
805 tcg_regset_set(ct
->u
.regs
, 0xffffffffffffffffull
);
808 ct
->ct
|= TCG_CT_CONST_S22
;
811 ct
->ct
|= TCG_CT_REG
;
812 tcg_regset_set(ct
->u
.regs
, 0xffffffffffffffffull
);
813 #if defined(CONFIG_SOFTMMU)
814 tcg_regset_reset_reg(ct
->u
.regs
, TCG_REG_R56
);
815 tcg_regset_reset_reg(ct
->u
.regs
, TCG_REG_R57
);
819 /* We are cheating a bit here, using the fact that the register
820 r0 is also the register number 0. Hence there is no need
821 to check for const_args in each instruction. */
822 ct
->ct
|= TCG_CT_CONST_ZERO
;
832 /* test if a constant matches the constraint */
833 static inline int tcg_target_const_match(tcg_target_long val
,
834 const TCGArgConstraint
*arg_ct
)
838 if (ct
& TCG_CT_CONST
)
840 else if ((ct
& TCG_CT_CONST_ZERO
) && val
== 0)
842 else if ((ct
& TCG_CT_CONST_S22
) && val
== ((int32_t)val
<< 10) >> 10)
852 static uint8_t *tb_ret_addr
;
854 static inline void tcg_out_bundle(TCGContext
*s
, int template,
855 uint64_t slot0
, uint64_t slot1
,
858 template &= 0x1f; /* 5 bits */
859 slot0
&= 0x1ffffffffffull
; /* 41 bits */
860 slot1
&= 0x1ffffffffffull
; /* 41 bits */
861 slot2
&= 0x1ffffffffffull
; /* 41 bits */
863 *(uint64_t *)(s
->code_ptr
+ 0) = (slot1
<< 46) | (slot0
<< 5) | template;
864 *(uint64_t *)(s
->code_ptr
+ 8) = (slot2
<< 23) | (slot1
>> 18);
868 static inline void tcg_out_mov(TCGContext
*s
, TCGType type
,
869 TCGReg ret
, TCGReg arg
)
871 tcg_out_bundle(s
, mmI
,
874 tcg_opc_a4(TCG_REG_P0
, OPC_ADDS_A4
, ret
, 0, arg
));
877 static inline void tcg_out_movi(TCGContext
*s
, TCGType type
,
878 TCGReg reg
, tcg_target_long arg
)
880 tcg_out_bundle(s
, mLX
,
883 tcg_opc_x2 (TCG_REG_P0
, OPC_MOVL_X2
, reg
, arg
));
886 static void tcg_out_br(TCGContext
*s
, int label_index
)
888 TCGLabel
*l
= &s
->labels
[label_index
];
890 /* We pay attention here to not modify the branch target by reading
891 the existing value and using it again. This ensure that caches and
892 memory are kept coherent during retranslation. */
893 tcg_out_bundle(s
, mmB
,
896 tcg_opc_b1 (TCG_REG_P0
, OPC_BR_SPTK_MANY_B1
,
897 get_reloc_pcrel21b(s
->code_ptr
+ 2)));
900 reloc_pcrel21b((s
->code_ptr
- 16) + 2, l
->u
.value
);
902 tcg_out_reloc(s
, (s
->code_ptr
- 16) + 2,
903 R_IA64_PCREL21B
, label_index
, 0);
907 static inline void tcg_out_calli(TCGContext
*s
, uintptr_t addr
)
909 /* Look through the function descriptor. */
910 uintptr_t disp
, *desc
= (uintptr_t *)addr
;
911 tcg_out_bundle(s
, mlx
,
913 tcg_opc_l2 (desc
[1]),
914 tcg_opc_x2 (TCG_REG_P0
, OPC_MOVL_X2
, TCG_REG_R1
, desc
[1]));
915 disp
= (desc
[0] - (uintptr_t)s
->code_ptr
) >> 4;
916 tcg_out_bundle(s
, mLX
,
919 tcg_opc_x4 (TCG_REG_P0
, OPC_BRL_CALL_SPTK_MANY_X4
,
923 static inline void tcg_out_callr(TCGContext
*s
, TCGReg addr
)
925 tcg_out_bundle(s
, MmI
,
926 tcg_opc_m1 (TCG_REG_P0
, OPC_LD8_M1
, TCG_REG_R2
, addr
),
927 tcg_opc_a4 (TCG_REG_P0
, OPC_ADDS_A4
, TCG_REG_R3
, 8, addr
),
928 tcg_opc_i21(TCG_REG_P0
, OPC_MOV_I21
,
929 TCG_REG_B6
, TCG_REG_R2
, 0));
930 tcg_out_bundle(s
, mmB
,
931 tcg_opc_m1 (TCG_REG_P0
, OPC_LD8_M1
, TCG_REG_R1
, TCG_REG_R3
),
933 tcg_opc_b5 (TCG_REG_P0
, OPC_BR_CALL_SPTK_MANY_B5
,
934 TCG_REG_B0
, TCG_REG_B6
));
937 static void tcg_out_exit_tb(TCGContext
*s
, tcg_target_long arg
)
942 tcg_out_movi(s
, TCG_TYPE_PTR
, TCG_REG_R8
, arg
);
944 disp
= tb_ret_addr
- s
->code_ptr
;
945 imm
= (uint64_t)disp
>> 4;
947 tcg_out_bundle(s
, mLX
,
950 tcg_opc_x3 (TCG_REG_P0
, OPC_BRL_SPTK_MANY_X3
, imm
));
953 static inline void tcg_out_goto_tb(TCGContext
*s
, TCGArg arg
)
955 if (s
->tb_jmp_offset
) {
956 /* direct jump method */
959 /* indirect jump method */
960 tcg_out_movi(s
, TCG_TYPE_PTR
, TCG_REG_R2
,
961 (tcg_target_long
)(s
->tb_next
+ arg
));
962 tcg_out_bundle(s
, MmI
,
963 tcg_opc_m1 (TCG_REG_P0
, OPC_LD8_M1
,
964 TCG_REG_R2
, TCG_REG_R2
),
966 tcg_opc_i21(TCG_REG_P0
, OPC_MOV_I21
, TCG_REG_B6
,
968 tcg_out_bundle(s
, mmB
,
971 tcg_opc_b4 (TCG_REG_P0
, OPC_BR_SPTK_MANY_B4
,
974 s
->tb_next_offset
[arg
] = s
->code_ptr
- s
->code_buf
;
977 static inline void tcg_out_jmp(TCGContext
*s
, TCGArg addr
)
979 tcg_out_bundle(s
, mmI
,
982 tcg_opc_i21(TCG_REG_P0
, OPC_MOV_I21
, TCG_REG_B6
, addr
, 0));
983 tcg_out_bundle(s
, mmB
,
986 tcg_opc_b4(TCG_REG_P0
, OPC_BR_SPTK_MANY_B4
, TCG_REG_B6
));
989 static inline void tcg_out_ld_rel(TCGContext
*s
, uint64_t opc_m4
, TCGArg arg
,
990 TCGArg arg1
, tcg_target_long arg2
)
992 if (arg2
== ((int16_t)arg2
>> 2) << 2) {
993 tcg_out_bundle(s
, MmI
,
994 tcg_opc_a4(TCG_REG_P0
, OPC_ADDS_A4
,
995 TCG_REG_R2
, arg2
, arg1
),
996 tcg_opc_m1 (TCG_REG_P0
, opc_m4
, arg
, TCG_REG_R2
),
999 tcg_out_movi(s
, TCG_TYPE_PTR
, TCG_REG_R2
, arg2
);
1000 tcg_out_bundle(s
, MmI
,
1001 tcg_opc_a1 (TCG_REG_P0
, OPC_ADD_A1
,
1002 TCG_REG_R2
, TCG_REG_R2
, arg1
),
1003 tcg_opc_m1 (TCG_REG_P0
, opc_m4
, arg
, TCG_REG_R2
),
1008 static inline void tcg_out_st_rel(TCGContext
*s
, uint64_t opc_m4
, TCGArg arg
,
1009 TCGArg arg1
, tcg_target_long arg2
)
1011 if (arg2
== ((int16_t)arg2
>> 2) << 2) {
1012 tcg_out_bundle(s
, MmI
,
1013 tcg_opc_a4(TCG_REG_P0
, OPC_ADDS_A4
,
1014 TCG_REG_R2
, arg2
, arg1
),
1015 tcg_opc_m4 (TCG_REG_P0
, opc_m4
, arg
, TCG_REG_R2
),
1018 tcg_out_movi(s
, TCG_TYPE_PTR
, TCG_REG_R2
, arg2
);
1019 tcg_out_bundle(s
, MmI
,
1020 tcg_opc_a1 (TCG_REG_P0
, OPC_ADD_A1
,
1021 TCG_REG_R2
, TCG_REG_R2
, arg1
),
1022 tcg_opc_m4 (TCG_REG_P0
, opc_m4
, arg
, TCG_REG_R2
),
1027 static inline void tcg_out_ld(TCGContext
*s
, TCGType type
, TCGReg arg
,
1028 TCGReg arg1
, intptr_t arg2
)
1030 if (type
== TCG_TYPE_I32
) {
1031 tcg_out_ld_rel(s
, OPC_LD4_M1
, arg
, arg1
, arg2
);
1033 tcg_out_ld_rel(s
, OPC_LD8_M1
, arg
, arg1
, arg2
);
1037 static inline void tcg_out_st(TCGContext
*s
, TCGType type
, TCGReg arg
,
1038 TCGReg arg1
, intptr_t arg2
)
1040 if (type
== TCG_TYPE_I32
) {
1041 tcg_out_st_rel(s
, OPC_ST4_M4
, arg
, arg1
, arg2
);
1043 tcg_out_st_rel(s
, OPC_ST8_M4
, arg
, arg1
, arg2
);
1047 static void tcg_out_alu(TCGContext
*s
, uint64_t opc_a1
, TCGReg ret
, TCGArg arg1
,
1048 int const_arg1
, TCGArg arg2
, int const_arg2
)
1050 uint64_t opc1
= 0, opc2
= 0;
1052 if (const_arg1
&& arg1
!= 0) {
1053 opc1
= tcg_opc_a5(TCG_REG_P0
, OPC_ADDL_A5
,
1054 TCG_REG_R2
, arg1
, TCG_REG_R0
);
1058 if (const_arg2
&& arg2
!= 0) {
1059 opc2
= tcg_opc_a5(TCG_REG_P0
, OPC_ADDL_A5
,
1060 TCG_REG_R3
, arg2
, TCG_REG_R0
);
1064 tcg_out_bundle(s
, (opc1
|| opc2
? mII
: miI
),
1065 opc1
? opc1
: INSN_NOP_M
,
1066 opc2
? opc2
: INSN_NOP_I
,
1067 tcg_opc_a1(TCG_REG_P0
, opc_a1
, ret
, arg1
, arg2
));
1070 static inline void tcg_out_add(TCGContext
*s
, TCGReg ret
, TCGReg arg1
,
1071 TCGArg arg2
, int const_arg2
)
1073 if (const_arg2
&& arg2
== sextract64(arg2
, 0, 14)) {
1074 tcg_out_bundle(s
, mmI
,
1077 tcg_opc_a4(TCG_REG_P0
, OPC_ADDS_A4
, ret
, arg2
, arg1
));
1079 tcg_out_alu(s
, OPC_ADD_A1
, ret
, arg1
, 0, arg2
, const_arg2
);
1083 static inline void tcg_out_sub(TCGContext
*s
, TCGReg ret
, TCGArg arg1
,
1084 int const_arg1
, TCGArg arg2
, int const_arg2
)
1086 if (const_arg1
&& arg1
== (int8_t)arg1
) {
1088 tcg_out_movi(s
, TCG_TYPE_I64
, ret
, arg1
- arg2
);
1091 tcg_out_bundle(s
, mmI
,
1094 tcg_opc_a3(TCG_REG_P0
, OPC_SUB_A3
, ret
, arg1
, arg2
));
1095 } else if (const_arg2
&& -arg2
== sextract64(-arg2
, 0, 14)) {
1096 tcg_out_bundle(s
, mmI
,
1099 tcg_opc_a4(TCG_REG_P0
, OPC_ADDS_A4
, ret
, -arg2
, arg1
));
1101 tcg_out_alu(s
, OPC_SUB_A1
, ret
, arg1
, const_arg1
, arg2
, const_arg2
);
1105 static inline void tcg_out_eqv(TCGContext
*s
, TCGArg ret
,
1106 TCGArg arg1
, int const_arg1
,
1107 TCGArg arg2
, int const_arg2
)
1109 tcg_out_bundle(s
, mII
,
1111 tcg_opc_a1 (TCG_REG_P0
, OPC_XOR_A1
, ret
, arg1
, arg2
),
1112 tcg_opc_a3 (TCG_REG_P0
, OPC_ANDCM_A3
, ret
, -1, ret
));
1115 static inline void tcg_out_nand(TCGContext
*s
, TCGArg ret
,
1116 TCGArg arg1
, int const_arg1
,
1117 TCGArg arg2
, int const_arg2
)
1119 tcg_out_bundle(s
, mII
,
1121 tcg_opc_a1 (TCG_REG_P0
, OPC_AND_A1
, ret
, arg1
, arg2
),
1122 tcg_opc_a3 (TCG_REG_P0
, OPC_ANDCM_A3
, ret
, -1, ret
));
1125 static inline void tcg_out_nor(TCGContext
*s
, TCGArg ret
,
1126 TCGArg arg1
, int const_arg1
,
1127 TCGArg arg2
, int const_arg2
)
1129 tcg_out_bundle(s
, mII
,
1131 tcg_opc_a1 (TCG_REG_P0
, OPC_OR_A1
, ret
, arg1
, arg2
),
1132 tcg_opc_a3 (TCG_REG_P0
, OPC_ANDCM_A3
, ret
, -1, ret
));
1135 static inline void tcg_out_orc(TCGContext
*s
, TCGArg ret
,
1136 TCGArg arg1
, int const_arg1
,
1137 TCGArg arg2
, int const_arg2
)
1139 tcg_out_bundle(s
, mII
,
1141 tcg_opc_a3 (TCG_REG_P0
, OPC_ANDCM_A3
, TCG_REG_R2
, -1, arg2
),
1142 tcg_opc_a1 (TCG_REG_P0
, OPC_OR_A1
, ret
, arg1
, TCG_REG_R2
));
1145 static inline void tcg_out_mul(TCGContext
*s
, TCGArg ret
,
1146 TCGArg arg1
, TCGArg arg2
)
1148 tcg_out_bundle(s
, mmI
,
1149 tcg_opc_m18(TCG_REG_P0
, OPC_SETF_SIG_M18
, TCG_REG_F6
, arg1
),
1150 tcg_opc_m18(TCG_REG_P0
, OPC_SETF_SIG_M18
, TCG_REG_F7
, arg2
),
1152 tcg_out_bundle(s
, mmF
,
1155 tcg_opc_f2 (TCG_REG_P0
, OPC_XMA_L_F2
, TCG_REG_F6
, TCG_REG_F6
,
1156 TCG_REG_F7
, TCG_REG_F0
));
1157 tcg_out_bundle(s
, miI
,
1158 tcg_opc_m19(TCG_REG_P0
, OPC_GETF_SIG_M19
, ret
, TCG_REG_F6
),
1163 static inline void tcg_out_sar_i32(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1164 TCGArg arg2
, int const_arg2
)
1167 tcg_out_bundle(s
, miI
,
1170 tcg_opc_i11(TCG_REG_P0
, OPC_EXTR_I11
,
1171 ret
, arg1
, arg2
, 31 - arg2
));
1173 tcg_out_bundle(s
, mII
,
1174 tcg_opc_a3 (TCG_REG_P0
, OPC_AND_A3
,
1175 TCG_REG_R3
, 0x1f, arg2
),
1176 tcg_opc_i29(TCG_REG_P0
, OPC_SXT4_I29
, TCG_REG_R2
, arg1
),
1177 tcg_opc_i5 (TCG_REG_P0
, OPC_SHR_I5
, ret
,
1178 TCG_REG_R2
, TCG_REG_R3
));
1182 static inline void tcg_out_sar_i64(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1183 TCGArg arg2
, int const_arg2
)
1186 tcg_out_bundle(s
, miI
,
1189 tcg_opc_i11(TCG_REG_P0
, OPC_EXTR_I11
,
1190 ret
, arg1
, arg2
, 63 - arg2
));
1192 tcg_out_bundle(s
, miI
,
1195 tcg_opc_i5 (TCG_REG_P0
, OPC_SHR_I5
, ret
, arg1
, arg2
));
1199 static inline void tcg_out_shl_i32(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1200 TCGArg arg2
, int const_arg2
)
1203 tcg_out_bundle(s
, miI
,
1206 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
, ret
,
1207 arg1
, 63 - arg2
, 31 - arg2
));
1209 tcg_out_bundle(s
, mII
,
1211 tcg_opc_a3 (TCG_REG_P0
, OPC_AND_A3
, TCG_REG_R2
,
1213 tcg_opc_i7 (TCG_REG_P0
, OPC_SHL_I7
, ret
,
1218 static inline void tcg_out_shl_i64(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1219 TCGArg arg2
, int const_arg2
)
1222 tcg_out_bundle(s
, miI
,
1225 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
, ret
,
1226 arg1
, 63 - arg2
, 63 - arg2
));
1228 tcg_out_bundle(s
, miI
,
1231 tcg_opc_i7 (TCG_REG_P0
, OPC_SHL_I7
, ret
,
1236 static inline void tcg_out_shr_i32(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1237 TCGArg arg2
, int const_arg2
)
1240 tcg_out_bundle(s
, miI
,
1243 tcg_opc_i11(TCG_REG_P0
, OPC_EXTR_U_I11
, ret
,
1244 arg1
, arg2
, 31 - arg2
));
1246 tcg_out_bundle(s
, mII
,
1247 tcg_opc_a3 (TCG_REG_P0
, OPC_AND_A3
, TCG_REG_R3
,
1249 tcg_opc_i29(TCG_REG_P0
, OPC_ZXT4_I29
, TCG_REG_R2
, arg1
),
1250 tcg_opc_i5 (TCG_REG_P0
, OPC_SHR_U_I5
, ret
,
1251 TCG_REG_R2
, TCG_REG_R3
));
1255 static inline void tcg_out_shr_i64(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1256 TCGArg arg2
, int const_arg2
)
1259 tcg_out_bundle(s
, miI
,
1262 tcg_opc_i11(TCG_REG_P0
, OPC_EXTR_U_I11
, ret
,
1263 arg1
, arg2
, 63 - arg2
));
1265 tcg_out_bundle(s
, miI
,
1268 tcg_opc_i5 (TCG_REG_P0
, OPC_SHR_U_I5
, ret
,
1273 static inline void tcg_out_rotl_i32(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1274 TCGArg arg2
, int const_arg2
)
1277 tcg_out_bundle(s
, mII
,
1279 tcg_opc_i2 (TCG_REG_P0
, OPC_UNPACK4_L_I2
,
1280 TCG_REG_R2
, arg1
, arg1
),
1281 tcg_opc_i11(TCG_REG_P0
, OPC_EXTR_U_I11
, ret
,
1282 TCG_REG_R2
, 32 - arg2
, 31));
1284 tcg_out_bundle(s
, miI
,
1286 tcg_opc_i2 (TCG_REG_P0
, OPC_UNPACK4_L_I2
,
1287 TCG_REG_R2
, arg1
, arg1
),
1288 tcg_opc_a3 (TCG_REG_P0
, OPC_AND_A3
, TCG_REG_R3
,
1290 tcg_out_bundle(s
, mII
,
1292 tcg_opc_a3 (TCG_REG_P0
, OPC_SUB_A3
, TCG_REG_R3
,
1294 tcg_opc_i5 (TCG_REG_P0
, OPC_SHR_U_I5
, ret
,
1295 TCG_REG_R2
, TCG_REG_R3
));
1299 static inline void tcg_out_rotl_i64(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1300 TCGArg arg2
, int const_arg2
)
1303 tcg_out_bundle(s
, miI
,
1306 tcg_opc_i10(TCG_REG_P0
, OPC_SHRP_I10
, ret
, arg1
,
1307 arg1
, 0x40 - arg2
));
1309 tcg_out_bundle(s
, mII
,
1310 tcg_opc_a3 (TCG_REG_P0
, OPC_SUB_A3
, TCG_REG_R2
,
1312 tcg_opc_i7 (TCG_REG_P0
, OPC_SHL_I7
, TCG_REG_R3
,
1314 tcg_opc_i5 (TCG_REG_P0
, OPC_SHR_U_I5
, TCG_REG_R2
,
1316 tcg_out_bundle(s
, miI
,
1319 tcg_opc_a1 (TCG_REG_P0
, OPC_OR_A1
, ret
,
1320 TCG_REG_R2
, TCG_REG_R3
));
1324 static inline void tcg_out_rotr_i32(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1325 TCGArg arg2
, int const_arg2
)
1328 tcg_out_bundle(s
, mII
,
1330 tcg_opc_i2 (TCG_REG_P0
, OPC_UNPACK4_L_I2
,
1331 TCG_REG_R2
, arg1
, arg1
),
1332 tcg_opc_i11(TCG_REG_P0
, OPC_EXTR_U_I11
, ret
,
1333 TCG_REG_R2
, arg2
, 31));
1335 tcg_out_bundle(s
, mII
,
1336 tcg_opc_a3 (TCG_REG_P0
, OPC_AND_A3
, TCG_REG_R3
,
1338 tcg_opc_i2 (TCG_REG_P0
, OPC_UNPACK4_L_I2
,
1339 TCG_REG_R2
, arg1
, arg1
),
1340 tcg_opc_i5 (TCG_REG_P0
, OPC_SHR_U_I5
, ret
,
1341 TCG_REG_R2
, TCG_REG_R3
));
1345 static inline void tcg_out_rotr_i64(TCGContext
*s
, TCGArg ret
, TCGArg arg1
,
1346 TCGArg arg2
, int const_arg2
)
1349 tcg_out_bundle(s
, miI
,
1352 tcg_opc_i10(TCG_REG_P0
, OPC_SHRP_I10
, ret
, arg1
,
1355 tcg_out_bundle(s
, mII
,
1356 tcg_opc_a3 (TCG_REG_P0
, OPC_SUB_A3
, TCG_REG_R2
,
1358 tcg_opc_i5 (TCG_REG_P0
, OPC_SHR_U_I5
, TCG_REG_R3
,
1360 tcg_opc_i7 (TCG_REG_P0
, OPC_SHL_I7
, TCG_REG_R2
,
1362 tcg_out_bundle(s
, miI
,
1365 tcg_opc_a1 (TCG_REG_P0
, OPC_OR_A1
, ret
,
1366 TCG_REG_R2
, TCG_REG_R3
));
1370 static inline void tcg_out_ext(TCGContext
*s
, uint64_t opc_i29
,
1371 TCGArg ret
, TCGArg arg
)
1373 tcg_out_bundle(s
, miI
,
1376 tcg_opc_i29(TCG_REG_P0
, opc_i29
, ret
, arg
));
1379 static inline void tcg_out_bswap16(TCGContext
*s
, TCGArg ret
, TCGArg arg
)
1381 tcg_out_bundle(s
, mII
,
1383 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
, ret
, arg
, 15, 15),
1384 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
, ret
, ret
, 0xb));
1387 static inline void tcg_out_bswap32(TCGContext
*s
, TCGArg ret
, TCGArg arg
)
1389 tcg_out_bundle(s
, mII
,
1391 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
, ret
, arg
, 31, 31),
1392 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
, ret
, ret
, 0xb));
1395 static inline void tcg_out_bswap64(TCGContext
*s
, TCGArg ret
, TCGArg arg
)
1397 tcg_out_bundle(s
, miI
,
1400 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
, ret
, arg
, 0xb));
1403 static inline void tcg_out_deposit(TCGContext
*s
, TCGArg ret
, TCGArg a1
,
1404 TCGArg a2
, int const_a2
, int pos
, int len
)
1406 uint64_t i1
= 0, i2
= 0;
1407 int cpos
= 63 - pos
, lm1
= len
- 1;
1410 /* Truncate the value of a constant a2 to the width of the field. */
1411 int mask
= (1u << len
) - 1;
1414 if (a2
== 0 || a2
== mask
) {
1415 /* 1-bit signed constant inserted into register. */
1416 i2
= tcg_opc_i14(TCG_REG_P0
, OPC_DEP_I14
, ret
, a2
, a1
, cpos
, lm1
);
1418 /* Otherwise, load any constant into a temporary. Do this into
1419 the first I slot to help out with cross-unit delays. */
1420 i1
= tcg_opc_a5(TCG_REG_P0
, OPC_ADDL_A5
,
1421 TCG_REG_R2
, a2
, TCG_REG_R0
);
1426 i2
= tcg_opc_i15(TCG_REG_P0
, OPC_DEP_I15
, ret
, a2
, a1
, cpos
, lm1
);
1428 tcg_out_bundle(s
, (i1
? mII
: miI
),
1430 i1
? i1
: INSN_NOP_I
,
1434 static inline uint64_t tcg_opc_cmp_a(int qp
, TCGCond cond
, TCGArg arg1
,
1435 TCGArg arg2
, int cmp4
)
1437 uint64_t opc_eq_a6
, opc_lt_a6
, opc_ltu_a6
;
1440 opc_eq_a6
= OPC_CMP4_EQ_A6
;
1441 opc_lt_a6
= OPC_CMP4_LT_A6
;
1442 opc_ltu_a6
= OPC_CMP4_LTU_A6
;
1444 opc_eq_a6
= OPC_CMP_EQ_A6
;
1445 opc_lt_a6
= OPC_CMP_LT_A6
;
1446 opc_ltu_a6
= OPC_CMP_LTU_A6
;
1451 return tcg_opc_a6 (qp
, opc_eq_a6
, TCG_REG_P6
, TCG_REG_P7
, arg1
, arg2
);
1453 return tcg_opc_a6 (qp
, opc_eq_a6
, TCG_REG_P7
, TCG_REG_P6
, arg1
, arg2
);
1455 return tcg_opc_a6 (qp
, opc_lt_a6
, TCG_REG_P6
, TCG_REG_P7
, arg1
, arg2
);
1457 return tcg_opc_a6 (qp
, opc_ltu_a6
, TCG_REG_P6
, TCG_REG_P7
, arg1
, arg2
);
1459 return tcg_opc_a6 (qp
, opc_lt_a6
, TCG_REG_P7
, TCG_REG_P6
, arg1
, arg2
);
1461 return tcg_opc_a6 (qp
, opc_ltu_a6
, TCG_REG_P7
, TCG_REG_P6
, arg1
, arg2
);
1463 return tcg_opc_a6 (qp
, opc_lt_a6
, TCG_REG_P7
, TCG_REG_P6
, arg2
, arg1
);
1465 return tcg_opc_a6 (qp
, opc_ltu_a6
, TCG_REG_P7
, TCG_REG_P6
, arg2
, arg1
);
1467 return tcg_opc_a6 (qp
, opc_lt_a6
, TCG_REG_P6
, TCG_REG_P7
, arg2
, arg1
);
1469 return tcg_opc_a6 (qp
, opc_ltu_a6
, TCG_REG_P6
, TCG_REG_P7
, arg2
, arg1
);
1476 static inline void tcg_out_brcond(TCGContext
*s
, TCGCond cond
, TCGReg arg1
,
1477 TCGReg arg2
, int label_index
, int cmp4
)
1479 TCGLabel
*l
= &s
->labels
[label_index
];
1481 tcg_out_bundle(s
, miB
,
1483 tcg_opc_cmp_a(TCG_REG_P0
, cond
, arg1
, arg2
, cmp4
),
1484 tcg_opc_b1(TCG_REG_P6
, OPC_BR_DPTK_FEW_B1
,
1485 get_reloc_pcrel21b(s
->code_ptr
+ 2)));
1488 reloc_pcrel21b((s
->code_ptr
- 16) + 2, l
->u
.value
);
1490 tcg_out_reloc(s
, (s
->code_ptr
- 16) + 2,
1491 R_IA64_PCREL21B
, label_index
, 0);
1495 static inline void tcg_out_setcond(TCGContext
*s
, TCGCond cond
, TCGArg ret
,
1496 TCGArg arg1
, TCGArg arg2
, int cmp4
)
1498 tcg_out_bundle(s
, MmI
,
1499 tcg_opc_cmp_a(TCG_REG_P0
, cond
, arg1
, arg2
, cmp4
),
1500 tcg_opc_a5(TCG_REG_P6
, OPC_ADDL_A5
, ret
, 1, TCG_REG_R0
),
1501 tcg_opc_a5(TCG_REG_P7
, OPC_ADDL_A5
, ret
, 0, TCG_REG_R0
));
1504 static inline void tcg_out_movcond(TCGContext
*s
, TCGCond cond
, TCGArg ret
,
1505 TCGArg c1
, TCGArg c2
,
1506 TCGArg v1
, int const_v1
,
1507 TCGArg v2
, int const_v2
, int cmp4
)
1509 uint64_t opc1
, opc2
;
1512 opc1
= tcg_opc_a5(TCG_REG_P6
, OPC_ADDL_A5
, ret
, v1
, TCG_REG_R0
);
1513 } else if (ret
== v1
) {
1516 opc1
= tcg_opc_a4(TCG_REG_P6
, OPC_ADDS_A4
, ret
, 0, v1
);
1519 opc2
= tcg_opc_a5(TCG_REG_P7
, OPC_ADDL_A5
, ret
, v2
, TCG_REG_R0
);
1520 } else if (ret
== v2
) {
1523 opc2
= tcg_opc_a4(TCG_REG_P7
, OPC_ADDS_A4
, ret
, 0, v2
);
1526 tcg_out_bundle(s
, MmI
,
1527 tcg_opc_cmp_a(TCG_REG_P0
, cond
, c1
, c2
, cmp4
),
1532 #if defined(CONFIG_SOFTMMU)
1533 /* Load and compare a TLB entry, and return the result in (p6, p7).
1534 R2 is loaded with the address of the addend TLB entry.
1535 R57 is loaded with the address, zero extented on 32-bit targets. */
1536 static inline void tcg_out_qemu_tlb(TCGContext
*s
, TCGArg addr_reg
,
1537 TCGMemOp s_bits
, uint64_t offset_rw
,
1538 uint64_t offset_addend
)
1540 tcg_out_bundle(s
, mII
,
1542 tcg_opc_i11(TCG_REG_P0
, OPC_EXTR_U_I11
, TCG_REG_R2
,
1543 addr_reg
, TARGET_PAGE_BITS
, CPU_TLB_BITS
- 1),
1544 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
, TCG_REG_R2
,
1545 TCG_REG_R2
, 63 - CPU_TLB_ENTRY_BITS
,
1546 63 - CPU_TLB_ENTRY_BITS
));
1547 tcg_out_bundle(s
, mII
,
1548 tcg_opc_a5 (TCG_REG_P0
, OPC_ADDL_A5
, TCG_REG_R2
,
1549 offset_rw
, TCG_REG_R2
),
1550 #if TARGET_LONG_BITS == 32
1551 tcg_opc_i29(TCG_REG_P0
, OPC_ZXT4_I29
, TCG_REG_R57
, addr_reg
),
1553 tcg_opc_a4(TCG_REG_P0
, OPC_ADDS_A4
, TCG_REG_R57
,
1556 tcg_opc_a1 (TCG_REG_P0
, OPC_ADD_A1
, TCG_REG_R2
,
1557 TCG_REG_R2
, TCG_AREG0
));
1558 tcg_out_bundle(s
, mII
,
1559 tcg_opc_m3 (TCG_REG_P0
,
1560 (TARGET_LONG_BITS
== 32
1561 ? OPC_LD4_M3
: OPC_LD8_M3
), TCG_REG_R56
,
1562 TCG_REG_R2
, offset_addend
- offset_rw
),
1563 tcg_opc_i14(TCG_REG_P0
, OPC_DEP_I14
, TCG_REG_R3
, 0,
1564 TCG_REG_R57
, 63 - s_bits
,
1565 TARGET_PAGE_BITS
- s_bits
- 1),
1566 tcg_opc_a6 (TCG_REG_P0
, OPC_CMP_EQ_A6
, TCG_REG_P6
,
1567 TCG_REG_P7
, TCG_REG_R3
, TCG_REG_R56
));
1570 /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
1572 static const void * const qemu_ld_helpers
[4] = {
1579 static inline void tcg_out_qemu_ld(TCGContext
*s
, const TCGArg
*args
,
1582 static const uint64_t opc_ld_m1
[4] = {
1583 OPC_LD1_M1
, OPC_LD2_M1
, OPC_LD4_M1
, OPC_LD8_M1
1585 static const uint64_t opc_ext_i29
[8] = {
1586 OPC_ZXT1_I29
, OPC_ZXT2_I29
, OPC_ZXT4_I29
, 0,
1587 OPC_SXT1_I29
, OPC_SXT2_I29
, OPC_SXT4_I29
, 0
1589 int addr_reg
, data_reg
, mem_index
;
1590 TCGMemOp s_bits
, bswap
;
1595 s_bits
= opc
& MO_SIZE
;
1596 bswap
= opc
& MO_BSWAP
;
1598 /* Read the TLB entry */
1599 tcg_out_qemu_tlb(s
, addr_reg
, s_bits
,
1600 offsetof(CPUArchState
, tlb_table
[mem_index
][0].addr_read
),
1601 offsetof(CPUArchState
, tlb_table
[mem_index
][0].addend
));
1603 /* P6 is the fast path, and P7 the slow path */
1604 tcg_out_bundle(s
, mLX
,
1605 tcg_opc_a4 (TCG_REG_P7
, OPC_ADDS_A4
,
1606 TCG_REG_R56
, 0, TCG_AREG0
),
1607 tcg_opc_l2 ((tcg_target_long
) qemu_ld_helpers
[s_bits
]),
1608 tcg_opc_x2 (TCG_REG_P7
, OPC_MOVL_X2
, TCG_REG_R2
,
1609 (tcg_target_long
) qemu_ld_helpers
[s_bits
]));
1610 tcg_out_bundle(s
, MmI
,
1611 tcg_opc_m3 (TCG_REG_P0
, OPC_LD8_M3
, TCG_REG_R3
,
1613 tcg_opc_a1 (TCG_REG_P6
, OPC_ADD_A1
, TCG_REG_R3
,
1614 TCG_REG_R3
, TCG_REG_R57
),
1615 tcg_opc_i21(TCG_REG_P7
, OPC_MOV_I21
, TCG_REG_B6
,
1617 if (bswap
&& s_bits
== MO_16
) {
1618 tcg_out_bundle(s
, MmI
,
1619 tcg_opc_m1 (TCG_REG_P6
, opc_ld_m1
[s_bits
],
1620 TCG_REG_R8
, TCG_REG_R3
),
1621 tcg_opc_m1 (TCG_REG_P7
, OPC_LD8_M1
, TCG_REG_R1
, TCG_REG_R2
),
1622 tcg_opc_i12(TCG_REG_P6
, OPC_DEP_Z_I12
,
1623 TCG_REG_R8
, TCG_REG_R8
, 15, 15));
1624 } else if (bswap
&& s_bits
== MO_32
) {
1625 tcg_out_bundle(s
, MmI
,
1626 tcg_opc_m1 (TCG_REG_P6
, opc_ld_m1
[s_bits
],
1627 TCG_REG_R8
, TCG_REG_R3
),
1628 tcg_opc_m1 (TCG_REG_P7
, OPC_LD8_M1
, TCG_REG_R1
, TCG_REG_R2
),
1629 tcg_opc_i12(TCG_REG_P6
, OPC_DEP_Z_I12
,
1630 TCG_REG_R8
, TCG_REG_R8
, 31, 31));
1632 tcg_out_bundle(s
, mmI
,
1633 tcg_opc_m1 (TCG_REG_P6
, opc_ld_m1
[s_bits
],
1634 TCG_REG_R8
, TCG_REG_R3
),
1635 tcg_opc_m1 (TCG_REG_P7
, OPC_LD8_M1
, TCG_REG_R1
, TCG_REG_R2
),
1639 tcg_out_bundle(s
, miB
,
1640 tcg_opc_a5 (TCG_REG_P7
, OPC_ADDL_A5
, TCG_REG_R58
,
1641 mem_index
, TCG_REG_R0
),
1643 tcg_opc_b5 (TCG_REG_P7
, OPC_BR_CALL_SPTK_MANY_B5
,
1644 TCG_REG_B0
, TCG_REG_B6
));
1646 tcg_out_bundle(s
, miB
,
1647 tcg_opc_a5 (TCG_REG_P7
, OPC_ADDL_A5
, TCG_REG_R58
,
1648 mem_index
, TCG_REG_R0
),
1649 tcg_opc_i3 (TCG_REG_P6
, OPC_MUX1_I3
,
1650 TCG_REG_R8
, TCG_REG_R8
, 0xb),
1651 tcg_opc_b5 (TCG_REG_P7
, OPC_BR_CALL_SPTK_MANY_B5
,
1652 TCG_REG_B0
, TCG_REG_B6
));
1655 if (s_bits
== MO_64
) {
1656 tcg_out_bundle(s
, miI
,
1659 tcg_opc_a4 (TCG_REG_P0
, OPC_ADDS_A4
,
1660 data_reg
, 0, TCG_REG_R8
));
1662 tcg_out_bundle(s
, miI
,
1665 tcg_opc_i29(TCG_REG_P0
, opc_ext_i29
[opc
& MO_SSIZE
],
1666 data_reg
, TCG_REG_R8
));
1670 /* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
1671 uintxx_t val, int mmu_idx) */
1672 static const void * const qemu_st_helpers
[4] = {
1679 static inline void tcg_out_qemu_st(TCGContext
*s
, const TCGArg
*args
,
1682 static const uint64_t opc_st_m4
[4] = {
1683 OPC_ST1_M4
, OPC_ST2_M4
, OPC_ST4_M4
, OPC_ST8_M4
1685 int addr_reg
, data_reg
, mem_index
;
1691 s_bits
= opc
& MO_SIZE
;
1693 tcg_out_qemu_tlb(s
, addr_reg
, s_bits
,
1694 offsetof(CPUArchState
, tlb_table
[mem_index
][0].addr_write
),
1695 offsetof(CPUArchState
, tlb_table
[mem_index
][0].addend
));
1697 /* P6 is the fast path, and P7 the slow path */
1698 tcg_out_bundle(s
, mLX
,
1699 tcg_opc_a4 (TCG_REG_P7
, OPC_ADDS_A4
,
1700 TCG_REG_R56
, 0, TCG_AREG0
),
1701 tcg_opc_l2 ((tcg_target_long
) qemu_st_helpers
[s_bits
]),
1702 tcg_opc_x2 (TCG_REG_P7
, OPC_MOVL_X2
, TCG_REG_R2
,
1703 (tcg_target_long
) qemu_st_helpers
[s_bits
]));
1704 tcg_out_bundle(s
, MmI
,
1705 tcg_opc_m3 (TCG_REG_P0
, OPC_LD8_M3
, TCG_REG_R3
,
1707 tcg_opc_a1 (TCG_REG_P6
, OPC_ADD_A1
, TCG_REG_R3
,
1708 TCG_REG_R3
, TCG_REG_R57
),
1709 tcg_opc_i21(TCG_REG_P7
, OPC_MOV_I21
, TCG_REG_B6
,
1717 tcg_out_bundle(s
, mii
,
1718 tcg_opc_m1 (TCG_REG_P7
, OPC_LD8_M1
,
1719 TCG_REG_R1
, TCG_REG_R2
),
1720 tcg_opc_a4 (TCG_REG_P7
, OPC_ADDS_A4
, TCG_REG_R58
,
1725 case MO_16
| MO_BSWAP
:
1726 tcg_out_bundle(s
, miI
,
1727 tcg_opc_m1 (TCG_REG_P7
, OPC_LD8_M1
,
1728 TCG_REG_R1
, TCG_REG_R2
),
1730 tcg_opc_i12(TCG_REG_P6
, OPC_DEP_Z_I12
,
1731 TCG_REG_R2
, data_reg
, 15, 15));
1732 tcg_out_bundle(s
, miI
,
1733 tcg_opc_a4 (TCG_REG_P7
, OPC_ADDS_A4
, TCG_REG_R58
,
1736 tcg_opc_i3 (TCG_REG_P6
, OPC_MUX1_I3
,
1737 TCG_REG_R2
, TCG_REG_R2
, 0xb));
1738 data_reg
= TCG_REG_R2
;
1741 case MO_32
| MO_BSWAP
:
1742 tcg_out_bundle(s
, miI
,
1743 tcg_opc_m1 (TCG_REG_P7
, OPC_LD8_M1
,
1744 TCG_REG_R1
, TCG_REG_R2
),
1746 tcg_opc_i12(TCG_REG_P6
, OPC_DEP_Z_I12
,
1747 TCG_REG_R2
, data_reg
, 31, 31));
1748 tcg_out_bundle(s
, miI
,
1749 tcg_opc_a4 (TCG_REG_P7
, OPC_ADDS_A4
, TCG_REG_R58
,
1752 tcg_opc_i3 (TCG_REG_P6
, OPC_MUX1_I3
,
1753 TCG_REG_R2
, TCG_REG_R2
, 0xb));
1754 data_reg
= TCG_REG_R2
;
1757 case MO_64
| MO_BSWAP
:
1758 tcg_out_bundle(s
, miI
,
1759 tcg_opc_m1 (TCG_REG_P7
, OPC_LD8_M1
,
1760 TCG_REG_R1
, TCG_REG_R2
),
1761 tcg_opc_a4 (TCG_REG_P7
, OPC_ADDS_A4
, TCG_REG_R58
,
1763 tcg_opc_i3 (TCG_REG_P6
, OPC_MUX1_I3
,
1764 TCG_REG_R2
, data_reg
, 0xb));
1765 data_reg
= TCG_REG_R2
;
1772 tcg_out_bundle(s
, miB
,
1773 tcg_opc_m4 (TCG_REG_P6
, opc_st_m4
[s_bits
],
1774 data_reg
, TCG_REG_R3
),
1775 tcg_opc_a5 (TCG_REG_P7
, OPC_ADDL_A5
, TCG_REG_R59
,
1776 mem_index
, TCG_REG_R0
),
1777 tcg_opc_b5 (TCG_REG_P7
, OPC_BR_CALL_SPTK_MANY_B5
,
1778 TCG_REG_B0
, TCG_REG_B6
));
1781 #else /* !CONFIG_SOFTMMU */
1783 static inline void tcg_out_qemu_ld(TCGContext
*s
, const TCGArg
*args
,
1786 static uint64_t const opc_ld_m1
[4] = {
1787 OPC_LD1_M1
, OPC_LD2_M1
, OPC_LD4_M1
, OPC_LD8_M1
1789 static uint64_t const opc_sxt_i29
[4] = {
1790 OPC_SXT1_I29
, OPC_SXT2_I29
, OPC_SXT4_I29
, 0
1792 int addr_reg
, data_reg
;
1793 TCGMemOp s_bits
, bswap
;
1797 s_bits
= opc
& MO_SIZE
;
1798 bswap
= opc
& MO_BSWAP
;
1800 #if TARGET_LONG_BITS == 32
1801 if (GUEST_BASE
!= 0) {
1802 tcg_out_bundle(s
, mII
,
1804 tcg_opc_i29(TCG_REG_P0
, OPC_ZXT4_I29
,
1805 TCG_REG_R3
, addr_reg
),
1806 tcg_opc_a1 (TCG_REG_P0
, OPC_ADD_A1
, TCG_REG_R2
,
1807 TCG_GUEST_BASE_REG
, TCG_REG_R3
));
1809 tcg_out_bundle(s
, miI
,
1811 tcg_opc_i29(TCG_REG_P0
, OPC_ZXT4_I29
,
1812 TCG_REG_R2
, addr_reg
),
1817 if (!(opc
& MO_SIGN
)) {
1818 tcg_out_bundle(s
, miI
,
1819 tcg_opc_m1 (TCG_REG_P0
, opc_ld_m1
[s_bits
],
1820 data_reg
, TCG_REG_R2
),
1824 tcg_out_bundle(s
, mII
,
1825 tcg_opc_m1 (TCG_REG_P0
, opc_ld_m1
[s_bits
],
1826 data_reg
, TCG_REG_R2
),
1828 tcg_opc_i29(TCG_REG_P0
, opc_sxt_i29
[s_bits
],
1829 data_reg
, data_reg
));
1831 } else if (s_bits
== MO_64
) {
1832 tcg_out_bundle(s
, mII
,
1833 tcg_opc_m1 (TCG_REG_P0
, opc_ld_m1
[s_bits
],
1834 data_reg
, TCG_REG_R2
),
1836 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
1837 data_reg
, data_reg
, 0xb));
1839 if (s_bits
== MO_16
) {
1840 tcg_out_bundle(s
, mII
,
1841 tcg_opc_m1 (TCG_REG_P0
, opc_ld_m1
[s_bits
],
1842 data_reg
, TCG_REG_R2
),
1844 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
,
1845 data_reg
, data_reg
, 15, 15));
1847 tcg_out_bundle(s
, mII
,
1848 tcg_opc_m1 (TCG_REG_P0
, opc_ld_m1
[s_bits
],
1849 data_reg
, TCG_REG_R2
),
1851 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
,
1852 data_reg
, data_reg
, 31, 31));
1854 if (!(opc
& MO_SIGN
)) {
1855 tcg_out_bundle(s
, miI
,
1858 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
1859 data_reg
, data_reg
, 0xb));
1861 tcg_out_bundle(s
, mII
,
1863 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
1864 data_reg
, data_reg
, 0xb),
1865 tcg_opc_i29(TCG_REG_P0
, opc_sxt_i29
[s_bits
],
1866 data_reg
, data_reg
));
1870 if (GUEST_BASE
!= 0) {
1871 tcg_out_bundle(s
, MmI
,
1872 tcg_opc_a1 (TCG_REG_P0
, OPC_ADD_A1
, TCG_REG_R2
,
1873 TCG_GUEST_BASE_REG
, addr_reg
),
1874 tcg_opc_m1 (TCG_REG_P0
, opc_ld_m1
[s_bits
],
1875 data_reg
, TCG_REG_R2
),
1878 tcg_out_bundle(s
, mmI
,
1880 tcg_opc_m1 (TCG_REG_P0
, opc_ld_m1
[s_bits
],
1881 data_reg
, addr_reg
),
1885 if (bswap
&& s_bits
== MO_16
) {
1886 tcg_out_bundle(s
, mII
,
1888 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
,
1889 data_reg
, data_reg
, 15, 15),
1890 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
1891 data_reg
, data_reg
, 0xb));
1892 } else if (bswap
&& s_bits
== MO_32
) {
1893 tcg_out_bundle(s
, mII
,
1895 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
,
1896 data_reg
, data_reg
, 31, 31),
1897 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
1898 data_reg
, data_reg
, 0xb));
1899 } else if (bswap
&& s_bits
== MO_64
) {
1900 tcg_out_bundle(s
, miI
,
1903 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
1904 data_reg
, data_reg
, 0xb));
1906 if (opc
& MO_SIGN
) {
1907 tcg_out_bundle(s
, miI
,
1910 tcg_opc_i29(TCG_REG_P0
, opc_sxt_i29
[s_bits
],
1911 data_reg
, data_reg
));
1916 static inline void tcg_out_qemu_st(TCGContext
*s
, const TCGArg
*args
,
1919 static uint64_t const opc_st_m4
[4] = {
1920 OPC_ST1_M4
, OPC_ST2_M4
, OPC_ST4_M4
, OPC_ST8_M4
1922 int addr_reg
, data_reg
;
1923 #if TARGET_LONG_BITS == 64
1924 uint64_t add_guest_base
;
1926 TCGMemOp s_bits
, bswap
;
1930 s_bits
= opc
& MO_SIZE
;
1931 bswap
= opc
& MO_BSWAP
;
1933 #if TARGET_LONG_BITS == 32
1934 if (GUEST_BASE
!= 0) {
1935 tcg_out_bundle(s
, mII
,
1937 tcg_opc_i29(TCG_REG_P0
, OPC_ZXT4_I29
,
1938 TCG_REG_R3
, addr_reg
),
1939 tcg_opc_a1 (TCG_REG_P0
, OPC_ADD_A1
, TCG_REG_R2
,
1940 TCG_GUEST_BASE_REG
, TCG_REG_R3
));
1942 tcg_out_bundle(s
, miI
,
1944 tcg_opc_i29(TCG_REG_P0
, OPC_ZXT4_I29
,
1945 TCG_REG_R2
, addr_reg
),
1950 if (s_bits
== MO_16
) {
1951 tcg_out_bundle(s
, mII
,
1953 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
,
1954 TCG_REG_R3
, data_reg
, 15, 15),
1955 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
1956 TCG_REG_R3
, TCG_REG_R3
, 0xb));
1957 data_reg
= TCG_REG_R3
;
1958 } else if (s_bits
== MO_32
) {
1959 tcg_out_bundle(s
, mII
,
1961 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
,
1962 TCG_REG_R3
, data_reg
, 31, 31),
1963 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
1964 TCG_REG_R3
, TCG_REG_R3
, 0xb));
1965 data_reg
= TCG_REG_R3
;
1966 } else if (s_bits
== MO_64
) {
1967 tcg_out_bundle(s
, miI
,
1970 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
1971 TCG_REG_R3
, data_reg
, 0xb));
1972 data_reg
= TCG_REG_R3
;
1975 tcg_out_bundle(s
, mmI
,
1976 tcg_opc_m4 (TCG_REG_P0
, opc_st_m4
[s_bits
],
1977 data_reg
, TCG_REG_R2
),
1981 if (GUEST_BASE
!= 0) {
1982 add_guest_base
= tcg_opc_a1 (TCG_REG_P0
, OPC_ADD_A1
, TCG_REG_R2
,
1983 TCG_GUEST_BASE_REG
, addr_reg
);
1984 addr_reg
= TCG_REG_R2
;
1986 add_guest_base
= INSN_NOP_M
;
1990 tcg_out_bundle(s
, (GUEST_BASE
? MmI
: mmI
),
1992 tcg_opc_m4 (TCG_REG_P0
, opc_st_m4
[s_bits
],
1993 data_reg
, addr_reg
),
1996 if (s_bits
== MO_16
) {
1997 tcg_out_bundle(s
, mII
,
1999 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
,
2000 TCG_REG_R3
, data_reg
, 15, 15),
2001 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
2002 TCG_REG_R3
, TCG_REG_R3
, 0xb));
2003 data_reg
= TCG_REG_R3
;
2004 } else if (s_bits
== MO_32
) {
2005 tcg_out_bundle(s
, mII
,
2007 tcg_opc_i12(TCG_REG_P0
, OPC_DEP_Z_I12
,
2008 TCG_REG_R3
, data_reg
, 31, 31),
2009 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
2010 TCG_REG_R3
, TCG_REG_R3
, 0xb));
2011 data_reg
= TCG_REG_R3
;
2012 } else if (s_bits
== MO_64
) {
2013 tcg_out_bundle(s
, miI
,
2016 tcg_opc_i3 (TCG_REG_P0
, OPC_MUX1_I3
,
2017 TCG_REG_R3
, data_reg
, 0xb));
2018 data_reg
= TCG_REG_R3
;
2020 tcg_out_bundle(s
, miI
,
2021 tcg_opc_m4 (TCG_REG_P0
, opc_st_m4
[s_bits
],
2022 data_reg
, addr_reg
),
2031 static inline void tcg_out_op(TCGContext
*s
, TCGOpcode opc
,
2032 const TCGArg
*args
, const int *const_args
)
2035 case INDEX_op_exit_tb
:
2036 tcg_out_exit_tb(s
, args
[0]);
2039 tcg_out_br(s
, args
[0]);
2042 if (likely(const_args
[0])) {
2043 tcg_out_calli(s
, args
[0]);
2045 tcg_out_callr(s
, args
[0]);
2048 case INDEX_op_goto_tb
:
2049 tcg_out_goto_tb(s
, args
[0]);
2052 case INDEX_op_movi_i32
:
2053 tcg_out_movi(s
, TCG_TYPE_I32
, args
[0], args
[1]);
2055 case INDEX_op_movi_i64
:
2056 tcg_out_movi(s
, TCG_TYPE_I64
, args
[0], args
[1]);
2059 case INDEX_op_ld8u_i32
:
2060 case INDEX_op_ld8u_i64
:
2061 tcg_out_ld_rel(s
, OPC_LD1_M1
, args
[0], args
[1], args
[2]);
2063 case INDEX_op_ld8s_i32
:
2064 case INDEX_op_ld8s_i64
:
2065 tcg_out_ld_rel(s
, OPC_LD1_M1
, args
[0], args
[1], args
[2]);
2066 tcg_out_ext(s
, OPC_SXT1_I29
, args
[0], args
[0]);
2068 case INDEX_op_ld16u_i32
:
2069 case INDEX_op_ld16u_i64
:
2070 tcg_out_ld_rel(s
, OPC_LD2_M1
, args
[0], args
[1], args
[2]);
2072 case INDEX_op_ld16s_i32
:
2073 case INDEX_op_ld16s_i64
:
2074 tcg_out_ld_rel(s
, OPC_LD2_M1
, args
[0], args
[1], args
[2]);
2075 tcg_out_ext(s
, OPC_SXT2_I29
, args
[0], args
[0]);
2077 case INDEX_op_ld_i32
:
2078 case INDEX_op_ld32u_i64
:
2079 tcg_out_ld_rel(s
, OPC_LD4_M1
, args
[0], args
[1], args
[2]);
2081 case INDEX_op_ld32s_i64
:
2082 tcg_out_ld_rel(s
, OPC_LD4_M1
, args
[0], args
[1], args
[2]);
2083 tcg_out_ext(s
, OPC_SXT4_I29
, args
[0], args
[0]);
2085 case INDEX_op_ld_i64
:
2086 tcg_out_ld_rel(s
, OPC_LD8_M1
, args
[0], args
[1], args
[2]);
2088 case INDEX_op_st8_i32
:
2089 case INDEX_op_st8_i64
:
2090 tcg_out_st_rel(s
, OPC_ST1_M4
, args
[0], args
[1], args
[2]);
2092 case INDEX_op_st16_i32
:
2093 case INDEX_op_st16_i64
:
2094 tcg_out_st_rel(s
, OPC_ST2_M4
, args
[0], args
[1], args
[2]);
2096 case INDEX_op_st_i32
:
2097 case INDEX_op_st32_i64
:
2098 tcg_out_st_rel(s
, OPC_ST4_M4
, args
[0], args
[1], args
[2]);
2100 case INDEX_op_st_i64
:
2101 tcg_out_st_rel(s
, OPC_ST8_M4
, args
[0], args
[1], args
[2]);
2104 case INDEX_op_add_i32
:
2105 case INDEX_op_add_i64
:
2106 tcg_out_add(s
, args
[0], args
[1], args
[2], const_args
[2]);
2108 case INDEX_op_sub_i32
:
2109 case INDEX_op_sub_i64
:
2110 tcg_out_sub(s
, args
[0], args
[1], const_args
[1], args
[2], const_args
[2]);
2113 case INDEX_op_and_i32
:
2114 case INDEX_op_and_i64
:
2115 tcg_out_alu(s
, OPC_AND_A1
, args
[0], args
[1], const_args
[1],
2116 args
[2], const_args
[2]);
2118 case INDEX_op_andc_i32
:
2119 case INDEX_op_andc_i64
:
2120 tcg_out_alu(s
, OPC_ANDCM_A1
, args
[0], args
[1], const_args
[1],
2121 args
[2], const_args
[2]);
2123 case INDEX_op_eqv_i32
:
2124 case INDEX_op_eqv_i64
:
2125 tcg_out_eqv(s
, args
[0], args
[1], const_args
[1],
2126 args
[2], const_args
[2]);
2128 case INDEX_op_nand_i32
:
2129 case INDEX_op_nand_i64
:
2130 tcg_out_nand(s
, args
[0], args
[1], const_args
[1],
2131 args
[2], const_args
[2]);
2133 case INDEX_op_nor_i32
:
2134 case INDEX_op_nor_i64
:
2135 tcg_out_nor(s
, args
[0], args
[1], const_args
[1],
2136 args
[2], const_args
[2]);
2138 case INDEX_op_or_i32
:
2139 case INDEX_op_or_i64
:
2140 tcg_out_alu(s
, OPC_OR_A1
, args
[0], args
[1], const_args
[1],
2141 args
[2], const_args
[2]);
2143 case INDEX_op_orc_i32
:
2144 case INDEX_op_orc_i64
:
2145 tcg_out_orc(s
, args
[0], args
[1], const_args
[1],
2146 args
[2], const_args
[2]);
2148 case INDEX_op_xor_i32
:
2149 case INDEX_op_xor_i64
:
2150 tcg_out_alu(s
, OPC_XOR_A1
, args
[0], args
[1], const_args
[1],
2151 args
[2], const_args
[2]);
2154 case INDEX_op_mul_i32
:
2155 case INDEX_op_mul_i64
:
2156 tcg_out_mul(s
, args
[0], args
[1], args
[2]);
2159 case INDEX_op_sar_i32
:
2160 tcg_out_sar_i32(s
, args
[0], args
[1], args
[2], const_args
[2]);
2162 case INDEX_op_sar_i64
:
2163 tcg_out_sar_i64(s
, args
[0], args
[1], args
[2], const_args
[2]);
2165 case INDEX_op_shl_i32
:
2166 tcg_out_shl_i32(s
, args
[0], args
[1], args
[2], const_args
[2]);
2168 case INDEX_op_shl_i64
:
2169 tcg_out_shl_i64(s
, args
[0], args
[1], args
[2], const_args
[2]);
2171 case INDEX_op_shr_i32
:
2172 tcg_out_shr_i32(s
, args
[0], args
[1], args
[2], const_args
[2]);
2174 case INDEX_op_shr_i64
:
2175 tcg_out_shr_i64(s
, args
[0], args
[1], args
[2], const_args
[2]);
2177 case INDEX_op_rotl_i32
:
2178 tcg_out_rotl_i32(s
, args
[0], args
[1], args
[2], const_args
[2]);
2180 case INDEX_op_rotl_i64
:
2181 tcg_out_rotl_i64(s
, args
[0], args
[1], args
[2], const_args
[2]);
2183 case INDEX_op_rotr_i32
:
2184 tcg_out_rotr_i32(s
, args
[0], args
[1], args
[2], const_args
[2]);
2186 case INDEX_op_rotr_i64
:
2187 tcg_out_rotr_i64(s
, args
[0], args
[1], args
[2], const_args
[2]);
2190 case INDEX_op_ext8s_i32
:
2191 case INDEX_op_ext8s_i64
:
2192 tcg_out_ext(s
, OPC_SXT1_I29
, args
[0], args
[1]);
2194 case INDEX_op_ext8u_i32
:
2195 case INDEX_op_ext8u_i64
:
2196 tcg_out_ext(s
, OPC_ZXT1_I29
, args
[0], args
[1]);
2198 case INDEX_op_ext16s_i32
:
2199 case INDEX_op_ext16s_i64
:
2200 tcg_out_ext(s
, OPC_SXT2_I29
, args
[0], args
[1]);
2202 case INDEX_op_ext16u_i32
:
2203 case INDEX_op_ext16u_i64
:
2204 tcg_out_ext(s
, OPC_ZXT2_I29
, args
[0], args
[1]);
2206 case INDEX_op_ext32s_i64
:
2207 tcg_out_ext(s
, OPC_SXT4_I29
, args
[0], args
[1]);
2209 case INDEX_op_ext32u_i64
:
2210 tcg_out_ext(s
, OPC_ZXT4_I29
, args
[0], args
[1]);
2213 case INDEX_op_bswap16_i32
:
2214 case INDEX_op_bswap16_i64
:
2215 tcg_out_bswap16(s
, args
[0], args
[1]);
2217 case INDEX_op_bswap32_i32
:
2218 case INDEX_op_bswap32_i64
:
2219 tcg_out_bswap32(s
, args
[0], args
[1]);
2221 case INDEX_op_bswap64_i64
:
2222 tcg_out_bswap64(s
, args
[0], args
[1]);
2225 case INDEX_op_deposit_i32
:
2226 case INDEX_op_deposit_i64
:
2227 tcg_out_deposit(s
, args
[0], args
[1], args
[2], const_args
[2],
2231 case INDEX_op_brcond_i32
:
2232 tcg_out_brcond(s
, args
[2], args
[0], args
[1], args
[3], 1);
2234 case INDEX_op_brcond_i64
:
2235 tcg_out_brcond(s
, args
[2], args
[0], args
[1], args
[3], 0);
2237 case INDEX_op_setcond_i32
:
2238 tcg_out_setcond(s
, args
[3], args
[0], args
[1], args
[2], 1);
2240 case INDEX_op_setcond_i64
:
2241 tcg_out_setcond(s
, args
[3], args
[0], args
[1], args
[2], 0);
2243 case INDEX_op_movcond_i32
:
2244 tcg_out_movcond(s
, args
[5], args
[0], args
[1], args
[2],
2245 args
[3], const_args
[3], args
[4], const_args
[4], 1);
2247 case INDEX_op_movcond_i64
:
2248 tcg_out_movcond(s
, args
[5], args
[0], args
[1], args
[2],
2249 args
[3], const_args
[3], args
[4], const_args
[4], 0);
2252 case INDEX_op_qemu_ld8u
:
2253 tcg_out_qemu_ld(s
, args
, MO_UB
);
2255 case INDEX_op_qemu_ld8s
:
2256 tcg_out_qemu_ld(s
, args
, MO_SB
);
2258 case INDEX_op_qemu_ld16u
:
2259 tcg_out_qemu_ld(s
, args
, MO_TEUW
);
2261 case INDEX_op_qemu_ld16s
:
2262 tcg_out_qemu_ld(s
, args
, MO_TESW
);
2264 case INDEX_op_qemu_ld32
:
2265 case INDEX_op_qemu_ld32u
:
2266 tcg_out_qemu_ld(s
, args
, MO_TEUL
);
2268 case INDEX_op_qemu_ld32s
:
2269 tcg_out_qemu_ld(s
, args
, MO_TESL
);
2271 case INDEX_op_qemu_ld64
:
2272 tcg_out_qemu_ld(s
, args
, MO_TEQ
);
2275 case INDEX_op_qemu_st8
:
2276 tcg_out_qemu_st(s
, args
, MO_UB
);
2278 case INDEX_op_qemu_st16
:
2279 tcg_out_qemu_st(s
, args
, MO_TEUW
);
2281 case INDEX_op_qemu_st32
:
2282 tcg_out_qemu_st(s
, args
, MO_TEUL
);
2284 case INDEX_op_qemu_st64
:
2285 tcg_out_qemu_st(s
, args
, MO_TEQ
);
2293 static const TCGTargetOpDef ia64_op_defs
[] = {
2294 { INDEX_op_br
, { } },
2295 { INDEX_op_call
, { "ri" } },
2296 { INDEX_op_exit_tb
, { } },
2297 { INDEX_op_goto_tb
, { } },
2299 { INDEX_op_mov_i32
, { "r", "r" } },
2300 { INDEX_op_movi_i32
, { "r" } },
2302 { INDEX_op_ld8u_i32
, { "r", "r" } },
2303 { INDEX_op_ld8s_i32
, { "r", "r" } },
2304 { INDEX_op_ld16u_i32
, { "r", "r" } },
2305 { INDEX_op_ld16s_i32
, { "r", "r" } },
2306 { INDEX_op_ld_i32
, { "r", "r" } },
2307 { INDEX_op_st8_i32
, { "rZ", "r" } },
2308 { INDEX_op_st16_i32
, { "rZ", "r" } },
2309 { INDEX_op_st_i32
, { "rZ", "r" } },
2311 { INDEX_op_add_i32
, { "r", "rZ", "rI" } },
2312 { INDEX_op_sub_i32
, { "r", "rI", "rI" } },
2314 { INDEX_op_and_i32
, { "r", "rI", "rI" } },
2315 { INDEX_op_andc_i32
, { "r", "rI", "rI" } },
2316 { INDEX_op_eqv_i32
, { "r", "rZ", "rZ" } },
2317 { INDEX_op_nand_i32
, { "r", "rZ", "rZ" } },
2318 { INDEX_op_nor_i32
, { "r", "rZ", "rZ" } },
2319 { INDEX_op_or_i32
, { "r", "rI", "rI" } },
2320 { INDEX_op_orc_i32
, { "r", "rZ", "rZ" } },
2321 { INDEX_op_xor_i32
, { "r", "rI", "rI" } },
2323 { INDEX_op_mul_i32
, { "r", "rZ", "rZ" } },
2325 { INDEX_op_sar_i32
, { "r", "rZ", "ri" } },
2326 { INDEX_op_shl_i32
, { "r", "rZ", "ri" } },
2327 { INDEX_op_shr_i32
, { "r", "rZ", "ri" } },
2328 { INDEX_op_rotl_i32
, { "r", "rZ", "ri" } },
2329 { INDEX_op_rotr_i32
, { "r", "rZ", "ri" } },
2331 { INDEX_op_ext8s_i32
, { "r", "rZ"} },
2332 { INDEX_op_ext8u_i32
, { "r", "rZ"} },
2333 { INDEX_op_ext16s_i32
, { "r", "rZ"} },
2334 { INDEX_op_ext16u_i32
, { "r", "rZ"} },
2336 { INDEX_op_bswap16_i32
, { "r", "rZ" } },
2337 { INDEX_op_bswap32_i32
, { "r", "rZ" } },
2339 { INDEX_op_brcond_i32
, { "rZ", "rZ" } },
2340 { INDEX_op_setcond_i32
, { "r", "rZ", "rZ" } },
2341 { INDEX_op_movcond_i32
, { "r", "rZ", "rZ", "rI", "rI" } },
2343 { INDEX_op_mov_i64
, { "r", "r" } },
2344 { INDEX_op_movi_i64
, { "r" } },
2346 { INDEX_op_ld8u_i64
, { "r", "r" } },
2347 { INDEX_op_ld8s_i64
, { "r", "r" } },
2348 { INDEX_op_ld16u_i64
, { "r", "r" } },
2349 { INDEX_op_ld16s_i64
, { "r", "r" } },
2350 { INDEX_op_ld32u_i64
, { "r", "r" } },
2351 { INDEX_op_ld32s_i64
, { "r", "r" } },
2352 { INDEX_op_ld_i64
, { "r", "r" } },
2353 { INDEX_op_st8_i64
, { "rZ", "r" } },
2354 { INDEX_op_st16_i64
, { "rZ", "r" } },
2355 { INDEX_op_st32_i64
, { "rZ", "r" } },
2356 { INDEX_op_st_i64
, { "rZ", "r" } },
2358 { INDEX_op_add_i64
, { "r", "rZ", "rI" } },
2359 { INDEX_op_sub_i64
, { "r", "rI", "rI" } },
2361 { INDEX_op_and_i64
, { "r", "rI", "rI" } },
2362 { INDEX_op_andc_i64
, { "r", "rI", "rI" } },
2363 { INDEX_op_eqv_i64
, { "r", "rZ", "rZ" } },
2364 { INDEX_op_nand_i64
, { "r", "rZ", "rZ" } },
2365 { INDEX_op_nor_i64
, { "r", "rZ", "rZ" } },
2366 { INDEX_op_or_i64
, { "r", "rI", "rI" } },
2367 { INDEX_op_orc_i64
, { "r", "rZ", "rZ" } },
2368 { INDEX_op_xor_i64
, { "r", "rI", "rI" } },
2370 { INDEX_op_mul_i64
, { "r", "rZ", "rZ" } },
2372 { INDEX_op_sar_i64
, { "r", "rZ", "ri" } },
2373 { INDEX_op_shl_i64
, { "r", "rZ", "ri" } },
2374 { INDEX_op_shr_i64
, { "r", "rZ", "ri" } },
2375 { INDEX_op_rotl_i64
, { "r", "rZ", "ri" } },
2376 { INDEX_op_rotr_i64
, { "r", "rZ", "ri" } },
2378 { INDEX_op_ext8s_i64
, { "r", "rZ"} },
2379 { INDEX_op_ext8u_i64
, { "r", "rZ"} },
2380 { INDEX_op_ext16s_i64
, { "r", "rZ"} },
2381 { INDEX_op_ext16u_i64
, { "r", "rZ"} },
2382 { INDEX_op_ext32s_i64
, { "r", "rZ"} },
2383 { INDEX_op_ext32u_i64
, { "r", "rZ"} },
2385 { INDEX_op_bswap16_i64
, { "r", "rZ" } },
2386 { INDEX_op_bswap32_i64
, { "r", "rZ" } },
2387 { INDEX_op_bswap64_i64
, { "r", "rZ" } },
2389 { INDEX_op_brcond_i64
, { "rZ", "rZ" } },
2390 { INDEX_op_setcond_i64
, { "r", "rZ", "rZ" } },
2391 { INDEX_op_movcond_i64
, { "r", "rZ", "rZ", "rI", "rI" } },
2393 { INDEX_op_deposit_i32
, { "r", "rZ", "ri" } },
2394 { INDEX_op_deposit_i64
, { "r", "rZ", "ri" } },
2396 { INDEX_op_qemu_ld8u
, { "r", "r" } },
2397 { INDEX_op_qemu_ld8s
, { "r", "r" } },
2398 { INDEX_op_qemu_ld16u
, { "r", "r" } },
2399 { INDEX_op_qemu_ld16s
, { "r", "r" } },
2400 { INDEX_op_qemu_ld32
, { "r", "r" } },
2401 { INDEX_op_qemu_ld32u
, { "r", "r" } },
2402 { INDEX_op_qemu_ld32s
, { "r", "r" } },
2403 { INDEX_op_qemu_ld64
, { "r", "r" } },
2405 { INDEX_op_qemu_st8
, { "SZ", "r" } },
2406 { INDEX_op_qemu_st16
, { "SZ", "r" } },
2407 { INDEX_op_qemu_st32
, { "SZ", "r" } },
2408 { INDEX_op_qemu_st64
, { "SZ", "r" } },
2413 /* Generate global QEMU prologue and epilogue code */
2414 static void tcg_target_qemu_prologue(TCGContext
*s
)
2418 /* reserve some stack space */
2419 frame_size
= TCG_STATIC_CALL_ARGS_SIZE
+
2420 CPU_TEMP_BUF_NLONGS
* sizeof(long);
2421 frame_size
= (frame_size
+ TCG_TARGET_STACK_ALIGN
- 1) &
2422 ~(TCG_TARGET_STACK_ALIGN
- 1);
2423 tcg_set_frame(s
, TCG_REG_CALL_STACK
, TCG_STATIC_CALL_ARGS_SIZE
,
2424 CPU_TEMP_BUF_NLONGS
* sizeof(long));
2426 /* First emit adhoc function descriptor */
2427 *(uint64_t *)(s
->code_ptr
) = (uint64_t)s
->code_ptr
+ 16; /* entry point */
2428 s
->code_ptr
+= 16; /* skip GP */
2431 tcg_out_bundle(s
, miI
,
2432 tcg_opc_m34(TCG_REG_P0
, OPC_ALLOC_M34
,
2433 TCG_REG_R34
, 32, 24, 0),
2435 tcg_opc_i21(TCG_REG_P0
, OPC_MOV_I21
,
2436 TCG_REG_B6
, TCG_REG_R33
, 0));
2438 /* ??? If GUEST_BASE < 0x200000, we could load the register via
2439 an ADDL in the M slot of the next bundle. */
2440 if (GUEST_BASE
!= 0) {
2441 tcg_out_bundle(s
, mlx
,
2443 tcg_opc_l2 (GUEST_BASE
),
2444 tcg_opc_x2 (TCG_REG_P0
, OPC_MOVL_X2
,
2445 TCG_GUEST_BASE_REG
, GUEST_BASE
));
2446 tcg_regset_set_reg(s
->reserved_regs
, TCG_GUEST_BASE_REG
);
2449 tcg_out_bundle(s
, miB
,
2450 tcg_opc_a4 (TCG_REG_P0
, OPC_ADDS_A4
,
2451 TCG_REG_R12
, -frame_size
, TCG_REG_R12
),
2452 tcg_opc_i22(TCG_REG_P0
, OPC_MOV_I22
,
2453 TCG_REG_R33
, TCG_REG_B0
),
2454 tcg_opc_b4 (TCG_REG_P0
, OPC_BR_SPTK_MANY_B4
, TCG_REG_B6
));
2457 tb_ret_addr
= s
->code_ptr
;
2458 tcg_out_bundle(s
, miI
,
2460 tcg_opc_i21(TCG_REG_P0
, OPC_MOV_I21
,
2461 TCG_REG_B0
, TCG_REG_R33
, 0),
2462 tcg_opc_a4 (TCG_REG_P0
, OPC_ADDS_A4
,
2463 TCG_REG_R12
, frame_size
, TCG_REG_R12
));
2464 tcg_out_bundle(s
, miB
,
2466 tcg_opc_i26(TCG_REG_P0
, OPC_MOV_I_I26
,
2467 TCG_REG_PFS
, TCG_REG_R34
),
2468 tcg_opc_b4 (TCG_REG_P0
, OPC_BR_RET_SPTK_MANY_B4
,
2472 static void tcg_target_init(TCGContext
*s
)
2474 tcg_regset_set(tcg_target_available_regs
[TCG_TYPE_I32
],
2475 0xffffffffffffffffull
);
2476 tcg_regset_set(tcg_target_available_regs
[TCG_TYPE_I64
],
2477 0xffffffffffffffffull
);
2479 tcg_regset_clear(tcg_target_call_clobber_regs
);
2480 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R8
);
2481 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R9
);
2482 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R10
);
2483 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R11
);
2484 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R14
);
2485 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R15
);
2486 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R16
);
2487 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R17
);
2488 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R18
);
2489 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R19
);
2490 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R20
);
2491 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R21
);
2492 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R22
);
2493 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R23
);
2494 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R24
);
2495 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R25
);
2496 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R26
);
2497 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R27
);
2498 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R28
);
2499 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R29
);
2500 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R30
);
2501 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R31
);
2502 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R56
);
2503 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R57
);
2504 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R58
);
2505 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R59
);
2506 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R60
);
2507 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R61
);
2508 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R62
);
2509 tcg_regset_set_reg(tcg_target_call_clobber_regs
, TCG_REG_R63
);
2511 tcg_regset_clear(s
->reserved_regs
);
2512 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R0
); /* zero register */
2513 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R1
); /* global pointer */
2514 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R2
); /* internal use */
2515 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R3
); /* internal use */
2516 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R12
); /* stack pointer */
2517 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R13
); /* thread pointer */
2518 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R33
); /* return address */
2519 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R34
); /* PFS */
2521 /* The following 4 are not in use, are call-saved, but *not* saved
2522 by the prologue. Therefore we cannot use them without modifying
2523 the prologue. There doesn't seem to be any good reason to use
2524 these as opposed to the windowed registers. */
2525 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R4
);
2526 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R5
);
2527 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R6
);
2528 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_R7
);
2530 tcg_add_target_add_op_defs(ia64_op_defs
);