xref: /openbmc/qemu/tcg/s390x/tcg-target.h (revision 4ae7d11b70a840eec7aa27269093b15d04ebc84e)
13704993fSRichard Henderson /*
23704993fSRichard Henderson  * Tiny Code Generator for QEMU
33704993fSRichard Henderson  *
43704993fSRichard Henderson  * Copyright (c) 2009 Ulrich Hecht <uli@suse.de>
53704993fSRichard Henderson  *
63704993fSRichard Henderson  * Permission is hereby granted, free of charge, to any person obtaining a copy
73704993fSRichard Henderson  * of this software and associated documentation files (the "Software"), to deal
83704993fSRichard Henderson  * in the Software without restriction, including without limitation the rights
93704993fSRichard Henderson  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
103704993fSRichard Henderson  * copies of the Software, and to permit persons to whom the Software is
113704993fSRichard Henderson  * furnished to do so, subject to the following conditions:
123704993fSRichard Henderson  *
133704993fSRichard Henderson  * The above copyright notice and this permission notice shall be included in
143704993fSRichard Henderson  * all copies or substantial portions of the Software.
153704993fSRichard Henderson  *
163704993fSRichard Henderson  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
173704993fSRichard Henderson  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
183704993fSRichard Henderson  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
193704993fSRichard Henderson  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
203704993fSRichard Henderson  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
213704993fSRichard Henderson  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
223704993fSRichard Henderson  * THE SOFTWARE.
233704993fSRichard Henderson  */
243704993fSRichard Henderson 
253704993fSRichard Henderson #ifndef S390_TCG_TARGET_H
263704993fSRichard Henderson #define S390_TCG_TARGET_H
273704993fSRichard Henderson 
283704993fSRichard Henderson #define TCG_TARGET_INSN_UNIT_SIZE 2
293704993fSRichard Henderson 
303704993fSRichard Henderson /* We have a +- 4GB range on the branches; leave some slop.  */
313704993fSRichard Henderson #define MAX_CODE_GEN_BUFFER_SIZE  (3 * GiB)
323704993fSRichard Henderson 
333704993fSRichard Henderson typedef enum TCGReg {
34eee6251bSRichard Henderson     TCG_REG_R0,  TCG_REG_R1,  TCG_REG_R2,  TCG_REG_R3,
35eee6251bSRichard Henderson     TCG_REG_R4,  TCG_REG_R5,  TCG_REG_R6,  TCG_REG_R7,
36eee6251bSRichard Henderson     TCG_REG_R8,  TCG_REG_R9,  TCG_REG_R10, TCG_REG_R11,
37eee6251bSRichard Henderson     TCG_REG_R12, TCG_REG_R13, TCG_REG_R14, TCG_REG_R15,
38eee6251bSRichard Henderson 
3934ef7676SRichard Henderson     TCG_REG_V0 = 32, TCG_REG_V1,  TCG_REG_V2,  TCG_REG_V3,
4034ef7676SRichard Henderson     TCG_REG_V4,  TCG_REG_V5,  TCG_REG_V6,  TCG_REG_V7,
4134ef7676SRichard Henderson     TCG_REG_V8,  TCG_REG_V9,  TCG_REG_V10, TCG_REG_V11,
4234ef7676SRichard Henderson     TCG_REG_V12, TCG_REG_V13, TCG_REG_V14, TCG_REG_V15,
4334ef7676SRichard Henderson     TCG_REG_V16, TCG_REG_V17, TCG_REG_V18, TCG_REG_V19,
4434ef7676SRichard Henderson     TCG_REG_V20, TCG_REG_V21, TCG_REG_V22, TCG_REG_V23,
4534ef7676SRichard Henderson     TCG_REG_V24, TCG_REG_V25, TCG_REG_V26, TCG_REG_V27,
4634ef7676SRichard Henderson     TCG_REG_V28, TCG_REG_V29, TCG_REG_V30, TCG_REG_V31,
4734ef7676SRichard Henderson 
48eee6251bSRichard Henderson     TCG_AREG0 = TCG_REG_R10,
49eee6251bSRichard Henderson     TCG_REG_CALL_STACK = TCG_REG_R15
503704993fSRichard Henderson } TCGReg;
513704993fSRichard Henderson 
5234ef7676SRichard Henderson #define TCG_TARGET_NB_REGS 64
533704993fSRichard Henderson 
54761ea522SRichard Henderson /* Facilities required for proper operation; checked at startup. */
553704993fSRichard Henderson 
56748b7f3eSRichard Henderson #define FACILITY_ZARCH_ACTIVE         2
57748b7f3eSRichard Henderson #define FACILITY_LONG_DISP            18
583e25f7daSRichard Henderson #define FACILITY_EXT_IMM              21
599c3bfb79SRichard Henderson #define FACILITY_GEN_INST_EXT         34
60c68d5b7aSRichard Henderson #define FACILITY_45                   45
61761ea522SRichard Henderson 
62761ea522SRichard Henderson /* Facilities that are checked at runtime. */
63761ea522SRichard Henderson 
64748b7f3eSRichard Henderson #define FACILITY_LOAD_ON_COND2        53
6592c89a07SRichard Henderson #define FACILITY_MISC_INSN_EXT2       58
666c9b5c0fSRichard Henderson #define FACILITY_MISC_INSN_EXT3       61
6734ef7676SRichard Henderson #define FACILITY_VECTOR               129
68ae77bbe5SRichard Henderson #define FACILITY_VECTOR_ENH1          135
693704993fSRichard Henderson 
7034ef7676SRichard Henderson extern uint64_t s390_facilities[3];
71748b7f3eSRichard Henderson 
72748b7f3eSRichard Henderson #define HAVE_FACILITY(X) \
73748b7f3eSRichard Henderson     ((s390_facilities[FACILITY_##X / 64] >> (63 - FACILITY_##X % 64)) & 1)
743704993fSRichard Henderson 
753704993fSRichard Henderson /* optional instructions */
763704993fSRichard Henderson #define TCG_TARGET_HAS_div2_i32       1
773704993fSRichard Henderson #define TCG_TARGET_HAS_rot_i32        1
783704993fSRichard Henderson #define TCG_TARGET_HAS_ext8s_i32      1
793704993fSRichard Henderson #define TCG_TARGET_HAS_ext16s_i32     1
803704993fSRichard Henderson #define TCG_TARGET_HAS_ext8u_i32      1
813704993fSRichard Henderson #define TCG_TARGET_HAS_ext16u_i32     1
823704993fSRichard Henderson #define TCG_TARGET_HAS_bswap16_i32    1
833704993fSRichard Henderson #define TCG_TARGET_HAS_bswap32_i32    1
846c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_not_i32        HAVE_FACILITY(MISC_INSN_EXT3)
856c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_andc_i32       HAVE_FACILITY(MISC_INSN_EXT3)
866c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_orc_i32        HAVE_FACILITY(MISC_INSN_EXT3)
876c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_eqv_i32        HAVE_FACILITY(MISC_INSN_EXT3)
886c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_nand_i32       HAVE_FACILITY(MISC_INSN_EXT3)
896c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_nor_i32        HAVE_FACILITY(MISC_INSN_EXT3)
903704993fSRichard Henderson #define TCG_TARGET_HAS_clz_i32        0
913704993fSRichard Henderson #define TCG_TARGET_HAS_ctz_i32        0
9229a5ea73SRichard Henderson #define TCG_TARGET_HAS_ctpop_i32      1
939c3bfb79SRichard Henderson #define TCG_TARGET_HAS_deposit_i32    1
949c3bfb79SRichard Henderson #define TCG_TARGET_HAS_extract_i32    1
953704993fSRichard Henderson #define TCG_TARGET_HAS_sextract_i32   0
963704993fSRichard Henderson #define TCG_TARGET_HAS_extract2_i32   0
97128c7d51SRichard Henderson #define TCG_TARGET_HAS_negsetcond_i32 1
983704993fSRichard Henderson #define TCG_TARGET_HAS_add2_i32       1
993704993fSRichard Henderson #define TCG_TARGET_HAS_sub2_i32       1
1003704993fSRichard Henderson #define TCG_TARGET_HAS_mulu2_i32      0
1013704993fSRichard Henderson #define TCG_TARGET_HAS_muls2_i32      0
1023704993fSRichard Henderson #define TCG_TARGET_HAS_muluh_i32      0
1033704993fSRichard Henderson #define TCG_TARGET_HAS_mulsh_i32      0
10413d885b0SRichard Henderson #define TCG_TARGET_HAS_extr_i64_i32   0
1053704993fSRichard Henderson #define TCG_TARGET_HAS_qemu_st8_i32   0
1063704993fSRichard Henderson 
1073704993fSRichard Henderson #define TCG_TARGET_HAS_div2_i64       1
1083704993fSRichard Henderson #define TCG_TARGET_HAS_rot_i64        1
1093704993fSRichard Henderson #define TCG_TARGET_HAS_ext8s_i64      1
1103704993fSRichard Henderson #define TCG_TARGET_HAS_ext16s_i64     1
1113704993fSRichard Henderson #define TCG_TARGET_HAS_ext32s_i64     1
1123704993fSRichard Henderson #define TCG_TARGET_HAS_ext8u_i64      1
1133704993fSRichard Henderson #define TCG_TARGET_HAS_ext16u_i64     1
1143704993fSRichard Henderson #define TCG_TARGET_HAS_ext32u_i64     1
1153704993fSRichard Henderson #define TCG_TARGET_HAS_bswap16_i64    1
1163704993fSRichard Henderson #define TCG_TARGET_HAS_bswap32_i64    1
1173704993fSRichard Henderson #define TCG_TARGET_HAS_bswap64_i64    1
1186c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_not_i64        HAVE_FACILITY(MISC_INSN_EXT3)
1196c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_andc_i64       HAVE_FACILITY(MISC_INSN_EXT3)
1206c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_orc_i64        HAVE_FACILITY(MISC_INSN_EXT3)
1216c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_eqv_i64        HAVE_FACILITY(MISC_INSN_EXT3)
1226c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_nand_i64       HAVE_FACILITY(MISC_INSN_EXT3)
1236c9b5c0fSRichard Henderson #define TCG_TARGET_HAS_nor_i64        HAVE_FACILITY(MISC_INSN_EXT3)
1243e25f7daSRichard Henderson #define TCG_TARGET_HAS_clz_i64        1
1253704993fSRichard Henderson #define TCG_TARGET_HAS_ctz_i64        0
12629a5ea73SRichard Henderson #define TCG_TARGET_HAS_ctpop_i64      1
1279c3bfb79SRichard Henderson #define TCG_TARGET_HAS_deposit_i64    1
1289c3bfb79SRichard Henderson #define TCG_TARGET_HAS_extract_i64    1
1293704993fSRichard Henderson #define TCG_TARGET_HAS_sextract_i64   0
1303704993fSRichard Henderson #define TCG_TARGET_HAS_extract2_i64   0
131128c7d51SRichard Henderson #define TCG_TARGET_HAS_negsetcond_i64 1
1323704993fSRichard Henderson #define TCG_TARGET_HAS_add2_i64       1
1333704993fSRichard Henderson #define TCG_TARGET_HAS_sub2_i64       1
1343704993fSRichard Henderson #define TCG_TARGET_HAS_mulu2_i64      1
135668ce343SRichard Henderson #define TCG_TARGET_HAS_muls2_i64      HAVE_FACILITY(MISC_INSN_EXT2)
1363704993fSRichard Henderson #define TCG_TARGET_HAS_muluh_i64      0
1373704993fSRichard Henderson #define TCG_TARGET_HAS_mulsh_i64      0
1383704993fSRichard Henderson 
1394caad79fSRichard Henderson #define TCG_TARGET_HAS_qemu_ldst_i128 1
14012fde9bcSRichard Henderson 
141585b7a42SRichard Henderson #define TCG_TARGET_HAS_tst            1
142caf3eaccSRichard Henderson 
14334ef7676SRichard Henderson #define TCG_TARGET_HAS_v64            HAVE_FACILITY(VECTOR)
14434ef7676SRichard Henderson #define TCG_TARGET_HAS_v128           HAVE_FACILITY(VECTOR)
14534ef7676SRichard Henderson #define TCG_TARGET_HAS_v256           0
14634ef7676SRichard Henderson 
147ae77bbe5SRichard Henderson #define TCG_TARGET_HAS_andc_vec       1
148ae77bbe5SRichard Henderson #define TCG_TARGET_HAS_orc_vec        HAVE_FACILITY(VECTOR_ENH1)
14921eab5bfSRichard Henderson #define TCG_TARGET_HAS_nand_vec       HAVE_FACILITY(VECTOR_ENH1)
15021eab5bfSRichard Henderson #define TCG_TARGET_HAS_nor_vec        1
15121eab5bfSRichard Henderson #define TCG_TARGET_HAS_eqv_vec        HAVE_FACILITY(VECTOR_ENH1)
152ae77bbe5SRichard Henderson #define TCG_TARGET_HAS_not_vec        1
153ae77bbe5SRichard Henderson #define TCG_TARGET_HAS_neg_vec        1
154ae77bbe5SRichard Henderson #define TCG_TARGET_HAS_abs_vec        1
15522cb37b4SRichard Henderson #define TCG_TARGET_HAS_roti_vec       1
15622cb37b4SRichard Henderson #define TCG_TARGET_HAS_rots_vec       1
15722cb37b4SRichard Henderson #define TCG_TARGET_HAS_rotv_vec       1
15822cb37b4SRichard Henderson #define TCG_TARGET_HAS_shi_vec        1
15922cb37b4SRichard Henderson #define TCG_TARGET_HAS_shs_vec        1
16022cb37b4SRichard Henderson #define TCG_TARGET_HAS_shv_vec        1
161479b61cbSRichard Henderson #define TCG_TARGET_HAS_mul_vec        1
16234ef7676SRichard Henderson #define TCG_TARGET_HAS_sat_vec        0
163220db7a6SRichard Henderson #define TCG_TARGET_HAS_minmax_vec     1
1649bca986dSRichard Henderson #define TCG_TARGET_HAS_bitsel_vec     1
165*1c7d05ffSRichard Henderson #define TCG_TARGET_HAS_cmpsel_vec     1
166af8c14a2SRichard Henderson #define TCG_TARGET_HAS_tst_vec        0
16734ef7676SRichard Henderson 
1683704993fSRichard Henderson /* used for function call generation */
1693704993fSRichard Henderson #define TCG_TARGET_STACK_ALIGN		8
1703704993fSRichard Henderson #define TCG_TARGET_CALL_STACK_OFFSET	160
171eb8b0224SRichard Henderson #define TCG_TARGET_CALL_ARG_I32         TCG_CALL_ARG_EXTEND
172c8eef960SRichard Henderson #define TCG_TARGET_CALL_ARG_I64         TCG_CALL_ARG_NORMAL
1735427a9a7SRichard Henderson #define TCG_TARGET_CALL_ARG_I128        TCG_CALL_ARG_BY_REF
1745427a9a7SRichard Henderson #define TCG_TARGET_CALL_RET_I128        TCG_CALL_RET_BY_REF
1753704993fSRichard Henderson 
1763704993fSRichard Henderson #define TCG_TARGET_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
1773704993fSRichard Henderson #define TCG_TARGET_NEED_LDST_LABELS
1783704993fSRichard Henderson #define TCG_TARGET_NEED_POOL_LABELS
1793704993fSRichard Henderson 
1803704993fSRichard Henderson #endif
181