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