2 * Tiny Code Generator for QEMU
4 * Copyright (c) 2008 Fabrice Bellard
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
25 #define TCG_CT_CONST_S16 0x100
26 #define TCG_CT_CONST_U16 0x200
27 #define TCG_CT_CONST_S32 0x400
28 #define TCG_CT_CONST_U32 0x800
29 #define TCG_CT_CONST_ZERO 0x1000
31 static uint8_t *tb_ret_addr
;
35 #if TARGET_LONG_BITS == 32
47 #ifdef CONFIG_GETAUXVAL
49 static bool have_isa_2_06
;
50 #define HAVE_ISA_2_06 have_isa_2_06
51 #define HAVE_ISEL have_isa_2_06
53 #define HAVE_ISA_2_06 0
57 #ifdef CONFIG_USE_GUEST_BASE
58 #define TCG_GUEST_BASE_REG 30
60 #define TCG_GUEST_BASE_REG 0
64 static const char * const tcg_target_reg_names
[TCG_TARGET_NB_REGS
] = {
100 static const int tcg_target_reg_alloc_order
[] = {
136 static const int tcg_target_call_iarg_regs
[] = {
147 static const int tcg_target_call_oarg_regs
[] = {
151 static const int tcg_target_callee_save_regs
[] = {
168 TCG_REG_R27
, /* currently used for the global env */
175 static uint32_t reloc_pc24_val (void *pc
, tcg_target_long target
)
177 tcg_target_long disp
;
179 disp
= target
- (tcg_target_long
) pc
;
180 if ((disp
<< 38) >> 38 != disp
)
183 return disp
& 0x3fffffc;
186 static void reloc_pc24 (void *pc
, tcg_target_long target
)
188 *(uint32_t *) pc
= (*(uint32_t *) pc
& ~0x3fffffc)
189 | reloc_pc24_val (pc
, target
);
192 static uint16_t reloc_pc14_val (void *pc
, tcg_target_long target
)
194 tcg_target_long disp
;
196 disp
= target
- (tcg_target_long
) pc
;
197 if (disp
!= (int16_t) disp
)
200 return disp
& 0xfffc;
203 static void reloc_pc14 (void *pc
, tcg_target_long target
)
205 *(uint32_t *) pc
= (*(uint32_t *) pc
& ~0xfffc)
206 | reloc_pc14_val (pc
, target
);
209 static void patch_reloc (uint8_t *code_ptr
, int type
,
210 tcg_target_long value
, tcg_target_long addend
)
215 reloc_pc14 (code_ptr
, value
);
218 reloc_pc24 (code_ptr
, value
);
225 /* parse target specific constraints */
226 static int target_parse_constraint (TCGArgConstraint
*ct
, const char **pct_str
)
232 case 'A': case 'B': case 'C': case 'D':
233 ct
->ct
|= TCG_CT_REG
;
234 tcg_regset_set_reg (ct
->u
.regs
, 3 + ct_str
[0] - 'A');
237 ct
->ct
|= TCG_CT_REG
;
238 tcg_regset_set32 (ct
->u
.regs
, 0, 0xffffffff);
240 case 'L': /* qemu_ld constraint */
241 ct
->ct
|= TCG_CT_REG
;
242 tcg_regset_set32 (ct
->u
.regs
, 0, 0xffffffff);
243 tcg_regset_reset_reg (ct
->u
.regs
, TCG_REG_R3
);
244 #ifdef CONFIG_SOFTMMU
245 tcg_regset_reset_reg (ct
->u
.regs
, TCG_REG_R4
);
246 tcg_regset_reset_reg (ct
->u
.regs
, TCG_REG_R5
);
249 case 'S': /* qemu_st constraint */
250 ct
->ct
|= TCG_CT_REG
;
251 tcg_regset_set32 (ct
->u
.regs
, 0, 0xffffffff);
252 tcg_regset_reset_reg (ct
->u
.regs
, TCG_REG_R3
);
253 #ifdef CONFIG_SOFTMMU
254 tcg_regset_reset_reg (ct
->u
.regs
, TCG_REG_R4
);
255 tcg_regset_reset_reg (ct
->u
.regs
, TCG_REG_R5
);
256 tcg_regset_reset_reg (ct
->u
.regs
, TCG_REG_R6
);
260 ct
->ct
|= TCG_CT_CONST_S16
;
263 ct
->ct
|= TCG_CT_CONST_U16
;
266 ct
->ct
|= TCG_CT_CONST_S32
;
269 ct
->ct
|= TCG_CT_CONST_U32
;
272 ct
->ct
|= TCG_CT_CONST_ZERO
;
282 /* test if a constant matches the constraint */
283 static int tcg_target_const_match (tcg_target_long val
,
284 const TCGArgConstraint
*arg_ct
)
287 if (ct
& TCG_CT_CONST
) {
289 } else if ((ct
& TCG_CT_CONST_S16
) && val
== (int16_t)val
) {
291 } else if ((ct
& TCG_CT_CONST_U16
) && val
== (uint16_t)val
) {
293 } else if ((ct
& TCG_CT_CONST_S32
) && val
== (int32_t)val
) {
295 } else if ((ct
& TCG_CT_CONST_U32
) && val
== (uint32_t)val
) {
297 } else if ((ct
& TCG_CT_CONST_ZERO
) && val
== 0) {
303 #define OPCD(opc) ((opc)<<26)
304 #define XO19(opc) (OPCD(19)|((opc)<<1))
305 #define XO30(opc) (OPCD(30)|((opc)<<2))
306 #define XO31(opc) (OPCD(31)|((opc)<<1))
307 #define XO58(opc) (OPCD(58)|(opc))
308 #define XO62(opc) (OPCD(62)|(opc))
312 #define LBZ OPCD( 34)
313 #define LHZ OPCD( 40)
314 #define LHA OPCD( 42)
315 #define LWZ OPCD( 32)
316 #define STB OPCD( 38)
317 #define STH OPCD( 44)
318 #define STW OPCD( 36)
321 #define STDU XO62( 1)
322 #define STDX XO31(149)
325 #define LDX XO31( 21)
328 #define LWAX XO31(341)
330 #define ADDIC OPCD( 12)
331 #define ADDI OPCD( 14)
332 #define ADDIS OPCD( 15)
333 #define ORI OPCD( 24)
334 #define ORIS OPCD( 25)
335 #define XORI OPCD( 26)
336 #define XORIS OPCD( 27)
337 #define ANDI OPCD( 28)
338 #define ANDIS OPCD( 29)
339 #define MULLI OPCD( 7)
340 #define CMPLI OPCD( 10)
341 #define CMPI OPCD( 11)
342 #define SUBFIC OPCD( 8)
344 #define LWZU OPCD( 33)
345 #define STWU OPCD( 37)
347 #define RLWIMI OPCD( 20)
348 #define RLWINM OPCD( 21)
349 #define RLWNM OPCD( 23)
351 #define RLDICL XO30( 0)
352 #define RLDICR XO30( 1)
353 #define RLDIMI XO30( 3)
354 #define RLDCL XO30( 8)
356 #define BCLR XO19( 16)
357 #define BCCTR XO19(528)
358 #define CRAND XO19(257)
359 #define CRANDC XO19(129)
360 #define CRNAND XO19(225)
361 #define CROR XO19(449)
362 #define CRNOR XO19( 33)
364 #define EXTSB XO31(954)
365 #define EXTSH XO31(922)
366 #define EXTSW XO31(986)
367 #define ADD XO31(266)
368 #define ADDE XO31(138)
369 #define ADDC XO31( 10)
370 #define AND XO31( 28)
371 #define SUBF XO31( 40)
372 #define SUBFC XO31( 8)
373 #define SUBFE XO31(136)
375 #define XOR XO31(316)
376 #define MULLW XO31(235)
377 #define MULHWU XO31( 11)
378 #define DIVW XO31(491)
379 #define DIVWU XO31(459)
381 #define CMPL XO31( 32)
382 #define LHBRX XO31(790)
383 #define LWBRX XO31(534)
384 #define LDBRX XO31(532)
385 #define STHBRX XO31(918)
386 #define STWBRX XO31(662)
387 #define STDBRX XO31(660)
388 #define MFSPR XO31(339)
389 #define MTSPR XO31(467)
390 #define SRAWI XO31(824)
391 #define NEG XO31(104)
392 #define MFCR XO31( 19)
393 #define MFOCRF (MFCR | (1u << 20))
394 #define NOR XO31(124)
395 #define CNTLZW XO31( 26)
396 #define CNTLZD XO31( 58)
397 #define ANDC XO31( 60)
398 #define ORC XO31(412)
399 #define EQV XO31(284)
400 #define NAND XO31(476)
401 #define ISEL XO31( 15)
403 #define MULLD XO31(233)
404 #define MULHD XO31( 73)
405 #define MULHDU XO31( 9)
406 #define DIVD XO31(489)
407 #define DIVDU XO31(457)
409 #define LBZX XO31( 87)
410 #define LHZX XO31(279)
411 #define LHAX XO31(343)
412 #define LWZX XO31( 23)
413 #define STBX XO31(215)
414 #define STHX XO31(407)
415 #define STWX XO31(151)
417 #define SPR(a,b) ((((a)<<5)|(b))<<11)
419 #define CTR SPR(9, 0)
421 #define SLW XO31( 24)
422 #define SRW XO31(536)
423 #define SRAW XO31(792)
425 #define SLD XO31( 27)
426 #define SRD XO31(539)
427 #define SRAD XO31(794)
428 #define SRADI XO31(413<<1)
431 #define TRAP (TW | TO (31))
433 #define RT(r) ((r)<<21)
434 #define RS(r) ((r)<<21)
435 #define RA(r) ((r)<<16)
436 #define RB(r) ((r)<<11)
437 #define TO(t) ((t)<<21)
438 #define SH(s) ((s)<<11)
439 #define MB(b) ((b)<<6)
440 #define ME(e) ((e)<<1)
441 #define BO(o) ((o)<<21)
442 #define MB64(b) ((b)<<5)
443 #define FXM(b) (1 << (19 - (b)))
447 #define TAB(t, a, b) (RT(t) | RA(a) | RB(b))
448 #define SAB(s, a, b) (RS(s) | RA(a) | RB(b))
449 #define TAI(s, a, i) (RT(s) | RA(a) | ((i) & 0xffff))
450 #define SAI(s, a, i) (RS(s) | RA(a) | ((i) & 0xffff))
452 #define BF(n) ((n)<<23)
453 #define BI(n, c) (((c)+((n)*4))<<16)
454 #define BT(n, c) (((c)+((n)*4))<<21)
455 #define BA(n, c) (((c)+((n)*4))<<16)
456 #define BB(n, c) (((c)+((n)*4))<<11)
457 #define BC_(n, c) (((c)+((n)*4))<<6)
459 #define BO_COND_TRUE BO (12)
460 #define BO_COND_FALSE BO ( 4)
461 #define BO_ALWAYS BO (20)
470 static const uint32_t tcg_to_bc
[] = {
471 [TCG_COND_EQ
] = BC
| BI (7, CR_EQ
) | BO_COND_TRUE
,
472 [TCG_COND_NE
] = BC
| BI (7, CR_EQ
) | BO_COND_FALSE
,
473 [TCG_COND_LT
] = BC
| BI (7, CR_LT
) | BO_COND_TRUE
,
474 [TCG_COND_GE
] = BC
| BI (7, CR_LT
) | BO_COND_FALSE
,
475 [TCG_COND_LE
] = BC
| BI (7, CR_GT
) | BO_COND_FALSE
,
476 [TCG_COND_GT
] = BC
| BI (7, CR_GT
) | BO_COND_TRUE
,
477 [TCG_COND_LTU
] = BC
| BI (7, CR_LT
) | BO_COND_TRUE
,
478 [TCG_COND_GEU
] = BC
| BI (7, CR_LT
) | BO_COND_FALSE
,
479 [TCG_COND_LEU
] = BC
| BI (7, CR_GT
) | BO_COND_FALSE
,
480 [TCG_COND_GTU
] = BC
| BI (7, CR_GT
) | BO_COND_TRUE
,
483 /* The low bit here is set if the RA and RB fields must be inverted. */
484 static const uint32_t tcg_to_isel
[] = {
485 [TCG_COND_EQ
] = ISEL
| BC_(7, CR_EQ
),
486 [TCG_COND_NE
] = ISEL
| BC_(7, CR_EQ
) | 1,
487 [TCG_COND_LT
] = ISEL
| BC_(7, CR_LT
),
488 [TCG_COND_GE
] = ISEL
| BC_(7, CR_LT
) | 1,
489 [TCG_COND_LE
] = ISEL
| BC_(7, CR_GT
) | 1,
490 [TCG_COND_GT
] = ISEL
| BC_(7, CR_GT
),
491 [TCG_COND_LTU
] = ISEL
| BC_(7, CR_LT
),
492 [TCG_COND_GEU
] = ISEL
| BC_(7, CR_LT
) | 1,
493 [TCG_COND_LEU
] = ISEL
| BC_(7, CR_GT
) | 1,
494 [TCG_COND_GTU
] = ISEL
| BC_(7, CR_GT
),
497 static inline void tcg_out_mov(TCGContext
*s
, TCGType type
,
498 TCGReg ret
, TCGReg arg
)
500 tcg_out32 (s
, OR
| SAB (arg
, ret
, arg
));
503 static inline void tcg_out_rld(TCGContext
*s
, int op
, TCGReg ra
, TCGReg rs
,
506 sh
= SH (sh
& 0x1f) | (((sh
>> 5) & 1) << 1);
507 mb
= MB64 ((mb
>> 5) | ((mb
<< 1) & 0x3f));
508 tcg_out32 (s
, op
| RA (ra
) | RS (rs
) | sh
| mb
);
511 static inline void tcg_out_rlw(TCGContext
*s
, int op
, TCGReg ra
, TCGReg rs
,
512 int sh
, int mb
, int me
)
514 tcg_out32(s
, op
| RA(ra
) | RS(rs
) | SH(sh
) | MB(mb
) | ME(me
));
517 static inline void tcg_out_ext32u(TCGContext
*s
, TCGReg dst
, TCGReg src
)
519 tcg_out_rld(s
, RLDICL
, dst
, src
, 0, 32);
522 static inline void tcg_out_shli64(TCGContext
*s
, TCGReg dst
, TCGReg src
, int c
)
524 tcg_out_rld(s
, RLDICR
, dst
, src
, c
, 63 - c
);
527 static inline void tcg_out_shri64(TCGContext
*s
, TCGReg dst
, TCGReg src
, int c
)
529 tcg_out_rld(s
, RLDICL
, dst
, src
, 64 - c
, c
);
532 static void tcg_out_movi32(TCGContext
*s
, TCGReg ret
, int32_t arg
)
534 if (arg
== (int16_t) arg
) {
535 tcg_out32(s
, ADDI
| TAI(ret
, 0, arg
));
537 tcg_out32(s
, ADDIS
| TAI(ret
, 0, arg
>> 16));
539 tcg_out32(s
, ORI
| SAI(ret
, ret
, arg
));
544 static void tcg_out_movi(TCGContext
*s
, TCGType type
, TCGReg ret
,
547 if (type
== TCG_TYPE_I32
|| arg
== (int32_t)arg
) {
548 tcg_out_movi32(s
, ret
, arg
);
549 } else if (arg
== (uint32_t)arg
&& !(arg
& 0x8000)) {
550 tcg_out32(s
, ADDI
| TAI(ret
, 0, arg
));
551 tcg_out32(s
, ORIS
| SAI(ret
, ret
, arg
>> 16));
553 int32_t high
= arg
>> 32;
554 tcg_out_movi32(s
, ret
, high
);
556 tcg_out_shli64(s
, ret
, ret
, 32);
558 if (arg
& 0xffff0000) {
559 tcg_out32(s
, ORIS
| SAI(ret
, ret
, arg
>> 16));
562 tcg_out32(s
, ORI
| SAI(ret
, ret
, arg
));
567 static bool mask_operand(uint32_t c
, int *mb
, int *me
)
571 /* Accept a bit pattern like:
575 Keep track of the transitions. */
576 if (c
== 0 || c
== -1) {
582 if (test
& (test
- 1)) {
587 *mb
= test
? clz32(test
& -test
) + 1 : 0;
591 static bool mask64_operand(uint64_t c
, int *mb
, int *me
)
600 /* Accept 1..10..0. */
606 /* Accept 0..01..1. */
607 if (lsb
== 1 && (c
& (c
+ 1)) == 0) {
608 *mb
= clz64(c
+ 1) + 1;
615 static void tcg_out_andi32(TCGContext
*s
, TCGReg dst
, TCGReg src
, uint32_t c
)
619 if ((c
& 0xffff) == c
) {
620 tcg_out32(s
, ANDI
| SAI(src
, dst
, c
));
622 } else if ((c
& 0xffff0000) == c
) {
623 tcg_out32(s
, ANDIS
| SAI(src
, dst
, c
>> 16));
625 } else if (mask_operand(c
, &mb
, &me
)) {
626 tcg_out_rlw(s
, RLWINM
, dst
, src
, 0, mb
, me
);
628 tcg_out_movi(s
, TCG_TYPE_I32
, 0, c
);
629 tcg_out32(s
, AND
| SAB(src
, dst
, 0));
633 static void tcg_out_andi64(TCGContext
*s
, TCGReg dst
, TCGReg src
, uint64_t c
)
637 if ((c
& 0xffff) == c
) {
638 tcg_out32(s
, ANDI
| SAI(src
, dst
, c
));
640 } else if ((c
& 0xffff0000) == c
) {
641 tcg_out32(s
, ANDIS
| SAI(src
, dst
, c
>> 16));
643 } else if (mask64_operand(c
, &mb
, &me
)) {
645 tcg_out_rld(s
, RLDICR
, dst
, src
, 0, me
);
647 tcg_out_rld(s
, RLDICL
, dst
, src
, 0, mb
);
650 tcg_out_movi(s
, TCG_TYPE_I64
, 0, c
);
651 tcg_out32(s
, AND
| SAB(src
, dst
, 0));
655 static void tcg_out_zori32(TCGContext
*s
, TCGReg dst
, TCGReg src
, uint32_t c
,
656 int op_lo
, int op_hi
)
659 tcg_out32(s
, op_hi
| SAI(src
, dst
, c
>> 16));
663 tcg_out32(s
, op_lo
| SAI(src
, dst
, c
));
668 static void tcg_out_ori32(TCGContext
*s
, TCGReg dst
, TCGReg src
, uint32_t c
)
670 tcg_out_zori32(s
, dst
, src
, c
, ORI
, ORIS
);
673 static void tcg_out_xori32(TCGContext
*s
, TCGReg dst
, TCGReg src
, uint32_t c
)
675 tcg_out_zori32(s
, dst
, src
, c
, XORI
, XORIS
);
678 static void tcg_out_b (TCGContext
*s
, int mask
, tcg_target_long target
)
680 tcg_target_long disp
;
682 disp
= target
- (tcg_target_long
) s
->code_ptr
;
683 if ((disp
<< 38) >> 38 == disp
)
684 tcg_out32 (s
, B
| (disp
& 0x3fffffc) | mask
);
686 tcg_out_movi (s
, TCG_TYPE_I64
, 0, (tcg_target_long
) target
);
687 tcg_out32 (s
, MTSPR
| RS (0) | CTR
);
688 tcg_out32 (s
, BCCTR
| BO_ALWAYS
| mask
);
692 static void tcg_out_call (TCGContext
*s
, tcg_target_long arg
, int const_arg
)
696 tcg_out_b (s
, LK
, arg
);
699 tcg_out32 (s
, MTSPR
| RS (arg
) | LR
);
700 tcg_out32 (s
, BCLR
| BO_ALWAYS
| LK
);
707 tcg_out_movi (s
, TCG_TYPE_I64
, reg
, arg
);
711 tcg_out32 (s
, LD
| RT (0) | RA (reg
));
712 tcg_out32 (s
, MTSPR
| RA (0) | CTR
);
713 tcg_out32 (s
, LD
| RT (11) | RA (reg
) | 16);
714 tcg_out32 (s
, LD
| RT (2) | RA (reg
) | 8);
715 tcg_out32 (s
, BCCTR
| BO_ALWAYS
| LK
);
719 static void tcg_out_ldst(TCGContext
*s
, TCGReg ret
, TCGReg addr
,
720 int offset
, int op1
, int op2
)
722 if (offset
== (int16_t) offset
) {
723 tcg_out32(s
, op1
| TAI(ret
, addr
, offset
));
725 tcg_out_movi(s
, TCG_TYPE_I64
, 0, offset
);
726 tcg_out32(s
, op2
| TAB(ret
, addr
, 0));
730 static void tcg_out_ldsta(TCGContext
*s
, TCGReg ret
, TCGReg addr
,
731 int offset
, int op1
, int op2
)
733 if (offset
== (int16_t) (offset
& ~3)) {
734 tcg_out32(s
, op1
| TAI(ret
, addr
, offset
));
736 tcg_out_movi(s
, TCG_TYPE_I64
, 0, offset
);
737 tcg_out32(s
, op2
| TAB(ret
, addr
, 0));
741 #if defined (CONFIG_SOFTMMU)
743 #include "exec/softmmu_defs.h"
745 /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
747 static const void * const qemu_ld_helpers
[4] = {
754 /* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
755 uintxx_t val, int mmu_idx) */
756 static const void * const qemu_st_helpers
[4] = {
763 static void tcg_out_tlb_read(TCGContext
*s
, TCGReg r0
, TCGReg r1
, TCGReg r2
,
764 TCGReg addr_reg
, int s_bits
, int offset
)
766 #if TARGET_LONG_BITS == 32
767 tcg_out_ext32u(s
, addr_reg
, addr_reg
);
769 tcg_out_rlw(s
, RLWINM
, r0
, addr_reg
,
770 32 - (TARGET_PAGE_BITS
- CPU_TLB_ENTRY_BITS
),
771 32 - (CPU_TLB_BITS
+ CPU_TLB_ENTRY_BITS
),
772 31 - CPU_TLB_ENTRY_BITS
);
773 tcg_out32(s
, ADD
| TAB(r0
, r0
, TCG_AREG0
));
774 tcg_out32(s
, LWZU
| TAI(r1
, r0
, offset
));
775 tcg_out_rlw(s
, RLWINM
, r2
, addr_reg
, 0,
776 (32 - s_bits
) & 31, 31 - TARGET_PAGE_BITS
);
778 tcg_out_rld (s
, RLDICL
, r0
, addr_reg
,
779 64 - TARGET_PAGE_BITS
,
781 tcg_out_shli64(s
, r0
, r0
, CPU_TLB_ENTRY_BITS
);
783 tcg_out32(s
, ADD
| TAB(r0
, r0
, TCG_AREG0
));
784 tcg_out32(s
, LD_ADDR
| TAI(r1
, r0
, offset
));
787 tcg_out_rld (s
, RLDICR
, r2
, addr_reg
, 0, 63 - TARGET_PAGE_BITS
);
790 tcg_out_rld (s
, RLDICL
, r2
, addr_reg
,
791 64 - TARGET_PAGE_BITS
,
792 TARGET_PAGE_BITS
- s_bits
);
793 tcg_out_rld (s
, RLDICL
, r2
, r2
, TARGET_PAGE_BITS
, 0);
799 static const uint32_t qemu_ldx_opc
[8] = {
800 #ifdef TARGET_WORDS_BIGENDIAN
801 LBZX
, LHZX
, LWZX
, LDX
,
804 LBZX
, LHBRX
, LWBRX
, LDBRX
,
809 static const uint32_t qemu_stx_opc
[4] = {
810 #ifdef TARGET_WORDS_BIGENDIAN
811 STBX
, STHX
, STWX
, STDX
813 STBX
, STHBRX
, STWBRX
, STDBRX
,
817 static const uint32_t qemu_exts_opc
[4] = {
818 EXTSB
, EXTSH
, EXTSW
, 0
821 static void tcg_out_qemu_ld (TCGContext
*s
, const TCGArg
*args
, int opc
)
823 TCGReg addr_reg
, data_reg
, r0
, r1
, rbase
;
824 uint32_t insn
, s_bits
;
825 #ifdef CONFIG_SOFTMMU
828 void *label1_ptr
, *label2_ptr
;
835 #ifdef CONFIG_SOFTMMU
843 tcg_out_tlb_read (s
, r0
, r1
, r2
, addr_reg
, s_bits
,
844 offsetof (CPUArchState
, tlb_table
[mem_index
][0].addr_read
));
846 tcg_out32 (s
, CMP
| BF (7) | RA (r2
) | RB (r1
) | CMP_L
);
848 label1_ptr
= s
->code_ptr
;
850 tcg_out32 (s
, BC
| BI (7, CR_EQ
) | BO_COND_TRUE
);
855 tcg_out_mov (s
, TCG_TYPE_I64
, ir
++, TCG_AREG0
);
856 tcg_out_mov (s
, TCG_TYPE_I64
, ir
++, addr_reg
);
857 tcg_out_movi (s
, TCG_TYPE_I64
, ir
++, mem_index
);
859 tcg_out_call (s
, (tcg_target_long
) qemu_ld_helpers
[s_bits
], 1);
862 insn
= qemu_exts_opc
[s_bits
];
863 tcg_out32(s
, insn
| RA(data_reg
) | RS(3));
864 } else if (data_reg
!= 3) {
865 tcg_out_mov(s
, TCG_TYPE_I64
, data_reg
, 3);
867 label2_ptr
= s
->code_ptr
;
870 /* label1: fast path */
872 reloc_pc14 (label1_ptr
, (tcg_target_long
) s
->code_ptr
);
875 /* r0 now contains &env->tlb_table[mem_index][index].addr_read */
876 tcg_out32(s
, LD
| TAI(r0
, r0
,
877 offsetof(CPUTLBEntry
, addend
)
878 - offsetof(CPUTLBEntry
, addr_read
)));
879 /* r0 = env->tlb_table[mem_index][index].addend */
880 tcg_out32(s
, ADD
| TAB(r0
, r0
, addr_reg
));
881 /* r0 = env->tlb_table[mem_index][index].addend + addr */
883 #else /* !CONFIG_SOFTMMU */
884 #if TARGET_LONG_BITS == 32
885 tcg_out_ext32u(s
, addr_reg
, addr_reg
);
889 rbase
= GUEST_BASE
? TCG_GUEST_BASE_REG
: 0;
892 insn
= qemu_ldx_opc
[opc
];
893 if (!HAVE_ISA_2_06
&& insn
== LDBRX
) {
894 tcg_out32(s
, ADDI
| TAI(r1
, r0
, 4));
895 tcg_out32(s
, LWBRX
| TAB(data_reg
, rbase
, r0
));
896 tcg_out32(s
, LWBRX
| TAB( r1
, rbase
, r1
));
897 tcg_out_rld(s
, RLDIMI
, data_reg
, r1
, 32, 0);
899 tcg_out32(s
, insn
| TAB(data_reg
, rbase
, r0
));
901 insn
= qemu_ldx_opc
[s_bits
];
902 tcg_out32(s
, insn
| TAB(data_reg
, rbase
, r0
));
903 insn
= qemu_exts_opc
[s_bits
];
904 tcg_out32 (s
, insn
| RA(data_reg
) | RS(data_reg
));
907 #ifdef CONFIG_SOFTMMU
908 reloc_pc24 (label2_ptr
, (tcg_target_long
) s
->code_ptr
);
912 static void tcg_out_qemu_st (TCGContext
*s
, const TCGArg
*args
, int opc
)
914 TCGReg addr_reg
, r0
, r1
, rbase
, data_reg
;
916 #ifdef CONFIG_SOFTMMU
919 void *label1_ptr
, *label2_ptr
;
925 #ifdef CONFIG_SOFTMMU
933 tcg_out_tlb_read (s
, r0
, r1
, r2
, addr_reg
, opc
,
934 offsetof (CPUArchState
, tlb_table
[mem_index
][0].addr_write
));
936 tcg_out32 (s
, CMP
| BF (7) | RA (r2
) | RB (r1
) | CMP_L
);
938 label1_ptr
= s
->code_ptr
;
940 tcg_out32 (s
, BC
| BI (7, CR_EQ
) | BO_COND_TRUE
);
945 tcg_out_mov (s
, TCG_TYPE_I64
, ir
++, TCG_AREG0
);
946 tcg_out_mov (s
, TCG_TYPE_I64
, ir
++, addr_reg
);
947 tcg_out_rld (s
, RLDICL
, ir
++, data_reg
, 0, 64 - (1 << (3 + opc
)));
948 tcg_out_movi (s
, TCG_TYPE_I64
, ir
++, mem_index
);
950 tcg_out_call (s
, (tcg_target_long
) qemu_st_helpers
[opc
], 1);
952 label2_ptr
= s
->code_ptr
;
955 /* label1: fast path */
957 reloc_pc14 (label1_ptr
, (tcg_target_long
) s
->code_ptr
);
963 | (offsetof (CPUTLBEntry
, addend
)
964 - offsetof (CPUTLBEntry
, addr_write
))
966 /* r0 = env->tlb_table[mem_index][index].addend */
967 tcg_out32(s
, ADD
| TAB(r0
, r0
, addr_reg
));
968 /* r0 = env->tlb_table[mem_index][index].addend + addr */
970 #else /* !CONFIG_SOFTMMU */
971 #if TARGET_LONG_BITS == 32
972 tcg_out_ext32u(s
, addr_reg
, addr_reg
);
976 rbase
= GUEST_BASE
? TCG_GUEST_BASE_REG
: 0;
979 insn
= qemu_stx_opc
[opc
];
980 if (!HAVE_ISA_2_06
&& insn
== STDBRX
) {
981 tcg_out32(s
, STWBRX
| SAB(data_reg
, rbase
, r0
));
982 tcg_out32(s
, ADDI
| TAI(r1
, r0
, 4));
983 tcg_out_shri64(s
, 0, data_reg
, 32);
984 tcg_out32(s
, STWBRX
| SAB(0, rbase
, r1
));
986 tcg_out32(s
, insn
| SAB(data_reg
, rbase
, r0
));
989 #ifdef CONFIG_SOFTMMU
990 reloc_pc24 (label2_ptr
, (tcg_target_long
) s
->code_ptr
);
994 static void tcg_target_qemu_prologue (TCGContext
*s
)
1002 + 8 /* back chain */
1005 + 8 /* compiler doubleword */
1006 + 8 /* link editor doubleword */
1007 + 8 /* TOC save area */
1008 + TCG_STATIC_CALL_ARGS_SIZE
1009 + ARRAY_SIZE (tcg_target_callee_save_regs
) * 8
1010 + CPU_TEMP_BUF_NLONGS
* sizeof(long)
1012 frame_size
= (frame_size
+ 15) & ~15;
1014 tcg_set_frame (s
, TCG_REG_CALL_STACK
, frame_size
1015 - CPU_TEMP_BUF_NLONGS
* sizeof (long),
1016 CPU_TEMP_BUF_NLONGS
* sizeof (long));
1019 /* First emit adhoc function descriptor */
1020 addr
= (uint64_t) s
->code_ptr
+ 24;
1021 tcg_out32 (s
, addr
>> 32); tcg_out32 (s
, addr
); /* entry point */
1022 s
->code_ptr
+= 16; /* skip TOC and environment pointer */
1026 tcg_out32 (s
, MFSPR
| RT (0) | LR
);
1027 tcg_out32 (s
, STDU
| RS (1) | RA (1) | (-frame_size
& 0xffff));
1028 for (i
= 0; i
< ARRAY_SIZE (tcg_target_callee_save_regs
); ++i
)
1030 | RS (tcg_target_callee_save_regs
[i
])
1032 | (i
* 8 + 48 + TCG_STATIC_CALL_ARGS_SIZE
)
1035 tcg_out32 (s
, STD
| RS (0) | RA (1) | (frame_size
+ 16));
1037 #ifdef CONFIG_USE_GUEST_BASE
1039 tcg_out_movi (s
, TCG_TYPE_I64
, TCG_GUEST_BASE_REG
, GUEST_BASE
);
1040 tcg_regset_set_reg (s
->reserved_regs
, TCG_GUEST_BASE_REG
);
1044 tcg_out_mov (s
, TCG_TYPE_PTR
, TCG_AREG0
, tcg_target_call_iarg_regs
[0]);
1045 tcg_out32 (s
, MTSPR
| RS (tcg_target_call_iarg_regs
[1]) | CTR
);
1046 tcg_out32 (s
, BCCTR
| BO_ALWAYS
);
1049 tb_ret_addr
= s
->code_ptr
;
1051 for (i
= 0; i
< ARRAY_SIZE (tcg_target_callee_save_regs
); ++i
)
1053 | RT (tcg_target_callee_save_regs
[i
])
1055 | (i
* 8 + 48 + TCG_STATIC_CALL_ARGS_SIZE
)
1058 tcg_out32(s
, LD
| TAI(0, 1, frame_size
+ 16));
1059 tcg_out32(s
, MTSPR
| RS(0) | LR
);
1060 tcg_out32(s
, ADDI
| TAI(1, 1, frame_size
));
1061 tcg_out32(s
, BCLR
| BO_ALWAYS
);
1064 static void tcg_out_ld (TCGContext
*s
, TCGType type
, TCGReg ret
, TCGReg arg1
,
1065 tcg_target_long arg2
)
1067 if (type
== TCG_TYPE_I32
)
1068 tcg_out_ldst (s
, ret
, arg1
, arg2
, LWZ
, LWZX
);
1070 tcg_out_ldsta (s
, ret
, arg1
, arg2
, LD
, LDX
);
1073 static void tcg_out_st (TCGContext
*s
, TCGType type
, TCGReg arg
, TCGReg arg1
,
1074 tcg_target_long arg2
)
1076 if (type
== TCG_TYPE_I32
)
1077 tcg_out_ldst (s
, arg
, arg1
, arg2
, STW
, STWX
);
1079 tcg_out_ldsta (s
, arg
, arg1
, arg2
, STD
, STDX
);
1082 static void tcg_out_cmp(TCGContext
*s
, int cond
, TCGArg arg1
, TCGArg arg2
,
1083 int const_arg2
, int cr
, TCGType type
)
1088 /* Simplify the comparisons below wrt CMPI. */
1089 if (type
== TCG_TYPE_I32
) {
1090 arg2
= (int32_t)arg2
;
1097 if ((int16_t) arg2
== arg2
) {
1102 else if ((uint16_t) arg2
== arg2
) {
1117 if ((int16_t) arg2
== arg2
) {
1132 if ((uint16_t) arg2
== arg2
) {
1145 op
|= BF(cr
) | ((type
== TCG_TYPE_I64
) << 21);
1148 tcg_out32(s
, op
| RA(arg1
) | (arg2
& 0xffff));
1151 tcg_out_movi(s
, type
, 0, arg2
);
1154 tcg_out32(s
, op
| RA(arg1
) | RB(arg2
));
1158 static void tcg_out_setcond_eq0(TCGContext
*s
, TCGType type
,
1159 TCGReg dst
, TCGReg src
)
1161 tcg_out32(s
, (type
== TCG_TYPE_I64
? CNTLZD
: CNTLZW
) | RS(src
) | RA(dst
));
1162 tcg_out_shri64(s
, dst
, dst
, type
== TCG_TYPE_I64
? 6 : 5);
1165 static void tcg_out_setcond_ne0(TCGContext
*s
, TCGReg dst
, TCGReg src
)
1167 /* X != 0 implies X + -1 generates a carry. Extra addition
1168 trickery means: R = X-1 + ~X + C = X-1 + (-X+1) + C = C. */
1170 tcg_out32(s
, ADDIC
| TAI(dst
, src
, -1));
1171 tcg_out32(s
, SUBFE
| TAB(dst
, dst
, src
));
1173 tcg_out32(s
, ADDIC
| TAI(0, src
, -1));
1174 tcg_out32(s
, SUBFE
| TAB(dst
, 0, src
));
1178 static TCGReg
tcg_gen_setcond_xor(TCGContext
*s
, TCGReg arg1
, TCGArg arg2
,
1182 if ((uint32_t)arg2
== arg2
) {
1183 tcg_out_xori32(s
, TCG_REG_R0
, arg1
, arg2
);
1185 tcg_out_movi(s
, TCG_TYPE_I64
, TCG_REG_R0
, arg2
);
1186 tcg_out32(s
, XOR
| SAB(arg1
, TCG_REG_R0
, TCG_REG_R0
));
1189 tcg_out32(s
, XOR
| SAB(arg1
, TCG_REG_R0
, arg2
));
1194 static void tcg_out_setcond(TCGContext
*s
, TCGType type
, TCGCond cond
,
1195 TCGArg arg0
, TCGArg arg1
, TCGArg arg2
,
1200 /* Ignore high bits of a potential constant arg2. */
1201 if (type
== TCG_TYPE_I32
) {
1202 arg2
= (uint32_t)arg2
;
1205 /* Handle common and trivial cases before handling anything else. */
1209 tcg_out_setcond_eq0(s
, type
, arg0
, arg1
);
1212 if (type
== TCG_TYPE_I32
) {
1213 tcg_out_ext32u(s
, TCG_REG_R0
, arg1
);
1216 tcg_out_setcond_ne0(s
, arg0
, arg1
);
1219 tcg_out32(s
, NOR
| SAB(arg1
, arg0
, arg1
));
1223 /* Extract the sign bit. */
1224 tcg_out_rld(s
, RLDICL
, arg0
, arg1
,
1225 type
== TCG_TYPE_I64
? 1 : 33, 63);
1232 /* If we have ISEL, we can implement everything with 3 or 4 insns.
1233 All other cases below are also at least 3 insns, so speed up the
1234 code generator by not considering them and always using ISEL. */
1238 tcg_out_cmp(s
, cond
, arg1
, arg2
, const_arg2
, 7, type
);
1240 isel
= tcg_to_isel
[cond
];
1242 tcg_out_movi(s
, type
, arg0
, 1);
1244 /* arg0 = (bc ? 0 : 1) */
1245 tab
= TAB(arg0
, 0, arg0
);
1248 /* arg0 = (bc ? 1 : 0) */
1249 tcg_out_movi(s
, type
, TCG_REG_R0
, 0);
1250 tab
= TAB(arg0
, arg0
, TCG_REG_R0
);
1252 tcg_out32(s
, isel
| tab
);
1258 arg1
= tcg_gen_setcond_xor(s
, arg1
, arg2
, const_arg2
);
1259 tcg_out_setcond_eq0(s
, type
, arg0
, arg1
);
1263 arg1
= tcg_gen_setcond_xor(s
, arg1
, arg2
, const_arg2
);
1264 /* Discard the high bits only once, rather than both inputs. */
1265 if (type
== TCG_TYPE_I32
) {
1266 tcg_out_ext32u(s
, TCG_REG_R0
, arg1
);
1269 tcg_out_setcond_ne0(s
, arg0
, arg1
);
1287 crop
= CRNOR
| BT (7, CR_EQ
) | BA (7, CR_LT
) | BB (7, CR_LT
);
1293 crop
= CRNOR
| BT (7, CR_EQ
) | BA (7, CR_GT
) | BB (7, CR_GT
);
1295 tcg_out_cmp(s
, cond
, arg1
, arg2
, const_arg2
, 7, type
);
1299 tcg_out32(s
, MFOCRF
| RT(TCG_REG_R0
) | FXM(7));
1300 tcg_out_rlw(s
, RLWINM
, arg0
, TCG_REG_R0
, sh
, 31, 31);
1308 static void tcg_out_bc (TCGContext
*s
, int bc
, int label_index
)
1310 TCGLabel
*l
= &s
->labels
[label_index
];
1313 tcg_out32 (s
, bc
| reloc_pc14_val (s
->code_ptr
, l
->u
.value
));
1315 uint16_t val
= *(uint16_t *) &s
->code_ptr
[2];
1317 /* Thanks to Andrzej Zaborowski */
1318 tcg_out32 (s
, bc
| (val
& 0xfffc));
1319 tcg_out_reloc (s
, s
->code_ptr
- 4, R_PPC_REL14
, label_index
, 0);
1323 static void tcg_out_brcond(TCGContext
*s
, TCGCond cond
,
1324 TCGArg arg1
, TCGArg arg2
, int const_arg2
,
1325 int label_index
, TCGType type
)
1327 tcg_out_cmp(s
, cond
, arg1
, arg2
, const_arg2
, 7, type
);
1328 tcg_out_bc(s
, tcg_to_bc
[cond
], label_index
);
1331 static void tcg_out_movcond(TCGContext
*s
, TCGType type
, TCGCond cond
,
1332 TCGArg dest
, TCGArg c1
, TCGArg c2
, TCGArg v1
,
1333 TCGArg v2
, bool const_c2
)
1335 /* If for some reason both inputs are zero, don't produce bad code. */
1336 if (v1
== 0 && v2
== 0) {
1337 tcg_out_movi(s
, type
, dest
, 0);
1341 tcg_out_cmp(s
, cond
, c1
, c2
, const_c2
, 7, type
);
1344 int isel
= tcg_to_isel
[cond
];
1346 /* Swap the V operands if the operation indicates inversion. */
1353 /* V1 == 0 is handled by isel; V2 == 0 must be handled by hand. */
1355 tcg_out_movi(s
, type
, 0, 0);
1357 tcg_out32(s
, isel
| TAB(dest
, v1
, v2
));
1360 cond
= tcg_invert_cond(cond
);
1362 } else if (dest
!= v1
) {
1364 tcg_out_movi(s
, type
, dest
, 0);
1366 tcg_out_mov(s
, type
, dest
, v1
);
1369 /* Branch forward over one insn */
1370 tcg_out32(s
, tcg_to_bc
[cond
] | 8);
1372 tcg_out_movi(s
, type
, dest
, 0);
1374 tcg_out_mov(s
, type
, dest
, v2
);
1379 void ppc_tb_set_jmp_target (unsigned long jmp_addr
, unsigned long addr
)
1382 unsigned long patch_size
;
1384 s
.code_ptr
= (uint8_t *) jmp_addr
;
1385 tcg_out_b (&s
, 0, addr
);
1386 patch_size
= s
.code_ptr
- (uint8_t *) jmp_addr
;
1387 flush_icache_range (jmp_addr
, jmp_addr
+ patch_size
);
1390 static void tcg_out_op (TCGContext
*s
, TCGOpcode opc
, const TCGArg
*args
,
1391 const int *const_args
)
1397 case INDEX_op_exit_tb
:
1398 tcg_out_movi (s
, TCG_TYPE_I64
, TCG_REG_R3
, args
[0]);
1399 tcg_out_b (s
, 0, (tcg_target_long
) tb_ret_addr
);
1401 case INDEX_op_goto_tb
:
1402 if (s
->tb_jmp_offset
) {
1403 /* direct jump method */
1405 s
->tb_jmp_offset
[args
[0]] = s
->code_ptr
- s
->code_buf
;
1411 s
->tb_next_offset
[args
[0]] = s
->code_ptr
- s
->code_buf
;
1415 TCGLabel
*l
= &s
->labels
[args
[0]];
1418 tcg_out_b (s
, 0, l
->u
.value
);
1421 uint32_t val
= *(uint32_t *) s
->code_ptr
;
1423 /* Thanks to Andrzej Zaborowski */
1424 tcg_out32 (s
, B
| (val
& 0x3fffffc));
1425 tcg_out_reloc (s
, s
->code_ptr
- 4, R_PPC_REL24
, args
[0], 0);
1430 tcg_out_call (s
, args
[0], const_args
[0]);
1432 case INDEX_op_movi_i32
:
1433 tcg_out_movi (s
, TCG_TYPE_I32
, args
[0], args
[1]);
1435 case INDEX_op_movi_i64
:
1436 tcg_out_movi (s
, TCG_TYPE_I64
, args
[0], args
[1]);
1438 case INDEX_op_ld8u_i32
:
1439 case INDEX_op_ld8u_i64
:
1440 tcg_out_ldst (s
, args
[0], args
[1], args
[2], LBZ
, LBZX
);
1442 case INDEX_op_ld8s_i32
:
1443 case INDEX_op_ld8s_i64
:
1444 tcg_out_ldst (s
, args
[0], args
[1], args
[2], LBZ
, LBZX
);
1445 tcg_out32 (s
, EXTSB
| RS (args
[0]) | RA (args
[0]));
1447 case INDEX_op_ld16u_i32
:
1448 case INDEX_op_ld16u_i64
:
1449 tcg_out_ldst (s
, args
[0], args
[1], args
[2], LHZ
, LHZX
);
1451 case INDEX_op_ld16s_i32
:
1452 case INDEX_op_ld16s_i64
:
1453 tcg_out_ldst (s
, args
[0], args
[1], args
[2], LHA
, LHAX
);
1455 case INDEX_op_ld_i32
:
1456 case INDEX_op_ld32u_i64
:
1457 tcg_out_ldst (s
, args
[0], args
[1], args
[2], LWZ
, LWZX
);
1459 case INDEX_op_ld32s_i64
:
1460 tcg_out_ldsta (s
, args
[0], args
[1], args
[2], LWA
, LWAX
);
1462 case INDEX_op_ld_i64
:
1463 tcg_out_ldsta (s
, args
[0], args
[1], args
[2], LD
, LDX
);
1465 case INDEX_op_st8_i32
:
1466 case INDEX_op_st8_i64
:
1467 tcg_out_ldst (s
, args
[0], args
[1], args
[2], STB
, STBX
);
1469 case INDEX_op_st16_i32
:
1470 case INDEX_op_st16_i64
:
1471 tcg_out_ldst (s
, args
[0], args
[1], args
[2], STH
, STHX
);
1473 case INDEX_op_st_i32
:
1474 case INDEX_op_st32_i64
:
1475 tcg_out_ldst (s
, args
[0], args
[1], args
[2], STW
, STWX
);
1477 case INDEX_op_st_i64
:
1478 tcg_out_ldsta (s
, args
[0], args
[1], args
[2], STD
, STDX
);
1481 case INDEX_op_add_i32
:
1482 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1483 if (const_args
[2]) {
1489 tcg_out32(s
, ADDIS
| TAI(a0
, a1
, h
>> 16));
1492 if (l
|| a0
!= a1
) {
1493 tcg_out32(s
, ADDI
| TAI(a0
, a1
, l
));
1496 tcg_out32(s
, ADD
| TAB(a0
, a1
, a2
));
1499 case INDEX_op_sub_i32
:
1500 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1501 if (const_args
[1]) {
1502 if (const_args
[2]) {
1503 tcg_out_movi(s
, TCG_TYPE_I32
, a0
, a1
- a2
);
1505 tcg_out32(s
, SUBFIC
| TAI(a0
, a2
, a1
));
1507 } else if (const_args
[2]) {
1511 tcg_out32(s
, SUBF
| TAB(a0
, a2
, a1
));
1515 case INDEX_op_and_i32
:
1516 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1517 if (const_args
[2]) {
1518 tcg_out_andi32(s
, a0
, a1
, a2
);
1520 tcg_out32(s
, AND
| SAB(a1
, a0
, a2
));
1523 case INDEX_op_and_i64
:
1524 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1525 if (const_args
[2]) {
1526 tcg_out_andi64(s
, a0
, a1
, a2
);
1528 tcg_out32(s
, AND
| SAB(a1
, a0
, a2
));
1531 case INDEX_op_or_i64
:
1532 case INDEX_op_or_i32
:
1533 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1534 if (const_args
[2]) {
1535 tcg_out_ori32(s
, a0
, a1
, a2
);
1537 tcg_out32(s
, OR
| SAB(a1
, a0
, a2
));
1540 case INDEX_op_xor_i64
:
1541 case INDEX_op_xor_i32
:
1542 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1543 if (const_args
[2]) {
1544 tcg_out_xori32(s
, a0
, a1
, a2
);
1546 tcg_out32(s
, XOR
| SAB(a1
, a0
, a2
));
1549 case INDEX_op_andc_i32
:
1550 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1551 if (const_args
[2]) {
1552 tcg_out_andi32(s
, a0
, a1
, ~a2
);
1554 tcg_out32(s
, ANDC
| SAB(a1
, a0
, a2
));
1557 case INDEX_op_andc_i64
:
1558 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1559 if (const_args
[2]) {
1560 tcg_out_andi64(s
, a0
, a1
, ~a2
);
1562 tcg_out32(s
, ANDC
| SAB(a1
, a0
, a2
));
1565 case INDEX_op_orc_i32
:
1566 if (const_args
[2]) {
1567 tcg_out_ori32(s
, args
[0], args
[1], ~args
[2]);
1571 case INDEX_op_orc_i64
:
1572 tcg_out32(s
, ORC
| SAB(args
[1], args
[0], args
[2]));
1574 case INDEX_op_eqv_i32
:
1575 if (const_args
[2]) {
1576 tcg_out_xori32(s
, args
[0], args
[1], ~args
[2]);
1580 case INDEX_op_eqv_i64
:
1581 tcg_out32(s
, EQV
| SAB(args
[1], args
[0], args
[2]));
1583 case INDEX_op_nand_i32
:
1584 case INDEX_op_nand_i64
:
1585 tcg_out32(s
, NAND
| SAB(args
[1], args
[0], args
[2]));
1587 case INDEX_op_nor_i32
:
1588 case INDEX_op_nor_i64
:
1589 tcg_out32(s
, NOR
| SAB(args
[1], args
[0], args
[2]));
1592 case INDEX_op_mul_i32
:
1593 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1594 if (const_args
[2]) {
1595 tcg_out32(s
, MULLI
| TAI(a0
, a1
, a2
));
1597 tcg_out32(s
, MULLW
| TAB(a0
, a1
, a2
));
1601 case INDEX_op_div_i32
:
1602 tcg_out32 (s
, DIVW
| TAB (args
[0], args
[1], args
[2]));
1605 case INDEX_op_divu_i32
:
1606 tcg_out32 (s
, DIVWU
| TAB (args
[0], args
[1], args
[2]));
1609 case INDEX_op_rem_i32
:
1610 tcg_out32 (s
, DIVW
| TAB (0, args
[1], args
[2]));
1611 tcg_out32 (s
, MULLW
| TAB (0, 0, args
[2]));
1612 tcg_out32 (s
, SUBF
| TAB (args
[0], 0, args
[1]));
1615 case INDEX_op_remu_i32
:
1616 tcg_out32 (s
, DIVWU
| TAB (0, args
[1], args
[2]));
1617 tcg_out32 (s
, MULLW
| TAB (0, 0, args
[2]));
1618 tcg_out32 (s
, SUBF
| TAB (args
[0], 0, args
[1]));
1621 case INDEX_op_shl_i32
:
1622 if (const_args
[2]) {
1623 tcg_out_rlw(s
, RLWINM
, args
[0], args
[1], args
[2], 0, 31 - args
[2]);
1625 tcg_out32 (s
, SLW
| SAB (args
[1], args
[0], args
[2]));
1628 case INDEX_op_shr_i32
:
1629 if (const_args
[2]) {
1630 tcg_out_rlw(s
, RLWINM
, args
[0], args
[1], 32 - args
[2], args
[2], 31);
1632 tcg_out32 (s
, SRW
| SAB (args
[1], args
[0], args
[2]));
1635 case INDEX_op_sar_i32
:
1637 tcg_out32 (s
, SRAWI
| RS (args
[1]) | RA (args
[0]) | SH (args
[2]));
1639 tcg_out32 (s
, SRAW
| SAB (args
[1], args
[0], args
[2]));
1641 case INDEX_op_rotl_i32
:
1642 if (const_args
[2]) {
1643 tcg_out_rlw(s
, RLWINM
, args
[0], args
[1], args
[2], 0, 31);
1645 tcg_out32(s
, RLWNM
| SAB(args
[1], args
[0], args
[2])
1649 case INDEX_op_rotr_i32
:
1650 if (const_args
[2]) {
1651 tcg_out_rlw(s
, RLWINM
, args
[0], args
[1], 32 - args
[2], 0, 31);
1653 tcg_out32(s
, SUBFIC
| TAI(0, args
[2], 32));
1654 tcg_out32(s
, RLWNM
| SAB(args
[1], args
[0], args
[2])
1659 case INDEX_op_brcond_i32
:
1660 tcg_out_brcond(s
, args
[2], args
[0], args
[1], const_args
[1],
1661 args
[3], TCG_TYPE_I32
);
1664 case INDEX_op_brcond_i64
:
1665 tcg_out_brcond(s
, args
[2], args
[0], args
[1], const_args
[1],
1666 args
[3], TCG_TYPE_I64
);
1669 case INDEX_op_neg_i32
:
1670 case INDEX_op_neg_i64
:
1671 tcg_out32 (s
, NEG
| RT (args
[0]) | RA (args
[1]));
1674 case INDEX_op_not_i32
:
1675 case INDEX_op_not_i64
:
1676 tcg_out32 (s
, NOR
| SAB (args
[1], args
[0], args
[1]));
1679 case INDEX_op_add_i64
:
1680 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1681 if (const_args
[2]) {
1684 /* We can always split any 32-bit signed constant into 3 pieces.
1685 Note the positive 0x80000000 coming from the sub_i64 path,
1686 handled with the same code we need for eg 0x7fff8000. */
1687 assert(a2
== (int32_t)a2
|| a2
== 0x80000000);
1691 if (h1
< 0 && (int64_t)a2
> 0) {
1695 assert((TCGArg
)h2
+ h1
+ l0
== a2
);
1698 tcg_out32(s
, ADDIS
| TAI(a0
, a1
, h2
>> 16));
1702 tcg_out32(s
, ADDIS
| TAI(a0
, a1
, h1
>> 16));
1705 if (l0
|| a0
!= a1
) {
1706 tcg_out32(s
, ADDI
| TAI(a0
, a1
, l0
));
1709 tcg_out32(s
, ADD
| TAB(a0
, a1
, a2
));
1712 case INDEX_op_sub_i64
:
1713 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1714 if (const_args
[1]) {
1715 if (const_args
[2]) {
1716 tcg_out_movi(s
, TCG_TYPE_I64
, a0
, a1
- a2
);
1718 tcg_out32(s
, SUBFIC
| TAI(a0
, a2
, a1
));
1720 } else if (const_args
[2]) {
1724 tcg_out32(s
, SUBF
| TAB(a0
, a2
, a1
));
1728 case INDEX_op_shl_i64
:
1730 tcg_out_shli64(s
, args
[0], args
[1], args
[2]);
1732 tcg_out32 (s
, SLD
| SAB (args
[1], args
[0], args
[2]));
1734 case INDEX_op_shr_i64
:
1736 tcg_out_shri64(s
, args
[0], args
[1], args
[2]);
1738 tcg_out32 (s
, SRD
| SAB (args
[1], args
[0], args
[2]));
1740 case INDEX_op_sar_i64
:
1741 if (const_args
[2]) {
1742 int sh
= SH (args
[2] & 0x1f) | (((args
[2] >> 5) & 1) << 1);
1743 tcg_out32 (s
, SRADI
| RA (args
[0]) | RS (args
[1]) | sh
);
1746 tcg_out32 (s
, SRAD
| SAB (args
[1], args
[0], args
[2]));
1748 case INDEX_op_rotl_i64
:
1749 if (const_args
[2]) {
1750 tcg_out_rld(s
, RLDICL
, args
[0], args
[1], args
[2], 0);
1752 tcg_out32(s
, RLDCL
| SAB(args
[1], args
[0], args
[2]) | MB64(0));
1755 case INDEX_op_rotr_i64
:
1756 if (const_args
[2]) {
1757 tcg_out_rld(s
, RLDICL
, args
[0], args
[1], 64 - args
[2], 0);
1759 tcg_out32(s
, SUBFIC
| TAI(0, args
[2], 64));
1760 tcg_out32(s
, RLDCL
| SAB(args
[1], args
[0], 0) | MB64(0));
1764 case INDEX_op_mul_i64
:
1765 a0
= args
[0], a1
= args
[1], a2
= args
[2];
1766 if (const_args
[2]) {
1767 tcg_out32(s
, MULLI
| TAI(a0
, a1
, a2
));
1769 tcg_out32(s
, MULLD
| TAB(a0
, a1
, a2
));
1772 case INDEX_op_div_i64
:
1773 tcg_out32 (s
, DIVD
| TAB (args
[0], args
[1], args
[2]));
1775 case INDEX_op_divu_i64
:
1776 tcg_out32 (s
, DIVDU
| TAB (args
[0], args
[1], args
[2]));
1778 case INDEX_op_rem_i64
:
1779 tcg_out32 (s
, DIVD
| TAB (0, args
[1], args
[2]));
1780 tcg_out32 (s
, MULLD
| TAB (0, 0, args
[2]));
1781 tcg_out32 (s
, SUBF
| TAB (args
[0], 0, args
[1]));
1783 case INDEX_op_remu_i64
:
1784 tcg_out32 (s
, DIVDU
| TAB (0, args
[1], args
[2]));
1785 tcg_out32 (s
, MULLD
| TAB (0, 0, args
[2]));
1786 tcg_out32 (s
, SUBF
| TAB (args
[0], 0, args
[1]));
1789 case INDEX_op_qemu_ld8u
:
1790 tcg_out_qemu_ld (s
, args
, 0);
1792 case INDEX_op_qemu_ld8s
:
1793 tcg_out_qemu_ld (s
, args
, 0 | 4);
1795 case INDEX_op_qemu_ld16u
:
1796 tcg_out_qemu_ld (s
, args
, 1);
1798 case INDEX_op_qemu_ld16s
:
1799 tcg_out_qemu_ld (s
, args
, 1 | 4);
1801 case INDEX_op_qemu_ld32
:
1802 case INDEX_op_qemu_ld32u
:
1803 tcg_out_qemu_ld (s
, args
, 2);
1805 case INDEX_op_qemu_ld32s
:
1806 tcg_out_qemu_ld (s
, args
, 2 | 4);
1808 case INDEX_op_qemu_ld64
:
1809 tcg_out_qemu_ld (s
, args
, 3);
1811 case INDEX_op_qemu_st8
:
1812 tcg_out_qemu_st (s
, args
, 0);
1814 case INDEX_op_qemu_st16
:
1815 tcg_out_qemu_st (s
, args
, 1);
1817 case INDEX_op_qemu_st32
:
1818 tcg_out_qemu_st (s
, args
, 2);
1820 case INDEX_op_qemu_st64
:
1821 tcg_out_qemu_st (s
, args
, 3);
1824 case INDEX_op_ext8s_i32
:
1825 case INDEX_op_ext8s_i64
:
1828 case INDEX_op_ext16s_i32
:
1829 case INDEX_op_ext16s_i64
:
1832 case INDEX_op_ext32s_i64
:
1836 tcg_out32 (s
, c
| RS (args
[1]) | RA (args
[0]));
1839 case INDEX_op_setcond_i32
:
1840 tcg_out_setcond (s
, TCG_TYPE_I32
, args
[3], args
[0], args
[1], args
[2],
1843 case INDEX_op_setcond_i64
:
1844 tcg_out_setcond (s
, TCG_TYPE_I64
, args
[3], args
[0], args
[1], args
[2],
1848 case INDEX_op_bswap16_i32
:
1849 case INDEX_op_bswap16_i64
:
1850 a0
= args
[0], a1
= args
[1];
1853 /* a0 = (a1 r<< 24) & 0xff # 000c */
1854 tcg_out_rlw(s
, RLWINM
, a0
, a1
, 24, 24, 31);
1855 /* a0 = (a0 & ~0xff00) | (a1 r<< 8) & 0xff00 # 00dc */
1856 tcg_out_rlw(s
, RLWIMI
, a0
, a1
, 8, 16, 23);
1858 /* r0 = (a1 r<< 8) & 0xff00 # 00d0 */
1859 tcg_out_rlw(s
, RLWINM
, TCG_REG_R0
, a1
, 8, 16, 23);
1860 /* a0 = (a1 r<< 24) & 0xff # 000c */
1861 tcg_out_rlw(s
, RLWINM
, a0
, a1
, 24, 24, 31);
1862 /* a0 = a0 | r0 # 00dc */
1863 tcg_out32(s
, OR
| SAB(TCG_REG_R0
, a0
, a0
));
1867 case INDEX_op_bswap32_i32
:
1868 case INDEX_op_bswap32_i64
:
1869 /* Stolen from gcc's builtin_bswap32 */
1871 a0
= args
[0] == a1
? TCG_REG_R0
: args
[0];
1873 /* a1 = args[1] # abcd */
1874 /* a0 = rotate_left (a1, 8) # bcda */
1875 tcg_out_rlw(s
, RLWINM
, a0
, a1
, 8, 0, 31);
1876 /* a0 = (a0 & ~0xff000000) | ((a1 r<< 24) & 0xff000000) # dcda */
1877 tcg_out_rlw(s
, RLWIMI
, a0
, a1
, 24, 0, 7);
1878 /* a0 = (a0 & ~0x0000ff00) | ((a1 r<< 24) & 0x0000ff00) # dcba */
1879 tcg_out_rlw(s
, RLWIMI
, a0
, a1
, 24, 16, 23);
1881 if (a0
== TCG_REG_R0
) {
1882 tcg_out_mov(s
, TCG_TYPE_I64
, args
[0], a0
);
1886 case INDEX_op_bswap64_i64
:
1887 a0
= args
[0], a1
= args
[1], a2
= 0;
1893 /* a1 = # abcd efgh */
1894 /* a0 = rl32(a1, 8) # 0000 fghe */
1895 tcg_out_rlw(s
, RLWINM
, a0
, a1
, 8, 0, 31);
1896 /* a0 = dep(a0, rl32(a1, 24), 0xff000000) # 0000 hghe */
1897 tcg_out_rlw(s
, RLWIMI
, a0
, a1
, 24, 0, 7);
1898 /* a0 = dep(a0, rl32(a1, 24), 0x0000ff00) # 0000 hgfe */
1899 tcg_out_rlw(s
, RLWIMI
, a0
, a1
, 24, 16, 23);
1901 /* a0 = rl64(a0, 32) # hgfe 0000 */
1902 /* a2 = rl64(a1, 32) # efgh abcd */
1903 tcg_out_rld(s
, RLDICL
, a0
, a0
, 32, 0);
1904 tcg_out_rld(s
, RLDICL
, a2
, a1
, 32, 0);
1906 /* a0 = dep(a0, rl32(a2, 8), 0xffffffff) # hgfe bcda */
1907 tcg_out_rlw(s
, RLWIMI
, a0
, a2
, 8, 0, 31);
1908 /* a0 = dep(a0, rl32(a2, 24), 0xff000000) # hgfe dcda */
1909 tcg_out_rlw(s
, RLWIMI
, a0
, a2
, 24, 0, 7);
1910 /* a0 = dep(a0, rl32(a2, 24), 0x0000ff00) # hgfe dcba */
1911 tcg_out_rlw(s
, RLWIMI
, a0
, a2
, 24, 16, 23);
1914 tcg_out_mov(s
, TCG_TYPE_I64
, args
[0], a0
);
1915 /* Revert the source rotate that we performed above. */
1916 tcg_out_rld(s
, RLDICL
, a1
, a1
, 32, 0);
1920 case INDEX_op_deposit_i32
:
1921 tcg_out_rlw(s
, RLWIMI
, args
[0], args
[2], args
[3],
1922 32 - args
[3] - args
[4], 31 - args
[3]);
1924 case INDEX_op_deposit_i64
:
1925 tcg_out_rld(s
, RLDIMI
, args
[0], args
[2], args
[3],
1926 64 - args
[3] - args
[4]);
1929 case INDEX_op_movcond_i32
:
1930 tcg_out_movcond(s
, TCG_TYPE_I32
, args
[5], args
[0], args
[1], args
[2],
1931 args
[3], args
[4], const_args
[2]);
1933 case INDEX_op_movcond_i64
:
1934 tcg_out_movcond(s
, TCG_TYPE_I64
, args
[5], args
[0], args
[1], args
[2],
1935 args
[3], args
[4], const_args
[2]);
1944 static const TCGTargetOpDef ppc_op_defs
[] = {
1945 { INDEX_op_exit_tb
, { } },
1946 { INDEX_op_goto_tb
, { } },
1947 { INDEX_op_call
, { "ri" } },
1948 { INDEX_op_br
, { } },
1950 { INDEX_op_mov_i32
, { "r", "r" } },
1951 { INDEX_op_mov_i64
, { "r", "r" } },
1952 { INDEX_op_movi_i32
, { "r" } },
1953 { INDEX_op_movi_i64
, { "r" } },
1955 { INDEX_op_ld8u_i32
, { "r", "r" } },
1956 { INDEX_op_ld8s_i32
, { "r", "r" } },
1957 { INDEX_op_ld16u_i32
, { "r", "r" } },
1958 { INDEX_op_ld16s_i32
, { "r", "r" } },
1959 { INDEX_op_ld_i32
, { "r", "r" } },
1960 { INDEX_op_ld_i64
, { "r", "r" } },
1961 { INDEX_op_st8_i32
, { "r", "r" } },
1962 { INDEX_op_st8_i64
, { "r", "r" } },
1963 { INDEX_op_st16_i32
, { "r", "r" } },
1964 { INDEX_op_st16_i64
, { "r", "r" } },
1965 { INDEX_op_st_i32
, { "r", "r" } },
1966 { INDEX_op_st_i64
, { "r", "r" } },
1967 { INDEX_op_st32_i64
, { "r", "r" } },
1969 { INDEX_op_ld8u_i64
, { "r", "r" } },
1970 { INDEX_op_ld8s_i64
, { "r", "r" } },
1971 { INDEX_op_ld16u_i64
, { "r", "r" } },
1972 { INDEX_op_ld16s_i64
, { "r", "r" } },
1973 { INDEX_op_ld32u_i64
, { "r", "r" } },
1974 { INDEX_op_ld32s_i64
, { "r", "r" } },
1976 { INDEX_op_add_i32
, { "r", "r", "ri" } },
1977 { INDEX_op_mul_i32
, { "r", "r", "rI" } },
1978 { INDEX_op_div_i32
, { "r", "r", "r" } },
1979 { INDEX_op_divu_i32
, { "r", "r", "r" } },
1980 { INDEX_op_rem_i32
, { "r", "r", "r" } },
1981 { INDEX_op_remu_i32
, { "r", "r", "r" } },
1982 { INDEX_op_sub_i32
, { "r", "rI", "ri" } },
1983 { INDEX_op_and_i32
, { "r", "r", "ri" } },
1984 { INDEX_op_or_i32
, { "r", "r", "ri" } },
1985 { INDEX_op_xor_i32
, { "r", "r", "ri" } },
1986 { INDEX_op_andc_i32
, { "r", "r", "ri" } },
1987 { INDEX_op_orc_i32
, { "r", "r", "ri" } },
1988 { INDEX_op_eqv_i32
, { "r", "r", "ri" } },
1989 { INDEX_op_nand_i32
, { "r", "r", "r" } },
1990 { INDEX_op_nor_i32
, { "r", "r", "r" } },
1992 { INDEX_op_shl_i32
, { "r", "r", "ri" } },
1993 { INDEX_op_shr_i32
, { "r", "r", "ri" } },
1994 { INDEX_op_sar_i32
, { "r", "r", "ri" } },
1995 { INDEX_op_rotl_i32
, { "r", "r", "ri" } },
1996 { INDEX_op_rotr_i32
, { "r", "r", "ri" } },
1998 { INDEX_op_brcond_i32
, { "r", "ri" } },
1999 { INDEX_op_brcond_i64
, { "r", "ri" } },
2001 { INDEX_op_neg_i32
, { "r", "r" } },
2002 { INDEX_op_not_i32
, { "r", "r" } },
2004 { INDEX_op_add_i64
, { "r", "r", "rT" } },
2005 { INDEX_op_sub_i64
, { "r", "rI", "rT" } },
2006 { INDEX_op_and_i64
, { "r", "r", "ri" } },
2007 { INDEX_op_or_i64
, { "r", "r", "rU" } },
2008 { INDEX_op_xor_i64
, { "r", "r", "rU" } },
2009 { INDEX_op_andc_i64
, { "r", "r", "ri" } },
2010 { INDEX_op_orc_i64
, { "r", "r", "r" } },
2011 { INDEX_op_eqv_i64
, { "r", "r", "r" } },
2012 { INDEX_op_nand_i64
, { "r", "r", "r" } },
2013 { INDEX_op_nor_i64
, { "r", "r", "r" } },
2015 { INDEX_op_shl_i64
, { "r", "r", "ri" } },
2016 { INDEX_op_shr_i64
, { "r", "r", "ri" } },
2017 { INDEX_op_sar_i64
, { "r", "r", "ri" } },
2018 { INDEX_op_rotl_i64
, { "r", "r", "ri" } },
2019 { INDEX_op_rotr_i64
, { "r", "r", "ri" } },
2021 { INDEX_op_mul_i64
, { "r", "r", "rI" } },
2022 { INDEX_op_div_i64
, { "r", "r", "r" } },
2023 { INDEX_op_divu_i64
, { "r", "r", "r" } },
2024 { INDEX_op_rem_i64
, { "r", "r", "r" } },
2025 { INDEX_op_remu_i64
, { "r", "r", "r" } },
2027 { INDEX_op_neg_i64
, { "r", "r" } },
2028 { INDEX_op_not_i64
, { "r", "r" } },
2030 { INDEX_op_qemu_ld8u
, { "r", "L" } },
2031 { INDEX_op_qemu_ld8s
, { "r", "L" } },
2032 { INDEX_op_qemu_ld16u
, { "r", "L" } },
2033 { INDEX_op_qemu_ld16s
, { "r", "L" } },
2034 { INDEX_op_qemu_ld32
, { "r", "L" } },
2035 { INDEX_op_qemu_ld32u
, { "r", "L" } },
2036 { INDEX_op_qemu_ld32s
, { "r", "L" } },
2037 { INDEX_op_qemu_ld64
, { "r", "L" } },
2039 { INDEX_op_qemu_st8
, { "S", "S" } },
2040 { INDEX_op_qemu_st16
, { "S", "S" } },
2041 { INDEX_op_qemu_st32
, { "S", "S" } },
2042 { INDEX_op_qemu_st64
, { "S", "S" } },
2044 { INDEX_op_ext8s_i32
, { "r", "r" } },
2045 { INDEX_op_ext16s_i32
, { "r", "r" } },
2046 { INDEX_op_ext8s_i64
, { "r", "r" } },
2047 { INDEX_op_ext16s_i64
, { "r", "r" } },
2048 { INDEX_op_ext32s_i64
, { "r", "r" } },
2050 { INDEX_op_setcond_i32
, { "r", "r", "ri" } },
2051 { INDEX_op_setcond_i64
, { "r", "r", "ri" } },
2052 { INDEX_op_movcond_i32
, { "r", "r", "ri", "rZ", "rZ" } },
2053 { INDEX_op_movcond_i64
, { "r", "r", "ri", "rZ", "rZ" } },
2055 { INDEX_op_bswap16_i32
, { "r", "r" } },
2056 { INDEX_op_bswap16_i64
, { "r", "r" } },
2057 { INDEX_op_bswap32_i32
, { "r", "r" } },
2058 { INDEX_op_bswap32_i64
, { "r", "r" } },
2059 { INDEX_op_bswap64_i64
, { "r", "r" } },
2061 { INDEX_op_deposit_i32
, { "r", "0", "r" } },
2062 { INDEX_op_deposit_i64
, { "r", "0", "r" } },
2067 static void tcg_target_init (TCGContext
*s
)
2069 #ifdef CONFIG_GETAUXVAL
2070 unsigned long hwcap
= getauxval(AT_HWCAP
);
2071 if (hwcap
& PPC_FEATURE_ARCH_2_06
) {
2072 have_isa_2_06
= true;
2076 tcg_regset_set32 (tcg_target_available_regs
[TCG_TYPE_I32
], 0, 0xffffffff);
2077 tcg_regset_set32 (tcg_target_available_regs
[TCG_TYPE_I64
], 0, 0xffffffff);
2078 tcg_regset_set32 (tcg_target_call_clobber_regs
, 0,
2090 (1 << TCG_REG_R10
) |
2091 (1 << TCG_REG_R11
) |
2095 tcg_regset_clear (s
->reserved_regs
);
2096 tcg_regset_set_reg (s
->reserved_regs
, TCG_REG_R0
);
2097 tcg_regset_set_reg (s
->reserved_regs
, TCG_REG_R1
);
2099 tcg_regset_set_reg (s
->reserved_regs
, TCG_REG_R2
);
2101 tcg_regset_set_reg (s
->reserved_regs
, TCG_REG_R13
);
2103 tcg_add_target_add_op_defs (ppc_op_defs
);