OSDN Git Service

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