OSDN Git Service

Support for official Sparc V9 ABI:
[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, 92, 95, 96, 97, 1998 Free Software Foundation, Inc.
3    Contributed by Ron Guilmette (rfg@monkeys.com).
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 #include "sparc/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 WORD_SWITCH_TAKES_ARG
28 #undef ASM_OUTPUT_SOURCE_LINE
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 /* ??? Put back the SIZE_TYPE/PTRDIFF_TYPE definitions set by sparc.h.
37    Why, exactly, is svr4.h messing with this?  Seems like the chip 
38    would know best.  */
39
40 #undef SIZE_TYPE
41 #define SIZE_TYPE (TARGET_ARCH64 ? "long unsigned int" : "unsigned int")
42
43 #undef PTRDIFF_TYPE
44 #define PTRDIFF_TYPE (TARGET_ARCH64 ? "long int" : "int")
45
46 /* Undefined some symbols which are defined in "svr4.h" but which are
47    appropriate only for typical svr4 systems, but not for the specific
48    case of svr4 running on a Sparc.  */
49
50 #undef INIT_SECTION_ASM_OP
51 #undef FINI_SECTION_ASM_OP
52 #undef CONST_SECTION_ASM_OP
53 #undef TYPE_OPERAND_FMT
54 #undef PUSHSECTION_FORMAT
55 #undef STRING_ASM_OP
56 #undef COMMON_ASM_OP
57 #undef SKIP_ASM_OP
58 #undef SET_ASM_OP       /* Has no equivalent.  See ASM_OUTPUT_DEF below.  */
59
60 /* Provide a set of pre-definitions and pre-assertions appropriate for
61    the Sparc running svr4.  __svr4__ is our extension.  */
62
63 #define CPP_PREDEFINES \
64 "-Dsparc -Dunix -D__svr4__ -Asystem(unix) -Asystem(svr4)"
65
66 /* The native assembler can't compute differences between symbols in different
67    sections when generating pic code, so we must put jump tables in the
68    text section.  */
69 #define JUMP_TABLES_IN_TEXT_SECTION 1
70
71 /* Pass -K to the assembler when PIC.  */
72 #undef ASM_SPEC
73 #define ASM_SPEC \
74   "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
75    %{fpic:-K PIC} %{fPIC:-K PIC} %(asm_cpu)"
76
77 /* Must use data section for relocatable constants when pic.  */
78 #undef SELECT_RTX_SECTION
79 #define SELECT_RTX_SECTION(MODE,RTX)            \
80 {                                               \
81   if (flag_pic && symbolic_operand (RTX))       \
82     data_section ();                            \
83   else                                          \
84     const_section ();                           \
85 }
86
87 /* Define the names of various pseudo-op used by the Sparc/svr4 assembler.
88    Note that many of these are different from the typical pseudo-ops used
89    by most svr4 assemblers.  That is probably due to a (misguided?) attempt
90    to keep the Sparc/svr4 assembler somewhat compatible with the Sparc/SunOS
91    assembler.  */
92
93 #define STRING_ASM_OP           ".asciz"
94 #define COMMON_ASM_OP           ".common"
95 #define SKIP_ASM_OP             ".skip"
96 #define UNALIGNED_DOUBLE_INT_ASM_OP ".uaxword"
97 #define UNALIGNED_INT_ASM_OP    ".uaword"
98 #define UNALIGNED_SHORT_ASM_OP  ".uahalf"
99 #define PUSHSECTION_ASM_OP      ".pushsection"
100 #define POPSECTION_ASM_OP       ".popsection"
101
102 /* This is defined in sparc.h but is not used by svr4.h.  */
103 #undef ASM_LONG
104 #define ASM_LONG ".long"
105
106 /* This is the format used to print the second operand of a .type pseudo-op
107    for the Sparc/svr4 assembler.  */
108
109 #define TYPE_OPERAND_FMT      "#%s"
110
111 /* This is the format used to print a .pushsection pseudo-op (and its operand)
112    for the Sparc/svr4 assembler.  */
113
114 #define PUSHSECTION_FORMAT      "\t%s\t\"%s\"\n"
115
116 #undef ASM_OUTPUT_CASE_LABEL
117 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)             \
118 do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3);                \
119      ASM_OUTPUT_INTERNAL_LABEL ((FILE), PREFIX, NUM);                   \
120    } while (0)
121
122 /* This is how to equate one symbol to another symbol.  The syntax used is
123    `SYM1=SYM2'.  Note that this is different from the way equates are done
124    with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'.  */
125
126 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
127  do {   fprintf ((FILE), "\t");                                         \
128         assemble_name (FILE, LABEL1);                                   \
129         fprintf (FILE, " = ");                                          \
130         assemble_name (FILE, LABEL2);                                   \
131         fprintf (FILE, "\n");                                           \
132   } while (0)
133
134 /* Define how the Sparc registers should be numbered for Dwarf output.
135    The numbering provided here should be compatible with the native
136    svr4 SDB debugger in the Sparc/svr4 reference port.  The numbering
137    is as follows:
138
139    Assembly name        gcc internal regno      Dwarf regno
140    ----------------------------------------------------------
141    g0-g7                0-7                     0-7
142    o0-o7                8-15                    8-15
143    l0-l7                16-23                   16-23
144    i0-i7                24-31                   24-31
145    f0-f31               32-63                   40-71
146 */
147
148 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 32 ? (REGNO) : (REGNO) + 8)
149
150 /* A set of symbol definitions for assembly pseudo-ops which will
151    get us switched to various sections of interest.  These are used
152    in all places where we simply want to switch to a section, and
153    *not* to push the previous section name onto the assembler's
154    section names stack (as we do often in dwarfout.c).  */
155
156 #define TEXT_SECTION_ASM_OP     ".section\t\".text\""
157 #define DATA_SECTION_ASM_OP     ".section\t\".data\""
158 #define BSS_SECTION_ASM_OP      ".section\t\".bss\""
159 #define CONST_SECTION_ASM_OP    ".section\t\".rodata\""
160 #define INIT_SECTION_ASM_OP     ".section\t\".init\""
161 #define FINI_SECTION_ASM_OP     ".section\t\".fini\""
162
163 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
164  
165    Note that we want to give these sections the SHF_WRITE attribute
166    because these sections will actually contain data (i.e. tables of
167    addresses of functions in the current root executable or shared library
168    file) and, in the case of a shared library, the relocatable addresses
169    will have to be properly resolved/relocated (and then written into) by
170    the dynamic linker when it actually attaches the given shared library
171    to the executing process.  (Note that on SVR4, you may wish to use the
172    `-z text' option to the ELF linker, when building a shared library, as
173    an additional check that you are doing everything right.  But if you do
174    use the `-z text' option when building a shared library, you will get
175    errors unless the .ctors and .dtors sections are marked as writable
176    via the SHF_WRITE attribute.)  */
177  
178 #undef CTORS_SECTION_ASM_OP
179 #define CTORS_SECTION_ASM_OP    ".section\t\".ctors\",#alloc,#write"
180 #undef DTORS_SECTION_ASM_OP
181 #define DTORS_SECTION_ASM_OP    ".section\t\".dtors\",#alloc,#write"
182 #undef EH_FRAME_SECTION_ASM_OP
183 #define EH_FRAME_SECTION_ASM_OP ".section\t\".eh_frame\",#alloc,#write"
184
185 /* A C statement to output something to the assembler file to switch to section
186    NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
187    NULL_TREE.  Some target formats do not support arbitrary sections.  Do not
188    define this macro in such cases.  */
189
190 #undef  ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition.  */
191 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
192 do {                                                                    \
193   if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)                      \
194     fprintf (FILE, ".section\t\"%s%s\",#alloc,#execinstr\n",            \
195              flag_function_sections ? ".text%" : "", (NAME));           \
196   else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC))               \
197     fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME));                \
198   else                                                                  \
199     fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME));         \
200 } while (0)
201 \f
202 /* Output assembler code to FILE to initialize this source file's
203    basic block profiling info, if that has not already been done.  */
204
205 #undef FUNCTION_BLOCK_PROFILER
206 #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO)  \
207   do { \
208     fprintf (FILE, "\tsethi %%hi(.LLPBX0),%%o0\n\tld [%%lo(.LLPBX0)+%%o0],%%o1\n\ttst %%o1\n\tbne LPY%d\n\tadd %%o0,%%lo(.LLPBX0),%%o0\n\tcall __bb_init_func\n\tnop\nLPY%d:\n", \
209              (LABELNO), (LABELNO)); \
210   } while (0)
211
212 /* Output assembler code to FILE to increment the entry-count for
213    the BLOCKNO'th basic block in this source file.  */
214
215 #undef BLOCK_PROFILER
216 #define BLOCK_PROFILER(FILE, BLOCKNO) \
217 { \
218   int blockn = (BLOCKNO); \
219   fprintf (FILE, "\tsethi %%hi(.LLPBX2+%d),%%g1\n\tld [%%lo(.LLPBX2+%d)+%%g1],%%g2\n\
220 \tadd %%g2,1,%%g2\n\tst %%g2,[%%lo(.LLPBX2+%d)+%%g1]\n", \
221            4 * blockn, 4 * blockn, 4 * blockn); \
222 }
223
224 /* A C statement (sans semicolon) to output to the stdio stream
225    FILE the assembler definition of uninitialized global DECL named
226    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
227    Try to use asm_output_aligned_bss to implement this macro.  */
228
229 #undef ASM_OUTPUT_ALIGNED_BSS
230 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
231   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)