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).
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 /* ??? 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
42 #define SIZE_TYPE (TARGET_ARCH64 ? "long unsigned int" : "unsigned int")
45 #define PTRDIFF_TYPE (TARGET_ARCH64 ? "long int" : "int")
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. */
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
59 #undef SET_ASM_OP /* Has no equivalent. See ASM_OUTPUT_DEF below. */
61 /* Provide a set of pre-definitions and pre-assertions appropriate for
62 the Sparc running svr4. __svr4__ is our extension. */
64 #define CPP_PREDEFINES \
65 "-Dsparc -Dunix -D__svr4__ -Asystem=unix -Asystem=svr4"
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
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
74 /* Pass -K to the assembler when PIC. */
77 "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
78 %{fpic:-K PIC} %{fPIC:-K PIC} %(asm_cpu)"
80 /* Must use data section for relocatable constants when pic. */
81 #undef SELECT_RTX_SECTION
82 #define SELECT_RTX_SECTION(MODE,RTX,ALIGN) \
84 if (flag_pic && symbolic_operand ((RTX), (MODE))) \
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
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"
105 /* This is defined in sparc.h but is not used by svr4.h. */
107 #define ASM_LONG ".long"
109 /* This is the format used to print the second operand of a .type pseudo-op
110 for the Sparc/svr4 assembler. */
112 #define TYPE_OPERAND_FMT "#%s"
114 /* This is the format used to print a .pushsection pseudo-op (and its operand)
115 for the Sparc/svr4 assembler. */
117 #define PUSHSECTION_FORMAT "%s\"%s\"\n"
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); \
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'. */
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"); \
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
142 Assembly name gcc internal regno Dwarf regno
143 ----------------------------------------------------------
151 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 32 ? (REGNO) : (REGNO) + 8)
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). */
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\""
166 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
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.) */
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"
186 /* Switch into a generic section. */
187 #undef TARGET_ASM_NAMED_SECTION
188 #define TARGET_ASM_NAMED_SECTION sparc_elf_asm_named_section
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. */
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)
199 /* Override the name of the mcount profiling function. */
201 #undef MCOUNT_FUNCTION
202 #define MCOUNT_FUNCTION "*_mcount"