OSDN Git Service

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