OSDN Git Service

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