OSDN Git Service

d2d13edafa34cf74b7271c10275fdd12c30bca1b
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / sysv4.h
1 /* Target definitions for GNU compiler for PowerPC running System V.4
2    Copyright (C) 1995, Free Software Foundation, Inc.
3    Contributed by Cygnus Support.
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 /* eABI local switches -- put here rather than eabi.h, so the switches
23    can be tested in macros.  */
24
25 #define MASK_NO_BITFIELD_TYPE   0x40000000      /* Set PCC_BITFIELD_TYPE_MATTERS to 0 */
26 #define MASK_STRICT_ALIGN       0x20000000      /* Set STRICT_ALIGNMENT to 1.  */
27 #define MASK_RELOCATABLE        0x10000000      /* GOT pointers are PC relative */
28 #define MASK_UNUSED             0x08000000      /* UNUSED, was no-traceback */
29 #define MASK_LITTLE_ENDIAN      0x04000000      /* target is little endian */
30 #define MASK_CALLS_1            0x02000000      /* First ABI bit (AIX, AIXDESC) */
31 #define MASK_PROTOTYPE          0x01000000      /* Only prototyped fcns pass variable args */
32 #define MASK_CALLS_2            0x00800000      /* Second ABI bit (NT) */
33
34 #define MASK_CALLS              (MASK_CALLS_1 | MASK_CALLS_2)
35 #define MASK_CALLS_V4           0
36 #define MASK_CALLS_AIX          MASK_CALLS_1
37 #define MASK_CALLS_NT           MASK_CALLS_2
38 #define MASK_CALLS_AIXDESC      MASK_CALLS
39
40 #define TARGET_NO_BITFIELD_TYPE (target_flags & MASK_NO_BITFIELD_TYPE)
41 #define TARGET_STRICT_ALIGN     (target_flags & MASK_STRICT_ALIGN)
42 #define TARGET_RELOCATABLE      (target_flags & MASK_RELOCATABLE)
43 #define TARGET_LITTLE_ENDIAN    (target_flags & MASK_LITTLE_ENDIAN)
44 #define TARGET_PROTOTYPE        (target_flags & MASK_PROTOTYPE)
45 #define TARGET_TOC              ((target_flags & (MASK_64BIT            \
46                                                  | MASK_RELOCATABLE     \
47                                                  | MASK_MINIMAL_TOC))   \
48                                  || DEFAULT_ABI == ABI_AIX              \
49                                  || DEFAULT_ABI == ABI_NT)
50
51 #define TARGET_BITFIELD_TYPE    (! TARGET_NO_BITFIELD_TYPE)
52 #define TARGET_BIG_ENDIAN       (! TARGET_LITTLE_ENDIAN)
53 #define TARGET_NO_PROTOTYPE     (! TARGET_PROTOTYPE)
54 #define TARGET_NO_TOC           (! TARGET_TOC)
55
56 #define TARGET_AIX_CALLS        (target_flags & MASK_CALLS_1)   /* either -mcall-aix or -mcall-aixdesc */
57 #define TARGET_V4_CALLS         ((target_flags & MASK_CALLS) == MASK_CALLS_V4)
58 #define TARGET_NT_CALLS         ((target_flags & MASK_CALLS) == MASK_CALLS_NT)
59 #define TARGET_AIXDESC_CALLS    ((target_flags & MASK_CALLS) == MASK_CALLS_AIXDESC)
60
61 /* Pseudo target to indicate whether the object format is ELF
62    (to get around not having conditional compilation in the md file)  */
63 #define TARGET_ELF              1
64
65 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be just
66    the same as -mminimal-toc.  */
67 #undef  SUBTARGET_SWITCHES
68 #define SUBTARGET_SWITCHES                                              \
69   { "bit-align",        -MASK_NO_BITFIELD_TYPE },                       \
70   { "no-bit-align",      MASK_NO_BITFIELD_TYPE },                       \
71   { "strict-align",      MASK_STRICT_ALIGN },                           \
72   { "no-strict-align",  -MASK_STRICT_ALIGN },                           \
73   { "relocatable",       MASK_RELOCATABLE | MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC }, \
74   { "no-relocatable",   -MASK_RELOCATABLE },                            \
75   { "relocatable-lib",   MASK_RELOCATABLE | MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC }, \
76   { "no-relocatable-lib", -MASK_RELOCATABLE },                          \
77   { "little-endian",     MASK_LITTLE_ENDIAN },                          \
78   { "little",            MASK_LITTLE_ENDIAN },                          \
79   { "big-endian",       -MASK_LITTLE_ENDIAN },                          \
80   { "big",              -MASK_LITTLE_ENDIAN },                          \
81   { "no-toc",            0 },                                           \
82   { "toc",               MASK_MINIMAL_TOC },                            \
83   { "full-toc",          MASK_MINIMAL_TOC },                            \
84   { "call-aix",          MASK_CALLS_AIX },                              \
85   { "call-aix",         -MASK_CALLS_NT },                               \
86   { "call-aixdesc",      MASK_CALLS_AIXDESC },                          \
87   { "call-aixdesc",     -MASK_LITTLE_ENDIAN },                          \
88   { "call-sysv",        -MASK_CALLS },                                  \
89   { "call-nt",           MASK_CALLS_NT | MASK_LITTLE_ENDIAN },          \
90   { "call-nt",          -MASK_CALLS_AIX },                              \
91   { "prototype",         MASK_PROTOTYPE },                              \
92   { "no-prototype",     -MASK_PROTOTYPE },                              \
93   { "no-traceback",      0 },                                           \
94   { "sim",               0 },                                           \
95   { "mvme",              0 },                                           \
96   { "emb",               0 },                                           \
97
98 /* Sometimes certain combinations of command options do not make sense
99    on a particular target machine.  You can define a macro
100    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
101    defined, is executed once just after all the command options have
102    been parsed.
103
104    The macro SUBTARGET_OVERRIDE_OPTIONS is provided for subtargets, to
105    get control.  */
106
107 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
108 do {                                                                    \
109   if (TARGET_RELOCATABLE && !TARGET_MINIMAL_TOC)                        \
110     {                                                                   \
111       target_flags |= MASK_MINIMAL_TOC;                                 \
112       error ("-mrelocatable and -mno-minimal-toc are incompatible.");   \
113     }                                                                   \
114                                                                         \
115   if (TARGET_RELOCATABLE && TARGET_AIXDESC_CALLS)                       \
116     {                                                                   \
117       target_flags &= ~MASK_RELOCATABLE;                                \
118       error ("-mrelocatable and -mcall-aixdesc are incompatible.");     \
119     }                                                                   \
120                                                                         \
121   if (TARGET_RELOCATABLE && TARGET_NT_CALLS)                            \
122     {                                                                   \
123       target_flags &= ~MASK_MINIMAL_TOC;                                \
124       error ("-mrelocatable and -mcall-nt are incompatible.");          \
125     }                                                                   \
126                                                                         \
127   if (TARGET_AIXDESC_CALLS && TARGET_LITTLE_ENDIAN)                     \
128     {                                                                   \
129       target_flags &= ~MASK_LITTLE_ENDIAN;                              \
130       error ("-mcall-aixdesc must be big endian");                      \
131     }                                                                   \
132                                                                         \
133   if (TARGET_NT_CALLS && TARGET_BIG_ENDIAN)                             \
134     {                                                                   \
135       target_flags |= MASK_LITTLE_ENDIAN;                               \
136       error ("-mcall-nt must be little endian");                        \
137     }                                                                   \
138                                                                         \
139   rs6000_current_abi = ((TARGET_AIXDESC_CALLS) ? ABI_AIX :              \
140                         (TARGET_NT_CALLS)      ? ABI_NT :               \
141                         (TARGET_AIX_CALLS)     ? ABI_AIX_NODESC :       \
142                                                  ABI_V4);               \
143 } while (0)
144
145 /* Default ABI to compile code for */
146 #define DEFAULT_ABI rs6000_current_abi
147
148 #include "rs6000/powerpc.h"
149
150 /* System V.4 uses register 13 as a pointer to the small data area,
151    so it is not available to the normal user.  */
152
153 #undef  FIXED_R13
154 #define FIXED_R13 1
155
156 /* System V.4 passes the first 8 floating arguments in registers,
157    instead of the first 13 like AIX does.  */
158 #undef  FP_ARG_MAX_REG
159 #define FP_ARG_AIX_MAX_REG      45
160 #define FP_ARG_V4_MAX_REG       40
161 #define FP_ARG_MAX_REG ((TARGET_AIX_CALLS) ? FP_ARG_AIX_MAX_REG : FP_ARG_V4_MAX_REG)
162
163 /* Size of the V.4 varargs area if needed */
164 #undef  RS6000_VARARGS_AREA
165 #define RS6000_VARARGS_AREA ((rs6000_sysv_varargs_p) ? RS6000_VARARGS_SIZE : 0)
166
167 /* Override default big endianism */
168 #undef  BYTES_BIG_ENDIAN
169 #undef  WORDS_BIG_ENDIAN
170 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
171 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
172
173 /* Define this to set the endianness to use in libgcc2.c, which can
174    not depend on target_flags.  */
175 #ifndef _LITTLE_ENDIAN
176 #define LIBGCC2_WORDS_BIG_ENDIAN 1
177 #else
178 #define LIBGCC2_WORDS_BIG_ENDIAN 0
179 #endif
180
181 /* Size of the outgoing register save area */
182 #undef  RS6000_REG_SAVE
183 #define RS6000_REG_SAVE (TARGET_AIX_CALLS ? (TARGET_64BIT ? 64 : 32) : 0)
184
185 /* Size of the fixed area on the stack.  For AIX, use the standard 6 word
186    area, otherwise use 2 words to store back chain & LR.  */
187 #undef  RS6000_SAVE_AREA
188 #define RS6000_SAVE_AREA \
189   ((TARGET_AIX_CALLS ? 24 : 8) << (TARGET_64BIT ? 1 : 0))
190
191 /* Define cutoff for using external functions to save floating point.
192    Currently on V.4, always use inline stores */
193 #undef  FP_SAVE_INLINE
194 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
195
196 /* Don't generate XCOFF debugging information.  */
197
198 #undef XCOFF_DEBUGGING_INFO
199
200 /* Don't use the COFF object file format.  */
201
202 #undef OBJECT_FORMAT_COFF
203
204 /* Don't bother to output .extern pseudo-ops.  They are not needed by
205    ELF assemblers.  */
206
207 #undef ASM_OUTPUT_EXTERNAL
208
209 /* Undefine some things which are defined by the generic svr4.h.  */
210
211 #undef ASM_FILE_END
212 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
213 #undef READONLY_DATA_SECTION
214 #undef SELECT_SECTION
215 #undef ASM_DECLARE_FUNCTION_NAME
216 #undef ASM_OUTPUT_CONSTRUCTOR
217 #undef ASM_OUTPUT_DESTRUCTOR
218
219 /* Use the regular svr4 definitions.  */
220
221 #include "svr4.h"
222
223 /* Prefix and suffix to use to saving floating point */
224 #undef  SAVE_FP_PREFIX
225 #undef  SAVE_FP_SUFFIX
226 #define SAVE_FP_PREFIX "_savefpr_"
227 #define SAVE_FP_SUFFIX "_l"
228
229 /* Prefix and suffix to use to restoring floating point */
230 #undef  RESTORE_FP_PREFIX
231 #undef  RESTORE_FP_SUFFIX
232 #define RESTORE_FP_PREFIX "_restfpr_"
233 #define RESTORE_FP_SUFFIX "_l"
234
235 /* Type used for ptrdiff_t, as a string used in a declaration.  */
236 #undef  PTRDIFF_TYPE
237 #define PTRDIFF_TYPE "int"
238
239 /* Type used for wchar_t, as a string used in a declaration.  */
240 #undef  WCHAR_TYPE
241 #define WCHAR_TYPE "short unsigned int"
242
243 /* Width of wchar_t in bits.  */
244 #undef  WCHAR_TYPE_SIZE
245 #define WCHAR_TYPE_SIZE 16
246
247 /* Align stack to 16 byte boundaries */
248 #undef  STACK_BOUNDARY
249 #define STACK_BOUNDARY  128
250
251 /* No data type wants to be aligned rounder than this.  */
252 #undef  BIGGEST_ALIGNMENT
253 #define BIGGEST_ALIGNMENT 128
254
255 /* Use ELF style section commands.  */
256
257 #undef TEXT_SECTION_ASM_OP
258 #define TEXT_SECTION_ASM_OP     "\t.section\t\".text\""
259
260 #undef DATA_SECTION_ASM_OP
261 #define DATA_SECTION_ASM_OP     "\t.section\t\".data\""
262
263 /* Besides the usual ELF sections, we need a toc section.  */
264 #undef EXTRA_SECTIONS
265 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_toc
266
267 #undef EXTRA_SECTION_FUNCTIONS
268 #define EXTRA_SECTION_FUNCTIONS                                         \
269   CONST_SECTION_FUNCTION                                                \
270   CTORS_SECTION_FUNCTION                                                \
271   DTORS_SECTION_FUNCTION                                                \
272   TOC_SECTION_FUNCTION
273
274 #define TOC_SECTION_FUNCTION                                            \
275 void                                                                    \
276 toc_section ()                                                          \
277 {                                                                       \
278   static int toc_initialized = 0;                                       \
279                                                                         \
280   if (in_section != in_toc)                                             \
281     {                                                                   \
282       in_section = in_toc;                                              \
283       if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)             \
284           && TARGET_MINIMAL_TOC                                         \
285           && !TARGET_RELOCATABLE)                                       \
286         {                                                               \
287           if (! toc_initialized)                                        \
288             {                                                           \
289               toc_initialized = 1;                                      \
290               fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);       \
291               ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LCTOC", 0);     \
292               fprintf (asm_out_file, "\t.tc ");                         \
293               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1[TC],"); \
294               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
295               fprintf (asm_out_file, "\n");                             \
296                                                                         \
297               fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \
298               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
299               fprintf (asm_out_file, " = .+32768\n");                   \
300             }                                                           \
301           else                                                          \
302             fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \
303         }                                                               \
304       else if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)        \
305                && !TARGET_RELOCATABLE)                                  \
306         fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);             \
307       else                                                              \
308         {                                                               \
309           fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);   \
310           if (! toc_initialized)                                        \
311             {                                                           \
312               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
313               fprintf (asm_out_file, " = .+32768\n");                   \
314               toc_initialized = 1;                                      \
315             }                                                           \
316         }                                                               \
317     }                                                                   \
318 }
319
320 #define TOC_SECTION_ASM_OP "\t.section\t\".got\",\"aw\""
321 #define MINIMAL_TOC_SECTION_ASM_OP "\t.section\t\".got1\",\"aw\""
322
323 /* Use the TOC section for TOC entries.  */
324
325 #undef SELECT_RTX_SECTION
326 #define SELECT_RTX_SECTION(MODE, X)             \
327 { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (X))      \
328     toc_section ();                             \
329   else                                          \
330     const_section ();                           \
331 }
332
333 /* Return non-zero if this entry is to be written into the constant pool
334    in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF or a CONST
335    containing one of them.  If -mfp-in-toc (the default), we also do
336    this for floating-point constants.  We actually can only do this
337    if the FP formats of the target and host machines are the same, but
338    we can't check that since not every file that uses
339    GO_IF_LEGITIMATE_ADDRESS_P includes real.h.
340
341    Unlike AIX, we don't key off of -mmininal-toc, but instead do not
342    allow floating point constants in the TOC if -mrelocatable.  */
343
344 #undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
345 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X)                              \
346   (TARGET_TOC                                                           \
347    && (GET_CODE (X) == SYMBOL_REF                                       \
348        || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS      \
349            && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)           \
350        || GET_CODE (X) == LABEL_REF                                     \
351        || (!TARGET_NO_FP_IN_TOC                                         \
352            && !TARGET_RELOCATABLE                                       \
353            && GET_CODE (X) == CONST_DOUBLE                              \
354            && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT               \
355            && BITS_PER_WORD == HOST_BITS_PER_INT)))
356
357 /* These macros generate the special .type and .size directives which
358    are used to set the corresponding fields of the linker symbol table
359    entries in an ELF object file under SVR4.  These macros also output
360    the starting labels for the relevant functions/objects.  */
361
362 /* Write the extra assembler code needed to declare a function properly.
363    Some svr4 assemblers need to also have something extra said about the
364    function's return value.  We allow for that here.  */
365
366 extern int rs6000_pic_labelno;
367
368 #undef  ASM_DECLARE_FUNCTION_NAME
369 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
370   do {                                                                  \
371     char *orig_name;                                                    \
372     char *init_ptr = (TARGET_64BIT) ? ".quad" : ".long";                \
373     STRIP_NAME_ENCODING (orig_name, NAME);                              \
374                                                                         \
375     if (TARGET_RELOCATABLE && get_pool_size () != 0)                    \
376       {                                                                 \
377         char buf[256], *buf_ptr;                                        \
378                                                                         \
379         ASM_OUTPUT_INTERNAL_LABEL (FILE, "LCL", rs6000_pic_labelno);    \
380                                                                         \
381         ASM_GENERATE_INTERNAL_LABEL (buf, "LCTOC", 1);                  \
382         STRIP_NAME_ENCODING (buf_ptr, buf);                             \
383         fprintf (FILE, "\t%s %s-", init_ptr, buf_ptr);                  \
384                                                                         \
385         ASM_GENERATE_INTERNAL_LABEL (buf, "LCF", rs6000_pic_labelno);   \
386         fprintf (FILE, "%s\n", buf_ptr);                                \
387       }                                                                 \
388                                                                         \
389     fprintf (FILE, "\t%s\t %s,", TYPE_ASM_OP, orig_name);               \
390     fprintf (FILE, TYPE_OPERAND_FMT, "function");                       \
391     putc ('\n', FILE);                                                  \
392     ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                      \
393                                                                         \
394     if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)                \
395       {                                                                 \
396         char *desc_name = orig_name;                                    \
397                                                                         \
398         while (*desc_name == '.')                                       \
399           desc_name++;                                                  \
400                                                                         \
401         if (TREE_PUBLIC (DECL))                                         \
402           fprintf (FILE, "\t.globl %s\n", desc_name);                   \
403                                                                         \
404         fprintf (FILE, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);             \
405         fprintf (FILE, "%s:\n", desc_name);                             \
406         fprintf (FILE, "\t%s %s\n", init_ptr, orig_name);               \
407         fprintf (FILE, "\t%s _GLOBAL_OFFSET_TABLE_\n", init_ptr);       \
408         if (DEFAULT_ABI == ABI_AIX)                                     \
409           fprintf (FILE, "\t%s 0\n", init_ptr);                         \
410         fprintf (FILE, "\t.previous\n");                                \
411       }                                                                 \
412     fprintf (FILE, "%s:\n", orig_name);                                 \
413   } while (0)
414
415 /* How to renumber registers for dbx and gdb.  */
416
417 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
418
419 /* svr4.h overrides ASM_OUTPUT_INTERNAL_LABEL.  */
420
421 #undef ASM_OUTPUT_INTERNAL_LABEL_PREFIX
422 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX)   \
423   fprintf (FILE, ".%s", PREFIX)
424
425 /* Pass -mppc to the assembler, since that is what powerpc.h currently
426    implies.  */
427 #undef ASM_SPEC
428 #define ASM_SPEC "\
429 -u \
430 %{!mcpu*: \
431   %{mpower2: -mpwrx} \
432   %{mpowerpc*: %{!mpower: -mppc}} \
433   %{mno-powerpc: %{!mpower: %{!mpower2: -mcom}}} \
434   %{mno-powerpc: %{mpower: %{!mpower2: -mpwr}}} \
435   %{!mno-powerpc: %{mpower: -m601}} \
436   %{!mno-powerpc: %{!mpower: -mppc}}} \
437 %{mcpu=common: -mcom} \
438 %{mcpu=rs6000: -mpwr} \
439 %{mcpu=power: -mpwr} \
440 %{mcpu=power2: -mpwrx} \
441 %{mcpu=powerpc: -mppc} \
442 %{mcpu=rios: -mpwr} \
443 %{mcpu=rios1: -mpwr} \
444 %{mcpu=rios2: -mpwrx} \
445 %{mcpu=rsc: -mpwr} \
446 %{mcpu=rsc1: -mpwr} \
447 %{mcpu=403: -mppc} \
448 %{mcpu=601: -m601} \
449 %{mcpu=602: -mppc} \
450 %{mcpu=603: -mppc} \
451 %{mcpu=603e: -mppc} \
452 %{mcpu=604: -mppc} \
453 %{mcpu=620: -mppc} \
454 %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
455 %{mrelocatable} %{mrelocatable-lib} %{memb} \
456 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
457
458 /* Output .file and comments listing what options there are */
459 #undef ASM_FILE_START
460 #define ASM_FILE_START(FILE)                                            \
461 do {                                                                    \
462   ASM_OUTPUT_OPTIONS (FILE);                                            \
463   output_file_directive ((FILE), main_input_filename);                  \
464 } while (0)
465
466
467 /* This is how to output an assembler line defining an `int' constant.
468    For -mrelocatable, we mark all addresses that need to be fixed up
469    in the .fixup section.  */
470 #undef  ASM_OUTPUT_INT
471 #define ASM_OUTPUT_INT(FILE,VALUE)                                      \
472 do {                                                                    \
473   static int recurse = 0;                                               \
474   if (TARGET_RELOCATABLE                                                \
475       && in_section != in_toc                                           \
476       && in_section != in_text                                          \
477       && in_section != in_ctors                                         \
478       && in_section != in_dtors                                         \
479       && !recurse                                                       \
480       && GET_CODE (VALUE) != CONST_INT                                  \
481       && GET_CODE (VALUE) != CONST_DOUBLE                               \
482       && CONSTANT_P (VALUE))                                            \
483     {                                                                   \
484       static int labelno = 0;                                           \
485       char buf[256], *p;                                                \
486                                                                         \
487       recurse = 1;                                                      \
488       ASM_GENERATE_INTERNAL_LABEL (buf, "LCP", labelno++);              \
489       STRIP_NAME_ENCODING (p, buf);                                     \
490       fprintf (FILE, "%s:\n", p);                                       \
491       fprintf (FILE, "\t.long (");                                      \
492       output_addr_const (FILE, (VALUE));                                \
493       fprintf (FILE, ")@fixup\n");                                      \
494       fprintf (FILE, "\t.section\t\".fixup\",\"aw\"\n");                \
495       ASM_OUTPUT_ALIGN (FILE, 2);                                       \
496       fprintf (FILE, "\t.long\t%s\n", p);                               \
497       fprintf (FILE, "\t.previous\n");                                  \
498       recurse = 0;                                                      \
499     }                                                                   \
500   /* Remove initial .'s to turn a -mcall-aixdesc or -mcall-nt function  \
501      address into the address of the descriptor, not the function       \
502      itself.  */                                                        \
503   else if (GET_CODE (VALUE) == SYMBOL_REF                               \
504            && XSTR (VALUE, 0)[0] == '.'                                 \
505            && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT))        \
506     {                                                                   \
507       char *name = XSTR (VALUE, 0);                                     \
508       while (*name == '.')                                              \
509         name++;                                                         \
510                                                                         \
511       fprintf (FILE, "\t.long %s\n", name);                             \
512     }                                                                   \
513   else                                                                  \
514     {                                                                   \
515       fprintf (FILE, "\t.long ");                                       \
516       output_addr_const (FILE, (VALUE));                                \
517       fprintf (FILE, "\n");                                             \
518     }                                                                   \
519 } while (0)
520
521 /* This is the end of what might become sysv4.h.  */
522
523 /* Allow stabs and dwarf, prefer dwarf.  */
524 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
525 #define DBX_DEBUGGING_INFO
526 #define DWARF_DEBUGGING_INFO
527
528 /* If we are referencing a function that is static or is known to be
529    in this file, make the SYMBOL_REF special.  We can use this to indicate
530    that we can branch to this function without emitting a no-op after the
531    call.  For real AIX and NT calling sequences, we also replace the
532    function name with the real name (1 or 2 leading .'s), rather than
533    the function descriptor name.  This saves a lot of overriding code
534    to readd the prefixes.  */
535
536 #undef  ENCODE_SECTION_INFO
537 #define ENCODE_SECTION_INFO(DECL)                                       \
538   do {                                                                  \
539     if (TREE_CODE (DECL) == FUNCTION_DECL)                              \
540       {                                                                 \
541         rtx sym_ref = XEXP (DECL_RTL (DECL), 0);                        \
542         if (TREE_ASM_WRITTEN (DECL) || ! TREE_PUBLIC (DECL))            \
543           SYMBOL_REF_FLAG (sym_ref) = 1;                                \
544                                                                         \
545         if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)            \
546           {                                                             \
547             char *prefix = (DEFAULT_ABI == ABI_AIX) ? "." : "..";       \
548             char *str = permalloc (strlen (prefix) + 1                  \
549                                    + strlen (XSTR (sym_ref, 0)));       \
550             strcpy (str, prefix);                                       \
551             strcat (str, XSTR (sym_ref, 0));                            \
552             XSTR (sym_ref, 0) = str;                                    \
553           }                                                             \
554       }                                                                 \
555   } while (0)
556
557 /* This macro gets just the user-specified name
558    out of the string in a SYMBOL_REF.  Discard
559    a leading * */
560 #undef  STRIP_NAME_ENCODING
561 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
562   (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
563
564 /* But, to make this work, we have to output the stabs for the function
565    name *first*...  */
566
567 #define DBX_FUNCTION_FIRST
568
569 /* This is the end of what might become sysv4dbx.h.  */
570
571 #undef TARGET_VERSION
572 #define TARGET_VERSION fprintf (stderr, " (PowerPC System V.4)");
573 \f
574 #undef CPP_PREDEFINES
575 #define CPP_PREDEFINES \
576   "-DPPC -Dunix -D__svr4__ -Asystem(unix) -Asystem(svr4) -Acpu(powerpc) -Amachine(powerpc)"
577
578 /* Don't put -Y P,<path> for cross compilers */
579 #undef LINK_SPEC
580 #ifdef CROSS_COMPILE
581 #define LINK_SPEC "\
582 %{h*} %{V} %{v:%{!V:-V}} \
583 %{b} %{Wl,*:%*} \
584 %{static:-dn -Bstatic} \
585 %{shared:-G -dy -z text %{!h*:%{o*:-h %*}}} \
586 %{symbolic:-Bsymbolic -G -dy -z text %{!h*:%{o*:-h %*}}} \
587 %{G:-G} \
588 %{YP,*} \
589 %{Qy:} %{!Qn:-Qy} \
590 %{mlittle: -oformat elf32-powerpcle } %{mlittle-endian: -oformat elf32-powerpcle } \
591 %{mbig: -oformat elf32-powerpc } %{mbig-endian: -oformat elf32-powerpc }"
592 #else
593
594 #define LINK_SPEC "\
595 %{h*} %{V} %{v:%{!V:-V}} \
596 %{b} %{Wl,*:%*} \
597 %{static:-dn -Bstatic} \
598 %{shared:-G -dy -z text %{!h*:%{o*:-h %*}}} \
599 %{symbolic:-Bsymbolic -G -dy -z text %{!h*:%{o*:-h %*}}} \
600 %{G:-G} \
601 %{YP,*} \
602 %{!nostdlib: %{!YP,*:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
603              %{!p:-Y P,/usr/ccs/lib:/usr/lib}}} \
604 %{Qy:} %{!Qn:-Qy} \
605 %{mlittle: -oformat elf32-powerpcle } %{mlittle-endian: -oformat elf32-powerpcle } \
606 %{mbig: -oformat elf32-powerpc } %{mbig-endian: -oformat elf32-powerpc }"
607 #endif /* CROSS_COMPILE */
608
609 #undef CPP_SPEC
610 #define CPP_SPEC "\
611 %{posix: -D_POSIX_SOURCE} \
612 %{mrelocatable: -D_RELOCATABLE} \
613 %{mcall-sysv: -D_CALL_SYSV} %{mcall-nt: -D_CALL_NT} \
614 %{mcall-aix: -D_CALL_AIX} %{mcall-aixdesc: -D_CALL_AIX -D_CALL_AIXDESC} \
615 %{!mcall-sysv: %{!mcall-aix: %{!mcall-aixdesc: %{!mcall-nt: -D_CALL_SYSV}}}} \
616 %{msoft-float: -D_SOFT_FLOAT} %{mcpu=403: -D_SOFT_FLOAT} \
617 %{mlittle: -D_LITTLE_ENDIAN -Amachine(littleendian)} \
618 %{mlittle-endian: -D_LITTLE_ENDIAN -Amachine(littleendian)} \
619 %{!mlittle: %{!mlittle-endian: -D_BIG_ENDIAN -Amachine(bigendian)}} \
620 %{!mcpu*: \
621   %{mpower: %{!mpower2: -D_ARCH_PWR}} \
622   %{mpower2: -D_ARCH_PWR2} \
623   %{mpowerpc*: -D_ARCH_PPC} \
624   %{mno-powerpc: %{!mpower: %{!mpower2: -D_ARCH_COM}}} \
625   %{!mno-powerpc: -D_ARCH_PPC}} \
626 %{mcpu=common: -D_ARCH_COM} \
627 %{mcpu=rs6000: -D_ARCH_PWR} \
628 %{mcpu=power: -D_ARCH_PWR} \
629 %{mcpu=power2: -D_ARCH_PWR2} \
630 %{mcpu=powerpc: -D_ARCH_PPC} \
631 %{mcpu=rios: -D_ARCH_PWR} \
632 %{mcpu=rios1: -D_ARCH_PWR} \
633 %{mcpu=rios2: -D_ARCH_PWR2} \
634 %{mcpu=rsc: -D_ARCH_PWR} \
635 %{mcpu=rsc1: -D_ARCH_PWR} \
636 %{mcpu=403: -D_ARCH_PPC} \
637 %{mcpu=601: -D_ARCH_PPC -D_ARCH_PWR} \
638 %{mcpu=602: -D_ARCH_PPC} \
639 %{mcpu=603: -D_ARCH_PPC} \
640 %{mcpu=603e: -D_ARCH_PPC} \
641 %{mcpu=604: -D_ARCH_PPC} \
642 %{mcpu=620: -D_ARCH_PPC}"
643
644 /* Define this macro as a C expression for the initializer of an
645    array of string to tell the driver program which options are
646    defaults for this target and thus do not need to be handled
647    specially when using `MULTILIB_OPTIONS'.
648
649    Do not define this macro if `MULTILIB_OPTIONS' is not defined in
650    the target makefile fragment or if none of the options listed in
651    `MULTILIB_OPTIONS' are set by default.  *Note Target Fragment::.  */
652
653 #undef  MULTILIB_DEFAULTS
654 #define MULTILIB_DEFAULTS { "mbig", "mbig-endian", "mcall-sysv" }