1 /* Target definitions for GNU compiler for Intel 80386 running Interix
2 Parts Copyright (C) 1991, 1999, 2000, 2002 Free Software Foundation, Inc.
5 by Douglas B. Rupp (drupp@cs.washington.edu).
6 by Ron Guilmette (rfg@netcom.com).
7 by Donn Terry (donn@softway.com).
8 by Mumit Khan (khan@xraylith.wisc.edu).
10 This file is part of GNU CC.
12 GNU CC is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
17 GNU CC is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with GNU CC; see the file COPYING. If not, write to
24 the Free Software Foundation, 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. */
27 /* The rest must follow. */
29 #define DBX_DEBUGGING_INFO
30 #define SDB_DEBUGGING_INFO
31 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
33 #define HANDLE_SYSV_PRAGMA
34 #undef HANDLE_PRAGMA_WEAK /* until the link format can handle it */
36 /* By default, target has a 80387, uses IEEE compatible arithmetic,
37 and returns float values in the 387 and needs stack probes
38 We also align doubles to 64-bits for MSVC default compatibility */
39 #undef TARGET_SUBTARGET_DEFAULT
40 #define TARGET_SUBTARGET_DEFAULT \
41 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \
44 #undef TARGET_CPU_DEFAULT
45 #define TARGET_CPU_DEFAULT 2 /* 486 */
47 #define WCHAR_TYPE_SIZE 16
48 #define WCHAR_TYPE "short unsigned int"
50 /* WinNT (and thus Interix) use unsigned int */
51 #define SIZE_TYPE "unsigned int"
53 #define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n"
55 /* cpp handles __STDC__ */
57 #define CPP_PREDEFINES " \
60 -D_M_IX86=300 -D_X86_=1 \
61 -D__stdcall=__attribute__((__stdcall__)) \
62 -D__cdecl=__attribute__((__cdecl__)) \
63 -D__declspec(x)=__attribute__((x)) \
64 -Asystem=unix -Asystem=interix"
67 /* Write out the correct language type definition for the header files.
68 Unless we have assembler language, write out the symbols for C.
69 cpp_cpu is an Intel specific variant. See i386.h
70 mieee is an Alpha specific variant. Cross polination a bad idea.
73 %{!.S: -D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}} \
74 %{.S: -D__LANGUAGE_ASSEMBLY__ -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \
75 %{.cc: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
76 %{.cxx: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
77 %{.C: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
78 %{.m: -D__LANGUAGE_OBJECTIVE_C__ -D__LANGUAGE_OBJECTIVE_C} \
81 %{posix:-D_POSIX_SOURCE} \
82 -isystem %$INTERIX_ROOT/usr/include"
84 #define TARGET_VERSION fprintf (stderr, " (i386 Interix)");
86 /* The global __fltused is necessary to cause the printf/scanf routines
87 for outputting/inputting floating point numbers to be loaded. Since this
88 is kind of hard to detect, we just do it all the time. */
93 #define ASM_FILE_START(FILE) \
94 do { fprintf (FILE, "\t.file\t"); \
95 output_quoted_string (FILE, dump_base_name); \
96 fprintf (FILE, "\n"); \
97 fprintf (FILE, ".global\t__fltused\n"); \
100 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
101 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
102 corresponds to a particular byte value [0..255]. For any
103 given byte value, if the value in the corresponding table
104 position is zero, the given character can be output directly.
105 If the table value is 1, the byte must be output as a \ooo
106 octal escape. If the tables value is anything else, then the
107 byte value should be output as a \ followed by the value
108 in the table. Note that we can use standard UN*X escape
109 sequences for many control characters, but we don't use
110 \a to represent BEL because some svr4 assemblers (e.g. on
111 the i386) don't know about that. Also, we don't use \v
112 since some versions of gas, such as 2.2 did not accept it. */
115 "\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\
116 \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\
117 \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\
118 \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\
119 \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\
120 \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\
121 \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\
122 \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"
124 /* Some svr4 assemblers have a limit on the number of characters which
125 can appear in the operand of a .string directive. If your assembler
126 has such a limitation, you should define STRING_LIMIT to reflect that
127 limit. Note that at least some svr4 assemblers have a limit on the
128 actual number of bytes in the double-quoted string, and that they
129 count each character in an escape sequence as one byte. Thus, an
130 escape sequence like \377 would count as four bytes.
132 If your target assembler doesn't support the .string directive, you
133 should define this to zero.
136 #define STRING_LIMIT ((unsigned) 256)
138 #define STRING_ASM_OP "\t.string\t"
140 /* The routine used to output NUL terminated strings. We use a special
141 version of this for most svr4 targets because doing so makes the
142 generated assembly code more compact (and thus faster to assemble)
143 as well as more readable, especially for targets like the i386
144 (where the only alternative is to output character sequences as
145 comma separated lists of numbers). */
147 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
150 register const unsigned char *_limited_str = \
151 (const unsigned char *) (STR); \
152 register unsigned ch; \
153 fprintf ((FILE), "%s\"", STRING_ASM_OP); \
154 for (; (ch = *_limited_str); _limited_str++) \
156 register int escape = ESCAPES[ch]; \
163 fprintf ((FILE), "\\%03o", ch); \
166 putc ('\\', (FILE)); \
167 putc (escape, (FILE)); \
171 fprintf ((FILE), "\"\n"); \
175 /* The routine used to output sequences of byte values. We use a special
176 version of this for most svr4 targets because doing so makes the
177 generated assembly code more compact (and thus faster to assemble)
178 as well as more readable. Note that if we find subparts of the
179 character sequence which end with NUL (and which are shorter than
180 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
182 #undef ASM_OUTPUT_ASCII
183 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
186 register const unsigned char *_ascii_bytes = \
187 (const unsigned char *) (STR); \
188 register const unsigned char *limit = _ascii_bytes + (LENGTH); \
189 register unsigned bytes_in_chunk = 0; \
190 for (; _ascii_bytes < limit; _ascii_bytes++) \
192 register const unsigned char *p; \
193 if (bytes_in_chunk >= 64) \
195 fputc ('\n', (FILE)); \
196 bytes_in_chunk = 0; \
198 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
200 if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT) \
202 if (bytes_in_chunk > 0) \
204 fputc ('\n', (FILE)); \
205 bytes_in_chunk = 0; \
207 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
212 if (bytes_in_chunk == 0) \
213 fprintf ((FILE), "\t.byte\t"); \
215 fputc (',', (FILE)); \
216 fprintf ((FILE), "0x%02x", *_ascii_bytes); \
217 bytes_in_chunk += 5; \
220 if (bytes_in_chunk > 0) \
221 fprintf ((FILE), "\n"); \
225 /* Emit code to check the stack when allocating more that 4000
228 #define CHECK_STACK_LIMIT 0x1000
230 /* the following are OSF linker (not gld) specific... we don't want them */
231 #undef HAS_INIT_SECTION
232 #undef LD_INIT_SWITCH
233 #undef LD_FINI_SWITCH
235 #define EH_FRAME_IN_DATA_SECTION
237 /* Note that there appears to be two different ways to support const
238 sections at the moment. You can either #define the symbol
239 READONLY_DATA_SECTION (giving it some code which switches to the
240 readonly data section) or else you can #define the symbols
241 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
242 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
244 #define USE_CONST_SECTION 1
246 #define CONST_SECTION_ASM_OP "\t.section\t.rdata,\"r\""
248 /* A default list of other sections which we might be "in" at any given
249 time. For targets that use additional sections (e.g. .tdesc) you
250 should override this definition in the target-specific file which
251 includes this file. */
253 #undef EXTRA_SECTIONS
254 #define EXTRA_SECTIONS in_const
256 /* A default list of extra section function definitions. For targets
257 that use additional sections (e.g. .tdesc) you should override this
258 definition in the target-specific file which includes this file. */
260 #undef EXTRA_SECTION_FUNCTIONS
261 #define EXTRA_SECTION_FUNCTIONS \
262 CONST_SECTION_FUNCTION
264 #undef READONLY_DATA_SECTION
265 #define READONLY_DATA_SECTION() const_section ()
267 #define CONST_SECTION_FUNCTION \
271 if (!USE_CONST_SECTION) \
273 else if (in_section != in_const) \
275 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
276 in_section = in_const; \
280 /* The MS compilers take alignment as a number of bytes, so we do as well */
281 #undef ASM_OUTPUT_ALIGN
282 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
283 if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG))
285 /* The linker will take care of this, and having them causes problems with
286 ld -r (specifically -rU). */
287 #define CTOR_LISTS_DEFINED_EXTERNALLY 1
289 #define SET_ASM_OP "\t.set\t"
290 /* Output a definition (implements alias) */
291 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
294 fprintf ((FILE), "%s", SET_ASM_OP); \
295 assemble_name (FILE, LABEL1); \
296 fprintf (FILE, ","); \
297 assemble_name (FILE, LABEL2); \
298 fprintf (FILE, "\n"); \
302 #define HOST_PTR_PRINTF "%p"
303 #define HOST_PTR_AS_INT unsigned long
305 #define PCC_BITFIELD_TYPE_MATTERS 1
306 #define PCC_BITFIELD_TYPE_TEST TYPE_NATIVE(rec)
307 #define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
309 /* The following two flags are usually "off" for i386, because some non-gnu
310 tools (for the i386) don't handle them. However, we don't have that
313 /* Forward references to tags are allowed. */
314 #define SDB_ALLOW_FORWARD_REFERENCES
316 /* Unknown tags are also allowed. */
317 #define SDB_ALLOW_UNKNOWN_REFERENCES
319 /* The integer half of this list needs to be constant. However, there's
320 a lot of disagreement about what the floating point adjustments should
321 be. We pick one that works with gdb. (The underlying problem is
322 what to do about the segment registers. Since we have access to them
323 from /proc, we'll allow them to be accessed in gdb, even tho the
324 gcc compiler can't generate them. (There's some evidence that
325 MSVC does, but possibly only for certain special "canned" sequences.) */
327 #undef DBX_REGISTER_NUMBER
328 #define DBX_REGISTER_NUMBER(n) \
329 (TARGET_64BIT ? dbx64_register_map[n] \
338 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+8 \
341 /* Define this macro if references to a symbol must be treated
342 differently depending on something about the variable or
343 function named by the symbol (such as what section it is in).
345 Apply stddef, handle (as yet unimplemented) pic.
347 stddef renaming does NOT apply to Alpha. */
350 const char *gen_stdcall_suffix PARAMS ((union tree_node *));
352 #undef ENCODE_SECTION_INFO
353 #define ENCODE_SECTION_INFO(DECL, FIRST) \
358 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
359 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \
360 SYMBOL_REF_FLAG (XEXP (rtl, 0)) \
361 = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
362 || ! TREE_PUBLIC (DECL)); \
364 if ((FIRST) && TREE_CODE (DECL) == FUNCTION_DECL) \
365 if (lookup_attribute ("stdcall", \
366 TYPE_ATTRIBUTES (TREE_TYPE (DECL)))) \
367 XEXP (DECL_RTL (DECL), 0) = \
368 gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL)); \
372 /* This macro gets just the user-specified name
373 out of the string in a SYMBOL_REF. Discard
374 trailing @[NUM] encoded by ENCODE_SECTION_INFO. */
375 #undef STRIP_NAME_ENCODING
376 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
379 const char *_name = SYMBOL_NAME; \
380 for (_p = _name; *_p && *_p != '@'; ++_p) \
384 int _len = _p - _name; \
385 char *_new_name = (char *) alloca (_len + 1); \
386 strncpy (_new_name, _name, _len); \
387 _new_name[_len] = '\0'; \
395 /* Turn this back on when the linker is updated to handle grouped
396 .data$ sections correctly. See corresponding note in i386/interix.c.
399 /* Define this macro if in some cases global symbols from one translation
400 unit may not be bound to undefined symbols in another translation unit
401 without user intervention. For instance, under Microsoft Windows
402 symbols must be explicitly imported from shared libraries (DLLs). */
403 #define MULTIPLE_SYMBOL_SPACES
405 extern void i386_pe_unique_section ();
406 #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
408 #define SUPPORTS_ONE_ONLY 1
411 /* Switch into a generic section. */
412 #define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section
414 /* DWARF2 Unwinding doesn't work with exception handling yet. */
415 #define DWARF2_UNWIND_INFO 0
417 /* Don't assume anything about the header files. */
418 #define NO_IMPLICIT_EXTERN_C
420 /* MSVC returns structs of up to 8 bytes via registers. */
422 #define DEFAULT_PCC_STRUCT_RETURN 0
424 #undef RETURN_IN_MEMORY
425 #define RETURN_IN_MEMORY(TYPE) \
426 (TYPE_MODE (TYPE) == BLKmode || \
427 (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes(TYPE) > 8 ))