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