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