linux64.h revision 90075
1/* Definitions of target machine for GNU compiler,
2   for 64 bit powerpc linux.
3   Copyright (C) 2000, 2001 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/* Define cutoff for using external functions to save floating point.  */
91#undef  FP_SAVE_INLINE
92#define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63)
93
94/* 64-bit PowerPC Linux always has GPR13 fixed.  */
95#define FIXED_R13		1
96
97/* __throw will restore its own return address to be the same as the
98   return address of the function that the throw is being made to.
99   This is unfortunate, because we want to check the original
100   return address to see if we need to restore the TOC.
101   So we have to squirrel it away with this.  */
102#define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init ()
103
104/* Don't assume anything about the header files.  */
105#define NO_IMPLICIT_EXTERN_C
106
107#undef MD_EXEC_PREFIX
108#undef MD_STARTFILE_PREFIX
109
110#undef  CPP_PREDEFINES
111#define CPP_PREDEFINES \
112 "-D_PPC_ -D__PPC__ -D_PPC64_ -D__PPC64__ -D__powerpc__ -D__powerpc64__ \
113  -D_PIC_ -D__PIC__ -D_BIG_ENDIAN -D__BIG_ENDIAN__ -D__ELF__ \
114  -D__LONG_MAX__=9223372036854775807L \
115  -Acpu=powerpc64 -Amachine=powerpc64"
116
117#undef  CPP_OS_DEFAULT_SPEC
118#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
119
120/* The GNU C++ standard library currently requires _GNU_SOURCE being
121   defined on glibc-based systems. This temporary hack accomplishes this,
122   it should go away as soon as libstdc++-v3 has a real fix.  */
123#undef  CPLUSPLUS_CPP_SPEC
124#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
125
126#undef  LINK_SHLIB_SPEC
127#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
128
129#undef  LIB_DEFAULT_SPEC
130#define LIB_DEFAULT_SPEC "%(lib_linux)"
131
132#undef  STARTFILE_DEFAULT_SPEC
133#define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
134
135#undef	ENDFILE_DEFAULT_SPEC
136#define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
137
138#undef	LINK_START_DEFAULT_SPEC
139#define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
140
141#undef	LINK_OS_DEFAULT_SPEC
142#define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
143
144#undef  LINK_OS_LINUX_SPEC
145#define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \
146  %{rdynamic:-export-dynamic} \
147  %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
148
149#undef  TOC_SECTION_ASM_OP
150#define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\""
151
152#undef  MINIMAL_TOC_SECTION_ASM_OP
153#define MINIMAL_TOC_SECTION_ASM_OP "\t.section\t\".toc1\",\"aw\""
154
155#undef  TARGET_VERSION
156#define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)");
157
158/* Must be at least as big as our pointer type.  */
159#undef  SIZE_TYPE
160#define SIZE_TYPE "long unsigned int"
161
162#undef  PTRDIFF_TYPE
163#define PTRDIFF_TYPE "long int"
164
165#undef  WCHAR_TYPE
166#define WCHAR_TYPE "int"
167#undef  WCHAR_TYPE_SIZE
168#define WCHAR_TYPE_SIZE 32
169
170/* Override rs6000.h definition.  */
171#undef  ASM_APP_ON
172#define ASM_APP_ON "#APP\n"
173
174/* Override rs6000.h definition.  */
175#undef  ASM_APP_OFF
176#define ASM_APP_OFF "#NO_APP\n"
177
178/* PowerPC no-op instruction.  */
179#undef  RS6000_CALL_GLUE
180#define RS6000_CALL_GLUE "nop"
181
182#undef  RS6000_MCOUNT
183#define RS6000_MCOUNT "_mcount"
184
185/* FP save and restore routines.  */
186#undef  SAVE_FP_PREFIX
187#define SAVE_FP_PREFIX "._savef"
188#undef  SAVE_FP_SUFFIX
189#define SAVE_FP_SUFFIX ""
190#undef  RESTORE_FP_PREFIX
191#define RESTORE_FP_PREFIX "._restf"
192#undef  RESTORE_FP_SUFFIX
193#define RESTORE_FP_SUFFIX ""
194
195/* Dwarf2 debugging.  */
196#undef  PREFERRED_DEBUGGING_TYPE
197#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
198
199/* If we are referencing a function that is static or is known to be
200   in this file, make the SYMBOL_REF special.  We can use this to indicate
201   that we can branch to this function without emitting a no-op after the
202   call.  Do not set this flag if the function is weakly defined.  */
203
204#undef  ENCODE_SECTION_INFO
205#define ENCODE_SECTION_INFO(DECL)				\
206  if (TREE_CODE (DECL) == FUNCTION_DECL				\
207      && (TREE_ASM_WRITTEN (DECL) || ! TREE_PUBLIC (DECL))	\
208      && ! DECL_WEAK (DECL))					\
209    SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;
210
211/* This macro gets just the user-specified name
212   out of the string in a SYMBOL_REF.  Discard
213   a leading * or @.  */
214#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME)	\
215do {						\
216  const char *_name = (SYMBOL_NAME);		\
217  while (*_name == '*' || *_name == '@')	\
218    _name++;					\
219  (VAR) = _name;				\
220} while (0)
221
222/* This is how to output a reference to a user-level label named NAME.
223   `assemble_name' uses this.  */
224
225/* Override elfos.h definition.  */
226#undef  ASM_OUTPUT_LABELREF
227#define ASM_OUTPUT_LABELREF(FILE,NAME)		\
228do {						\
229  const char *_name = NAME;			\
230  if (*_name == '@')				\
231    _name++;					\
232 						\
233  if (*_name == '*')				\
234    fprintf (FILE, "%s", _name + 1);		\
235  else						\
236    asm_fprintf (FILE, "%U%s", _name);		\
237} while (0)
238
239#undef  ASM_DECLARE_FUNCTION_NAME
240#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
241  do									\
242    {									\
243      fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", (FILE));	\
244      ASM_OUTPUT_LABEL ((FILE), (NAME));				\
245      fputs (DOUBLE_INT_ASM_OP, (FILE));				\
246      putc ('.', (FILE));						\
247      assemble_name ((FILE), (NAME));					\
248      putc ('\n', (FILE));						\
249      fputs (DOUBLE_INT_ASM_OP, (FILE));				\
250      fputs (".TOC.@tocbase, 0\n\t.previous\n", (FILE));		\
251									\
252      if (TREE_PUBLIC (DECL))						\
253        {								\
254	  if (DECL_WEAK (DECL))						\
255	    fputs ("\t.weak\t", (FILE));				\
256	  else								\
257	    fputs ("\t.globl\t", (FILE));				\
258	  putc ('.', (FILE));						\
259	  assemble_name ((FILE), (NAME));				\
260	  putc ('\n', (FILE));						\
261        }								\
262      fputs (TYPE_ASM_OP, (FILE));					\
263      putc ('.', (FILE));						\
264      assemble_name ((FILE), (NAME));					\
265      putc (',', (FILE));						\
266      fprintf ((FILE), TYPE_OPERAND_FMT, "function");			\
267      putc ('\n', (FILE));						\
268      ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL));			\
269      putc ('.', (FILE));						\
270      ASM_OUTPUT_LABEL ((FILE), (NAME));				\
271    }									\
272  while (0)
273
274/* Return non-zero if this entry is to be written into the constant
275   pool in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF
276   or a CONST containing one of them.  If -mfp-in-toc (the default),
277   we also do this for floating-point constants.  We actually can only
278   do this if the FP formats of the target and host machines are the
279   same, but we can't check that since not every file that uses
280   GO_IF_LEGITIMATE_ADDRESS_P includes real.h.  We also do this when
281   we can write the entry into the TOC and the entry is not larger
282   than a TOC entry.  */
283
284#undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
285#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)			\
286  (TARGET_TOC								\
287   && (GET_CODE (X) == SYMBOL_REF					\
288       || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS	\
289	   && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)		\
290       || GET_CODE (X) == LABEL_REF					\
291       || (GET_CODE (X) == CONST_INT 					\
292	   && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode))	\
293       || (GET_CODE (X) == CONST_DOUBLE					\
294	   && (TARGET_POWERPC64						\
295	       || TARGET_MINIMAL_TOC					\
296	       || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT		\
297		   && ! TARGET_NO_FP_IN_TOC)))))
298
299