Debian Codegraph @

gcc/config/rs6000/rtems.h

raw
1 /* Definitions for rtems targeting a PowerPC using elf.
2 Copyright (C) 1996-2025 Free Software Foundation, Inc.
3 Contributed by Joel Sherrill ([email protected]).
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 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.
20
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/>. */
25
26 /* Undef gnu-user.h macro we don't want. */
27 #undef CPLUSPLUS_CPP_SPEC
28
29 /* Copy and paste from linux64.h and freebsd64.h */
30 #ifdef IN_LIBGCC2
31 #undef TARGET_64BIT
32 #ifdef __powerpc64__
33 #define TARGET_64BIT 1
34 #else
35 #define TARGET_64BIT 0
36 #endif
37 #endif
38
39 /* RTEMS configured for the 32-bit multilibs doesn't support saving and
40 restoring 64-bit regs. */
41 #define OS_MISSING_POWERPC64 !TARGET_64BIT
42
43 /* Copy and paste from linux64.h and freebsd64.h */
44 #undef TARGET_AIX
45 #define TARGET_AIX TARGET_64BIT
46
47 /* Simplified copy and paste from linux64.h and freebsd64.h */
48 #undef DOT_SYMBOLS
49 #define DOT_SYMBOLS 0
50
51 /* Copy and paste from linux64.h and freebsd64.h */
52 #undef TARGET_CMODEL
53 #define TARGET_CMODEL rs6000_current_cmodel
54 #define SET_CMODEL(opt) rs6000_current_cmodel = opt
55
56 #undef TARGET_OS_CPP_BUILTINS
57 #define TARGET_OS_CPP_BUILTINS() \
58 do \
59 { \
60 builtin_define ("__rtems__"); \
61 builtin_define ("__USE_INIT_FINI__"); \
62 builtin_assert ("system=rtems"); \
63 if (TARGET_64BIT) \
64 { \
65 builtin_define ("__PPC__"); \
66 builtin_define ("__PPC64__"); \
67 builtin_define ("__powerpc64__"); \
68 builtin_assert ("cpu=powerpc64"); \
69 builtin_assert ("machine=powerpc64"); \
70 } \
71 else \
72 { \
73 builtin_define_std ("PPC"); \
74 builtin_define_std ("powerpc"); \
75 builtin_assert ("cpu=powerpc"); \
76 builtin_assert ("machine=powerpc"); \
77 TARGET_OS_SYSV_CPP_BUILTINS (); \
78 } \
79 } \
80 while (0)
81
82 /* Copy and paste from linux64.h and freebsd64.h */
83 #undef RELOCATABLE_NEEDS_FIXUP
84 #define RELOCATABLE_NEEDS_FIXUP \
85 (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
86
87 /* Copy and paste from linux64.h */
88 #undef RS6000_ABI_NAME
89 #define RS6000_ABI_NAME "linux"
90
91 /* Copy and paste from linux64.h and freebsd64.h */
92 #define INVALID_64BIT "%<-m%s%> not supported in this configuration"
93
94 /* A lot of copy and paste from linux64.h and freebsd64.h */
95 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
96 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
97 do \
98 { \
99 if (rs6000_isa_flags & OPTION_MASK_64BIT) \
100 { \
101 rs6000_elf_abi = 2; \
102 rs6000_current_abi = ABI_ELFv2; \
103 if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \
104 { \
105 rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
106 error (INVALID_64BIT, "relocatable"); \
107 } \
108 if (rs6000_isa_flags & OPTION_MASK_EABI) \
109 { \
110 rs6000_isa_flags &= ~OPTION_MASK_EABI; \
111 error (INVALID_64BIT, "eabi"); \
112 } \
113 if (TARGET_PROTOTYPE) \
114 { \
115 target_prototype = 0; \
116 error (INVALID_64BIT, "prototype"); \
117 } \
118 if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \
119 { \
120 rs6000_isa_flags |= OPTION_MASK_POWERPC64; \
121 error ("%<-m64%> requires a PowerPC64 cpu"); \
122 } \
123 if ((rs6000_isa_flags_explicit \
124 & OPTION_MASK_MINIMAL_TOC) != 0) \
125 { \
126 if (OPTION_SET_P (rs6000_current_cmodel) \
127 && rs6000_current_cmodel != CMODEL_SMALL) \
128 error ("%<-mcmodel%> incompatible with other toc options"); \
129 SET_CMODEL (CMODEL_SMALL); \
130 } \
131 else \
132 { \
133 if (!OPTION_SET_P (rs6000_current_cmodel)) \
134 SET_CMODEL (CMODEL_MEDIUM); \
135 if (rs6000_current_cmodel != CMODEL_SMALL) \
136 { \
137 TARGET_NO_FP_IN_TOC = 0; \
138 TARGET_NO_SUM_IN_TOC = 0; \
139 } \
140 } \
141 } \
142 } \
143 while (0)
144
145 #undef TARGET_LIBGCC_SDATA_SECTION
146 #define TARGET_LIBGCC_SDATA_SECTION ".sdata"
147
148 /* Copy and paste from linux64.h and freebsd64.h */
149 #undef SIZE_TYPE
150 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
151
152 /* Copy and paste from linux64.h and freebsd64.h */
153 #undef PTRDIFF_TYPE
154 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
155
156 /* Copy and paste from freebsd64.h */
157 #undef WCHAR_TYPE
158
159 /* Copy and paste from freebsd64.h */
160 #undef WCHAR_TYPE_SIZE
161 #define WCHAR_TYPE_SIZE 32
162
163 /* Copy and paste from linux64.h and freebsd64.h */
164 #ifdef __powerpc64__
165 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
166 asm (SECTION_OP "\n" \
167 " bl " #FUNC "\n" \
168 " nop\n" \
169 " .previous");
170 #endif
171
172 /* This could be also POWERPC_FREEBSD. It is related to the save/restore
173 defines below. */
174 #define POWERPC_LINUX
175
176 /* Copy and paste from linux64.h and freebsd64.h */
177 #undef SAVE_FP_PREFIX
178 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
179 #undef SAVE_FP_SUFFIX
180 #define SAVE_FP_SUFFIX ""
181 #undef RESTORE_FP_PREFIX
182 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
183 #undef RESTORE_FP_SUFFIX
184 #define RESTORE_FP_SUFFIX ""
185
186 /* Copy and paste from linux64.h and freebsd64.h */
187 #undef ASM_PREFERRED_EH_DATA_FORMAT
188 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
189 (TARGET_64BIT || flag_pic \
190 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
191 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
192 : DW_EH_PE_absptr)
193
194 /* Copy and paste from linux64.h and freebsd64.h */
195 #undef TOC_SECTION_ASM_OP
196 #define TOC_SECTION_ASM_OP \
197 (TARGET_64BIT \
198 ? "\t.section\t\".toc\",\"aw\"" \
199 : "\t.section\t\".got\",\"aw\"")
200
201 /* Copy and paste from linux64.h and freebsd64.h */
202 #undef MINIMAL_TOC_SECTION_ASM_OP
203 #define MINIMAL_TOC_SECTION_ASM_OP \
204 (TARGET_64BIT \
205 ? "\t.section\t\".toc1\",\"aw\"" \
206 : (flag_pic \
207 ? "\t.section\t\".got2\",\"aw\"" \
208 : "\t.section\t\".got1\",\"aw\""))
209
210 /* Copy and paste from linux64.h and freebsd64.h */
211 #undef ASM_DECLARE_FUNCTION_SIZE
212 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
213 do \
214 { \
215 if (!flag_inhibit_size_directive) \
216 { \
217 fputs ("\t.size\t", (FILE)); \
218 if (TARGET_64BIT && DOT_SYMBOLS) \
219 putc ('.', (FILE)); \
220 assemble_name ((FILE), (FNAME)); \
221 fputs (",.-", (FILE)); \
222 rs6000_output_function_entry (FILE, FNAME); \
223 putc ('\n', (FILE)); \
224 } \
225 } \
226 while (0)
227
228 /* Copy and paste from linux64.h and freebsd64.h */
229 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
230 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
231 (TARGET_TOC \
232 && (SYMBOL_REF_P (X) \
233 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
234 && SYMBOL_REF_P (XEXP (XEXP (X, 0), 0))) \
235 || GET_CODE (X) == LABEL_REF \
236 || (CONST_INT_P (X) \
237 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
238 || (CONST_DOUBLE_P (X) \
239 && ((TARGET_64BIT \
240 && (TARGET_MINIMAL_TOC \
241 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
242 && ! TARGET_NO_FP_IN_TOC))) \
243 || (!TARGET_64BIT \
244 && !TARGET_NO_FP_IN_TOC \
245 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
246 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
247
248 #undef CPP_OS_DEFAULT_SPEC
249 #define CPP_OS_DEFAULT_SPEC "\
250 %{!mcpu*: %{!Dppc*: %{!Dmpc*: -Dmpc750} } }\
251 %{mcpu=403: %{!Dppc*: %{!Dmpc*: -Dppc403} } } \
252 %{mcpu=505: %{!Dppc*: %{!Dmpc*: -Dmpc505} } } \
253 %{mcpu=601: %{!Dppc*: %{!Dmpc*: -Dppc601} } } \
254 %{mcpu=602: %{!Dppc*: %{!Dmpc*: -Dppc602} } } \
255 %{mcpu=603: %{!Dppc*: %{!Dmpc*: -Dppc603} } } \
256 %{mcpu=603e: %{!Dppc*: %{!Dmpc*: -Dppc603e} } } \
257 %{mcpu=604: %{!Dppc*: %{!Dmpc*: -Dmpc604} } } \
258 %{mcpu=750: %{!Dppc*: %{!Dmpc*: -Dmpc750} } } \
259 %{mcpu=821: %{!Dppc*: %{!Dmpc*: -Dmpc821} } } \
260 %{mcpu=860: %{!Dppc*: %{!Dmpc*: -Dmpc860} } } \
261 %{mcpu=8540: %{!Dppc*: %{!Dmpc*: -Dppc8540} } } \
262 %{mcpu=e6500: -D__PPC_CPU_E6500__} \
263 %{mvrsave: -D__PPC_VRSAVE__}"
264
265 #undef ASM_SPEC
266 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
267
268 #define ASM_SPEC32 "-a32 \
269 %{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
270 %{memb|msdata=eabi: -memb}"
271
272 #define ASM_SPEC64 "-a64"
273
274 #define ASM_SPEC_COMMON "%(asm_cpu) \
275 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \
276 ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
277
278 #undef LINK_OS_DEFAULT_SPEC
279 #define LINK_OS_DEFAULT_SPEC \
280 "%{!m64:%(link_os_spec32)}%{m64:%(link_os_spec64)}"
281
282 #define LINK_OS_SPEC32 ENDIAN_SELECT(" -m elf32ppc", \
283 " -m elf32lppc", \
284 " -m elf32ppc")
285 #define LINK_OS_SPEC64 ENDIAN_SELECT(" -m elf64ppc", \
286 " -m elf64lppc", \
287 " -m elf64ppc")
288
289 #undef SUBSUBTARGET_EXTRA_SPECS
290 #define SUBSUBTARGET_EXTRA_SPECS \
291 { "asm_spec_common", ASM_SPEC_COMMON }, \
292 { "asm_spec32", ASM_SPEC32 }, \
293 { "asm_spec64", ASM_SPEC64 }, \
294 { "link_os_spec32", LINK_OS_SPEC32 }, \
295 { "link_os_spec64", LINK_OS_SPEC64 },
296
297 /* Use gnu-user.h LINK_GCC_SEQUENCE_SPEC for rtems. */
298 #undef LINK_GCC_C_SEQUENCE_SPEC
299 #define LINK_GCC_C_SEQUENCE_SPEC \
300 "%{mads|myellowknife|mmvme|msim:%G %L %G;" \
301 "!mcall-*|mcall-linux:" GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC ";" \
302 ":%G %L %G}"
303
304 #define RTEMS_STARTFILE_SPEC "ecrti%O%s rtems_crti%O%s crtbegin%O%s"
305 #define RTEMS_ENDFILE_SPEC "crtend%O%s rtems_crtn%O%s ecrtn%O%s"