| 1 |
/* Prototypes of target machine for GNU compiler. LoongArch version. |
| 2 |
Copyright (C) 2021-2025 Free Software Foundation, Inc. |
| 3 |
Contributed by Loongson Ltd. |
| 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_LOONGARCH_PROTOS_H |
| 23 |
#define GCC_LOONGARCH_PROTOS_H |
| 24 |
|
| 25 |
/* Classifies a SYMBOL_REF, LABEL_REF or UNSPEC address. |
| 26 |
|
| 27 |
SYMBOL_GOT_DISP |
| 28 |
The symbol's value will be loaded directly from the GOT. |
| 29 |
|
| 30 |
SYMBOL_PCREL |
| 31 |
The symbol's value will be loaded directly from data section within |
| 32 |
+/- 2GiB range. |
| 33 |
|
| 34 |
SYMBOL_PCREL64 |
| 35 |
The symbol's value will be loaded directly from data section within |
| 36 |
+/- 8EiB range. |
| 37 |
|
| 38 |
SYMBOL_TLS |
| 39 |
A thread-local symbol. |
| 40 |
|
| 41 |
SYMBOL_TLS_IE |
| 42 |
SYMBOL_TLSGD |
| 43 |
SYMBOL_TLSLDM |
| 44 |
UNSPEC wrappers around SYMBOL_TLS, corresponding to the |
| 45 |
thread-local storage relocation operators. |
| 46 |
*/ |
| 47 |
enum loongarch_symbol_type { |
| 48 |
SYMBOL_GOT_DISP, |
| 49 |
SYMBOL_PCREL, |
| 50 |
SYMBOL_PCREL64, |
| 51 |
SYMBOL_TLS, |
| 52 |
SYMBOL_TLS_IE, |
| 53 |
SYMBOL_TLS_LE, |
| 54 |
SYMBOL_TLSGD, |
| 55 |
SYMBOL_TLSLDM, |
| 56 |
}; |
| 57 |
#define NUM_SYMBOL_TYPES (SYMBOL_TLSLDM + 1) |
| 58 |
|
| 59 |
/* Routines implemented in loongarch.cc. */ |
| 60 |
extern rtx loongarch_emit_move (rtx, rtx); |
| 61 |
extern HOST_WIDE_INT loongarch_initial_elimination_offset (int, int); |
| 62 |
extern void loongarch_expand_prologue (void); |
| 63 |
extern void loongarch_expand_epilogue (int); |
| 64 |
extern bool loongarch_can_use_return_insn (void); |
| 65 |
|
| 66 |
extern bool loongarch_symbolic_constant_p (rtx, enum loongarch_symbol_type *); |
| 67 |
extern int loongarch_regno_mode_ok_for_base_p (int, machine_mode, bool); |
| 68 |
extern int loongarch_address_insns (rtx, machine_mode, bool); |
| 69 |
extern int loongarch_const_insns (rtx); |
| 70 |
extern int loongarch_split_const_insns (rtx); |
| 71 |
extern int loongarch_split_128bit_const_insns (rtx); |
| 72 |
extern int loongarch_load_store_insns (rtx, rtx_insn *); |
| 73 |
extern int loongarch_idiv_insns (machine_mode); |
| 74 |
#ifdef RTX_CODE |
| 75 |
extern void loongarch_emit_binary (enum rtx_code, rtx, rtx, rtx); |
| 76 |
#endif |
| 77 |
extern rtx loongarch_unspec_address (rtx, enum loongarch_symbol_type); |
| 78 |
extern rtx loongarch_strip_unspec_address (rtx); |
| 79 |
extern void loongarch_move_integer (rtx, rtx, unsigned HOST_WIDE_INT); |
| 80 |
extern bool loongarch_legitimize_move (machine_mode, rtx, rtx); |
| 81 |
extern rtx loongarch_legitimize_call_address (rtx); |
| 82 |
|
| 83 |
extern rtx loongarch_subword (rtx, bool); |
| 84 |
extern bool loongarch_split_move_p (rtx, rtx); |
| 85 |
extern void loongarch_split_move (rtx, rtx); |
| 86 |
extern bool loongarch_addu16i_imm12_operand_p (HOST_WIDE_INT, machine_mode); |
| 87 |
extern void loongarch_split_plus_constant (rtx *, machine_mode); |
| 88 |
extern rtx loongarch_reassoc_shift_bitwise (bool is_and, rtx shamt, |
| 89 |
rtx mask, machine_mode mode); |
| 90 |
extern void loongarch_split_vector_move (rtx, rtx); |
| 91 |
extern const char *loongarch_output_move (rtx *); |
| 92 |
#ifdef RTX_CODE |
| 93 |
extern void loongarch_expand_scc (rtx *); |
| 94 |
extern void loongarch_expand_vec_cmp (rtx *); |
| 95 |
extern void loongarch_expand_conditional_branch (rtx *); |
| 96 |
extern void loongarch_expand_conditional_move (rtx *); |
| 97 |
extern void loongarch_expand_conditional_trap (rtx); |
| 98 |
#endif |
| 99 |
extern void loongarch_set_return_address (rtx, rtx); |
| 100 |
extern bool loongarch_move_by_pieces_p (unsigned HOST_WIDE_INT, unsigned int); |
| 101 |
extern bool loongarch_expand_block_move (rtx, rtx, rtx, rtx); |
| 102 |
extern bool loongarch_do_optimize_block_move_p (void); |
| 103 |
|
| 104 |
extern bool loongarch_expand_ext_as_unaligned_load (rtx, rtx, HOST_WIDE_INT, |
| 105 |
HOST_WIDE_INT, bool); |
| 106 |
extern bool loongarch_expand_ins_as_unaligned_store (rtx, rtx, HOST_WIDE_INT, |
| 107 |
HOST_WIDE_INT); |
| 108 |
extern HOST_WIDE_INT loongarch_debugger_offset (rtx, HOST_WIDE_INT); |
| 109 |
|
| 110 |
extern void loongarch_output_external (FILE *, tree, const char *); |
| 111 |
extern void loongarch_output_ascii (FILE *, const char *, size_t); |
| 112 |
extern bool loongarch_small_data_pattern_p (rtx); |
| 113 |
extern rtx loongarch_rewrite_small_data (rtx); |
| 114 |
extern rtx loongarch_return_addr (int, rtx); |
| 115 |
|
| 116 |
extern bool loongarch_const_vector_same_val_p (rtx, machine_mode); |
| 117 |
extern bool loongarch_const_vector_same_bytes_p (rtx, machine_mode); |
| 118 |
extern bool loongarch_const_vector_same_int_p (rtx, machine_mode, |
| 119 |
HOST_WIDE_INT low = HOST_WIDE_INT_MIN, |
| 120 |
HOST_WIDE_INT high = HOST_WIDE_INT_MAX); |
| 121 |
extern bool loongarch_const_vector_shuffle_set_p (rtx, machine_mode); |
| 122 |
extern bool loongarch_const_vector_bitimm_set_p (rtx, machine_mode); |
| 123 |
extern bool loongarch_const_vector_bitimm_clr_p (rtx, machine_mode); |
| 124 |
extern rtx loongarch_const_vector_vrepli (rtx, machine_mode); |
| 125 |
extern rtx loongarch_lsx_vec_parallel_const_half (machine_mode, bool); |
| 126 |
extern rtx loongarch_gen_const_int_vector (machine_mode, HOST_WIDE_INT); |
| 127 |
extern enum reg_class loongarch_secondary_reload_class (enum reg_class, |
| 128 |
machine_mode, |
| 129 |
rtx, bool); |
| 130 |
extern int loongarch_class_max_nregs (enum reg_class, machine_mode); |
| 131 |
|
| 132 |
extern machine_mode loongarch_hard_regno_caller_save_mode (unsigned int, |
| 133 |
unsigned int, |
| 134 |
machine_mode); |
| 135 |
extern const char *loongarch_output_conditional_branch (rtx_insn *, rtx *, |
| 136 |
const char *, |
| 137 |
const char *); |
| 138 |
extern const char *loongarch_output_order_conditional_branch (rtx_insn *, |
| 139 |
rtx *, |
| 140 |
bool); |
| 141 |
extern const char *loongarch_output_equal_conditional_branch (rtx_insn *, |
| 142 |
rtx *, |
| 143 |
bool); |
| 144 |
extern const char *loongarch_output_division (const char *, rtx *); |
| 145 |
extern const char *loongarch_lsx_output_division (const char *, rtx *); |
| 146 |
extern const char *loongarch_output_probe_stack_range (rtx, rtx, rtx); |
| 147 |
extern bool loongarch_hard_regno_rename_ok (unsigned int, unsigned int); |
| 148 |
extern int loongarch_dspalu_bypass_p (rtx, rtx); |
| 149 |
extern rtx loongarch_prefetch_cookie (rtx, rtx); |
| 150 |
|
| 151 |
extern bool loongarch_global_symbol_p (const_rtx); |
| 152 |
extern bool loongarch_global_symbol_noweak_p (const_rtx); |
| 153 |
extern bool loongarch_weak_symbol_p (const_rtx); |
| 154 |
extern bool loongarch_symbol_binds_local_p (const_rtx); |
| 155 |
|
| 156 |
extern unsigned int current_section_flags (void); |
| 157 |
extern bool loongarch_use_ins_ext_p (rtx, HOST_WIDE_INT, HOST_WIDE_INT); |
| 158 |
extern bool loongarch_check_zero_div_p (void); |
| 159 |
extern bool loongarch_pre_reload_split (void); |
| 160 |
extern int loongarch_use_bstrins_for_ior_with_mask (machine_mode, rtx *); |
| 161 |
extern rtx loongarch_rewrite_mem_for_simple_ldst (rtx); |
| 162 |
|
| 163 |
union loongarch_gen_fn_ptrs |
| 164 |
{ |
| 165 |
rtx (*fn_8) (rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx); |
| 166 |
rtx (*fn_7) (rtx, rtx, rtx, rtx, rtx, rtx, rtx); |
| 167 |
rtx (*fn_6) (rtx, rtx, rtx, rtx, rtx, rtx); |
| 168 |
rtx (*fn_5) (rtx, rtx, rtx, rtx, rtx); |
| 169 |
rtx (*fn_4) (rtx, rtx, rtx, rtx); |
| 170 |
}; |
| 171 |
|
| 172 |
extern void loongarch_expand_atomic_qihi (union loongarch_gen_fn_ptrs, |
| 173 |
rtx, rtx, rtx, rtx, rtx); |
| 174 |
|
| 175 |
extern void loongarch_expand_vector_group_init (rtx, rtx); |
| 176 |
extern void loongarch_expand_vector_init (rtx, rtx); |
| 177 |
extern void loongarch_expand_vec_unpack (rtx op[2], bool); |
| 178 |
extern void loongarch_expand_vec_perm (rtx, rtx, rtx, rtx); |
| 179 |
extern void loongarch_expand_vec_perm_1 (rtx[]); |
| 180 |
extern void loongarch_expand_vector_extract (rtx, rtx, int); |
| 181 |
extern void loongarch_expand_vector_reduc (rtx (*)(rtx, rtx, rtx), rtx, rtx); |
| 182 |
|
| 183 |
extern int loongarch_ldst_scaled_shift (machine_mode); |
| 184 |
extern bool loongarch_signed_immediate_p (unsigned HOST_WIDE_INT, int, int); |
| 185 |
extern bool loongarch_unsigned_immediate_p (unsigned HOST_WIDE_INT, int, int); |
| 186 |
extern bool loongarch_12bit_offset_address_p (rtx, machine_mode); |
| 187 |
extern bool loongarch_14bit_shifted_offset_address_p (rtx, machine_mode); |
| 188 |
extern bool loongarch_base_index_address_p (rtx, machine_mode); |
| 189 |
extern rtx loongarch_expand_thread_pointer (rtx); |
| 190 |
|
| 191 |
extern bool loongarch_eh_uses (unsigned int); |
| 192 |
extern bool loongarch_epilogue_uses (unsigned int); |
| 193 |
extern bool loongarch_load_store_bonding_p (rtx *, machine_mode, bool); |
| 194 |
extern bool loongarch_split_symbol_type (enum loongarch_symbol_type); |
| 195 |
|
| 196 |
extern void loongarch_register_frame_header_opt (void); |
| 197 |
extern void loongarch_expand_vec_cond_expr (machine_mode, machine_mode, rtx *); |
| 198 |
extern void loongarch_expand_vec_cond_mask_expr (machine_mode, machine_mode, |
| 199 |
rtx *); |
| 200 |
extern void loongarch_expand_vec_widen_hilo (rtx, rtx, rtx, bool, bool, const char *); |
| 201 |
|
| 202 |
/* Routines implemented in loongarch-c.c. */ |
| 203 |
void loongarch_cpu_cpp_builtins (cpp_reader *); |
| 204 |
|
| 205 |
extern void loongarch_init_builtins (void); |
| 206 |
extern void loongarch_atomic_assign_expand_fenv (tree *, tree *, tree *); |
| 207 |
extern tree loongarch_builtin_decl (unsigned int, bool); |
| 208 |
extern rtx loongarch_expand_builtin (tree, rtx, rtx subtarget ATTRIBUTE_UNUSED, |
| 209 |
machine_mode, int); |
| 210 |
extern rtx loongarch_gen_const_int_vector_shuffle (machine_mode, int); |
| 211 |
extern tree loongarch_build_builtin_va_list (void); |
| 212 |
|
| 213 |
extern rtx loongarch_build_signbit_mask (machine_mode, bool, bool); |
| 214 |
extern void loongarch_emit_swrsqrtsf (rtx, rtx, machine_mode, bool); |
| 215 |
extern void loongarch_emit_swdivsf (rtx, rtx, rtx, machine_mode); |
| 216 |
extern bool loongarch_explicit_relocs_p (enum loongarch_symbol_type); |
| 217 |
extern bool loongarch_symbol_extreme_p (enum loongarch_symbol_type); |
| 218 |
extern bool loongarch_option_valid_attribute_p (tree, tree, tree, int); |
| 219 |
extern void loongarch_option_override_internal (struct loongarch_target *, struct gcc_options *, struct gcc_options *); |
| 220 |
extern void loongarch_reset_previous_fndecl (void); |
| 221 |
extern void loongarch_save_restore_target_globals (tree new_tree); |
| 222 |
extern void loongarch_register_pragmas (void); |
| 223 |
extern bool loongarch_process_target_attr (tree args, tree fndecl); |
| 224 |
extern rtx loongarch_gen_stepped_int_parallel (unsigned int nelts, int base, |
| 225 |
int step); |
| 226 |
extern void loongarch_output_asm_load_canary (rtx reg, rtx canary, rtx tmp); |
| 227 |
#endif /* ! GCC_LOONGARCH_PROTOS_H */ |