OSDN Git Service

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