]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/linux64.h
eaa962d024df32713ab52cc2dfc9b80f55d1913b
[thirdparty/gcc.git] / gcc / config / rs6000 / linux64.h
1 /* Definitions of target machine for GNU compiler,
2 for 64 bit powerpc linux.
3 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC 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 2, or (at your option)
10 any later version.
11
12 GNU CC 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 GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 /* Yes! We are AIX! Err. Wait. We're Linux!. No, wait, we're a
23 combo of both!*/
24 #undef DEFAULT_ABI
25 #define DEFAULT_ABI ABI_AIX
26
27 #undef TARGET_AIX
28 #define TARGET_AIX 1
29
30 #undef TARGET_DEFAULT
31 #define TARGET_DEFAULT \
32 (MASK_POWERPC | MASK_POWERPC64 | MASK_64BIT | MASK_NEW_MNEMONICS)
33
34 #undef PROCESSOR_DEFAULT
35 #define PROCESSOR_DEFAULT PROCESSOR_PPC630
36 #undef PROCESSOR_DEFAULT64
37 #define PROCESSOR_DEFAULT64 PROCESSOR_PPC630
38
39 #undef ASM_DEFAULT_SPEC
40 #define ASM_DEFAULT_SPEC "-mppc64"
41
42 /* 64-bit PowerPC Linux always has a TOC. */
43 #undef TARGET_NO_TOC
44 #define TARGET_NO_TOC 0
45 #undef TARGET_TOC
46 #define TARGET_TOC 1
47
48 /* We use glibc _mcount for profiling. */
49 #define NO_PROFILE_COUNTERS 1
50 #undef PROFILE_BEFORE_PROLOGUE
51
52 /* Define this for kernel profiling, which just saves LR then calls
53 _mcount without worrying about arg saves. The idea is to change
54 the function prologue as little as possible as it isn't easy to
55 account for arg save/restore code added just for _mcount. */
56 /* #define PROFILE_KERNEL 1 */
57 #if PROFILE_KERNEL
58 #define PROFILE_BEFORE_PROLOGUE 1
59 #undef PROFILE_HOOK
60 #else
61 #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL)
62 #endif
63
64 /* We don't need to generate entries in .fixup. */
65 #undef RELOCATABLE_NEEDS_FIXUP
66
67 #define USER_LABEL_PREFIX ""
68
69 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */
70 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
71 (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
72 ? get_inner_array_type (FIELD) \
73 : TREE_TYPE (FIELD)) == DFmode \
74 ? MIN ((COMPUTED), 32) : (COMPUTED))
75
76 /* AIX increases natural record alignment to doubleword if the first
77 field is an FP double while the FP fields remain word aligned. */
78 #undef ROUND_TYPE_ALIGN
79 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
80 ((TREE_CODE (STRUCT) == RECORD_TYPE \
81 || TREE_CODE (STRUCT) == UNION_TYPE \
82 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
83 && TYPE_FIELDS (STRUCT) != 0 \
84 && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode \
85 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \
86 : MAX ((COMPUTED), (SPECIFIED)))
87
88 /* Indicate that jump tables go in the text section. */
89 #undef JUMP_TABLES_IN_TEXT_SECTION
90 #define JUMP_TABLES_IN_TEXT_SECTION 1
91
92 /* 64-bit PowerPC Linux always has GPR13 fixed. */
93 #define FIXED_R13 1
94
95 /* __throw will restore its own return address to be the same as the
96 return address of the function that the throw is being made to.
97 This is unfortunate, because we want to check the original
98 return address to see if we need to restore the TOC.
99 So we have to squirrel it away with this. */
100 #define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init ()
101
102 /* Don't assume anything about the header files. */
103 #define NO_IMPLICIT_EXTERN_C
104
105 /* Override svr4.h */
106 #undef MD_EXEC_PREFIX
107 #undef MD_STARTFILE_PREFIX
108
109 #undef CPP_PREDEFINES
110 #define CPP_PREDEFINES \
111 "-D_PPC_ -D__PPC__ -D_PPC64_ -D__PPC64__ -D__powerpc__ -D__powerpc64__ \
112 -D_PIC_ -D__PIC__ -D__ELF__ \
113 -Acpu=powerpc64 -Amachine=powerpc64"
114
115 #undef CPP_OS_DEFAULT_SPEC
116 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
117
118 /* The GNU C++ standard library currently requires _GNU_SOURCE being
119 defined on glibc-based systems. This temporary hack accomplishes this,
120 it should go away as soon as libstdc++-v3 has a real fix. */
121 #undef CPLUSPLUS_CPP_SPEC
122 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
123
124 #undef LINK_SHLIB_SPEC
125 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
126
127 #undef LIB_DEFAULT_SPEC
128 #define LIB_DEFAULT_SPEC "%(lib_linux)"
129
130 #undef STARTFILE_DEFAULT_SPEC
131 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
132
133 #undef ENDFILE_DEFAULT_SPEC
134 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
135
136 #undef LINK_START_DEFAULT_SPEC
137 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
138
139 #undef LINK_OS_DEFAULT_SPEC
140 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
141
142 #undef LINK_OS_LINUX_SPEC
143 #define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \
144 %{rdynamic:-export-dynamic} \
145 %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}"
146
147 #ifdef NATIVE_CROSS
148 #define STARTFILE_PREFIX_SPEC "/usr/local/lib64/ /lib64/ /usr/lib64/"
149 #endif
150
151 #undef STARTFILE_LINUX_SPEC
152 #define STARTFILE_LINUX_SPEC "\
153 %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} crti.o%s \
154 %{static:crtbeginT.o%s} \
155 %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
156
157 #undef ENDFILE_LINUX_SPEC
158 #define ENDFILE_LINUX_SPEC "\
159 %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
160
161 #undef TOC_SECTION_ASM_OP
162 #define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\""
163
164 #undef MINIMAL_TOC_SECTION_ASM_OP
165 #define MINIMAL_TOC_SECTION_ASM_OP "\t.section\t\".toc1\",\"aw\""
166
167 #undef TARGET_VERSION
168 #define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)");
169
170 /* Must be at least as big as our pointer type. */
171 #undef SIZE_TYPE
172 #define SIZE_TYPE "long unsigned int"
173
174 #undef PTRDIFF_TYPE
175 #define PTRDIFF_TYPE "long int"
176
177 #undef WCHAR_TYPE
178 #define WCHAR_TYPE "int"
179 #undef WCHAR_TYPE_SIZE
180 #define WCHAR_TYPE_SIZE 32
181
182 /* Override rs6000.h definition. */
183 #undef ASM_APP_ON
184 #define ASM_APP_ON "#APP\n"
185
186 /* Override rs6000.h definition. */
187 #undef ASM_APP_OFF
188 #define ASM_APP_OFF "#NO_APP\n"
189
190 /* PowerPC no-op instruction. */
191 #undef RS6000_CALL_GLUE
192 #define RS6000_CALL_GLUE "nop"
193
194 #undef RS6000_MCOUNT
195 #define RS6000_MCOUNT "_mcount"
196
197 /* FP save and restore routines. */
198 #undef SAVE_FP_PREFIX
199 #define SAVE_FP_PREFIX "._savef"
200 #undef SAVE_FP_SUFFIX
201 #define SAVE_FP_SUFFIX ""
202 #undef RESTORE_FP_PREFIX
203 #define RESTORE_FP_PREFIX "._restf"
204 #undef RESTORE_FP_SUFFIX
205 #define RESTORE_FP_SUFFIX ""
206
207 /* Dwarf2 debugging. */
208 #undef PREFERRED_DEBUGGING_TYPE
209 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
210
211 #undef TARGET_ENCODE_SECTION_INFO
212 #define TARGET_ENCODE_SECTION_INFO rs6000_xcoff_encode_section_info
213
214 /* This is how to output a reference to a user-level label named NAME.
215 `assemble_name' uses this. */
216
217 /* Override elfos.h definition. */
218 #undef ASM_OUTPUT_LABELREF
219 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
220 do { \
221 const char *_name = NAME; \
222 if (*_name == '@') \
223 _name++; \
224 \
225 if (*_name == '*') \
226 fprintf (FILE, "%s", _name + 1); \
227 else \
228 asm_fprintf (FILE, "%U%s", _name); \
229 } while (0)
230
231 #undef ASM_DECLARE_FUNCTION_NAME
232 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
233 do \
234 { \
235 fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", (FILE)); \
236 ASM_OUTPUT_LABEL ((FILE), (NAME)); \
237 fputs (DOUBLE_INT_ASM_OP, (FILE)); \
238 putc ('.', (FILE)); \
239 assemble_name ((FILE), (NAME)); \
240 fputs (",.TOC.@tocbase,0\n\t.previous\n\t.size\t", (FILE)); \
241 assemble_name ((FILE), (NAME)); \
242 fputs (",24\n\t.type\t.", (FILE)); \
243 assemble_name ((FILE), (NAME)); \
244 fputs (",@function\n", (FILE)); \
245 if (TREE_PUBLIC (DECL) && ! DECL_WEAK (DECL)) \
246 { \
247 fputs ("\t.globl\t.", (FILE)); \
248 assemble_name ((FILE), (NAME)); \
249 putc ('\n', (FILE)); \
250 } \
251 ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL)); \
252 putc ('.', (FILE)); \
253 ASM_OUTPUT_LABEL ((FILE), (NAME)); \
254 } \
255 while (0)
256
257 /* This is how to declare the size of a function. */
258 #undef ASM_DECLARE_FUNCTION_SIZE
259 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
260 do \
261 { \
262 if (!flag_inhibit_size_directive) \
263 { \
264 fputs ("\t.size\t.", (FILE)); \
265 assemble_name ((FILE), (FNAME)); \
266 fputs (",.-.", (FILE)); \
267 assemble_name ((FILE), (FNAME)); \
268 putc ('\n', (FILE)); \
269 } \
270 } \
271 while (0)
272
273 /* Return non-zero if this entry is to be written into the constant
274 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
275 or a CONST containing one of them. If -mfp-in-toc (the default),
276 we also do this for floating-point constants. We actually can only
277 do this if the FP formats of the target and host machines are the
278 same, but we can't check that since not every file that uses
279 GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when
280 we can write the entry into the TOC and the entry is not larger
281 than a TOC entry. */
282
283 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
284 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
285 (TARGET_TOC \
286 && (GET_CODE (X) == SYMBOL_REF \
287 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
288 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
289 || GET_CODE (X) == LABEL_REF \
290 || (GET_CODE (X) == CONST_INT \
291 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
292 || (GET_CODE (X) == CONST_DOUBLE \
293 && (TARGET_POWERPC64 \
294 || TARGET_MINIMAL_TOC \
295 || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
296 && ! TARGET_NO_FP_IN_TOC)))))
297
298 /* This is the same as the dbxelf.h version, except that we need to
299 use the function code label, not the function descriptor. */
300 #undef ASM_OUTPUT_SOURCE_LINE
301 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE) \
302 do \
303 { \
304 static int sym_lineno = 1; \
305 char temp[256]; \
306 ASM_GENERATE_INTERNAL_LABEL (temp, "LM", sym_lineno); \
307 fprintf (FILE, "\t.stabn 68,0,%d,", LINE); \
308 assemble_name (FILE, temp); \
309 fputs ("-.", FILE); \
310 assemble_name (FILE, \
311 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
312 putc ('\n', FILE); \
313 ASM_OUTPUT_INTERNAL_LABEL (FILE, "LM", sym_lineno); \
314 sym_lineno += 1; \
315 } \
316 while (0)