(root)/
gcc-13.2.0/
gcc/
config/
sparc/
linux64.h
       1  /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
       2     Copyright (C) 1996-2023 Free Software Foundation, Inc.
       3     Contributed by David S. Miller (davem@caip.rutgers.edu)
       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  #define TARGET_OS_CPP_BUILTINS()		\
      22    do						\
      23      {						\
      24        GNU_USER_TARGET_OS_CPP_BUILTINS();	\
      25        if (TARGET_ARCH64)			\
      26          builtin_define ("_LONGLONG");		\
      27        if (TARGET_ARCH32				\
      28            && TARGET_LONG_DOUBLE_128)		\
      29  	builtin_define ("__LONG_DOUBLE_128__");	\
      30      }						\
      31    while (0)
      32  
      33  /* On Linux, the combination sparc64-* --with-cpu=v8 is supported and
      34     selects a 32-bit compiler.  */
      35  #if defined(TARGET_64BIT_DEFAULT) && TARGET_CPU_DEFAULT >= TARGET_CPU_v9
      36  #undef TARGET_DEFAULT
      37  #define TARGET_DEFAULT \
      38    (MASK_V9 + MASK_64BIT + MASK_PTR64 + MASK_STACK_BIAS + \
      39     MASK_V8PLUS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
      40  #endif
      41  
      42  /* This must be v9a not just v9 because by default we enable
      43     -mvis.  */
      44  #undef ASM_CPU64_DEFAULT_SPEC
      45  #define ASM_CPU64_DEFAULT_SPEC "-Av9a"
      46  
      47  #undef	ENDFILE_SPEC
      48  #define ENDFILE_SPEC \
      49    GNU_USER_TARGET_ENDFILE_SPEC \
      50    "%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}}"
      51  
      52  /* The default code model.  */
      53  #undef SPARC_DEFAULT_CMODEL
      54  #define SPARC_DEFAULT_CMODEL CM_MEDLOW
      55  
      56  #undef WCHAR_TYPE
      57  #define WCHAR_TYPE "int"
      58  
      59  #undef WCHAR_TYPE_SIZE
      60  #define WCHAR_TYPE_SIZE 32
      61  
      62  /* Define for support of TFmode long double.
      63     SPARC ABI says that long double is 4 words.  */
      64  #undef LONG_DOUBLE_TYPE_SIZE
      65  #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
      66  
      67  #undef CPP_SUBTARGET_SPEC
      68  #define CPP_SUBTARGET_SPEC "\
      69  %{posix:-D_POSIX_SOURCE} \
      70  %{pthread:-D_REENTRANT} \
      71  "
      72  
      73  /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
      74     for the special GCC options -static and -shared, which allow us to
      75     link things in one of these three modes by applying the appropriate
      76     combinations of options at link-time.
      77  
      78     When the -shared link option is used a final link is not being
      79     done.  */
      80  
      81  #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
      82  #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
      83  
      84  #ifdef SPARC_BI_ARCH
      85  
      86  #undef SUBTARGET_EXTRA_SPECS
      87  #define SUBTARGET_EXTRA_SPECS \
      88    { "link_arch32",       LINK_ARCH32_SPEC },              \
      89    { "link_arch64",       LINK_ARCH64_SPEC },              \
      90    { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },	  \
      91    { "link_arch",	 LINK_ARCH_SPEC },
      92  
      93  #define LINK_ARCH32_SPEC "-m elf32_sparc %{shared:-shared} \
      94    %{!shared: \
      95      %{!static: \
      96        %{rdynamic:-export-dynamic} \
      97        -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
      98        %{static:-static}} \
      99  "
     100  
     101  #define LINK_ARCH64_SPEC "-m elf64_sparc %{shared:-shared} \
     102    %{!shared: \
     103      %{!static: \
     104        %{rdynamic:-export-dynamic} \
     105        -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
     106        %{static:-static}} \
     107  "
     108  
     109  #define LINK_ARCH_SPEC "\
     110  %{m32:%(link_arch32)} \
     111  %{m64:%(link_arch64)} \
     112  %{!m32:%{!m64:%(link_arch_default)}} \
     113  "
     114  
     115  #define LINK_ARCH_DEFAULT_SPEC \
     116  (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
     117  
     118  #undef  LINK_SPEC
     119  #define LINK_SPEC "\
     120  %(link_arch) \
     121  %{!mno-relax:%{!r:-relax}} \
     122  "
     123  
     124  /* -mcpu=native handling only makes sense with compiler running on
     125     a SPARC chip.  */
     126  #if defined(__sparc__) && defined(__linux__)
     127  extern const char *host_detect_local_cpu (int argc, const char **argv);
     128  # define EXTRA_SPEC_FUNCTIONS						\
     129    { "local_cpu_detect", host_detect_local_cpu },
     130  
     131  # define MCPU_MTUNE_NATIVE_SPECS					\
     132     " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}"		\
     133     " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
     134  #else
     135  # define MCPU_MTUNE_NATIVE_SPECS ""
     136  #endif
     137  
     138  #define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
     139  
     140  /* -fsanitize=address is currently only supported for 32-bit.  */
     141  #define ASAN_REJECT_SPEC \
     142    "%{!%:sanitize(thread):%e-fsanitize=address is not supported in this configuration}"
     143  
     144  #undef  ASAN_CC1_SPEC
     145  #if DEFAULT_ARCH32_P
     146  #define ASAN_CC1_SPEC \
     147    "%{%:sanitize(address):-funwind-tables %{m64:" ASAN_REJECT_SPEC "}}"
     148  #else
     149  #define ASAN_CC1_SPEC \
     150    "%{%:sanitize(address):-funwind-tables %{!m32:" ASAN_REJECT_SPEC "}}"
     151  #endif
     152  
     153  #undef  CC1_SPEC
     154  #if DEFAULT_ARCH32_P
     155  #define CC1_SPEC GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC \
     156  "%{m32:%{m64:%emay not use both -m32 and -m64}} \
     157  %{m64:-mptr64 -mstack-bias -mlong-double-128 \
     158    %{!mcpu*:-mcpu=ultrasparc} \
     159    %{!mno-vis:%{!mcpu=v9:-mvis}}}"
     160  #else
     161  #define CC1_SPEC GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC \
     162  "%{m32:%{m64:%emay not use both -m32 and -m64}} \
     163  %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
     164    %{!mcpu*:-mcpu=cypress}} \
     165  %{mv8plus:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
     166    %{!mcpu*:-mcpu=v9}} \
     167  %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
     168  %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}}"
     169  #endif
     170  
     171  /* Support for a compile-time default CPU, et cetera.  The rules are:
     172     --with-cpu is ignored if -mcpu is specified; likewise --with-cpu-32
     173       and --with-cpu-64.
     174     --with-tune is ignored if -mtune is specified; likewise --with-tune-32
     175       and --with-tune-64.
     176     --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
     177       are specified.
     178     In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
     179     here, otherwise say -mcpu=v7 would be passed even when -m64.
     180     CC1_SPEC above takes care of this instead.
     181  
     182     Note that the order of the cpu* and tune* options matters: the
     183     config.gcc file always sets with_cpu to some value, even if the
     184     user didn't use --with-cpu when invoking the configure script.
     185     This value is based on the target name.  Therefore we have to make
     186     sure that --with-cpu-32 takes precedence to --with-cpu in < v9
     187     systems, and that --with-cpu-64 takes precedence to --with-cpu in
     188     >= v9 systems.  As for the tune* options, in some platforms
     189     config.gcc also sets a default value for it if the user didn't use
     190     --with-tune when invoking the configure script.  */
     191  #undef OPTION_DEFAULT_SPECS
     192  #if DEFAULT_ARCH32_P
     193  #define OPTION_DEFAULT_SPECS \
     194    {"cpu_32", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
     195    {"cpu_64", "%{m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
     196    {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
     197    {"tune_32", "%{!m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
     198    {"tune_64", "%{m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
     199    {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
     200    {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
     201  #else
     202  #define OPTION_DEFAULT_SPECS \
     203    {"cpu_32", "%{m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
     204    {"cpu_64", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
     205    {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
     206    {"tune_32", "%{m32:%{!mtune=*:-mtune=%(VALUE)}}" },	\
     207    {"tune_64", "%{!m32:%{!mtune=*:-mtune=%(VALUE)}}" },	\
     208    {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
     209    {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
     210  #endif
     211  
     212  #if DEFAULT_ARCH32_P
     213  #define MULTILIB_DEFAULTS { "m32" }
     214  #else
     215  #define MULTILIB_DEFAULTS { "m64" }
     216  #endif
     217  
     218  #else /* !SPARC_BI_ARCH */
     219  
     220  #undef LINK_SPEC
     221  #define LINK_SPEC "-m elf64_sparc -Y P,%R/usr/lib64 %{shared:-shared} \
     222    %{!shared: \
     223      %{!static: \
     224        %{rdynamic:-export-dynamic} \
     225        -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
     226      %{static:-static}} \
     227  %{!mno-relax:%{!r:-relax}} \
     228  "
     229  
     230  #endif /* !SPARC_BI_ARCH */
     231  
     232  /* It's safe to pass -s always, even if -g is not used.  */
     233  #undef ASM_SPEC
     234  #define ASM_SPEC "\
     235  -s \
     236  %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
     237  %{!.c:%{findirect-dispatch:-K PIC}} \
     238  %(asm_cpu) %(asm_arch) %(asm_relax)"
     239  
     240  #undef ASM_OUTPUT_ALIGNED_LOCAL
     241  #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)		\
     242  do {									\
     243    fputs ("\t.local\t", (FILE));		\
     244    assemble_name ((FILE), (NAME));					\
     245    putc ('\n', (FILE));							\
     246    ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);			\
     247  } while (0)
     248  
     249  #undef COMMON_ASM_OP
     250  #define COMMON_ASM_OP "\t.common\t"
     251  
     252  #undef  LOCAL_LABEL_PREFIX
     253  #define LOCAL_LABEL_PREFIX  "."
     254  
     255  /* DWARF bits.  */
     256  
     257  /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets. 
     258     Obviously the Dwarf2 folks haven't tried to actually build systems
     259     with their spec.  On a 64-bit system, only 64-bit relocs become
     260     RELATIVE relocations.  */
     261  
     262  /* #define DWARF_OFFSET_SIZE PTR_SIZE */
     263  
     264  #undef DITF_CONVERSION_LIBFUNCS
     265  #define DITF_CONVERSION_LIBFUNCS 1
     266  
     267  #ifdef HAVE_AS_TLS
     268  #undef TARGET_SUN_TLS
     269  #undef TARGET_GNU_TLS
     270  #define TARGET_SUN_TLS 0
     271  #define TARGET_GNU_TLS 1
     272  #endif
     273  
     274  /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
     275  #undef CTORS_SECTION_ASM_OP
     276  #undef DTORS_SECTION_ASM_OP
     277  
     278  /* Static stack checking is supported by means of probes.  */
     279  #define STACK_CHECK_STATIC_BUILTIN 1
     280  
     281  #undef NEED_INDICATE_EXEC_STACK
     282  #define NEED_INDICATE_EXEC_STACK 1
     283  
     284  #ifdef TARGET_LIBC_PROVIDES_SSP
     285  /* sparc glibc provides __stack_chk_guard in [%g7 + 0x14],
     286     sparc64 glibc provides it at [%g7 + 0x28].  */
     287  #define TARGET_THREAD_SSP_OFFSET	(TARGET_ARCH64 ? 0x28 : 0x14)
     288  #endif
     289  
     290  /* Define if long doubles should be mangled as 'g'.  */
     291  #define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING
     292  
     293  /* We use glibc _mcount for profiling.  */
     294  #undef NO_PROFILE_COUNTERS
     295  #define NO_PROFILE_COUNTERS	1