1 /* Target definitions for GNU compiler for Sparc running System V.4
2 Copyright (C) 1991, 1992 Free Software Foundation, Inc.
4 Written by Ron Guilmette (rfg@ncd.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, 675 Mass Ave, Cambridge, MA 02139, USA. */
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 DBX_DEBUGGING_INFO
29 #undef WORD_SWITCH_TAKES_ARG
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 CTORS_SECTION_ASM_OP
42 #undef DTORS_SECTION_ASM_OP
43 #undef INIT_SECTION_ASM_OP
44 #undef CONST_SECTION_ASM_OP
45 #undef TYPE_OPERAND_FMT
46 #undef PUSHSECTION_FORMAT
50 #undef SET_ASM_OP /* Has no equivalent. See ASM_OUTPUT_DEF below. */
52 /* Provide a set of pre-definitions and pre-assertions appropriate for
53 the Sparc running svr4. __svr4__ is our extension. */
55 #define CPP_PREDEFINES \
56 "-Dsparc -Dunix -D__svr4__ -Asystem(unix) -Acpu(sparc) -Amachine(sparc)"
58 /* The specialized code which needs to appear in the .init section prior
59 to the prologue code for `__do_global_ctors' (see crtstuff.c).
61 On Sparcs running svr4, the /usr/ccs/lib/crti.o file (with gets linked
62 in prior to the crtbegin.o file) has a single `save' instruction in its
63 .init section. That `save' instruction tries to setup a stack frame for
64 the sake of any subsequent code in the .init section. Unfortunately,
65 the size it uses for the stack frame is only a guess, and is not really
66 adequate for our purposes. More importantly, we independently put our
67 own standard function prologue (for __do_global_ctors) into the .init
68 section and that function prologue includes its own `save' instruction!
69 Thus, unless we do something to correct the situation, we'll get *two*
70 stack frames allocated when crt0.o calls the code in the .init section,
71 and havoc will ensue. The following macro definition prevents such woes.
74 #define INIT_SECTION_PREAMBLE asm ("restore")
76 /* This is the string used to begin an assembly language comment for the
77 Sparc/svr4 assembler. */
79 #define ASM_COMMENT_START "!"
81 /* Define the names of various pseudo-op used by the Sparc/svr4 assembler.
82 Note that many of these are different from the typical pseudo-ops used
83 by most svr4 assemblers. That is probably due to a (misguided?) attempt
84 to keep the Sparc/svr4 assembler somewhat compatible with the Sparc/SunOS
87 #define STRING_ASM_OP ".asciz"
88 #define COMMON_ASM_OP ".common"
89 #define SKIP_ASM_OP ".skip"
90 #define UNALIGNED_INT_ASM_OP ".uaword"
91 #define UNALIGNED_SHORT_ASM_OP ".uahalf"
92 #define PUSHSECTION_ASM_OP ".pushsection"
93 #define POPSECTION_ASM_OP ".popsection"
95 /* This is the format used to print the second operand of a .type pseudo-op
96 for the Sparc/svr4 assembler. */
98 #define TYPE_OPERAND_FMT "#%s"
100 /* This is the format used to print a .pushsection pseudo-op (and its operand)
101 for the Sparc/svr4 assembler. */
103 #define PUSHSECTION_FORMAT "\t%s\t\"%s\"\n"
105 #undef ASM_OUTPUT_CASE_LABEL
106 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
107 do { ASM_OUTPUT_ALIGN ((FILE), 2); \
108 ASM_OUTPUT_INTERNAL_LABEL ((FILE), PREFIX, NUM); \
111 /* This is how to equate one symbol to another symbol. The syntax used is
112 `SYM1=SYM2'. Note that this is different from the way equates are done
113 with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'. */
115 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
116 do { fprintf ((FILE), "\t"); \
117 assemble_name (FILE, LABEL1); \
118 fprintf (FILE, " = "); \
119 assemble_name (FILE, LABEL2); \
120 fprintf (FILE, "\n"); \
123 /* Define how the Sparc registers should be numbered for Dwarf output.
124 The numbering provided here should be compatible with the native
125 svr4 SDB debugger in the Sparc/svr4 reference port. The numbering
128 Assembly name gcc internal regno Dwarf regno
129 ----------------------------------------------------------
137 #define DBX_REGISTER_NUMBER(REGNO) \
138 (((REGNO) < 32) ? (REGNO) \
139 : ((REGNO) < 63) ? ((REGNO) + 8) \
142 /* A set of symbol definitions for assembly pseudo-ops which will
143 get us switched to various sections of interest. These are used
144 in all places where we simply want to switch to a section, and
145 *not* to push the previous section name onto the assembler's
146 section names stack (as we do often in dwarfout.c). */
148 #define TEXT_SECTION_ASM_OP ".section\t\".text\""
149 #define DATA_SECTION_ASM_OP ".section\t\".data\""
150 #define BSS_SECTION_ASM_OP ".section\t\".bss\""
151 #define CONST_SECTION_ASM_OP ".section\t\".rodata\""
152 #define INIT_SECTION_ASM_OP ".section\t\".init\",#alloc"
153 #define CTORS_SECTION_ASM_OP ".section\t\".ctors\",#alloc"
154 #define DTORS_SECTION_ASM_OP ".section\t\".dtors\",#alloc"
156 /* Code to handle #pragma directives. The interface is a bit messy,
157 but there's no simpler way to do this while still using yylex. */
158 #define HANDLE_PRAGMA(FILE) \
160 while (c == ' ' || c == '\t') \
162 if (c == '\n' || c == EOF) \
164 handle_pragma_token (0, 0); \
174 handle_pragma_token (token_buffer, yylval.ttype); \
177 handle_pragma_token (token_buffer, 0); \
180 c = nextchar, nextchar = -1; \
185 /* If the host and target formats match, output the floats as hex. */
186 #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
187 #if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN
189 /* This is how to output assembly code to define a `float' constant.
190 We always have to use a .long pseudo-op to do this because the native
191 SVR4 ELF assembler is buggy and it generates incorrect values when we
192 try to use the .float pseudo-op instead. */
194 #undef ASM_OUTPUT_FLOAT
195 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
197 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), value); \
198 fprintf((FILE), "\t.long\t0x%x\n", value); \
201 /* This is how to output assembly code to define a `double' constant.
202 We always have to use a pair of .long pseudo-ops to do this because
203 the native SVR4 ELF assembler is buggy and it generates incorrect
204 values when we try to use the the .double pseudo-op instead. */
206 #undef ASM_OUTPUT_DOUBLE
207 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
208 do { long value[2]; \
209 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), value); \
210 fprintf((FILE), "\t.long\t0x%x\n", value[0]); \
211 fprintf((FILE), "\t.long\t0x%x\n", value[1]); \
214 #endif /* word order matches */
215 #endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */