]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/loongarch/loongarch-driver.h
LoongArch: Reimplement multilib build option handling.
[thirdparty/gcc.git] / gcc / config / loongarch / loongarch-driver.h
1 /* Subroutine headers for the gcc driver.
2 Copyright (C) 2021-2023 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_DRIVER_H
22 #define LOONGARCH_DRIVER_H
23
24 #include "loongarch-str.h"
25
26 #ifndef SUBTARGET_CPP_SPEC
27 #define SUBTARGET_CPP_SPEC ""
28 #endif
29
30 #ifndef SUBTARGET_CC1_SPEC
31 #define SUBTARGET_CC1_SPEC ""
32 #endif
33
34 #ifndef SUBTARGET_ASM_SPEC
35 #define SUBTARGET_ASM_SPEC ""
36 #endif
37
38 #define EXTRA_SPECS \
39 {"early_self_spec", ""}, \
40 {"subtarget_cc1_spec", SUBTARGET_CC1_SPEC}, \
41 {"subtarget_cpp_spec", SUBTARGET_CPP_SPEC}, \
42 {"subtarget_asm_spec", SUBTARGET_ASM_SPEC},
43
44
45 #undef CPP_SPEC
46 #define CPP_SPEC \
47 "%(subtarget_cpp_spec)"
48
49 #undef CC1_SPEC
50 #define CC1_SPEC \
51 "%{G*} %{,ada:-gnatea %{mabi=*} -gnatez} " \
52 "%(subtarget_cc1_spec)"
53
54 #undef ASM_SPEC
55 #define ASM_SPEC \
56 "%{mabi=*} %(subtarget_asm_spec)"
57
58
59 extern const char*
60 la_driver_init (int argc, const char **argv);
61
62 extern const char*
63 driver_set_m_parm (int argc, const char **argv);
64
65 extern const char*
66 driver_set_no_link (int argc, const char **argv);
67
68 extern const char*
69 driver_get_normalized_m_opts (int argc, const char **argv);
70
71 #define EXTRA_SPEC_FUNCTIONS \
72 { "driver_init", la_driver_init }, \
73 { "set_m_parm", driver_set_m_parm }, \
74 { "set_no_link", driver_set_no_link }, \
75 { "get_normalized_m_opts", driver_get_normalized_m_opts },
76
77 /* Pre-process ABI-related options. */
78 #define LA_SET_PARM_SPEC(NAME) \
79 " %{m" OPTSTR_##NAME "=*: %:set_m_parm(" OPTSTR_##NAME " %*)}" \
80
81 /* For MLIB_SELF_SPECS. */
82 #include "loongarch-multilib.h"
83
84 #ifndef MLIB_SELF_SPECS
85 #define MLIB_SELF_SPECS ""
86 #endif
87
88 #define DRIVER_HANDLE_MACHINE_OPTIONS \
89 " %(early_self_spec)", \
90 MLIB_SELF_SPECS \
91 " %:driver_init()" \
92 " %{c|S|E|nostdlib: %:set_no_link()}" \
93 " %{nostartfiles: %{nodefaultlibs: %:set_no_link()}}" \
94 LA_SET_PARM_SPEC (ABI_BASE) \
95 LA_SET_PARM_SPEC (ARCH) \
96 LA_SET_PARM_SPEC (TUNE) \
97 LA_SET_PARM_SPEC (ISA_EXT_FPU) \
98 LA_SET_PARM_SPEC (ISA_EXT_SIMD) \
99 LA_SET_PARM_SPEC (CMODEL) \
100 " %:get_normalized_m_opts()"
101
102 #define DRIVER_SELF_SPECS \
103 DRIVER_HANDLE_MACHINE_OPTIONS
104
105 /* ABI spec strings. */
106 #define ABI_GRLEN_SPEC \
107 "%{mabi=lp64*:64}" \
108
109 #define ABI_SPEC \
110 "%{mabi=lp64d:lp64d}" \
111 "%{mabi=lp64f:lp64f}" \
112 "%{mabi=lp64s:lp64s}" \
113
114 #endif /* LOONGARCH_DRIVER_H */