hppa: Revise REG+D address support to allow long displacements before reload
[official-gcc.git] / libatomic / configure.tgt
blob39dd5686f2e65168578d7479446b4f3b5a03e513
1 # -*- shell-script -*-
2 #  Copyright (C) 2012-2023 Free Software Foundation, Inc.
3 #  Contributed by Richard Henderson <rth@redhat.com>.
5 #  This file is part of the GNU Atomic Library (libatomic).
7 #  Libatomic is free software; you can redistribute it and/or modify it
8 #  under the terms of the GNU General Public License as published by
9 #  the Free Software Foundation; either version 3 of the License, or
10 #  (at your option) any later version.
12 #  Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
13 #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15 #  more details.
17 #  Under Section 7 of GPL version 3, you are granted additional
18 #  permissions described in the GCC Runtime Library Exception, version
19 #  3.1, as published by the Free Software Foundation.
21 #  You should have received a copy of the GNU General Public License and
22 #  a copy of the GCC Runtime Library Exception along with this program;
23 #  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24 #  <http://www.gnu.org/licenses/>.
26 # Map the target cpu to an ARCH sub-directory.  At the same time,
27 # work out any special compilation flags as necessary.
29 # Give operating systems the opportunity to discard XCFLAGS modifications based
30 # on ${target_cpu}.  For example to allow proper use of multilibs.
31 configure_tgt_pre_target_cpu_XCFLAGS="${XCFLAGS}"
33 case "${target_cpu}" in
34   alpha*)
35         # fenv.c needs this option to generate inexact exceptions.
36         XCFLAGS="${XCFLAGS} -mfp-trap-mode=sui"
37         ARCH=alpha
38         ;;
39   rs6000 | powerpc*)    ARCH=powerpc ;;
40   riscv*)               ARCH=riscv ;;
41   sh*)                  ARCH=sh ;;
43   aarch64*)
44         ARCH=aarch64
45         case "${target}" in
46             aarch64*-*-linux*)
47                 if test -n "$enable_aarch64_lse"; then
48                     try_ifunc=yes
49                 fi
50                 ;;
51         esac
52         XCFLAGS="${XCFLAGS} -mno-outline-atomics"
53         ;;
54   arm*)
55         ARCH=arm
56         case "${target}" in
57             arm*-*-freebsd* | arm*-*-netbsd*)
58                 ;;
59             *)
60                 # ??? Detect when -march=armv7 is already enabled.
61                 try_ifunc=yes
62                 ;;
63         esac
64         ;;
65   sparc)
66         case " ${CC} ${CFLAGS} " in
67           *" -m64 "*)
68             ;;
69           *)
70             if test -z "$with_cpu"; then
71               XCFLAGS="${XCFLAGS} -mcpu=v9"
72             fi
73         esac
74         ARCH=sparc
75         ;;
76   sparc64|sparcv9)
77         case " ${CC} ${CFLAGS} " in
78           *" -m32 "*)
79             XCFLAGS="${XCFLAGS} -mcpu=v9"
80             ;;
81         esac
82         ARCH=sparc
83         ;;
85   i[3456]86 | x86_64)
86         cat > conftestx.c <<EOF
87 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
88 #error need -march=i486
89 #endif
90 EOF
91         if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
92           :
93         else
94           if test "${target_cpu}" = x86_64; then
95             XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
96           else
97             XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
98           fi
99           XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
100         fi
101         cat > conftestx.c <<EOF
102 #ifdef __x86_64__
103 #error ifunc is always wanted for 16B atomic load
104 #else
105 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
106 #error need -march=i686
107 #endif
108 #endif
110         if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
111           try_ifunc=no
112         else
113           try_ifunc=yes
114         fi
115         rm -f conftestx.c
116         ARCH=x86
117         ;;
119   *)                    ARCH="${target_cpu}" ;;
120 esac
122 # The cpu configury is always most relevant.
123 if test -d ${srcdir}/config/$ARCH ; then
124   config_path="$ARCH"
127 tmake_file=
128 # Other system configury
129 case "${target}" in
130   aarch64*-*-linux*)
131         # OS support for atomic primitives.
132         config_path="${config_path} linux/aarch64 posix"
133         ;;
135   arm*-*-linux* | arm*-*-uclinux*)
136         # OS support for atomic primitives.
137         config_path="${config_path} linux/arm posix"
138         ;;
140   s390*-*-linux*)
141         # OS support for atomic primitives.
142         config_path="${config_path} s390 posix"
143         ;;
145   powerpc*-*-aix*)
146         config_path="${config_path} posix"
147         tmake_file="t-aix"
148         ;;
150   *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \
151   | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* \
152   | *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \
153   | *-*-darwin* | *-*-aix* | *-*-cygwin*)
154         # POSIX system.  The OS is supported.
155         config_path="${config_path} posix"
156         ;;
158   *-*-mingw*)
159         # OS support for atomic primitives.
160         case ${target_thread_file} in
161           win32 | mcf | single)
162             config_path="${config_path} mingw"
163             ;;
164           posix)
165             config_path="${config_path} posix"
166             ;;
167         esac
168         ;;
170   *-*-rtems*)
171         XCFLAGS="${configure_tgt_pre_target_cpu_XCFLAGS}"
172         config_path="rtems"
173         ;;
175   *-*-elf*)
176         # ??? No target OS.  We could be targeting bare-metal kernel-mode,
177         # or user-mode for some custom OS.  If the target supports TAS,
178         # we can build our own spinlocks, given there are no signals.
179         # If the target supports disabling interrupts, we can work in
180         # kernel-mode, given the system is not multi-processor.
181         UNSUPPORTED=1
182         ;;
184   nvptx*-*-*)
185         ;;
187   *)
188         # Who are you?
189         UNSUPPORTED=1
190         ;;
191 esac
193 # glibc will pass hwcap to ifunc resolver functions as an argument.
194 # The type may be different on different architectures.
195 case "${target}" in
196   aarch64*-*-*)
197         IFUNC_RESOLVER_ARGS="uint64_t hwcap"
198         ;;
199   *)
200         IFUNC_RESOLVER_ARGS="void"
201         ;;
202 esac