OSDN Git Service

Don't include real.h.
[pf3gnuchains/gcc-fork.git] / gcc / config / sparc / sysv4.h
1 /* Target definitions for GNU compiler for Sparc running System V.4
2    Copyright (C) 1991, 1992 Free Software Foundation, Inc.
3
4    Written by Ron Guilmette (rfg@ncd.com).
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
21
22 #include "sparc.h"
23
24 /* Undefine some symbols which are defined in "sparc.h" but which are
25    appropriate only for SunOS 4.x, and not for svr4.  */
26
27 #undef DBX_DEBUGGING_INFO
28 #undef WORD_SWITCH_TAKES_ARG
29 #undef SELECT_SECTION
30 #undef ASM_DECLARE_FUNCTION_NAME
31 #undef TEXT_SECTION_ASM_OP
32 #undef DATA_SECTION_ASM_OP
33
34 #include "svr4.h"
35
36 /* Undefined some symbols which are defined in "svr4.h" but which are
37    appropriate only for typical svr4 systems, but not for the specific
38    case of svr4 running on a Sparc.  */
39
40 #undef CTORS_SECTION_ASM_OP
41 #undef DTORS_SECTION_ASM_OP
42 #undef INIT_SECTION_ASM_OP
43 #undef CONST_SECTION_ASM_OP
44 #undef TYPE_OPERAND_FMT
45 #undef PUSHSECTION_FORMAT
46 #undef STRING_ASM_OP
47 #undef COMMON_ASM_OP
48 #undef SKIP_ASM_OP
49 #undef SET_ASM_OP       /* Has no equivalent.  See ASM_OUTPUT_DEF below.  */
50
51 /* Provide a set of pre-definitions and pre-assertions appropriate for
52    the Sparc running svr4.  __svr4__ is our extension.  */
53
54 #define CPP_PREDEFINES \
55   "-Dsparc -Dunix -D__svr4__ -Asystem(unix) -Acpu(sparc) -Amachine(sparc)"
56
57 /* The specialized code which needs to appear in the .init section prior
58    to the prologue code for `__do_global_ctors' (see crtstuff.c).
59
60    On Sparcs running svr4, the /usr/ccs/lib/crti.o file (with gets linked
61    in prior to the crtbegin.o file) has a single `save' instruction in its
62    .init section.  That `save' instruction tries to setup a stack frame for
63    the sake of any subsequent code in the .init section.  Unfortunately,
64    the size it uses for the stack frame is only a guess, and is not really
65    adequate for our purposes.  More importantly, we independently put our
66    own standard function prologue (for __do_global_ctors) into the .init
67    section and that function prologue includes its own `save' instruction!
68    Thus, unless we do something to correct the situation, we'll get *two*
69    stack frames allocated when crt0.o calls the code in the .init section,
70    and havoc will ensue.  The following macro definition prevents such woes.
71 */
72
73 #define INIT_SECTION_PREAMBLE   asm ("restore")
74
75 /* This is the string used to begin an assembly language comment for the
76    Sparc/svr4 assembler.  */
77
78 #define ASM_COMMENT_START "!"
79
80 /* Define the names of various pseudo-op used by the Sparc/svr4 assembler.
81    Note that many of these are different from the typical pseudo-ops used
82    by most svr4 assemblers.  That is probably due to a (misguided?) attempt
83    to keep the Sparc/svr4 assembler somewhat compatible with the Sparc/SunOS
84    assembler.  */
85
86 #define STRING_ASM_OP           ".asciz"
87 #define COMMON_ASM_OP           ".common"
88 #define SKIP_ASM_OP             ".skip"
89 #define UNALIGNED_INT_ASM_OP    ".uaword"
90 #define UNALIGNED_SHORT_ASM_OP  ".uahalf"
91 #define PUSHSECTION_ASM_OP      ".pushsection"
92 #define POPSECTION_ASM_OP       ".popsection"
93
94 /* This is the format used to print the second operand of a .type pseudo-op
95    for the Sparc/svr4 assembler.  */
96
97 #define TYPE_OPERAND_FMT      "#%s"
98
99 /* This is the format used to print a .pushsection pseudo-op (and its operand)
100    for the Sparc/svr4 assembler.  */
101
102 #define PUSHSECTION_FORMAT      "\t%s\t\"%s\"\n"
103
104 #undef ASM_OUTPUT_CASE_LABEL
105 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)             \
106 do { ASM_OUTPUT_ALIGN ((FILE), 2);                                      \
107      ASM_OUTPUT_INTERNAL_LABEL ((FILE), PREFIX, NUM);                   \
108    } while (0)
109
110 /* This is how to equate one symbol to another symbol.  The syntax used is
111    `SYM1=SYM2'.  Note that this is different from the way equates are done
112    with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'.  */
113
114 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
115  do {   fprintf ((FILE), "\t");                                         \
116         assemble_name (FILE, LABEL1);                                   \
117         fprintf (FILE, " = ");                                          \
118         assemble_name (FILE, LABEL2);                                   \
119         fprintf (FILE, "\n");                                           \
120   } while (0)
121
122 /* Define how the Sparc registers should be numbered for Dwarf output.
123    The numbering provided here should be compatible with the native
124    svr4 SDB debugger in the Sparc/svr4 reference port.  The numbering
125    is as follows:
126
127    Assembly name        gcc internal regno      Dwarf regno
128    ----------------------------------------------------------
129    g0-g7                0-7                     0-7
130    o0-o7                8-15                    8-15
131    l0-l7                16-23                   16-23
132    i0-i7                24-31                   24-31
133    f0-f31               32-63                   40-71
134 */
135
136 #define DBX_REGISTER_NUMBER(REGNO)                                      \
137   (((REGNO) < 32) ? (REGNO)                                             \
138    : ((REGNO) < 63) ? ((REGNO) + 8)                                     \
139    : (abort (), 0))
140
141 /* A set of symbol definitions for assembly pseudo-ops which will
142    get us switched to various sections of interest.  These are used
143    in all places where we simply want to switch to a section, and
144    *not* to push the previous section name onto the assembler's
145    section names stack (as we do often in dwarfout.c).  */
146
147 #define TEXT_SECTION_ASM_OP     ".section\t\".text\""
148 #define DATA_SECTION_ASM_OP     ".section\t\".data\""
149 #define BSS_SECTION_ASM_OP      ".section\t\".bss\""
150 #define CONST_SECTION_ASM_OP    ".section\t\".rodata\""
151 #define INIT_SECTION_ASM_OP     ".section\t\".init\",#alloc"
152 #define CTORS_SECTION_ASM_OP    ".section\t\".ctors\",#alloc"
153 #define DTORS_SECTION_ASM_OP    ".section\t\".dtors\",#alloc"
154
155 /* Code to handle #pragma directives.  The interface is a bit messy,
156    but there's no simpler way to do this while still using yylex.  */
157 #define HANDLE_PRAGMA(FILE)                                     \
158   do {                                                          \
159     while (c == ' ' || c == '\t')                               \
160       c = getc (FILE);                                          \
161     if (c == '\n' || c == EOF)                                  \
162       {                                                         \
163         handle_pragma_token (0, 0);                             \
164         return c;                                               \
165       }                                                         \
166     ungetc (c, FILE);                                           \
167     switch (yylex ())                                           \
168       {                                                         \
169       case IDENTIFIER:                                          \
170       case TYPENAME:                                            \
171       case STRING:                                              \
172       case CONSTANT:                                            \
173         handle_pragma_token (token_buffer, yylval.ttype);       \
174         break;                                                  \
175       default:                                                  \
176         handle_pragma_token (token_buffer, 0);                  \
177       }                                                         \
178     if (nextchar >= 0)                                          \
179       c = nextchar, nextchar = -1;                              \
180     else                                                        \
181       c = getc (FILE);                                          \
182   } while (1)
183
184 /* If the host and target formats match, output the floats as hex.  */
185 #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
186 #if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN
187
188 /* This is how to output assembly code to define a `float' constant.
189    We always have to use a .long pseudo-op to do this because the native
190    SVR4 ELF assembler is buggy and it generates incorrect values when we
191    try to use the .float pseudo-op instead.  */
192
193 #undef ASM_OUTPUT_FLOAT
194 #define ASM_OUTPUT_FLOAT(FILE,VALUE)                                    \
195 do { long value;                                                        \
196      REAL_VALUE_TO_TARGET_SINGLE ((VALUE), value);                      \
197      fprintf((FILE), "\t.long\t0x%x\n", value);                         \
198    } while (0)
199
200 /* This is how to output assembly code to define a `double' constant.
201    We always have to use a pair of .long pseudo-ops to do this because
202    the native SVR4 ELF assembler is buggy and it generates incorrect
203    values when we try to use the the .double pseudo-op instead.  */
204
205 #undef ASM_OUTPUT_DOUBLE
206 #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                                   \
207 do { long value[2];                                                     \
208      REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), value);                      \
209      fprintf((FILE), "\t.long\t0x%x\n", value[0]);                      \
210      fprintf((FILE), "\t.long\t0x%x\n", value[1]);                      \
211    } while (0)
212
213 #endif /* word order matches */
214 #endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */