| 1 |
/* Subroutine headers for the gcc driver. |
| 2 |
Copyright (C) 2021-2025 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 |
#if HAVE_AS_MRELAX_OPTION && HAVE_AS_COND_BRANCH_RELAXATION |
| 55 |
#define ASM_MRELAX_DEFAULT "%{!mrelax:%{!mno-relax:-mrelax}}" |
| 56 |
#else |
| 57 |
#define ASM_MRELAX_DEFAULT "%{!mrelax:%{!mno-relax:-mno-relax}}" |
| 58 |
#endif |
| 59 |
|
| 60 |
#if HAVE_AS_MRELAX_OPTION |
| 61 |
#define ASM_MRELAX_SPEC \ |
| 62 |
"%{!mno-pass-mrelax-to-as:%{mrelax} %{mno-relax} " ASM_MRELAX_DEFAULT "}" |
| 63 |
#else |
| 64 |
#define ASM_MRELAX_SPEC \ |
| 65 |
"%{mpass-mrelax-to-as:%{mrelax} %{mno-relax} " ASM_MRELAX_DEFAULT "}" |
| 66 |
#endif |
| 67 |
|
| 68 |
#undef ASM_SPEC |
| 69 |
#define ASM_SPEC \ |
| 70 |
"%{mabi=*} " ASM_MRELAX_SPEC " %(subtarget_asm_spec)" |
| 71 |
|
| 72 |
|
| 73 |
extern const char* |
| 74 |
la_driver_init (int argc, const char **argv); |
| 75 |
|
| 76 |
extern const char* |
| 77 |
driver_set_m_parm (int argc, const char **argv); |
| 78 |
|
| 79 |
extern const char* |
| 80 |
driver_set_no_link (int argc, const char **argv); |
| 81 |
|
| 82 |
extern const char* |
| 83 |
driver_get_normalized_m_opts (int argc, const char **argv); |
| 84 |
|
| 85 |
#define EXTRA_SPEC_FUNCTIONS \ |
| 86 |
{ "driver_init", la_driver_init }, \ |
| 87 |
{ "set_m_parm", driver_set_m_parm }, \ |
| 88 |
{ "set_no_link", driver_set_no_link }, \ |
| 89 |
{ "get_normalized_m_opts", driver_get_normalized_m_opts }, |
| 90 |
|
| 91 |
/* Pre-process ABI-related options. */ |
| 92 |
#define LA_SET_PARM_SPEC(NAME) \ |
| 93 |
" %{m" OPTSTR_##NAME "=*: %:set_m_parm(" OPTSTR_##NAME " %*)}" \ |
| 94 |
|
| 95 |
/* For MLIB_SELF_SPECS. */ |
| 96 |
#include "loongarch-multilib.h" |
| 97 |
|
| 98 |
#ifndef MLIB_SELF_SPECS |
| 99 |
#define MLIB_SELF_SPECS "" |
| 100 |
#endif |
| 101 |
|
| 102 |
#define DRIVER_HANDLE_MACHINE_OPTIONS \ |
| 103 |
" %(early_self_spec)", \ |
| 104 |
MLIB_SELF_SPECS \ |
| 105 |
" %:driver_init()" \ |
| 106 |
" %{c|S|E|nostdlib: %:set_no_link()}" \ |
| 107 |
" %{nostartfiles: %{nodefaultlibs: %:set_no_link()}}" \ |
| 108 |
LA_SET_PARM_SPEC (ABI_BASE) \ |
| 109 |
LA_SET_PARM_SPEC (ARCH) \ |
| 110 |
LA_SET_PARM_SPEC (TUNE) \ |
| 111 |
LA_SET_PARM_SPEC (ISA_EXT_FPU) \ |
| 112 |
LA_SET_PARM_SPEC (ISA_EXT_SIMD) \ |
| 113 |
LA_SET_PARM_SPEC (CMODEL) \ |
| 114 |
" %:get_normalized_m_opts()" |
| 115 |
|
| 116 |
#define DRIVER_SELF_SPECS \ |
| 117 |
DRIVER_HANDLE_MACHINE_OPTIONS |
| 118 |
|
| 119 |
/* ABI spec strings. */ |
| 120 |
#define ABI_GRLEN_SPEC \ |
| 121 |
"%{mabi=lp64*:64}" \ |
| 122 |
|
| 123 |
#define ABI_SPEC \ |
| 124 |
"%{mabi=lp64d:lp64d}" \ |
| 125 |
"%{mabi=lp64f:lp64f}" \ |
| 126 |
"%{mabi=lp64s:lp64s}" \ |
| 127 |
|
| 128 |
#endif /* LOONGARCH_DRIVER_H */ |