xref: /netbsd-src/external/gpl3/gcc/dist/gcc/config/loongarch/loongarch-opts.h (revision 0a3071956a3a9fdebdbf7f338cf2d439b45fc728)
1 /* Definitions for loongarch-specific option handling.
2    Copyright (C) 2021-2022 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 
25 /* Target configuration */
26 extern struct loongarch_target la_target;
27 
28 /* Switch masks */
29 extern const int loongarch_switch_mask[];
30 
31 #include "loongarch-def.h"
32 
33 #if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS) && !defined(IN_RTS)
34 /* Handler for "-m" option combinations,
35    shared by the driver and the compiler proper.  */
36 void
37 loongarch_config_target (struct loongarch_target *target,
38 			 HOST_WIDE_INT opt_switches,
39 			 int opt_arch, int opt_tune, int opt_fpu,
40 			 int opt_abi_base, int opt_abi_ext,
41 			 int opt_cmodel, int follow_multilib_list);
42 
43 /* option status feedback for "gcc --help=target -Q" */
44 void
45 loongarch_update_gcc_opt_status (struct loongarch_target *target,
46 				 struct gcc_options *opts,
47 				 struct gcc_options *opts_set);
48 #endif
49 
50 
51 /* Macros for common conditional expressions used in loongarch.{c,h,md} */
52 #define TARGET_CMODEL_NORMAL	    (la_target.cmodel == CMODEL_NORMAL)
53 #define TARGET_CMODEL_TINY	    (la_target.cmodel == CMODEL_TINY)
54 #define TARGET_CMODEL_TINY_STATIC   (la_target.cmodel == CMODEL_TINY_STATIC)
55 #define TARGET_CMODEL_LARGE	    (la_target.cmodel == CMODEL_LARGE)
56 #define TARGET_CMODEL_EXTREME	    (la_target.cmodel == CMODEL_EXTREME)
57 
58 #define TARGET_HARD_FLOAT	    (la_target.isa.fpu != ISA_EXT_NOFPU)
59 #define TARGET_HARD_FLOAT_ABI	    (la_target.abi.base == ABI_BASE_LP64D \
60 				     || la_target.abi.base == ABI_BASE_LP64F)
61 
62 #define TARGET_SOFT_FLOAT	  (la_target.isa.fpu == ISA_EXT_NOFPU)
63 #define TARGET_SOFT_FLOAT_ABI	  (la_target.abi.base == ABI_BASE_LP64S)
64 #define TARGET_SINGLE_FLOAT	  (la_target.isa.fpu == ISA_EXT_FPU32)
65 #define TARGET_SINGLE_FLOAT_ABI	  (la_target.abi.base == ABI_BASE_LP64F)
66 #define TARGET_DOUBLE_FLOAT	  (la_target.isa.fpu == ISA_EXT_FPU64)
67 #define TARGET_DOUBLE_FLOAT_ABI	  (la_target.abi.base == ABI_BASE_LP64D)
68 
69 #define TARGET_64BIT		  (la_target.isa.base == ISA_BASE_LA64V100)
70 #define TARGET_ABI_LP64		  (la_target.abi.base == ABI_BASE_LP64D	\
71 				   || la_target.abi.base == ABI_BASE_LP64F \
72 				   || la_target.abi.base == ABI_BASE_LP64S)
73 
74 #define TARGET_ARCH_NATIVE	  (la_target.cpu_arch == CPU_NATIVE)
75 #define LARCH_ACTUAL_ARCH	  (TARGET_ARCH_NATIVE \
76 				   ? (la_target.cpu_native < N_ARCH_TYPES \
77 				      ? (la_target.cpu_native) : (CPU_NATIVE)) \
78 				      : (la_target.cpu_arch))
79 
80 #define TARGET_TUNE_NATIVE	(la_target.cpu_tune == CPU_NATIVE)
81 #define LARCH_ACTUAL_TUNE		(TARGET_TUNE_NATIVE \
82 				 ? (la_target.cpu_native < N_TUNE_TYPES \
83 				    ? (la_target.cpu_native) : (CPU_NATIVE)) \
84 				    : (la_target.cpu_tune))
85 
86 #define TARGET_ARCH_LOONGARCH64	  (LARCH_ACTUAL_ARCH == CPU_LOONGARCH64)
87 #define TARGET_ARCH_LA464	  (LARCH_ACTUAL_ARCH == CPU_LA464)
88 
89 #define TARGET_TUNE_LOONGARCH64	  (LARCH_ACTUAL_TUNE == CPU_LOONGARCH64)
90 #define TARGET_TUNE_LA464	  (LARCH_ACTUAL_TUNE == CPU_LA464)
91 
92 /* Note: optimize_size may vary across functions,
93    while -m[no]-memcpy imposes a global constraint.  */
94 #define TARGET_DO_OPTIMIZE_BLOCK_MOVE_P  loongarch_do_optimize_block_move_p()
95 
96 #ifndef HAVE_AS_MRELAX_OPTION
97 #define HAVE_AS_MRELAX_OPTION 0
98 #endif
99 
100 #ifndef HAVE_AS_COND_BRANCH_RELAXATION
101 #define HAVE_AS_COND_BRANCH_RELAXATION 0
102 #endif
103 
104 #ifndef HAVE_AS_TLS
105 #define HAVE_AS_TLS 0
106 #endif
107 
108 #endif /* LOONGARCH_OPTS_H */
109