xref: /openbmc/qemu/tcg/ppc/tcg-target.h (revision 4ae7d11b70a840eec7aa27269093b15d04ebc84e)
140d964b5SRichard Henderson /*
240d964b5SRichard Henderson  * Tiny Code Generator for QEMU
340d964b5SRichard Henderson  *
440d964b5SRichard Henderson  * Copyright (c) 2008 Fabrice Bellard
540d964b5SRichard Henderson  *
640d964b5SRichard Henderson  * Permission is hereby granted, free of charge, to any person obtaining a copy
740d964b5SRichard Henderson  * of this software and associated documentation files (the "Software"), to deal
840d964b5SRichard Henderson  * in the Software without restriction, including without limitation the rights
940d964b5SRichard Henderson  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1040d964b5SRichard Henderson  * copies of the Software, and to permit persons to whom the Software is
1140d964b5SRichard Henderson  * furnished to do so, subject to the following conditions:
1240d964b5SRichard Henderson  *
1340d964b5SRichard Henderson  * The above copyright notice and this permission notice shall be included in
1440d964b5SRichard Henderson  * all copies or substantial portions of the Software.
1540d964b5SRichard Henderson  *
1640d964b5SRichard Henderson  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1740d964b5SRichard Henderson  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1840d964b5SRichard Henderson  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1940d964b5SRichard Henderson  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2040d964b5SRichard Henderson  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2140d964b5SRichard Henderson  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2240d964b5SRichard Henderson  * THE SOFTWARE.
2340d964b5SRichard Henderson  */
2414e54f8eSMarkus Armbruster 
2514e54f8eSMarkus Armbruster #ifndef PPC_TCG_TARGET_H
2614e54f8eSMarkus Armbruster #define PPC_TCG_TARGET_H
2740d964b5SRichard Henderson 
28623d7e35SRichard Henderson #include "host/cpuinfo.h"
29623d7e35SRichard Henderson 
3020b66433SRichard Henderson #define MAX_CODE_GEN_BUFFER_SIZE  ((size_t)-1)
3140d964b5SRichard Henderson 
3242281ec6SRichard Henderson #define TCG_TARGET_NB_REGS 64
3340d964b5SRichard Henderson #define TCG_TARGET_INSN_UNIT_SIZE 4
3440d964b5SRichard Henderson 
3540d964b5SRichard Henderson typedef enum {
3640d964b5SRichard Henderson     TCG_REG_R0,  TCG_REG_R1,  TCG_REG_R2,  TCG_REG_R3,
3740d964b5SRichard Henderson     TCG_REG_R4,  TCG_REG_R5,  TCG_REG_R6,  TCG_REG_R7,
3840d964b5SRichard Henderson     TCG_REG_R8,  TCG_REG_R9,  TCG_REG_R10, TCG_REG_R11,
3940d964b5SRichard Henderson     TCG_REG_R12, TCG_REG_R13, TCG_REG_R14, TCG_REG_R15,
4040d964b5SRichard Henderson     TCG_REG_R16, TCG_REG_R17, TCG_REG_R18, TCG_REG_R19,
4140d964b5SRichard Henderson     TCG_REG_R20, TCG_REG_R21, TCG_REG_R22, TCG_REG_R23,
4240d964b5SRichard Henderson     TCG_REG_R24, TCG_REG_R25, TCG_REG_R26, TCG_REG_R27,
4340d964b5SRichard Henderson     TCG_REG_R28, TCG_REG_R29, TCG_REG_R30, TCG_REG_R31,
4440d964b5SRichard Henderson 
4542281ec6SRichard Henderson     TCG_REG_V0,  TCG_REG_V1,  TCG_REG_V2,  TCG_REG_V3,
4642281ec6SRichard Henderson     TCG_REG_V4,  TCG_REG_V5,  TCG_REG_V6,  TCG_REG_V7,
4742281ec6SRichard Henderson     TCG_REG_V8,  TCG_REG_V9,  TCG_REG_V10, TCG_REG_V11,
4842281ec6SRichard Henderson     TCG_REG_V12, TCG_REG_V13, TCG_REG_V14, TCG_REG_V15,
4942281ec6SRichard Henderson     TCG_REG_V16, TCG_REG_V17, TCG_REG_V18, TCG_REG_V19,
5042281ec6SRichard Henderson     TCG_REG_V20, TCG_REG_V21, TCG_REG_V22, TCG_REG_V23,
5142281ec6SRichard Henderson     TCG_REG_V24, TCG_REG_V25, TCG_REG_V26, TCG_REG_V27,
5242281ec6SRichard Henderson     TCG_REG_V28, TCG_REG_V29, TCG_REG_V30, TCG_REG_V31,
5342281ec6SRichard Henderson 
5440d964b5SRichard Henderson     TCG_REG_CALL_STACK = TCG_REG_R1,
5540d964b5SRichard Henderson     TCG_AREG0 = TCG_REG_R27
5640d964b5SRichard Henderson } TCGReg;
5740d964b5SRichard Henderson 
587d9dae0aSRichard Henderson typedef enum {
597d9dae0aSRichard Henderson     tcg_isa_base,
607d9dae0aSRichard Henderson     tcg_isa_2_06,
6164ff1c6dSRichard Henderson     tcg_isa_2_07,
627d9dae0aSRichard Henderson     tcg_isa_3_00,
6373ebe95eSLijun Pan     tcg_isa_3_10,
647d9dae0aSRichard Henderson } TCGPowerISA;
657d9dae0aSRichard Henderson 
66623d7e35SRichard Henderson #define have_isa_2_06  (cpuinfo & CPUINFO_V2_06)
67623d7e35SRichard Henderson #define have_isa_2_07  (cpuinfo & CPUINFO_V2_07)
68623d7e35SRichard Henderson #define have_isa_3_00  (cpuinfo & CPUINFO_V3_0)
69623d7e35SRichard Henderson #define have_isa_3_10  (cpuinfo & CPUINFO_V3_1)
70623d7e35SRichard Henderson #define have_altivec   (cpuinfo & CPUINFO_ALTIVEC)
71623d7e35SRichard Henderson #define have_vsx       (cpuinfo & CPUINFO_VSX)
72d0b07481SRichard Henderson 
7340d964b5SRichard Henderson /* optional instructions automatically implemented */
7440d964b5SRichard Henderson #define TCG_TARGET_HAS_ext8u_i32        0 /* andi */
7540d964b5SRichard Henderson #define TCG_TARGET_HAS_ext16u_i32       0
7640d964b5SRichard Henderson 
7740d964b5SRichard Henderson /* optional instructions */
7840d964b5SRichard Henderson #define TCG_TARGET_HAS_div_i32          1
794d573822SMatheus Kowalczuk Ferst #define TCG_TARGET_HAS_rem_i32          have_isa_3_00
8040d964b5SRichard Henderson #define TCG_TARGET_HAS_rot_i32          1
8140d964b5SRichard Henderson #define TCG_TARGET_HAS_ext8s_i32        1
8240d964b5SRichard Henderson #define TCG_TARGET_HAS_ext16s_i32       1
8340d964b5SRichard Henderson #define TCG_TARGET_HAS_bswap16_i32      1
8440d964b5SRichard Henderson #define TCG_TARGET_HAS_bswap32_i32      1
8540d964b5SRichard Henderson #define TCG_TARGET_HAS_not_i32          1
8640d964b5SRichard Henderson #define TCG_TARGET_HAS_andc_i32         1
8740d964b5SRichard Henderson #define TCG_TARGET_HAS_orc_i32          1
8840d964b5SRichard Henderson #define TCG_TARGET_HAS_eqv_i32          1
8940d964b5SRichard Henderson #define TCG_TARGET_HAS_nand_i32         1
9040d964b5SRichard Henderson #define TCG_TARGET_HAS_nor_i32          1
91d0b07481SRichard Henderson #define TCG_TARGET_HAS_clz_i32          1
92d0b07481SRichard Henderson #define TCG_TARGET_HAS_ctz_i32          have_isa_3_00
9333e75fb9SRichard Henderson #define TCG_TARGET_HAS_ctpop_i32        have_isa_2_06
9440d964b5SRichard Henderson #define TCG_TARGET_HAS_deposit_i32      1
95c05021c3SRichard Henderson #define TCG_TARGET_HAS_extract_i32      1
967ec8bab3SRichard Henderson #define TCG_TARGET_HAS_sextract_i32     0
97fce1296fSRichard Henderson #define TCG_TARGET_HAS_extract2_i32     0
98cba10bb3SRichard Henderson #define TCG_TARGET_HAS_negsetcond_i32   1
9940d964b5SRichard Henderson #define TCG_TARGET_HAS_mulu2_i32        0
10040d964b5SRichard Henderson #define TCG_TARGET_HAS_muls2_i32        0
10140d964b5SRichard Henderson #define TCG_TARGET_HAS_muluh_i32        1
10240d964b5SRichard Henderson #define TCG_TARGET_HAS_mulsh_i32        1
10307ce0b05SRichard Henderson #define TCG_TARGET_HAS_qemu_st8_i32     0
10440d964b5SRichard Henderson 
10540d964b5SRichard Henderson #if TCG_TARGET_REG_BITS == 64
10640d964b5SRichard Henderson #define TCG_TARGET_HAS_add2_i32         0
10740d964b5SRichard Henderson #define TCG_TARGET_HAS_sub2_i32         0
10813d885b0SRichard Henderson #define TCG_TARGET_HAS_extr_i64_i32     0
10940d964b5SRichard Henderson #define TCG_TARGET_HAS_div_i64          1
1104d573822SMatheus Kowalczuk Ferst #define TCG_TARGET_HAS_rem_i64          have_isa_3_00
11140d964b5SRichard Henderson #define TCG_TARGET_HAS_rot_i64          1
11240d964b5SRichard Henderson #define TCG_TARGET_HAS_ext8s_i64        1
11340d964b5SRichard Henderson #define TCG_TARGET_HAS_ext16s_i64       1
11440d964b5SRichard Henderson #define TCG_TARGET_HAS_ext32s_i64       1
11540d964b5SRichard Henderson #define TCG_TARGET_HAS_ext8u_i64        0
11640d964b5SRichard Henderson #define TCG_TARGET_HAS_ext16u_i64       0
11740d964b5SRichard Henderson #define TCG_TARGET_HAS_ext32u_i64       0
11840d964b5SRichard Henderson #define TCG_TARGET_HAS_bswap16_i64      1
11940d964b5SRichard Henderson #define TCG_TARGET_HAS_bswap32_i64      1
12040d964b5SRichard Henderson #define TCG_TARGET_HAS_bswap64_i64      1
12140d964b5SRichard Henderson #define TCG_TARGET_HAS_not_i64          1
12240d964b5SRichard Henderson #define TCG_TARGET_HAS_andc_i64         1
12340d964b5SRichard Henderson #define TCG_TARGET_HAS_orc_i64          1
12440d964b5SRichard Henderson #define TCG_TARGET_HAS_eqv_i64          1
12540d964b5SRichard Henderson #define TCG_TARGET_HAS_nand_i64         1
12640d964b5SRichard Henderson #define TCG_TARGET_HAS_nor_i64          1
127d0b07481SRichard Henderson #define TCG_TARGET_HAS_clz_i64          1
128d0b07481SRichard Henderson #define TCG_TARGET_HAS_ctz_i64          have_isa_3_00
12933e75fb9SRichard Henderson #define TCG_TARGET_HAS_ctpop_i64        have_isa_2_06
13040d964b5SRichard Henderson #define TCG_TARGET_HAS_deposit_i64      1
131c05021c3SRichard Henderson #define TCG_TARGET_HAS_extract_i64      1
1327ec8bab3SRichard Henderson #define TCG_TARGET_HAS_sextract_i64     0
133fce1296fSRichard Henderson #define TCG_TARGET_HAS_extract2_i64     0
134cba10bb3SRichard Henderson #define TCG_TARGET_HAS_negsetcond_i64   1
13540d964b5SRichard Henderson #define TCG_TARGET_HAS_add2_i64         1
13640d964b5SRichard Henderson #define TCG_TARGET_HAS_sub2_i64         1
13740d964b5SRichard Henderson #define TCG_TARGET_HAS_mulu2_i64        0
13840d964b5SRichard Henderson #define TCG_TARGET_HAS_muls2_i64        0
13940d964b5SRichard Henderson #define TCG_TARGET_HAS_muluh_i64        1
14040d964b5SRichard Henderson #define TCG_TARGET_HAS_mulsh_i64        1
14140d964b5SRichard Henderson #endif
14240d964b5SRichard Henderson 
143526cd4ecSRichard Henderson #define TCG_TARGET_HAS_qemu_ldst_i128   \
144526cd4ecSRichard Henderson     (TCG_TARGET_REG_BITS == 64 && have_isa_2_07)
14512fde9bcSRichard Henderson 
146ad788aebSRichard Henderson #define TCG_TARGET_HAS_tst              1
147caf3eaccSRichard Henderson 
1484b06c216SRichard Henderson /*
1494b06c216SRichard Henderson  * While technically Altivec could support V64, it has no 64-bit store
1504b06c216SRichard Henderson  * instruction and substituting two 32-bit stores makes the generated
1514b06c216SRichard Henderson  * code quite large.
1524b06c216SRichard Henderson  */
15347c906aeSRichard Henderson #define TCG_TARGET_HAS_v64              have_vsx
1544b06c216SRichard Henderson #define TCG_TARGET_HAS_v128             have_altivec
1554b06c216SRichard Henderson #define TCG_TARGET_HAS_v256             0
1564b06c216SRichard Henderson 
1576ef14d7eSRichard Henderson #define TCG_TARGET_HAS_andc_vec         1
15864ff1c6dSRichard Henderson #define TCG_TARGET_HAS_orc_vec          have_isa_2_07
159fa8e90d6SRichard Henderson #define TCG_TARGET_HAS_nand_vec         have_isa_2_07
160fa8e90d6SRichard Henderson #define TCG_TARGET_HAS_nor_vec          1
161fa8e90d6SRichard Henderson #define TCG_TARGET_HAS_eqv_vec          have_isa_2_07
1626ef14d7eSRichard Henderson #define TCG_TARGET_HAS_not_vec          1
163d7cd6a2fSRichard Henderson #define TCG_TARGET_HAS_neg_vec          have_isa_3_00
1644b06c216SRichard Henderson #define TCG_TARGET_HAS_abs_vec          0
165b0f7e744SRichard Henderson #define TCG_TARGET_HAS_roti_vec         0
16623850a74SRichard Henderson #define TCG_TARGET_HAS_rots_vec         0
167ab87a66fSRichard Henderson #define TCG_TARGET_HAS_rotv_vec         1
1684b06c216SRichard Henderson #define TCG_TARGET_HAS_shi_vec          0
1694b06c216SRichard Henderson #define TCG_TARGET_HAS_shs_vec          0
170dabae097SRichard Henderson #define TCG_TARGET_HAS_shv_vec          1
171d9897efaSRichard Henderson #define TCG_TARGET_HAS_mul_vec          1
172e9d1a53aSRichard Henderson #define TCG_TARGET_HAS_sat_vec          1
173e2382972SRichard Henderson #define TCG_TARGET_HAS_minmax_vec       1
17447c906aeSRichard Henderson #define TCG_TARGET_HAS_bitsel_vec       have_vsx
175*d0dabf9eSRichard Henderson #define TCG_TARGET_HAS_cmpsel_vec       1
176af8c14a2SRichard Henderson #define TCG_TARGET_HAS_tst_vec          0
1774b06c216SRichard Henderson 
17871650df7SPranith Kumar #define TCG_TARGET_DEFAULT_MO (0)
179659ef5cbSRichard Henderson #define TCG_TARGET_NEED_LDST_LABELS
18053c89efdSRichard Henderson #define TCG_TARGET_NEED_POOL_LABELS
181659ef5cbSRichard Henderson 
18240d964b5SRichard Henderson #endif
183