1 /* Target definitions for GNU compiler for Intel 80386 running System V.4
2 Copyright (C) 1991, 2001 Free Software Foundation, Inc.
4 Written by Ron Guilmette (rfg@netcom.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. */
25 #define TARGET_VERSION fprintf (stderr, " (i386 System V Release 4)");
27 /* The svr4 ABI for the i386 says that records and unions are returned
30 #undef RETURN_IN_MEMORY
31 #define RETURN_IN_MEMORY(TYPE) \
32 (TYPE_MODE (TYPE) == BLKmode \
33 || (VECTOR_MODE_P (TYPE_MODE (TYPE)) && int_size_in_bytes (TYPE) == 8))
35 /* Define which macros to predefine. __svr4__ is our extension. */
36 /* This used to define X86, but james@bigtex.cactus.org says that
37 is supposed to be defined optionally by user programs--not by default. */
38 #define CPP_PREDEFINES \
39 "-Dunix -D__svr4__ -Asystem=unix -Asystem=svr4"
41 /* This is how to output assembly code to define a `float' constant.
42 We always have to use a .long pseudo-op to do this because the native
43 SVR4 ELF assembler is buggy and it generates incorrect values when we
44 try to use the .float pseudo-op instead. */
46 #undef ASM_OUTPUT_FLOAT
47 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
49 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), value); \
50 if (sizeof (int) == sizeof (long)) \
51 fprintf((FILE), "%s0x%x\n", ASM_LONG, (int) value); \
53 fprintf((FILE), "%s0x%lx\n", ASM_LONG, value); \
56 /* This is how to output assembly code to define a `double' constant.
57 We always have to use a pair of .long pseudo-ops to do this because
58 the native SVR4 ELF assembler is buggy and it generates incorrect
59 values when we try to use the .double pseudo-op instead. */
61 #undef ASM_OUTPUT_DOUBLE
62 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
64 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), value); \
65 if (sizeof (int) == sizeof (long)) \
67 fprintf((FILE), "%s0x%x\n", ASM_LONG, (int) value[0]); \
68 fprintf((FILE), "%s0x%x\n", ASM_LONG, (int) value[1]); \
72 fprintf((FILE), "%s0x%lx\n", ASM_LONG, value[0]); \
73 fprintf((FILE), "%s0x%lx\n", ASM_LONG, value[1]); \
78 #undef ASM_OUTPUT_LONG_DOUBLE
79 #define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
81 REAL_VALUE_TO_TARGET_LONG_DOUBLE ((VALUE), value); \
82 if (sizeof (int) == sizeof (long)) \
84 fprintf((FILE), "%s0x%x\n", ASM_LONG, (int) value[0]); \
85 fprintf((FILE), "%s0x%x\n", ASM_LONG, (int) value[1]); \
86 fprintf((FILE), "%s0x%x\n", ASM_LONG, (int) value[2]); \
90 fprintf((FILE), "%s0x%lx\n", ASM_LONG, value[0]); \
91 fprintf((FILE), "%s0x%lx\n", ASM_LONG, value[1]); \
92 fprintf((FILE), "%s0x%lx\n", ASM_LONG, value[2]); \
96 /* Output at beginning of assembler file. */
97 /* The .file command should always begin the output. */
100 #define ASM_FILE_START(FILE) \
102 output_file_directive (FILE, main_input_filename); \
103 fprintf (FILE, "\t.version\t\"01.01\"\n"); \
106 #undef DBX_REGISTER_NUMBER
107 #define DBX_REGISTER_NUMBER(n) svr4_dbx_register_map[n]
109 /* The routine used to output sequences of byte values. We use a special
110 version of this for most svr4 targets because doing so makes the
111 generated assembly code more compact (and thus faster to assemble)
112 as well as more readable. Note that if we find subparts of the
113 character sequence which end with NUL (and which are shorter than
114 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
116 #undef ASM_OUTPUT_ASCII
117 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
120 register const unsigned char *_ascii_bytes = \
121 (const unsigned char *) (STR); \
122 register const unsigned char *limit = _ascii_bytes + (LENGTH); \
123 register unsigned bytes_in_chunk = 0; \
124 for (; _ascii_bytes < limit; _ascii_bytes++) \
126 register const unsigned char *p; \
127 if (bytes_in_chunk >= 64) \
129 fputc ('\n', (FILE)); \
130 bytes_in_chunk = 0; \
132 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
134 if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT) \
136 if (bytes_in_chunk > 0) \
138 fputc ('\n', (FILE)); \
139 bytes_in_chunk = 0; \
141 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
146 if (bytes_in_chunk == 0) \
147 fprintf ((FILE), "\t.byte\t"); \
149 fputc (',', (FILE)); \
150 fprintf ((FILE), "0x%02x", *_ascii_bytes); \
151 bytes_in_chunk += 5; \
154 if (bytes_in_chunk > 0) \
155 fprintf ((FILE), "\n"); \
159 /* A C statement (sans semicolon) to output to the stdio stream
160 FILE the assembler definition of uninitialized global DECL named
161 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
162 Try to use asm_output_aligned_bss to implement this macro. */
164 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
165 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
167 /* Handle special EH pointer encodings. Absolute, pc-relative, and
168 indirect are handled automatically. */
169 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
171 if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel) \
173 fputs (ASM_LONG, FILE); \
174 assemble_name (FILE, XSTR (ADDR, 0)); \
175 fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
180 /* Used by crtstuff.c to initialize the base of data-relative relocations.
181 These are GOT relative on x86, so return the pic register. */
183 #define CRT_GET_RFIB_DATA(BASE) \
185 register void *ebx_ __asm__("ebx"); \
189 #define CRT_GET_RFIB_DATA(BASE) \
190 __asm__ ("call\t.LPR%=\n" \
193 /* Due to a GAS bug, this cannot use EAX. That encodes \
194 smaller than the traditional EBX, which results in the \
195 offset being off by one. */ \
196 "addl\t$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0" \