OSDN Git Service

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