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