1 /* Definitions for rtems targeting a PowerPC using elf.
2 Copyright (C) 1996-2018 Free Software Foundation, Inc.
3 Contributed by Joel Sherrill (joel@OARcorp.com).
5 This file is part of GCC.
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.
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.
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 /* Copy and paste from linux64.h and freebsd64.h */
30 #define TARGET_64BIT 1
32 #define TARGET_64BIT 0
36 /* Copy and paste from linux64.h and freebsd64.h */
38 #define TARGET_AIX TARGET_64BIT
40 /* Simplified copy and paste from linux64.h and freebsd64.h */
44 /* Copy and paste from linux64.h and freebsd64.h */
46 #define TARGET_CMODEL rs6000_current_cmodel
47 #define SET_CMODEL(opt) rs6000_current_cmodel = opt
49 #undef TARGET_OS_CPP_BUILTINS
50 #define TARGET_OS_CPP_BUILTINS() \
53 builtin_define ("__rtems__"); \
54 builtin_define ("__USE_INIT_FINI__"); \
55 builtin_assert ("system=rtems"); \
58 builtin_define ("__PPC__"); \
59 builtin_define ("__PPC64__"); \
60 builtin_define ("__powerpc64__"); \
61 builtin_assert ("cpu=powerpc64"); \
62 builtin_assert ("machine=powerpc64"); \
66 builtin_define_std ("PPC"); \
67 builtin_define_std ("powerpc"); \
68 builtin_assert ("cpu=powerpc"); \
69 builtin_assert ("machine=powerpc"); \
70 TARGET_OS_SYSV_CPP_BUILTINS (); \
75 /* Copy and paste from linux64.h and freebsd64.h */
76 #undef RELOCATABLE_NEEDS_FIXUP
77 #define RELOCATABLE_NEEDS_FIXUP \
78 (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
80 /* Copy and paste from linux64.h */
81 #undef RS6000_ABI_NAME
82 #define RS6000_ABI_NAME "linux"
84 /* Copy and paste from linux64.h and freebsd64.h */
85 #define INVALID_64BIT "-m%s not supported in this configuration"
87 /* A lot of copy and paste from linux64.h and freebsd64.h */
88 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
89 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
92 if (rs6000_isa_flags & OPTION_MASK_64BIT) \
95 rs6000_current_abi = ABI_ELFv2; \
96 if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \
98 rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
99 error (INVALID_64BIT, "relocatable"); \
101 if (rs6000_isa_flags & OPTION_MASK_EABI) \
103 rs6000_isa_flags &= ~OPTION_MASK_EABI; \
104 error (INVALID_64BIT, "eabi"); \
106 if (TARGET_PROTOTYPE) \
108 target_prototype = 0; \
109 error (INVALID_64BIT, "prototype"); \
111 if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \
113 rs6000_isa_flags |= OPTION_MASK_POWERPC64; \
114 error ("-m64 requires a PowerPC64 cpu"); \
116 if ((rs6000_isa_flags_explicit \
117 & OPTION_MASK_MINIMAL_TOC) != 0) \
119 if (global_options_set.x_rs6000_current_cmodel \
120 && rs6000_current_cmodel != CMODEL_SMALL) \
121 error ("-mcmodel incompatible with other toc options"); \
122 SET_CMODEL (CMODEL_SMALL); \
126 if (!global_options_set.x_rs6000_current_cmodel) \
127 SET_CMODEL (CMODEL_MEDIUM); \
128 if (rs6000_current_cmodel != CMODEL_SMALL) \
130 TARGET_NO_FP_IN_TOC = 0; \
131 TARGET_NO_SUM_IN_TOC = 0; \
138 #undef TARGET_LIBGCC_SDATA_SECTION
139 #define TARGET_LIBGCC_SDATA_SECTION ".sdata"
141 /* Copy and paste from linux64.h and freebsd64.h */
143 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
145 /* Copy and paste from linux64.h and freebsd64.h */
147 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
149 /* Copy and paste from freebsd64.h */
152 /* Copy and paste from freebsd64.h */
153 #undef WCHAR_TYPE_SIZE
154 #define WCHAR_TYPE_SIZE 32
156 /* Copy and paste from linux64.h and freebsd64.h */
158 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
159 asm (SECTION_OP "\n" \
165 /* This could be also POWERPC_FREEBSD. It is related to the save/restore
167 #define POWERPC_LINUX
169 /* Copy and paste from linux64.h and freebsd64.h */
170 #undef SAVE_FP_PREFIX
171 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
172 #undef SAVE_FP_SUFFIX
173 #define SAVE_FP_SUFFIX ""
174 #undef RESTORE_FP_PREFIX
175 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
176 #undef RESTORE_FP_SUFFIX
177 #define RESTORE_FP_SUFFIX ""
179 /* Copy and paste from linux64.h and freebsd64.h */
180 #undef ASM_PREFERRED_EH_DATA_FORMAT
181 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
182 (TARGET_64BIT || flag_pic \
183 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
184 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
187 /* Copy and paste from linux64.h and freebsd64.h */
188 #undef TOC_SECTION_ASM_OP
189 #define TOC_SECTION_ASM_OP \
191 ? "\t.section\t\".toc\",\"aw\"" \
192 : "\t.section\t\".got\",\"aw\"")
194 /* Copy and paste from linux64.h and freebsd64.h */
195 #undef MINIMAL_TOC_SECTION_ASM_OP
196 #define MINIMAL_TOC_SECTION_ASM_OP \
198 ? "\t.section\t\".toc1\",\"aw\"" \
200 ? "\t.section\t\".got2\",\"aw\"" \
201 : "\t.section\t\".got1\",\"aw\""))
203 /* Copy and paste from linux64.h and freebsd64.h */
204 #undef ASM_DECLARE_FUNCTION_SIZE
205 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
208 if (!flag_inhibit_size_directive) \
210 fputs ("\t.size\t", (FILE)); \
211 if (TARGET_64BIT && DOT_SYMBOLS) \
212 putc ('.', (FILE)); \
213 assemble_name ((FILE), (FNAME)); \
214 fputs (",.-", (FILE)); \
215 rs6000_output_function_entry (FILE, FNAME); \
216 putc ('\n', (FILE)); \
221 /* Copy and paste from linux64.h and freebsd64.h */
222 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
223 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
225 && (GET_CODE (X) == SYMBOL_REF \
226 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
227 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
228 || GET_CODE (X) == LABEL_REF \
229 || (GET_CODE (X) == CONST_INT \
230 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
231 || (GET_CODE (X) == CONST_DOUBLE \
233 && (TARGET_MINIMAL_TOC \
234 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
235 && ! TARGET_NO_FP_IN_TOC))) \
237 && !TARGET_NO_FP_IN_TOC \
238 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
239 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
241 #undef CPP_OS_DEFAULT_SPEC
242 #define CPP_OS_DEFAULT_SPEC "\
243 %{!mcpu*: %{!Dppc*: %{!Dmpc*: -Dmpc750} } }\
244 %{mcpu=403: %{!Dppc*: %{!Dmpc*: -Dppc403} } } \
245 %{mcpu=505: %{!Dppc*: %{!Dmpc*: -Dmpc505} } } \
246 %{mcpu=601: %{!Dppc*: %{!Dmpc*: -Dppc601} } } \
247 %{mcpu=602: %{!Dppc*: %{!Dmpc*: -Dppc602} } } \
248 %{mcpu=603: %{!Dppc*: %{!Dmpc*: -Dppc603} } } \
249 %{mcpu=603e: %{!Dppc*: %{!Dmpc*: -Dppc603e} } } \
250 %{mcpu=604: %{!Dppc*: %{!Dmpc*: -Dmpc604} } } \
251 %{mcpu=750: %{!Dppc*: %{!Dmpc*: -Dmpc750} } } \
252 %{mcpu=821: %{!Dppc*: %{!Dmpc*: -Dmpc821} } } \
253 %{mcpu=860: %{!Dppc*: %{!Dmpc*: -Dmpc860} } } \
254 %{mcpu=8540: %{!Dppc*: %{!Dmpc*: -Dppc8540} } } \
255 %{mcpu=e6500: -D__PPC_CPU_E6500__}"
257 #undef ASM_DEFAULT_SPEC
258 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
261 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
263 #define ASM_SPEC32 "-a32 \
264 %{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
265 %{memb|msdata=eabi: -memb}"
267 #define ASM_SPEC64 "-a64"
269 #define ASM_SPEC_COMMON "%(asm_cpu) \
270 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \
271 ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
273 #undef LINK_OS_DEFAULT_SPEC
274 #define LINK_OS_DEFAULT_SPEC \
275 "%{!m64:%(link_os_spec32)}%{m64:%(link_os_spec64)}"
277 #define LINK_OS_SPEC32 ENDIAN_SELECT(" -m elf32ppc", \
280 #define LINK_OS_SPEC64 ENDIAN_SELECT(" -m elf64ppc", \
284 #undef SUBSUBTARGET_EXTRA_SPECS
285 #define SUBSUBTARGET_EXTRA_SPECS \
286 { "asm_spec_common", ASM_SPEC_COMMON }, \
287 { "asm_spec32", ASM_SPEC32 }, \
288 { "asm_spec64", ASM_SPEC64 }, \
289 { "link_os_spec32", LINK_OS_SPEC32 }, \
290 { "link_os_spec64", LINK_OS_SPEC64 },