]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/csky/csky-linux-elf.h
C-SKY: Define HAVE_sync_compare_and_swap*.
[thirdparty/gcc.git] / gcc / config / csky / csky-linux-elf.h
1 /* Declarations for C-SKY targets running Linux.
2 Copyright (C) 2018-2021 Free Software Foundation, Inc.
3 Contributed by C-SKY Microsystems and Mentor Graphics.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 3, or (at your
10 option) any later version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 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 /******************************************************************
22 * Run-time Target Specification *
23 ******************************************************************/
24
25 #undef STARTFILE_SPEC
26 #define STARTFILE_SPEC \
27 "%{!shared: %{pie:Scrt1.o%s;:crt1.o%s}} \
28 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
29
30 #undef ENDFILE_SPEC
31 #define ENDFILE_SPEC \
32 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
33
34 #undef CC1_SPEC
35 #define CC1_SPEC \
36 "%{EB:-EB} \
37 %{EL:-EL} \
38 %{profile:-p} \
39 "
40
41 #undef ASM_SPEC
42 #define ASM_SPEC \
43 "%{mbig-endian:-mbig-endian} \
44 %{EB:-EB} \
45 %{EL:-EL} \
46 %{fpic|fPIC:-pic} \
47 %{mcpu=*:-mcpu=%*} \
48 %{march=*:-march=%*} \
49 %{mhard-float:-mhard-float} \
50 %{mfloat-abi=softfp:-mhard-float} \
51 %{mfloat-abi=hard:-mhard-float} \
52 %{melrw:-melrw} \
53 %{mno-elrw:-mno-elrw} \
54 %{mistack:-mistack} \
55 %{mno-istack:-mno-istack} \
56 %{mmp:-mmp} \
57 %{mcp:-mcp} \
58 %{mcache:-mcache} \
59 %{msecurity|mmac:-msecurity} \
60 %{mtrust:-mtrust} \
61 %{mdsp:-mdsp} \
62 %{medsp:-medsp} \
63 %{mvdsp:-mvdsp} \
64 "
65
66 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-cskyv2%{mfloat-abi=hard:-hf}%{mbig-endian:-be}.so.1"
67
68 #define LINUX_TARGET_LINK_SPEC "%{h*} %{version:-v} \
69 %{b} \
70 %{static:-Bstatic} \
71 %{shared:-shared} \
72 %{symbolic:-Bsymbolic} \
73 %{!static: \
74 %{rdynamic:-export-dynamic} \
75 %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
76 -X \
77 %{mbig-endian:-EB} %{mlittle-endian:-EL} \
78 %{EB:-EB} %{EL:-EL}"
79
80
81 #undef LINK_SPEC
82 #define LINK_SPEC LINUX_TARGET_LINK_SPEC
83
84
85 #undef LIB_SPEC
86 #define LIB_SPEC \
87 "%{pthread:-lpthread} -lc %{mccrt:-lcc-rt}"
88 /* FIXME add this to LIB_SPEC when need */
89 /* %{!shared:%{profile:-lc_p}%{!profile:-lc}}" */
90
91 #define TARGET_OS_CPP_BUILTINS() \
92 do \
93 { \
94 GNU_USER_TARGET_OS_CPP_BUILTINS (); \
95 } \
96 while (0)
97
98 /* In crtstuff.c to control section in where code resides.
99 We have to write it as asm code. */
100 #ifdef __PIC__
101 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
102 asm (SECTION_OP "\n" \
103 "\tgrs\tr3, .Lgetpc_"#FUNC"\n\t" \
104 ".Lgetpc_"#FUNC":\n\t" \
105 "\tlrw\tr2,\t.Lgetpc_"#FUNC"@GOTPC\n\t" \
106 "\taddu\tr3, r2\n\t" \
107 "\tlrw\tr2, "#FUNC"@GOTOFF\n\t" \
108 "\taddu\tr2, r3\n\t" \
109 "\tjsr\tr2\n\t"); \
110 FORCE_CODE_SECTION_ALIGN \
111 asm (TEXT_SECTION_ASM_OP);
112 #endif
113
114 #undef CPP_SPEC
115 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
116
117 #undef FUNCTION_PROFILER
118 #define SAVE_LR \
119 "push\tlr"
120 #define FUNCTION_PROFILER(file, labelno) \
121 fprintf (file, "\t%s\n\tjbsr\t_mcount\n", SAVE_LR);
122 #define NO_PROFILE_COUNTERS 1
123
124 /* Enable features only for Linux toolchains. */
125 #define TARGET_CSKY_LINUX 1
126
127 /* Clear the instruction cache from `BEG' to `END'. */
128 #define CLEAR_INSN_CACHE(BEG, END) \
129 cacheflush (BEG, END-BEG, 3)
130
131 /* For __clear_cache in libgcc2.c. The declaration is copied from
132 <sys/cachectl.h>. */
133 #ifdef IN_LIBGCC2
134 extern int cacheflush (void *__addr, const int __nbytes, const int __op);
135 #endif
136
137 /* The SYNC operations are implemented as library functions, not
138 INSN patterns. As a result, the HAVE defines for the patterns are
139 not defined. We need to define them to generate the corresponding
140 __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* and __GCC_ATOMIC_*_LOCK_FREE
141 defines. */
142
143 #define HAVE_sync_compare_and_swapqi 1
144 #define HAVE_sync_compare_and_swaphi 1
145 #define HAVE_sync_compare_and_swapsi 1