1 /* Definitions for loongarch-specific option handling. 2 Copyright (C) 2021-2024 Free Software Foundation, Inc. 3 Contributed by Loongson Ltd. 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 3, or (at your option) 10 any later version. 11 12 GCC is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GCC; see the file COPYING3. If not see 19 <http://www.gnu.org/licenses/>. */ 20 21 #ifndef LOONGARCH_OPTS_H 22 #define LOONGARCH_OPTS_H 23 24 /* The loongarch-def.h file is a C++ header and it shouldn't be used by 25 target libraries. Exclude it and everything using the C++ structs 26 (struct loongarch_target and gcc_options) from target libraries. */ 27 #if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS) && !defined(IN_RTS) 28 #include "loongarch-def.h" 29 30 /* Target configuration */ 31 extern struct loongarch_target la_target; 32 33 /* RTL cost information */ 34 extern const struct loongarch_rtx_cost_data *loongarch_cost; 35 36 37 /* Initialize loongarch_target from separate option variables. */ 38 void 39 loongarch_init_target (struct loongarch_target *target, 40 int cpu_arch, int cpu_tune, int fpu, int simd, 41 int abi_base, int abi_ext, int cmodel, 42 int tls_dialect, 43 HOST_WIDE_INT isa_evolutions, 44 HOST_WIDE_INT isa_evolutions_set); 45 46 47 /* Handler for "-m" option combinations, 48 shared by the driver and the compiler proper. */ 49 void 50 loongarch_config_target (struct loongarch_target *target, 51 struct loongarch_flags *flags, 52 int follow_multilib_list_p); 53 54 55 /* Refresh the switches acccording to the resolved loongarch_target struct. */ 56 void 57 loongarch_target_option_override (struct loongarch_target *target, 58 struct gcc_options *opts, 59 struct gcc_options *opts_set); 60 61 62 /* option status feedback for "gcc --help=target -Q" */ 63 void 64 loongarch_update_gcc_opt_status (struct loongarch_target *target, 65 struct gcc_options *opts, 66 struct gcc_options *opts_set); 67 68 69 /* Parser for -mrecip=<recip_string>. */ 70 unsigned int 71 loongarch_parse_mrecip_scheme (const char *recip_string); 72 73 74 /* Resolve options that's not covered by la_target. */ 75 void 76 loongarch_init_misc_options (struct gcc_options *opts, 77 struct gcc_options *opts_set); 78 #endif 79 80 /* Flag status */ 81 struct loongarch_flags { 82 int flt; const char* flt_str; 83 #define SX_FLAG_TYPE(x) ((x) < 0 ? -(x) : (x)) 84 int sx[2]; 85 }; 86 87 /* Macros for common conditional expressions used in loongarch.{c,h,md} */ 88 #define TARGET_CMODEL_NORMAL (la_target.cmodel == CMODEL_NORMAL) 89 #define TARGET_CMODEL_TINY (la_target.cmodel == CMODEL_TINY) 90 #define TARGET_CMODEL_TINY_STATIC (la_target.cmodel == CMODEL_TINY_STATIC) 91 #define TARGET_CMODEL_MEDIUM (la_target.cmodel == CMODEL_MEDIUM) 92 #define TARGET_CMODEL_LARGE (la_target.cmodel == CMODEL_LARGE) 93 #define TARGET_CMODEL_EXTREME (la_target.cmodel == CMODEL_EXTREME) 94 95 #define TARGET_HARD_FLOAT (la_target.isa.fpu != ISA_EXT_NONE) 96 #define TARGET_HARD_FLOAT_ABI (la_target.abi.base == ABI_BASE_LP64D \ 97 || la_target.abi.base == ABI_BASE_LP64F) 98 99 #define TARGET_SOFT_FLOAT (la_target.isa.fpu == ISA_EXT_NONE) 100 #define TARGET_SOFT_FLOAT_ABI (la_target.abi.base == ABI_BASE_LP64S) 101 #define TARGET_SINGLE_FLOAT (la_target.isa.fpu == ISA_EXT_FPU32) 102 #define TARGET_SINGLE_FLOAT_ABI (la_target.abi.base == ABI_BASE_LP64F) 103 #define TARGET_DOUBLE_FLOAT (la_target.isa.fpu == ISA_EXT_FPU64) 104 #define TARGET_DOUBLE_FLOAT_ABI (la_target.abi.base == ABI_BASE_LP64D) 105 106 #define TARGET_64BIT (la_target.isa.base == ISA_BASE_LA64) 107 #define TARGET_ABI_LP64 ABI_LP64_P(la_target.abi.base) 108 109 #define TARGET_TLS_DESC (la_target.tls_dialect == TLS_DESCRIPTORS) 110 111 #define ISA_HAS_LSX \ 112 (la_target.isa.simd == ISA_EXT_SIMD_LSX \ 113 || la_target.isa.simd == ISA_EXT_SIMD_LASX) 114 115 #define ISA_HAS_LASX \ 116 (la_target.isa.simd == ISA_EXT_SIMD_LASX) 117 118 /* TARGET_ macros for use in *.md template conditionals */ 119 #define TARGET_uARCH_LA464 (la_target.cpu_tune == TUNE_LA464) 120 #define TARGET_uARCH_LA664 (la_target.cpu_tune == TUNE_LA664) 121 122 /* Note: optimize_size may vary across functions, 123 while -m[no]-memcpy imposes a global constraint. */ 124 #define TARGET_DO_OPTIMIZE_BLOCK_MOVE_P loongarch_do_optimize_block_move_p() 125 126 #ifndef HAVE_AS_EXPLICIT_RELOCS 127 #define HAVE_AS_EXPLICIT_RELOCS 0 128 #endif 129 130 #ifndef HAVE_AS_SUPPORT_CALL36 131 #define HAVE_AS_SUPPORT_CALL36 0 132 #endif 133 134 #ifndef HAVE_AS_MRELAX_OPTION 135 #define HAVE_AS_MRELAX_OPTION 0 136 #endif 137 138 #ifndef HAVE_AS_COND_BRANCH_RELAXATION 139 #define HAVE_AS_COND_BRANCH_RELAXATION 0 140 #endif 141 142 #ifndef HAVE_AS_TLS 143 #define HAVE_AS_TLS 0 144 #endif 145 146 #ifndef HAVE_AS_TLS_LE_RELAXATION 147 #define HAVE_AS_TLS_LE_RELAXATION 0 148 #endif 149 150 #endif /* LOONGARCH_OPTS_H */ 151