1 /* Target definitions for GNU compiler for Sparc running System V.4
2 Copyright (C) 1991, 92, 95, 96, 97, 1998 Free Software Foundation, Inc.
3 Contributed by Ron Guilmette (rfg@monkeys.com).
5 This file is part of GNU CC.
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)
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.
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. */
22 #include "sparc/sparc.h"
24 /* Undefine some symbols which are defined in "sparc.h" but which are
25 appropriate only for SunOS 4.x, and not for svr4. */
27 #undef WORD_SWITCH_TAKES_ARG
28 #undef ASM_OUTPUT_SOURCE_LINE
30 #undef ASM_DECLARE_FUNCTION_NAME
31 #undef TEXT_SECTION_ASM_OP
32 #undef DATA_SECTION_ASM_OP
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
41 #define SIZE_TYPE (TARGET_ARCH64 ? "long unsigned int" : "unsigned int")
44 #define PTRDIFF_TYPE (TARGET_ARCH64 ? "long int" : "int")
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. */
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
58 #undef SET_ASM_OP /* Has no equivalent. See ASM_OUTPUT_DEF below. */
60 /* Provide a set of pre-definitions and pre-assertions appropriate for
61 the Sparc running svr4. __svr4__ is our extension. */
63 #define CPP_PREDEFINES \
64 "-Dsparc -Dunix -D__svr4__ -Asystem(unix) -Asystem(svr4)"
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
69 #define JUMP_TABLES_IN_TEXT_SECTION 1
71 /* Pass -K to the assembler when PIC. */
74 "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
75 %{fpic:-K PIC} %{fPIC:-K PIC} %(asm_cpu)"
77 /* Must use data section for relocatable constants when pic. */
78 #undef SELECT_RTX_SECTION
79 #define SELECT_RTX_SECTION(MODE,RTX) \
81 if (flag_pic && symbolic_operand (RTX)) \
87 /* Define the names of various pseudo-op used by the Sparc/svr4 assembler.
88 Note that many of these are different from the typical pseudo-ops used
89 by most svr4 assemblers. That is probably due to a (misguided?) attempt
90 to keep the Sparc/svr4 assembler somewhat compatible with the Sparc/SunOS
93 #define STRING_ASM_OP ".asciz"
94 #define COMMON_ASM_OP ".common"
95 #define SKIP_ASM_OP ".skip"
96 #define UNALIGNED_DOUBLE_INT_ASM_OP ".uaxword"
97 #define UNALIGNED_INT_ASM_OP ".uaword"
98 #define UNALIGNED_SHORT_ASM_OP ".uahalf"
99 #define PUSHSECTION_ASM_OP ".pushsection"
100 #define POPSECTION_ASM_OP ".popsection"
102 /* This is defined in sparc.h but is not used by svr4.h. */
104 #define ASM_LONG ".long"
106 /* This is the format used to print the second operand of a .type pseudo-op
107 for the Sparc/svr4 assembler. */
109 #define TYPE_OPERAND_FMT "#%s"
111 /* This is the format used to print a .pushsection pseudo-op (and its operand)
112 for the Sparc/svr4 assembler. */
114 #define PUSHSECTION_FORMAT "\t%s\t\"%s\"\n"
116 #undef ASM_OUTPUT_CASE_LABEL
117 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
118 do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \
119 ASM_OUTPUT_INTERNAL_LABEL ((FILE), PREFIX, NUM); \
122 /* This is how to equate one symbol to another symbol. The syntax used is
123 `SYM1=SYM2'. Note that this is different from the way equates are done
124 with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'. */
126 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
127 do { fprintf ((FILE), "\t"); \
128 assemble_name (FILE, LABEL1); \
129 fprintf (FILE, " = "); \
130 assemble_name (FILE, LABEL2); \
131 fprintf (FILE, "\n"); \
134 /* Define how the Sparc registers should be numbered for Dwarf output.
135 The numbering provided here should be compatible with the native
136 svr4 SDB debugger in the Sparc/svr4 reference port. The numbering
139 Assembly name gcc internal regno Dwarf regno
140 ----------------------------------------------------------
148 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 32 ? (REGNO) : (REGNO) + 8)
150 /* A set of symbol definitions for assembly pseudo-ops which will
151 get us switched to various sections of interest. These are used
152 in all places where we simply want to switch to a section, and
153 *not* to push the previous section name onto the assembler's
154 section names stack (as we do often in dwarfout.c). */
156 #define TEXT_SECTION_ASM_OP ".section\t\".text\""
157 #define DATA_SECTION_ASM_OP ".section\t\".data\""
158 #define BSS_SECTION_ASM_OP ".section\t\".bss\""
159 #define CONST_SECTION_ASM_OP ".section\t\".rodata\""
160 #define INIT_SECTION_ASM_OP ".section\t\".init\""
161 #define FINI_SECTION_ASM_OP ".section\t\".fini\""
163 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
165 Note that we want to give these sections the SHF_WRITE attribute
166 because these sections will actually contain data (i.e. tables of
167 addresses of functions in the current root executable or shared library
168 file) and, in the case of a shared library, the relocatable addresses
169 will have to be properly resolved/relocated (and then written into) by
170 the dynamic linker when it actually attaches the given shared library
171 to the executing process. (Note that on SVR4, you may wish to use the
172 `-z text' option to the ELF linker, when building a shared library, as
173 an additional check that you are doing everything right. But if you do
174 use the `-z text' option when building a shared library, you will get
175 errors unless the .ctors and .dtors sections are marked as writable
176 via the SHF_WRITE attribute.) */
178 #undef CTORS_SECTION_ASM_OP
179 #define CTORS_SECTION_ASM_OP ".section\t\".ctors\",#alloc,#write"
180 #undef DTORS_SECTION_ASM_OP
181 #define DTORS_SECTION_ASM_OP ".section\t\".dtors\",#alloc,#write"
182 #undef EH_FRAME_SECTION_ASM_OP
183 #define EH_FRAME_SECTION_ASM_OP ".section\t\".eh_frame\",#alloc,#write"
185 /* A C statement to output something to the assembler file to switch to section
186 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
187 NULL_TREE. Some target formats do not support arbitrary sections. Do not
188 define this macro in such cases. */
190 #undef ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition. */
191 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
193 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
194 fprintf (FILE, ".section\t\"%s%s\",#alloc,#execinstr\n", \
195 flag_function_sections ? ".text%" : "", (NAME)); \
196 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
197 fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME)); \
199 fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME)); \
202 /* Output assembler code to FILE to initialize this source file's
203 basic block profiling info, if that has not already been done. */
205 #undef FUNCTION_BLOCK_PROFILER
206 #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \
208 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", \
209 (LABELNO), (LABELNO)); \
212 /* Output assembler code to FILE to increment the entry-count for
213 the BLOCKNO'th basic block in this source file. */
215 #undef BLOCK_PROFILER
216 #define BLOCK_PROFILER(FILE, BLOCKNO) \
218 int blockn = (BLOCKNO); \
219 fprintf (FILE, "\tsethi %%hi(.LLPBX2+%d),%%g1\n\tld [%%lo(.LLPBX2+%d)+%%g1],%%g2\n\
220 \tadd %%g2,1,%%g2\n\tst %%g2,[%%lo(.LLPBX2+%d)+%%g1]\n", \
221 4 * blockn, 4 * blockn, 4 * blockn); \
224 /* A C statement (sans semicolon) to output to the stdio stream
225 FILE the assembler definition of uninitialized global DECL named
226 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
227 Try to use asm_output_aligned_bss to implement this macro. */
229 #undef ASM_OUTPUT_ALIGNED_BSS
230 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
231 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)