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#define TCG_TARGET_SPARC 1 2574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 2674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if defined(__sparc_v9__) && !defined(__sparc_v8plus__) 2774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_REG_BITS 64 2874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 2974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_REG_BITS 32 3074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 3174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 3274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_WORDS_BIGENDIAN 3374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 3474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_NB_REGS 32 3574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 3674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtenum { 3774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_G0 = 0, 3874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_G1, 3974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_G2, 4074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_G3, 4174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_G4, 4274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_G5, 4374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_G6, 4474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_G7, 4574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_O0, 4674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_O1, 4774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_O2, 4874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_O3, 4974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_O4, 5074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_O5, 5174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_O6, 5274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_O7, 5374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_L0, 5474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_L1, 5574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_L2, 5674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_L3, 5774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_L4, 5874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_L5, 5974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_L6, 6074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_L7, 6174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_I0, 6274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_I1, 6374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_I2, 6474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_I3, 6574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_I4, 6674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_I5, 6774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_I6, 6874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_REG_I7, 6974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt}; 7074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 7174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_CT_CONST_S11 0x100 7274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_CT_CONST_S13 0x200 7374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 7474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* used for function call generation */ 7574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_REG_CALL_STACK TCG_REG_I6 7674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef __arch64__ 7774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// Reserve space for AREG0 7874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_STACK_MINFRAME (176 + 4 * (int)sizeof(long) + \ 7974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_STATIC_CALL_ARGS_SIZE) 8074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_CALL_STACK_OFFSET (2047 - 16) 8174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_STACK_ALIGN 16 8274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 8374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// AREG0 + one word for alignment 8474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_STACK_MINFRAME (92 + (2 + 1) * (int)sizeof(long) + \ 8574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt TCG_STATIC_CALL_ARGS_SIZE) 8674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_CALL_STACK_OFFSET TCG_TARGET_STACK_MINFRAME 8774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_STACK_ALIGN 8 8874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 8974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 90f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner#ifdef __arch64__ 91f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner#define TCG_TARGET_EXTEND_ARGS 1 92f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner#endif 93f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner 9474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt/* optional instructions */ 9574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_div_i32 9674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_rot_i32 9774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_ext8s_i32 9874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_ext16s_i32 9974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_ext8u_i32 10074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_ext16u_i32 10174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_bswap16_i32 10274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_bswap32_i32 10374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_neg_i32 10474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_not_i32 10574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_andc_i32 10674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_orc_i32 107f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner// #define TCG_TARGET_HAS_eqv_i32 108f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner// #define TCG_TARGET_HAS_nand_i32 109f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner// #define TCG_TARGET_HAS_nor_i32 11074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 11174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#if TCG_TARGET_REG_BITS == 64 11274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_div_i64 11374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_rot_i64 11474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_ext8s_i64 11574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_ext16s_i64 11674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_ext32s_i64 11774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_ext8u_i64 11874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_ext16u_i64 11974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_ext32u_i64 12074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_bswap16_i64 12174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_bswap32_i64 12274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt// #define TCG_TARGET_HAS_bswap64_i64 12374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_neg_i64 12474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_not_i64 12574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_andc_i64 12674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_TARGET_HAS_orc_i64 127f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner// #define TCG_TARGET_HAS_eqv_i64 128f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner// #define TCG_TARGET_HAS_nand_i64 129f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner// #define TCG_TARGET_HAS_nor_i64 13074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 13174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 132f1d9bf153726533acf659efd796aa484dfd0b412David 'Digit' Turner/* Note: must be synced with dyngen-exec.h */ 13374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#ifdef CONFIG_SOLARIS 13474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_AREG0 TCG_REG_G2 13574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#elif defined(__sparc_v9__) 13674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_AREG0 TCG_REG_G5 13774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#else 13874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#define TCG_AREG0 TCG_REG_G6 13974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt#endif 14074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 14174bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedtstatic inline void flush_icache_range(unsigned long start, unsigned long stop) 14274bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt{ 14374bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt unsigned long p; 14474bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 14574bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt p = start & ~(8UL - 1UL); 14674bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt stop = (stop + (8UL - 1UL)) & ~(8UL - 1UL); 14774bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt 14874bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt for (; p < stop; p += 8) 14974bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt __asm__ __volatile__("flush\t%0" : : "r" (p)); 15074bdaadb718584b216e29c13b9e1226c9f77205eMarcus Comstedt} 151