]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/riscv/riscv-protos.h
RISC-V: Fix RVV machine mode attribute configuration
[thirdparty/gcc.git] / gcc / config / riscv / riscv-protos.h
CommitLineData
09cae750 1/* Definition of RISC-V target for GNU compiler.
7adcbafe 2 Copyright (C) 2011-2022 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
25/* Symbol types we understand. The order of this list must match that of
26 the unspec enum in riscv.md, subsequent to UNSPEC_ADDRESS_FIRST. */
27enum riscv_symbol_type {
28 SYMBOL_ABSOLUTE,
29 SYMBOL_PCREL,
30 SYMBOL_GOT_DISP,
31 SYMBOL_TLS,
32 SYMBOL_TLS_LE,
33 SYMBOL_TLS_IE,
34 SYMBOL_TLS_GD
35};
36#define NUM_SYMBOL_TYPES (SYMBOL_TLS_GD + 1)
37
e53b6e56 38/* Routines implemented in riscv.cc. */
09cae750
PD
39extern enum riscv_symbol_type riscv_classify_symbolic_expression (rtx);
40extern bool riscv_symbolic_constant_p (rtx, enum riscv_symbol_type *);
b8506a8a 41extern int riscv_regno_mode_ok_for_base_p (int, machine_mode, bool);
b8506a8a 42extern int riscv_address_insns (rtx, machine_mode, bool);
09cae750
PD
43extern int riscv_const_insns (rtx);
44extern int riscv_split_const_insns (rtx);
45extern int riscv_load_store_insns (rtx, rtx_insn *);
46extern rtx riscv_emit_move (rtx, rtx);
a923a463 47extern bool riscv_split_symbol (rtx, rtx, machine_mode, rtx *, bool);
09cae750
PD
48extern bool riscv_split_symbol_type (enum riscv_symbol_type);
49extern rtx riscv_unspec_address (rtx, enum riscv_symbol_type);
a923a463 50extern void riscv_move_integer (rtx, rtx, HOST_WIDE_INT, machine_mode, bool);
b8506a8a 51extern bool riscv_legitimize_move (machine_mode, rtx, rtx);
09cae750
PD
52extern rtx riscv_subword (rtx, bool);
53extern bool riscv_split_64bit_move_p (rtx, rtx);
54extern void riscv_split_doubleword_move (rtx, rtx);
55extern const char *riscv_output_move (rtx, rtx);
8cad5b14 56extern const char *riscv_output_return ();
09cae750
PD
57#ifdef RTX_CODE
58extern void riscv_expand_int_scc (rtx, enum rtx_code, rtx, rtx);
59extern void riscv_expand_float_scc (rtx, enum rtx_code, rtx, rtx);
60extern void riscv_expand_conditional_branch (rtx, enum rtx_code, rtx, rtx);
4f475391 61extern void riscv_expand_conditional_move (rtx, rtx, rtx, rtx_code, rtx, rtx);
09cae750
PD
62#endif
63extern rtx riscv_legitimize_call_address (rtx);
64extern void riscv_set_return_address (rtx, rtx);
65extern bool riscv_expand_block_move (rtx, rtx, rtx);
66extern rtx riscv_return_addr (int, rtx);
3496ca4e 67extern poly_int64 riscv_initial_elimination_offset (int, int);
09cae750 68extern void riscv_expand_prologue (void);
fd1e52dc 69extern void riscv_expand_epilogue (int);
d0ebdd9f 70extern bool riscv_epilogue_uses (unsigned int);
09cae750 71extern bool riscv_can_use_return_insn (void);
6ed01e6b 72extern rtx riscv_function_value (const_tree, const_tree, enum machine_mode);
6ed01e6b 73extern bool riscv_expand_block_move (rtx, rtx, rtx);
88108b27 74extern bool riscv_store_data_bypass_p (rtx_insn *, rtx_insn *);
d0e0c130
KC
75extern rtx riscv_gen_gpr_save_insn (struct riscv_frame_info *);
76extern bool riscv_gpr_save_operation_p (rtx);
b4feb49c 77extern void riscv_reinit (void);
f556cd8b 78extern poly_uint64 riscv_regmode_natural_size (machine_mode);
7e924ba3 79extern bool riscv_v_ext_vector_mode_p (machine_mode);
787ac959 80extern bool riscv_shamt_matches_mask_p (int, HOST_WIDE_INT);
09cae750 81
e53b6e56 82/* Routines implemented in riscv-c.cc. */
09cae750 83void riscv_cpu_cpp_builtins (cpp_reader *);
7d935cdd 84void riscv_register_pragmas (void);
09cae750 85
e53b6e56 86/* Routines implemented in riscv-builtins.cc. */
09cae750 87extern void riscv_atomic_assign_expand_fenv (tree *, tree *, tree *);
b8506a8a 88extern rtx riscv_expand_builtin (tree, rtx, rtx, machine_mode, int);
09cae750
PD
89extern tree riscv_builtin_decl (unsigned int, bool);
90extern void riscv_init_builtins (void);
91
e53b6e56 92/* Routines implemented in riscv-common.cc. */
f908b69c 93extern std::string riscv_arch_str (bool version_p = true);
b4feb49c 94extern void riscv_parse_arch_string (const char *, struct gcc_options *, location_t);
8e966210 95
e0a5b313
KC
96extern bool riscv_hard_regno_rename_ok (unsigned, unsigned);
97
de6320a8
CB
98rtl_opt_pass * make_pass_shorten_memrefs (gcc::context *ctxt);
99
72eb8335
KC
100/* Information about one CPU we know about. */
101struct riscv_cpu_info {
102 /* This CPU's canonical name. */
103 const char *name;
104
105 /* Default arch for this CPU, could be NULL if no default arch. */
106 const char *arch;
107
108 /* Which automaton to use for tuning. */
109 const char *tune;
110};
111
112extern const riscv_cpu_info *riscv_find_cpu (const char *);
113
b4feb49c 114/* Routines implemented in riscv-selftests.cc. */
115#if CHECKING_P
116namespace selftest {
117extern void riscv_run_selftests (void);
118} // namespace selftest
119#endif
120
7d935cdd 121namespace riscv_vector {
fa144175 122#define RVV_VLMAX gen_rtx_REG (Pmode, X0_REGNUM)
3b16afeb
JZZ
123enum vlmul_type
124{
125 LMUL_1 = 0,
126 LMUL_2 = 1,
127 LMUL_4 = 2,
128 LMUL_8 = 3,
129 LMUL_RESERVED = 4,
130 LMUL_F8 = 5,
131 LMUL_F4 = 6,
132 LMUL_F2 = 7,
133};
7d935cdd
JZZ
134/* Routines implemented in riscv-vector-builtins.cc. */
135extern void init_builtins (void);
136extern const char *mangle_builtin_type (const_tree);
137#ifdef GCC_TARGET_H
138extern bool verify_type_context (location_t, type_context_kind, const_tree, bool);
139#endif
140extern void handle_pragma_vector (void);
cbd50570
JZZ
141extern tree builtin_decl (unsigned, bool);
142extern rtx expand_builtin (unsigned int, tree, rtx);
f556cd8b
JZZ
143extern bool const_vec_all_same_in_range_p (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
144extern bool legitimize_move (rtx, rtx, machine_mode);
fa144175 145extern void emit_pred_op (unsigned, rtx, rtx, machine_mode);
3b16afeb
JZZ
146extern enum vlmul_type get_vlmul (machine_mode);
147extern unsigned int get_ratio (machine_mode);
f556cd8b
JZZ
148enum tail_policy
149{
150 TAIL_UNDISTURBED = 0,
151 TAIL_AGNOSTIC = 1,
152};
153
154enum mask_policy
155{
156 MASK_UNDISTURBED = 0,
157 MASK_AGNOSTIC = 1,
158};
7d935cdd
JZZ
159}
160
cbd50570
JZZ
161/* We classify builtin types into two classes:
162 1. General builtin class which is defined in riscv_builtins.
163 2. Vector builtin class which is a special builtin architecture
164 that implement intrinsic short into "pragma". */
165enum riscv_builtin_class
166{
167 RISCV_BUILTIN_GENERAL,
168 RISCV_BUILTIN_VECTOR
169};
170
171const unsigned int RISCV_BUILTIN_SHIFT = 1;
172
173/* Mask that selects the riscv_builtin_class part of a function code. */
174const unsigned int RISCV_BUILTIN_CLASS = (1 << RISCV_BUILTIN_SHIFT) - 1;
175
09cae750 176#endif /* ! GCC_RISCV_PROTOS_H */