]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/riscv/riscv-protos.h
Speedup cse_insn
[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
e53b6e56 40/* Routines implemented in riscv.cc. */
09cae750
PD
41extern enum riscv_symbol_type riscv_classify_symbolic_expression (rtx);
42extern bool riscv_symbolic_constant_p (rtx, enum riscv_symbol_type *);
b8506a8a 43extern int riscv_regno_mode_ok_for_base_p (int, machine_mode, bool);
b8506a8a 44extern int riscv_address_insns (rtx, machine_mode, bool);
09cae750
PD
45extern int riscv_const_insns (rtx);
46extern int riscv_split_const_insns (rtx);
47extern int riscv_load_store_insns (rtx, rtx_insn *);
48extern rtx riscv_emit_move (rtx, rtx);
05302544 49extern bool riscv_split_symbol (rtx, rtx, machine_mode, rtx *);
09cae750
PD
50extern bool riscv_split_symbol_type (enum riscv_symbol_type);
51extern rtx riscv_unspec_address (rtx, enum riscv_symbol_type);
05302544 52extern void riscv_move_integer (rtx, rtx, HOST_WIDE_INT, machine_mode);
b8506a8a 53extern bool riscv_legitimize_move (machine_mode, rtx, rtx);
09cae750
PD
54extern rtx riscv_subword (rtx, bool);
55extern bool riscv_split_64bit_move_p (rtx, rtx);
56extern void riscv_split_doubleword_move (rtx, rtx);
57extern const char *riscv_output_move (rtx, rtx);
8cad5b14 58extern const char *riscv_output_return ();
02fcaf41 59
09cae750
PD
60#ifdef RTX_CODE
61extern void riscv_expand_int_scc (rtx, enum rtx_code, rtx, rtx);
62extern void riscv_expand_float_scc (rtx, enum rtx_code, rtx, rtx);
63extern void riscv_expand_conditional_branch (rtx, enum rtx_code, rtx, rtx);
64#endif
8e7ffe12 65extern bool riscv_expand_conditional_move (rtx, rtx, rtx, rtx);
09cae750
PD
66extern rtx riscv_legitimize_call_address (rtx);
67extern void riscv_set_return_address (rtx, rtx);
68extern bool riscv_expand_block_move (rtx, rtx, rtx);
69extern rtx riscv_return_addr (int, rtx);
3496ca4e 70extern poly_int64 riscv_initial_elimination_offset (int, int);
09cae750 71extern void riscv_expand_prologue (void);
fd1e52dc 72extern void riscv_expand_epilogue (int);
d0ebdd9f 73extern bool riscv_epilogue_uses (unsigned int);
09cae750 74extern bool riscv_can_use_return_insn (void);
6ed01e6b 75extern rtx riscv_function_value (const_tree, const_tree, enum machine_mode);
6ed01e6b 76extern bool riscv_expand_block_move (rtx, rtx, rtx);
88108b27 77extern bool riscv_store_data_bypass_p (rtx_insn *, rtx_insn *);
d0e0c130
KC
78extern rtx riscv_gen_gpr_save_insn (struct riscv_frame_info *);
79extern bool riscv_gpr_save_operation_p (rtx);
b4feb49c 80extern void riscv_reinit (void);
f556cd8b 81extern poly_uint64 riscv_regmode_natural_size (machine_mode);
7e924ba3 82extern bool riscv_v_ext_vector_mode_p (machine_mode);
787ac959 83extern bool riscv_shamt_matches_mask_p (int, HOST_WIDE_INT);
f797260a
PN
84extern void riscv_subword_address (rtx, rtx *, rtx *, rtx *, rtx *);
85extern void riscv_lshift_subword (machine_mode, rtx, rtx, rtx *);
942ab49b 86extern enum memmodel riscv_union_memmodels (enum memmodel, enum memmodel);
09cae750 87
e53b6e56 88/* Routines implemented in riscv-c.cc. */
09cae750 89void riscv_cpu_cpp_builtins (cpp_reader *);
7d935cdd 90void riscv_register_pragmas (void);
09cae750 91
e53b6e56 92/* Routines implemented in riscv-builtins.cc. */
09cae750 93extern void riscv_atomic_assign_expand_fenv (tree *, tree *, tree *);
60bd33bc 94extern bool riscv_gimple_fold_builtin (gimple_stmt_iterator *);
b8506a8a 95extern rtx riscv_expand_builtin (tree, rtx, rtx, machine_mode, int);
09cae750
PD
96extern tree riscv_builtin_decl (unsigned int, bool);
97extern void riscv_init_builtins (void);
98
e53b6e56 99/* Routines implemented in riscv-common.cc. */
f908b69c 100extern std::string riscv_arch_str (bool version_p = true);
b4feb49c 101extern void riscv_parse_arch_string (const char *, struct gcc_options *, location_t);
8e966210 102
e0a5b313
KC
103extern bool riscv_hard_regno_rename_ok (unsigned, unsigned);
104
de6320a8 105rtl_opt_pass * make_pass_shorten_memrefs (gcc::context *ctxt);
9243c3d1 106rtl_opt_pass * make_pass_vsetvl (gcc::context *ctxt);
de6320a8 107
72eb8335
KC
108/* Information about one CPU we know about. */
109struct riscv_cpu_info {
110 /* This CPU's canonical name. */
111 const char *name;
112
113 /* Default arch for this CPU, could be NULL if no default arch. */
114 const char *arch;
115
116 /* Which automaton to use for tuning. */
117 const char *tune;
118};
119
120extern const riscv_cpu_info *riscv_find_cpu (const char *);
121
b4feb49c 122/* Routines implemented in riscv-selftests.cc. */
123#if CHECKING_P
124namespace selftest {
3b6d44f4 125void riscv_run_selftests (void);
b4feb49c 126} // namespace selftest
127#endif
128
7d935cdd 129namespace riscv_vector {
fa144175 130#define RVV_VLMAX gen_rtx_REG (Pmode, X0_REGNUM)
272e119d 131#define RVV_VUNDEF(MODE) \
7caa1ae5
JZZ
132 gen_rtx_UNSPEC (MODE, gen_rtvec (1, gen_rtx_REG (SImode, X0_REGNUM)), \
133 UNSPEC_VUNDEF)
3b16afeb
JZZ
134enum vlmul_type
135{
136 LMUL_1 = 0,
137 LMUL_2 = 1,
138 LMUL_4 = 2,
139 LMUL_8 = 3,
140 LMUL_RESERVED = 4,
141 LMUL_F8 = 5,
142 LMUL_F4 = 6,
143 LMUL_F2 = 7,
ec99ffab 144 NUM_LMUL = 8
3b16afeb 145};
9243c3d1
JZZ
146
147enum avl_type
148{
149 NONVLMAX,
150 VLMAX,
151};
7d935cdd 152/* Routines implemented in riscv-vector-builtins.cc. */
3b6d44f4
JZZ
153void init_builtins (void);
154const char *mangle_builtin_type (const_tree);
7d935cdd 155#ifdef GCC_TARGET_H
3b6d44f4 156bool verify_type_context (location_t, type_context_kind, const_tree, bool);
7d935cdd 157#endif
3b6d44f4
JZZ
158void handle_pragma_vector (void);
159tree builtin_decl (unsigned, bool);
60bd33bc 160gimple *gimple_fold_builtin (unsigned int, gimple_stmt_iterator *, gcall *);
3b6d44f4 161rtx expand_builtin (unsigned int, tree, rtx);
7caa1ae5
JZZ
162bool check_builtin_call (location_t, vec<location_t>, unsigned int,
163 tree, unsigned int, tree *);
3b6d44f4
JZZ
164bool const_vec_all_same_in_range_p (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
165bool legitimize_move (rtx, rtx, machine_mode);
cd0c433e 166void emit_vlmax_vsetvl (machine_mode, rtx);
40fc8e3d 167void emit_hard_vlmax_vsetvl (machine_mode, rtx);
3b6d44f4 168void emit_vlmax_op (unsigned, rtx, rtx, machine_mode);
cd0c433e 169void emit_vlmax_op (unsigned, rtx, rtx, rtx, machine_mode);
3b6d44f4
JZZ
170void emit_nonvlmax_op (unsigned, rtx, rtx, rtx, machine_mode);
171enum vlmul_type get_vlmul (machine_mode);
172unsigned int get_ratio (machine_mode);
173int get_ta (rtx);
174int get_ma (rtx);
175int get_avl_type (rtx);
176unsigned int calculate_ratio (unsigned int, enum vlmul_type);
f556cd8b
JZZ
177enum tail_policy
178{
179 TAIL_UNDISTURBED = 0,
180 TAIL_AGNOSTIC = 1,
9243c3d1 181 TAIL_ANY = 2,
f556cd8b
JZZ
182};
183
184enum mask_policy
185{
186 MASK_UNDISTURBED = 0,
187 MASK_AGNOSTIC = 1,
9243c3d1 188 MASK_ANY = 2,
f556cd8b 189};
9243c3d1
JZZ
190enum tail_policy get_prefer_tail_policy ();
191enum mask_policy get_prefer_mask_policy ();
a143c3f7 192rtx get_avl_type_rtx (enum avl_type);
6c9bcb6c 193opt_machine_mode get_vector_mode (scalar_mode, poly_uint64);
3b6d44f4
JZZ
194bool simm5_p (rtx);
195bool neg_simm5_p (rtx);
a035d133 196#ifdef RTX_CODE
3b6d44f4 197bool has_vi_variant_p (rtx_code, rtx);
a035d133 198#endif
3cb0fa12
JZZ
199bool sew64_scalar_helper (rtx *, rtx *, rtx, machine_mode, machine_mode,
200 bool, void (*)(rtx *, rtx));
ec99ffab 201rtx gen_scalar_move_mask (machine_mode);
1bff101b
JZZ
202
203/* RVV vector register sizes.
204 TODO: Currently, we only add RVV_32/RVV_64/RVV_128, we may need to
205 support other values in the future. */
206enum vlen_enum
207{
208 RVV_32 = 32,
209 RVV_64 = 64,
210 RVV_65536 = 65536
211};
212bool slide1_sew64_helper (int, machine_mode, machine_mode,
213 machine_mode, rtx *);
db4f7a9b 214rtx gen_avl_for_scalar_move (rtx);
7d935cdd
JZZ
215}
216
cbd50570
JZZ
217/* We classify builtin types into two classes:
218 1. General builtin class which is defined in riscv_builtins.
219 2. Vector builtin class which is a special builtin architecture
220 that implement intrinsic short into "pragma". */
221enum riscv_builtin_class
222{
223 RISCV_BUILTIN_GENERAL,
224 RISCV_BUILTIN_VECTOR
225};
226
227const unsigned int RISCV_BUILTIN_SHIFT = 1;
228
229/* Mask that selects the riscv_builtin_class part of a function code. */
230const unsigned int RISCV_BUILTIN_CLASS = (1 << RISCV_BUILTIN_SHIFT) - 1;
231
02fcaf41
CM
232/* Routines implemented in thead.cc. */
233extern bool th_mempair_operands_p (rtx[4], bool, machine_mode);
234extern void th_mempair_order_operands (rtx[4], bool, machine_mode);
235extern void th_mempair_prepare_save_restore_operands (rtx[4], bool,
236 machine_mode,
237 int, HOST_WIDE_INT,
238 int, HOST_WIDE_INT);
239extern void th_mempair_save_restore_regs (rtx[4], bool, machine_mode);
240#ifdef RTX_CODE
241extern const char*
242th_mempair_output_move (rtx[4], bool, machine_mode, RTX_CODE);
243#endif
244
065be0ff 245extern bool riscv_use_divmod_expander (void);
09cae750 246#endif /* ! GCC_RISCV_PROTOS_H */