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 /* But we now defer the tables to the end of the function, so we make
70 this 0 to not confuse the branch shortening code. */
71 #define JUMP_TABLES_IN_TEXT_SECTION 0
73 /* Pass -K to the assembler when PIC. */
76 "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
77 %{fpic:-K PIC} %{fPIC:-K PIC} %(asm_cpu)"
79 /* Must use data section for relocatable constants when pic. */
80 #undef SELECT_RTX_SECTION
81 #define SELECT_RTX_SECTION(MODE,RTX) \
83 if (flag_pic && symbolic_operand ((RTX), (MODE))) \
89 /* Define the names of various pseudo-op used by the Sparc/svr4 assembler.
90 Note that many of these are different from the typical pseudo-ops used
91 by most svr4 assemblers. That is probably due to a (misguided?) attempt
92 to keep the Sparc/svr4 assembler somewhat compatible with the Sparc/SunOS
95 #define STRING_ASM_OP ".asciz"
96 #define COMMON_ASM_OP ".common"
97 #define SKIP_ASM_OP ".skip"
98 #define UNALIGNED_DOUBLE_INT_ASM_OP ".uaxword"
99 #define UNALIGNED_INT_ASM_OP ".uaword"
100 #define UNALIGNED_SHORT_ASM_OP ".uahalf"
101 #define PUSHSECTION_ASM_OP ".pushsection"
102 #define POPSECTION_ASM_OP ".popsection"
104 /* This is defined in sparc.h but is not used by svr4.h. */
106 #define ASM_LONG ".long"
108 /* This is the format used to print the second operand of a .type pseudo-op
109 for the Sparc/svr4 assembler. */
111 #define TYPE_OPERAND_FMT "#%s"
113 /* This is the format used to print a .pushsection pseudo-op (and its operand)
114 for the Sparc/svr4 assembler. */
116 #define PUSHSECTION_FORMAT "\t%s\t\"%s\"\n"
118 #undef ASM_OUTPUT_CASE_LABEL
119 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
120 do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \
121 ASM_OUTPUT_INTERNAL_LABEL ((FILE), PREFIX, NUM); \
124 /* This is how to equate one symbol to another symbol. The syntax used is
125 `SYM1=SYM2'. Note that this is different from the way equates are done
126 with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'. */
128 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
129 do { fprintf ((FILE), "\t"); \
130 assemble_name (FILE, LABEL1); \
131 fprintf (FILE, " = "); \
132 assemble_name (FILE, LABEL2); \
133 fprintf (FILE, "\n"); \
136 /* Define how the Sparc registers should be numbered for Dwarf output.
137 The numbering provided here should be compatible with the native
138 svr4 SDB debugger in the Sparc/svr4 reference port. The numbering
141 Assembly name gcc internal regno Dwarf regno
142 ----------------------------------------------------------
150 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 32 ? (REGNO) : (REGNO) + 8)
152 /* A set of symbol definitions for assembly pseudo-ops which will
153 get us switched to various sections of interest. These are used
154 in all places where we simply want to switch to a section, and
155 *not* to push the previous section name onto the assembler's
156 section names stack (as we do often in dwarfout.c). */
158 #define TEXT_SECTION_ASM_OP ".section\t\".text\""
159 #define DATA_SECTION_ASM_OP ".section\t\".data\""
160 #define BSS_SECTION_ASM_OP ".section\t\".bss\""
161 #define CONST_SECTION_ASM_OP ".section\t\".rodata\""
162 #define INIT_SECTION_ASM_OP ".section\t\".init\""
163 #define FINI_SECTION_ASM_OP ".section\t\".fini\""
165 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
167 Note that we want to give these sections the SHF_WRITE attribute
168 because these sections will actually contain data (i.e. tables of
169 addresses of functions in the current root executable or shared library
170 file) and, in the case of a shared library, the relocatable addresses
171 will have to be properly resolved/relocated (and then written into) by
172 the dynamic linker when it actually attaches the given shared library
173 to the executing process. (Note that on SVR4, you may wish to use the
174 `-z text' option to the ELF linker, when building a shared library, as
175 an additional check that you are doing everything right. But if you do
176 use the `-z text' option when building a shared library, you will get
177 errors unless the .ctors and .dtors sections are marked as writable
178 via the SHF_WRITE attribute.) */
180 #undef CTORS_SECTION_ASM_OP
181 #define CTORS_SECTION_ASM_OP ".section\t\".ctors\",#alloc,#write"
182 #undef DTORS_SECTION_ASM_OP
183 #define DTORS_SECTION_ASM_OP ".section\t\".dtors\",#alloc,#write"
184 #undef EH_FRAME_SECTION_ASM_OP
185 #define EH_FRAME_SECTION_ASM_OP ".section\t\".eh_frame\",#alloc,#write"
187 /* A C statement to output something to the assembler file to switch to section
188 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
189 NULL_TREE. Some target formats do not support arbitrary sections. Do not
190 define this macro in such cases. */
192 #undef ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition. */
193 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
195 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
196 fprintf (FILE, ".section\t\"%s\",#alloc,#execinstr\n", \
198 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
199 fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME)); \
201 fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME)); \
204 /* A C statement (sans semicolon) to output to the stdio stream
205 FILE the assembler definition of uninitialized global DECL named
206 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
207 Try to use asm_output_aligned_bss to implement this macro. */
209 #undef ASM_OUTPUT_ALIGNED_BSS
210 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
211 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
213 /* Override the name of the mcount profiling function. */
215 #undef MCOUNT_FUNCTION
216 #define MCOUNT_FUNCTION "*_mcount"