]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/rs6000/rs6000-protos.h
rs6000: Splat vector small V2DI constants with vspltisw and vupkhsw
[thirdparty/gcc.git] / gcc / config / rs6000 / rs6000-protos.h
CommitLineData
9ebbca7d 1/* Definitions of target machine for GNU compiler, for IBM RS/6000.
83ffe9cd 2 Copyright (C) 2000-2023 Free Software Foundation, Inc.
9ebbca7d
GK
3 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
4
5de601cf 5 This file is part of GCC.
9ebbca7d 6
5de601cf
NC
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
2f83c7d6 9 by the Free Software Foundation; either version 3, or (at your
5de601cf 10 option) any later version.
9ebbca7d 11
5de601cf
NC
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
9ebbca7d 16
5de601cf 17 You should have received a copy of the GNU General Public License
2f83c7d6
NC
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
9ebbca7d 20
a5c76ee6
ZW
21#ifndef GCC_RS6000_PROTOS_H
22#define GCC_RS6000_PROTOS_H
23
e53b6e56 24/* Declare functions in rs6000.cc */
9ebbca7d
GK
25
26#ifdef RTX_CODE
27
28#ifdef TREE_CODE
617718f7 29extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, int, int, int,
ef4bddc2 30 tree, machine_mode);
9ebbca7d
GK
31#endif /* TREE_CODE */
32
e0e82856 33extern int easy_altivec_constant (rtx, machine_mode);
50c78b9a 34extern bool xxspltib_constant_p (rtx, machine_mode, int *, int *);
f3d87219 35extern bool vspltisw_vupkhsw_constant_p (rtx, machine_mode, int * = nullptr);
683be46f 36extern int vspltis_shifted (rtx);
847535b6 37extern HOST_WIDE_INT const_vector_elt_as_int (rtx, unsigned int);
ef4bddc2 38extern bool macho_lo_sum_memory_operand (rtx, machine_mode);
1060cd2a
JG
39extern bool can_be_rotated_to_lowbits (unsigned HOST_WIDE_INT, int, int *);
40extern bool can_be_rotated_to_positive_16bits (HOST_WIDE_INT);
41extern bool can_be_rotated_to_negative_15bits (HOST_WIDE_INT);
ef4bddc2 42extern int num_insns_constant (rtx, machine_mode);
ef4bddc2
RS
43extern int small_data_operand (rtx, machine_mode);
44extern bool mem_operand_gpr (rtx, machine_mode);
ad69178c 45extern bool mem_operand_ds_form (rtx, machine_mode);
f990f3a3 46extern bool toc_relative_expr_p (const_rtx, bool, const_rtx *, const_rtx *);
ef4bddc2
RS
47extern void validate_condition_mode (enum rtx_code, machine_mode);
48extern bool legitimate_constant_pool_address_p (const_rtx, machine_mode,
77b0791e 49 bool);
48d72335 50extern bool legitimate_indirect_address_p (rtx, int);
6fb5fa3c 51extern bool legitimate_indexed_address_p (rtx, int);
ef4bddc2 52extern bool avoiding_indexed_address_p (machine_mode);
320314db 53extern rtx rs6000_force_indexed_or_indirect_mem (rtx x);
48d72335 54
9390387d
AM
55extern rtx rs6000_got_register (rtx);
56extern rtx find_addr_reg (rtx);
66180ff3 57extern rtx gen_easy_altivec_constant (rtx);
a2369ed3 58extern const char *output_vec_const_move (rtx *);
19be72ab 59extern const char *rs6000_output_move_128bit (rtx *);
a16a872d
MM
60extern bool rs6000_move_128bit_ok_p (rtx []);
61extern bool rs6000_split_128bit_ok_p (rtx []);
526303ec 62extern void rs6000_expand_float128_convert (rtx, rtx, bool);
7a4eca66 63extern void rs6000_expand_vector_init (rtx, rtx);
5e9f814d 64extern void rs6000_expand_vector_set (rtx, rtx, rtx);
98060bbe 65extern void rs6000_expand_vector_extract (rtx, rtx, rtx);
e0d32185 66extern void rs6000_split_vec_extract_var (rtx, rtx, rtx, rtx, rtx);
d0047a25 67extern rtx rs6000_adjust_vec_address (rtx, rtx, rtx, rtx, machine_mode);
f200869a 68extern void altivec_expand_vec_perm_le (rtx op[4]);
5aebfdad
RH
69extern void rs6000_expand_extract_even (rtx, rtx, rtx);
70extern void rs6000_expand_interleave (rtx, rtx, rtx, bool);
70f0f8b2 71extern void rs6000_scale_v2df (rtx, rtx, int);
be1418c7 72extern void rs6000_generate_float2_code (bool, rtx, rtx, rtx);
19d22f7c 73extern void rs6000_generate_float2_double_code (rtx, rtx, rtx);
e5898daf 74extern void rs6000_generate_vsigned2_code (bool, rtx, rtx, rtx);
fba73eb1 75extern int expand_block_clear (rtx[]);
c8241327 76extern int expand_block_move (rtx[], bool);
9f38dde2 77extern bool expand_block_compare (rtx[]);
0edd264d 78extern bool expand_strn_compare (rtx[], int);
7fc5cca3 79extern bool rs6000_is_valid_mask (rtx, int *, int *, machine_mode);
19d81fda 80extern bool rs6000_is_valid_rotate_dot_mask (rtx mask, machine_mode mode);
7fc5cca3
SB
81extern bool rs6000_is_valid_and_mask (rtx, machine_mode);
82extern bool rs6000_is_valid_shift_mask (rtx, rtx, machine_mode);
83extern bool rs6000_is_valid_insert_mask (rtx, rtx, machine_mode);
84extern const char *rs6000_insn_for_and_mask (machine_mode, rtx *, bool);
85extern const char *rs6000_insn_for_shift_mask (machine_mode, rtx *, bool);
86extern const char *rs6000_insn_for_insert_mask (machine_mode, rtx *, bool);
87extern bool rs6000_is_valid_2insn_and (rtx, machine_mode);
a34f4f64 88extern void rs6000_emit_2insn_and (machine_mode, rtx *, bool, int);
a2369ed3 89extern int registers_ok_for_quad_peep (rtx, rtx);
90f81f99 90extern int mems_ok_for_quad_peep (rtx, rtx);
3a1f863f 91extern bool gpr_or_gpr_p (rtx, rtx);
19be72ab 92extern bool direct_move_p (rtx, rtx);
3fd2b007 93extern bool quad_address_p (rtx, machine_mode, bool);
19be72ab 94extern bool quad_load_store_p (rtx, rtx);
3f99b061 95extern bool fusion_gpr_load_p (rtx, rtx, rtx, rtx);
f758f299 96extern void expand_fusion_gpr_load (rtx *);
0bcd172e 97extern void emit_fusion_addis (rtx, rtx);
3f99b061 98extern const char *emit_fusion_gpr_load (rtx, rtx);
8beb65e3
MM
99extern enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx,
100 enum reg_class);
101extern enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class,
ef4bddc2 102 machine_mode,
8beb65e3 103 rtx);
8beb65e3 104extern void rs6000_secondary_reload_inner (rtx, rtx, rtx, bool);
d32d6b75 105extern void rs6000_secondary_reload_gpr (rtx, rtx, rtx, bool);
e2e95f45
RE
106
107
a2369ed3 108extern int ccr_bit (rtx, int);
85b776df 109extern void rs6000_output_function_entry (FILE *, const char *);
a2369ed3
DJ
110extern void print_operand (FILE *, rtx, int);
111extern void print_operand_address (FILE *, rtx);
ece3bca2
AM
112extern const char *rs6000_call_template (rtx *, unsigned int);
113extern const char *rs6000_sibcall_template (rtx *, unsigned int);
ce83eeda
AM
114extern const char *rs6000_indirect_call_template (rtx *, unsigned int);
115extern const char *rs6000_indirect_sibcall_template (rtx *, unsigned int);
3f79c0ad 116extern const char *rs6000_pltseq_template (rtx *, int);
ef4bddc2 117extern enum rtx_code rs6000_reverse_condition (machine_mode,
3a1f863f 118 enum rtx_code);
a935964d 119extern rtx rs6000_emit_eqne (machine_mode, rtx, rtx, rtx);
eb548534 120extern rtx rs6000_emit_fp_cror (rtx_code, machine_mode, rtx);
ef4bddc2
RS
121extern void rs6000_emit_sCOND (machine_mode, rtx[]);
122extern void rs6000_emit_cbranch (machine_mode, rtx[]);
e64e631b 123extern char * output_cbranch (rtx, const char *, int, rtx_insn *);
af2c8a96 124extern const char * output_probe_stack_range (rtx, rtx, rtx);
8845cb37 125extern void rs6000_emit_dot_insn (rtx dst, rtx src, int dot, rtx ccreg);
bfe51f42 126extern bool rs6000_emit_set_const (rtx, rtx);
aa53f657
MM
127extern bool rs6000_emit_cmove (rtx, rtx, rtx, rtx);
128extern bool rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
21213b4c 129extern int rs6000_emit_vector_cond_expr (rtx, rtx, rtx, rtx, rtx, rtx);
a2369ed3 130extern void rs6000_emit_minmax (rtx, enum rtx_code, rtx, rtx);
2747a046 131extern void rs6000_expand_atomic_compare_and_swap (rtx op[]);
fc504349
CL
132extern rtx swap_endian_selector_for_mode (machine_mode mode);
133
2747a046
RH
134extern void rs6000_expand_atomic_exchange (rtx op[]);
135extern void rs6000_expand_atomic_op (enum rtx_code, rtx, rtx, rtx, rtx, rtx);
92902797 136extern void rs6000_emit_swdiv (rtx, rtx, rtx, bool);
4f0055bd 137extern void rs6000_emit_swsqrt (rtx, rtx, bool);
ef4bddc2 138extern void output_toc (FILE *, rtx, int, machine_mode);
a2369ed3 139extern void rs6000_fatal_bad_address (rtx);
070b27da 140extern rtx create_TOC_reference (rtx, rtx);
a9baceb1 141extern void rs6000_split_multireg_move (rtx, rtx);
02d3ba0e 142extern void rs6000_emit_le_vsx_permute (rtx, rtx, machine_mode);
ef4bddc2 143extern void rs6000_emit_le_vsx_move (rtx, rtx, machine_mode);
fba4b861 144extern bool valid_sf_si_move (rtx, rtx, machine_mode);
ef4bddc2 145extern void rs6000_emit_move (rtx, rtx, machine_mode);
ef4bddc2 146extern bool rs6000_legitimate_offset_address_p (machine_mode, rtx,
d32d6b75 147 bool, bool);
944258eb 148extern rtx rs6000_find_base_term (rtx);
a2369ed3
DJ
149extern rtx rs6000_return_addr (int, rtx);
150extern void rs6000_output_symbol_ref (FILE*, rtx);
d1d0c603 151extern HOST_WIDE_INT rs6000_initial_elimination_offset (int, int);
565ef4ba
RS
152extern void rs6000_emit_popcount (rtx, rtx);
153extern void rs6000_emit_parity (rtx, rtx);
a2369ed3 154
ef4bddc2 155extern rtx rs6000_machopic_legitimize_pic_address (rtx, machine_mode,
fa5b0972 156 rtx);
ef4bddc2 157extern rtx rs6000_allocate_stack_temp (machine_mode, bool, bool);
e6de5335 158extern align_flags rs6000_loop_align (rtx);
44c3a8bb 159extern void rs6000_split_logical (rtx [], enum rtx_code, bool, bool, bool);
8c0f8755
BS
160extern bool rs6000_function_pcrel_p (struct function *);
161extern bool rs6000_pcrel_p (void);
91117603 162extern bool rs6000_fndecl_pcrel_p (const_tree);
3493b0c3 163extern void rs6000_output_addr_vec_elt (FILE *, int);
26ca7d1b
MM
164
165/* Different PowerPC instruction formats that are used by GCC. There are
166 various other instruction formats used by the PowerPC hardware, but these
167 formats are not currently used by GCC. */
168
169enum insn_form {
170 INSN_FORM_BAD, /* Bad instruction format. */
171 INSN_FORM_BASE_REG, /* Base register only. */
172 INSN_FORM_D, /* Reg + 16-bit numeric offset. */
173 INSN_FORM_DS, /* Reg + offset, bottom 2 bits must be 0. */
174 INSN_FORM_DQ, /* Reg + offset, bottom 4 bits must be 0. */
175 INSN_FORM_X, /* Base register + index register. */
176 INSN_FORM_UPDATE, /* Address updates base register. */
177 INSN_FORM_LO_SUM, /* Reg + offset using symbol. */
178 INSN_FORM_PREFIXED_NUMERIC, /* Reg + 34 bit numeric offset. */
179 INSN_FORM_PCREL_LOCAL, /* PC-relative local symbol. */
180 INSN_FORM_PCREL_EXTERNAL /* PC-relative external symbol. */
181};
182
183/* Instruction format for the non-prefixed version of a load or store. This is
184 used to determine if a 16-bit offset is valid to be used with a non-prefixed
185 (traditional) instruction or if the bottom bits of the offset cannot be used
186 with a DS or DQ instruction format, and GCC has to use a prefixed
187 instruction for the load or store. */
188
189enum non_prefixed_form {
190 NON_PREFIXED_DEFAULT, /* Use the default. */
191 NON_PREFIXED_D, /* All 16-bits are valid. */
192 NON_PREFIXED_DS, /* Bottom 2 bits must be 0. */
193 NON_PREFIXED_DQ, /* Bottom 4 bits must be 0. */
194 NON_PREFIXED_X /* No offset memory form exists. */
195};
196
197extern enum insn_form address_to_insn_form (rtx, machine_mode,
198 enum non_prefixed_form);
7a279bed
AS
199extern bool address_is_non_pfx_d_or_x (rtx addr, machine_mode mode,
200 enum non_prefixed_form non_prefix_format);
b8d85f56
AS
201extern bool pcrel_opt_valid_mem_p (rtx, machine_mode, rtx);
202enum non_prefixed_form reg_to_non_prefixed (rtx reg, machine_mode mode);
26ca7d1b
MM
203extern bool prefixed_load_p (rtx_insn *);
204extern bool prefixed_store_p (rtx_insn *);
205extern bool prefixed_paddi_p (rtx_insn *);
206extern void rs6000_asm_output_opcode (FILE *);
b8d85f56 207extern void output_pcrel_opt_reloc (rtx);
26ca7d1b 208extern void rs6000_final_prescan_insn (rtx_insn *, rtx [], int);
ca06b86c 209extern int rs6000_adjust_insn_length (rtx_insn *, int);
26ca7d1b
MM
210
211/* Return true if the address can be used for a prefixed load, store, or add
212 immediate instructions that cannot be used with a non-prefixed instruction.
213 For example, using a numeric offset that is not valid for the non-prefixed
214 instruction or a PC-relative reference to a local symbol would return true,
215 but an address with an offset of 64 would not return true.
216
217 References to external PC-relative symbols aren't allowed, because GCC has
218 to load the address into a register and then issue a separate load or
219 store. */
220
221static inline bool
222address_is_prefixed (rtx addr,
223 machine_mode mode,
224 enum non_prefixed_form non_prefixed)
225{
226 enum insn_form iform = address_to_insn_form (addr, mode, non_prefixed);
227 return (iform == INSN_FORM_PREFIXED_NUMERIC
228 || iform == INSN_FORM_PCREL_LOCAL);
229}
c6756b3b
MM
230
231/* Functions and data structures relating to 128-bit constants that are
232 converted to byte, half-word, word, and double-word values. All fields are
233 kept in big endian order. We also convert scalar values to 128-bits if they
234 are going to be loaded into vector registers. */
235#define VECTOR_128BIT_BITS 128
236#define VECTOR_128BIT_BYTES (128 / 8)
237#define VECTOR_128BIT_HALF_WORDS (128 / 16)
238#define VECTOR_128BIT_WORDS (128 / 32)
239#define VECTOR_128BIT_DOUBLE_WORDS (128 / 64)
240
241typedef struct {
242 /* Constant as various sized items. */
243 unsigned HOST_WIDE_INT double_words[VECTOR_128BIT_DOUBLE_WORDS];
244 unsigned int words[VECTOR_128BIT_WORDS];
245 unsigned short half_words[VECTOR_128BIT_HALF_WORDS];
246 unsigned char bytes[VECTOR_128BIT_BYTES];
247
248 unsigned original_size; /* Constant size before splat. */
249 bool fp_constant_p; /* Is the constant floating point? */
250 bool all_double_words_same; /* Are the double words all equal? */
251 bool all_words_same; /* Are the words all equal? */
252 bool all_half_words_same; /* Are the half words all equal? */
253 bool all_bytes_same; /* Are the bytes all equal? */
254} vec_const_128bit_type;
255
256extern bool vec_const_128bit_to_bytes (rtx, machine_mode,
257 vec_const_128bit_type *);
8ccd8b12 258extern unsigned constant_generates_lxvkq (vec_const_128bit_type *);
d730aa8a 259extern unsigned constant_generates_xxspltiw (vec_const_128bit_type *);
8d443ac0 260extern unsigned constant_generates_xxspltidp (vec_const_128bit_type *);
9ebbca7d
GK
261#endif /* RTX_CODE */
262
263#ifdef TREE_CODE
69eff9da 264extern unsigned int rs6000_data_alignment (tree, unsigned int, enum data_align);
42a21b4c 265extern unsigned int rs6000_special_adjust_field_align (tree, unsigned int);
fa5b0972
AM
266extern unsigned int rs6000_special_round_type_align (tree, unsigned int,
267 unsigned int);
58182de3
GK
268extern unsigned int darwin_rs6000_special_round_type_align (tree, unsigned int,
269 unsigned int);
4b29c5e5 270extern tree altivec_resolve_overloaded_builtin (location_t, tree, void *);
ef4bddc2 271extern rtx rs6000_libcall_value (machine_mode);
9390387d 272extern rtx rs6000_va_arg (tree, tree);
a2369ed3 273extern int function_ok_for_sibcall (tree);
ddbb449f 274extern int rs6000_reg_parm_stack_space (tree, bool);
8d91472f 275extern void rs6000_asm_weaken_decl (FILE *, tree, const char *, const char *);
b36e833f 276extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
9af46873 277extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
8d91472f
DE
278extern void rs6000_xcoff_asm_output_aligned_decl_common (FILE *, tree,
279 const char *,
280 unsigned HOST_WIDE_INT,
92f59e47 281 unsigned int);
a2369ed3 282extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
3101faab 283extern bool rs6000_elf_in_small_data_p (const_tree);
ee890fe2 284
9ebbca7d
GK
285#endif /* TREE_CODE */
286
a2369ed3 287extern int direct_return (void);
a2369ed3
DJ
288extern int first_reg_to_save (void);
289extern int first_fp_reg_to_save (void);
a2369ed3
DJ
290extern void output_ascii (FILE *, const char *, int);
291extern void rs6000_gen_section_name (char **, const char *, const char *);
292extern void output_function_profiler (FILE *, int);
293extern void output_profile_hook (int);
294extern int rs6000_trampoline_size (void);
4862826d 295extern alias_set_type get_TOC_alias_set (void);
a2369ed3
DJ
296extern void rs6000_emit_prologue (void);
297extern void rs6000_emit_load_toc_table (int);
ca60bd93 298extern unsigned int rs6000_debugger_regno (unsigned int, unsigned int);
a3d59ce9 299extern void rs6000_emit_epilogue (enum epilogue_type);
0f0fd745
AM
300extern void rs6000_expand_split_stack_prologue (void);
301extern void rs6000_split_stack_space_check (rtx, rtx);
d1d0c603 302extern void rs6000_emit_eh_reg_restore (rtx, rtx);
f90f960c
UW
303extern void rs6000_call_aix (rtx, rtx, rtx, rtx);
304extern void rs6000_sibcall_aix (rtx, rtx, rtx, rtx);
ece3bca2 305extern void rs6000_call_sysv (rtx, rtx, rtx, rtx);
3f79c0ad 306extern void rs6000_sibcall_sysv (rtx, rtx, rtx, rtx);
aa3a2eca
IS
307extern void rs6000_call_darwin (rtx, rtx, rtx, rtx);
308extern void rs6000_sibcall_darwin (rtx, rtx, rtx, rtx);
7e49a4b3 309extern void rs6000_aix_asm_output_dwarf_table_ref (char *);
be26142a 310extern void get_ppc476_thunk_name (char name[32]);
6ba86ba7 311extern int rs6000_store_data_bypass_p (rtx_insn *, rtx_insn *);
b85aed95 312extern HOST_WIDE_INT rs6000_builtin_mask_calculate (void);
e707a2dd
AD
313extern void rs6000_asm_output_dwarf_pcrel (FILE *file, int size,
314 const char *label);
315extern void rs6000_asm_output_dwarf_datarel (FILE *file, int size,
316 const char *label);
75913096 317extern long rs6000_const_f32_to_i32 (rtx operand);
7e49a4b3 318
e53b6e56 319/* Declare functions in rs6000-c.cc */
4c4eb375 320
a2369ed3
DJ
321extern void rs6000_pragma_longcall (struct cpp_reader *);
322extern void rs6000_cpu_cpp_builtins (struct cpp_reader *);
fd438373
MM
323#ifdef TREE_CODE
324extern bool rs6000_pragma_target_parse (tree, tree);
325#endif
20a7e14a 326extern void rs6000_activate_target_options (tree new_tree);
75841b04
WS
327extern void rs6000_target_modify_macros (bool, HOST_WIDE_INT);
328extern void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT);
a5c76ee6 329
ee06c6a5
DE
330#ifdef NO_DOLLAR_IN_LABEL
331const char * rs6000_xcoff_strip_dollar (const char *);
332#endif
333
cacf1ca8
MM
334extern unsigned char rs6000_class_max_nregs[][LIM_REG_CLASSES];
335extern unsigned char rs6000_hard_regno_nregs[][FIRST_PSEUDO_REGISTER];
9193fb05
JM
336
337extern bool rs6000_linux_float_exceptions_rounding_supported_p (void);
bd539c9b
JJ
338extern unsigned rs6000_linux_libm_function_max_error (unsigned, machine_mode,
339 bool);
5715e980
BS
340
341/* Pass management. */
342namespace gcc { class context; }
343class rtl_opt_pass;
344
345extern rtl_opt_pass *make_pass_analyze_swaps (gcc::context *);
b8d85f56 346extern rtl_opt_pass *make_pass_pcrel_opt (gcc::context *);
a3a821c9
KN
347extern bool rs6000_sum_of_two_registers_p (const_rtx expr);
348extern bool rs6000_quadword_masked_address_p (const_rtx exp);
349extern rtx rs6000_gen_lvx (enum machine_mode, rtx, rtx);
350extern rtx rs6000_gen_stvx (enum machine_mode, rtx, rtx);
5715e980 351
7f3b1997 352extern void rs6000_emit_xxspltidp_v2df (rtx, long value);
282462b3
KL
353extern gimple *currently_expanding_gimple_stmt;
354extern bool rs6000_opaque_type_invalid_use_p (gimple *);
a5c76ee6 355#endif /* rs6000-protos.h */