linux64.h revision 103445
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#undef	ASM_SPEC
41#define	ASM_SPEC "%{.s: %{mregnames} %{mno-regnames}} \
42%{.S: %{mregnames} %{mno-regnames}} \
43%{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian} \
44%{v:-V} %{Qy:} %{!Qn:-Qy} -a64 %(asm_cpu) %{Wa,*:%*}"
45
46/* 64-bit PowerPC Linux always has a TOC.  */
47#undef  TARGET_NO_TOC
48#define TARGET_NO_TOC		0
49#undef  TARGET_TOC
50#define	TARGET_TOC		1
51
52/* We use glibc _mcount for profiling.  */
53#define NO_PROFILE_COUNTERS 1
54#undef  PROFILE_BEFORE_PROLOGUE
55
56/* Define this for kernel profiling, which just saves LR then calls
57   _mcount without worrying about arg saves.  The idea is to change
58   the function prologue as little as possible as it isn't easy to
59   account for arg save/restore code added just for _mcount.  */
60/* #define PROFILE_KERNEL 1 */
61#if PROFILE_KERNEL
62#define PROFILE_BEFORE_PROLOGUE 1
63#undef  PROFILE_HOOK
64#else
65#define PROFILE_HOOK(LABEL) output_profile_hook (LABEL)
66#endif
67
68/* We don't need to generate entries in .fixup.  */
69#undef RELOCATABLE_NEEDS_FIXUP
70
71#define USER_LABEL_PREFIX  ""
72
73/* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints.  */
74#undef  ADJUST_FIELD_ALIGN
75#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
76  (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
77	      ? get_inner_array_type (FIELD) \
78	      : TREE_TYPE (FIELD)) == DFmode \
79   ? MIN ((COMPUTED), 32) : (COMPUTED))
80
81/* AIX increases natural record alignment to doubleword if the first
82   field is an FP double while the FP fields remain word aligned.  */
83#undef ROUND_TYPE_ALIGN
84#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)	\
85  ((TREE_CODE (STRUCT) == RECORD_TYPE			\
86    || TREE_CODE (STRUCT) == UNION_TYPE			\
87    || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)		\
88   && TYPE_FIELDS (STRUCT) != 0				\
89   && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode	\
90   ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64)		\
91   : MAX ((COMPUTED), (SPECIFIED)))
92
93/* Indicate that jump tables go in the text section.  */
94#undef  JUMP_TABLES_IN_TEXT_SECTION
95#define JUMP_TABLES_IN_TEXT_SECTION 1
96
97/* 64-bit PowerPC Linux always has GPR13 fixed.  */
98#define FIXED_R13		1
99
100/* __throw will restore its own return address to be the same as the
101   return address of the function that the throw is being made to.
102   This is unfortunate, because we want to check the original
103   return address to see if we need to restore the TOC.
104   So we have to squirrel it away with this.  */
105#define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init ()
106
107/* Don't assume anything about the header files.  */
108#define NO_IMPLICIT_EXTERN_C
109
110#undef MD_EXEC_PREFIX
111#undef MD_STARTFILE_PREFIX
112
113#undef  CPP_PREDEFINES
114#define CPP_PREDEFINES \
115 "-D_PPC_ -D__PPC__ -D_PPC64_ -D__PPC64__ -D__powerpc__ -D__powerpc64__ \
116  -D_PIC_ -D__PIC__ -D_BIG_ENDIAN -D__BIG_ENDIAN__ -D__ELF__ \
117  -D__LONG_MAX__=9223372036854775807L \
118  -Acpu=powerpc64 -Amachine=powerpc64"
119
120#undef  CPP_OS_DEFAULT_SPEC
121#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
122
123/* The GNU C++ standard library currently requires _GNU_SOURCE being
124   defined on glibc-based systems. This temporary hack accomplishes this,
125   it should go away as soon as libstdc++-v3 has a real fix.  */
126#undef  CPLUSPLUS_CPP_SPEC
127#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
128
129#undef  LINK_SHLIB_SPEC
130#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
131
132#undef  LIB_DEFAULT_SPEC
133#define LIB_DEFAULT_SPEC "%(lib_linux)"
134
135#undef  STARTFILE_DEFAULT_SPEC
136#define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
137
138#undef	ENDFILE_DEFAULT_SPEC
139#define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
140
141#undef	LINK_START_DEFAULT_SPEC
142#define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
143
144#undef	LINK_OS_DEFAULT_SPEC
145#define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
146
147#undef  LINK_OS_LINUX_SPEC
148#ifndef CROSS_COMPILE
149#define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \
150  %{rdynamic:-export-dynamic} \
151  %{!dynamic-linker:-dynamic-linker /lib64/ld.so.1}}}"
152#else
153#define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \
154  %{rdynamic:-export-dynamic} \
155  %{!dynamic-linker:-dynamic-linker ld.so.1}}}"
156#endif
157
158#ifndef CROSS_COMPILE
159#undef  STARTFILE_LINUX_SPEC
160#define STARTFILE_LINUX_SPEC "\
161%{!shared: %{pg:/usr/lib64/gcrt1.o%s} %{!pg:%{p:/usr/lib64/gcrt1.o%s} \
162  %{!p:/usr/lib64/crt1.o%s}}} /usr/lib64/crti.o%s \
163%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
164#endif
165
166#ifndef CROSS_COMPILE
167#undef  ENDFILE_LINUX_SPEC
168#define ENDFILE_LINUX_SPEC "\
169%{!shared:crtend.o%s} %{shared:crtendS.o%s} /usr/lib64/crtn.o%s"
170#endif
171
172#undef  TOC_SECTION_ASM_OP
173#define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\""
174
175#undef  MINIMAL_TOC_SECTION_ASM_OP
176#define MINIMAL_TOC_SECTION_ASM_OP "\t.section\t\".toc1\",\"aw\""
177
178#undef  TARGET_VERSION
179#define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)");
180
181/* Must be at least as big as our pointer type.  */
182#undef  SIZE_TYPE
183#define SIZE_TYPE "long unsigned int"
184
185#undef  PTRDIFF_TYPE
186#define PTRDIFF_TYPE "long int"
187
188#undef  WCHAR_TYPE
189#define WCHAR_TYPE "int"
190#undef  WCHAR_TYPE_SIZE
191#define WCHAR_TYPE_SIZE 32
192
193/* Override rs6000.h definition.  */
194#undef  ASM_APP_ON
195#define ASM_APP_ON "#APP\n"
196
197/* Override rs6000.h definition.  */
198#undef  ASM_APP_OFF
199#define ASM_APP_OFF "#NO_APP\n"
200
201/* PowerPC no-op instruction.  */
202#undef  RS6000_CALL_GLUE
203#define RS6000_CALL_GLUE "nop"
204
205#undef  RS6000_MCOUNT
206#define RS6000_MCOUNT "_mcount"
207
208/* FP save and restore routines.  */
209#undef  SAVE_FP_PREFIX
210#define SAVE_FP_PREFIX "._savef"
211#undef  SAVE_FP_SUFFIX
212#define SAVE_FP_SUFFIX ""
213#undef  RESTORE_FP_PREFIX
214#define RESTORE_FP_PREFIX "._restf"
215#undef  RESTORE_FP_SUFFIX
216#define RESTORE_FP_SUFFIX ""
217
218/* Dwarf2 debugging.  */
219#undef  PREFERRED_DEBUGGING_TYPE
220#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
221
222/* If we are referencing a function that is static or is known to be
223   in this file, make the SYMBOL_REF special.  We can use this to indicate
224   that we can branch to this function without emitting a no-op after the
225   call.  Do not set this flag if the function is weakly defined.  */
226
227#undef  ENCODE_SECTION_INFO
228#define ENCODE_SECTION_INFO(DECL)				\
229  if (TREE_CODE (DECL) == FUNCTION_DECL				\
230      && (TREE_ASM_WRITTEN (DECL) || ! TREE_PUBLIC (DECL))	\
231      && ! DECL_WEAK (DECL))					\
232    SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;
233
234/* This is how to output a reference to a user-level label named NAME.
235   `assemble_name' uses this.  */
236
237/* Override elfos.h definition.  */
238#undef  ASM_OUTPUT_LABELREF
239#define ASM_OUTPUT_LABELREF(FILE,NAME)		\
240do {						\
241  const char *_name = NAME;			\
242  if (*_name == '@')				\
243    _name++;					\
244 						\
245  if (*_name == '*')				\
246    fprintf (FILE, "%s", _name + 1);		\
247  else						\
248    asm_fprintf (FILE, "%U%s", _name);		\
249} while (0)
250
251#undef  ASM_DECLARE_FUNCTION_NAME
252#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
253  do									\
254    {									\
255      fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", (FILE));	\
256      ASM_OUTPUT_LABEL ((FILE), (NAME));				\
257      fputs (DOUBLE_INT_ASM_OP, (FILE));				\
258      putc ('.', (FILE));						\
259      assemble_name ((FILE), (NAME));					\
260      fputs (",.TOC.@tocbase,0\n\t.previous\n\t.size\t", (FILE));	\
261      assemble_name ((FILE), (NAME));					\
262      fputs (",24\n\t.type\t.", (FILE));				\
263      assemble_name ((FILE), (NAME));					\
264      fputs (",@function\n", (FILE));					\
265      if (TREE_PUBLIC (DECL) && ! DECL_WEAK (DECL))			\
266        {								\
267	  fputs ("\t.globl\t.", (FILE));				\
268	  assemble_name ((FILE), (NAME));				\
269	  putc ('\n', (FILE));						\
270        }								\
271      ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL));			\
272      putc ('.', (FILE));						\
273      ASM_OUTPUT_LABEL ((FILE), (NAME));				\
274    }									\
275  while (0)
276
277/* This is how to declare the size of a function.  */
278#undef	ASM_DECLARE_FUNCTION_SIZE
279#define	ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)			\
280  do									\
281    {									\
282      if (!flag_inhibit_size_directive)					\
283	{								\
284	  fputs ("\t.size\t.", (FILE));					\
285	  assemble_name ((FILE), (FNAME));				\
286	  fputs (",.-.", (FILE));					\
287	  assemble_name ((FILE), (FNAME));				\
288	  putc ('\n', (FILE));						\
289	}								\
290    }									\
291  while (0)
292
293/* Return non-zero if this entry is to be written into the constant
294   pool in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF
295   or a CONST containing one of them.  If -mfp-in-toc (the default),
296   we also do this for floating-point constants.  We actually can only
297   do this if the FP formats of the target and host machines are the
298   same, but we can't check that since not every file that uses
299   GO_IF_LEGITIMATE_ADDRESS_P includes real.h.  We also do this when
300   we can write the entry into the TOC and the entry is not larger
301   than a TOC entry.  */
302
303#undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
304#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)			\
305  (TARGET_TOC								\
306   && (GET_CODE (X) == SYMBOL_REF					\
307       || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS	\
308	   && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)		\
309       || GET_CODE (X) == LABEL_REF					\
310       || (GET_CODE (X) == CONST_INT 					\
311	   && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode))	\
312       || (GET_CODE (X) == CONST_DOUBLE					\
313	   && (TARGET_POWERPC64						\
314	       || TARGET_MINIMAL_TOC					\
315	       || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT		\
316		   && ! TARGET_NO_FP_IN_TOC)))))
317
318/* This is the same as the dbxelf.h version, except that we need to
319   use the function code label, not the function descriptor.  */
320#undef	ASM_OUTPUT_SOURCE_LINE
321#define	ASM_OUTPUT_SOURCE_LINE(FILE, LINE)				\
322do									\
323  {									\
324    static int sym_lineno = 1;						\
325    char temp[256];							\
326    ASM_GENERATE_INTERNAL_LABEL (temp, "LM", sym_lineno);		\
327    fprintf (FILE, "\t.stabn 68,0,%d,", LINE);				\
328    assemble_name (FILE, temp);						\
329    fputs ("-.", FILE);							\
330    assemble_name (FILE,						\
331		   XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
332    putc ('\n', FILE);							\
333    ASM_OUTPUT_INTERNAL_LABEL (FILE, "LM", sym_lineno);			\
334    sym_lineno += 1;							\
335  }									\
336while (0)
337
338/* Similarly, we want the function code label here.  */
339#define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \
340  do									\
341    {									\
342      const char *flab;							\
343      fprintf (FILE, "%s%d,0,0,", ASM_STABN_OP, BRAC);			\
344      assemble_name (FILE, NAME);					\
345      putc ('-', FILE);							\
346      if (current_function_func_begin_label != NULL_TREE)		\
347	flab = IDENTIFIER_POINTER (current_function_func_begin_label);	\
348      else								\
349	{								\
350	  putc ('.', FILE);						\
351	  flab = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);	\
352	}								\
353      assemble_name (FILE, flab);					\
354      putc ('\n', FILE);						\
355    }									\
356  while (0)
357
358#define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC)
359#define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC)
360
361/* Another case where we want the dot name.  */
362#define	DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL)				\
363  do									\
364    {									\
365      fprintf (FILE, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);		\
366      assemble_name (FILE, LSCOPE);					\
367      fputs ("-.", FILE);						\
368      assemble_name (FILE, XSTR (XEXP (DECL_RTL (DECL), 0), 0));	\
369      putc ('\n', FILE);						\
370    }									\
371  while (0)
372
373/* Override sysv4.h as these are ABI_V4 only.  */
374#undef	ASM_OUTPUT_REG_PUSH
375#undef	ASM_OUTPUT_REG_POP
376
377/* Select a format to encode pointers in exception handling data.  CODE
378   is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
379   true if the symbol may be affected by dynamic relocations.  */
380#undef	ASM_PREFERRED_EH_DATA_FORMAT
381#define	ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
382  (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_udata8)
383