]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/i386/i386-interix.h
tm.texi.in (HANDLE_SYSV_PRAGMA, [...]): Remove.
[thirdparty/gcc.git] / gcc / config / i386 / i386-interix.h
1 /* Target definitions for GCC for Intel 80386 running Interix
2 Parts Copyright (C) 1991, 1999, 2000, 2002, 2003, 2004, 2007, 2008, 2009,
3 2010 Free Software Foundation, Inc.
4
5 Parts:
6 by Douglas B. Rupp (drupp@cs.washington.edu).
7 by Ron Guilmette (rfg@netcom.com).
8 by Donn Terry (donn@softway.com).
9 by Mumit Khan (khan@xraylith.wisc.edu).
10
11 This file is part of GCC.
12
13 GCC is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 3, or (at your option)
16 any later version.
17
18 GCC is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with GCC; see the file COPYING3. If not see
25 <http://www.gnu.org/licenses/>. */
26
27 /* The rest must follow. */
28
29 #define DBX_DEBUGGING_INFO 1
30 #define SDB_DEBUGGING_INFO 1
31 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
32
33 /* By default, target has a 80387, uses IEEE compatible arithmetic,
34 and returns float values in the 387 and needs stack probes
35 We also align doubles to 64-bits for MSVC default compatibility
36 We do bitfields MSVC-compatibly by default, too. */
37 #undef TARGET_SUBTARGET_DEFAULT
38 #define TARGET_SUBTARGET_DEFAULT \
39 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \
40 MASK_ALIGN_DOUBLE | MASK_MS_BITFIELD_LAYOUT)
41
42 #undef TARGET_CPU_DEFAULT
43 #define TARGET_CPU_DEFAULT TARGET_CPU_DEFAULT_i486
44
45 #define WCHAR_TYPE_SIZE 16
46 #define WCHAR_TYPE "short unsigned int"
47
48 /* WinNT (and thus Interix) use unsigned int */
49 #define SIZE_TYPE "unsigned int"
50
51 #define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n"
52
53 #define TARGET_DECLSPEC 1
54
55 /* cpp handles __STDC__ */
56 #define TARGET_OS_CPP_BUILTINS() \
57 do \
58 { \
59 builtin_define ("__INTERIX"); \
60 builtin_define ("__OPENNT"); \
61 builtin_define ("_M_IX86=300"); \
62 builtin_define ("_X86_=1"); \
63 builtin_define ("__stdcall=__attribute__((__stdcall__))"); \
64 builtin_define ("__cdecl=__attribute__((__cdecl__))"); \
65 builtin_assert ("system=unix"); \
66 builtin_assert ("system=interix"); \
67 if (preprocessing_asm_p ()) \
68 builtin_define_std ("LANGUAGE_ASSEMBLY"); \
69 else \
70 { \
71 builtin_define_std ("LANGUAGE_C"); \
72 if (c_dialect_cxx ()) \
73 builtin_define_std ("LANGUAGE_C_PLUS_PLUS"); \
74 if (c_dialect_objc ()) \
75 builtin_define_std ("LANGUAGE_OBJECTIVE_C"); \
76 } \
77 } \
78 while (0)
79
80 #undef CPP_SPEC
81 /* Write out the correct language type definition for the header files.
82 Unless we have assembler language, write out the symbols for C.
83 mieee is an Alpha specific variant. Cross pollination a bad idea.
84 */
85 #define CPP_SPEC "-remap %{posix:-D_POSIX_SOURCE} \
86 -isystem %$INTERIX_ROOT/usr/include"
87
88 #define TARGET_VERSION fprintf (stderr, " (i386 Interix)");
89
90 /* The global __fltused is necessary to cause the printf/scanf routines
91 for outputting/inputting floating point numbers to be loaded. Since this
92 is kind of hard to detect, we just do it all the time. */
93 #undef X86_FILE_START_FLTUSED
94 #define X86_FILE_START_FLTUSED 1
95
96 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
97 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
98 corresponds to a particular byte value [0..255]. For any
99 given byte value, if the value in the corresponding table
100 position is zero, the given character can be output directly.
101 If the table value is 1, the byte must be output as a \ooo
102 octal escape. If the tables value is anything else, then the
103 byte value should be output as a \ followed by the value
104 in the table. Note that we can use standard UN*X escape
105 sequences for many control characters, but we don't use
106 \a to represent BEL because some svr4 assemblers (e.g. on
107 the i386) don't know about that. Also, we don't use \v
108 since some versions of gas, such as 2.2 did not accept it. */
109
110 #define ESCAPES \
111 "\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
112 \0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
113 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\
114 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\
115 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
116 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
117 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
118 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"
119
120 /* Some svr4 assemblers have a limit on the number of characters which
121 can appear in the operand of a .string directive. If your assembler
122 has such a limitation, you should define STRING_LIMIT to reflect that
123 limit. Note that at least some svr4 assemblers have a limit on the
124 actual number of bytes in the double-quoted string, and that they
125 count each character in an escape sequence as one byte. Thus, an
126 escape sequence like \377 would count as four bytes.
127
128 If your target assembler doesn't support the .string directive, you
129 should define this to zero.
130 */
131
132 #define STRING_LIMIT ((unsigned) 256)
133
134 #define STRING_ASM_OP "\t.string\t"
135
136 /* The routine used to output NUL terminated strings. We use a special
137 version of this for most svr4 targets because doing so makes the
138 generated assembly code more compact (and thus faster to assemble)
139 as well as more readable, especially for targets like the i386
140 (where the only alternative is to output character sequences as
141 comma separated lists of numbers). */
142
143 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
144 do \
145 { \
146 const unsigned char *_limited_str = \
147 (const unsigned char *) (STR); \
148 unsigned ch; \
149 fprintf ((FILE), "%s\"", STRING_ASM_OP); \
150 for (; (ch = *_limited_str); _limited_str++) \
151 { \
152 int escape = ESCAPES[ch]; \
153 switch (escape) \
154 { \
155 case 0: \
156 putc (ch, (FILE)); \
157 break; \
158 case 1: \
159 fprintf ((FILE), "\\%03o", ch); \
160 break; \
161 default: \
162 putc ('\\', (FILE)); \
163 putc (escape, (FILE)); \
164 break; \
165 } \
166 } \
167 fprintf ((FILE), "\"\n"); \
168 } \
169 while (0)
170
171 /* The routine used to output sequences of byte values. We use a special
172 version of this for most svr4 targets because doing so makes the
173 generated assembly code more compact (and thus faster to assemble)
174 as well as more readable. Note that if we find subparts of the
175 character sequence which end with NUL (and which are shorter than
176 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
177
178 #undef ASM_OUTPUT_ASCII
179 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
180 do \
181 { \
182 const unsigned char *_ascii_bytes = \
183 (const unsigned char *) (STR); \
184 const unsigned char *limit = _ascii_bytes + (LENGTH); \
185 unsigned bytes_in_chunk = 0; \
186 for (; _ascii_bytes < limit; _ascii_bytes++) \
187 { \
188 const unsigned char *p; \
189 if (bytes_in_chunk >= 64) \
190 { \
191 fputc ('\n', (FILE)); \
192 bytes_in_chunk = 0; \
193 } \
194 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
195 continue; \
196 if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT) \
197 { \
198 if (bytes_in_chunk > 0) \
199 { \
200 fputc ('\n', (FILE)); \
201 bytes_in_chunk = 0; \
202 } \
203 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
204 _ascii_bytes = p; \
205 } \
206 else \
207 { \
208 if (bytes_in_chunk == 0) \
209 fputs (ASM_BYTE, (FILE)); \
210 else \
211 fputc (',', (FILE)); \
212 fprintf ((FILE), "0x%02x", *_ascii_bytes); \
213 bytes_in_chunk += 5; \
214 } \
215 } \
216 if (bytes_in_chunk > 0) \
217 fputc ('\n', (FILE)); \
218 } \
219 while (0)
220
221 /* Emit code to check the stack when allocating more that 4000
222 bytes in one go. */
223
224 #define CHECK_STACK_LIMIT 0x1000
225
226 /* the following are OSF linker (not gld) specific... we don't want them */
227 #undef HAS_INIT_SECTION
228 #undef LD_INIT_SWITCH
229 #undef LD_FINI_SWITCH
230
231 /* The following are needed for us to be able to use winnt.c, but are not
232 otherwise meaningful to Interix. (The functions that use these are
233 never called because we don't do DLLs.) */
234 #define TARGET_NOP_FUN_DLLIMPORT 1
235 #define drectve_section() /* nothing */
236
237 /* Objective-C has its own packing rules...
238 Objc tries to parallel the code in stor-layout.c at runtime
239 (see libobjc/encoding.c). This (compile-time) packing info isn't
240 available at runtime, so it's hopeless to try.
241
242 And if the user tries to set the flag for objc, give an error
243 so he has some clue. */
244
245 #undef SUBTARGET_OVERRIDE_OPTIONS
246 #define SUBTARGET_OVERRIDE_OPTIONS \
247 do { \
248 if (strcmp (lang_hooks.name, "GNU Objective-C") == 0) \
249 { \
250 if ((target_flags & MASK_MS_BITFIELD_LAYOUT) != 0 \
251 && (target_flags_explicit & MASK_MS_BITFIELD_LAYOUT) != 0) \
252 { \
253 error ("ms-bitfields not supported for objc"); \
254 } \
255 target_flags &= ~MASK_MS_BITFIELD_LAYOUT; \
256 } \
257 } while (0)
258
259 #define EH_FRAME_IN_DATA_SECTION
260
261 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rdata,\"r\""
262
263 /* The MS compilers take alignment as a number of bytes, so we do as well */
264 #undef ASM_OUTPUT_ALIGN
265 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
266 if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG))
267
268 /* The linker will take care of this, and having them causes problems with
269 ld -r (specifically -rU). */
270 #define CTOR_LISTS_DEFINED_EXTERNALLY 1
271
272 #define SET_ASM_OP "\t.set\t"
273 /* Output a definition (implements alias) */
274 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
275 do \
276 { \
277 fputs (SET_ASM_OP, (FILE)); \
278 assemble_name (FILE, LABEL1); \
279 fputc (',', (FILE)); \
280 assemble_name (FILE, LABEL2); \
281 fputc ('\n', (FILE)); \
282 } \
283 while (0)
284
285 #define HOST_PTR_AS_INT unsigned long
286
287 /* The following two flags are usually "off" for i386, because some non-gnu
288 tools (for the i386) don't handle them. However, we don't have that
289 problem, so.... */
290
291 /* Forward references to tags are allowed. */
292 #define SDB_ALLOW_FORWARD_REFERENCES
293
294 /* Unknown tags are also allowed. */
295 #define SDB_ALLOW_UNKNOWN_REFERENCES
296
297 /* The integer half of this list needs to be constant. However, there's
298 a lot of disagreement about what the floating point adjustments should
299 be. We pick one that works with gdb. (The underlying problem is
300 what to do about the segment registers. Since we have access to them
301 from /proc, we'll allow them to be accessed in gdb, even tho the
302 gcc compiler can't generate them. (There's some evidence that
303 MSVC does, but possibly only for certain special "canned" sequences.) */
304
305 #undef DBX_REGISTER_NUMBER
306 #define DBX_REGISTER_NUMBER(n) \
307 (TARGET_64BIT ? dbx64_register_map[n] \
308 : (n) == 0 ? 0 \
309 : (n) == 1 ? 2 \
310 : (n) == 2 ? 1 \
311 : (n) == 3 ? 3 \
312 : (n) == 4 ? 6 \
313 : (n) == 5 ? 7 \
314 : (n) == 6 ? 5 \
315 : (n) == 7 ? 4 \
316 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+8 \
317 : (-1))
318
319 /* Define this macro if references to a symbol must be treated
320 differently depending on something about the variable or
321 function named by the symbol (such as what section it is in). */
322
323 #define SUBTARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info
324 #undef TARGET_STRIP_NAME_ENCODING
325 #define TARGET_STRIP_NAME_ENCODING i386_pe_strip_name_encoding_full
326
327 #if 0
328 /* Turn this back on when the linker is updated to handle grouped
329 .data$ sections correctly. See corresponding note in i386/interix.c.
330 MK. */
331
332 /* Interix uses explicit import from shared libraries. */
333 #define MULTIPLE_SYMBOL_SPACES 1
334
335 extern void i386_pe_unique_section (tree, int);
336 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
337 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
338
339 #define SUPPORTS_ONE_ONLY 1
340 #endif /* 0 */
341
342 /* Switch into a generic section. */
343 #define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section
344
345 /* DWARF2 Unwinding doesn't work with exception handling yet. */
346 #define DWARF2_UNWIND_INFO 0
347
348 /* Don't assume anything about the header files. */
349 #define NO_IMPLICIT_EXTERN_C
350
351 /* MSVC returns structs of up to 8 bytes via registers. */
352
353 #define DEFAULT_PCC_STRUCT_RETURN 0
354
355 #define SUBTARGET_RETURN_IN_MEMORY(TYPE, FNTYPE) \
356 (TYPE_MODE (TYPE) == BLKmode \
357 || (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes (TYPE) > 8 ))