OSDN Git Service

4cd6b585838676ef6db83d20c857b45a89884020
[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, 1996 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_SDATA              0x08000000      /* use eabi .sdata/.sdata2/.sbss relocations */
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_SDATA            (target_flags & MASK_SDATA)
44 #define TARGET_LITTLE_ENDIAN    (target_flags & MASK_LITTLE_ENDIAN)
45 #define TARGET_PROTOTYPE        (target_flags & MASK_PROTOTYPE)
46 #define TARGET_TOC              ((target_flags & (MASK_64BIT            \
47                                                  | MASK_RELOCATABLE     \
48                                                  | MASK_MINIMAL_TOC))   \
49                                  || DEFAULT_ABI == ABI_AIX              \
50                                  || DEFAULT_ABI == ABI_NT)
51
52 #define TARGET_BITFIELD_TYPE    (! TARGET_NO_BITFIELD_TYPE)
53 #define TARGET_BIG_ENDIAN       (! TARGET_LITTLE_ENDIAN)
54 #define TARGET_NO_PROTOTYPE     (! TARGET_PROTOTYPE)
55 #define TARGET_NO_TOC           (! TARGET_TOC)
56
57 #define TARGET_AIX_CALLS        (target_flags & MASK_CALLS_1)   /* either -mcall-aix or -mcall-aixdesc */
58 #define TARGET_V4_CALLS         ((target_flags & MASK_CALLS) == MASK_CALLS_V4)
59 #define TARGET_NT_CALLS         ((target_flags & MASK_CALLS) == MASK_CALLS_NT)
60 #define TARGET_AIXDESC_CALLS    ((target_flags & MASK_CALLS) == MASK_CALLS_AIXDESC)
61
62 /* Pseudo target to indicate whether the object format is ELF
63    (to get around not having conditional compilation in the md file)  */
64 #define TARGET_ELF              1
65
66 /* Note, V.4 no longer uses a normal TOC, so make -mfull-toc, be just
67    the same as -mminimal-toc.  */
68 #undef  SUBTARGET_SWITCHES
69 #define SUBTARGET_SWITCHES                                              \
70   { "bit-align",        -MASK_NO_BITFIELD_TYPE },                       \
71   { "no-bit-align",      MASK_NO_BITFIELD_TYPE },                       \
72   { "strict-align",      MASK_STRICT_ALIGN },                           \
73   { "no-strict-align",  -MASK_STRICT_ALIGN },                           \
74   { "relocatable",       MASK_RELOCATABLE | MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC }, \
75   { "relocatable",      -MASK_SDATA },                                  \
76   { "no-relocatable",   -MASK_RELOCATABLE },                            \
77   { "relocatable-lib",   MASK_RELOCATABLE | MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC }, \
78   { "no-relocatable-lib", -MASK_RELOCATABLE },                          \
79   { "sdata",             MASK_SDATA },                                  \
80   { "no-sdata",         -MASK_SDATA },                                  \
81   { "little-endian",     MASK_LITTLE_ENDIAN },                          \
82   { "little",            MASK_LITTLE_ENDIAN },                          \
83   { "big-endian",       -MASK_LITTLE_ENDIAN },                          \
84   { "big",              -MASK_LITTLE_ENDIAN },                          \
85   { "no-toc",            0 },                                           \
86   { "toc",               MASK_MINIMAL_TOC },                            \
87   { "full-toc",          MASK_MINIMAL_TOC },                            \
88   { "call-aix",          MASK_CALLS_AIX },                              \
89   { "call-aix",         -MASK_CALLS_NT },                               \
90   { "call-aixdesc",      MASK_CALLS_AIXDESC },                          \
91   { "call-aixdesc",     -MASK_LITTLE_ENDIAN },                          \
92   { "call-sysv",        -MASK_CALLS },                                  \
93   { "call-nt",           MASK_CALLS_NT | MASK_LITTLE_ENDIAN },          \
94   { "call-nt",          -MASK_CALLS_AIX },                              \
95   { "prototype",         MASK_PROTOTYPE },                              \
96   { "no-prototype",     -MASK_PROTOTYPE },                              \
97   { "no-traceback",      0 },                                           \
98   { "sim",               0 },                                           \
99   { "mvme",              0 },                                           \
100   { "emb",               0 },                                           \
101
102 /* Max # of bytes for variables to automatically be put into the .sdata
103    or .sdata2 sections.  */
104 extern int g_switch_value;              /* value of the -G xx switch */
105 extern int g_switch_set;                /* whether -G xx was passed.  */
106
107 #ifndef SDATA_DEFAULT_SIZE
108 #define SDATA_DEFAULT_SIZE 8
109 #endif
110
111 /* Sometimes certain combinations of command options do not make sense
112    on a particular target machine.  You can define a macro
113    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
114    defined, is executed once just after all the command options have
115    been parsed.
116
117    The macro SUBTARGET_OVERRIDE_OPTIONS is provided for subtargets, to
118    get control.  */
119
120 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
121 do {                                                                    \
122   if (!g_switch_set)                                                    \
123     g_switch_value = SDATA_DEFAULT_SIZE;                                \
124                                                                         \
125   rs6000_current_abi = ((TARGET_AIXDESC_CALLS) ? ABI_AIX :              \
126                         (TARGET_NT_CALLS)      ? ABI_NT :               \
127                         (TARGET_AIX_CALLS)     ? ABI_AIX_NODESC :       \
128                                                  ABI_V4);               \
129                                                                         \
130   /* CYGNUS LOCAL -fcombine-statics vs. -msdata */                      \
131   if (TARGET_SDATA)                                                     \
132     flag_combine_statics = 0;                                           \
133   /* END CYGNUS LOCAL -fcombine-statics vs. -msdata */                  \
134                                                                         \
135   if (TARGET_RELOCATABLE && TARGET_SDATA)                               \
136     {                                                                   \
137       target_flags &= ~MASK_SDATA;                                      \
138       error ("-mrelocatable and -msdata are incompatible.");            \
139     }                                                                   \
140                                                                         \
141   if (TARGET_SDATA && DEFAULT_ABI != ABI_V4)                            \
142     {                                                                   \
143       target_flags &= ~MASK_SDATA;                                      \
144       error ("-msdata and -mcall-aix are incompatible.");               \
145     }                                                                   \
146                                                                         \
147   if (TARGET_RELOCATABLE && !TARGET_MINIMAL_TOC)                        \
148     {                                                                   \
149       target_flags |= MASK_MINIMAL_TOC;                                 \
150       error ("-mrelocatable and -mno-minimal-toc are incompatible.");   \
151     }                                                                   \
152                                                                         \
153   if (TARGET_RELOCATABLE && TARGET_AIXDESC_CALLS)                       \
154     {                                                                   \
155       target_flags &= ~MASK_RELOCATABLE;                                \
156       error ("-mrelocatable and -mcall-aixdesc are incompatible.");     \
157     }                                                                   \
158                                                                         \
159   if (TARGET_RELOCATABLE && TARGET_NT_CALLS)                            \
160     {                                                                   \
161       target_flags &= ~MASK_MINIMAL_TOC;                                \
162       error ("-mrelocatable and -mcall-nt are incompatible.");          \
163     }                                                                   \
164                                                                         \
165   if (TARGET_AIXDESC_CALLS && TARGET_LITTLE_ENDIAN)                     \
166     {                                                                   \
167       target_flags &= ~MASK_LITTLE_ENDIAN;                              \
168       error ("-mcall-aixdesc must be big endian");                      \
169     }                                                                   \
170                                                                         \
171   if (TARGET_NT_CALLS && TARGET_BIG_ENDIAN)                             \
172     {                                                                   \
173       target_flags |= MASK_LITTLE_ENDIAN;                               \
174       error ("-mcall-nt must be little endian");                        \
175     }                                                                   \
176 } while (0)
177
178 /* Default ABI to compile code for */
179 #define DEFAULT_ABI rs6000_current_abi
180
181 #include "rs6000/powerpc.h"
182
183 /* System V.4 uses register 13 as a pointer to the small data area,
184    so it is not available to the normal user.  */
185
186 #undef  FIXED_R13
187 #define FIXED_R13 1
188
189 /* System V.4 passes the first 8 floating arguments in registers,
190    instead of the first 13 like AIX does.  */
191 #undef  FP_ARG_MAX_REG
192 #define FP_ARG_MAX_REG ((TARGET_AIX_CALLS) ? FP_ARG_AIX_MAX_REG : FP_ARG_V4_MAX_REG)
193
194 /* Size of the V.4 varargs area if needed */
195 #undef  RS6000_VARARGS_AREA
196 #define RS6000_VARARGS_AREA ((rs6000_sysv_varargs_p) ? RS6000_VARARGS_SIZE : 0)
197
198 /* Override default big endianism */
199 #undef  BYTES_BIG_ENDIAN
200 #undef  WORDS_BIG_ENDIAN
201 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
202 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
203
204 /* Define this to set the endianness to use in libgcc2.c, which can
205    not depend on target_flags.  */
206 #ifndef _LITTLE_ENDIAN
207 #define LIBGCC2_WORDS_BIG_ENDIAN 1
208 #else
209 #define LIBGCC2_WORDS_BIG_ENDIAN 0
210 #endif
211
212 /* Size of the outgoing register save area */
213 #undef  RS6000_REG_SAVE
214 #define RS6000_REG_SAVE (TARGET_AIX_CALLS ? (TARGET_64BIT ? 64 : 32) : 0)
215
216 /* Size of the fixed area on the stack.  For AIX, use the standard 6 word
217    area, otherwise use 2 words to store back chain & LR.  */
218 #undef  RS6000_SAVE_AREA
219 #define RS6000_SAVE_AREA \
220   ((TARGET_AIX_CALLS ? 24 : 8) << (TARGET_64BIT ? 1 : 0))
221
222 /* Define cutoff for using external functions to save floating point.
223    Currently on V.4, always use inline stores */
224 #undef  FP_SAVE_INLINE
225 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
226
227 /* Don't generate XCOFF debugging information.  */
228
229 #undef XCOFF_DEBUGGING_INFO
230
231 /* Don't use the COFF object file format.  */
232
233 #undef OBJECT_FORMAT_COFF
234
235 /* Don't bother to output .extern pseudo-ops.  They are not needed by
236    ELF assemblers.  */
237
238 #undef ASM_OUTPUT_EXTERNAL
239
240 /* Undefine some things which are defined by the generic svr4.h.  */
241
242 #undef ASM_FILE_END
243 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
244 #undef READONLY_DATA_SECTION
245 #undef SELECT_SECTION
246 #undef ASM_DECLARE_FUNCTION_NAME
247 #undef ASM_OUTPUT_CONSTRUCTOR
248 #undef ASM_OUTPUT_DESTRUCTOR
249
250 /* Use the regular svr4 definitions.  */
251
252 #include "svr4.h"
253
254 /* Prefix and suffix to use to saving floating point */
255 #undef  SAVE_FP_PREFIX
256 #undef  SAVE_FP_SUFFIX
257 #define SAVE_FP_PREFIX "_savefpr_"
258 #define SAVE_FP_SUFFIX "_l"
259
260 /* Prefix and suffix to use to restoring floating point */
261 #undef  RESTORE_FP_PREFIX
262 #undef  RESTORE_FP_SUFFIX
263 #define RESTORE_FP_PREFIX "_restfpr_"
264 #define RESTORE_FP_SUFFIX "_l"
265
266 /* Type used for ptrdiff_t, as a string used in a declaration.  */
267 #undef  PTRDIFF_TYPE
268 #define PTRDIFF_TYPE "int"
269
270 /* Type used for wchar_t, as a string used in a declaration.  */
271 #undef  WCHAR_TYPE
272 #define WCHAR_TYPE "short unsigned int"
273
274 /* Width of wchar_t in bits.  */
275 #undef  WCHAR_TYPE_SIZE
276 #define WCHAR_TYPE_SIZE 16
277
278 /* Align stack to 16 byte boundaries */
279 #undef  STACK_BOUNDARY
280 #define STACK_BOUNDARY  128
281
282 /* No data type wants to be aligned rounder than this.  */
283 #undef  BIGGEST_ALIGNMENT
284 #undef  BIGGEST_FIELD_ALIGNMENT
285 #define BIGGEST_ALIGNMENT 128
286
287 /* Use ELF style section commands.  */
288
289 #undef TEXT_SECTION_ASM_OP
290 #define TEXT_SECTION_ASM_OP     "\t.section\t\".text\""
291
292 #undef DATA_SECTION_ASM_OP
293 #define DATA_SECTION_ASM_OP     "\t.section\t\".data\""
294
295 /* Besides the usual ELF sections, we need a toc section.  */
296 #undef EXTRA_SECTIONS
297 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_toc, in_sdata, in_sdata2, in_sbss
298
299 #undef EXTRA_SECTION_FUNCTIONS
300 #define EXTRA_SECTION_FUNCTIONS                                         \
301   CONST_SECTION_FUNCTION                                                \
302   CTORS_SECTION_FUNCTION                                                \
303   DTORS_SECTION_FUNCTION                                                \
304   TOC_SECTION_FUNCTION                                                  \
305   SDATA_SECTION_FUNCTION                                                \
306   SDATA2_SECTION_FUNCTION                                               \
307   SBSS_SECTION_FUNCTION
308
309 extern void toc_section (), sdata_section (), sdata2_section ();
310 extern void sbss_section ();
311
312 #define TOC_SECTION_FUNCTION                                            \
313 void                                                                    \
314 toc_section ()                                                          \
315 {                                                                       \
316   static int toc_initialized = 0;                                       \
317                                                                         \
318   if (in_section != in_toc)                                             \
319     {                                                                   \
320       in_section = in_toc;                                              \
321       if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)             \
322           && TARGET_MINIMAL_TOC                                         \
323           && !TARGET_RELOCATABLE)                                       \
324         {                                                               \
325           if (! toc_initialized)                                        \
326             {                                                           \
327               toc_initialized = 1;                                      \
328               fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);       \
329               ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LCTOC", 0);     \
330               fprintf (asm_out_file, "\t.tc ");                         \
331               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1[TC],"); \
332               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
333               fprintf (asm_out_file, "\n");                             \
334                                                                         \
335               fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \
336               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
337               fprintf (asm_out_file, " = .+32768\n");                   \
338             }                                                           \
339           else                                                          \
340             fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \
341         }                                                               \
342       else if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)        \
343                && !TARGET_RELOCATABLE)                                  \
344         fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);             \
345       else                                                              \
346         {                                                               \
347           fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);   \
348           if (! toc_initialized)                                        \
349             {                                                           \
350               ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \
351               fprintf (asm_out_file, " = .+32768\n");                   \
352               toc_initialized = 1;                                      \
353             }                                                           \
354         }                                                               \
355     }                                                                   \
356 }
357
358 #define TOC_SECTION_ASM_OP "\t.section\t\".got\",\"aw\""
359 #define MINIMAL_TOC_SECTION_ASM_OP "\t.section\t\".got1\",\"aw\""
360
361 #define SDATA_SECTION_ASM_OP "\t.section\t\".sdata\",\"aw\""
362 #define SDATA2_SECTION_ASM_OP "\t.section\t\".sdata2\",\"a\""
363 #define SBSS_SECTION_ASM_OP "\t.section\t\".sbss\",\"aw\",@nobits"
364
365 #define SDATA_SECTION_FUNCTION                                          \
366 void                                                                    \
367 sdata_section ()                                                        \
368 {                                                                       \
369   if (in_section != in_sdata)                                           \
370     {                                                                   \
371       in_section = in_sdata;                                            \
372       fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP);             \
373     }                                                                   \
374 }
375
376 #define SDATA2_SECTION_FUNCTION                                         \
377 void                                                                    \
378 sdata2_section ()                                                       \
379 {                                                                       \
380   if (in_section != in_sdata2)                                          \
381     {                                                                   \
382       in_section = in_sdata2;                                           \
383       fprintf (asm_out_file, "%s\n", SDATA2_SECTION_ASM_OP);            \
384     }                                                                   \
385 }
386
387 #define SBSS_SECTION_FUNCTION                                           \
388 void                                                                    \
389 sbss_section ()                                                         \
390 {                                                                       \
391   if (in_section != in_sbss)                                            \
392     {                                                                   \
393       in_section = in_sbss;                                             \
394       fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP);              \
395     }                                                                   \
396 }
397
398 /* A C statement or statements to switch to the appropriate section
399    for output of RTX in mode MODE.  You can assume that RTX is some
400    kind of constant in RTL.  The argument MODE is redundant except in
401    the case of a `const_int' rtx.  Select the section by calling
402    `text_section' or one of the alternatives for other sections.
403
404    Do not define this macro if you put all constants in the read-only
405    data section.  */
406
407 extern void rs6000_select_rtx_section (), rs6000_select_section ();
408
409 #undef SELECT_RTX_SECTION
410 #define SELECT_RTX_SECTION(MODE, X) rs6000_select_rtx_section (MODE, X)
411
412 /* A C statement or statements to switch to the appropriate
413    section for output of DECL.  DECL is either a `VAR_DECL' node
414    or a constant of some sort.  RELOC indicates whether forming
415    the initial value of DECL requires link-time relocations.  */
416
417 #undef SELECT_SECTION
418 #define SELECT_SECTION(DECL,RELOC) rs6000_select_section (DECL, RELOC)
419
420 /* Return non-zero if this entry is to be written into the constant pool
421    in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF or a CONST
422    containing one of them.  If -mfp-in-toc (the default), we also do
423    this for floating-point constants.  We actually can only do this
424    if the FP formats of the target and host machines are the same, but
425    we can't check that since not every file that uses
426    GO_IF_LEGITIMATE_ADDRESS_P includes real.h.
427
428    Unlike AIX, we don't key off of -mmininal-toc, but instead do not
429    allow floating point constants in the TOC if -mrelocatable.  */
430
431 #undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
432 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X)                              \
433   (TARGET_TOC                                                           \
434    && (GET_CODE (X) == SYMBOL_REF                                       \
435        || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS      \
436            && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)           \
437        || GET_CODE (X) == LABEL_REF                                     \
438        || (!TARGET_NO_FP_IN_TOC                                         \
439            && !TARGET_RELOCATABLE                                       \
440            && GET_CODE (X) == CONST_DOUBLE                              \
441            && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT               \
442            && BITS_PER_WORD == HOST_BITS_PER_INT)))
443
444 /* These macros generate the special .type and .size directives which
445    are used to set the corresponding fields of the linker symbol table
446    entries in an ELF object file under SVR4.  These macros also output
447    the starting labels for the relevant functions/objects.  */
448
449 /* Write the extra assembler code needed to declare a function properly.
450    Some svr4 assemblers need to also have something extra said about the
451    function's return value.  We allow for that here.  */
452
453 extern int rs6000_pic_labelno;
454
455 #undef  ASM_DECLARE_FUNCTION_NAME
456 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
457   do {                                                                  \
458     char *orig_name;                                                    \
459     char *init_ptr = (TARGET_64BIT) ? ".quad" : ".long";                \
460     STRIP_NAME_ENCODING (orig_name, NAME);                              \
461                                                                         \
462     if (TARGET_RELOCATABLE && get_pool_size () != 0)                    \
463       {                                                                 \
464         char buf[256], *buf_ptr;                                        \
465                                                                         \
466         ASM_OUTPUT_INTERNAL_LABEL (FILE, "LCL", rs6000_pic_labelno);    \
467                                                                         \
468         ASM_GENERATE_INTERNAL_LABEL (buf, "LCTOC", 1);                  \
469         STRIP_NAME_ENCODING (buf_ptr, buf);                             \
470         fprintf (FILE, "\t%s %s-", init_ptr, buf_ptr);                  \
471                                                                         \
472         ASM_GENERATE_INTERNAL_LABEL (buf, "LCF", rs6000_pic_labelno);   \
473         fprintf (FILE, "%s\n", buf_ptr);                                \
474       }                                                                 \
475                                                                         \
476     fprintf (FILE, "\t%s\t %s,", TYPE_ASM_OP, orig_name);               \
477     fprintf (FILE, TYPE_OPERAND_FMT, "function");                       \
478     putc ('\n', FILE);                                                  \
479     ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                      \
480                                                                         \
481     if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)                \
482       {                                                                 \
483         char *desc_name = orig_name;                                    \
484                                                                         \
485         while (*desc_name == '.')                                       \
486           desc_name++;                                                  \
487                                                                         \
488         if (TREE_PUBLIC (DECL))                                         \
489           fprintf (FILE, "\t.globl %s\n", desc_name);                   \
490                                                                         \
491         fprintf (FILE, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);             \
492         fprintf (FILE, "%s:\n", desc_name);                             \
493         fprintf (FILE, "\t%s %s\n", init_ptr, orig_name);               \
494         fprintf (FILE, "\t%s _GLOBAL_OFFSET_TABLE_\n", init_ptr);       \
495         if (DEFAULT_ABI == ABI_AIX)                                     \
496           fprintf (FILE, "\t%s 0\n", init_ptr);                         \
497         fprintf (FILE, "\t.previous\n");                                \
498       }                                                                 \
499     fprintf (FILE, "%s:\n", orig_name);                                 \
500   } while (0)
501
502 /* How to renumber registers for dbx and gdb.  */
503
504 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
505
506 /* svr4.h overrides ASM_OUTPUT_INTERNAL_LABEL.  */
507
508 #undef ASM_OUTPUT_INTERNAL_LABEL_PREFIX
509 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX)   \
510   fprintf (FILE, ".%s", PREFIX)
511
512 /* This says how to output assembler code to declare an
513    uninitialized internal linkage data object.  Under SVR4,
514    the linker seems to want the alignment of data objects
515    to depend on their types.  We do exactly that here.  */
516
517 #ifndef LOCAL_ASM_OP
518 #define LOCAL_ASM_OP    ".local"
519 #endif
520
521 #undef ASM_OUTPUT_ALIGNED_LOCAL
522 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
523 do {                                                                    \
524   if (TARGET_SDATA && (SIZE) > 0 && (SIZE) <= g_switch_value)           \
525     {                                                                   \
526       sbss_section ();                                                  \
527       ASM_OUTPUT_ALIGN (FILE, exact_log2 (ALIGN / BITS_PER_UNIT));      \
528       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
529       ASM_OUTPUT_SKIP (FILE, SIZE);                                     \
530     }                                                                   \
531   else                                                                  \
532     {                                                                   \
533       fprintf ((FILE), "\t%s\t", LOCAL_ASM_OP);                         \
534       assemble_name ((FILE), (NAME));                                   \
535       fprintf ((FILE), "\n");                                           \
536       ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);              \
537     }                                                                   \
538 } while (0)
539
540 /* Pass various options to the assembler */
541 #undef ASM_SPEC
542 #define ASM_SPEC "-u %(asm_cpu) \
543 %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
544 %{mrelocatable} %{mrelocatable-lib} %{memb} %{msdata: -memb} \
545 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
546
547 #undef CC1_SPEC
548 /* Pass -G xxx to the compiler */
549 #define CC1_SPEC "%{G*}"
550
551 /* Switch  Recognition by gcc.c.  Add -G xx support */
552
553 #undef SWITCH_TAKES_ARG
554 #define SWITCH_TAKES_ARG(CHAR)                                          \
555   ((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o'                      \
556    || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u'                   \
557    || (CHAR) == 'I' || (CHAR) == 'm'                                    \
558    || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'G')
559
560 /* Output .file and comments listing what options there are */
561 #undef ASM_FILE_START
562 #define ASM_FILE_START(FILE)                                            \
563 do {                                                                    \
564   ASM_OUTPUT_OPTIONS (FILE);                                            \
565   output_file_directive ((FILE), main_input_filename);                  \
566 } while (0)
567
568
569 /* This is how to output an assembler line defining an `int' constant.
570    For -mrelocatable, we mark all addresses that need to be fixed up
571    in the .fixup section.  */
572 #undef  ASM_OUTPUT_INT
573 #define ASM_OUTPUT_INT(FILE,VALUE)                                      \
574 do {                                                                    \
575   static int recurse = 0;                                               \
576   if (TARGET_RELOCATABLE                                                \
577       && in_section != in_toc                                           \
578       && in_section != in_text                                          \
579       && in_section != in_ctors                                         \
580       && in_section != in_dtors                                         \
581       && !recurse                                                       \
582       && GET_CODE (VALUE) != CONST_INT                                  \
583       && GET_CODE (VALUE) != CONST_DOUBLE                               \
584       && CONSTANT_P (VALUE))                                            \
585     {                                                                   \
586       static int labelno = 0;                                           \
587       char buf[256], *p;                                                \
588                                                                         \
589       recurse = 1;                                                      \
590       ASM_GENERATE_INTERNAL_LABEL (buf, "LCP", labelno++);              \
591       STRIP_NAME_ENCODING (p, buf);                                     \
592       fprintf (FILE, "%s:\n", p);                                       \
593       fprintf (FILE, "\t.long (");                                      \
594       output_addr_const (FILE, (VALUE));                                \
595       fprintf (FILE, ")@fixup\n");                                      \
596       fprintf (FILE, "\t.section\t\".fixup\",\"aw\"\n");                \
597       ASM_OUTPUT_ALIGN (FILE, 2);                                       \
598       fprintf (FILE, "\t.long\t%s\n", p);                               \
599       fprintf (FILE, "\t.previous\n");                                  \
600       recurse = 0;                                                      \
601     }                                                                   \
602   /* Remove initial .'s to turn a -mcall-aixdesc or -mcall-nt function  \
603      address into the address of the descriptor, not the function       \
604      itself.  */                                                        \
605   else if (GET_CODE (VALUE) == SYMBOL_REF                               \
606            && XSTR (VALUE, 0)[0] == '.'                                 \
607            && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT))        \
608     {                                                                   \
609       char *name = XSTR (VALUE, 0);                                     \
610       while (*name == '.')                                              \
611         name++;                                                         \
612                                                                         \
613       fprintf (FILE, "\t.long %s\n", name);                             \
614     }                                                                   \
615   else                                                                  \
616     {                                                                   \
617       fprintf (FILE, "\t.long ");                                       \
618       output_addr_const (FILE, (VALUE));                                \
619       fprintf (FILE, "\n");                                             \
620     }                                                                   \
621 } while (0)
622
623 /* This is the end of what might become sysv4.h.  */
624
625 /* Allow stabs and dwarf, prefer dwarf.  */
626 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
627 #define DBX_DEBUGGING_INFO
628 #define DWARF_DEBUGGING_INFO
629
630 /* If we are referencing a function that is static or is known to be
631    in this file, make the SYMBOL_REF special.  We can use this to indicate
632    that we can branch to this function without emitting a no-op after the
633    call.  For real AIX and NT calling sequences, we also replace the
634    function name with the real name (1 or 2 leading .'s), rather than
635    the function descriptor name.  This saves a lot of overriding code
636    to readd the prefixes.  */
637
638 #undef  ENCODE_SECTION_INFO
639 #define ENCODE_SECTION_INFO(DECL)                                       \
640   do {                                                                  \
641     if (TREE_CODE (DECL) == FUNCTION_DECL)                              \
642       {                                                                 \
643         rtx sym_ref = XEXP (DECL_RTL (DECL), 0);                        \
644         if (TREE_ASM_WRITTEN (DECL) || ! TREE_PUBLIC (DECL))            \
645           SYMBOL_REF_FLAG (sym_ref) = 1;                                \
646                                                                         \
647         if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)            \
648           {                                                             \
649             char *prefix = (DEFAULT_ABI == ABI_AIX) ? "." : "..";       \
650             char *str = permalloc (strlen (prefix) + 1                  \
651                                    + strlen (XSTR (sym_ref, 0)));       \
652             strcpy (str, prefix);                                       \
653             strcat (str, XSTR (sym_ref, 0));                            \
654             XSTR (sym_ref, 0) = str;                                    \
655           }                                                             \
656       }                                                                 \
657     else if (TARGET_SDATA && DEFAULT_ABI == ABI_V4                      \
658              && TREE_CODE (DECL) == VAR_DECL)                           \
659       {                                                                 \
660         int size = int_size_in_bytes (TREE_TYPE (DECL));                \
661         tree section_name = DECL_SECTION_NAME (DECL);                   \
662         char *name = ((section_name)                                    \
663                             ? IDENTIFIER_POINTER (section_name)         \
664                             : (char *)0);                               \
665                                                                         \
666         if ((size > 0 && size <= 8)                                     \
667             || (name                                                    \
668                 && (strcmp (name, ".sdata") == 0                        \
669                     || strcmp (name, ".sdata2") == 0                    \
670                     || strcmp (name, ".sbss") == 0                      \
671                     || strcmp (name, ".sbss2") == 0                     \
672                     || strcmp (name, ".PPC.EMB.sdata0") == 0            \
673                     || strcmp (name, ".PPC.EMB.sbss0") == 0)))          \
674           {                                                             \
675             rtx sym_ref = XEXP (DECL_RTL (DECL), 0);                    \
676             char *str = permalloc (2 + strlen (XSTR (sym_ref, 0)));     \
677             strcpy (str, "@");                                          \
678             strcat (str, XSTR (sym_ref, 0));                            \
679             XSTR (sym_ref, 0) = str;                                    \
680           }                                                             \
681       }                                                                 \
682   } while (0)
683
684 /* This macro gets just the user-specified name
685    out of the string in a SYMBOL_REF.  Discard
686    a leading * or @. */
687 #undef  STRIP_NAME_ENCODING
688 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME)                            \
689 do {                                                                    \
690   char *_name = SYMBOL_NAME;                                            \
691   while (*_name == '*' || *_name == '@')                                \
692     _name++;                                                            \
693   (VAR) = _name;                                                        \
694 } while (0)
695
696 /* This is how to output a reference to a user-level label named NAME.
697    `assemble_name' uses this.  */
698
699 #undef ASM_OUTPUT_LABELREF
700 #define ASM_OUTPUT_LABELREF(FILE,NAME)  \
701 do {                                                                    \
702   char *_name = NAME;                                                   \
703   while (*_name == '*' || *_name == '@')                                \
704     _name++;                                                            \
705   fputs (_name, FILE);                                                  \
706 } while (0)
707
708 /* But, to make this work, we have to output the stabs for the function
709    name *first*...  */
710
711 #define DBX_FUNCTION_FIRST
712
713 /* This is the end of what might become sysv4dbx.h.  */
714
715 #undef TARGET_VERSION
716 #define TARGET_VERSION fprintf (stderr, " (PowerPC System V.4)");
717 \f
718 #undef CPP_PREDEFINES
719 #define CPP_PREDEFINES \
720   "-DPPC -Dunix -D__svr4__ -Asystem(unix) -Asystem(svr4) -Acpu(powerpc) -Amachine(powerpc)"
721
722 /* Don't put -Y P,<path> for cross compilers */
723 #undef LINK_PATH_SPEC
724 #ifndef CROSS_COMPILE
725 #define LINK_PATH_SPEC "\
726 %{!nostdlib: %{!YP,*:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
727 %{!p:-Y P,/usr/ccs/lib:/usr/lib}}}"
728
729 #else
730 #define LINK_PATH_SPEC ""
731 #endif
732
733 #undef LINK_SPEC
734 #define LINK_SPEC "\
735 %{h*} %{V} %{v:%{!V:-V}} %{G*} \
736 %{b} %{Wl,*:%*} \
737 %{static:-dn -Bstatic} \
738 %{shared:-G -dy -z text %{!h*:%{o*:-h %*}}} \
739 %{symbolic:-Bsymbolic -G -dy -z text %{!h*:%{o*:-h %*}}} \
740 %{G:-G} \
741 %{YP,*} \
742 %(link_path) %(link_start) \
743 %{Qy:} %{!Qn:-Qy} \
744 %{mlittle: -oformat elf32-powerpcle } %{mlittle-endian: -oformat elf32-powerpcle } \
745 %{mbig: -oformat elf32-powerpc } %{mbig-endian: -oformat elf32-powerpc }"
746
747 #undef  CPP_SYSV_SPEC
748 #define CPP_SYSV_SPEC \
749 "%{mrelocatable: -D_RELOCATABLE} \
750 %{mcall-sysv: -D_CALL_SYSV} %{mcall-nt: -D_CALL_NT} \
751 %{mcall-aix: -D_CALL_AIX} %{mcall-aixdesc: -D_CALL_AIX -D_CALL_AIXDESC} \
752 %{!mcall-sysv: %{!mcall-aix: %{!mcall-aixdesc: %{!mcall-nt: %(cpp_sysv_default) }}}} \
753 %{msoft-float: -D_SOFT_FLOAT} %{mcpu=403: -D_SOFT_FLOAT}"
754
755 #undef  CPP_SYSV_DEFAULT_SPEC
756 #define CPP_SYSV_DEFAULT_SPEC "-D_CALL_SYSV"
757
758 #undef  CPP_ENDIAN_SPEC
759 #define CPP_ENDIAN_SPEC \
760 "%{mlittle: -D_LITTLE_ENDIAN -Amachine(littleendian)} \
761 %{mlittle-endian: -D_LITTLE_ENDIAN -Amachine(littleendian)} \
762 %{!mlittle: %{!mlittle-endian: -D_BIG_ENDIAN -Amachine(bigendian)}}"
763
764 #undef CPP_SPEC
765 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE} %(cpp_sysv) %(cpp_endian) %(cpp_cpu)"
766
767 /* Define this macro as a C expression for the initializer of an
768    array of string to tell the driver program which options are
769    defaults for this target and thus do not need to be handled
770    specially when using `MULTILIB_OPTIONS'.
771
772    Do not define this macro if `MULTILIB_OPTIONS' is not defined in
773    the target makefile fragment or if none of the options listed in
774    `MULTILIB_OPTIONS' are set by default.  *Note Target Fragment::.  */
775
776 #undef  MULTILIB_DEFAULTS
777 #define MULTILIB_DEFAULTS { "mbig", "mbig-endian", "mcall-sysv", "mno-sdata" }