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 Comstedtstatic uint8_t *tb_ret_addr; 2674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 2774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef _CALL_DARWIN 2874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LINKAGE_AREA_SIZE 24 2974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LR_OFFSET 8 3074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#elif defined _CALL_AIX 3174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LINKAGE_AREA_SIZE 52 3274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LR_OFFSET 8 3374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 3474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LINKAGE_AREA_SIZE 8 3574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LR_OFFSET 4 3674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 3774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 3874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define FAST_PATH 3974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 4074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifndef GUEST_BASE 4174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define GUEST_BASE 0 4274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 4374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 4474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_USE_GUEST_BASE 4574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_GUEST_BASE_REG 30 4674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 4774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_GUEST_BASE_REG 0 4874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 4974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 5074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifndef NDEBUG 5174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { 5274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r0", 5374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r1", 54f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner "r2", 5574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r3", 5674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r4", 5774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r5", 5874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r6", 5974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r7", 6074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r8", 6174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r9", 6274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r10", 6374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r11", 6474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r12", 6574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r13", 6674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r14", 6774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r15", 6874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r16", 6974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r17", 7074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r18", 7174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r19", 7274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r20", 7374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r21", 7474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r22", 7574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r23", 7674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r24", 7774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r25", 7874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r26", 7974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r27", 8074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r28", 8174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r29", 8274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r30", 8374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt "r31" 8474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 8574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 8674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 8774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const int tcg_target_reg_alloc_order[] = { 8874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R14, 8974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R15, 9074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R16, 9174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R17, 9274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R18, 9374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R19, 9474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R20, 9574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R21, 9674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R22, 9774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R23, 9874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R28, 9974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R29, 10074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R30, 10174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R31, 10274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef _CALL_DARWIN 10374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R2, 10474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 10574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R3, 10674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R4, 10774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R5, 10874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R6, 10974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R7, 11074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R8, 11174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R9, 11274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R10, 11374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifndef _CALL_DARWIN 11474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R11, 11574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 11674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R12, 11774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifndef _CALL_SYSV 11874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R13, 11974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 12074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R24, 12174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R25, 12274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R26, 12374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R27 12474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 12574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 12674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const int tcg_target_call_iarg_regs[] = { 12774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R3, 12874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R4, 12974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R5, 13074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R6, 13174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R7, 13274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R8, 13374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R9, 13474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R10 13574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 13674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 13774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const int tcg_target_call_oarg_regs[2] = { 13874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R3, 13974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R4 14074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 14174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 14274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const int tcg_target_callee_save_regs[] = { 14374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef _CALL_DARWIN 14474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R11, 14574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R13, 14674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 14774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef _CALL_AIX 14874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R13, 14974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 15074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R14, 15174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R15, 15274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R16, 15374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R17, 15474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R18, 15574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R19, 15674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R20, 15774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R21, 15874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R22, 15974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R23, 16074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R24, 16174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R25, 16274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R26, 16374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* TCG_REG_R27, */ /* currently used for the global env, so no 16474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt need to save */ 16574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R28, 16674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R29, 16774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R30, 16874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_R31 16974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 17074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 17174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic uint32_t reloc_pc24_val (void *pc, tcg_target_long target) 17274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 17374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long disp; 17474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 17574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt disp = target - (tcg_target_long) pc; 17674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((disp << 6) >> 6 != disp) 17774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort (); 17874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 17974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return disp & 0x3fffffc; 18074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 18174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 18274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void reloc_pc24 (void *pc, tcg_target_long target) 18374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 18474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *(uint32_t *) pc = (*(uint32_t *) pc & ~0x3fffffc) 18574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | reloc_pc24_val (pc, target); 18674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 18774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 18874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic uint16_t reloc_pc14_val (void *pc, tcg_target_long target) 18974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 19074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long disp; 19174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 19274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt disp = target - (tcg_target_long) pc; 19374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (disp != (int16_t) disp) 19474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort (); 19574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 19674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return disp & 0xfffc; 19774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 19874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 19974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void reloc_pc14 (void *pc, tcg_target_long target) 20074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 20174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *(uint32_t *) pc = (*(uint32_t *) pc & ~0xfffc) 20274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | reloc_pc14_val (pc, target); 20374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 20474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 20574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void patch_reloc(uint8_t *code_ptr, int type, 20674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long value, tcg_target_long addend) 20774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 20874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt value += addend; 20974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (type) { 21074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case R_PPC_REL14: 21174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reloc_pc14 (code_ptr, value); 21274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 21374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case R_PPC_REL24: 21474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reloc_pc24 (code_ptr, value); 21574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 21674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 21774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 21874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 21974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 22074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 22174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* maximum number of register used for input function arguments */ 22274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic int tcg_target_get_call_iarg_regs_count(int flags) 22374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 22474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return ARRAY_SIZE (tcg_target_call_iarg_regs); 22574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 22674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 22774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* parse target specific constraints */ 22874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) 22974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 23074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt const char *ct_str; 23174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 23274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct_str = *pct_str; 23374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (ct_str[0]) { 23474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'A': case 'B': case 'C': case 'D': 23574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct->ct |= TCG_CT_REG; 23674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(ct->u.regs, 3 + ct_str[0] - 'A'); 23774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 23874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'r': 23974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct->ct |= TCG_CT_REG; 24074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(ct->u.regs, 0, 0xffffffff); 24174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 24274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_SOFTMMU 24374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'L': /* qemu_ld constraint */ 24474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct->ct |= TCG_CT_REG; 24574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(ct->u.regs, 0, 0xffffffff); 24674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R3); 24774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R4); 24874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 24974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'K': /* qemu_st[8..32] constraint */ 25074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct->ct |= TCG_CT_REG; 25174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(ct->u.regs, 0, 0xffffffff); 25274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R3); 25374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R4); 25474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R5); 25574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 25674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R6); 25774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 25874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 25974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'M': /* qemu_st64 constraint */ 26074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct->ct |= TCG_CT_REG; 26174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(ct->u.regs, 0, 0xffffffff); 26274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R3); 26374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R4); 26474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R5); 26574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R6); 26674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R7); 26774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 26874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 26974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'L': 27074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'K': 27174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct->ct |= TCG_CT_REG; 27274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(ct->u.regs, 0, 0xffffffff); 27374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 27474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 'M': 27574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct->ct |= TCG_CT_REG; 27674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(ct->u.regs, 0, 0xffffffff); 27774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_reset_reg(ct->u.regs, TCG_REG_R3); 27874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 27974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 28074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 28174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return -1; 28274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 28374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct_str++; 28474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *pct_str = ct_str; 28574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return 0; 28674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 28774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 28874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* test if a constant matches the constraint */ 28974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic int tcg_target_const_match(tcg_target_long val, 29074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt const TCGArgConstraint *arg_ct) 29174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 29274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int ct; 29374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 29474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ct = arg_ct->ct; 29574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (ct & TCG_CT_CONST) 29674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return 1; 29774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return 0; 29874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 29974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 30074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define OPCD(opc) ((opc)<<26) 30174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define XO31(opc) (OPCD(31)|((opc)<<1)) 30274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define XO19(opc) (OPCD(19)|((opc)<<1)) 30374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 30474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define B OPCD(18) 30574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BC OPCD(16) 30674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LBZ OPCD(34) 30774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LHZ OPCD(40) 30874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LHA OPCD(42) 30974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LWZ OPCD(32) 31074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STB OPCD(38) 31174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STH OPCD(44) 31274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STW OPCD(36) 31374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 31474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ADDIC OPCD(12) 31574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ADDI OPCD(14) 31674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ADDIS OPCD(15) 31774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ORI OPCD(24) 31874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ORIS OPCD(25) 31974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define XORI OPCD(26) 32074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define XORIS OPCD(27) 32174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ANDI OPCD(28) 32274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ANDIS OPCD(29) 32374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define MULLI OPCD( 7) 32474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CMPLI OPCD(10) 32574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CMPI OPCD(11) 326f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner#define SUBFIC OPCD( 8) 32774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 32874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LWZU OPCD(33) 32974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STWU OPCD(37) 33074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 331f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner#define RLWIMI OPCD(20) 33274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define RLWINM OPCD(21) 33374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define RLWNM OPCD(23) 33474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 33574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BCLR XO19( 16) 33674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BCCTR XO19(528) 33774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CRAND XO19(257) 33874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CRANDC XO19(129) 33974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CRNAND XO19(225) 34074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CROR XO19(449) 34174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CRNOR XO19( 33) 34274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 34374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define EXTSB XO31(954) 34474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define EXTSH XO31(922) 34574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ADD XO31(266) 34674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ADDE XO31(138) 34774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ADDC XO31( 10) 34874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define AND XO31( 28) 34974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SUBF XO31( 40) 35074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SUBFC XO31( 8) 35174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SUBFE XO31(136) 35274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define OR XO31(444) 35374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define XOR XO31(316) 35474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define MULLW XO31(235) 35574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define MULHWU XO31( 11) 35674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define DIVW XO31(491) 35774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define DIVWU XO31(459) 35874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CMP XO31( 0) 35974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CMPL XO31( 32) 36074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LHBRX XO31(790) 36174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LWBRX XO31(534) 36274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STHBRX XO31(918) 36374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STWBRX XO31(662) 36474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define MFSPR XO31(339) 36574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define MTSPR XO31(467) 36674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SRAWI XO31(824) 36774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define NEG XO31(104) 36874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define MFCR XO31( 19) 36974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CNTLZW XO31( 26) 37074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define NOR XO31(124) 37174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ANDC XO31( 60) 37274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ORC XO31(412) 373f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner#define EQV XO31(284) 374f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner#define NAND XO31(476) 37574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 37674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LBZX XO31( 87) 37774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LHZX XO31(279) 37874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LHAX XO31(343) 37974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LWZX XO31( 23) 38074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STBX XO31(215) 38174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STHX XO31(407) 38274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define STWX XO31(151) 38374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 38474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SPR(a,b) ((((a)<<5)|(b))<<11) 38574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LR SPR(8, 0) 38674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define CTR SPR(9, 0) 38774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 38874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SLW XO31( 24) 38974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SRW XO31(536) 39074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SRAW XO31(792) 39174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 39274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TW XO31(4) 39374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TRAP (TW | TO (31)) 39474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 39574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define RT(r) ((r)<<21) 39674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define RS(r) ((r)<<21) 39774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define RA(r) ((r)<<16) 39874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define RB(r) ((r)<<11) 39974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TO(t) ((t)<<21) 40074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SH(s) ((s)<<11) 40174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define MB(b) ((b)<<6) 40274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define ME(e) ((e)<<1) 40374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BO(o) ((o)<<21) 40474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 40574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define LK 1 40674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 40774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TAB(t,a,b) (RT(t) | RA(a) | RB(b)) 40874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define SAB(s,a,b) (RS(s) | RA(a) | RB(b)) 40974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 41074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BF(n) ((n)<<23) 41174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BI(n, c) (((c)+((n)*4))<<16) 41274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BT(n, c) (((c)+((n)*4))<<21) 41374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BA(n, c) (((c)+((n)*4))<<16) 41474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BB(n, c) (((c)+((n)*4))<<11) 41574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 41674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BO_COND_TRUE BO (12) 41774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BO_COND_FALSE BO (4) 41874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define BO_ALWAYS BO (20) 41974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 42074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtenum { 42174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt CR_LT, 42274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt CR_GT, 42374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt CR_EQ, 42474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt CR_SO 42574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 42674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 42774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const uint32_t tcg_to_bc[10] = { 42874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_EQ] = BC | BI (7, CR_EQ) | BO_COND_TRUE, 42974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_NE] = BC | BI (7, CR_EQ) | BO_COND_FALSE, 43074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_LT] = BC | BI (7, CR_LT) | BO_COND_TRUE, 43174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_GE] = BC | BI (7, CR_LT) | BO_COND_FALSE, 43274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_LE] = BC | BI (7, CR_GT) | BO_COND_FALSE, 43374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_GT] = BC | BI (7, CR_GT) | BO_COND_TRUE, 43474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_LTU] = BC | BI (7, CR_LT) | BO_COND_TRUE, 43574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_GEU] = BC | BI (7, CR_LT) | BO_COND_FALSE, 43674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_LEU] = BC | BI (7, CR_GT) | BO_COND_FALSE, 43774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_GTU] = BC | BI (7, CR_GT) | BO_COND_TRUE, 43874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 43974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 440f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turnerstatic void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg) 44174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 44274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, OR | SAB (arg, ret, arg)); 44374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 44474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 44574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_movi(TCGContext *s, TCGType type, 44674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int ret, tcg_target_long arg) 44774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 44874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (arg == (int16_t) arg) 44974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDI | RT (ret) | RA (0) | (arg & 0xffff)); 45074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 45174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDIS | RT (ret) | RA (0) | ((arg >> 16) & 0xffff)); 45274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (arg & 0xffff) 45374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ORI | RS (ret) | RA (ret) | (arg & 0xffff)); 45474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 45574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 45674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 45774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_ldst (TCGContext *s, int ret, int addr, 45874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int offset, int op1, int op2) 45974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 46074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (offset == (int16_t) offset) 46174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, op1 | RT (ret) | RA (addr) | (offset & 0xffff)); 46274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 46374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 0, offset); 46474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, op2 | RT (ret) | RA (addr) | RB (0)); 46574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 46674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 46774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 46874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_b (TCGContext *s, int mask, tcg_target_long target) 46974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 47074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long disp; 47174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 47274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt disp = target - (tcg_target_long) s->code_ptr; 47374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((disp << 6) >> 6 == disp) 47474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, B | (disp & 0x3fffffc) | mask); 47574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 47674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 0, (tcg_target_long) target); 47774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MTSPR | RS (0) | CTR); 47874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, BCCTR | BO_ALWAYS | mask); 47974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 48074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 48174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 48274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_call (TCGContext *s, tcg_target_long arg, int const_arg) 48374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 48474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef _CALL_AIX 48574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int reg; 48674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 48774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_arg) { 48874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reg = 2; 48974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, reg, arg); 49074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 49174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else reg = arg; 49274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 49374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZ | RT (0) | RA (reg)); 49474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MTSPR | RA (0) | CTR); 49574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZ | RT (2) | RA (reg) | 4); 49674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, BCCTR | BO_ALWAYS | LK); 49774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 49874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_arg) { 49974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_b (s, LK, arg); 50074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 50174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 50274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MTSPR | RS (arg) | LR); 50374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, BCLR | BO_ALWAYS | LK); 50474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 50574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 50674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 50774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 50874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(CONFIG_SOFTMMU) 50974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 51074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#include "../../softmmu_defs.h" 51174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 51274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void *qemu_ld_helpers[4] = { 51374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __ldb_mmu, 51474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __ldw_mmu, 51574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __ldl_mmu, 51674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __ldq_mmu, 51774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 51874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 51974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void *qemu_st_helpers[4] = { 52074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __stb_mmu, 52174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __stw_mmu, 52274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __stl_mmu, 52374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __stq_mmu, 52474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 52574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 52674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 52774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc) 52874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 52974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int addr_reg, data_reg, data_reg2, r0, r1, rbase, mem_index, s_bits, bswap; 53074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_SOFTMMU 53174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int r2; 53274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt void *label1_ptr, *label2_ptr; 53374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 53474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 53574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int addr_reg2; 53674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 53774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 53874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg = *args++; 53974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (opc == 3) 54074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg2 = *args++; 54174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 54274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg2 = 0; 54374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt addr_reg = *args++; 54474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 54574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt addr_reg2 = *args++; 54674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 54774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt mem_index = *args; 54874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt s_bits = opc & 3; 54974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 55074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_SOFTMMU 55174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r0 = 3; 55274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r1 = 4; 55374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r2 = 0; 55474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt rbase = 0; 55574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 55674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 55774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (r0) 55874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (addr_reg) 55974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (32 - (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS)) 56074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (32 - (CPU_TLB_BITS + CPU_TLB_ENTRY_BITS)) 56174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31 - CPU_TLB_ENTRY_BITS) 56274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 56374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 56474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (TCG_AREG0)); 56574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (LWZU 56674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RT (r1) 56774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (r0) 56874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | offsetof (CPUState, tlb_table[mem_index][0].addr_read) 56974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 57074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 57174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 57274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (r2) 57374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (addr_reg) 57474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (0) 57574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB ((32 - s_bits) & 31) 57674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31 - TARGET_PAGE_BITS) 57774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 57874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 57974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 58074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, CMP | BF (7) | RA (r2) | RB (r1)); 58174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 58274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZ | RT (r1) | RA (r0) | 4); 58374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, CMP | BF (6) | RA (addr_reg2) | RB (r1)); 58474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, CRAND | BT (7, CR_EQ) | BA (6, CR_EQ) | BB (7, CR_EQ)); 58574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 58674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 58774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label1_ptr = s->code_ptr; 58874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef FAST_PATH 58974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, BC | BI (7, CR_EQ) | BO_COND_TRUE); 59074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 59174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 59274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* slow path */ 59374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 32 594f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg); 59574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 4, mem_index); 59674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 597f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg2); 598f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 4, addr_reg); 59974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 5, mem_index); 60074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 60174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 60274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_call (s, (tcg_target_long) qemu_ld_helpers[s_bits], 1); 60374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (opc) { 60474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0|4: 60574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, EXTSB | RA (data_reg) | RS (3)); 60674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 60774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1|4: 60874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, EXTSH | RA (data_reg) | RS (3)); 60974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 61074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0: 61174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1: 61274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 2: 61374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (data_reg != 3) 614f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, data_reg, 3); 61574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 61674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 3: 61774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (data_reg == 3) { 61874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (data_reg2 == 4) { 619f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 0, 4); 620f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 4, 3); 621f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 3, 0); 62274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 62374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 624f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, data_reg2, 3); 625f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 3, 4); 62674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 62774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 62874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 629f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner if (data_reg != 4) tcg_out_mov (s, TCG_TYPE_I32, data_reg, 4); 630f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner if (data_reg2 != 3) tcg_out_mov (s, TCG_TYPE_I32, data_reg2, 3); 63174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 63274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 63374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 63474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label2_ptr = s->code_ptr; 63574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, B); 63674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 63774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* label1: fast path */ 63874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef FAST_PATH 63974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reloc_pc14 (label1_ptr, (tcg_target_long) s->code_ptr); 64074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 64174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 64274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* r0 now contains &env->tlb_table[mem_index][index].addr_read */ 64374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (LWZ 64474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RT (r0) 64574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (r0) 646f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | (offsetof (CPUTLBEntry, addend) 64774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt - offsetof (CPUTLBEntry, addr_read)) 64874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt )); 64974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* r0 = env->tlb_table[mem_index][index].addend */ 65074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (addr_reg)); 65174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* r0 = env->tlb_table[mem_index][index].addend + addr */ 65274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 65374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else /* !CONFIG_SOFTMMU */ 65474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r0 = addr_reg; 65574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r1 = 3; 65674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt rbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0; 65774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 65874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 65974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef TARGET_WORDS_BIGENDIAN 66074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt bswap = 0; 66174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 66274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt bswap = 1; 66374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 66474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 66574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (opc) { 66674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 66774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0: 66874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LBZX | TAB (data_reg, rbase, r0)); 66974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 67074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0|4: 67174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LBZX | TAB (data_reg, rbase, r0)); 67274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, EXTSB | RA (data_reg) | RS (data_reg)); 67374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 67474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1: 67574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) 67674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LHBRX | TAB (data_reg, rbase, r0)); 67774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 67874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LHZX | TAB (data_reg, rbase, r0)); 67974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 68074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1|4: 68174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) { 68274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LHBRX | TAB (data_reg, rbase, r0)); 68374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, EXTSH | RA (data_reg) | RS (data_reg)); 68474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 68574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else tcg_out32 (s, LHAX | TAB (data_reg, rbase, r0)); 68674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 68774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 2: 68874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) 68974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWBRX | TAB (data_reg, rbase, r0)); 69074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 69174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZX | TAB (data_reg, rbase, r0)); 69274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 69374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 3: 69474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) { 69574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDI | RT (r1) | RA (r0) | 4); 69674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWBRX | TAB (data_reg, rbase, r0)); 69774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWBRX | TAB (data_reg2, rbase, r1)); 69874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 69974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 70074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_USE_GUEST_BASE 70174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDI | RT (r1) | RA (r0) | 4); 70274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZX | TAB (data_reg2, rbase, r0)); 70374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZX | TAB (data_reg, rbase, r1)); 70474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 70574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (r0 == data_reg2) { 70674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZ | RT (0) | RA (r0)); 70774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZ | RT (data_reg) | RA (r0) | 4); 708f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, data_reg2, 0); 70974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 71074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 71174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZ | RT (data_reg2) | RA (r0)); 71274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZ | RT (data_reg) | RA (r0) | 4); 71374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 71474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 71574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 71674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 71774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 71874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 71974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_SOFTMMU 72074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reloc_pc24 (label2_ptr, (tcg_target_long) s->code_ptr); 72174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 72274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 72374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 72474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc) 72574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 72674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int addr_reg, r0, r1, data_reg, data_reg2, mem_index, bswap, rbase; 72774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_SOFTMMU 72874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int r2, ir; 72974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt void *label1_ptr, *label2_ptr; 73074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 73174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 73274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int addr_reg2; 73374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 73474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 73574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg = *args++; 73674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (opc == 3) 73774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg2 = *args++; 73874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 73974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt data_reg2 = 0; 74074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt addr_reg = *args++; 74174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 74274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt addr_reg2 = *args++; 74374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 74474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt mem_index = *args; 74574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 74674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_SOFTMMU 74774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r0 = 3; 74874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r1 = 4; 74974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r2 = 0; 75074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt rbase = 0; 75174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 75274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 75374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (r0) 75474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (addr_reg) 75574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (32 - (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS)) 75674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (32 - (CPU_TLB_ENTRY_BITS + CPU_TLB_BITS)) 75774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31 - CPU_TLB_ENTRY_BITS) 75874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 75974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 76074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (TCG_AREG0)); 76174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (LWZU 76274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RT (r1) 76374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (r0) 76474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | offsetof (CPUState, tlb_table[mem_index][0].addr_write) 76574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 76674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 76774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 76874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (r2) 76974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (addr_reg) 77074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (0) 77174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB ((32 - opc) & 31) 77274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31 - TARGET_PAGE_BITS) 77374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 77474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 77574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 77674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, CMP | (7 << 23) | RA (r2) | RB (r1)); 77774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 64 77874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZ | RT (r1) | RA (r0) | 4); 77974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, CMP | BF (6) | RA (addr_reg2) | RB (r1)); 78074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, CRAND | BT (7, CR_EQ) | BA (6, CR_EQ) | BB (7, CR_EQ)); 78174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 78274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 78374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label1_ptr = s->code_ptr; 78474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef FAST_PATH 78574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, BC | BI (7, CR_EQ) | BO_COND_TRUE); 78674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 78774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 78874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* slow path */ 78974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 32 790f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg); 79174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ir = 4; 79274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 793f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg2); 794f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, 4, addr_reg); 79574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef TCG_TARGET_CALL_ALIGN_ARGS 79674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ir = 5; 79774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 79874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ir = 4; 79974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 80074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 80174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 80274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (opc) { 80374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0: 80474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 80574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (ir) 80674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (data_reg) 80774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (0) 80874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (24) 80974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31))); 81074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 81174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1: 81274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 81374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (ir) 81474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (data_reg) 81574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (0) 81674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (16) 81774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31))); 81874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 81974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 2: 820f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, ir, data_reg); 82174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 82274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 3: 82374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef TCG_TARGET_CALL_ALIGN_ARGS 82474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ir = 5; 82574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 826f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, ir++, data_reg2); 827f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, ir, data_reg); 82874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 82974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 83074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ir++; 83174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 83274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, ir, mem_index); 83374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_call (s, (tcg_target_long) qemu_st_helpers[opc], 1); 83474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt label2_ptr = s->code_ptr; 83574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, B); 83674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 83774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* label1: fast path */ 83874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef FAST_PATH 83974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reloc_pc14 (label1_ptr, (tcg_target_long) s->code_ptr); 84074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 84174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 84274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (LWZ 84374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RT (r0) 84474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (r0) 845f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | (offsetof (CPUTLBEntry, addend) 84674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt - offsetof (CPUTLBEntry, addr_write)) 84774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt )); 84874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* r0 = env->tlb_table[mem_index][index].addend */ 84974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (addr_reg)); 85074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* r0 = env->tlb_table[mem_index][index].addend + addr */ 85174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 85274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else /* !CONFIG_SOFTMMU */ 85374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r0 = addr_reg; 85474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt r1 = 3; 85574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt rbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0; 85674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 85774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 85874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef TARGET_WORDS_BIGENDIAN 85974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt bswap = 0; 86074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 86174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt bswap = 1; 86274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 86374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (opc) { 86474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 0: 86574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STBX | SAB (data_reg, rbase, r0)); 86674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 86774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 1: 86874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) 86974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STHBRX | SAB (data_reg, rbase, r0)); 87074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 87174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STHX | SAB (data_reg, rbase, r0)); 87274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 87374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 2: 87474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) 87574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STWBRX | SAB (data_reg, rbase, r0)); 87674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 87774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STWX | SAB (data_reg, rbase, r0)); 87874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 87974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case 3: 88074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (bswap) { 88174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDI | RT (r1) | RA (r0) | 4); 88274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STWBRX | SAB (data_reg, rbase, r0)); 88374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STWBRX | SAB (data_reg2, rbase, r1)); 88474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 88574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 88674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_USE_GUEST_BASE 88774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STWX | SAB (data_reg2, rbase, r0)); 88874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDI | RT (r1) | RA (r0) | 4); 88974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STWX | SAB (data_reg, rbase, r1)); 89074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 89174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STW | RS (data_reg2) | RA (r0)); 89274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STW | RS (data_reg) | RA (r0) | 4); 89374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 89474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 89574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 89674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 89774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 89874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_SOFTMMU 89974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt reloc_pc24 (label2_ptr, (tcg_target_long) s->code_ptr); 90074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 90174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 90274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 903f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turnerstatic void tcg_target_qemu_prologue (TCGContext *s) 90474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 90574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int i, frame_size; 90674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 90774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt frame_size = 0 90874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt + LINKAGE_AREA_SIZE 90974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt + TCG_STATIC_CALL_ARGS_SIZE 91074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt + ARRAY_SIZE (tcg_target_callee_save_regs) * 4 91174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ; 91274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt frame_size = (frame_size + 15) & ~15; 91374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 91474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef _CALL_AIX 91574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { 91674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t addr; 91774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 91874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* First emit adhoc function descriptor */ 91974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt addr = (uint32_t) s->code_ptr + 12; 92074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, addr); /* entry point */ 92174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt s->code_ptr += 8; /* skip TOC and environment pointer */ 92274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 92374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 92474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MFSPR | RT (0) | LR); 92574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STWU | RS (1) | RA (1) | (-frame_size & 0xffff)); 92674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i) 92774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (STW 92874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (tcg_target_callee_save_regs[i]) 92974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (1) 93074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | (i * 4 + LINKAGE_AREA_SIZE + TCG_STATIC_CALL_ARGS_SIZE) 93174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 93274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 93374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, STW | RS (0) | RA (1) | (frame_size + LR_OFFSET)); 93474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 93574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_USE_GUEST_BASE 936f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner if (GUEST_BASE) { 937f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_movi (s, TCG_TYPE_I32, TCG_GUEST_BASE_REG, GUEST_BASE); 938f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); 939f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner } 94074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 94174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 94274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MTSPR | RS (3) | CTR); 94374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, BCCTR | BO_ALWAYS); 94474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tb_ret_addr = s->code_ptr; 94574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 94674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i) 94774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (LWZ 94874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RT (tcg_target_callee_save_regs[i]) 94974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (1) 95074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | (i * 4 + LINKAGE_AREA_SIZE + TCG_STATIC_CALL_ARGS_SIZE) 95174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 95274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 95374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, LWZ | RT (0) | RA (1) | (frame_size + LR_OFFSET)); 95474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MTSPR | RS (0) | LR); 95574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDI | RT (1) | RA (1) | frame_size); 95674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, BCLR | BO_ALWAYS); 95774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 95874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 95974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_ld (TCGContext *s, TCGType type, int ret, int arg1, 96074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long arg2) 96174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 96274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, ret, arg1, arg2, LWZ, LWZX); 96374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 96474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 96574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_st (TCGContext *s, TCGType type, int arg, int arg1, 96674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_target_long arg2) 96774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 96874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, arg, arg1, arg2, STW, STWX); 96974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 97074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 97174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void ppc_addi (TCGContext *s, int rt, int ra, tcg_target_long si) 97274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 97374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (!si && rt == ra) 97474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt return; 97574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 97674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (si == (int16_t) si) 97774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDI | RT (rt) | RA (ra) | (si & 0xffff)); 97874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 97974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint16_t h = ((si >> 16) & 0xffff) + ((uint16_t) si >> 15); 98074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDIS | RT (rt) | RA (ra) | h); 98174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDI | RT (rt) | RA (rt) | (si & 0xffff)); 98274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 98374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 98474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 98574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val) 98674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 98774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ppc_addi (s, reg, reg, val); 98874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 98974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 99074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_cmp (TCGContext *s, int cond, TCGArg arg1, TCGArg arg2, 99174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int const_arg2, int cr) 99274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 99374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int imm; 99474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t op; 99574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 99674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (cond) { 99774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_EQ: 99874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_NE: 99974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_arg2) { 100074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((int16_t) arg2 == arg2) { 100174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op = CMPI; 100274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt imm = 1; 100374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 100474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 100574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else if ((uint16_t) arg2 == arg2) { 100674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op = CMPLI; 100774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt imm = 1; 100874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 100974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 101074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 101174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op = CMPL; 101274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt imm = 0; 101374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 101474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 101574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LT: 101674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GE: 101774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LE: 101874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GT: 101974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_arg2) { 102074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((int16_t) arg2 == arg2) { 102174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op = CMPI; 102274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt imm = 1; 102374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 102474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 102574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 102674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op = CMP; 102774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt imm = 0; 102874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 102974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 103074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LTU: 103174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GEU: 103274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LEU: 103374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GTU: 103474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_arg2) { 103574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((uint16_t) arg2 == arg2) { 103674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op = CMPLI; 103774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt imm = 1; 103874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 103974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 104074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 104174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op = CMPL; 104274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt imm = 0; 104374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 104474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 104574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 104674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort (); 104774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 104874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op |= BF (cr); 104974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 105074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (imm) 105174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, op | RA (arg1) | (arg2 & 0xffff)); 105274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 105374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_arg2) { 105474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 0, arg2); 105574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, op | RA (arg1) | RB (0)); 105674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 105774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 105874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, op | RA (arg1) | RB (arg2)); 105974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 106074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 106174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 106274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 106374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_bc (TCGContext *s, int bc, int label_index) 106474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 106574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCGLabel *l = &s->labels[label_index]; 106674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 106774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (l->has_value) 106874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, bc | reloc_pc14_val (s->code_ptr, l->u.value)); 106974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 107074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint16_t val = *(uint16_t *) &s->code_ptr[2]; 107174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 107274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* Thanks to Andrzej Zaborowski */ 107374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, bc | (val & 0xfffc)); 107474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_reloc (s, s->code_ptr - 4, R_PPC_REL14, label_index, 0); 107574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 107674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 107774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 107874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_cr7eq_from_cond (TCGContext *s, const TCGArg *args, 107974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt const int *const_args) 108074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 1081f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner TCGCond cond = args[4]; 1082f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner int op; 108374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt struct { int bit1; int bit2; int cond2; } bits[] = { 108474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_LT ] = { CR_LT, CR_LT, TCG_COND_LT }, 108574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_LE ] = { CR_LT, CR_GT, TCG_COND_LT }, 108674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_GT ] = { CR_GT, CR_GT, TCG_COND_GT }, 108774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_GE ] = { CR_GT, CR_LT, TCG_COND_GT }, 108874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_LTU] = { CR_LT, CR_LT, TCG_COND_LTU }, 108974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_LEU] = { CR_LT, CR_GT, TCG_COND_LTU }, 109074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_GTU] = { CR_GT, CR_GT, TCG_COND_GTU }, 109174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt [TCG_COND_GEU] = { CR_GT, CR_LT, TCG_COND_GTU }, 109274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt }, *b = &bits[cond]; 109374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 109474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (cond) { 109574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_EQ: 109674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_NE: 109774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op = (cond == TCG_COND_EQ) ? CRAND : CRNAND; 109874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_cmp (s, cond, args[0], args[2], const_args[2], 6); 109974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_cmp (s, cond, args[1], args[3], const_args[3], 7); 110074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, op | BT (7, CR_EQ) | BA (6, CR_EQ) | BB (7, CR_EQ)); 110174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 110274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LT: 110374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LE: 110474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GT: 110574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GE: 110674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LTU: 110774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LEU: 110874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GTU: 110974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GEU: 111074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt op = (b->bit1 != b->bit2) ? CRANDC : CRAND; 111174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_cmp (s, b->cond2, args[1], args[3], const_args[3], 5); 1112f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_cmp (s, tcg_unsigned_cond (cond), args[0], args[2], 1113f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner const_args[2], 7); 1114f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, op | BT (7, CR_EQ) | BA (5, CR_EQ) | BB (7, b->bit2)); 111574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, CROR | BT (7, CR_EQ) | BA (5, b->bit1) | BB (7, CR_EQ)); 111674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 111774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 111874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort(); 111974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 112074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 112174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 1122f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turnerstatic void tcg_out_setcond (TCGContext *s, TCGCond cond, TCGArg arg0, 112374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCGArg arg1, TCGArg arg2, int const_arg2) 112474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 112574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int crop, sh, arg; 112674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 112774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (cond) { 112874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_EQ: 112974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_arg2) { 113074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (!arg2) { 113174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt arg = arg1; 113274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 113374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 113474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt arg = 0; 113574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((uint16_t) arg2 == arg2) { 113674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XORI | RS (arg1) | RA (0) | arg2); 113774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 113874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 113974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 0, arg2); 114074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XOR | SAB (arg1, 0, 0)); 114174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 114274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 114374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 114474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 114574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt arg = 0; 114674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XOR | SAB (arg1, 0, arg2)); 114774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 114874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, CNTLZW | RS (arg) | RA (0)); 114974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 115074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (arg0) 115174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (0) 115274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (27) 115374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (5) 115474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31) 115574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 115674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 115774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 115874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 115974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_NE: 116074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_arg2) { 116174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (!arg2) { 116274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt arg = arg1; 116374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 116474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 116574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt arg = 0; 116674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((uint16_t) arg2 == arg2) { 116774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XORI | RS (arg1) | RA (0) | arg2); 116874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 116974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 117074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 0, arg2); 117174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XOR | SAB (arg1, 0, 0)); 117274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 117374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 117474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 117574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 117674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt arg = 0; 117774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XOR | SAB (arg1, 0, arg2)); 117874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 117974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 118074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (arg == arg1 && arg1 == arg0) { 118174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDIC | RT (0) | RA (arg) | 0xffff); 118274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SUBFE | TAB (arg0, 0, arg)); 118374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 118474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 118574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDIC | RT (arg0) | RA (arg) | 0xffff); 118674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SUBFE | TAB (arg0, arg0, arg)); 118774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 118874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 118974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 119074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GT: 119174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GTU: 119274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt sh = 30; 119374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt crop = 0; 119474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt goto crtest; 119574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 119674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LT: 119774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LTU: 119874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt sh = 29; 119974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt crop = 0; 120074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt goto crtest; 120174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 120274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GE: 120374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_GEU: 120474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt sh = 31; 120574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt crop = CRNOR | BT (7, CR_EQ) | BA (7, CR_LT) | BB (7, CR_LT); 120674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt goto crtest; 120774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 120874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LE: 120974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case TCG_COND_LEU: 121074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt sh = 31; 121174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt crop = CRNOR | BT (7, CR_EQ) | BA (7, CR_GT) | BB (7, CR_GT); 121274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt crtest: 121374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_cmp (s, cond, arg1, arg2, const_arg2, 7); 121474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (crop) tcg_out32 (s, crop); 121574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MFCR | RT (0)); 121674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 121774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (arg0) 121874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (0) 121974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (sh) 122074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (31) 122174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31) 122274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 122374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 122474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 122574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 122674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 122774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort (); 122874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 122974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 123074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 123174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_setcond2 (TCGContext *s, const TCGArg *args, 123274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt const int *const_args) 123374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 123474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_cr7eq_from_cond (s, args + 1, const_args + 1); 123574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MFCR | RT (0)); 123674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 123774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (args[0]) 123874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (0) 123974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (31) 124074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (31) 124174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31) 124274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 124374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 124474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 124574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 1246f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turnerstatic void tcg_out_brcond (TCGContext *s, TCGCond cond, 124774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCGArg arg1, TCGArg arg2, int const_arg2, 124874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int label_index) 124974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 125074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_cmp (s, cond, arg1, arg2, const_arg2, 7); 125174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bc (s, tcg_to_bc[cond], label_index); 125274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 125374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 125474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* XXX: we implement it at the target level to avoid having to 125574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt handle cross basic blocks temporaries */ 125674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic void tcg_out_brcond2 (TCGContext *s, const TCGArg *args, 125774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt const int *const_args) 125874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 125974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_cr7eq_from_cond (s, args, const_args); 126074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_bc (s, (BC | BI (7, CR_EQ) | BO_COND_TRUE), args[5]); 126174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 126274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 126374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtvoid ppc_tb_set_jmp_target (unsigned long jmp_addr, unsigned long addr) 126474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 126574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t *ptr; 126674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt long disp = addr - jmp_addr; 126774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt unsigned long patch_size; 126874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 126974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ptr = (uint32_t *)jmp_addr; 127074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 127174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((disp << 6) >> 6 != disp) { 127274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ptr[0] = 0x3c000000 | (addr >> 16); /* lis 0,addr@ha */ 127374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ptr[1] = 0x60000000 | (addr & 0xffff); /* la 0,addr@l(0) */ 127474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ptr[2] = 0x7c0903a6; /* mtctr 0 */ 127574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ptr[3] = 0x4e800420; /* brctr */ 127674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt patch_size = 16; 127774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } else { 127874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* patch the branch destination */ 127974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (disp != 16) { 128074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt *ptr = 0x48000000 | (disp & 0x03fffffc); /* b disp */ 128174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt patch_size = 4; 128274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } else { 128374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ptr[0] = 0x60000000; /* nop */ 128474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ptr[1] = 0x60000000; 128574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ptr[2] = 0x60000000; 128674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ptr[3] = 0x60000000; 128774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt patch_size = 16; 128874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 128974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 129074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* flush icache */ 129174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt flush_icache_range(jmp_addr, jmp_addr + patch_size); 129274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 129374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 1294f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turnerstatic void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, 129574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt const int *const_args) 129674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 129774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt switch (opc) { 129874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_exit_tb: 129974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, TCG_REG_R3, args[0]); 130074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_b (s, 0, (tcg_target_long) tb_ret_addr); 130174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 130274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_goto_tb: 130374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (s->tb_jmp_offset) { 130474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* direct jump method */ 130574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 130674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; 130774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt s->code_ptr += 16; 130874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 130974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 131074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort (); 131174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 131274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf; 131374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 131474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_br: 131574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { 131674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCGLabel *l = &s->labels[args[0]]; 131774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 131874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (l->has_value) { 131974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_b (s, 0, l->u.value); 132074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 132174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 132274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t val = *(uint32_t *) s->code_ptr; 132374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 132474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* Thanks to Andrzej Zaborowski */ 132574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, B | (val & 0x3fffffc)); 132674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_reloc (s, s->code_ptr - 4, R_PPC_REL24, args[0], 0); 132774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 132874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 132974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 133074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_call: 133174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_call (s, args[0], const_args[0]); 133274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 133374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_jmp: 133474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[0]) { 133574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_b (s, 0, args[0]); 133674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 133774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 133874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MTSPR | RS (args[0]) | CTR); 133974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, BCCTR | BO_ALWAYS); 134074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 134174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 134274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_movi_i32: 134374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi(s, TCG_TYPE_I32, args[0], args[1]); 134474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 134574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld8u_i32: 134674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX); 134774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 134874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld8s_i32: 134974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX); 135074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, EXTSB | RS (args[0]) | RA (args[0])); 135174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 135274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld16u_i32: 135374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, args[0], args[1], args[2], LHZ, LHZX); 135474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 135574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld16s_i32: 135674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, args[0], args[1], args[2], LHA, LHAX); 135774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 135874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ld_i32: 135974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, args[0], args[1], args[2], LWZ, LWZX); 136074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 136174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_st8_i32: 136274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, args[0], args[1], args[2], STB, STBX); 136374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 136474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_st16_i32: 136574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, args[0], args[1], args[2], STH, STHX); 136674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 136774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_st_i32: 136874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_ldst (s, args[0], args[1], args[2], STW, STWX); 136974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 137074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 137174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_add_i32: 137274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) 137374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ppc_addi (s, args[0], args[1], args[2]); 137474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 137574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADD | TAB (args[0], args[1], args[2])); 137674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 137774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_sub_i32: 137874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) 137974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ppc_addi (s, args[0], args[1], -args[2]); 138074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 138174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SUBF | TAB (args[0], args[2], args[1])); 138274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 138374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 138474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_and_i32: 138574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) { 138674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t c; 138774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 138874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt c = args[2]; 138974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 139074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (!c) { 139174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, args[0], 0); 139274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 139374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 139474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef __PPU__ 139574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt uint32_t t, n; 139674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int mb, me; 139774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 139874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt n = c ^ -(c & 1); 139974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt t = n + (n & -n); 140074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 140174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((t & (t - 1)) == 0) { 140274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int lzc, tzc; 140374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 140474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((c & 0x80000001) == 0x80000001) { 140574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt lzc = clz32 (n); 140674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tzc = ctz32 (n); 140774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 140874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt mb = 32 - tzc; 140974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt me = lzc - 1; 141074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 141174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 141274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt lzc = clz32 (c); 141374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tzc = ctz32 (c); 141474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 141574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt mb = lzc; 141674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt me = 31 - tzc; 141774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 141874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 141974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 142074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (args[0]) 142174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (args[1]) 142274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (0) 142374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (mb) 142474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (me) 142574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 142674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 142774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 142874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 142974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif /* !__PPU__ */ 143074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { 143174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((c & 0xffff) == c) 143274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ANDI | RS (args[1]) | RA (args[0]) | c); 143374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else if ((c & 0xffff0000) == c) 143474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ANDIS | RS (args[1]) | RA (args[0]) 143574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ((c >> 16) & 0xffff)); 143674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 143774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 0, c); 143874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, AND | SAB (args[1], args[0], 0)); 143974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 144074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 144174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 144274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 144374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, AND | SAB (args[1], args[0], args[2])); 144474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 144574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_or_i32: 144674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) { 144774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (args[2] & 0xffff) { 144874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ORI | RS (args[1]) | RA (args[0]) 144974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | (args[2] & 0xffff)); 145074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (args[2] >> 16) 145174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ORIS | RS (args[0]) | RA (args[0]) 145274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ((args[2] >> 16) & 0xffff)); 145374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 145474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 145574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ORIS | RS (args[1]) | RA (args[0]) 145674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ((args[2] >> 16) & 0xffff)); 145774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 145874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 145974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 146074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, OR | SAB (args[1], args[0], args[2])); 146174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 146274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_xor_i32: 146374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) { 146474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if ((args[2] & 0xffff) == args[2]) 146574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XORI | RS (args[1]) | RA (args[0]) 146674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | (args[2] & 0xffff)); 146774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else if ((args[2] & 0xffff0000) == args[2]) 146874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XORIS | RS (args[1]) | RA (args[0]) 146974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ((args[2] >> 16) & 0xffff)); 147074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 147174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 0, args[2]); 147274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XOR | SAB (args[1], args[0], 0)); 147374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 147474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 147574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 147674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, XOR | SAB (args[1], args[0], args[2])); 147774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 147874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_andc_i32: 147974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ANDC | SAB (args[1], args[0], args[2])); 148074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 148174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_orc_i32: 148274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ORC | SAB (args[1], args[0], args[2])); 148374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 1484f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner case INDEX_op_eqv_i32: 1485f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, EQV | SAB (args[1], args[0], args[2])); 1486f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner break; 1487f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner case INDEX_op_nand_i32: 1488f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, NAND | SAB (args[1], args[0], args[2])); 1489f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner break; 1490f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner case INDEX_op_nor_i32: 1491f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, NOR | SAB (args[1], args[0], args[2])); 1492f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner break; 149374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 149474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_mul_i32: 149574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) { 149674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (args[2] == (int16_t) args[2]) 149774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MULLI | RT (args[0]) | RA (args[1]) 149874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | (args[2] & 0xffff)); 149974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 150074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_movi (s, TCG_TYPE_I32, 0, args[2]); 150174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MULLW | TAB (args[0], args[1], 0)); 150274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 150374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 150474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 150574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MULLW | TAB (args[0], args[1], args[2])); 150674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 150774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 150874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_div_i32: 150974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, DIVW | TAB (args[0], args[1], args[2])); 151074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 151174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 151274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_divu_i32: 151374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, DIVWU | TAB (args[0], args[1], args[2])); 151474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 151574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 151674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_rem_i32: 151774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, DIVW | TAB (0, args[1], args[2])); 151874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MULLW | TAB (0, 0, args[2])); 151974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); 152074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 152174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 152274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_remu_i32: 152374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, DIVWU | TAB (0, args[1], args[2])); 152474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MULLW | TAB (0, 0, args[2])); 152574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); 152674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 152774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 152874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_mulu2_i32: 152974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (args[0] == args[2] || args[0] == args[3]) { 153074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MULLW | TAB (0, args[2], args[3])); 153174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MULHWU | TAB (args[1], args[2], args[3])); 1532f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, args[0], 0); 153374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 153474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 153574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MULLW | TAB (args[0], args[2], args[3])); 153674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, MULHWU | TAB (args[1], args[2], args[3])); 153774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 153874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 153974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 154074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_shl_i32: 154174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) { 154274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 154374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (args[0]) 154474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (args[1]) 154574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (args[2]) 154674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (0) 154774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31 - args[2]) 154874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 154974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 155074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 155174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 155274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SLW | SAB (args[1], args[0], args[2])); 155374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 155474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_shr_i32: 155574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) { 155674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, (RLWINM 155774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (args[0]) 155874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (args[1]) 155974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (32 - args[2]) 156074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (args[2]) 156174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31) 156274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ) 156374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 156474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 156574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 156674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SRW | SAB (args[1], args[0], args[2])); 156774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 156874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_sar_i32: 156974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) 157074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SRAWI | RS (args[1]) | RA (args[0]) | SH (args[2])); 157174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else 157274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SRAW | SAB (args[1], args[0], args[2])); 157374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 157474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_rotl_i32: 157574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { 157674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt int op = 0 157774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (args[0]) 157874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (args[1]) 157974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (0) 158074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31) 158174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | (const_args[2] ? RLWINM | SH (args[2]) 158274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt : RLWNM | RB (args[2])) 158374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ; 158474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, op); 158574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 158674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 158774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_rotr_i32: 158874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (const_args[2]) { 158974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (!args[2]) { 1590f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, args[0], args[1]); 159174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 159274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 159374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, RLWINM 159474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (args[0]) 159574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (args[1]) 159674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (32 - args[2]) 159774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (0) 159874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31) 159974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 160074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 160174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 160274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 1603f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, SUBFIC | RT (0) | RA (args[2]) | 32); 160474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, RLWNM 160574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (args[0]) 160674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (args[1]) 160774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RB (0) 160874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (0) 160974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31) 161074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 161174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 161274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 161374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 161474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_add2_i32: 161574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (args[0] == args[3] || args[0] == args[5]) { 161674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDC | TAB (0, args[2], args[4])); 161774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDE | TAB (args[1], args[3], args[5])); 1618f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, args[0], 0); 161974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 162074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 162174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDC | TAB (args[0], args[2], args[4])); 162274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, ADDE | TAB (args[1], args[3], args[5])); 162374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 162474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 162574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_sub2_i32: 162674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt if (args[0] == args[3] || args[0] == args[5]) { 162774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SUBFC | TAB (0, args[4], args[2])); 162874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SUBFE | TAB (args[1], args[5], args[3])); 1629f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, args[0], 0); 163074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 163174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt else { 163274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SUBFC | TAB (args[0], args[4], args[2])); 163374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, SUBFE | TAB (args[1], args[5], args[3])); 163474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 163574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 163674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 163774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_brcond_i32: 163874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt /* 163974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt args[0] = r0 164074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt args[1] = r1 164174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt args[2] = cond 164274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt args[3] = r1 is const 164374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt args[4] = label_index 164474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt */ 164574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_brcond (s, args[2], args[0], args[1], const_args[1], args[3]); 164674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 164774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_brcond2_i32: 164874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_brcond2(s, args, const_args); 164974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 165074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 165174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_neg_i32: 165274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, NEG | RT (args[0]) | RA (args[1])); 165374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 165474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 165574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_not_i32: 1656f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, NOR | SAB (args[1], args[0], args[1])); 165774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 165874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 165974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld8u: 166074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 0); 166174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 166274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld8s: 166374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 0 | 4); 166474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 166574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld16u: 166674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 1); 166774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 166874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld16s: 166974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 1 | 4); 167074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 1671f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner case INDEX_op_qemu_ld32: 167274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 2); 167374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 167474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_ld64: 167574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_ld(s, args, 3); 167674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 167774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_st8: 167874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_st(s, args, 0); 167974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 168074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_st16: 168174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_st(s, args, 1); 168274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 168374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_st32: 168474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_st(s, args, 2); 168574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 168674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_qemu_st64: 168774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_qemu_st(s, args, 3); 168874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 168974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 169074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ext8s_i32: 169174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, EXTSB | RS (args[1]) | RA (args[0])); 169274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 169374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ext8u_i32: 169474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, RLWINM 169574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (args[0]) 169674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (args[1]) 169774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (0) 169874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (24) 169974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31) 170074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 170174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 170274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ext16s_i32: 170374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, EXTSH | RS (args[1]) | RA (args[0])); 170474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 170574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_ext16u_i32: 170674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out32 (s, RLWINM 170774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RA (args[0]) 170874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | RS (args[1]) 170974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | SH (0) 171074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | MB (16) 171174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt | ME (31) 171274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 171374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 171474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 171574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_setcond_i32: 171674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_setcond (s, args[3], args[0], args[1], args[2], const_args[2]); 171774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 171874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt case INDEX_op_setcond2_i32: 171974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_out_setcond2 (s, args, const_args); 172074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt break; 172174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 1722f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner case INDEX_op_bswap16_i32: 1723f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* Stolen from gcc's builtin_bswap16 */ 1724f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1725f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* a1 = abcd */ 1726f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1727f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* r0 = (a1 << 8) & 0xff00 # 00d0 */ 1728f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, RLWINM 1729f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RA (0) 1730f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RS (args[1]) 1731f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | SH (8) 1732f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | MB (16) 1733f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | ME (23) 1734f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner ); 1735f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1736f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* a0 = rotate_left (a1, 24) & 0xff # 000c */ 1737f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, RLWINM 1738f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RA (args[0]) 1739f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RS (args[1]) 1740f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | SH (24) 1741f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | MB (24) 1742f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | ME (31) 1743f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner ); 1744f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1745f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* a0 = a0 | r0 # 00dc */ 1746f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, OR | SAB (0, args[0], args[0])); 1747f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner break; 1748f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1749f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner case INDEX_op_bswap32_i32: 1750f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* Stolen from gcc's builtin_bswap32 */ 1751f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner { 1752f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner int a0 = args[0]; 1753f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1754f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* a1 = args[1] # abcd */ 1755f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1756f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner if (a0 == args[1]) { 1757f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner a0 = 0; 1758f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner } 1759f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1760f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* a0 = rotate_left (a1, 8) # bcda */ 1761f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, RLWINM 1762f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RA (a0) 1763f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RS (args[1]) 1764f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | SH (8) 1765f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | MB (0) 1766f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | ME (31) 1767f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner ); 1768f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1769f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* a0 = (a0 & ~0xff000000) | ((a1 << 24) & 0xff000000) # dcda */ 1770f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, RLWIMI 1771f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RA (a0) 1772f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RS (args[1]) 1773f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | SH (24) 1774f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | MB (0) 1775f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | ME (7) 1776f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner ); 1777f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1778f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner /* a0 = (a0 & ~0x0000ff00) | ((a1 << 24) & 0x0000ff00) # dcba */ 1779f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out32 (s, RLWIMI 1780f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RA (a0) 1781f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | RS (args[1]) 1782f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | SH (24) 1783f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | MB (16) 1784f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner | ME (23) 1785f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner ); 1786f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 1787f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner if (!a0) { 1788f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner tcg_out_mov (s, TCG_TYPE_I32, args[0], a0); 1789f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner } 1790f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner } 1791f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner break; 1792f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 179374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt default: 179474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_dump_ops (s, stderr); 179574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_abort (); 179674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt } 179774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 179874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 179974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic const TCGTargetOpDef ppc_op_defs[] = { 180074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_exit_tb, { } }, 180174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_goto_tb, { } }, 180274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_call, { "ri" } }, 180374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_jmp, { "ri" } }, 180474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_br, { } }, 180574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 180674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_mov_i32, { "r", "r" } }, 180774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_movi_i32, { "r" } }, 180874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld8u_i32, { "r", "r" } }, 180974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld8s_i32, { "r", "r" } }, 181074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld16u_i32, { "r", "r" } }, 181174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld16s_i32, { "r", "r" } }, 181274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ld_i32, { "r", "r" } }, 181374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_st8_i32, { "r", "r" } }, 181474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_st16_i32, { "r", "r" } }, 181574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_st_i32, { "r", "r" } }, 181674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 181774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_add_i32, { "r", "r", "ri" } }, 181874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_mul_i32, { "r", "r", "ri" } }, 181974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_div_i32, { "r", "r", "r" } }, 182074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_divu_i32, { "r", "r", "r" } }, 182174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_rem_i32, { "r", "r", "r" } }, 182274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_remu_i32, { "r", "r", "r" } }, 182374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_mulu2_i32, { "r", "r", "r", "r" } }, 182474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_sub_i32, { "r", "r", "ri" } }, 182574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_and_i32, { "r", "r", "ri" } }, 182674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_or_i32, { "r", "r", "ri" } }, 182774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_xor_i32, { "r", "r", "ri" } }, 182874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 182974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_shl_i32, { "r", "r", "ri" } }, 183074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_shr_i32, { "r", "r", "ri" } }, 183174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_sar_i32, { "r", "r", "ri" } }, 183274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 183374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_rotl_i32, { "r", "r", "ri" } }, 183474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_rotr_i32, { "r", "r", "ri" } }, 183574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 183674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_brcond_i32, { "r", "ri" } }, 183774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 183874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_add2_i32, { "r", "r", "r", "r", "r", "r" } }, 183974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_sub2_i32, { "r", "r", "r", "r", "r", "r" } }, 184074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_brcond2_i32, { "r", "r", "r", "r" } }, 184174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 184274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_neg_i32, { "r", "r" } }, 184374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_not_i32, { "r", "r" } }, 184474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 184574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_andc_i32, { "r", "r", "r" } }, 184674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_orc_i32, { "r", "r", "r" } }, 1847f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner { INDEX_op_eqv_i32, { "r", "r", "r" } }, 1848f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner { INDEX_op_nand_i32, { "r", "r", "r" } }, 1849f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner { INDEX_op_nor_i32, { "r", "r", "r" } }, 185074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 185174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_setcond_i32, { "r", "r", "ri" } }, 185274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_setcond2_i32, { "r", "r", "r", "ri", "ri" } }, 185374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 1854f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner { INDEX_op_bswap16_i32, { "r", "r" } }, 1855f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner { INDEX_op_bswap32_i32, { "r", "r" } }, 1856f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 185774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TARGET_LONG_BITS == 32 185874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld8u, { "r", "L" } }, 185974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld8s, { "r", "L" } }, 186074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld16u, { "r", "L" } }, 186174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld16s, { "r", "L" } }, 1862f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner { INDEX_op_qemu_ld32, { "r", "L" } }, 186374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld64, { "r", "r", "L" } }, 186474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 186574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st8, { "K", "K" } }, 186674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st16, { "K", "K" } }, 186774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st32, { "K", "K" } }, 186874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st64, { "M", "M", "M" } }, 186974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 187074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld8u, { "r", "L", "L" } }, 187174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld8s, { "r", "L", "L" } }, 187274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld16u, { "r", "L", "L" } }, 187374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld16s, { "r", "L", "L" } }, 1874f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner { INDEX_op_qemu_ld32, { "r", "L", "L" } }, 187574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_ld64, { "r", "L", "L", "L" } }, 187674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 187774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st8, { "K", "K", "K" } }, 187874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st16, { "K", "K", "K" } }, 187974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st32, { "K", "K", "K" } }, 188074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_qemu_st64, { "M", "M", "M", "M" } }, 188174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 188274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 188374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ext8s_i32, { "r", "r" } }, 188474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ext8u_i32, { "r", "r" } }, 188574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ext16s_i32, { "r", "r" } }, 188674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { INDEX_op_ext16u_i32, { "r", "r" } }, 188774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 188874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt { -1 }, 188974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 189074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 1891f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turnerstatic void tcg_target_init(TCGContext *s) 189274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 189374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff); 189474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set32(tcg_target_call_clobber_regs, 0, 189574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R0) | 189674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef _CALL_DARWIN 189774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R2) | 189874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 189974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R3) | 190074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R4) | 190174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R5) | 190274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R6) | 190374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R7) | 190474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R8) | 190574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R9) | 190674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R10) | 190774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R11) | 190874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt (1 << TCG_REG_R12) 190974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt ); 191074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 191174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_clear(s->reserved_regs); 191274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0); 191374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R1); 191474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifndef _CALL_DARWIN 191574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R2); 191674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 191774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef _CALL_SYSV 191874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_regset_set_reg(s->reserved_regs, TCG_REG_R13); 191974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 192074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 192174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt tcg_add_target_add_op_defs(ppc_op_defs); 192274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 1923