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
26 static const char * const tcg_target_reg_names
[TCG_TARGET_NB_REGS
] = {
62 static const int tcg_target_reg_alloc_order
[] = {
78 static const int tcg_target_call_iarg_regs
[6] = {
87 static const int tcg_target_call_oarg_regs
[2] = {
92 static inline int check_fit_tl(tcg_target_long val
, unsigned int bits
)
94 return (val
<< ((sizeof(tcg_target_long
) * 8 - bits
))
95 >> (sizeof(tcg_target_long
) * 8 - bits
)) == val
;
98 static inline int check_fit_i32(uint32_t val
, unsigned int bits
)
100 return ((val
<< (32 - bits
)) >> (32 - bits
)) == val
;
103 static void patch_reloc(uint8_t *code_ptr
, int type
,
104 tcg_target_long value
, tcg_target_long addend
)
109 if (value
!= (uint32_t)value
)
111 *(uint32_t *)code_ptr
= value
;
113 case R_SPARC_WDISP22
:
114 value
-= (long)code_ptr
;
116 if (!check_fit_tl(value
, 22))
118 *(uint32_t *)code_ptr
= ((*(uint32_t *)code_ptr
) & ~0x3fffff) | value
;
120 case R_SPARC_WDISP19
:
121 value
-= (long)code_ptr
;
123 if (!check_fit_tl(value
, 19))
125 *(uint32_t *)code_ptr
= ((*(uint32_t *)code_ptr
) & ~0x7ffff) | value
;
132 /* maximum number of register used for input function arguments */
133 static inline int tcg_target_get_call_iarg_regs_count(int flags
)
138 /* parse target specific constraints */
139 static int target_parse_constraint(TCGArgConstraint
*ct
, const char **pct_str
)
146 ct
->ct
|= TCG_CT_REG
;
147 tcg_regset_set32(ct
->u
.regs
, 0, 0xffffffff);
149 case 'L': /* qemu_ld/st constraint */
150 ct
->ct
|= TCG_CT_REG
;
151 tcg_regset_set32(ct
->u
.regs
, 0, 0xffffffff);
153 tcg_regset_reset_reg(ct
->u
.regs
, TCG_REG_O0
);
154 tcg_regset_reset_reg(ct
->u
.regs
, TCG_REG_O1
);
155 tcg_regset_reset_reg(ct
->u
.regs
, TCG_REG_O2
);
158 ct
->ct
|= TCG_CT_CONST_S11
;
161 ct
->ct
|= TCG_CT_CONST_S13
;
171 /* test if a constant matches the constraint */
172 static inline int tcg_target_const_match(tcg_target_long val
,
173 const TCGArgConstraint
*arg_ct
)
178 if (ct
& TCG_CT_CONST
)
180 else if ((ct
& TCG_CT_CONST_S11
) && check_fit_tl(val
, 11))
182 else if ((ct
& TCG_CT_CONST_S13
) && check_fit_tl(val
, 13))
188 #define INSN_OP(x) ((x) << 30)
189 #define INSN_OP2(x) ((x) << 22)
190 #define INSN_OP3(x) ((x) << 19)
191 #define INSN_OPF(x) ((x) << 5)
192 #define INSN_RD(x) ((x) << 25)
193 #define INSN_RS1(x) ((x) << 14)
194 #define INSN_RS2(x) (x)
195 #define INSN_ASI(x) ((x) << 5)
197 #define INSN_IMM13(x) ((1 << 13) | ((x) & 0x1fff))
198 #define INSN_OFF19(x) (((x) >> 2) & 0x07ffff)
199 #define INSN_OFF22(x) (((x) >> 2) & 0x3fffff)
201 #define INSN_COND(x, a) (((x) << 25) | ((a) << 29))
218 #define BA (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2))
220 #define ARITH_ADD (INSN_OP(2) | INSN_OP3(0x00))
221 #define ARITH_ADDCC (INSN_OP(2) | INSN_OP3(0x10))
222 #define ARITH_AND (INSN_OP(2) | INSN_OP3(0x01))
223 #define ARITH_OR (INSN_OP(2) | INSN_OP3(0x02))
224 #define ARITH_ORCC (INSN_OP(2) | INSN_OP3(0x12))
225 #define ARITH_XOR (INSN_OP(2) | INSN_OP3(0x03))
226 #define ARITH_SUB (INSN_OP(2) | INSN_OP3(0x04))
227 #define ARITH_SUBCC (INSN_OP(2) | INSN_OP3(0x14))
228 #define ARITH_ADDX (INSN_OP(2) | INSN_OP3(0x10))
229 #define ARITH_SUBX (INSN_OP(2) | INSN_OP3(0x0c))
230 #define ARITH_UMUL (INSN_OP(2) | INSN_OP3(0x0a))
231 #define ARITH_UDIV (INSN_OP(2) | INSN_OP3(0x0e))
232 #define ARITH_SDIV (INSN_OP(2) | INSN_OP3(0x0f))
233 #define ARITH_MULX (INSN_OP(2) | INSN_OP3(0x09))
234 #define ARITH_UDIVX (INSN_OP(2) | INSN_OP3(0x0d))
235 #define ARITH_SDIVX (INSN_OP(2) | INSN_OP3(0x2d))
237 #define SHIFT_SLL (INSN_OP(2) | INSN_OP3(0x25))
238 #define SHIFT_SRL (INSN_OP(2) | INSN_OP3(0x26))
239 #define SHIFT_SRA (INSN_OP(2) | INSN_OP3(0x27))
241 #define SHIFT_SLLX (INSN_OP(2) | INSN_OP3(0x25) | (1 << 12))
242 #define SHIFT_SRLX (INSN_OP(2) | INSN_OP3(0x26) | (1 << 12))
243 #define SHIFT_SRAX (INSN_OP(2) | INSN_OP3(0x27) | (1 << 12))
245 #define RDY (INSN_OP(2) | INSN_OP3(0x28) | INSN_RS1(0))
246 #define WRY (INSN_OP(2) | INSN_OP3(0x30))
247 #define JMPL (INSN_OP(2) | INSN_OP3(0x38))
248 #define SAVE (INSN_OP(2) | INSN_OP3(0x3c))
249 #define RESTORE (INSN_OP(2) | INSN_OP3(0x3d))
250 #define SETHI (INSN_OP(0) | INSN_OP2(0x4))
251 #define CALL INSN_OP(1)
252 #define LDUB (INSN_OP(3) | INSN_OP3(0x01))
253 #define LDSB (INSN_OP(3) | INSN_OP3(0x09))
254 #define LDUH (INSN_OP(3) | INSN_OP3(0x02))
255 #define LDSH (INSN_OP(3) | INSN_OP3(0x0a))
256 #define LDUW (INSN_OP(3) | INSN_OP3(0x00))
257 #define LDSW (INSN_OP(3) | INSN_OP3(0x08))
258 #define LDX (INSN_OP(3) | INSN_OP3(0x0b))
259 #define STB (INSN_OP(3) | INSN_OP3(0x05))
260 #define STH (INSN_OP(3) | INSN_OP3(0x06))
261 #define STW (INSN_OP(3) | INSN_OP3(0x04))
262 #define STX (INSN_OP(3) | INSN_OP3(0x0e))
263 #define LDUBA (INSN_OP(3) | INSN_OP3(0x11))
264 #define LDSBA (INSN_OP(3) | INSN_OP3(0x19))
265 #define LDUHA (INSN_OP(3) | INSN_OP3(0x12))
266 #define LDSHA (INSN_OP(3) | INSN_OP3(0x1a))
267 #define LDUWA (INSN_OP(3) | INSN_OP3(0x10))
268 #define LDSWA (INSN_OP(3) | INSN_OP3(0x18))
269 #define LDXA (INSN_OP(3) | INSN_OP3(0x1b))
270 #define STBA (INSN_OP(3) | INSN_OP3(0x15))
271 #define STHA (INSN_OP(3) | INSN_OP3(0x16))
272 #define STWA (INSN_OP(3) | INSN_OP3(0x14))
273 #define STXA (INSN_OP(3) | INSN_OP3(0x1e))
275 #ifndef ASI_PRIMARY_LITTLE
276 #define ASI_PRIMARY_LITTLE 0x88
279 static inline void tcg_out_arith(TCGContext
*s
, int rd
, int rs1
, int rs2
,
282 tcg_out32(s
, op
| INSN_RD(rd
) | INSN_RS1(rs1
) |
286 static inline void tcg_out_arithi(TCGContext
*s
, int rd
, int rs1
,
287 uint32_t offset
, int op
)
289 tcg_out32(s
, op
| INSN_RD(rd
) | INSN_RS1(rs1
) |
293 static void tcg_out_arithc(TCGContext
*s
, int rd
, int rs1
,
294 int val2
, int val2const
, int op
)
296 tcg_out32(s
, op
| INSN_RD(rd
) | INSN_RS1(rs1
)
297 | (val2const
? INSN_IMM13(val2
) : INSN_RS2(val2
)));
300 static inline void tcg_out_mov(TCGContext
*s
, int ret
, int arg
)
302 tcg_out_arith(s
, ret
, arg
, TCG_REG_G0
, ARITH_OR
);
305 static inline void tcg_out_sethi(TCGContext
*s
, int ret
, uint32_t arg
)
307 tcg_out32(s
, SETHI
| INSN_RD(ret
) | ((arg
& 0xfffffc00) >> 10));
310 static inline void tcg_out_movi_imm13(TCGContext
*s
, int ret
, uint32_t arg
)
312 tcg_out_arithi(s
, ret
, TCG_REG_G0
, arg
, ARITH_OR
);
315 static inline void tcg_out_movi_imm32(TCGContext
*s
, int ret
, uint32_t arg
)
317 if (check_fit_tl(arg
, 13))
318 tcg_out_movi_imm13(s
, ret
, arg
);
320 tcg_out_sethi(s
, ret
, arg
);
322 tcg_out_arithi(s
, ret
, ret
, arg
& 0x3ff, ARITH_OR
);
326 static inline void tcg_out_movi(TCGContext
*s
, TCGType type
,
327 int ret
, tcg_target_long arg
)
329 /* All 32-bit constants, as well as 64-bit constants with
330 no high bits set go through movi_imm32. */
331 if (TCG_TARGET_REG_BITS
== 32
332 || type
== TCG_TYPE_I32
333 || (arg
& ~(tcg_target_long
)0xffffffff) == 0) {
334 tcg_out_movi_imm32(s
, ret
, arg
);
335 } else if (check_fit_tl(arg
, 13)) {
336 /* A 13-bit constant sign-extended to 64-bits. */
337 tcg_out_movi_imm13(s
, ret
, arg
);
338 } else if (check_fit_tl(arg
, 32)) {
339 /* A 32-bit constant sign-extended to 64-bits. */
340 tcg_out_sethi(s
, ret
, ~arg
);
341 tcg_out_arithi(s
, ret
, ret
, (arg
& 0x3ff) | -0x400, ARITH_XOR
);
343 tcg_out_movi_imm32(s
, TCG_REG_I4
, arg
>> (TCG_TARGET_REG_BITS
/ 2));
344 tcg_out_arithi(s
, TCG_REG_I4
, TCG_REG_I4
, 32, SHIFT_SLLX
);
345 tcg_out_movi_imm32(s
, ret
, arg
);
346 tcg_out_arith(s
, ret
, ret
, TCG_REG_I4
, ARITH_OR
);
350 static inline void tcg_out_ld_raw(TCGContext
*s
, int ret
,
353 tcg_out_sethi(s
, ret
, arg
);
354 tcg_out32(s
, LDUW
| INSN_RD(ret
) | INSN_RS1(ret
) |
355 INSN_IMM13(arg
& 0x3ff));
358 static inline void tcg_out_ld_ptr(TCGContext
*s
, int ret
,
361 if (!check_fit_tl(arg
, 10))
362 tcg_out_movi(s
, TCG_TYPE_PTR
, ret
, arg
& ~0x3ffULL
);
363 if (TCG_TARGET_REG_BITS
== 64) {
364 tcg_out32(s
, LDX
| INSN_RD(ret
) | INSN_RS1(ret
) |
365 INSN_IMM13(arg
& 0x3ff));
367 tcg_out32(s
, LDUW
| INSN_RD(ret
) | INSN_RS1(ret
) |
368 INSN_IMM13(arg
& 0x3ff));
372 static inline void tcg_out_ldst(TCGContext
*s
, int ret
, int addr
, int offset
, int op
)
374 if (check_fit_tl(offset
, 13))
375 tcg_out32(s
, op
| INSN_RD(ret
) | INSN_RS1(addr
) |
378 tcg_out_movi(s
, TCG_TYPE_PTR
, TCG_REG_I5
, offset
);
379 tcg_out32(s
, op
| INSN_RD(ret
) | INSN_RS1(TCG_REG_I5
) |
384 static inline void tcg_out_ldst_asi(TCGContext
*s
, int ret
, int addr
,
385 int offset
, int op
, int asi
)
387 tcg_out_movi(s
, TCG_TYPE_PTR
, TCG_REG_I5
, offset
);
388 tcg_out32(s
, op
| INSN_RD(ret
) | INSN_RS1(TCG_REG_I5
) |
389 INSN_ASI(asi
) | INSN_RS2(addr
));
392 static inline void tcg_out_ld(TCGContext
*s
, TCGType type
, int ret
,
393 int arg1
, tcg_target_long arg2
)
395 if (type
== TCG_TYPE_I32
)
396 tcg_out_ldst(s
, ret
, arg1
, arg2
, LDUW
);
398 tcg_out_ldst(s
, ret
, arg1
, arg2
, LDX
);
401 static inline void tcg_out_st(TCGContext
*s
, TCGType type
, int arg
,
402 int arg1
, tcg_target_long arg2
)
404 if (type
== TCG_TYPE_I32
)
405 tcg_out_ldst(s
, arg
, arg1
, arg2
, STW
);
407 tcg_out_ldst(s
, arg
, arg1
, arg2
, STX
);
410 static inline void tcg_out_sety(TCGContext
*s
, tcg_target_long val
)
412 if (val
== 0 || val
== -1)
413 tcg_out32(s
, WRY
| INSN_IMM13(val
));
415 fprintf(stderr
, "unimplemented sety %ld\n", (long)val
);
418 static inline void tcg_out_rdy(TCGContext
*s
, int rd
)
420 tcg_out32(s
, RDY
| INSN_RD(rd
));
423 static inline void tcg_out_addi(TCGContext
*s
, int reg
, tcg_target_long val
)
426 if (check_fit_tl(val
, 13))
427 tcg_out_arithi(s
, reg
, reg
, val
, ARITH_ADD
);
429 tcg_out_movi(s
, TCG_TYPE_PTR
, TCG_REG_I5
, val
);
430 tcg_out_arith(s
, reg
, reg
, TCG_REG_I5
, ARITH_ADD
);
435 static inline void tcg_out_andi(TCGContext
*s
, int reg
, tcg_target_long val
)
438 if (check_fit_tl(val
, 13))
439 tcg_out_arithi(s
, reg
, reg
, val
, ARITH_AND
);
441 tcg_out_movi(s
, TCG_TYPE_I32
, TCG_REG_I5
, val
);
442 tcg_out_arith(s
, reg
, reg
, TCG_REG_I5
, ARITH_AND
);
447 static inline void tcg_out_nop(TCGContext
*s
)
449 tcg_out_sethi(s
, TCG_REG_G0
, 0);
452 static void tcg_out_branch_i32(TCGContext
*s
, int opc
, int label_index
)
455 TCGLabel
*l
= &s
->labels
[label_index
];
458 val
= l
->u
.value
- (tcg_target_long
)s
->code_ptr
;
459 tcg_out32(s
, (INSN_OP(0) | INSN_COND(opc
, 0) | INSN_OP2(0x2)
460 | INSN_OFF22(l
->u
.value
- (unsigned long)s
->code_ptr
)));
462 tcg_out_reloc(s
, s
->code_ptr
, R_SPARC_WDISP22
, label_index
, 0);
463 tcg_out32(s
, (INSN_OP(0) | INSN_COND(opc
, 0) | INSN_OP2(0x2) | 0));
467 #if TCG_TARGET_REG_BITS == 64
468 static void tcg_out_branch_i64(TCGContext
*s
, int opc
, int label_index
)
471 TCGLabel
*l
= &s
->labels
[label_index
];
474 val
= l
->u
.value
- (tcg_target_long
)s
->code_ptr
;
475 tcg_out32(s
, (INSN_OP(0) | INSN_COND(opc
, 0) | INSN_OP2(0x1) |
477 INSN_OFF19(l
->u
.value
- (unsigned long)s
->code_ptr
)));
479 tcg_out_reloc(s
, s
->code_ptr
, R_SPARC_WDISP19
, label_index
, 0);
480 tcg_out32(s
, (INSN_OP(0) | INSN_COND(opc
, 0) | INSN_OP2(0x1) |
486 static const uint8_t tcg_cond_to_bcond
[10] = {
487 [TCG_COND_EQ
] = COND_E
,
488 [TCG_COND_NE
] = COND_NE
,
489 [TCG_COND_LT
] = COND_L
,
490 [TCG_COND_GE
] = COND_GE
,
491 [TCG_COND_LE
] = COND_LE
,
492 [TCG_COND_GT
] = COND_G
,
493 [TCG_COND_LTU
] = COND_CS
,
494 [TCG_COND_GEU
] = COND_CC
,
495 [TCG_COND_LEU
] = COND_LEU
,
496 [TCG_COND_GTU
] = COND_GU
,
499 static void tcg_out_cmp(TCGContext
*s
, TCGArg c1
, TCGArg c2
, int c2const
)
501 tcg_out_arithc(s
, TCG_REG_G0
, c1
, c2
, c2const
, ARITH_SUBCC
);
504 static void tcg_out_brcond_i32(TCGContext
*s
, int cond
,
505 TCGArg arg1
, TCGArg arg2
, int const_arg2
,
508 tcg_out_cmp(s
, arg1
, arg2
, const_arg2
);
509 tcg_out_branch_i32(s
, tcg_cond_to_bcond
[cond
], label_index
);
513 #if TCG_TARGET_REG_BITS == 64
514 static void tcg_out_brcond_i64(TCGContext
*s
, int cond
,
515 TCGArg arg1
, TCGArg arg2
, int const_arg2
,
518 tcg_out_cmp(s
, arg1
, arg2
, const_arg2
);
519 tcg_out_branch_i64(s
, tcg_cond_to_bcond
[cond
], label_index
);
523 static void tcg_out_brcond2_i32(TCGContext
*s
, int cond
,
524 TCGArg al
, TCGArg ah
,
525 TCGArg bl
, int blconst
,
526 TCGArg bh
, int bhconst
, int label_dest
)
528 int cc
, label_next
= gen_new_label();
530 tcg_out_cmp(s
, ah
, bh
, bhconst
);
532 /* Note that we fill one of the delay slots with the second compare. */
535 cc
= INSN_COND(tcg_cond_to_bcond
[TCG_COND_NE
], 0);
536 tcg_out_branch_i32(s
, cc
, label_next
);
537 tcg_out_cmp(s
, al
, bl
, blconst
);
538 cc
= INSN_COND(tcg_cond_to_bcond
[TCG_COND_EQ
], 0);
539 tcg_out_branch_i32(s
, cc
, label_dest
);
543 cc
= INSN_COND(tcg_cond_to_bcond
[TCG_COND_NE
], 0);
544 tcg_out_branch_i32(s
, cc
, label_dest
);
545 tcg_out_cmp(s
, al
, bl
, blconst
);
546 tcg_out_branch_i32(s
, cc
, label_dest
);
550 /* ??? One could fairly easily special-case 64-bit unsigned
551 compares against 32-bit zero-extended constants. For instance,
552 we know that (unsigned)AH < 0 is false and need not emit it.
553 Similarly, (unsigned)AH > 0 being true implies AH != 0, so the
554 second branch will never be taken. */
555 cc
= INSN_COND(tcg_cond_to_bcond
[cond
], 0);
556 tcg_out_branch_i32(s
, cc
, label_dest
);
558 cc
= INSN_COND(tcg_cond_to_bcond
[TCG_COND_NE
], 0);
559 tcg_out_branch_i32(s
, cc
, label_next
);
560 tcg_out_cmp(s
, al
, bl
, blconst
);
561 cc
= INSN_COND(tcg_cond_to_bcond
[tcg_unsigned_cond(cond
)], 0);
562 tcg_out_branch_i32(s
, cc
, label_dest
);
567 tcg_out_label(s
, label_next
, (tcg_target_long
)s
->code_ptr
);
571 /* Generate global QEMU prologue and epilogue code */
572 void tcg_target_qemu_prologue(TCGContext
*s
)
574 tcg_out32(s
, SAVE
| INSN_RD(TCG_REG_O6
) | INSN_RS1(TCG_REG_O6
) |
575 INSN_IMM13(-TCG_TARGET_STACK_MINFRAME
));
576 tcg_out32(s
, JMPL
| INSN_RD(TCG_REG_G0
) | INSN_RS1(TCG_REG_I0
) |
577 INSN_RS2(TCG_REG_G0
));
581 #if defined(CONFIG_SOFTMMU)
583 #include "../../softmmu_defs.h"
585 static const void * const qemu_ld_helpers
[4] = {
592 static const void * const qemu_st_helpers
[4] = {
600 #if TARGET_LONG_BITS == 32
601 #define TARGET_LD_OP LDUW
603 #define TARGET_LD_OP LDX
606 #if TARGET_PHYS_ADDR_BITS == 32
607 #define TARGET_ADDEND_LD_OP LDUW
609 #define TARGET_ADDEND_LD_OP LDX
613 #define HOST_LD_OP LDX
614 #define HOST_ST_OP STX
615 #define HOST_SLL_OP SHIFT_SLLX
616 #define HOST_SRA_OP SHIFT_SRAX
618 #define HOST_LD_OP LDUW
619 #define HOST_ST_OP STW
620 #define HOST_SLL_OP SHIFT_SLL
621 #define HOST_SRA_OP SHIFT_SRA
624 static void tcg_out_qemu_ld(TCGContext
*s
, const TCGArg
*args
,
627 int addr_reg
, data_reg
, arg0
, arg1
, arg2
, mem_index
, s_bits
;
628 #if defined(CONFIG_SOFTMMU)
629 uint32_t *label1_ptr
, *label2_ptr
;
641 #if defined(CONFIG_SOFTMMU)
642 /* srl addr_reg, x, arg1 */
643 tcg_out_arithi(s
, arg1
, addr_reg
, TARGET_PAGE_BITS
- CPU_TLB_ENTRY_BITS
,
645 /* and addr_reg, x, arg0 */
646 tcg_out_arithi(s
, arg0
, addr_reg
, TARGET_PAGE_MASK
| ((1 << s_bits
) - 1),
649 /* and arg1, x, arg1 */
650 tcg_out_andi(s
, arg1
, (CPU_TLB_SIZE
- 1) << CPU_TLB_ENTRY_BITS
);
652 /* add arg1, x, arg1 */
653 tcg_out_addi(s
, arg1
, offsetof(CPUState
,
654 tlb_table
[mem_index
][0].addr_read
));
656 /* add env, arg1, arg1 */
657 tcg_out_arith(s
, arg1
, TCG_AREG0
, arg1
, ARITH_ADD
);
659 /* ld [arg1], arg2 */
660 tcg_out32(s
, TARGET_LD_OP
| INSN_RD(arg2
) | INSN_RS1(arg1
) |
661 INSN_RS2(TCG_REG_G0
));
663 /* subcc arg0, arg2, %g0 */
664 tcg_out_arith(s
, TCG_REG_G0
, arg0
, arg2
, ARITH_SUBCC
);
670 label1_ptr
= (uint32_t *)s
->code_ptr
;
673 /* mov (delay slot) */
674 tcg_out_mov(s
, arg0
, addr_reg
);
677 tcg_out_movi(s
, TCG_TYPE_I32
, arg1
, mem_index
);
679 /* XXX: move that code at the end of the TB */
680 /* qemu_ld_helper[s_bits](arg0, arg1) */
681 tcg_out32(s
, CALL
| ((((tcg_target_ulong
)qemu_ld_helpers
[s_bits
]
682 - (tcg_target_ulong
)s
->code_ptr
) >> 2)
684 /* Store AREG0 in stack to avoid ugly glibc bugs that mangle
687 tcg_out_ldst(s
, TCG_AREG0
, TCG_REG_CALL_STACK
,
688 TCG_TARGET_CALL_STACK_OFFSET
- TCG_STATIC_CALL_ARGS_SIZE
-
689 sizeof(long), HOST_ST_OP
);
690 tcg_out_ldst(s
, TCG_AREG0
, TCG_REG_CALL_STACK
,
691 TCG_TARGET_CALL_STACK_OFFSET
- TCG_STATIC_CALL_ARGS_SIZE
-
692 sizeof(long), HOST_LD_OP
);
694 /* data_reg = sign_extend(arg0) */
697 /* sll arg0, 24/56, data_reg */
698 tcg_out_arithi(s
, data_reg
, arg0
, (int)sizeof(tcg_target_long
) * 8 - 8,
700 /* sra data_reg, 24/56, data_reg */
701 tcg_out_arithi(s
, data_reg
, data_reg
,
702 (int)sizeof(tcg_target_long
) * 8 - 8, HOST_SRA_OP
);
705 /* sll arg0, 16/48, data_reg */
706 tcg_out_arithi(s
, data_reg
, arg0
,
707 (int)sizeof(tcg_target_long
) * 8 - 16, HOST_SLL_OP
);
708 /* sra data_reg, 16/48, data_reg */
709 tcg_out_arithi(s
, data_reg
, data_reg
,
710 (int)sizeof(tcg_target_long
) * 8 - 16, HOST_SRA_OP
);
713 /* sll arg0, 32, data_reg */
714 tcg_out_arithi(s
, data_reg
, arg0
, 32, HOST_SLL_OP
);
715 /* sra data_reg, 32, data_reg */
716 tcg_out_arithi(s
, data_reg
, data_reg
, 32, HOST_SRA_OP
);
724 tcg_out_mov(s
, data_reg
, arg0
);
730 label2_ptr
= (uint32_t *)s
->code_ptr
;
733 /* nop (delay slot */
737 #if TARGET_LONG_BITS == 32
739 *label1_ptr
= (INSN_OP(0) | INSN_COND(COND_E
, 0) | INSN_OP2(0x2) |
740 INSN_OFF22((unsigned long)s
->code_ptr
-
741 (unsigned long)label1_ptr
));
743 /* be,pt %xcc label1 */
744 *label1_ptr
= (INSN_OP(0) | INSN_COND(COND_E
, 0) | INSN_OP2(0x1) |
745 (0x5 << 19) | INSN_OFF19((unsigned long)s
->code_ptr
-
746 (unsigned long)label1_ptr
));
749 /* ld [arg1 + x], arg1 */
750 tcg_out_ldst(s
, arg1
, arg1
, offsetof(CPUTLBEntry
, addend
) -
751 offsetof(CPUTLBEntry
, addr_read
), TARGET_ADDEND_LD_OP
);
753 #if TARGET_LONG_BITS == 32
754 /* and addr_reg, x, arg0 */
755 tcg_out_movi(s
, TCG_TYPE_I32
, TCG_REG_I5
, 0xffffffff);
756 tcg_out_arith(s
, arg0
, addr_reg
, TCG_REG_I5
, ARITH_AND
);
757 /* add arg0, arg1, arg0 */
758 tcg_out_arith(s
, arg0
, arg0
, arg1
, ARITH_ADD
);
760 /* add addr_reg, arg1, arg0 */
761 tcg_out_arith(s
, arg0
, addr_reg
, arg1
, ARITH_ADD
);
770 /* ldub [arg0], data_reg */
771 tcg_out_ldst(s
, data_reg
, arg0
, 0, LDUB
);
774 /* ldsb [arg0], data_reg */
775 tcg_out_ldst(s
, data_reg
, arg0
, 0, LDSB
);
778 #ifdef TARGET_WORDS_BIGENDIAN
779 /* lduh [arg0], data_reg */
780 tcg_out_ldst(s
, data_reg
, arg0
, 0, LDUH
);
782 /* lduha [arg0] ASI_PRIMARY_LITTLE, data_reg */
783 tcg_out_ldst_asi(s
, data_reg
, arg0
, 0, LDUHA
, ASI_PRIMARY_LITTLE
);
787 #ifdef TARGET_WORDS_BIGENDIAN
788 /* ldsh [arg0], data_reg */
789 tcg_out_ldst(s
, data_reg
, arg0
, 0, LDSH
);
791 /* ldsha [arg0] ASI_PRIMARY_LITTLE, data_reg */
792 tcg_out_ldst_asi(s
, data_reg
, arg0
, 0, LDSHA
, ASI_PRIMARY_LITTLE
);
796 #ifdef TARGET_WORDS_BIGENDIAN
797 /* lduw [arg0], data_reg */
798 tcg_out_ldst(s
, data_reg
, arg0
, 0, LDUW
);
800 /* lduwa [arg0] ASI_PRIMARY_LITTLE, data_reg */
801 tcg_out_ldst_asi(s
, data_reg
, arg0
, 0, LDUWA
, ASI_PRIMARY_LITTLE
);
805 #ifdef TARGET_WORDS_BIGENDIAN
806 /* ldsw [arg0], data_reg */
807 tcg_out_ldst(s
, data_reg
, arg0
, 0, LDSW
);
809 /* ldswa [arg0] ASI_PRIMARY_LITTLE, data_reg */
810 tcg_out_ldst_asi(s
, data_reg
, arg0
, 0, LDSWA
, ASI_PRIMARY_LITTLE
);
814 #ifdef TARGET_WORDS_BIGENDIAN
815 /* ldx [arg0], data_reg */
816 tcg_out_ldst(s
, data_reg
, arg0
, 0, LDX
);
818 /* ldxa [arg0] ASI_PRIMARY_LITTLE, data_reg */
819 tcg_out_ldst_asi(s
, data_reg
, arg0
, 0, LDXA
, ASI_PRIMARY_LITTLE
);
826 #if defined(CONFIG_SOFTMMU)
828 *label2_ptr
= (INSN_OP(0) | INSN_COND(COND_A
, 0) | INSN_OP2(0x2) |
829 INSN_OFF22((unsigned long)s
->code_ptr
-
830 (unsigned long)label2_ptr
));
834 static void tcg_out_qemu_st(TCGContext
*s
, const TCGArg
*args
,
837 int addr_reg
, data_reg
, arg0
, arg1
, arg2
, mem_index
, s_bits
;
838 #if defined(CONFIG_SOFTMMU)
839 uint32_t *label1_ptr
, *label2_ptr
;
852 #if defined(CONFIG_SOFTMMU)
853 /* srl addr_reg, x, arg1 */
854 tcg_out_arithi(s
, arg1
, addr_reg
, TARGET_PAGE_BITS
- CPU_TLB_ENTRY_BITS
,
857 /* and addr_reg, x, arg0 */
858 tcg_out_arithi(s
, arg0
, addr_reg
, TARGET_PAGE_MASK
| ((1 << s_bits
) - 1),
861 /* and arg1, x, arg1 */
862 tcg_out_andi(s
, arg1
, (CPU_TLB_SIZE
- 1) << CPU_TLB_ENTRY_BITS
);
864 /* add arg1, x, arg1 */
865 tcg_out_addi(s
, arg1
, offsetof(CPUState
,
866 tlb_table
[mem_index
][0].addr_write
));
868 /* add env, arg1, arg1 */
869 tcg_out_arith(s
, arg1
, TCG_AREG0
, arg1
, ARITH_ADD
);
871 /* ld [arg1], arg2 */
872 tcg_out32(s
, TARGET_LD_OP
| INSN_RD(arg2
) | INSN_RS1(arg1
) |
873 INSN_RS2(TCG_REG_G0
));
875 /* subcc arg0, arg2, %g0 */
876 tcg_out_arith(s
, TCG_REG_G0
, arg0
, arg2
, ARITH_SUBCC
);
882 label1_ptr
= (uint32_t *)s
->code_ptr
;
885 /* mov (delay slot) */
886 tcg_out_mov(s
, arg0
, addr_reg
);
889 tcg_out_mov(s
, arg1
, data_reg
);
892 tcg_out_movi(s
, TCG_TYPE_I32
, arg2
, mem_index
);
894 /* XXX: move that code at the end of the TB */
895 /* qemu_st_helper[s_bits](arg0, arg1, arg2) */
896 tcg_out32(s
, CALL
| ((((tcg_target_ulong
)qemu_st_helpers
[s_bits
]
897 - (tcg_target_ulong
)s
->code_ptr
) >> 2)
899 /* Store AREG0 in stack to avoid ugly glibc bugs that mangle
902 tcg_out_ldst(s
, TCG_AREG0
, TCG_REG_CALL_STACK
,
903 TCG_TARGET_CALL_STACK_OFFSET
- TCG_STATIC_CALL_ARGS_SIZE
-
904 sizeof(long), HOST_ST_OP
);
905 tcg_out_ldst(s
, TCG_AREG0
, TCG_REG_CALL_STACK
,
906 TCG_TARGET_CALL_STACK_OFFSET
- TCG_STATIC_CALL_ARGS_SIZE
-
907 sizeof(long), HOST_LD_OP
);
911 label2_ptr
= (uint32_t *)s
->code_ptr
;
914 /* nop (delay slot) */
917 #if TARGET_LONG_BITS == 32
919 *label1_ptr
= (INSN_OP(0) | INSN_COND(COND_E
, 0) | INSN_OP2(0x2) |
920 INSN_OFF22((unsigned long)s
->code_ptr
-
921 (unsigned long)label1_ptr
));
923 /* be,pt %xcc label1 */
924 *label1_ptr
= (INSN_OP(0) | INSN_COND(COND_E
, 0) | INSN_OP2(0x1) |
925 (0x5 << 19) | INSN_OFF19((unsigned long)s
->code_ptr
-
926 (unsigned long)label1_ptr
));
929 /* ld [arg1 + x], arg1 */
930 tcg_out_ldst(s
, arg1
, arg1
, offsetof(CPUTLBEntry
, addend
) -
931 offsetof(CPUTLBEntry
, addr_write
), TARGET_ADDEND_LD_OP
);
933 #if TARGET_LONG_BITS == 32
934 /* and addr_reg, x, arg0 */
935 tcg_out_movi(s
, TCG_TYPE_I32
, TCG_REG_I5
, 0xffffffff);
936 tcg_out_arith(s
, arg0
, addr_reg
, TCG_REG_I5
, ARITH_AND
);
937 /* add arg0, arg1, arg0 */
938 tcg_out_arith(s
, arg0
, arg0
, arg1
, ARITH_ADD
);
940 /* add addr_reg, arg1, arg0 */
941 tcg_out_arith(s
, arg0
, addr_reg
, arg1
, ARITH_ADD
);
950 /* stb data_reg, [arg0] */
951 tcg_out_ldst(s
, data_reg
, arg0
, 0, STB
);
954 #ifdef TARGET_WORDS_BIGENDIAN
955 /* sth data_reg, [arg0] */
956 tcg_out_ldst(s
, data_reg
, arg0
, 0, STH
);
958 /* stha data_reg, [arg0] ASI_PRIMARY_LITTLE */
959 tcg_out_ldst_asi(s
, data_reg
, arg0
, 0, STHA
, ASI_PRIMARY_LITTLE
);
963 #ifdef TARGET_WORDS_BIGENDIAN
964 /* stw data_reg, [arg0] */
965 tcg_out_ldst(s
, data_reg
, arg0
, 0, STW
);
967 /* stwa data_reg, [arg0] ASI_PRIMARY_LITTLE */
968 tcg_out_ldst_asi(s
, data_reg
, arg0
, 0, STWA
, ASI_PRIMARY_LITTLE
);
972 #ifdef TARGET_WORDS_BIGENDIAN
973 /* stx data_reg, [arg0] */
974 tcg_out_ldst(s
, data_reg
, arg0
, 0, STX
);
976 /* stxa data_reg, [arg0] ASI_PRIMARY_LITTLE */
977 tcg_out_ldst_asi(s
, data_reg
, arg0
, 0, STXA
, ASI_PRIMARY_LITTLE
);
984 #if defined(CONFIG_SOFTMMU)
986 *label2_ptr
= (INSN_OP(0) | INSN_COND(COND_A
, 0) | INSN_OP2(0x2) |
987 INSN_OFF22((unsigned long)s
->code_ptr
-
988 (unsigned long)label2_ptr
));
992 static inline void tcg_out_op(TCGContext
*s
, int opc
, const TCGArg
*args
,
993 const int *const_args
)
998 case INDEX_op_exit_tb
:
999 tcg_out_movi(s
, TCG_TYPE_PTR
, TCG_REG_I0
, args
[0]);
1000 tcg_out32(s
, JMPL
| INSN_RD(TCG_REG_G0
) | INSN_RS1(TCG_REG_I7
) |
1002 tcg_out32(s
, RESTORE
| INSN_RD(TCG_REG_G0
) | INSN_RS1(TCG_REG_G0
) |
1003 INSN_RS2(TCG_REG_G0
));
1005 case INDEX_op_goto_tb
:
1006 if (s
->tb_jmp_offset
) {
1007 /* direct jump method */
1008 tcg_out_sethi(s
, TCG_REG_I5
, args
[0] & 0xffffe000);
1009 tcg_out32(s
, JMPL
| INSN_RD(TCG_REG_G0
) | INSN_RS1(TCG_REG_I5
) |
1010 INSN_IMM13((args
[0] & 0x1fff)));
1011 s
->tb_jmp_offset
[args
[0]] = s
->code_ptr
- s
->code_buf
;
1013 /* indirect jump method */
1014 tcg_out_ld_ptr(s
, TCG_REG_I5
, (tcg_target_long
)(s
->tb_next
+ args
[0]));
1015 tcg_out32(s
, JMPL
| INSN_RD(TCG_REG_G0
) | INSN_RS1(TCG_REG_I5
) |
1016 INSN_RS2(TCG_REG_G0
));
1019 s
->tb_next_offset
[args
[0]] = s
->code_ptr
- s
->code_buf
;
1023 tcg_out32(s
, CALL
| ((((tcg_target_ulong
)args
[0]
1024 - (tcg_target_ulong
)s
->code_ptr
) >> 2)
1027 tcg_out_ld_ptr(s
, TCG_REG_I5
,
1028 (tcg_target_long
)(s
->tb_next
+ args
[0]));
1029 tcg_out32(s
, JMPL
| INSN_RD(TCG_REG_O7
) | INSN_RS1(TCG_REG_I5
) |
1030 INSN_RS2(TCG_REG_G0
));
1032 /* Store AREG0 in stack to avoid ugly glibc bugs that mangle
1035 tcg_out_ldst(s
, TCG_AREG0
, TCG_REG_CALL_STACK
,
1036 TCG_TARGET_CALL_STACK_OFFSET
- TCG_STATIC_CALL_ARGS_SIZE
-
1037 sizeof(long), HOST_ST_OP
);
1038 tcg_out_ldst(s
, TCG_AREG0
, TCG_REG_CALL_STACK
,
1039 TCG_TARGET_CALL_STACK_OFFSET
- TCG_STATIC_CALL_ARGS_SIZE
-
1040 sizeof(long), HOST_LD_OP
);
1044 tcg_out_branch_i32(s
, COND_A
, args
[0]);
1047 case INDEX_op_movi_i32
:
1048 tcg_out_movi(s
, TCG_TYPE_I32
, args
[0], (uint32_t)args
[1]);
1051 #if TCG_TARGET_REG_BITS == 64
1052 #define OP_32_64(x) \
1053 glue(glue(case INDEX_op_, x), _i32): \
1054 glue(glue(case INDEX_op_, x), _i64)
1056 #define OP_32_64(x) \
1057 glue(glue(case INDEX_op_, x), _i32)
1060 tcg_out_ldst(s
, args
[0], args
[1], args
[2], LDUB
);
1063 tcg_out_ldst(s
, args
[0], args
[1], args
[2], LDSB
);
1066 tcg_out_ldst(s
, args
[0], args
[1], args
[2], LDUH
);
1069 tcg_out_ldst(s
, args
[0], args
[1], args
[2], LDSH
);
1071 case INDEX_op_ld_i32
:
1072 #if TCG_TARGET_REG_BITS == 64
1073 case INDEX_op_ld32u_i64
:
1075 tcg_out_ldst(s
, args
[0], args
[1], args
[2], LDUW
);
1078 tcg_out_ldst(s
, args
[0], args
[1], args
[2], STB
);
1081 tcg_out_ldst(s
, args
[0], args
[1], args
[2], STH
);
1083 case INDEX_op_st_i32
:
1084 #if TCG_TARGET_REG_BITS == 64
1085 case INDEX_op_st32_i64
:
1087 tcg_out_ldst(s
, args
[0], args
[1], args
[2], STW
);
1104 case INDEX_op_shl_i32
:
1107 case INDEX_op_shr_i32
:
1110 case INDEX_op_sar_i32
:
1113 case INDEX_op_mul_i32
:
1116 case INDEX_op_div2_i32
:
1117 #if defined(__sparc_v9__) || defined(__sparc_v8plus__)
1125 case INDEX_op_divu2_i32
:
1126 #if defined(__sparc_v9__) || defined(__sparc_v8plus__)
1135 case INDEX_op_brcond_i32
:
1136 tcg_out_brcond_i32(s
, args
[2], args
[0], args
[1], const_args
[1],
1139 #if TCG_TARGET_REG_BITS == 32
1140 case INDEX_op_brcond2_i32
:
1141 tcg_out_brcond2_i32(s
, args
[4], args
[0], args
[1],
1142 args
[2], const_args
[2],
1143 args
[3], const_args
[3], args
[5]);
1145 case INDEX_op_add2_i32
:
1146 tcg_out_arithc(s
, args
[0], args
[2], args
[4], const_args
[4],
1148 tcg_out_arithc(s
, args
[1], args
[3], args
[5], const_args
[5],
1151 case INDEX_op_sub2_i32
:
1152 tcg_out_arithc(s
, args
[0], args
[2], args
[4], const_args
[4],
1154 tcg_out_arithc(s
, args
[1], args
[3], args
[5], const_args
[5],
1157 case INDEX_op_mulu2_i32
:
1158 tcg_out_arithc(s
, args
[0], args
[2], args
[3], const_args
[3],
1160 tcg_out_rdy(s
, args
[1]);
1164 case INDEX_op_qemu_ld8u
:
1165 tcg_out_qemu_ld(s
, args
, 0);
1167 case INDEX_op_qemu_ld8s
:
1168 tcg_out_qemu_ld(s
, args
, 0 | 4);
1170 case INDEX_op_qemu_ld16u
:
1171 tcg_out_qemu_ld(s
, args
, 1);
1173 case INDEX_op_qemu_ld16s
:
1174 tcg_out_qemu_ld(s
, args
, 1 | 4);
1176 case INDEX_op_qemu_ld32u
:
1177 tcg_out_qemu_ld(s
, args
, 2);
1179 case INDEX_op_qemu_ld32s
:
1180 tcg_out_qemu_ld(s
, args
, 2 | 4);
1182 case INDEX_op_qemu_st8
:
1183 tcg_out_qemu_st(s
, args
, 0);
1185 case INDEX_op_qemu_st16
:
1186 tcg_out_qemu_st(s
, args
, 1);
1188 case INDEX_op_qemu_st32
:
1189 tcg_out_qemu_st(s
, args
, 2);
1192 #if TCG_TARGET_REG_BITS == 64
1193 case INDEX_op_movi_i64
:
1194 tcg_out_movi(s
, TCG_TYPE_I64
, args
[0], args
[1]);
1196 case INDEX_op_ld32s_i64
:
1197 tcg_out_ldst(s
, args
[0], args
[1], args
[2], LDSW
);
1199 case INDEX_op_ld_i64
:
1200 tcg_out_ldst(s
, args
[0], args
[1], args
[2], LDX
);
1202 case INDEX_op_st_i64
:
1203 tcg_out_ldst(s
, args
[0], args
[1], args
[2], STX
);
1205 case INDEX_op_shl_i64
:
1208 case INDEX_op_shr_i64
:
1211 case INDEX_op_sar_i64
:
1214 case INDEX_op_mul_i64
:
1217 case INDEX_op_div2_i64
:
1220 case INDEX_op_divu2_i64
:
1224 case INDEX_op_brcond_i64
:
1225 tcg_out_brcond_i64(s
, args
[2], args
[0], args
[1], const_args
[1],
1228 case INDEX_op_qemu_ld64
:
1229 tcg_out_qemu_ld(s
, args
, 3);
1231 case INDEX_op_qemu_st64
:
1232 tcg_out_qemu_st(s
, args
, 3);
1237 tcg_out_arithc(s
, args
[0], args
[1], args
[2], const_args
[2], c
);
1241 fprintf(stderr
, "unknown opcode 0x%x\n", opc
);
1246 static const TCGTargetOpDef sparc_op_defs
[] = {
1247 { INDEX_op_exit_tb
, { } },
1248 { INDEX_op_goto_tb
, { } },
1249 { INDEX_op_call
, { "ri" } },
1250 { INDEX_op_jmp
, { "ri" } },
1251 { INDEX_op_br
, { } },
1253 { INDEX_op_mov_i32
, { "r", "r" } },
1254 { INDEX_op_movi_i32
, { "r" } },
1255 { INDEX_op_ld8u_i32
, { "r", "r" } },
1256 { INDEX_op_ld8s_i32
, { "r", "r" } },
1257 { INDEX_op_ld16u_i32
, { "r", "r" } },
1258 { INDEX_op_ld16s_i32
, { "r", "r" } },
1259 { INDEX_op_ld_i32
, { "r", "r" } },
1260 { INDEX_op_st8_i32
, { "r", "r" } },
1261 { INDEX_op_st16_i32
, { "r", "r" } },
1262 { INDEX_op_st_i32
, { "r", "r" } },
1264 { INDEX_op_add_i32
, { "r", "r", "rJ" } },
1265 { INDEX_op_mul_i32
, { "r", "r", "rJ" } },
1266 { INDEX_op_div2_i32
, { "r", "r", "0", "1", "r" } },
1267 { INDEX_op_divu2_i32
, { "r", "r", "0", "1", "r" } },
1268 { INDEX_op_sub_i32
, { "r", "r", "rJ" } },
1269 { INDEX_op_and_i32
, { "r", "r", "rJ" } },
1270 { INDEX_op_or_i32
, { "r", "r", "rJ" } },
1271 { INDEX_op_xor_i32
, { "r", "r", "rJ" } },
1273 { INDEX_op_shl_i32
, { "r", "r", "rJ" } },
1274 { INDEX_op_shr_i32
, { "r", "r", "rJ" } },
1275 { INDEX_op_sar_i32
, { "r", "r", "rJ" } },
1277 { INDEX_op_brcond_i32
, { "r", "rJ" } },
1278 #if TCG_TARGET_REG_BITS == 32
1279 { INDEX_op_brcond2_i32
, { "r", "r", "rJ", "rJ" } },
1280 { INDEX_op_add2_i32
, { "r", "r", "r", "r", "rJ", "rJ" } },
1281 { INDEX_op_sub2_i32
, { "r", "r", "r", "r", "rJ", "rJ" } },
1282 { INDEX_op_mulu2_i32
, { "r", "r", "r", "rJ" } },
1285 { INDEX_op_qemu_ld8u
, { "r", "L" } },
1286 { INDEX_op_qemu_ld8s
, { "r", "L" } },
1287 { INDEX_op_qemu_ld16u
, { "r", "L" } },
1288 { INDEX_op_qemu_ld16s
, { "r", "L" } },
1289 { INDEX_op_qemu_ld32u
, { "r", "L" } },
1290 { INDEX_op_qemu_ld32s
, { "r", "L" } },
1292 { INDEX_op_qemu_st8
, { "L", "L" } },
1293 { INDEX_op_qemu_st16
, { "L", "L" } },
1294 { INDEX_op_qemu_st32
, { "L", "L" } },
1296 #if TCG_TARGET_REG_BITS == 64
1297 { INDEX_op_mov_i64
, { "r", "r" } },
1298 { INDEX_op_movi_i64
, { "r" } },
1299 { INDEX_op_ld8u_i64
, { "r", "r" } },
1300 { INDEX_op_ld8s_i64
, { "r", "r" } },
1301 { INDEX_op_ld16u_i64
, { "r", "r" } },
1302 { INDEX_op_ld16s_i64
, { "r", "r" } },
1303 { INDEX_op_ld32u_i64
, { "r", "r" } },
1304 { INDEX_op_ld32s_i64
, { "r", "r" } },
1305 { INDEX_op_ld_i64
, { "r", "r" } },
1306 { INDEX_op_st8_i64
, { "r", "r" } },
1307 { INDEX_op_st16_i64
, { "r", "r" } },
1308 { INDEX_op_st32_i64
, { "r", "r" } },
1309 { INDEX_op_st_i64
, { "r", "r" } },
1310 { INDEX_op_qemu_ld64
, { "L", "L" } },
1311 { INDEX_op_qemu_st64
, { "L", "L" } },
1313 { INDEX_op_add_i64
, { "r", "r", "rJ" } },
1314 { INDEX_op_mul_i64
, { "r", "r", "rJ" } },
1315 { INDEX_op_div2_i64
, { "r", "r", "0", "1", "r" } },
1316 { INDEX_op_divu2_i64
, { "r", "r", "0", "1", "r" } },
1317 { INDEX_op_sub_i64
, { "r", "r", "rJ" } },
1318 { INDEX_op_and_i64
, { "r", "r", "rJ" } },
1319 { INDEX_op_or_i64
, { "r", "r", "rJ" } },
1320 { INDEX_op_xor_i64
, { "r", "r", "rJ" } },
1322 { INDEX_op_shl_i64
, { "r", "r", "rJ" } },
1323 { INDEX_op_shr_i64
, { "r", "r", "rJ" } },
1324 { INDEX_op_sar_i64
, { "r", "r", "rJ" } },
1326 { INDEX_op_brcond_i64
, { "r", "rJ" } },
1331 void tcg_target_init(TCGContext
*s
)
1333 tcg_regset_set32(tcg_target_available_regs
[TCG_TYPE_I32
], 0, 0xffffffff);
1334 #if TCG_TARGET_REG_BITS == 64
1335 tcg_regset_set32(tcg_target_available_regs
[TCG_TYPE_I64
], 0, 0xffffffff);
1337 tcg_regset_set32(tcg_target_call_clobber_regs
, 0,
1353 tcg_regset_clear(s
->reserved_regs
);
1354 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_G0
);
1355 #if TCG_TARGET_REG_BITS == 64
1356 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_I4
); // for internal use
1358 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_I5
); // for internal use
1359 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_I6
);
1360 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_I7
);
1361 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_O6
);
1362 tcg_regset_set_reg(s
->reserved_regs
, TCG_REG_O7
);
1363 tcg_add_target_add_op_defs(sparc_op_defs
);