]>
Commit | Line | Data |
---|---|---|
09cae750 | 1 | /* Definition of RISC-V target for GNU compiler. |
83ffe9cd | 2 | Copyright (C) 2011-2023 Free Software Foundation, Inc. |
09cae750 PD |
3 | Contributed by Andrew Waterman (andrew@sifive.com). |
4 | Based on MIPS target for GNU compiler. | |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 3, or (at your option) | |
11 | any later version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GCC; see the file COPYING3. If not see | |
20 | <http://www.gnu.org/licenses/>. */ | |
21 | ||
22 | #ifndef GCC_RISCV_PROTOS_H | |
23 | #define GCC_RISCV_PROTOS_H | |
24 | ||
942ab49b PN |
25 | #include "memmodel.h" |
26 | ||
09cae750 PD |
27 | /* Symbol types we understand. The order of this list must match that of |
28 | the unspec enum in riscv.md, subsequent to UNSPEC_ADDRESS_FIRST. */ | |
29 | enum riscv_symbol_type { | |
30 | SYMBOL_ABSOLUTE, | |
31 | SYMBOL_PCREL, | |
32 | SYMBOL_GOT_DISP, | |
33 | SYMBOL_TLS, | |
34 | SYMBOL_TLS_LE, | |
35 | SYMBOL_TLS_IE, | |
36 | SYMBOL_TLS_GD | |
37 | }; | |
38 | #define NUM_SYMBOL_TYPES (SYMBOL_TLS_GD + 1) | |
39 | ||
96ad6ab2 CM |
40 | /* Classifies an address. |
41 | ||
42 | ADDRESS_REG | |
43 | A natural register + offset address. The register satisfies | |
44 | riscv_valid_base_register_p and the offset is a const_arith_operand. | |
45 | ||
2d65622f CM |
46 | ADDRESS_REG_REG |
47 | A base register indexed by (optionally scaled) register. | |
48 | ||
49 | ADDRESS_REG_UREG | |
50 | A base register indexed by (optionally scaled) zero-extended register. | |
51 | ||
52 | ADDRESS_REG_WB | |
53 | A base register indexed by immediate offset with writeback. | |
54 | ||
96ad6ab2 CM |
55 | ADDRESS_LO_SUM |
56 | A LO_SUM rtx. The first operand is a valid base register and | |
57 | the second operand is a symbolic address. | |
58 | ||
59 | ADDRESS_CONST_INT | |
60 | A signed 16-bit constant address. | |
61 | ||
62 | ADDRESS_SYMBOLIC: | |
63 | A constant symbolic address. */ | |
64 | enum riscv_address_type { | |
65 | ADDRESS_REG, | |
2d65622f CM |
66 | ADDRESS_REG_REG, |
67 | ADDRESS_REG_UREG, | |
68 | ADDRESS_REG_WB, | |
96ad6ab2 CM |
69 | ADDRESS_LO_SUM, |
70 | ADDRESS_CONST_INT, | |
71 | ADDRESS_SYMBOLIC | |
72 | }; | |
73 | ||
74 | /* Information about an address described by riscv_address_type. | |
75 | ||
76 | ADDRESS_CONST_INT | |
77 | No fields are used. | |
78 | ||
79 | ADDRESS_REG | |
80 | REG is the base register and OFFSET is the constant offset. | |
81 | ||
2d65622f CM |
82 | ADDRESS_REG_REG and ADDRESS_REG_UREG |
83 | REG is the base register and OFFSET is the index register. | |
84 | ||
85 | ADDRESS_REG_WB | |
86 | REG is the base register, OFFSET is the constant offset, and | |
87 | shift is the shift amount for the offset. | |
88 | ||
96ad6ab2 CM |
89 | ADDRESS_LO_SUM |
90 | REG and OFFSET are the operands to the LO_SUM and SYMBOL_TYPE | |
91 | is the type of symbol it references. | |
92 | ||
93 | ADDRESS_SYMBOLIC | |
94 | SYMBOL_TYPE is the type of symbol that the address references. */ | |
95 | struct riscv_address_info { | |
96 | enum riscv_address_type type; | |
97 | rtx reg; | |
98 | rtx offset; | |
99 | enum riscv_symbol_type symbol_type; | |
2d65622f | 100 | int shift; |
96ad6ab2 CM |
101 | }; |
102 | ||
e53b6e56 | 103 | /* Routines implemented in riscv.cc. */ |
09cae750 PD |
104 | extern enum riscv_symbol_type riscv_classify_symbolic_expression (rtx); |
105 | extern bool riscv_symbolic_constant_p (rtx, enum riscv_symbol_type *); | |
30699b99 | 106 | extern int riscv_float_const_rtx_index_for_fli (rtx); |
b8506a8a | 107 | extern int riscv_regno_mode_ok_for_base_p (int, machine_mode, bool); |
2d65622f | 108 | extern bool riscv_valid_base_register_p (rtx, machine_mode, bool); |
42360427 CM |
109 | extern enum reg_class riscv_index_reg_class (); |
110 | extern int riscv_regno_ok_for_index_p (int); | |
b8506a8a | 111 | extern int riscv_address_insns (rtx, machine_mode, bool); |
09cae750 PD |
112 | extern int riscv_const_insns (rtx); |
113 | extern int riscv_split_const_insns (rtx); | |
114 | extern int riscv_load_store_insns (rtx, rtx_insn *); | |
115 | extern rtx riscv_emit_move (rtx, rtx); | |
05302544 | 116 | extern bool riscv_split_symbol (rtx, rtx, machine_mode, rtx *); |
09cae750 PD |
117 | extern bool riscv_split_symbol_type (enum riscv_symbol_type); |
118 | extern rtx riscv_unspec_address (rtx, enum riscv_symbol_type); | |
05302544 | 119 | extern void riscv_move_integer (rtx, rtx, HOST_WIDE_INT, machine_mode); |
b8506a8a | 120 | extern bool riscv_legitimize_move (machine_mode, rtx, rtx); |
09cae750 PD |
121 | extern rtx riscv_subword (rtx, bool); |
122 | extern bool riscv_split_64bit_move_p (rtx, rtx); | |
123 | extern void riscv_split_doubleword_move (rtx, rtx); | |
124 | extern const char *riscv_output_move (rtx, rtx); | |
8cad5b14 | 125 | extern const char *riscv_output_return (); |
4abcc500 | 126 | extern void riscv_declare_function_name (FILE *, const char *, tree); |
5f110561 | 127 | extern void riscv_declare_function_size (FILE *, const char *, tree); |
4abcc500 LD |
128 | extern void riscv_asm_output_alias (FILE *, const tree, const tree); |
129 | extern void riscv_asm_output_external (FILE *, const tree, const char *); | |
3d1d3132 FG |
130 | extern bool |
131 | riscv_zcmp_valid_stack_adj_bytes_p (HOST_WIDE_INT, int); | |
02fcaf41 | 132 | |
09cae750 | 133 | #ifdef RTX_CODE |
8ae83274 | 134 | extern void riscv_expand_int_scc (rtx, enum rtx_code, rtx, rtx, bool *invert_ptr = 0); |
9a1a2e98 MR |
135 | extern void riscv_expand_float_scc (rtx, enum rtx_code, rtx, rtx, |
136 | bool *invert_ptr = nullptr); | |
09cae750 | 137 | extern void riscv_expand_conditional_branch (rtx, enum rtx_code, rtx, rtx); |
4daeedcb | 138 | extern rtx riscv_emit_unary (enum rtx_code code, rtx dest, rtx x); |
99bfdb07 | 139 | extern rtx riscv_emit_binary (enum rtx_code code, rtx dest, rtx x, rtx y); |
09cae750 | 140 | #endif |
8e7ffe12 | 141 | extern bool riscv_expand_conditional_move (rtx, rtx, rtx, rtx); |
09cae750 PD |
142 | extern rtx riscv_legitimize_call_address (rtx); |
143 | extern void riscv_set_return_address (rtx, rtx); | |
09cae750 | 144 | extern rtx riscv_return_addr (int, rtx); |
3496ca4e | 145 | extern poly_int64 riscv_initial_elimination_offset (int, int); |
09cae750 | 146 | extern void riscv_expand_prologue (void); |
fd1e52dc | 147 | extern void riscv_expand_epilogue (int); |
d0ebdd9f | 148 | extern bool riscv_epilogue_uses (unsigned int); |
09cae750 | 149 | extern bool riscv_can_use_return_insn (void); |
6ed01e6b | 150 | extern rtx riscv_function_value (const_tree, const_tree, enum machine_mode); |
88108b27 | 151 | extern bool riscv_store_data_bypass_p (rtx_insn *, rtx_insn *); |
d0e0c130 KC |
152 | extern rtx riscv_gen_gpr_save_insn (struct riscv_frame_info *); |
153 | extern bool riscv_gpr_save_operation_p (rtx); | |
b4feb49c | 154 | extern void riscv_reinit (void); |
f556cd8b | 155 | extern poly_uint64 riscv_regmode_natural_size (machine_mode); |
7e924ba3 | 156 | extern bool riscv_v_ext_vector_mode_p (machine_mode); |
12847288 | 157 | extern bool riscv_v_ext_tuple_mode_p (machine_mode); |
33b153ff | 158 | extern bool riscv_v_ext_vls_mode_p (machine_mode); |
6ae5565e | 159 | extern int riscv_get_v_regno_alignment (machine_mode); |
787ac959 | 160 | extern bool riscv_shamt_matches_mask_p (int, HOST_WIDE_INT); |
f797260a PN |
161 | extern void riscv_subword_address (rtx, rtx *, rtx *, rtx *, rtx *); |
162 | extern void riscv_lshift_subword (machine_mode, rtx, rtx, rtx *); | |
942ab49b | 163 | extern enum memmodel riscv_union_memmodels (enum memmodel, enum memmodel); |
09cae750 | 164 | |
e53b6e56 | 165 | /* Routines implemented in riscv-c.cc. */ |
09cae750 | 166 | void riscv_cpu_cpp_builtins (cpp_reader *); |
7d935cdd | 167 | void riscv_register_pragmas (void); |
09cae750 | 168 | |
e53b6e56 | 169 | /* Routines implemented in riscv-builtins.cc. */ |
09cae750 | 170 | extern void riscv_atomic_assign_expand_fenv (tree *, tree *, tree *); |
60bd33bc | 171 | extern bool riscv_gimple_fold_builtin (gimple_stmt_iterator *); |
b8506a8a | 172 | extern rtx riscv_expand_builtin (tree, rtx, rtx, machine_mode, int); |
09cae750 PD |
173 | extern tree riscv_builtin_decl (unsigned int, bool); |
174 | extern void riscv_init_builtins (void); | |
175 | ||
e53b6e56 | 176 | /* Routines implemented in riscv-common.cc. */ |
f908b69c | 177 | extern std::string riscv_arch_str (bool version_p = true); |
b4feb49c | 178 | extern void riscv_parse_arch_string (const char *, struct gcc_options *, location_t); |
8e966210 | 179 | |
e0a5b313 KC |
180 | extern bool riscv_hard_regno_rename_ok (unsigned, unsigned); |
181 | ||
de6320a8 | 182 | rtl_opt_pass * make_pass_shorten_memrefs (gcc::context *ctxt); |
e37bc2cf | 183 | rtl_opt_pass * make_pass_avlprop (gcc::context *ctxt); |
9243c3d1 | 184 | rtl_opt_pass * make_pass_vsetvl (gcc::context *ctxt); |
de6320a8 | 185 | |
32874560 CM |
186 | /* Routines implemented in riscv-string.c. */ |
187 | extern bool riscv_expand_block_move (rtx, rtx, rtx); | |
188 | ||
72eb8335 KC |
189 | /* Information about one CPU we know about. */ |
190 | struct riscv_cpu_info { | |
191 | /* This CPU's canonical name. */ | |
192 | const char *name; | |
193 | ||
194 | /* Default arch for this CPU, could be NULL if no default arch. */ | |
195 | const char *arch; | |
196 | ||
197 | /* Which automaton to use for tuning. */ | |
198 | const char *tune; | |
199 | }; | |
200 | ||
201 | extern const riscv_cpu_info *riscv_find_cpu (const char *); | |
202 | ||
b4feb49c | 203 | /* Routines implemented in riscv-selftests.cc. */ |
204 | #if CHECKING_P | |
205 | namespace selftest { | |
3b6d44f4 | 206 | void riscv_run_selftests (void); |
b4feb49c | 207 | } // namespace selftest |
208 | #endif | |
209 | ||
7d935cdd | 210 | namespace riscv_vector { |
fa144175 | 211 | #define RVV_VLMAX gen_rtx_REG (Pmode, X0_REGNUM) |
272e119d | 212 | #define RVV_VUNDEF(MODE) \ |
7caa1ae5 JZZ |
213 | gen_rtx_UNSPEC (MODE, gen_rtvec (1, gen_rtx_REG (SImode, X0_REGNUM)), \ |
214 | UNSPEC_VUNDEF) | |
b3176bdc | 215 | |
79ab19bc LD |
216 | /* These flags describe how to pass the operands to a rvv insn pattern. |
217 | e.g.: | |
218 | If a insn has this flags: | |
219 | HAS_DEST_P | HAS_MASK_P | USE_VUNDEF_MERGE_P | |
220 | | TU_POLICY_P | BINARY_OP_P | FRM_DYN_P | |
221 | that means: | |
222 | operands[0] is the dest operand | |
223 | operands[1] is the mask operand | |
224 | operands[2] is the merge operand | |
225 | operands[3] and operands[4] is the two operand to do the operation. | |
226 | operands[5] is the vl operand | |
227 | operands[6] is the tail policy operand | |
228 | operands[7] is the mask policy operands | |
229 | operands[8] is the rounding mode operands | |
230 | ||
231 | Then you can call `emit_vlmax_insn (flags, icode, ops)` to emit a insn. | |
232 | and ops[0] is the dest operand (operands[0]), ops[1] is the mask | |
233 | operand (operands[1]), ops[2] and ops[3] is the two | |
234 | operands (operands[3], operands[4]) to do the operation. Other operands | |
235 | will be created by emit_vlmax_insn according to the flags information. | |
236 | */ | |
237 | enum insn_flags : unsigned int | |
51fd69ec | 238 | { |
79ab19bc LD |
239 | /* flags for dest, mask, merge operands. */ |
240 | /* Means INSN has dest operand. False for STORE insn. */ | |
241 | HAS_DEST_P = 1 << 0, | |
242 | /* Means INSN has mask operand. */ | |
243 | HAS_MASK_P = 1 << 1, | |
244 | /* Means using ALL_TRUES for mask operand. */ | |
245 | USE_ALL_TRUES_MASK_P = 1 << 2, | |
246 | /* Means using ONE_TRUE for mask operand. */ | |
247 | USE_ONE_TRUE_MASK_P = 1 << 3, | |
248 | /* Means INSN has merge operand. */ | |
249 | HAS_MERGE_P = 1 << 4, | |
250 | /* Means using VUNDEF for merge operand. */ | |
251 | USE_VUNDEF_MERGE_P = 1 << 5, | |
252 | ||
253 | /* flags for tail policy and mask plicy operands. */ | |
254 | /* Means the tail policy is TAIL_UNDISTURBED. */ | |
255 | TU_POLICY_P = 1 << 6, | |
256 | /* Means the tail policy is default (return by get_prefer_tail_policy). */ | |
257 | TDEFAULT_POLICY_P = 1 << 7, | |
258 | /* Means the mask policy is MASK_UNDISTURBED. */ | |
259 | MU_POLICY_P = 1 << 8, | |
260 | /* Means the mask policy is default (return by get_prefer_mask_policy). */ | |
261 | MDEFAULT_POLICY_P = 1 << 9, | |
262 | ||
263 | /* flags for the number operands to do the operation. */ | |
264 | /* Means INSN need zero operand to do the operation. e.g. vid.v */ | |
265 | NULLARY_OP_P = 1 << 10, | |
266 | /* Means INSN need one operand to do the operation. */ | |
267 | UNARY_OP_P = 1 << 11, | |
268 | /* Means INSN need two operands to do the operation. */ | |
269 | BINARY_OP_P = 1 << 12, | |
270 | /* Means INSN need two operands to do the operation. */ | |
271 | TERNARY_OP_P = 1 << 13, | |
272 | ||
dd6e5d29 LD |
273 | /* flags for get vtype mode from the index number. default from dest operand. */ |
274 | VTYPE_MODE_FROM_OP1_P = 1 << 14, | |
79ab19bc LD |
275 | |
276 | /* flags for the floating-point rounding mode. */ | |
277 | /* Means INSN has FRM operand and the value is FRM_DYN. */ | |
278 | FRM_DYN_P = 1 << 15, | |
8bf5636e PL |
279 | |
280 | /* Means INSN has FRM operand and the value is FRM_RUP. */ | |
281 | FRM_RUP_P = 1 << 16, | |
83441e75 PL |
282 | |
283 | /* Means INSN has FRM operand and the value is FRM_RDN. */ | |
284 | FRM_RDN_P = 1 << 17, | |
d324984f PL |
285 | |
286 | /* Means INSN has FRM operand and the value is FRM_RMM. */ | |
287 | FRM_RMM_P = 1 << 18, | |
fcbbf158 PL |
288 | |
289 | /* Means INSN has FRM operand and the value is FRM_RNE. */ | |
290 | FRM_RNE_P = 1 << 19, | |
51fd69ec | 291 | }; |
79ab19bc LD |
292 | |
293 | enum insn_type : unsigned int | |
294 | { | |
295 | /* some flags macros. */ | |
296 | /* For non-mask insn with tama. */ | |
297 | __NORMAL_OP = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | HAS_MERGE_P | |
298 | | USE_VUNDEF_MERGE_P | TDEFAULT_POLICY_P | MDEFAULT_POLICY_P, | |
299 | /* For non-mask insn with ta, without mask policy operand. */ | |
300 | __NORMAL_OP_TA = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | HAS_MERGE_P | |
301 | | USE_VUNDEF_MERGE_P | TDEFAULT_POLICY_P, | |
302 | /* For non-mask insn with ta, without mask operand and mask policy operand. */ | |
303 | __NORMAL_OP_TA2 | |
304 | = HAS_DEST_P | HAS_MERGE_P | USE_VUNDEF_MERGE_P | TDEFAULT_POLICY_P, | |
305 | /* For non-mask insn with ma, without tail policy operand. */ | |
306 | __NORMAL_OP_MA = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | HAS_MERGE_P | |
307 | | USE_VUNDEF_MERGE_P | MDEFAULT_POLICY_P, | |
308 | /* For mask insn with tama. */ | |
309 | __MASK_OP_TAMA = HAS_DEST_P | HAS_MASK_P | HAS_MERGE_P | USE_VUNDEF_MERGE_P | |
310 | | TDEFAULT_POLICY_P | MDEFAULT_POLICY_P, | |
311 | /* For mask insn with tamu. */ | |
312 | __MASK_OP_TAMU | |
313 | = HAS_DEST_P | HAS_MASK_P | HAS_MERGE_P | TDEFAULT_POLICY_P | MU_POLICY_P, | |
314 | /* For mask insn with tuma. */ | |
315 | __MASK_OP_TUMA = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | HAS_MERGE_P | |
316 | | TU_POLICY_P | MDEFAULT_POLICY_P, | |
317 | /* For mask insn with mu. */ | |
318 | __MASK_OP_MU = HAS_DEST_P | HAS_MASK_P | HAS_MERGE_P | MU_POLICY_P, | |
319 | /* For mask insn with ta, without mask policy operand. */ | |
320 | __MASK_OP_TA = HAS_DEST_P | HAS_MASK_P | HAS_MERGE_P | USE_VUNDEF_MERGE_P | |
321 | | TDEFAULT_POLICY_P, | |
322 | ||
323 | /* Nullary operator. e.g. vid.v */ | |
324 | NULLARY_OP = __NORMAL_OP | NULLARY_OP_P, | |
325 | ||
326 | /* Unary operator. */ | |
327 | UNARY_OP = __NORMAL_OP | UNARY_OP_P, | |
328 | UNARY_OP_TAMA = __MASK_OP_TAMA | UNARY_OP_P, | |
329 | UNARY_OP_TAMU = __MASK_OP_TAMU | UNARY_OP_P, | |
330 | UNARY_OP_FRM_DYN = UNARY_OP | FRM_DYN_P, | |
2cc4f58a | 331 | UNARY_OP_FRM_RMM = UNARY_OP | FRM_RMM_P, |
51f7bfaa | 332 | UNARY_OP_FRM_RUP = UNARY_OP | FRM_RUP_P, |
8f52040e | 333 | UNARY_OP_FRM_RDN = UNARY_OP | FRM_RDN_P, |
85858c71 PL |
334 | UNARY_OP_TAMA_FRM_DYN = UNARY_OP_TAMA | FRM_DYN_P, |
335 | UNARY_OP_TAMA_FRM_RUP = UNARY_OP_TAMA | FRM_RUP_P, | |
336 | UNARY_OP_TAMA_FRM_RDN = UNARY_OP_TAMA | FRM_RDN_P, | |
337 | UNARY_OP_TAMA_FRM_RMM = UNARY_OP_TAMA | FRM_RMM_P, | |
338 | UNARY_OP_TAMA_FRM_RNE = UNARY_OP_TAMA | FRM_RNE_P, | |
e2023d2d | 339 | UNARY_OP_TAMU_FRM_DYN = UNARY_OP_TAMU | FRM_DYN_P, |
8bf5636e | 340 | UNARY_OP_TAMU_FRM_RUP = UNARY_OP_TAMU | FRM_RUP_P, |
83441e75 | 341 | UNARY_OP_TAMU_FRM_RDN = UNARY_OP_TAMU | FRM_RDN_P, |
d324984f | 342 | UNARY_OP_TAMU_FRM_RMM = UNARY_OP_TAMU | FRM_RMM_P, |
fcbbf158 | 343 | UNARY_OP_TAMU_FRM_RNE = UNARY_OP_TAMU | FRM_RNE_P, |
79ab19bc LD |
344 | |
345 | /* Binary operator. */ | |
346 | BINARY_OP = __NORMAL_OP | BINARY_OP_P, | |
347 | BINARY_OP_TAMA = __MASK_OP_TAMA | BINARY_OP_P, | |
348 | BINARY_OP_TAMU = __MASK_OP_TAMU | BINARY_OP_P, | |
349 | BINARY_OP_TUMA = __MASK_OP_TUMA | BINARY_OP_P, | |
350 | BINARY_OP_FRM_DYN = BINARY_OP | FRM_DYN_P, | |
351 | ||
352 | /* Ternary operator. Always have real merge operand. */ | |
353 | TERNARY_OP = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | HAS_MERGE_P | |
354 | | TDEFAULT_POLICY_P | MDEFAULT_POLICY_P | TERNARY_OP_P, | |
355 | TERNARY_OP_FRM_DYN = TERNARY_OP | FRM_DYN_P, | |
356 | ||
357 | /* For vwmacc, no merge operand. */ | |
358 | WIDEN_TERNARY_OP = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | |
359 | | TDEFAULT_POLICY_P | MDEFAULT_POLICY_P | TERNARY_OP_P, | |
360 | WIDEN_TERNARY_OP_FRM_DYN = WIDEN_TERNARY_OP | FRM_DYN_P, | |
361 | ||
362 | /* For vmerge, no mask operand, no mask policy operand. */ | |
363 | MERGE_OP = __NORMAL_OP_TA2 | TERNARY_OP_P, | |
364 | ||
0c42741a RD |
365 | /* For vmerge with TU policy. */ |
366 | MERGE_OP_TU = HAS_DEST_P | HAS_MERGE_P | TERNARY_OP_P | TU_POLICY_P, | |
367 | ||
79ab19bc LD |
368 | /* For vm<compare>, no tail policy operand. */ |
369 | COMPARE_OP = __NORMAL_OP_MA | TERNARY_OP_P, | |
370 | COMPARE_OP_MU = __MASK_OP_MU | TERNARY_OP_P, | |
371 | ||
372 | /* For scatter insn: no dest operand, no merge operand, no tail and mask | |
373 | policy operands. */ | |
374 | SCATTER_OP_M = HAS_MASK_P | TERNARY_OP_P, | |
375 | ||
376 | /* For vcpop.m, no merge operand, no tail and mask policy operands. */ | |
377 | CPOP_OP = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | UNARY_OP_P | |
dd6e5d29 | 378 | | VTYPE_MODE_FROM_OP1_P, |
79ab19bc LD |
379 | |
380 | /* For mask instrunctions, no tail and mask policy operands. */ | |
381 | UNARY_MASK_OP = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | HAS_MERGE_P | |
382 | | USE_VUNDEF_MERGE_P | UNARY_OP_P, | |
383 | BINARY_MASK_OP = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | HAS_MERGE_P | |
384 | | USE_VUNDEF_MERGE_P | BINARY_OP_P, | |
385 | ||
386 | /* For vcompress.vm */ | |
387 | COMPRESS_OP = __NORMAL_OP_TA2 | BINARY_OP_P, | |
388 | /* has merge operand but use ta. */ | |
389 | COMPRESS_OP_MERGE | |
390 | = HAS_DEST_P | HAS_MERGE_P | TDEFAULT_POLICY_P | BINARY_OP_P, | |
391 | ||
6aaf72ff JZ |
392 | /* For vslideup.up has merge operand but use ta. */ |
393 | SLIDEUP_OP_MERGE = HAS_DEST_P | HAS_MASK_P | USE_ALL_TRUES_MASK_P | |
394 | | HAS_MERGE_P | TDEFAULT_POLICY_P | MDEFAULT_POLICY_P | |
395 | | BINARY_OP_P, | |
396 | ||
79ab19bc | 397 | /* For vreduce, no mask policy operand. */ |
dd6e5d29 | 398 | REDUCE_OP = __NORMAL_OP_TA | BINARY_OP_P | VTYPE_MODE_FROM_OP1_P, |
5bc8c83d | 399 | REDUCE_OP_M = __MASK_OP_TA | BINARY_OP_P | VTYPE_MODE_FROM_OP1_P, |
dd6e5d29 | 400 | REDUCE_OP_FRM_DYN = REDUCE_OP | FRM_DYN_P | VTYPE_MODE_FROM_OP1_P, |
79ab19bc | 401 | REDUCE_OP_M_FRM_DYN |
dd6e5d29 | 402 | = __MASK_OP_TA | BINARY_OP_P | FRM_DYN_P | VTYPE_MODE_FROM_OP1_P, |
79ab19bc LD |
403 | |
404 | /* For vmv.s.x/vfmv.s.f. */ | |
405 | SCALAR_MOVE_OP = HAS_DEST_P | HAS_MASK_P | USE_ONE_TRUE_MASK_P | HAS_MERGE_P | |
406 | | USE_VUNDEF_MERGE_P | TDEFAULT_POLICY_P | MDEFAULT_POLICY_P | |
407 | | UNARY_OP_P, | |
28f16f6d PL |
408 | |
409 | SCALAR_MOVE_MERGED_OP = HAS_DEST_P | HAS_MASK_P | USE_ONE_TRUE_MASK_P | |
410 | | HAS_MERGE_P | TDEFAULT_POLICY_P | MDEFAULT_POLICY_P | |
411 | | UNARY_OP_P, | |
79ab19bc LD |
412 | }; |
413 | ||
3b16afeb JZZ |
414 | enum vlmul_type |
415 | { | |
416 | LMUL_1 = 0, | |
417 | LMUL_2 = 1, | |
418 | LMUL_4 = 2, | |
419 | LMUL_8 = 3, | |
420 | LMUL_RESERVED = 4, | |
421 | LMUL_F8 = 5, | |
422 | LMUL_F4 = 6, | |
423 | LMUL_F2 = 7, | |
ec99ffab | 424 | NUM_LMUL = 8 |
3b16afeb | 425 | }; |
9243c3d1 | 426 | |
e99cdab8 LD |
427 | /* The RISC-V vsetvli pass uses "known vlmax" operations for optimization. |
428 | Whether or not an instruction actually is a vlmax operation is not | |
429 | recognizable from the length operand alone but the avl_type operand | |
430 | is used instead. In general, there are two cases: | |
431 | ||
432 | - Emit a vlmax operation by calling emit_vlmax_insn[_lra]. Here we emit | |
433 | a vsetvli with vlmax configuration and set the avl_type to VLMAX for | |
434 | VLA modes or VLS for VLS modes. | |
435 | - Emit an operation that uses the existing (last-set) length and | |
436 | set the avl_type to NONVLMAX. | |
437 | ||
438 | Sometimes we also need to set the VLMAX or VLS avl_type to an operation that | |
439 | already uses a given length register. This can happen during or after | |
440 | register allocation when we are not allowed to create a new register. | |
441 | For that case we also allow to set the avl_type to VLMAX or VLS. | |
442 | */ | |
9243c3d1 JZZ |
443 | enum avl_type |
444 | { | |
e99cdab8 LD |
445 | NONVLMAX = 0, |
446 | VLMAX = 1, | |
447 | VLS = 2, | |
9243c3d1 | 448 | }; |
7d935cdd | 449 | /* Routines implemented in riscv-vector-builtins.cc. */ |
3b6d44f4 JZZ |
450 | void init_builtins (void); |
451 | const char *mangle_builtin_type (const_tree); | |
509c10a6 | 452 | tree lookup_vector_type_attribute (const_tree); |
94a4b932 | 453 | bool builtin_type_p (const_tree); |
7d935cdd | 454 | #ifdef GCC_TARGET_H |
3b6d44f4 | 455 | bool verify_type_context (location_t, type_context_kind, const_tree, bool); |
631e86b7 JZ |
456 | bool expand_vec_perm_const (machine_mode, machine_mode, rtx, rtx, rtx, |
457 | const vec_perm_indices &); | |
7d935cdd | 458 | #endif |
3b6d44f4 JZZ |
459 | void handle_pragma_vector (void); |
460 | tree builtin_decl (unsigned, bool); | |
60bd33bc | 461 | gimple *gimple_fold_builtin (unsigned int, gimple_stmt_iterator *, gcall *); |
3b6d44f4 | 462 | rtx expand_builtin (unsigned int, tree, rtx); |
7caa1ae5 JZZ |
463 | bool check_builtin_call (location_t, vec<location_t>, unsigned int, |
464 | tree, unsigned int, tree *); | |
1a55724f | 465 | tree resolve_overloaded_builtin (unsigned int, vec<tree, va_gc> *); |
3b6d44f4 | 466 | bool const_vec_all_same_in_range_p (rtx, HOST_WIDE_INT, HOST_WIDE_INT); |
f416a3fd | 467 | bool legitimize_move (rtx, rtx *); |
cd0c433e | 468 | void emit_vlmax_vsetvl (machine_mode, rtx); |
40fc8e3d | 469 | void emit_hard_vlmax_vsetvl (machine_mode, rtx); |
79ab19bc LD |
470 | void emit_vlmax_insn (unsigned, unsigned, rtx *); |
471 | void emit_nonvlmax_insn (unsigned, unsigned, rtx *, rtx); | |
472 | void emit_vlmax_insn_lra (unsigned, unsigned, rtx *, rtx); | |
3b6d44f4 | 473 | enum vlmul_type get_vlmul (machine_mode); |
b3176bdc | 474 | rtx get_vlmax_rtx (machine_mode); |
3b6d44f4 | 475 | unsigned int get_ratio (machine_mode); |
12847288 JZZ |
476 | unsigned int get_nf (machine_mode); |
477 | machine_mode get_subpart_mode (machine_mode); | |
3b6d44f4 JZZ |
478 | int get_ta (rtx); |
479 | int get_ma (rtx); | |
480 | int get_avl_type (rtx); | |
481 | unsigned int calculate_ratio (unsigned int, enum vlmul_type); | |
f556cd8b JZZ |
482 | enum tail_policy |
483 | { | |
484 | TAIL_UNDISTURBED = 0, | |
485 | TAIL_AGNOSTIC = 1, | |
9243c3d1 | 486 | TAIL_ANY = 2, |
f556cd8b JZZ |
487 | }; |
488 | ||
489 | enum mask_policy | |
490 | { | |
491 | MASK_UNDISTURBED = 0, | |
492 | MASK_AGNOSTIC = 1, | |
9243c3d1 | 493 | MASK_ANY = 2, |
f556cd8b | 494 | }; |
8390a2af | 495 | |
e69d050f LD |
496 | /* Return true if VALUE is agnostic or any policy. */ |
497 | #define IS_AGNOSTIC(VALUE) (bool) (VALUE & 0x1 || (VALUE >> 1 & 0x1)) | |
498 | ||
9243c3d1 JZZ |
499 | enum tail_policy get_prefer_tail_policy (); |
500 | enum mask_policy get_prefer_mask_policy (); | |
a143c3f7 | 501 | rtx get_avl_type_rtx (enum avl_type); |
6c9bcb6c | 502 | opt_machine_mode get_vector_mode (scalar_mode, poly_uint64); |
12847288 | 503 | opt_machine_mode get_tuple_mode (machine_mode, unsigned int); |
3b6d44f4 JZZ |
504 | bool simm5_p (rtx); |
505 | bool neg_simm5_p (rtx); | |
a035d133 | 506 | #ifdef RTX_CODE |
3b6d44f4 | 507 | bool has_vi_variant_p (rtx_code, rtx); |
e0600a02 JZ |
508 | void expand_vec_cmp (rtx, rtx_code, rtx, rtx); |
509 | bool expand_vec_cmp_float (rtx, rtx_code, rtx, rtx, bool); | |
4d1c8b04 LD |
510 | void expand_cond_len_unop (unsigned, rtx *); |
511 | void expand_cond_len_binop (unsigned, rtx *); | |
e6413b5d | 512 | void expand_reduction (unsigned, unsigned, rtx *, rtx); |
8bf5636e | 513 | void expand_vec_ceil (rtx, rtx, machine_mode, machine_mode); |
83441e75 | 514 | void expand_vec_floor (rtx, rtx, machine_mode, machine_mode); |
e2023d2d | 515 | void expand_vec_nearbyint (rtx, rtx, machine_mode, machine_mode); |
e4cf5f54 | 516 | void expand_vec_rint (rtx, rtx, machine_mode, machine_mode); |
d324984f | 517 | void expand_vec_round (rtx, rtx, machine_mode, machine_mode); |
1c4ca595 | 518 | void expand_vec_trunc (rtx, rtx, machine_mode, machine_mode); |
fcbbf158 | 519 | void expand_vec_roundeven (rtx, rtx, machine_mode, machine_mode); |
5dfa501d PL |
520 | void expand_vec_lrint (rtx, rtx, machine_mode, machine_mode, machine_mode); |
521 | void expand_vec_lround (rtx, rtx, machine_mode, machine_mode, machine_mode); | |
51f7bfaa | 522 | void expand_vec_lceil (rtx, rtx, machine_mode, machine_mode); |
8f52040e | 523 | void expand_vec_lfloor (rtx, rtx, machine_mode, machine_mode); |
a035d133 | 524 | #endif |
51fd69ec | 525 | bool sew64_scalar_helper (rtx *, rtx *, rtx, machine_mode, |
eb1cdb3e | 526 | bool, void (*)(rtx *, rtx), enum avl_type); |
ec99ffab | 527 | rtx gen_scalar_move_mask (machine_mode); |
9c032218 | 528 | rtx gen_no_side_effects_vsetvl_rtx (machine_mode, rtx, rtx); |
1bff101b JZZ |
529 | |
530 | /* RVV vector register sizes. | |
531 | TODO: Currently, we only add RVV_32/RVV_64/RVV_128, we may need to | |
532 | support other values in the future. */ | |
533 | enum vlen_enum | |
534 | { | |
535 | RVV_32 = 32, | |
536 | RVV_64 = 64, | |
537 | RVV_65536 = 65536 | |
538 | }; | |
539 | bool slide1_sew64_helper (int, machine_mode, machine_mode, | |
540 | machine_mode, rtx *); | |
db4f7a9b | 541 | rtx gen_avl_for_scalar_move (rtx); |
51fd69ec | 542 | void expand_tuple_move (rtx *); |
9464e72b | 543 | bool expand_block_move (rtx, rtx, rtx); |
2d76f2b4 | 544 | machine_mode preferred_simd_mode (scalar_mode); |
1349f530 | 545 | machine_mode get_mask_mode (machine_mode); |
71a5ac67 | 546 | void expand_vec_series (rtx, rtx, rtx, rtx = 0); |
1c1a9d8e | 547 | void expand_vec_init (rtx, rtx); |
2418cdfc | 548 | void expand_vec_perm (rtx, rtx, rtx, rtx); |
55dcf277 | 549 | void expand_select_vl (rtx *); |
d42d199e | 550 | void expand_load_store (rtx *, bool); |
f048af2a | 551 | void expand_gather_scatter (rtx *, bool); |
0d2673e9 | 552 | void expand_cond_len_ternop (unsigned, rtx *); |
95d2ce05 | 553 | void prepare_ternary_operands (rtx *); |
fe578886 | 554 | void expand_lanes_load_store (rtx *, bool); |
e7545cad | 555 | void expand_fold_extract_last (rtx *); |
8a87ba0b JZ |
556 | void expand_cond_unop (unsigned, rtx *); |
557 | void expand_cond_binop (unsigned, rtx *); | |
558 | void expand_cond_ternop (unsigned, rtx *); | |
82bbbb73 | 559 | void expand_popcount (rtx *); |
2664964b | 560 | void expand_rawmemchr (machine_mode, rtx, rtx, rtx, bool = false); |
d468718c | 561 | bool expand_strcmp (rtx, rtx, rtx, rtx, unsigned HOST_WIDE_INT, bool); |
ef296fb3 | 562 | void emit_vec_extract (rtx, rtx, poly_int64); |
47ffabaf | 563 | |
5ed88078 | 564 | /* Rounding mode bitfield for fixed point VXRM. */ |
47ffabaf | 565 | enum fixed_point_rounding_mode |
5ed88078 JZ |
566 | { |
567 | VXRM_RNU, | |
568 | VXRM_RNE, | |
569 | VXRM_RDN, | |
570 | VXRM_ROD | |
571 | }; | |
47ffabaf | 572 | |
7f4644f8 PL |
573 | /* Rounding mode bitfield for floating point FRM. The value of enum comes |
574 | from the below link. | |
575 | https://github.com/riscv/riscv-isa-manual/blob/main/src/f-st-ext.adoc#floating-point-control-and-status-register | |
576 | */ | |
47ffabaf | 577 | enum floating_point_rounding_mode |
8cd140d3 | 578 | { |
7f4644f8 PL |
579 | FRM_RNE = 0, /* Aka 0b000. */ |
580 | FRM_RTZ = 1, /* Aka 0b001. */ | |
581 | FRM_RDN = 2, /* Aka 0b010. */ | |
582 | FRM_RUP = 3, /* Aka 0b011. */ | |
583 | FRM_RMM = 4, /* Aka 0b100. */ | |
584 | FRM_DYN = 7, /* Aka 0b111. */ | |
4d1e97f5 PL |
585 | FRM_STATIC_MIN = FRM_RNE, |
586 | FRM_STATIC_MAX = FRM_RMM, | |
4cede0de PL |
587 | FRM_DYN_EXIT = 8, |
588 | FRM_DYN_CALL = 9, | |
589 | FRM_NONE = 10, | |
8cd140d3 | 590 | }; |
25907509 | 591 | |
4cede0de | 592 | enum floating_point_rounding_mode get_frm_mode (rtx); |
25907509 RD |
593 | opt_machine_mode vectorize_related_mode (machine_mode, scalar_mode, |
594 | poly_uint64); | |
595 | unsigned int autovectorize_vector_modes (vec<machine_mode> *, bool); | |
d05aac04 JZ |
596 | bool cmp_lmul_le_one (machine_mode); |
597 | bool cmp_lmul_gt_one (machine_mode); | |
66c26e5c | 598 | bool vls_mode_valid_p (machine_mode); |
5e714992 | 599 | bool vlmax_avl_type_p (rtx_insn *); |
8064e7e2 JZ |
600 | bool has_vl_op (rtx_insn *); |
601 | bool tail_agnostic_p (rtx_insn *); | |
602 | void validate_change_or_fail (rtx, rtx *, rtx, bool); | |
603 | bool nonvlmax_avl_type_p (rtx_insn *); | |
604 | bool vlmax_avl_p (rtx); | |
605 | uint8_t get_sew (rtx_insn *); | |
606 | enum vlmul_type get_vlmul (rtx_insn *); | |
607 | int count_regno_occurrences (rtx_insn *, unsigned int); | |
5ea3c039 | 608 | bool imm_avl_p (machine_mode); |
418bd642 | 609 | bool can_be_broadcasted_p (rtx); |
8b93a0f3 | 610 | bool gather_scatter_valid_offset_p (machine_mode); |
7d935cdd JZZ |
611 | } |
612 | ||
cbd50570 JZZ |
613 | /* We classify builtin types into two classes: |
614 | 1. General builtin class which is defined in riscv_builtins. | |
615 | 2. Vector builtin class which is a special builtin architecture | |
616 | that implement intrinsic short into "pragma". */ | |
617 | enum riscv_builtin_class | |
618 | { | |
619 | RISCV_BUILTIN_GENERAL, | |
620 | RISCV_BUILTIN_VECTOR | |
621 | }; | |
622 | ||
623 | const unsigned int RISCV_BUILTIN_SHIFT = 1; | |
624 | ||
625 | /* Mask that selects the riscv_builtin_class part of a function code. */ | |
626 | const unsigned int RISCV_BUILTIN_CLASS = (1 << RISCV_BUILTIN_SHIFT) - 1; | |
627 | ||
df48285b | 628 | /* Routines implemented in riscv-string.cc. */ |
949f1ccf | 629 | extern bool riscv_expand_strcmp (rtx, rtx, rtx, rtx, rtx); |
df48285b CM |
630 | extern bool riscv_expand_strlen (rtx, rtx, rtx, rtx); |
631 | ||
02fcaf41 | 632 | /* Routines implemented in thead.cc. */ |
c177f28d | 633 | extern bool extract_base_offset_in_addr (rtx, rtx *, rtx *); |
02fcaf41 CM |
634 | extern bool th_mempair_operands_p (rtx[4], bool, machine_mode); |
635 | extern void th_mempair_order_operands (rtx[4], bool, machine_mode); | |
636 | extern void th_mempair_prepare_save_restore_operands (rtx[4], bool, | |
637 | machine_mode, | |
638 | int, HOST_WIDE_INT, | |
639 | int, HOST_WIDE_INT); | |
640 | extern void th_mempair_save_restore_regs (rtx[4], bool, machine_mode); | |
641 | #ifdef RTX_CODE | |
642 | extern const char* | |
643 | th_mempair_output_move (rtx[4], bool, machine_mode, RTX_CODE); | |
2d65622f CM |
644 | extern bool th_memidx_legitimate_modify_p (rtx); |
645 | extern bool th_memidx_legitimate_modify_p (rtx, bool); | |
646 | extern bool th_memidx_legitimate_index_p (rtx); | |
647 | extern bool th_memidx_legitimate_index_p (rtx, bool); | |
648 | extern bool th_classify_address (struct riscv_address_info *, | |
649 | rtx, machine_mode, bool); | |
650 | extern const char *th_output_move (rtx, rtx); | |
651 | extern bool th_print_operand_address (FILE *, machine_mode, rtx); | |
02fcaf41 CM |
652 | #endif |
653 | ||
065be0ff | 654 | extern bool riscv_use_divmod_expander (void); |
1d4d302a | 655 | void riscv_init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, int); |
5f110561 KC |
656 | extern bool |
657 | riscv_option_valid_attribute_p (tree, tree, tree, int); | |
658 | extern void | |
659 | riscv_override_options_internal (struct gcc_options *); | |
660 | ||
661 | struct riscv_tune_param; | |
662 | /* Information about one micro-arch we know about. */ | |
663 | struct riscv_tune_info { | |
664 | /* This micro-arch canonical name. */ | |
665 | const char *name; | |
666 | ||
667 | /* Which automaton to use for tuning. */ | |
668 | enum riscv_microarchitecture_type microarchitecture; | |
669 | ||
670 | /* Tuning parameters for this micro-arch. */ | |
671 | const struct riscv_tune_param *tune_param; | |
672 | }; | |
673 | ||
674 | const struct riscv_tune_info * | |
675 | riscv_parse_tune (const char *, bool); | |
1d4d302a | 676 | |
09cae750 | 677 | #endif /* ! GCC_RISCV_PROTOS_H */ |