xref: /openbsd/gnu/usr.bin/gcc/gcc/config/sparc/sysv4.h (revision c87b03e5)
1*c87b03e5Sespie /* Target definitions for GNU compiler for SPARC running System V.4
2*c87b03e5Sespie    Copyright (C) 1991, 1992, 1995, 1996, 1997, 1998, 2000, 2002
3*c87b03e5Sespie    Free Software Foundation, Inc.
4*c87b03e5Sespie    Contributed by Ron Guilmette (rfg@monkeys.com).
5*c87b03e5Sespie 
6*c87b03e5Sespie This file is part of GNU CC.
7*c87b03e5Sespie 
8*c87b03e5Sespie GNU CC is free software; you can redistribute it and/or modify
9*c87b03e5Sespie it under the terms of the GNU General Public License as published by
10*c87b03e5Sespie the Free Software Foundation; either version 2, or (at your option)
11*c87b03e5Sespie any later version.
12*c87b03e5Sespie 
13*c87b03e5Sespie GNU CC is distributed in the hope that it will be useful,
14*c87b03e5Sespie but WITHOUT ANY WARRANTY; without even the implied warranty of
15*c87b03e5Sespie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*c87b03e5Sespie GNU General Public License for more details.
17*c87b03e5Sespie 
18*c87b03e5Sespie You should have received a copy of the GNU General Public License
19*c87b03e5Sespie along with GNU CC; see the file COPYING.  If not, write to
20*c87b03e5Sespie the Free Software Foundation, 59 Temple Place - Suite 330,
21*c87b03e5Sespie Boston, MA 02111-1307, USA.  */
22*c87b03e5Sespie 
23*c87b03e5Sespie #ifndef TARGET_VERSION
24*c87b03e5Sespie #define TARGET_VERSION fprintf (stderr, " (sparc ELF)");
25*c87b03e5Sespie #endif
26*c87b03e5Sespie 
27*c87b03e5Sespie /* ??? Put back the SIZE_TYPE/PTRDIFF_TYPE definitions set by sparc.h.
28*c87b03e5Sespie    Why, exactly, is svr4.h messing with this?  Seems like the chip
29*c87b03e5Sespie    would know best.  */
30*c87b03e5Sespie 
31*c87b03e5Sespie #undef SIZE_TYPE
32*c87b03e5Sespie #define SIZE_TYPE (TARGET_ARCH64 ? "long unsigned int" : "unsigned int")
33*c87b03e5Sespie 
34*c87b03e5Sespie #undef PTRDIFF_TYPE
35*c87b03e5Sespie #define PTRDIFF_TYPE (TARGET_ARCH64 ? "long int" : "int")
36*c87b03e5Sespie 
37*c87b03e5Sespie /* Undefined some symbols which are defined in "svr4.h" but which are
38*c87b03e5Sespie    appropriate only for typical svr4 systems, but not for the specific
39*c87b03e5Sespie    case of svr4 running on a SPARC.  */
40*c87b03e5Sespie 
41*c87b03e5Sespie #undef INIT_SECTION_ASM_OP
42*c87b03e5Sespie #undef FINI_SECTION_ASM_OP
43*c87b03e5Sespie #undef READONLY_DATA_SECTION_ASM_OP
44*c87b03e5Sespie #undef TYPE_OPERAND_FMT
45*c87b03e5Sespie #undef PUSHSECTION_FORMAT
46*c87b03e5Sespie #undef STRING_ASM_OP
47*c87b03e5Sespie #undef COMMON_ASM_OP
48*c87b03e5Sespie #undef SKIP_ASM_OP
49*c87b03e5Sespie #undef SET_ASM_OP	/* Has no equivalent.  See ASM_OUTPUT_DEF below.  */
50*c87b03e5Sespie 
51*c87b03e5Sespie /* Provide a set of pre-definitions and pre-assertions appropriate for
52*c87b03e5Sespie    the SPARC running svr4.  __svr4__ is our extension.  */
53*c87b03e5Sespie 
54*c87b03e5Sespie #undef  CPP_PREDEFINES
55*c87b03e5Sespie #define CPP_PREDEFINES \
56*c87b03e5Sespie "-Dsparc -Dunix -D__svr4__ -Asystem=unix -Asystem=svr4"
57*c87b03e5Sespie 
58*c87b03e5Sespie /* The native assembler can't compute differences between symbols in different
59*c87b03e5Sespie    sections when generating pic code, so we must put jump tables in the
60*c87b03e5Sespie    text section.  */
61*c87b03e5Sespie /* But we now defer the tables to the end of the function, so we make
62*c87b03e5Sespie    this 0 to not confuse the branch shortening code.  */
63*c87b03e5Sespie #define JUMP_TABLES_IN_TEXT_SECTION 0
64*c87b03e5Sespie 
65*c87b03e5Sespie /* Pass -K to the assembler when PIC.  */
66*c87b03e5Sespie #undef ASM_SPEC
67*c87b03e5Sespie #define ASM_SPEC \
68*c87b03e5Sespie   "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
69*c87b03e5Sespie    %{fpic:-K PIC} %{fPIC:-K PIC} %(asm_cpu)"
70*c87b03e5Sespie 
71*c87b03e5Sespie /* Define the names of various pseudo-op used by the SPARC/svr4 assembler.
72*c87b03e5Sespie    Note that many of these are different from the typical pseudo-ops used
73*c87b03e5Sespie    by most svr4 assemblers.  That is probably due to a (misguided?) attempt
74*c87b03e5Sespie    to keep the SPARC/svr4 assembler somewhat compatible with the SPARC/SunOS
75*c87b03e5Sespie    assembler.  */
76*c87b03e5Sespie 
77*c87b03e5Sespie #define STRING_ASM_OP		"\t.asciz\t"
78*c87b03e5Sespie #define COMMON_ASM_OP		"\t.common\t"
79*c87b03e5Sespie #define SKIP_ASM_OP		"\t.skip\t"
80*c87b03e5Sespie #define PUSHSECTION_ASM_OP	"\t.pushsection\t"
81*c87b03e5Sespie #define POPSECTION_ASM_OP	"\t.popsection"
82*c87b03e5Sespie 
83*c87b03e5Sespie /* This is the format used to print the second operand of a .type pseudo-op
84*c87b03e5Sespie    for the SPARC/svr4 assembler.  */
85*c87b03e5Sespie 
86*c87b03e5Sespie #define TYPE_OPERAND_FMT      "#%s"
87*c87b03e5Sespie 
88*c87b03e5Sespie /* This is the format used to print a .pushsection pseudo-op (and its operand)
89*c87b03e5Sespie    for the SPARC/svr4 assembler.  */
90*c87b03e5Sespie 
91*c87b03e5Sespie #define PUSHSECTION_FORMAT	"%s\"%s\"\n"
92*c87b03e5Sespie 
93*c87b03e5Sespie #undef ASM_OUTPUT_CASE_LABEL
94*c87b03e5Sespie #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)		\
95*c87b03e5Sespie do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3);		\
96*c87b03e5Sespie      ASM_OUTPUT_INTERNAL_LABEL ((FILE), PREFIX, NUM);			\
97*c87b03e5Sespie    } while (0)
98*c87b03e5Sespie 
99*c87b03e5Sespie /* This is how to equate one symbol to another symbol.  The syntax used is
100*c87b03e5Sespie    `SYM1=SYM2'.  Note that this is different from the way equates are done
101*c87b03e5Sespie    with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'.  */
102*c87b03e5Sespie 
103*c87b03e5Sespie #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)				\
104*c87b03e5Sespie  do {	fprintf ((FILE), "\t");						\
105*c87b03e5Sespie 	assemble_name (FILE, LABEL1);					\
106*c87b03e5Sespie 	fprintf (FILE, " = ");						\
107*c87b03e5Sespie 	assemble_name (FILE, LABEL2);					\
108*c87b03e5Sespie 	fprintf (FILE, "\n");						\
109*c87b03e5Sespie   } while (0)
110*c87b03e5Sespie 
111*c87b03e5Sespie /* Define how the SPARC registers should be numbered for Dwarf output.
112*c87b03e5Sespie    The numbering provided here should be compatible with the native
113*c87b03e5Sespie    svr4 SDB debugger in the SPARC/svr4 reference port.  The numbering
114*c87b03e5Sespie    is as follows:
115*c87b03e5Sespie 
116*c87b03e5Sespie    Assembly name	gcc internal regno	Dwarf regno
117*c87b03e5Sespie    ----------------------------------------------------------
118*c87b03e5Sespie    g0-g7		0-7			0-7
119*c87b03e5Sespie    o0-o7		8-15			8-15
120*c87b03e5Sespie    l0-l7		16-23			16-23
121*c87b03e5Sespie    i0-i7		24-31			24-31
122*c87b03e5Sespie    f0-f31		32-63			40-71
123*c87b03e5Sespie */
124*c87b03e5Sespie 
125*c87b03e5Sespie #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 32 ? (REGNO) : (REGNO) + 8)
126*c87b03e5Sespie 
127*c87b03e5Sespie /* A set of symbol definitions for assembly pseudo-ops which will
128*c87b03e5Sespie    get us switched to various sections of interest.  These are used
129*c87b03e5Sespie    in all places where we simply want to switch to a section, and
130*c87b03e5Sespie    *not* to push the previous section name onto the assembler's
131*c87b03e5Sespie    section names stack (as we do often in dwarfout.c).  */
132*c87b03e5Sespie 
133*c87b03e5Sespie #define TEXT_SECTION_ASM_OP	"\t.section\t\".text\""
134*c87b03e5Sespie #define DATA_SECTION_ASM_OP	"\t.section\t\".data\""
135*c87b03e5Sespie #define BSS_SECTION_ASM_OP	"\t.section\t\".bss\""
136*c87b03e5Sespie #define READONLY_DATA_SECTION_ASM_OP "\t.section\t\".rodata\""
137*c87b03e5Sespie #define INIT_SECTION_ASM_OP	"\t.section\t\".init\""
138*c87b03e5Sespie #define FINI_SECTION_ASM_OP	"\t.section\t\".fini\""
139*c87b03e5Sespie 
140*c87b03e5Sespie /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
141*c87b03e5Sespie 
142*c87b03e5Sespie    Note that we want to give these sections the SHF_WRITE attribute
143*c87b03e5Sespie    because these sections will actually contain data (i.e. tables of
144*c87b03e5Sespie    addresses of functions in the current root executable or shared library
145*c87b03e5Sespie    file) and, in the case of a shared library, the relocatable addresses
146*c87b03e5Sespie    will have to be properly resolved/relocated (and then written into) by
147*c87b03e5Sespie    the dynamic linker when it actually attaches the given shared library
148*c87b03e5Sespie    to the executing process.  (Note that on SVR4, you may wish to use the
149*c87b03e5Sespie    `-z text' option to the ELF linker, when building a shared library, as
150*c87b03e5Sespie    an additional check that you are doing everything right.  But if you do
151*c87b03e5Sespie    use the `-z text' option when building a shared library, you will get
152*c87b03e5Sespie    errors unless the .ctors and .dtors sections are marked as writable
153*c87b03e5Sespie    via the SHF_WRITE attribute.)  */
154*c87b03e5Sespie 
155*c87b03e5Sespie #undef CTORS_SECTION_ASM_OP
156*c87b03e5Sespie #define CTORS_SECTION_ASM_OP    "\t.section\t\".ctors\",#alloc,#write"
157*c87b03e5Sespie #undef DTORS_SECTION_ASM_OP
158*c87b03e5Sespie #define DTORS_SECTION_ASM_OP    "\t.section\t\".dtors\",#alloc,#write"
159*c87b03e5Sespie 
160*c87b03e5Sespie /* Switch into a generic section.  */
161*c87b03e5Sespie #undef TARGET_ASM_NAMED_SECTION
162*c87b03e5Sespie #define TARGET_ASM_NAMED_SECTION  sparc_elf_asm_named_section
163*c87b03e5Sespie 
164*c87b03e5Sespie /* A C statement (sans semicolon) to output to the stdio stream
165*c87b03e5Sespie    FILE the assembler definition of uninitialized global DECL named
166*c87b03e5Sespie    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
167*c87b03e5Sespie    Try to use asm_output_aligned_bss to implement this macro.  */
168*c87b03e5Sespie 
169*c87b03e5Sespie #undef ASM_OUTPUT_ALIGNED_BSS
170*c87b03e5Sespie #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
171*c87b03e5Sespie   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
172*c87b03e5Sespie 
173*c87b03e5Sespie /* Override the name of the mcount profiling function.  */
174*c87b03e5Sespie 
175*c87b03e5Sespie #undef MCOUNT_FUNCTION
176*c87b03e5Sespie #define MCOUNT_FUNCTION "*_mcount"
177