2 * Tiny Code Generator for QEMU
6 * Based on i386/tcg-target.c - Copyright (c) 2008 Fabrice Bellard
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 #if defined(TCG_TARGET_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
28 # define TCG_NEED_BSWAP 0
30 # define TCG_NEED_BSWAP 1
34 static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
70 /* check if we really need so many registers :P */
71 static const int tcg_target_reg_alloc_order[] = {
97 static const int tcg_target_call_iarg_regs[4] = {
104 static const int tcg_target_call_oarg_regs[2] = {
109 static uint8_t *tb_ret_addr;
111 static inline uint32_t reloc_lo16_val (void *pc, tcg_target_long target)
113 return target & 0xffff;
116 static inline void reloc_lo16 (void *pc, tcg_target_long target)
118 *(uint32_t *) pc = (*(uint32_t *) pc & ~0xffff)
119 | reloc_lo16_val(pc, target);
122 static inline uint32_t reloc_hi16_val (void *pc, tcg_target_long target)
124 return (target >> 16) & 0xffff;
127 static inline void reloc_hi16 (void *pc, tcg_target_long target)
129 *(uint32_t *) pc = (*(uint32_t *) pc & ~0xffff)
130 | reloc_hi16_val(pc, target);
133 static inline uint32_t reloc_pc16_val (void *pc, tcg_target_long target)
137 disp = target - (tcg_target_long) pc - 4;
138 if (disp != (disp << 14) >> 14) {
142 return (disp >> 2) & 0xffff;
145 static inline void reloc_pc16 (void *pc, tcg_target_long target)
147 *(uint32_t *) pc = (*(uint32_t *) pc & ~0xffff)
148 | reloc_pc16_val(pc, target);
151 static inline uint32_t reloc_26_val (void *pc, tcg_target_long target)
153 if ((((tcg_target_long)pc + 4) & 0xf0000000) != (target & 0xf0000000)) {
157 return (target >> 2) & 0x3ffffff;
160 static inline void reloc_pc26 (void *pc, tcg_target_long target)
162 *(uint32_t *) pc = (*(uint32_t *) pc & ~0x3ffffff)
163 | reloc_26_val(pc, target);
166 static void patch_reloc(uint8_t *code_ptr, int type,
167 tcg_target_long value, tcg_target_long addend)
172 reloc_lo16(code_ptr, value);
175 reloc_hi16(code_ptr, value);
178 reloc_pc16(code_ptr, value);
181 reloc_pc26(code_ptr, value);
188 /* maximum number of register used for input function arguments */
189 static inline int tcg_target_get_call_iarg_regs_count(int flags)
194 /* parse target specific constraints */
195 static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
202 ct->ct |= TCG_CT_REG;
203 tcg_regset_set(ct->u.regs, 0xffffffff);
206 ct->ct |= TCG_CT_REG;
207 tcg_regset_clear(ct->u.regs);
208 tcg_regset_set_reg(ct->u.regs, TCG_REG_T9);
210 case 'L': /* qemu_ld output arg constraint */
211 ct->ct |= TCG_CT_REG;
212 tcg_regset_set(ct->u.regs, 0xffffffff);
213 tcg_regset_reset_reg(ct->u.regs, TCG_REG_V0);
215 case 'l': /* qemu_ld input arg constraint */
216 ct->ct |= TCG_CT_REG;
217 tcg_regset_set(ct->u.regs, 0xffffffff);
218 #if defined(CONFIG_SOFTMMU)
219 tcg_regset_reset_reg(ct->u.regs, TCG_REG_A0);
222 case 'S': /* qemu_st constraint */
223 ct->ct |= TCG_CT_REG;
224 tcg_regset_set(ct->u.regs, 0xffffffff);
225 #if defined(CONFIG_SOFTMMU)
226 tcg_regset_reset_reg(ct->u.regs, TCG_REG_A0);
227 # if TARGET_LONG_BITS == 64
228 tcg_regset_reset_reg(ct->u.regs, TCG_REG_A1);
230 tcg_regset_reset_reg(ct->u.regs, TCG_REG_A2);
234 ct->ct |= TCG_CT_CONST_U16;
237 ct->ct |= TCG_CT_CONST_S16;
240 /* We are cheating a bit here, using the fact that the register
241 ZERO is also the register number 0. Hence there is no need
242 to check for const_args in each instruction. */
243 ct->ct |= TCG_CT_CONST_ZERO;
253 /* test if a constant matches the constraint */
254 static inline int tcg_target_const_match(tcg_target_long val,
255 const TCGArgConstraint *arg_ct)
259 if (ct & TCG_CT_CONST)
261 else if ((ct & TCG_CT_CONST_ZERO) && val == 0)
263 else if ((ct & TCG_CT_CONST_U16) && val == (uint16_t)val)
265 else if ((ct & TCG_CT_CONST_S16) && val == (int16_t)val)
271 /* instruction opcodes */
273 OPC_SPECIAL = 0x00 << 26,
274 OPC_BEQ = 0x04 << 26,
275 OPC_BNE = 0x05 << 26,
276 OPC_ADDIU = 0x09 << 26,
277 OPC_SLTI = 0x0A << 26,
278 OPC_SLTIU = 0x0B << 26,
279 OPC_ANDI = 0x0C << 26,
280 OPC_ORI = 0x0D << 26,
281 OPC_XORI = 0x0E << 26,
282 OPC_LUI = 0x0F << 26,
286 OPC_LBU = 0x24 << 26,
287 OPC_LHU = 0x25 << 26,
288 OPC_LWU = 0x27 << 26,
292 OPC_SLL = OPC_SPECIAL | 0x00,
293 OPC_SRL = OPC_SPECIAL | 0x02,
294 OPC_SRA = OPC_SPECIAL | 0x03,
295 OPC_SLLV = OPC_SPECIAL | 0x04,
296 OPC_SRLV = OPC_SPECIAL | 0x06,
297 OPC_SRAV = OPC_SPECIAL | 0x07,
298 OPC_JR = OPC_SPECIAL | 0x08,
299 OPC_JALR = OPC_SPECIAL | 0x09,
300 OPC_MFHI = OPC_SPECIAL | 0x10,
301 OPC_MFLO = OPC_SPECIAL | 0x12,
302 OPC_MULT = OPC_SPECIAL | 0x18,
303 OPC_MULTU = OPC_SPECIAL | 0x19,
304 OPC_DIV = OPC_SPECIAL | 0x1A,
305 OPC_DIVU = OPC_SPECIAL | 0x1B,
306 OPC_ADDU = OPC_SPECIAL | 0x21,
307 OPC_SUBU = OPC_SPECIAL | 0x23,
308 OPC_AND = OPC_SPECIAL | 0x24,
309 OPC_OR = OPC_SPECIAL | 0x25,
310 OPC_XOR = OPC_SPECIAL | 0x26,
311 OPC_NOR = OPC_SPECIAL | 0x27,
312 OPC_SLT = OPC_SPECIAL | 0x2A,
313 OPC_SLTU = OPC_SPECIAL | 0x2B,
319 static inline void tcg_out_opc_reg(TCGContext *s, int opc, int rd, int rs, int rt)
324 inst |= (rs & 0x1F) << 21;
325 inst |= (rt & 0x1F) << 16;
326 inst |= (rd & 0x1F) << 11;
333 static inline void tcg_out_opc_imm(TCGContext *s, int opc, int rt, int rs, int imm)
338 inst |= (rs & 0x1F) << 21;
339 inst |= (rt & 0x1F) << 16;
340 inst |= (imm & 0xffff);
347 static inline void tcg_out_opc_sa(TCGContext *s, int opc, int rd, int rt, int sa)
352 inst |= (rt & 0x1F) << 16;
353 inst |= (rd & 0x1F) << 11;
354 inst |= (sa & 0x1F) << 6;
359 static inline void tcg_out_nop(TCGContext *s)
364 static inline void tcg_out_mov(TCGContext *s, int ret, int arg)
366 tcg_out_opc_reg(s, OPC_ADDU, ret, arg, TCG_REG_ZERO);
369 static inline void tcg_out_movi(TCGContext *s, TCGType type,
370 int reg, int32_t arg)
372 if (arg == (int16_t)arg) {
373 tcg_out_opc_imm(s, OPC_ADDIU, reg, TCG_REG_ZERO, arg);
374 } else if (arg == (uint16_t)arg) {
375 tcg_out_opc_imm(s, OPC_ORI, reg, TCG_REG_ZERO, arg);
377 tcg_out_opc_imm(s, OPC_LUI, reg, 0, arg >> 16);
378 tcg_out_opc_imm(s, OPC_ORI, reg, reg, arg & 0xffff);
382 static inline void tcg_out_bswap16(TCGContext *s, int ret, int arg)
384 /* ret and arg can't be register at */
385 if (ret == TCG_REG_AT || arg == TCG_REG_AT) {
389 tcg_out_opc_sa(s, OPC_SRL, TCG_REG_AT, arg, 8);
390 tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_AT, TCG_REG_AT, 0x00ff);
392 tcg_out_opc_sa(s, OPC_SLL, ret, arg, 8);
393 tcg_out_opc_imm(s, OPC_ANDI, ret, ret, 0xff00);
394 tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
397 static inline void tcg_out_bswap16s(TCGContext *s, int ret, int arg)
399 /* ret and arg can't be register at */
400 if (ret == TCG_REG_AT || arg == TCG_REG_AT) {
404 tcg_out_opc_sa(s, OPC_SRL, TCG_REG_AT, arg, 8);
405 tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_AT, TCG_REG_AT, 0xff);
407 tcg_out_opc_sa(s, OPC_SLL, ret, arg, 24);
408 tcg_out_opc_sa(s, OPC_SRA, ret, ret, 16);
409 tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
412 static inline void tcg_out_bswap32(TCGContext *s, int ret, int arg)
414 /* ret and arg must be different and can't be register at */
415 if (ret == arg || ret == TCG_REG_AT || arg == TCG_REG_AT) {
419 tcg_out_opc_sa(s, OPC_SLL, ret, arg, 24);
421 tcg_out_opc_sa(s, OPC_SRL, TCG_REG_AT, arg, 24);
422 tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
424 tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_AT, arg, 0xff00);
425 tcg_out_opc_sa(s, OPC_SLL, TCG_REG_AT, TCG_REG_AT, 8);
426 tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
428 tcg_out_opc_sa(s, OPC_SRL, TCG_REG_AT, arg, 8);
429 tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_AT, TCG_REG_AT, 0xff00);
430 tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_REG_AT);
433 static inline void tcg_out_ldst(TCGContext *s, int opc, int arg,
434 int arg1, tcg_target_long arg2)
436 if (arg2 == (int16_t) arg2) {
437 tcg_out_opc_imm(s, opc, arg, arg1, arg2);
439 tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_AT, arg2);
440 tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_AT, TCG_REG_AT, arg1);
441 tcg_out_opc_imm(s, opc, arg, TCG_REG_AT, 0);
445 static inline void tcg_out_ld(TCGContext *s, TCGType type, int arg,
446 int arg1, tcg_target_long arg2)
448 tcg_out_ldst(s, OPC_LW, arg, arg1, arg2);
451 static inline void tcg_out_st(TCGContext *s, TCGType type, int arg,
452 int arg1, tcg_target_long arg2)
454 tcg_out_ldst(s, OPC_SW, arg, arg1, arg2);
457 static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)
459 if (val == (int16_t)val) {
460 tcg_out_opc_imm(s, OPC_ADDIU, reg, reg, val);
462 tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_AT, val);
463 tcg_out_opc_reg(s, OPC_ADDU, reg, reg, TCG_REG_AT);
467 static void tcg_out_brcond(TCGContext *s, int cond, int arg1,
468 int arg2, int label_index)
470 TCGLabel *l = &s->labels[label_index];
474 tcg_out_opc_imm(s, OPC_BEQ, arg1, arg2, 0);
477 tcg_out_opc_imm(s, OPC_BNE, arg1, arg2, 0);
480 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg1, arg2);
481 tcg_out_opc_imm(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO, 0);
484 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg1, arg2);
485 tcg_out_opc_imm(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO, 0);
488 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg1, arg2);
489 tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO, 0);
492 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg1, arg2);
493 tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO, 0);
496 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg2, arg1);
497 tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO, 0);
500 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg2, arg1);
501 tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO, 0);
504 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg2, arg1);
505 tcg_out_opc_imm(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO, 0);
508 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg2, arg1);
509 tcg_out_opc_imm(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO, 0);
516 reloc_pc16(s->code_ptr - 4, l->u.value);
518 tcg_out_reloc(s, s->code_ptr - 4, R_MIPS_PC16, label_index, 0);
523 /* XXX: we implement it at the target level to avoid having to
524 handle cross basic blocks temporaries */
525 static void tcg_out_brcond2(TCGContext *s, int cond, int arg1,
526 int arg2, int arg3, int arg4, int label_index)
532 tcg_out_brcond(s, TCG_COND_NE, arg2, arg4, label_index);
533 tcg_out_brcond(s, TCG_COND_NE, arg1, arg3, label_index);
539 tcg_out_brcond(s, TCG_COND_LT, arg2, arg4, label_index);
543 tcg_out_brcond(s, TCG_COND_GT, arg2, arg4, label_index);
547 tcg_out_brcond(s, TCG_COND_LTU, arg2, arg4, label_index);
551 tcg_out_brcond(s, TCG_COND_GTU, arg2, arg4, label_index);
557 label_ptr = s->code_ptr;
558 tcg_out_opc_imm(s, OPC_BNE, arg2, arg4, 0);
563 tcg_out_brcond(s, TCG_COND_EQ, arg1, arg3, label_index);
567 tcg_out_brcond(s, TCG_COND_LTU, arg1, arg3, label_index);
571 tcg_out_brcond(s, TCG_COND_LEU, arg1, arg3, label_index);
575 tcg_out_brcond(s, TCG_COND_GTU, arg1, arg3, label_index);
579 tcg_out_brcond(s, TCG_COND_GEU, arg1, arg3, label_index);
585 reloc_pc16(label_ptr, (tcg_target_long) s->code_ptr);
588 static void tcg_out_setcond(TCGContext *s, int cond, int ret,
594 tcg_out_opc_imm(s, OPC_SLTIU, ret, arg2, 1);
595 } else if (arg2 == 0) {
596 tcg_out_opc_imm(s, OPC_SLTIU, ret, arg1, 1);
598 tcg_out_opc_reg(s, OPC_XOR, TCG_REG_AT, arg1, arg2);
599 tcg_out_opc_imm(s, OPC_SLTIU, ret, TCG_REG_AT, 1);
604 tcg_out_opc_reg(s, OPC_SLTU, ret, TCG_REG_ZERO, arg2);
605 } else if (arg2 == 0) {
606 tcg_out_opc_reg(s, OPC_SLTU, ret, TCG_REG_ZERO, arg1);
608 tcg_out_opc_reg(s, OPC_XOR, TCG_REG_AT, arg1, arg2);
609 tcg_out_opc_reg(s, OPC_SLTU, ret, TCG_REG_ZERO, TCG_REG_AT);
613 tcg_out_opc_reg(s, OPC_SLT, ret, arg1, arg2);
616 tcg_out_opc_reg(s, OPC_SLTU, ret, arg1, arg2);
619 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg1, arg2);
620 tcg_out_opc_imm(s, OPC_XORI, ret, TCG_REG_AT, 1);
623 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg1, arg2);
624 tcg_out_opc_imm(s, OPC_XORI, ret, TCG_REG_AT, 1);
627 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg2, arg1);
628 tcg_out_opc_imm(s, OPC_XORI, ret, TCG_REG_AT, 1);
631 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg2, arg1);
632 tcg_out_opc_imm(s, OPC_XORI, ret, TCG_REG_AT, 1);
635 tcg_out_opc_reg(s, OPC_SLT, ret, arg2, arg1);
638 tcg_out_opc_reg(s, OPC_SLTU, ret, arg2, arg1);
646 #if defined(CONFIG_SOFTMMU)
648 #include "../../softmmu_defs.h"
650 static void *qemu_ld_helpers[4] = {
657 static void *qemu_st_helpers[4] = {
665 static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
668 int addr_regl, addr_reg1, addr_meml;
669 int data_regl, data_regh, data_reg1, data_reg2;
670 int mem_index, s_bits;
671 #if defined(CONFIG_SOFTMMU)
672 void *label1_ptr, *label2_ptr;
675 #if TARGET_LONG_BITS == 64
676 # if defined(CONFIG_SOFTMMU)
679 int addr_regh, addr_reg2, addr_memh;
687 #if TARGET_LONG_BITS == 64
694 #if defined(TCG_TARGET_WORDS_BIGENDIAN)
695 data_reg1 = data_regh;
696 data_reg2 = data_regl;
698 data_reg1 = data_regl;
699 data_reg2 = data_regh;
702 data_reg1 = data_regl;
705 #if TARGET_LONG_BITS == 64
706 # if defined(TCG_TARGET_WORDS_BIGENDIAN)
707 addr_reg1 = addr_regh;
708 addr_reg2 = addr_regl;
712 addr_reg1 = addr_regl;
713 addr_reg2 = addr_regh;
718 addr_reg1 = addr_regl;
722 #if defined(CONFIG_SOFTMMU)
723 tcg_out_opc_sa(s, OPC_SRL, TCG_REG_A0, addr_regl, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
724 tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_A0, TCG_REG_A0, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
725 tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, TCG_AREG0);
726 tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
727 offsetof(CPUState, tlb_table[mem_index][0].addr_read) + addr_meml);
728 tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T0, TARGET_PAGE_MASK | ((1 << s_bits) - 1));
729 tcg_out_opc_reg(s, OPC_AND, TCG_REG_T0, TCG_REG_T0, addr_regl);
731 # if TARGET_LONG_BITS == 64
732 label3_ptr = s->code_ptr;
733 tcg_out_opc_imm(s, OPC_BNE, TCG_REG_T0, TCG_REG_AT, 0);
736 tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
737 offsetof(CPUState, tlb_table[mem_index][0].addr_read) + addr_memh);
739 label1_ptr = s->code_ptr;
740 tcg_out_opc_imm(s, OPC_BEQ, addr_regh, TCG_REG_AT, 0);
743 reloc_pc16(label3_ptr, (tcg_target_long) s->code_ptr);
745 label1_ptr = s->code_ptr;
746 tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_T0, TCG_REG_AT, 0);
751 sp_args = TCG_REG_A0;
752 tcg_out_mov(s, sp_args++, addr_reg1);
753 # if TARGET_LONG_BITS == 64
754 tcg_out_mov(s, sp_args++, addr_reg2);
756 tcg_out_movi(s, TCG_TYPE_I32, sp_args++, mem_index);
757 tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T9, (tcg_target_long)qemu_ld_helpers[s_bits]);
758 tcg_out_opc_reg(s, OPC_JALR, TCG_REG_RA, TCG_REG_T9, 0);
763 tcg_out_opc_imm(s, OPC_ANDI, data_reg1, TCG_REG_V0, 0xff);
766 tcg_out_opc_sa(s, OPC_SLL, TCG_REG_V0, TCG_REG_V0, 24);
767 tcg_out_opc_sa(s, OPC_SRA, data_reg1, TCG_REG_V0, 24);
770 tcg_out_opc_imm(s, OPC_ANDI, data_reg1, TCG_REG_V0, 0xffff);
773 tcg_out_opc_sa(s, OPC_SLL, TCG_REG_V0, TCG_REG_V0, 16);
774 tcg_out_opc_sa(s, OPC_SRA, data_reg1, TCG_REG_V0, 16);
777 tcg_out_mov(s, data_reg1, TCG_REG_V0);
780 tcg_out_mov(s, data_reg2, TCG_REG_V1);
781 tcg_out_mov(s, data_reg1, TCG_REG_V0);
787 label2_ptr = s->code_ptr;
788 tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO, 0);
791 /* label1: fast path */
792 reloc_pc16(label1_ptr, (tcg_target_long) s->code_ptr);
794 tcg_out_opc_imm(s, OPC_LW, TCG_REG_V0, TCG_REG_A0,
795 offsetof(CPUState, tlb_table[mem_index][0].addend) + addr_meml);
796 tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_V0, TCG_REG_V0, addr_regl);
798 addr_reg1 = TCG_REG_V0;
803 tcg_out_opc_imm(s, OPC_LBU, data_reg1, addr_reg1, 0);
806 tcg_out_opc_imm(s, OPC_LB, data_reg1, addr_reg1, 0);
809 if (TCG_NEED_BSWAP) {
810 tcg_out_opc_imm(s, OPC_LHU, TCG_REG_T0, addr_reg1, 0);
811 tcg_out_bswap16(s, data_reg1, TCG_REG_T0);
813 tcg_out_opc_imm(s, OPC_LHU, data_reg1, addr_reg1, 0);
817 if (TCG_NEED_BSWAP) {
818 tcg_out_opc_imm(s, OPC_LHU, TCG_REG_T0, addr_reg1, 0);
819 tcg_out_bswap16s(s, data_reg1, TCG_REG_T0);
821 tcg_out_opc_imm(s, OPC_LH, data_reg1, addr_reg1, 0);
825 if (TCG_NEED_BSWAP) {
826 tcg_out_opc_imm(s, OPC_LW, TCG_REG_T0, addr_reg1, 0);
827 tcg_out_bswap32(s, data_reg1, TCG_REG_T0);
829 tcg_out_opc_imm(s, OPC_LW, data_reg1, addr_reg1, 0);
833 #if !defined(CONFIG_SOFTMMU)
834 tcg_out_mov(s, TCG_REG_V0, addr_reg1);
835 addr_reg1 = TCG_REG_V0;
837 if (TCG_NEED_BSWAP) {
838 tcg_out_opc_imm(s, OPC_LW, TCG_REG_T0, addr_reg1, 4);
839 tcg_out_bswap32(s, data_reg1, TCG_REG_T0);
840 tcg_out_opc_imm(s, OPC_LW, TCG_REG_T0, addr_reg1, 0);
841 tcg_out_bswap32(s, data_reg2, TCG_REG_T0);
843 tcg_out_opc_imm(s, OPC_LW, data_reg1, addr_reg1, 0);
844 tcg_out_opc_imm(s, OPC_LW, data_reg2, addr_reg1, 4);
851 #if defined(CONFIG_SOFTMMU)
852 reloc_pc16(label2_ptr, (tcg_target_long) s->code_ptr);
856 static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
859 int addr_regl, addr_reg1, addr_meml;
860 int data_regl, data_regh, data_reg1, data_reg2;
861 int mem_index, s_bits;
862 #if defined(CONFIG_SOFTMMU)
863 uint8_t *label1_ptr, *label2_ptr;
866 #if TARGET_LONG_BITS == 64
867 # if defined(CONFIG_SOFTMMU)
870 int addr_regh, addr_reg2, addr_memh;
876 #if defined(TCG_TARGET_WORDS_BIGENDIAN)
877 data_reg1 = data_regh;
878 data_reg2 = data_regl;
880 data_reg1 = data_regl;
881 data_reg2 = data_regh;
884 data_reg1 = data_regl;
889 #if TARGET_LONG_BITS == 64
891 # if defined(TCG_TARGET_WORDS_BIGENDIAN)
892 addr_reg1 = addr_regh;
893 addr_reg2 = addr_regl;
897 addr_reg1 = addr_regl;
898 addr_reg2 = addr_regh;
903 addr_reg1 = addr_regl;
909 #if defined(CONFIG_SOFTMMU)
910 tcg_out_opc_sa(s, OPC_SRL, TCG_REG_A0, addr_regl, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
911 tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_A0, TCG_REG_A0, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
912 tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, TCG_AREG0);
913 tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
914 offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_meml);
915 tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T0, TARGET_PAGE_MASK | ((1 << s_bits) - 1));
916 tcg_out_opc_reg(s, OPC_AND, TCG_REG_T0, TCG_REG_T0, addr_regl);
918 # if TARGET_LONG_BITS == 64
919 label3_ptr = s->code_ptr;
920 tcg_out_opc_imm(s, OPC_BNE, TCG_REG_T0, TCG_REG_AT, 0);
923 tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
924 offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_memh);
926 label1_ptr = s->code_ptr;
927 tcg_out_opc_imm(s, OPC_BEQ, addr_regh, TCG_REG_AT, 0);
930 reloc_pc16(label3_ptr, (tcg_target_long) s->code_ptr);
932 label1_ptr = s->code_ptr;
933 tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_T0, TCG_REG_AT, 0);
938 sp_args = TCG_REG_A0;
939 tcg_out_mov(s, sp_args++, addr_reg1);
940 # if TARGET_LONG_BITS == 64
941 tcg_out_mov(s, sp_args++, addr_reg2);
945 tcg_out_opc_imm(s, OPC_ANDI, sp_args++, data_reg1, 0xff);
948 tcg_out_opc_imm(s, OPC_ANDI, sp_args++, data_reg1, 0xffff);
951 tcg_out_mov(s, sp_args++, data_reg1);
954 sp_args = (sp_args + 1) & ~1;
955 tcg_out_mov(s, sp_args++, data_reg1);
956 tcg_out_mov(s, sp_args++, data_reg2);
961 if (sp_args > TCG_REG_A3) {
962 /* Push mem_index on the stack */
963 tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_AT, mem_index);
964 tcg_out_st(s, TCG_TYPE_I32, TCG_REG_AT, TCG_REG_SP, 16);
966 tcg_out_movi(s, TCG_TYPE_I32, sp_args, mem_index);
969 tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T9, (tcg_target_long)qemu_st_helpers[s_bits]);
970 tcg_out_opc_reg(s, OPC_JALR, TCG_REG_RA, TCG_REG_T9, 0);
973 label2_ptr = s->code_ptr;
974 tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO, 0);
977 /* label1: fast path */
978 reloc_pc16(label1_ptr, (tcg_target_long) s->code_ptr);
980 tcg_out_opc_imm(s, OPC_LW, TCG_REG_A0, TCG_REG_A0,
981 offsetof(CPUState, tlb_table[mem_index][0].addend) + addr_meml);
982 tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, addr_regl);
984 addr_reg1 = TCG_REG_A0;
989 tcg_out_opc_imm(s, OPC_SB, data_reg1, addr_reg1, 0);
992 if (TCG_NEED_BSWAP) {
993 tcg_out_bswap16(s, TCG_REG_T0, data_reg1);
994 tcg_out_opc_imm(s, OPC_SH, TCG_REG_T0, addr_reg1, 0);
996 tcg_out_opc_imm(s, OPC_SH, data_reg1, addr_reg1, 0);
1000 if (TCG_NEED_BSWAP) {
1001 tcg_out_bswap32(s, TCG_REG_T0, data_reg1);
1002 tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, addr_reg1, 0);
1004 tcg_out_opc_imm(s, OPC_SW, data_reg1, addr_reg1, 0);
1008 if (TCG_NEED_BSWAP) {
1009 tcg_out_bswap32(s, TCG_REG_T0, data_reg2);
1010 tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, addr_reg1, 0);
1011 tcg_out_bswap32(s, TCG_REG_T0, data_reg1);
1012 tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, addr_reg1, 4);
1014 tcg_out_opc_imm(s, OPC_SW, data_reg1, addr_reg1, 0);
1015 tcg_out_opc_imm(s, OPC_SW, data_reg2, addr_reg1, 4);
1022 #if defined(CONFIG_SOFTMMU)
1023 reloc_pc16(label2_ptr, (tcg_target_long) s->code_ptr);
1027 static inline void tcg_out_op(TCGContext *s, int opc,
1028 const TCGArg *args, const int *const_args)
1031 case INDEX_op_exit_tb:
1032 tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_V0, args[0]);
1033 tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_AT, (tcg_target_long)tb_ret_addr);
1034 tcg_out_opc_reg(s, OPC_JR, 0, TCG_REG_AT, 0);
1037 case INDEX_op_goto_tb:
1038 if (s->tb_jmp_offset) {
1039 /* direct jump method */
1042 /* indirect jump method */
1043 tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_AT, (tcg_target_long)(s->tb_next + args[0]));
1044 tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_AT, TCG_REG_AT, 0);
1045 tcg_out_opc_reg(s, OPC_JR, 0, TCG_REG_AT, 0);
1048 s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
1051 tcg_out_opc_reg(s, OPC_JALR, TCG_REG_RA, args[0], 0);
1055 tcg_out_opc_reg(s, OPC_JR, 0, args[0], 0);
1059 tcg_out_brcond(s, TCG_COND_EQ, TCG_REG_ZERO, TCG_REG_ZERO, args[0]);
1062 case INDEX_op_mov_i32:
1063 tcg_out_mov(s, args[0], args[1]);
1065 case INDEX_op_movi_i32:
1066 tcg_out_movi(s, TCG_TYPE_I32, args[0], args[1]);
1069 case INDEX_op_ld8u_i32:
1070 tcg_out_ldst(s, OPC_LBU, args[0], args[1], args[2]);
1072 case INDEX_op_ld8s_i32:
1073 tcg_out_ldst(s, OPC_LB, args[0], args[1], args[2]);
1075 case INDEX_op_ld16u_i32:
1076 tcg_out_ldst(s, OPC_LHU, args[0], args[1], args[2]);
1078 case INDEX_op_ld16s_i32:
1079 tcg_out_ldst(s, OPC_LH, args[0], args[1], args[2]);
1081 case INDEX_op_ld_i32:
1082 tcg_out_ldst(s, OPC_LW, args[0], args[1], args[2]);
1084 case INDEX_op_st8_i32:
1085 tcg_out_ldst(s, OPC_SB, args[0], args[1], args[2]);
1087 case INDEX_op_st16_i32:
1088 tcg_out_ldst(s, OPC_SH, args[0], args[1], args[2]);
1090 case INDEX_op_st_i32:
1091 tcg_out_ldst(s, OPC_SW, args[0], args[1], args[2]);
1094 case INDEX_op_add_i32:
1095 if (const_args[2]) {
1096 tcg_out_opc_imm(s, OPC_ADDIU, args[0], args[1], args[2]);
1098 tcg_out_opc_reg(s, OPC_ADDU, args[0], args[1], args[2]);
1101 case INDEX_op_add2_i32:
1102 if (const_args[4]) {
1103 tcg_out_opc_imm(s, OPC_ADDIU, TCG_REG_AT, args[2], args[4]);
1105 tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_AT, args[2], args[4]);
1107 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_T0, TCG_REG_AT, args[2]);
1108 if (const_args[5]) {
1109 tcg_out_opc_imm(s, OPC_ADDIU, args[1], args[3], args[5]);
1111 tcg_out_opc_reg(s, OPC_ADDU, args[1], args[3], args[5]);
1113 tcg_out_opc_reg(s, OPC_ADDU, args[1], args[1], TCG_REG_T0);
1114 tcg_out_mov(s, args[0], TCG_REG_AT);
1116 case INDEX_op_sub_i32:
1117 if (const_args[2]) {
1118 tcg_out_opc_imm(s, OPC_ADDIU, args[0], args[1], -args[2]);
1120 tcg_out_opc_reg(s, OPC_SUBU, args[0], args[1], args[2]);
1123 case INDEX_op_sub2_i32:
1124 if (const_args[4]) {
1125 tcg_out_opc_imm(s, OPC_ADDIU, TCG_REG_AT, args[2], -args[4]);
1127 tcg_out_opc_reg(s, OPC_SUBU, TCG_REG_AT, args[2], args[4]);
1129 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_T0, args[2], TCG_REG_AT);
1130 if (const_args[5]) {
1131 tcg_out_opc_imm(s, OPC_ADDIU, args[1], args[3], -args[5]);
1133 tcg_out_opc_reg(s, OPC_SUBU, args[1], args[3], args[5]);
1135 tcg_out_opc_reg(s, OPC_SUBU, args[1], args[1], TCG_REG_T0);
1136 tcg_out_mov(s, args[0], TCG_REG_AT);
1138 case INDEX_op_mul_i32:
1139 tcg_out_opc_reg(s, OPC_MULT, 0, args[1], args[2]);
1140 tcg_out_opc_reg(s, OPC_MFLO, args[0], 0, 0);
1142 case INDEX_op_mulu2_i32:
1143 tcg_out_opc_reg(s, OPC_MULTU, 0, args[2], args[3]);
1144 tcg_out_opc_reg(s, OPC_MFLO, args[0], 0, 0);
1145 tcg_out_opc_reg(s, OPC_MFHI, args[1], 0, 0);
1147 case INDEX_op_div_i32:
1148 tcg_out_opc_reg(s, OPC_DIV, 0, args[1], args[2]);
1149 tcg_out_opc_reg(s, OPC_MFLO, args[0], 0, 0);
1151 case INDEX_op_divu_i32:
1152 tcg_out_opc_reg(s, OPC_DIVU, 0, args[1], args[2]);
1153 tcg_out_opc_reg(s, OPC_MFLO, args[0], 0, 0);
1155 case INDEX_op_rem_i32:
1156 tcg_out_opc_reg(s, OPC_DIV, 0, args[1], args[2]);
1157 tcg_out_opc_reg(s, OPC_MFHI, args[0], 0, 0);
1159 case INDEX_op_remu_i32:
1160 tcg_out_opc_reg(s, OPC_DIVU, 0, args[1], args[2]);
1161 tcg_out_opc_reg(s, OPC_MFHI, args[0], 0, 0);
1164 case INDEX_op_and_i32:
1165 if (const_args[2]) {
1166 tcg_out_opc_imm(s, OPC_ANDI, args[0], args[1], args[2]);
1168 tcg_out_opc_reg(s, OPC_AND, args[0], args[1], args[2]);
1171 case INDEX_op_or_i32:
1172 if (const_args[2]) {
1173 tcg_out_opc_imm(s, OPC_ORI, args[0], args[1], args[2]);
1175 tcg_out_opc_reg(s, OPC_OR, args[0], args[1], args[2]);
1178 case INDEX_op_not_i32:
1179 tcg_out_opc_reg(s, OPC_NOR, args[0], args[1], args[1]);
1181 case INDEX_op_xor_i32:
1182 if (const_args[2]) {
1183 tcg_out_opc_imm(s, OPC_XORI, args[0], args[1], args[2]);
1185 tcg_out_opc_reg(s, OPC_XOR, args[0], args[1], args[2]);
1189 case INDEX_op_sar_i32:
1190 if (const_args[2]) {
1191 tcg_out_opc_sa(s, OPC_SRA, args[0], args[1], args[2]);
1193 tcg_out_opc_reg(s, OPC_SRAV, args[0], args[2], args[1]);
1196 case INDEX_op_shl_i32:
1197 if (const_args[2]) {
1198 tcg_out_opc_sa(s, OPC_SLL, args[0], args[1], args[2]);
1200 tcg_out_opc_reg(s, OPC_SLLV, args[0], args[2], args[1]);
1203 case INDEX_op_shr_i32:
1204 if (const_args[2]) {
1205 tcg_out_opc_sa(s, OPC_SRL, args[0], args[1], args[2]);
1207 tcg_out_opc_reg(s, OPC_SRLV, args[0], args[2], args[1]);
1211 case INDEX_op_brcond_i32:
1212 tcg_out_brcond(s, args[2], args[0], args[1], args[3]);
1214 case INDEX_op_brcond2_i32:
1215 tcg_out_brcond2(s, args[4], args[0], args[1], args[2], args[3], args[5]);
1218 case INDEX_op_setcond_i32:
1219 tcg_out_setcond(s, args[3], args[0], args[1], args[2]);
1222 case INDEX_op_qemu_ld8u:
1223 tcg_out_qemu_ld(s, args, 0);
1225 case INDEX_op_qemu_ld8s:
1226 tcg_out_qemu_ld(s, args, 0 | 4);
1228 case INDEX_op_qemu_ld16u:
1229 tcg_out_qemu_ld(s, args, 1);
1231 case INDEX_op_qemu_ld16s:
1232 tcg_out_qemu_ld(s, args, 1 | 4);
1234 case INDEX_op_qemu_ld32u:
1235 tcg_out_qemu_ld(s, args, 2);
1237 case INDEX_op_qemu_ld64:
1238 tcg_out_qemu_ld(s, args, 3);
1240 case INDEX_op_qemu_st8:
1241 tcg_out_qemu_st(s, args, 0);
1243 case INDEX_op_qemu_st16:
1244 tcg_out_qemu_st(s, args, 1);
1246 case INDEX_op_qemu_st32:
1247 tcg_out_qemu_st(s, args, 2);
1249 case INDEX_op_qemu_st64:
1250 tcg_out_qemu_st(s, args, 3);
1258 static const TCGTargetOpDef mips_op_defs[] = {
1259 { INDEX_op_exit_tb, { } },
1260 { INDEX_op_goto_tb, { } },
1261 { INDEX_op_call, { "C" } },
1262 { INDEX_op_jmp, { "r" } },
1263 { INDEX_op_br, { } },
1265 { INDEX_op_mov_i32, { "r", "r" } },
1266 { INDEX_op_movi_i32, { "r" } },
1267 { INDEX_op_ld8u_i32, { "r", "r" } },
1268 { INDEX_op_ld8s_i32, { "r", "r" } },
1269 { INDEX_op_ld16u_i32, { "r", "r" } },
1270 { INDEX_op_ld16s_i32, { "r", "r" } },
1271 { INDEX_op_ld_i32, { "r", "r" } },
1272 { INDEX_op_st8_i32, { "rZ", "r" } },
1273 { INDEX_op_st16_i32, { "rZ", "r" } },
1274 { INDEX_op_st_i32, { "rZ", "r" } },
1276 { INDEX_op_add_i32, { "r", "rZ", "rJZ" } },
1277 { INDEX_op_mul_i32, { "r", "rZ", "rZ" } },
1278 { INDEX_op_mulu2_i32, { "r", "r", "rZ", "rZ" } },
1279 { INDEX_op_div_i32, { "r", "rZ", "rZ" } },
1280 { INDEX_op_divu_i32, { "r", "rZ", "rZ" } },
1281 { INDEX_op_rem_i32, { "r", "rZ", "rZ" } },
1282 { INDEX_op_remu_i32, { "r", "rZ", "rZ" } },
1283 { INDEX_op_sub_i32, { "r", "rZ", "rJZ" } },
1285 { INDEX_op_and_i32, { "r", "rZ", "rIZ" } },
1286 { INDEX_op_not_i32, { "r", "rZ" } },
1287 { INDEX_op_or_i32, { "r", "rZ", "rIZ" } },
1288 { INDEX_op_xor_i32, { "r", "rZ", "rIZ" } },
1290 { INDEX_op_shl_i32, { "r", "rZ", "riZ" } },
1291 { INDEX_op_shr_i32, { "r", "rZ", "riZ" } },
1292 { INDEX_op_sar_i32, { "r", "rZ", "riZ" } },
1294 { INDEX_op_brcond_i32, { "rZ", "rZ" } },
1295 { INDEX_op_setcond_i32, { "r", "rZ", "rZ" } },
1297 { INDEX_op_add2_i32, { "r", "r", "rZ", "rZ", "rJZ", "rJZ" } },
1298 { INDEX_op_sub2_i32, { "r", "r", "rZ", "rZ", "rJZ", "rJZ" } },
1299 { INDEX_op_brcond2_i32, { "rZ", "rZ", "rZ", "rZ" } },
1301 #if TARGET_LONG_BITS == 32
1302 { INDEX_op_qemu_ld8u, { "L", "lZ" } },
1303 { INDEX_op_qemu_ld8s, { "L", "lZ" } },
1304 { INDEX_op_qemu_ld16u, { "L", "lZ" } },
1305 { INDEX_op_qemu_ld16s, { "L", "lZ" } },
1306 { INDEX_op_qemu_ld32u, { "L", "lZ" } },
1307 { INDEX_op_qemu_ld64, { "L", "L", "lZ" } },
1309 { INDEX_op_qemu_st8, { "SZ", "SZ" } },
1310 { INDEX_op_qemu_st16, { "SZ", "SZ" } },
1311 { INDEX_op_qemu_st32, { "SZ", "SZ" } },
1312 { INDEX_op_qemu_st64, { "SZ", "SZ", "SZ" } },
1314 { INDEX_op_qemu_ld8u, { "L", "lZ", "lZ" } },
1315 { INDEX_op_qemu_ld8s, { "L", "lZ", "lZ" } },
1316 { INDEX_op_qemu_ld16u, { "L", "lZ", "lZ" } },
1317 { INDEX_op_qemu_ld16s, { "L", "lZ", "lZ" } },
1318 { INDEX_op_qemu_ld32u, { "L", "lZ", "lZ" } },
1319 { INDEX_op_qemu_ld64, { "L", "L", "lZ", "lZ" } },
1321 { INDEX_op_qemu_st8, { "SZ", "SZ", "SZ" } },
1322 { INDEX_op_qemu_st16, { "SZ", "SZ", "SZ" } },
1323 { INDEX_op_qemu_st32, { "SZ", "SZ", "SZ" } },
1324 { INDEX_op_qemu_st64, { "SZ", "SZ", "SZ", "SZ" } },
1329 static int tcg_target_callee_save_regs[] = {
1339 /* TCG_REG_FP, */ /* currently used for the global env, so np
1341 TCG_REG_RA, /* should be last for ABI compliance */
1344 /* Generate global QEMU prologue and epilogue code */
1345 void tcg_target_qemu_prologue(TCGContext *s)
1349 /* reserve some stack space */
1350 frame_size = ARRAY_SIZE(tcg_target_callee_save_regs) * 4
1351 + TCG_STATIC_CALL_ARGS_SIZE;
1352 frame_size = (frame_size + TCG_TARGET_STACK_ALIGN - 1) &
1353 ~(TCG_TARGET_STACK_ALIGN - 1);
1356 tcg_out_addi(s, TCG_REG_SP, -frame_size);
1357 for(i = 0 ; i < ARRAY_SIZE(tcg_target_callee_save_regs) ; i++) {
1358 tcg_out_st(s, TCG_TYPE_I32, tcg_target_callee_save_regs[i],
1359 TCG_REG_SP, TCG_STATIC_CALL_ARGS_SIZE + i * 4);
1362 /* Call generated code */
1363 tcg_out_opc_reg(s, OPC_JR, 0, TCG_REG_A0, 0);
1365 tb_ret_addr = s->code_ptr;
1368 for(i = 0 ; i < ARRAY_SIZE(tcg_target_callee_save_regs) ; i++) {
1369 tcg_out_ld(s, TCG_TYPE_I32, tcg_target_callee_save_regs[i],
1370 TCG_REG_SP, TCG_STATIC_CALL_ARGS_SIZE + i * 4);
1373 tcg_out_opc_reg(s, OPC_JR, 0, TCG_REG_RA, 0);
1374 tcg_out_addi(s, TCG_REG_SP, frame_size);
1377 void tcg_target_init(TCGContext *s)
1379 tcg_regset_set(tcg_target_available_regs[TCG_TYPE_I32], 0xffffffff);
1380 tcg_regset_set(tcg_target_call_clobber_regs,
1397 tcg_regset_clear(s->reserved_regs);
1398 tcg_regset_set_reg(s->reserved_regs, TCG_REG_ZERO); /* zero register */
1399 tcg_regset_set_reg(s->reserved_regs, TCG_REG_K0); /* kernel use only */
1400 tcg_regset_set_reg(s->reserved_regs, TCG_REG_K1); /* kernel use only */
1401 tcg_regset_set_reg(s->reserved_regs, TCG_REG_AT); /* internal use */
1402 tcg_regset_set_reg(s->reserved_regs, TCG_REG_T0); /* internal use */
1403 tcg_regset_set_reg(s->reserved_regs, TCG_REG_RA); /* return address */
1404 tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP); /* stack pointer */
1406 tcg_add_target_add_op_defs(mips_op_defs);