]>
Commit | Line | Data |
---|---|---|
c062fde6 RS |
1 | /* Target definitions for GNU compiler for Intel 80386 running System V.4 |
2 | Copyright (C) 1991 Free Software Foundation, Inc. | |
3 | ||
4 | Written by Ron Guilmette (rfg@ncd.com). | |
5 | ||
6 | This file is part of GNU CC. | |
7 | ||
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) | |
11 | any later version. | |
12 | ||
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. | |
17 | ||
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. */ | |
21 | ||
5ab576d8 JVA |
22 | #include "i386/i386.h" /* Base i386 target machine definitions */ |
23 | #include "i386/att.h" /* Use the i386 AT&T assembler syntax */ | |
c062fde6 RS |
24 | #include "svr4.h" /* Definitions common to all SVR4 targets */ |
25 | ||
26 | #undef TARGET_VERSION | |
27 | #define TARGET_VERSION fprintf (stderr, " (i386 System V Release 4)"); | |
28 | ||
c062fde6 RS |
29 | /* The svr4 ABI for the i386 says that records and unions are returned |
30 | in memory. */ | |
31 | ||
32 | #undef RETURN_IN_MEMORY | |
33 | #define RETURN_IN_MEMORY(TYPE) \ | |
e14fa9c4 DE |
34 | (TYPE_MODE (TYPE) == BLKmode \ |
35 | || TREE_CODE (TYPE) == RECORD_TYPE || TREE_CODE(TYPE) == UNION_TYPE) | |
c062fde6 RS |
36 | |
37 | /* Define which macros to predefine. __svr4__ is our extension. */ | |
38 | /* This used to define X86, but james@bigtex.cactus.org says that | |
39 | is supposed to be defined optionally by user programs--not by default. */ | |
40 | #define CPP_PREDEFINES \ | |
41 | "-Di386 -Dunix -D__svr4__ -Asystem(unix) -Acpu(i386) -Amachine(i386)" | |
42 | ||
4f529f0a RS |
43 | /* If the host and target formats match, output the floats as hex. */ |
44 | #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT | |
45 | #if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN | |
46 | /* This is how to output assembly code to define a `float' constant. | |
47 | We always have to use a .long pseudo-op to do this because the native | |
48 | SVR4 ELF assembler is buggy and it generates incorrect values when we | |
49 | try to use the .float pseudo-op instead. */ | |
50 | ||
51 | #undef ASM_OUTPUT_FLOAT | |
52 | #define ASM_OUTPUT_FLOAT(FILE,VALUE) \ | |
53 | do { long value; \ | |
54 | REAL_VALUE_TO_TARGET_SINGLE ((VALUE), value); \ | |
55 | fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value); \ | |
56 | } while (0) | |
57 | ||
58 | /* This is how to output assembly code to define a `double' constant. | |
59 | We always have to use a pair of .long pseudo-ops to do this because | |
60 | the native SVR4 ELF assembler is buggy and it generates incorrect | |
61 | values when we try to use the the .double pseudo-op instead. */ | |
62 | ||
63 | #undef ASM_OUTPUT_DOUBLE | |
64 | #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \ | |
65 | do { long value[2]; \ | |
66 | REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), value); \ | |
67 | fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[0]); \ | |
68 | fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[1]); \ | |
69 | } while (0) | |
70 | #endif /* word order matches */ | |
71 | #endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */ | |
72 | ||
c062fde6 RS |
73 | /* Output at beginning of assembler file. */ |
74 | /* The .file command should always begin the output. */ | |
75 | ||
76 | #undef ASM_FILE_START | |
77 | #define ASM_FILE_START(FILE) \ | |
78 | do { \ | |
79 | output_file_directive (FILE, main_input_filename); \ | |
80 | fprintf (FILE, "\t.version\t\"01.01\"\n"); \ | |
81 | } while (0) | |
82 | ||
83 | /* Define the register numbers to be used in Dwarf debugging information. | |
84 | The SVR4 reference port C compiler uses the following register numbers | |
85 | in its Dwarf output code: | |
86 | ||
c06de95d JVA |
87 | 0 for %eax (gnu regno = 0) |
88 | 1 for %ecx (gnu regno = 2) | |
89 | 2 for %edx (gnu regno = 1) | |
90 | 3 for %ebx (gnu regno = 3) | |
91 | 4 for %esp (gnu regno = 7) | |
92 | 5 for %ebp (gnu regno = 6) | |
93 | 6 for %esi (gnu regno = 4) | |
94 | 7 for %edi (gnu regno = 5) | |
95 | ||
96 | The following three DWARF register numbers are never generated by | |
97 | the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4 | |
98 | believes these numbers have these meanings. | |
99 | ||
100 | 8 for %eip (no gnu equivalent) | |
101 | 9 for %eflags (no gnu equivalent) | |
102 | 10 for %trapno (no gnu equivalent) | |
103 | ||
104 | It is not at all clear how we should number the FP stack registers | |
105 | for the x86 architecture. If the version of SDB on x86/svr4 were | |
106 | a bit less brain dead with respect to floating-point then we would | |
107 | have a precedent to follow with respect to DWARF register numbers | |
108 | for x86 FP registers, but the SDB on x86/svr4 is so completely | |
109 | broken with respect to FP registers that it is hardly worth thinking | |
c6e7f2fa | 110 | of it as something to strive for compatibility with. |
c06de95d JVA |
111 | |
112 | The verison of x86/svr4 SDB I have at the moment does (partially) | |
113 | seem to believe that DWARF register number 11 is associated with | |
114 | the x86 register %st(0), but that's about all. Higher DWARF | |
115 | register numbers don't seem to be associated with anything in | |
116 | particular, and even for DWARF regno 11, SDB only seems to under- | |
117 | stand that it should say that a variable lives in %st(0) (when | |
118 | asked via an `=' command) if we said it was in DWARF regno 11, | |
119 | but SDB still prints garbage when asked for the value of the | |
120 | variable in question (via a `/' command). | |
121 | ||
122 | (Also note that the labels SDB prints for various FP stack regs | |
123 | when doing an `x' command are all wrong.) | |
124 | ||
125 | Note that these problems generally don't affect the native SVR4 | |
126 | C compiler because it doesn't allow the use of -O with -g and | |
127 | because when it is *not* optimizing, it allocates a memory | |
128 | location for each floating-point variable, and the memory | |
129 | location is what gets described in the DWARF AT_location | |
130 | attribute for the variable in question. | |
131 | ||
132 | Regardless of the severe mental illness of the x86/svr4 SDB, we | |
133 | do something sensible here and we use the following DWARF | |
134 | register numbers. Note that these are all stack-top-relative | |
135 | numbers. | |
136 | ||
137 | 11 for %st(0) (gnu regno = 8) | |
138 | 12 for %st(1) (gnu regno = 9) | |
139 | 13 for %st(2) (gnu regno = 10) | |
140 | 14 for %st(3) (gnu regno = 11) | |
141 | 15 for %st(4) (gnu regno = 12) | |
142 | 16 for %st(5) (gnu regno = 13) | |
143 | 17 for %st(6) (gnu regno = 14) | |
144 | 18 for %st(7) (gnu regno = 15) | |
c062fde6 RS |
145 | */ |
146 | ||
147 | #undef DBX_REGISTER_NUMBER | |
148 | #define DBX_REGISTER_NUMBER(n) \ | |
149 | ((n) == 0 ? 0 \ | |
150 | : (n) == 1 ? 2 \ | |
151 | : (n) == 2 ? 1 \ | |
152 | : (n) == 3 ? 3 \ | |
153 | : (n) == 4 ? 6 \ | |
154 | : (n) == 5 ? 7 \ | |
155 | : (n) == 6 ? 5 \ | |
156 | : (n) == 7 ? 4 \ | |
c06de95d | 157 | : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \ |
3c5c04c8 | 158 | : (-1)) |
c062fde6 RS |
159 | |
160 | /* The routine used to output sequences of byte values. We use a special | |
161 | version of this for most svr4 targets because doing so makes the | |
162 | generated assembly code more compact (and thus faster to assemble) | |
163 | as well as more readable. Note that if we find subparts of the | |
164 | character sequence which end with NUL (and which are shorter than | |
165 | STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ | |
166 | ||
167 | #undef ASM_OUTPUT_ASCII | |
168 | #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ | |
169 | do \ | |
170 | { \ | |
171 | register unsigned char *_ascii_bytes = (unsigned char *) (STR); \ | |
172 | register unsigned char *limit = _ascii_bytes + (LENGTH); \ | |
173 | register unsigned bytes_in_chunk = 0; \ | |
174 | for (; _ascii_bytes < limit; _ascii_bytes++) \ | |
175 | { \ | |
176 | register unsigned char *p; \ | |
177 | if (bytes_in_chunk >= 64) \ | |
178 | { \ | |
179 | fputc ('\n', (FILE)); \ | |
180 | bytes_in_chunk = 0; \ | |
181 | } \ | |
182 | for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ | |
183 | continue; \ | |
184 | if (p < limit && (p - _ascii_bytes) <= STRING_LIMIT) \ | |
185 | { \ | |
186 | if (bytes_in_chunk > 0) \ | |
187 | { \ | |
188 | fputc ('\n', (FILE)); \ | |
189 | bytes_in_chunk = 0; \ | |
190 | } \ | |
191 | ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \ | |
192 | _ascii_bytes = p; \ | |
193 | } \ | |
194 | else \ | |
195 | { \ | |
196 | if (bytes_in_chunk == 0) \ | |
197 | fprintf ((FILE), "\t.byte\t"); \ | |
198 | else \ | |
199 | fputc (',', (FILE)); \ | |
200 | fprintf ((FILE), "0x%02x", *_ascii_bytes); \ | |
201 | bytes_in_chunk += 5; \ | |
202 | } \ | |
203 | } \ | |
204 | if (bytes_in_chunk > 0) \ | |
205 | fprintf ((FILE), "\n"); \ | |
206 | } \ | |
207 | while (0) | |
8b62f241 JVA |
208 | |
209 | /* This is how to output an element of a case-vector that is relative. | |
210 | This is only used for PIC code. See comments by the `casesi' insn in | |
211 | i386.md for an explanation of the expression this outputs. */ | |
212 | ||
213 | #undef ASM_OUTPUT_ADDR_DIFF_ELT | |
214 | #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ | |
215 | fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) | |
216 | ||
217 | /* Indicate that jump tables go in the text section. This is | |
218 | necessary when compiling PIC code. */ | |
219 | ||
220 | #define JUMP_TABLES_IN_TEXT_SECTION | |
221 | ||
8b62f241 JVA |
222 | /* Biggest alignment that any structure field can require on this |
223 | machine, in bits. If packing is in effect, this can be smaller than | |
224 | normal. */ | |
225 | ||
226 | #define BIGGEST_FIELD_ALIGNMENT \ | |
227 | (maximum_field_alignment ? maximum_field_alignment : 32) | |
228 | ||
229 | extern int maximum_field_alignment; | |
230 | ||
231 | /* If bit field type is int, don't let it cross an int, | |
232 | and give entire struct the alignment of an int. */ | |
233 | /* Required on the 386 since it doesn't have bitfield insns. */ | |
234 | /* If packing is in effect, then the type doesn't matter. */ | |
235 | ||
236 | #undef PCC_BITFIELD_TYPE_MATTERS | |
237 | #define PCC_BITFIELD_TYPE_MATTERS (maximum_field_alignment == 0) | |
238 | ||
4c461967 RS |
239 | /* Handle #pragma pack and sometimes #pragma weak. */ |
240 | #define HANDLE_SYSV_PRAGMA |