tcg-target.c revision 74bdaadb718584b216e29c13b9e1226c9f77205e
174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* 274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * Tiny Code Generator for QEMU 374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * 474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * Copyright (c) 2008 Fabrice Bellard 574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * 674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * Permission is hereby granted, free of charge, to any person obtaining a copy 774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * of this software and associated documentation files (the "Software"), to deal 874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * in the Software without restriction, including without limitation the rights 974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 1074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * copies of the Software, and to permit persons to whom the Software is 1174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * furnished to do so, subject to the following conditions: 1274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * 1374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * The above copyright notice and this permission notice shall be included in 1474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * all copies or substantial portions of the Software. 1574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * 1674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 2174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 2274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * THE SOFTWARE. 2374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt */ 2474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 2574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifndef NDEBUG 2674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { 2774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r0", 2874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r1", 2974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%rp", 3074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r3", 3174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r4", 3274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r5", 3374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r6", 3474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r7", 3574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r8", 3674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r9", 3774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r10", 3874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r11", 3974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r12", 4074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r13", 4174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r14", 4274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r15", 4374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r16", 4474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r17", 4574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r18", 4674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r19", 4774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r20", 4874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r21", 4974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r22", 5074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r23", 5174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r24", 5274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r25", 5374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r26", 5474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%dp", 5574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%ret0", 5674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%ret1", 5774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%sp", 5874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "%r31", 5974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 6074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 6174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 6274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const int tcg_target_reg_alloc_order[] = { 6374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R4, 6474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R5, 6574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R6, 6674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R7, 6774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R8, 6874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R9, 6974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R10, 7074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R11, 7174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R12, 7274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R13, 7374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 7474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R17, 7574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R14, 7674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R15, 7774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R16, 7874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 7974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 8074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const int tcg_target_call_iarg_regs[4] = { 8174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R26, 8274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R25, 8374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R24, 8474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R23, 8574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 8674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 8774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const int tcg_target_call_oarg_regs[2] = { 8874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_RET0, 8974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_RET1, 9074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 9174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 9274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void patch_reloc(uint8_t *code_ptr, int type, 9374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long value, tcg_target_long addend) 9474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 9574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (type) { 9674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case R_PARISC_PCREL17F: 9774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt hppa_patch17f((uint32_t *)code_ptr, value, addend); 9874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 9974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 10074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 10174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 10274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 10374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 10474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* maximum number of register used for input function arguments */ 10574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline int tcg_target_get_call_iarg_regs_count(int flags) 10674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 10774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return 4; 10874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 10974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 11074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* parse target specific constraints */ 11174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) 11274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 11374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt const char *ct_str; 11474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 11574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct_str = *pct_str; 11674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (ct_str[0]) { 11774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'r': 11874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct->ct |= TCG_CT_REG; 11974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(ct->u.regs, 0, 0xffffffff); 12074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 12174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'L': /* qemu_ld/st constraint */ 12274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct->ct |= TCG_CT_REG; 12374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(ct->u.regs, 0, 0xffffffff); 12474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R26); 12574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R25); 12674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R24); 12774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R23); 12874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 12974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 13074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return -1; 13174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 13274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct_str++; 13374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *pct_str = ct_str; 13474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return 0; 13574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 13674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 13774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* test if a constant matches the constraint */ 13874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline int tcg_target_const_match(tcg_target_long val, 13974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt const TCGArgConstraint *arg_ct) 14074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 14174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int ct; 14274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 14374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct = arg_ct->ct; 14474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 14574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* TODO */ 14674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 14774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return 0; 14874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 14974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 15074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_OP(x) ((x) << 26) 15174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_EXT3BR(x) ((x) << 13) 15274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_EXT3SH(x) ((x) << 10) 15374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_EXT4(x) ((x) << 6) 15474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_EXT5(x) (x) 15574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_EXT6(x) ((x) << 6) 15674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_EXT7(x) ((x) << 6) 15774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_EXT8A(x) ((x) << 6) 15874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_EXT8B(x) ((x) << 5) 15974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_T(x) (x) 16074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_R1(x) ((x) << 16) 16174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_R2(x) ((x) << 21) 16274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_DEP_LEN(x) (32 - (x)) 16374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_SHDEP_CP(x) ((31 - (x)) << 5) 16474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_SHDEP_P(x) ((x) << 5) 16574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define INSN_COND(x) ((x) << 13) 16674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 16774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COND_NEVER 0 16874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COND_EQUAL 1 16974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COND_LT 2 17074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COND_LTEQ 3 17174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COND_LTU 4 17274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COND_LTUEQ 5 17374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COND_SV 6 17474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COND_OD 7 17574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 17674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 17774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* Logical ADD */ 17874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ARITH_ADD (INSN_OP(0x02) | INSN_EXT6(0x28)) 17974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ARITH_AND (INSN_OP(0x02) | INSN_EXT6(0x08)) 18074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ARITH_OR (INSN_OP(0x02) | INSN_EXT6(0x09)) 18174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ARITH_XOR (INSN_OP(0x02) | INSN_EXT6(0x0a)) 18274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ARITH_SUB (INSN_OP(0x02) | INSN_EXT6(0x10)) 18374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 18474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SHD (INSN_OP(0x34) | INSN_EXT3SH(2)) 18574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define VSHD (INSN_OP(0x34) | INSN_EXT3SH(0)) 18674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define DEP (INSN_OP(0x35) | INSN_EXT3SH(3)) 18774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ZDEP (INSN_OP(0x35) | INSN_EXT3SH(2)) 18874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ZVDEP (INSN_OP(0x35) | INSN_EXT3SH(0)) 18974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define EXTRU (INSN_OP(0x34) | INSN_EXT3SH(6)) 19074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define EXTRS (INSN_OP(0x34) | INSN_EXT3SH(7)) 19174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define VEXTRS (INSN_OP(0x34) | INSN_EXT3SH(5)) 19274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 19374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SUBI (INSN_OP(0x25)) 19474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define MTCTL (INSN_OP(0x00) | INSN_EXT8B(0xc2)) 19574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 19674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BL (INSN_OP(0x3a) | INSN_EXT3BR(0)) 19774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BLE_SR4 (INSN_OP(0x39) | (1 << 13)) 19874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BV (INSN_OP(0x3a) | INSN_EXT3BR(6)) 19974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BV_N (INSN_OP(0x3a) | INSN_EXT3BR(6) | 2) 20074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LDIL (INSN_OP(0x08)) 20174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LDO (INSN_OP(0x0d)) 20274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 20374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LDB (INSN_OP(0x10)) 20474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LDH (INSN_OP(0x11)) 20574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LDW (INSN_OP(0x12)) 20674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LDWM (INSN_OP(0x13)) 20774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 20874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STB (INSN_OP(0x18)) 20974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STH (INSN_OP(0x19)) 21074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STW (INSN_OP(0x1a)) 21174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STWM (INSN_OP(0x1b)) 21274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 21374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COMBT (INSN_OP(0x20)) 21474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define COMBF (INSN_OP(0x22)) 21574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 21674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic int lowsignext(uint32_t val, int start, int length) 21774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 21874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return (((val << 1) & ~(~0 << length)) | 21974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ((val >> (length - 1)) & 1)) << start; 22074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 22174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 22274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_mov(TCGContext *s, int ret, int arg) 22374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 22474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* PA1.1 defines COPY as OR r,0,t */ 22574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, ARITH_OR | INSN_T(ret) | INSN_R1(arg) | INSN_R2(TCG_REG_R0)); 22674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 22774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* PA2.0 defines COPY as LDO 0(r),t 22874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt * but hppa-dis.c is unaware of this definition */ 22974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* tcg_out32(s, LDO | INSN_R1(ret) | INSN_R2(arg) | reassemble_14(0)); */ 23074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 23174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 23274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_movi(TCGContext *s, TCGType type, 23374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int ret, tcg_target_long arg) 23474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 23574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (arg == (arg & 0x1fff)) { 23674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, LDO | INSN_R1(ret) | INSN_R2(TCG_REG_R0) | 23774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reassemble_14(arg)); 23874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } else { 23974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, LDIL | INSN_R2(ret) | 24074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reassemble_21(lrsel((uint32_t)arg, 0))); 24174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (arg & 0x7ff) 24274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, LDO | INSN_R1(ret) | INSN_R2(ret) | 24374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reassemble_14(rrsel((uint32_t)arg, 0))); 24474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 24574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 24674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 24774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_ld_raw(TCGContext *s, int ret, 24874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long arg) 24974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 25074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, LDIL | INSN_R2(ret) | 25174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reassemble_21(lrsel((uint32_t)arg, 0))); 25274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, LDW | INSN_R1(ret) | INSN_R2(ret) | 25374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reassemble_14(rrsel((uint32_t)arg, 0))); 25474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 25574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 25674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_ld_ptr(TCGContext *s, int ret, 25774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long arg) 25874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 25974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ld_raw(s, ret, arg); 26074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 26174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 26274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_ldst(TCGContext *s, int ret, int addr, int offset, 26374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int op) 26474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 26574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (offset == (offset & 0xfff)) 26674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, op | INSN_R1(ret) | INSN_R2(addr) | 26774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reassemble_14(offset)); 26874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 26974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented %s with offset %d\n", __func__, offset); 27074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 27174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 27274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 27374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 27474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, 27574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int arg1, tcg_target_long arg2) 27674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 27774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented %s\n", __func__); 27874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 27974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 28074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 28174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_st(TCGContext *s, TCGType type, int ret, 28274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int arg1, tcg_target_long arg2) 28374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 28474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented %s\n", __func__); 28574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 28674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 28774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 28874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_arith(TCGContext *s, int t, int r1, int r2, int op) 28974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 29074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, op | INSN_T(t) | INSN_R1(r1) | INSN_R2(r2)); 29174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 29274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 29374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_arithi(TCGContext *s, int t, int r1, 29474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long val, int op) 29574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 29674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R20, val); 29774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arith(s, t, r1, TCG_REG_R20, op); 29874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 29974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 30074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val) 30174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 30274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arithi(s, reg, reg, val, ARITH_ADD); 30374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 30474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 30574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_nop(TCGContext *s) 30674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 30774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, ARITH_OR | INSN_T(TCG_REG_R0) | INSN_R1(TCG_REG_R0) | 30874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_R2(TCG_REG_R0)); 30974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 31074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 31174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_ext8s(TCGContext *s, int ret, int arg) { 31274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, EXTRS | INSN_R1(ret) | INSN_R2(arg) | 31374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_P(31) | INSN_DEP_LEN(8)); 31474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 31574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 31674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_ext16s(TCGContext *s, int ret, int arg) { 31774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, EXTRS | INSN_R1(ret) | INSN_R2(arg) | 31874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_P(31) | INSN_DEP_LEN(16)); 31974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 32074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 32174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_bswap16(TCGContext *s, int ret, int arg) { 32274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if(ret != arg) 32374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, ret, arg); 32474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, DEP | INSN_R2(ret) | INSN_R1(ret) | 32574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_CP(15) | INSN_DEP_LEN(8)); 32674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, SHD | INSN_T(ret) | INSN_R1(TCG_REG_R0) | 32774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_R2(ret) | INSN_SHDEP_CP(8)); 32874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 32974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 33074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_bswap32(TCGContext *s, int ret, int arg, int temp) { 33174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, SHD | INSN_T(temp) | INSN_R1(arg) | 33274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_R2(arg) | INSN_SHDEP_CP(16)); 33374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, DEP | INSN_R2(temp) | INSN_R1(temp) | 33474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_CP(15) | INSN_DEP_LEN(8)); 33574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, SHD | INSN_T(ret) | INSN_R1(arg) | 33674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_R2(temp) | INSN_SHDEP_CP(8)); 33774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 33874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 33974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_call(TCGContext *s, void *func) 34074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 34174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t val = (uint32_t)__canonicalize_funcptr_for_compare(func); 34274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, LDIL | INSN_R2(TCG_REG_R20) | 34374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reassemble_21(lrsel(val, 0))); 34474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, BLE_SR4 | INSN_R2(TCG_REG_R20) | 34574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reassemble_17(rrsel(val, 0) >> 2)); 34674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_RP, TCG_REG_R31); 34774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 34874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 34974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 35074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 35174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#include "../../softmmu_defs.h" 35274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 35374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void *qemu_ld_helpers[4] = { 35474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __ldb_mmu, 35574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __ldw_mmu, 35674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __ldl_mmu, 35774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __ldq_mmu, 35874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 35974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 36074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void *qemu_st_helpers[4] = { 36174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __stb_mmu, 36274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __stw_mmu, 36374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __stl_mmu, 36474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __stq_mmu, 36574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 36674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 36774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 36874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc) 36974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 37074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int addr_reg, data_reg, data_reg2, r0, r1, mem_index, s_bits, bswap; 37174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 37274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t *label1_ptr, *label2_ptr; 37374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 37474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 37574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 37674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t *label3_ptr; 37774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 37874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int addr_reg2; 37974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 38074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 38174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg = *args++; 38274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (opc == 3) 38374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg2 = *args++; 38474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 38574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg2 = 0; /* suppress warning */ 38674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt addr_reg = *args++; 38774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 38874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt addr_reg2 = *args++; 38974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 39074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt mem_index = *args; 39174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt s_bits = opc & 3; 39274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 39374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r0 = TCG_REG_R26; 39474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r1 = TCG_REG_R25; 39574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 39674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 39774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, r1, addr_reg); 39874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 39974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, r0, addr_reg); 40074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 40174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, SHD | INSN_T(r1) | INSN_R1(TCG_REG_R0) | INSN_R2(r1) | 40274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_CP(TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS)); 40374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 40474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arithi(s, r0, r0, TARGET_PAGE_MASK | ((1 << s_bits) - 1), 40574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ARITH_AND); 40674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 40774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arithi(s, r1, r1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 40874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ARITH_AND); 40974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 41074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arith(s, r1, r1, TCG_AREG0, ARITH_ADD); 41174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arithi(s, r1, r1, 41274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt offsetof(CPUState, tlb_table[mem_index][0].addr_read), 41374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ARITH_ADD); 41474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 41574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, TCG_REG_R20, r1, 0, LDW); 41674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 41774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 32 41874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* if equal, jump to label1 */ 41974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label1_ptr = (uint32_t *)s->code_ptr; 42074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, COMBT | INSN_R1(TCG_REG_R20) | INSN_R2(r0) | 42174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_COND(COND_EQUAL)); 42274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, r0, addr_reg); /* delay slot */ 42374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 42474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* if not equal, jump to label3 */ 42574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label3_ptr = (uint32_t *)s->code_ptr; 42674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, COMBF | INSN_R1(TCG_REG_R20) | INSN_R2(r0) | 42774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_COND(COND_EQUAL)); 42874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, r0, addr_reg); /* delay slot */ 42974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 43074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, TCG_REG_R20, r1, 4, LDW); 43174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 43274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* if equal, jump to label1 */ 43374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label1_ptr = (uint32_t *)s->code_ptr; 43474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, COMBT | INSN_R1(TCG_REG_R20) | INSN_R2(addr_reg2) | 43574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_COND(COND_EQUAL)); 43674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_nop(s); /* delay slot */ 43774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 43874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* label3: */ 43974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *label3_ptr |= reassemble_12((uint32_t *)s->code_ptr - label3_ptr - 2); 44074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 44174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 44274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 32 44374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R26, addr_reg); 44474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R25, mem_index); 44574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 44674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R26, addr_reg); 44774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R25, addr_reg2); 44874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R24, mem_index); 44974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 45074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 45174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_call(s, qemu_ld_helpers[s_bits]); 45274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 45374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch(opc) { 45474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0 | 4: 45574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ext8s(s, data_reg, TCG_REG_RET0); 45674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 45774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1 | 4: 45874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ext16s(s, data_reg, TCG_REG_RET0); 45974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 46074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0: 46174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1: 46274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 2: 46374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 46474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, data_reg, TCG_REG_RET0); 46574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 46674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 3: 46774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 46874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, data_reg, TCG_REG_RET0); 46974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, data_reg2, TCG_REG_RET1); 47074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 47174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 47274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 47374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* jump to label2 */ 47474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label2_ptr = (uint32_t *)s->code_ptr; 47574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, BL | INSN_R2(TCG_REG_R0) | 2); 47674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 47774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* label1: */ 47874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *label1_ptr |= reassemble_12((uint32_t *)s->code_ptr - label1_ptr - 2); 47974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 48074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arithi(s, TCG_REG_R20, r1, 48174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt offsetof(CPUTLBEntry, addend) - offsetof(CPUTLBEntry, addr_read), 48274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ARITH_ADD); 48374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, TCG_REG_R20, TCG_REG_R20, 0, LDW); 48474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arith(s, r0, r0, TCG_REG_R20, ARITH_ADD); 48574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 48674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r0 = addr_reg; 48774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 48874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 48974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef TARGET_WORDS_BIGENDIAN 49074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt bswap = 0; 49174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 49274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt bswap = 1; 49374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 49474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (opc) { 49574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0: 49674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, LDB); 49774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 49874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0 | 4: 49974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, LDB); 50074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ext8s(s, data_reg, data_reg); 50174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 50274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1: 50374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, LDH); 50474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) 50574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bswap16(s, data_reg, data_reg); 50674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 50774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1 | 4: 50874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, LDH); 50974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) 51074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bswap16(s, data_reg, data_reg); 51174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ext16s(s, data_reg, data_reg); 51274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 51374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 2: 51474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, LDW); 51574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) 51674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bswap32(s, data_reg, data_reg, TCG_REG_R20); 51774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 51874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 3: 51974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 52074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (!bswap) { 52174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, LDW); 52274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg2, r0, 4, LDW); 52374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } else { 52474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 4, LDW); 52574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bswap32(s, data_reg, data_reg, TCG_REG_R20); 52674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg2, r0, 0, LDW); 52774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bswap32(s, data_reg2, data_reg2, TCG_REG_R20); 52874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 52974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 53074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 53174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 53274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 53374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 53474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 53574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* label2: */ 53674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *label2_ptr |= reassemble_17((uint32_t *)s->code_ptr - label2_ptr - 2); 53774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 53874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 53974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 54074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc) 54174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 54274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int addr_reg, data_reg, data_reg2, r0, r1, mem_index, s_bits, bswap; 54374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 54474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t *label1_ptr, *label2_ptr; 54574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 54674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 54774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 54874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t *label3_ptr; 54974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 55074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int addr_reg2; 55174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 55274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 55374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg = *args++; 55474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (opc == 3) 55574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg2 = *args++; 55674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 55774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg2 = 0; /* suppress warning */ 55874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt addr_reg = *args++; 55974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 56074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt addr_reg2 = *args++; 56174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 56274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt mem_index = *args; 56374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 56474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt s_bits = opc; 56574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 56674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r0 = TCG_REG_R26; 56774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r1 = TCG_REG_R25; 56874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 56974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 57074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, r1, addr_reg); 57174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 57274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, r0, addr_reg); 57374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 57474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, SHD | INSN_T(r1) | INSN_R1(TCG_REG_R0) | INSN_R2(r1) | 57574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_CP(TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS)); 57674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 57774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arithi(s, r0, r0, TARGET_PAGE_MASK | ((1 << s_bits) - 1), 57874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ARITH_AND); 57974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 58074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arithi(s, r1, r1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 58174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ARITH_AND); 58274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 58374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arith(s, r1, r1, TCG_AREG0, ARITH_ADD); 58474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arithi(s, r1, r1, 58574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt offsetof(CPUState, tlb_table[mem_index][0].addr_write), 58674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ARITH_ADD); 58774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 58874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, TCG_REG_R20, r1, 0, LDW); 58974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 59074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 32 59174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* if equal, jump to label1 */ 59274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label1_ptr = (uint32_t *)s->code_ptr; 59374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, COMBT | INSN_R1(TCG_REG_R20) | INSN_R2(r0) | 59474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_COND(COND_EQUAL)); 59574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, r0, addr_reg); /* delay slot */ 59674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 59774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* if not equal, jump to label3 */ 59874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label3_ptr = (uint32_t *)s->code_ptr; 59974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, COMBF | INSN_R1(TCG_REG_R20) | INSN_R2(r0) | 60074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_COND(COND_EQUAL)); 60174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, r0, addr_reg); /* delay slot */ 60274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 60374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, TCG_REG_R20, r1, 4, LDW); 60474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 60574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* if equal, jump to label1 */ 60674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label1_ptr = (uint32_t *)s->code_ptr; 60774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, COMBT | INSN_R1(TCG_REG_R20) | INSN_R2(addr_reg2) | 60874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_COND(COND_EQUAL)); 60974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_nop(s); /* delay slot */ 61074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 61174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* label3: */ 61274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *label3_ptr |= reassemble_12((uint32_t *)s->code_ptr - label3_ptr - 2); 61374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 61474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 61574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R26, addr_reg); 61674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 61774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R25, addr_reg2); 61874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (opc == 3) { 61974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 62074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R24, data_reg); 62174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R23, data_reg2); 62274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* TODO: push mem_index */ 62374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 62474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } else { 62574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch(opc) { 62674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0: 62774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, EXTRU | INSN_R1(TCG_REG_R24) | INSN_R2(data_reg) | 62874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_P(31) | INSN_DEP_LEN(8)); 62974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 63074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1: 63174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, EXTRU | INSN_R1(TCG_REG_R24) | INSN_R2(data_reg) | 63274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_P(31) | INSN_DEP_LEN(16)); 63374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 63474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 2: 63574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R24, data_reg); 63674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 63774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 63874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R23, mem_index); 63974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 64074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 64174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (opc == 3) { 64274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 64374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R25, data_reg); 64474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R24, data_reg2); 64574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R23, mem_index); 64674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } else { 64774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch(opc) { 64874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0: 64974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, EXTRU | INSN_R1(TCG_REG_R25) | INSN_R2(data_reg) | 65074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_P(31) | INSN_DEP_LEN(8)); 65174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 65274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1: 65374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, EXTRU | INSN_R1(TCG_REG_R25) | INSN_R2(data_reg) | 65474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_SHDEP_P(31) | INSN_DEP_LEN(16)); 65574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 65674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 2: 65774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_R25, data_reg); 65874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 65974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 66074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R24, mem_index); 66174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 66274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 66374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_call(s, qemu_st_helpers[s_bits]); 66474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 66574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* jump to label2 */ 66674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label2_ptr = (uint32_t *)s->code_ptr; 66774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, BL | INSN_R2(TCG_REG_R0) | 2); 66874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 66974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* label1: */ 67074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *label1_ptr |= reassemble_12((uint32_t *)s->code_ptr - label1_ptr - 2); 67174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 67274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arithi(s, TCG_REG_R20, r1, 67374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt offsetof(CPUTLBEntry, addend) - offsetof(CPUTLBEntry, addr_write), 67474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ARITH_ADD); 67574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, TCG_REG_R20, TCG_REG_R20, 0, LDW); 67674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arith(s, r0, r0, TCG_REG_R20, ARITH_ADD); 67774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 67874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r0 = addr_reg; 67974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 68074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 68174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef TARGET_WORDS_BIGENDIAN 68274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt bswap = 0; 68374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 68474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt bswap = 1; 68574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 68674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (opc) { 68774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0: 68874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, STB); 68974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 69074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1: 69174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) { 69274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bswap16(s, TCG_REG_R20, data_reg); 69374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg = TCG_REG_R20; 69474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 69574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, STH); 69674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 69774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 2: 69874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) { 69974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bswap32(s, TCG_REG_R20, data_reg, TCG_REG_R20); 70074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg = TCG_REG_R20; 70174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 70274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, STW); 70374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 70474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 3: 70574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 70674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (!bswap) { 70774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg, r0, 0, STW); 70874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, data_reg2, r0, 4, STW); 70974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } else { 71074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bswap32(s, TCG_REG_R20, data_reg, TCG_REG_R20); 71174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, TCG_REG_R20, r0, 4, STW); 71274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bswap32(s, TCG_REG_R20, data_reg2, TCG_REG_R20); 71374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, TCG_REG_R20, r0, 0, STW); 71474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 71574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 71674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 71774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 71874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 71974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 72074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 72174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* label2: */ 72274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *label2_ptr |= reassemble_17((uint32_t *)s->code_ptr - label2_ptr - 2); 72374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 72474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 72574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 72674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, 72774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt const int *const_args) 72874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 72974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int c; 73074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 73174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (opc) { 73274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_exit_tb: 73374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_RET0, args[0]); 73474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, BV_N | INSN_R2(TCG_REG_R18)); 73574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 73674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_goto_tb: 73774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (s->tb_jmp_offset) { 73874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* direct jump method */ 73974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "goto_tb direct\n"); 74074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 74174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R20, args[0]); 74274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, BV_N | INSN_R2(TCG_REG_R20)); 74374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; 74474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } else { 74574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* indirect jump method */ 74674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ld_ptr(s, TCG_REG_R20, 74774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (tcg_target_long)(s->tb_next + args[0])); 74874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, BV_N | INSN_R2(TCG_REG_R20)); 74974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 75074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf; 75174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 75274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_call: 75374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, BLE_SR4 | INSN_R2(args[0])); 75474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_mov(s, TCG_REG_RP, TCG_REG_R31); 75574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 75674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_jmp: 75774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented jmp\n"); 75874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 75974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 76074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_br: 76174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented br\n"); 76274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 76374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 76474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_movi_i32: 76574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_I32, args[0], (uint32_t)args[1]); 76674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 76774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 76874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld8u_i32: 76974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, args[0], args[1], args[2], LDB); 77074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 77174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld8s_i32: 77274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, args[0], args[1], args[2], LDB); 77374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ext8s(s, args[0], args[0]); 77474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 77574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld16u_i32: 77674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, args[0], args[1], args[2], LDH); 77774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 77874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld16s_i32: 77974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, args[0], args[1], args[2], LDH); 78074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ext16s(s, args[0], args[0]); 78174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 78274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld_i32: 78374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, args[0], args[1], args[2], LDW); 78474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 78574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 78674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_st8_i32: 78774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, args[0], args[1], args[2], STB); 78874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 78974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_st16_i32: 79074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, args[0], args[1], args[2], STH); 79174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 79274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_st_i32: 79374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst(s, args[0], args[1], args[2], STW); 79474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 79574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 79674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_sub_i32: 79774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt c = ARITH_SUB; 79874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt goto gen_arith; 79974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_and_i32: 80074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt c = ARITH_AND; 80174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt goto gen_arith; 80274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_or_i32: 80374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt c = ARITH_OR; 80474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt goto gen_arith; 80574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_xor_i32: 80674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt c = ARITH_XOR; 80774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt goto gen_arith; 80874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_add_i32: 80974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt c = ARITH_ADD; 81074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt goto gen_arith; 81174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 81274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_shl_i32: 81374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, SUBI | INSN_R1(TCG_REG_R20) | INSN_R2(args[2]) | 81474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt lowsignext(0x1f, 0, 11)); 81574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, MTCTL | INSN_R2(11) | INSN_R1(TCG_REG_R20)); 81674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, ZVDEP | INSN_R2(args[0]) | INSN_R1(args[1]) | 81774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_DEP_LEN(32)); 81874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 81974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_shr_i32: 82074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, MTCTL | INSN_R2(11) | INSN_R1(args[2])); 82174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, VSHD | INSN_T(args[0]) | INSN_R1(TCG_REG_R0) | 82274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_R2(args[1])); 82374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 82474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_sar_i32: 82574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, SUBI | INSN_R1(TCG_REG_R20) | INSN_R2(args[2]) | 82674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt lowsignext(0x1f, 0, 11)); 82774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, MTCTL | INSN_R2(11) | INSN_R1(TCG_REG_R20)); 82874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32(s, VEXTRS | INSN_R1(args[0]) | INSN_R2(args[1]) | 82974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt INSN_DEP_LEN(32)); 83074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 83174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 83274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_mul_i32: 83374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented mul\n"); 83474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 83574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 83674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_mulu2_i32: 83774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented mulu2\n"); 83874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 83974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 84074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_div2_i32: 84174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented div2\n"); 84274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 84374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 84474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_divu2_i32: 84574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented divu2\n"); 84674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 84774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 84874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 84974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_brcond_i32: 85074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unimplemented brcond\n"); 85174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 85274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 85374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 85474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld8u: 85574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 0); 85674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 85774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld8s: 85874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 0 | 4); 85974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 86074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld16u: 86174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 1); 86274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 86374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld16s: 86474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 1 | 4); 86574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 86674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld32u: 86774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 2); 86874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 86974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 87074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_st8: 87174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_st(s, args, 0); 87274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 87374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_st16: 87474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_st(s, args, 1); 87574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 87674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_st32: 87774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_st(s, args, 2); 87874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 87974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 88074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 88174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt fprintf(stderr, "unknown opcode 0x%x\n", opc); 88274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 88374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 88474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return; 88574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 88674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtgen_arith: 88774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_arith(s, args[0], args[1], args[2], c); 88874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 88974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 89074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const TCGTargetOpDef hppa_op_defs[] = { 89174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_exit_tb, { } }, 89274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_goto_tb, { } }, 89374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 89474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_call, { "r" } }, 89574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_jmp, { "r" } }, 89674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_br, { } }, 89774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 89874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_mov_i32, { "r", "r" } }, 89974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_movi_i32, { "r" } }, 90074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld8u_i32, { "r", "r" } }, 90174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld8s_i32, { "r", "r" } }, 90274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld16u_i32, { "r", "r" } }, 90374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld16s_i32, { "r", "r" } }, 90474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld_i32, { "r", "r" } }, 90574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_st8_i32, { "r", "r" } }, 90674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_st16_i32, { "r", "r" } }, 90774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_st_i32, { "r", "r" } }, 90874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 90974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_add_i32, { "r", "r", "r" } }, 91074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_sub_i32, { "r", "r", "r" } }, 91174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_and_i32, { "r", "r", "r" } }, 91274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_or_i32, { "r", "r", "r" } }, 91374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_xor_i32, { "r", "r", "r" } }, 91474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 91574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_shl_i32, { "r", "r", "r" } }, 91674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_shr_i32, { "r", "r", "r" } }, 91774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_sar_i32, { "r", "r", "r" } }, 91874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 91974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_brcond_i32, { "r", "r" } }, 92074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 92174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 32 92274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld8u, { "r", "L" } }, 92374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld8s, { "r", "L" } }, 92474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld16u, { "r", "L" } }, 92574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld16s, { "r", "L" } }, 92674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld32u, { "r", "L" } }, 92774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld64, { "r", "r", "L" } }, 92874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 92974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st8, { "L", "L" } }, 93074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st16, { "L", "L" } }, 93174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st32, { "L", "L" } }, 93274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st64, { "L", "L", "L" } }, 93374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 93474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld8u, { "r", "L", "L" } }, 93574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld8s, { "r", "L", "L" } }, 93674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld16u, { "r", "L", "L" } }, 93774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld16s, { "r", "L", "L" } }, 93874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld32u, { "r", "L", "L" } }, 93974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld64, { "r", "r", "L", "L" } }, 94074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 94174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st8, { "L", "L", "L" } }, 94274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st16, { "L", "L", "L" } }, 94374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st32, { "L", "L", "L" } }, 94474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st64, { "L", "L", "L", "L" } }, 94574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 94674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { -1 }, 94774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 94874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 94974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtvoid tcg_target_init(TCGContext *s) 95074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 95174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff); 95274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(tcg_target_call_clobber_regs, 0, 95374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R20) | 95474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R21) | 95574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R22) | 95674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R23) | 95774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R24) | 95874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R25) | 95974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R26)); 96074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 96174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_clear(s->reserved_regs); 96274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0); /* hardwired to zero */ 96374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R1); /* addil target */ 96474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_RP); /* link register */ 96574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R3); /* frame pointer */ 96674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R18); /* return pointer */ 96774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R19); /* clobbered w/o pic */ 96874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R20); /* reserved */ 96974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_DP); /* data pointer */ 97074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP); /* stack pointer */ 97174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R31); /* ble link reg */ 97274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 97374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_add_target_add_op_defs(hppa_op_defs); 97474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 975