OSDN Git Service

(FUNCTION_BLOCK_PROFILER, BLOCK_PROFILER): Define.
[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 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, 675 Mass Ave, Cambridge, MA 02139, 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 DBX_DEBUGGING_INFO
28 #undef WORD_SWITCH_TAKES_ARG
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 /* Undefined some symbols which are defined in "svr4.h" but which are
37    appropriate only for typical svr4 systems, but not for the specific
38    case of svr4 running on a Sparc.  */
39
40 #undef CTORS_SECTION_ASM_OP
41 #undef DTORS_SECTION_ASM_OP
42 #undef INIT_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__ \
56    -Asystem(unix) -Asystem(svr4) -Acpu(sparc) -Amachine(sparc) \
57    -D__GCC_NEW_VARARGS__"
58
59 /* The native assembler can't compute differences between symbols in different
60    sections when generating pic code, so we must put jump tables in the
61    text section.  */
62 #define JUMP_TABLES_IN_TEXT_SECTION 1
63
64 /* Pass -K to the assembler when PIC.  */
65 #undef ASM_SPEC
66 #define ASM_SPEC \
67   "%{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
68    %{fpic:-K PIC} %{fPIC:-K PIC}"
69
70 /* Must use data section for relocatable constants when pic.  */
71 #undef SELECT_RTX_SECTION
72 #define SELECT_RTX_SECTION(MODE,RTX)            \
73 {                                               \
74   if (flag_pic && symbolic_operand (RTX))       \
75     data_section ();                            \
76   else                                          \
77     const_section ();                           \
78 }
79
80 /* The specialized code which needs to appear in the .init section prior
81    to the prologue code for `__do_global_ctors' (see crtstuff.c).
82
83    On Sparcs running svr4, the /usr/ccs/lib/crti.o file (with gets linked
84    in prior to the crtbegin.o file) has a single `save' instruction in its
85    .init section.  That `save' instruction tries to setup a stack frame for
86    the sake of any subsequent code in the .init section.  Unfortunately,
87    the size it uses for the stack frame is only a guess, and is not really
88    adequate for our purposes.  More importantly, we independently put our
89    own standard function prologue (for __do_global_ctors) into the .init
90    section and that function prologue includes its own `save' instruction!
91    Thus, unless we do something to correct the situation, we'll get *two*
92    stack frames allocated when crt0.o calls the code in the .init section,
93    and havoc will ensue.  The following macro definition prevents such woes.
94 */
95
96 #define INIT_SECTION_PREAMBLE   asm ("restore")
97
98 /* This is the string used to begin an assembly language comment for the
99    Sparc/svr4 assembler.  */
100
101 #define ASM_COMMENT_START "!"
102
103 /* Define the names of various pseudo-op used by the Sparc/svr4 assembler.
104    Note that many of these are different from the typical pseudo-ops used
105    by most svr4 assemblers.  That is probably due to a (misguided?) attempt
106    to keep the Sparc/svr4 assembler somewhat compatible with the Sparc/SunOS
107    assembler.  */
108
109 #define STRING_ASM_OP           ".asciz"
110 #define COMMON_ASM_OP           ".common"
111 #define SKIP_ASM_OP             ".skip"
112 #define UNALIGNED_INT_ASM_OP    ".uaword"
113 #define UNALIGNED_SHORT_ASM_OP  ".uahalf"
114 #define PUSHSECTION_ASM_OP      ".pushsection"
115 #define POPSECTION_ASM_OP       ".popsection"
116
117 /* This is the format used to print the second operand of a .type pseudo-op
118    for the Sparc/svr4 assembler.  */
119
120 #define TYPE_OPERAND_FMT      "#%s"
121
122 /* This is the format used to print a .pushsection pseudo-op (and its operand)
123    for the Sparc/svr4 assembler.  */
124
125 #define PUSHSECTION_FORMAT      "\t%s\t\"%s\"\n"
126
127 #undef ASM_OUTPUT_CASE_LABEL
128 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)             \
129 do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3);                \
130      ASM_OUTPUT_INTERNAL_LABEL ((FILE), PREFIX, NUM);                   \
131    } while (0)
132
133 /* This is how to equate one symbol to another symbol.  The syntax used is
134    `SYM1=SYM2'.  Note that this is different from the way equates are done
135    with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'.  */
136
137 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
138  do {   fprintf ((FILE), "\t");                                         \
139         assemble_name (FILE, LABEL1);                                   \
140         fprintf (FILE, " = ");                                          \
141         assemble_name (FILE, LABEL2);                                   \
142         fprintf (FILE, "\n");                                           \
143   } while (0)
144
145 /* Define how the Sparc registers should be numbered for Dwarf output.
146    The numbering provided here should be compatible with the native
147    svr4 SDB debugger in the Sparc/svr4 reference port.  The numbering
148    is as follows:
149
150    Assembly name        gcc internal regno      Dwarf regno
151    ----------------------------------------------------------
152    g0-g7                0-7                     0-7
153    o0-o7                8-15                    8-15
154    l0-l7                16-23                   16-23
155    i0-i7                24-31                   24-31
156    f0-f31               32-63                   40-71
157 */
158
159 #define DBX_REGISTER_NUMBER(REGNO)                                      \
160   (((REGNO) < 32) ? (REGNO)                                             \
161    : ((REGNO) < 63) ? ((REGNO) + 8)                                     \
162    : (abort (), 0))
163
164 /* A set of symbol definitions for assembly pseudo-ops which will
165    get us switched to various sections of interest.  These are used
166    in all places where we simply want to switch to a section, and
167    *not* to push the previous section name onto the assembler's
168    section names stack (as we do often in dwarfout.c).  */
169
170 #define TEXT_SECTION_ASM_OP     ".section\t\".text\""
171 #define DATA_SECTION_ASM_OP     ".section\t\".data\""
172 #define BSS_SECTION_ASM_OP      ".section\t\".bss\""
173 #define CONST_SECTION_ASM_OP    ".section\t\".rodata\""
174 #define INIT_SECTION_ASM_OP     ".section\t\".init\""
175 #define CTORS_SECTION_ASM_OP    ".section\t\".ctors\",#alloc,#execinstr"
176 #define DTORS_SECTION_ASM_OP    ".section\t\".dtors\",#alloc,#execinstr"
177
178 /* Assemble generic sections.
179    This is currently only used to support section attributes.  */
180
181 #define ASM_OUTPUT_SECTION_NAME(FILE, NAME) \
182    fprintf (FILE, ".section\t\"%s\"\n", NAME)
183
184 /* If the host and target formats match, output the floats as hex.  */
185 #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
186 #if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN
187
188 /* This is how to output assembly code to define a `float' constant.
189    We always have to use a .long pseudo-op to do this because the native
190    SVR4 ELF assembler is buggy and it generates incorrect values when we
191    try to use the .float pseudo-op instead.  */
192
193 #undef ASM_OUTPUT_FLOAT
194 #define ASM_OUTPUT_FLOAT(FILE,VALUE)                                    \
195 do { long value;                                                        \
196      REAL_VALUE_TO_TARGET_SINGLE ((VALUE), value);                      \
197      fprintf((FILE), "\t.long\t0x%x\n", value);                         \
198    } while (0)
199
200 /* This is how to output assembly code to define a `double' constant.
201    We always have to use a pair of .long pseudo-ops to do this because
202    the native SVR4 ELF assembler is buggy and it generates incorrect
203    values when we try to use the the .double pseudo-op instead.  */
204
205 #undef ASM_OUTPUT_DOUBLE
206 #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                                   \
207 do { long value[2];                                                     \
208      REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), value);                      \
209      fprintf((FILE), "\t.long\t0x%x\n", value[0]);                      \
210      fprintf((FILE), "\t.long\t0x%x\n", value[1]);                      \
211    } while (0)
212
213 #endif /* word order matches */
214 #endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */
215
216 /* This is how to output an assembler line defining a `long double'
217    constant.  */
218
219 #undef ASM_OUTPUT_LONG_DOUBLE
220 #define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE)                              \
221 do { long value[4];                                                     \
222      REAL_VALUE_TO_TARGET_LONG_DOUBLE ((VALUE), value);                 \
223      fprintf((FILE), "\t.long\t0x%x\n", value[0]);                      \
224      fprintf((FILE), "\t.long\t0x%x\n", value[1]);                      \
225      fprintf((FILE), "\t.long\t0x%x\n", value[2]);                      \
226      fprintf((FILE), "\t.long\t0x%x\n", value[3]);                      \
227    } while (0)
228 \f
229 /* Output assembler code to FILE to initialize this source file's
230    basic block profiling info, if that has not already been done.  */
231
232 #undef FUNCTION_BLOCK_PROFILER
233 #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO)  \
234   do { \
235     if (TARGET_MEDANY) \
236       fprintf (FILE, "\tsethi %%hi(.LLPBX0),%%o0\n\tor %%0,%%lo(.LLPBX0),%%o0\n\tld [%s+%%o0],%%o1\n\ttst %%o1\n\tbne .LLPY%d\n\tadd %%o0,%s,%%o0\n\tcall __bb_init_func\n\tnop\nLPY%d:\n", \
237                MEDANY_BASE_REG, (LABELNO), MEDANY_BASE_REG, (LABELNO)); \
238     else \
239       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", \
240                (LABELNO), (LABELNO)); \
241   } while (0)
242
243 /* Output assembler code to FILE to increment the entry-count for
244    the BLOCKNO'th basic block in this source file.  */
245
246 #undef BLOCK_PROFILER
247 #define BLOCK_PROFILER(FILE, BLOCKNO) \
248 { \
249   int blockn = (BLOCKNO); \
250   if (TARGET_MEDANY) \
251     fprintf (FILE, "\tsethi %%hi(.LLPBX2+%d),%%g1\n\tor %%g1,%%lo(.LLPBX2+%d),%%g1\n\tld [%%g1+%s],%%g2\n\tadd %%g2,1,%%g2\n\tst %%g2,[%%g1+%s]\n", \
252              4 * blockn, 4 * blockn, MEDANY_BASE_REG, MEDANY_BASE_REG); \
253   else \
254     fprintf (FILE, "\tsethi %%hi(.LLPBX2+%d),%%g1\n\tld [%%lo(.LLPBX2+%d)+%%g1],%%g2\n\
255 \tadd %%g2,1,%%g2\n\tst %%g2,[%%lo(.LLPBX2+%d)+%%g1]\n", \
256              4 * blockn, 4 * blockn, 4 * blockn); \
257 }
258