* rtl.h (rtunion_def): Constify member `rtstr'.
[official-gcc.git] / gcc / config / i386 / i386-interix.h
blob8bc43f365ad23c115b9f8c2993ba33c99ee80b47
1 /* Target definitions for GNU compiler for Intel 80386 running Interix
2 Parts Copyright (C) 1991, 1999 Free Software Foundation, Inc.
4 Parts:
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)
15 any later version.
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 #define YES_UNDERSCORES
29 /* YES_UNDERSCORES must preceed gas.h */
30 #include <i386/gas.h>
31 /* The rest must follow. */
33 #define DBX_DEBUGGING_INFO
34 #define SDB_DEBUGGING_INFO
35 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
37 #define HANDLE_SYSV_PRAGMA
38 #undef HANDLE_PRAGMA_WEAK /* until the link format can handle it */
40 /* By default, target has a 80387, uses IEEE compatible arithmetic,
41 and returns float values in the 387 and needs stack probes
42 We also align doubles to 64-bits for MSVC default compatability */
43 #undef TARGET_DEFAULT
44 #define TARGET_DEFAULT \
45 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \
46 MASK_ALIGN_DOUBLE)
48 #undef TARGET_CPU_DEFAULT
49 #define TARGET_CPU_DEFAULT 2 /* 486 */
51 #define WCHAR_UNSIGNED 1
52 #define WCHAR_TYPE_SIZE 16
53 #define WCHAR_TYPE "short unsigned int"
55 /* WinNT (and thus Interix) use unsigned int */
56 #define SIZE_TYPE "unsigned int"
58 #define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n"
60 /* cpp handles __STDC__ */
61 #undef CPP_PREDEFINES
62 #define CPP_PREDEFINES " \
63 -D__INTERIX \
64 -D__OPENNT \
65 -D_M_IX86=300 -D_X86_=1 \
66 -D__stdcall=__attribute__((__stdcall__)) \
67 -D__cdecl=__attribute__((__cdecl__)) \
68 -Asystem(unix) -Asystem(interix) -Asystem(interix)"
70 #undef CPP_SPEC
71 /* Write out the correct language type definition for the header files.
72 Unless we have assembler language, write out the symbols for C.
73 cpp_cpu is an Intel specific variant. See i386.h
74 mieee is an Alpha specific variant. Cross polination a bad idea.
76 #define CPP_SPEC "\
77 %{!.S: -D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}} \
78 %{.S: -D__LANGUAGE_ASSEMBLY__ -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \
79 %{.cc: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
80 %{.cxx: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
81 %{.C: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
82 %{.m: -D__LANGUAGE_OBJECTIVE_C__ -D__LANGUAGE_OBJECTIVE_C} \
83 -remap \
84 %(cpp_cpu) \
85 %{posix:-D_POSIX_SOURCE} \
86 -idirafter %$INTERIX_ROOT/usr/include"
88 #undef TARGET_VERSION
89 #define TARGET_VERSION fprintf (stderr, " (i386 Interix)");
91 /* The global __fltused is necessary to cause the printf/scanf routines
92 for outputting/inputting floating point numbers to be loaded. Since this
93 is kind of hard to detect, we just do it all the time. */
95 #ifdef ASM_FILE_START
96 #undef ASM_FILE_START
97 #endif
98 #define ASM_FILE_START(FILE) \
99 do { fprintf (FILE, "\t.file\t"); \
100 output_quoted_string (FILE, dump_base_name); \
101 fprintf (FILE, "\n"); \
102 fprintf (FILE, ".global\t__fltused\n"); \
103 } while (0)
105 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
106 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
107 corresponds to a particular byte value [0..255]. For any
108 given byte value, if the value in the corresponding table
109 position is zero, the given character can be output directly.
110 If the table value is 1, the byte must be output as a \ooo
111 octal escape. If the tables value is anything else, then the
112 byte value should be output as a \ followed by the value
113 in the table. Note that we can use standard UN*X escape
114 sequences for many control characters, but we don't use
115 \a to represent BEL because some svr4 assemblers (e.g. on
116 the i386) don't know about that. Also, we don't use \v
117 since some versions of gas, such as 2.2 did not accept it. */
119 #define ESCAPES \
120 "\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\
121 \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\
122 \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\
123 \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\
124 \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\
125 \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\
126 \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\
127 \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"
129 /* Some svr4 assemblers have a limit on the number of characters which
130 can appear in the operand of a .string directive. If your assembler
131 has such a limitation, you should define STRING_LIMIT to reflect that
132 limit. Note that at least some svr4 assemblers have a limit on the
133 actual number of bytes in the double-quoted string, and that they
134 count each character in an escape sequence as one byte. Thus, an
135 escape sequence like \377 would count as four bytes.
137 If your target assembler doesn't support the .string directive, you
138 should define this to zero.
141 #define STRING_LIMIT ((unsigned) 256)
143 #define STRING_ASM_OP ".string"
145 /* The routine used to output NUL terminated strings. We use a special
146 version of this for most svr4 targets because doing so makes the
147 generated assembly code more compact (and thus faster to assemble)
148 as well as more readable, especially for targets like the i386
149 (where the only alternative is to output character sequences as
150 comma separated lists of numbers). */
152 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
153 do \
155 register const unsigned char *_limited_str = \
156 (const unsigned char *) (STR); \
157 register unsigned ch; \
158 fprintf ((FILE), "\t%s\t\"", STRING_ASM_OP); \
159 for (; (ch = *_limited_str); _limited_str++) \
161 register int escape = ESCAPES[ch]; \
162 switch (escape) \
164 case 0: \
165 putc (ch, (FILE)); \
166 break; \
167 case 1: \
168 fprintf ((FILE), "\\%03o", ch); \
169 break; \
170 default: \
171 putc ('\\', (FILE)); \
172 putc (escape, (FILE)); \
173 break; \
176 fprintf ((FILE), "\"\n"); \
178 while (0)
180 /* The routine used to output sequences of byte values. We use a special
181 version of this for most svr4 targets because doing so makes the
182 generated assembly code more compact (and thus faster to assemble)
183 as well as more readable. Note that if we find subparts of the
184 character sequence which end with NUL (and which are shorter than
185 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
187 #undef ASM_OUTPUT_ASCII
188 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
189 do \
191 register const unsigned char *_ascii_bytes = \
192 (const unsigned char *) (STR); \
193 register const unsigned char *limit = _ascii_bytes + (LENGTH); \
194 register unsigned bytes_in_chunk = 0; \
195 for (; _ascii_bytes < limit; _ascii_bytes++) \
197 register const unsigned char *p; \
198 if (bytes_in_chunk >= 64) \
200 fputc ('\n', (FILE)); \
201 bytes_in_chunk = 0; \
203 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
204 continue; \
205 if (p < limit && (p - _ascii_bytes) <= STRING_LIMIT) \
207 if (bytes_in_chunk > 0) \
209 fputc ('\n', (FILE)); \
210 bytes_in_chunk = 0; \
212 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
213 _ascii_bytes = p; \
215 else \
217 if (bytes_in_chunk == 0) \
218 fprintf ((FILE), "\t.byte\t"); \
219 else \
220 fputc (',', (FILE)); \
221 fprintf ((FILE), "0x%02x", *_ascii_bytes); \
222 bytes_in_chunk += 5; \
225 if (bytes_in_chunk > 0) \
226 fprintf ((FILE), "\n"); \
228 while (0)
230 /* This is how to output an element of a case-vector that is relative.
231 This is only used for PIC code. See comments by the `casesi' insn in
232 i386.md for an explanation of the expression this outputs.
233 PE format differs on what PC-relative offsets look like (see
234 coff_i386_rtype_to_howto), and we need to compensate (by one word) here. */
236 #undef ASM_OUTPUT_ADDR_DIFF_ELT
237 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
238 fprintf (FILE, "\t.long __GLOBAL_OFFSET_TABLE_+[.-%s%d+4]\n", LPREFIX, VALUE)
240 /* Indicate that jump tables go in the text section. This is
241 necessary when compiling PIC code. */
243 #define JUMP_TABLES_IN_TEXT_SECTION 1
245 /* Emit code to check the stack when allocating more that 4000
246 bytes in one go. */
248 #define CHECK_STACK_LIMIT 0x1000
250 /* the following are OSF linker (not gld) specific... we don't want them */
251 #undef HAS_INIT_SECTION
252 #undef LD_INIT_SWITCH
253 #undef LD_FINI_SWITCH
256 /* The following are needed for C++, but also needed for profiling */
258 /* Support const sections and the ctors and dtors sections for g++.
259 Note that there appears to be two different ways to support const
260 sections at the moment. You can either #define the symbol
261 READONLY_DATA_SECTION (giving it some code which switches to the
262 readonly data section) or else you can #define the symbols
263 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
264 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
266 #define USE_CONST_SECTION 1
268 #define CONST_SECTION_ASM_OP ".section\t.rdata,\"r\""
270 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
272 Note that we want to give these sections the SHF_WRITE attribute
273 because these sections will actually contain data (i.e. tables of
274 addresses of functions in the current root executable or shared library
275 file) and, in the case of a shared library, the relocatable addresses
276 will have to be properly resolved/relocated (and then written into) by
277 the dynamic linker when it actually attaches the given shared library
278 to the executing process. (Note that on SVR4, you may wish to use the
279 `-z text' option to the ELF linker, when building a shared library, as
280 an additional check that you are doing everything right. But if you do
281 use the `-z text' option when building a shared library, you will get
282 errors unless the .ctors and .dtors sections are marked as writable
283 via the SHF_WRITE attribute.) */
285 #define CTORS_SECTION_ASM_OP ".section\t.ctors,\"x\""
286 #define DTORS_SECTION_ASM_OP ".section\t.dtors,\"x\""
288 /* A default list of other sections which we might be "in" at any given
289 time. For targets that use additional sections (e.g. .tdesc) you
290 should override this definition in the target-specific file which
291 includes this file. */
293 #undef EXTRA_SECTIONS
294 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors
296 /* A default list of extra section function definitions. For targets
297 that use additional sections (e.g. .tdesc) you should override this
298 definition in the target-specific file which includes this file. */
300 #undef EXTRA_SECTION_FUNCTIONS
301 #define EXTRA_SECTION_FUNCTIONS \
302 CONST_SECTION_FUNCTION \
303 CTORS_SECTION_FUNCTION \
304 DTORS_SECTION_FUNCTION
306 #undef READONLY_DATA_SECTION
307 #define READONLY_DATA_SECTION() const_section ()
309 #define CONST_SECTION_FUNCTION \
310 void \
311 const_section () \
313 if (!USE_CONST_SECTION) \
314 text_section(); \
315 else if (in_section != in_const) \
317 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
318 in_section = in_const; \
322 #define CTORS_SECTION_FUNCTION \
323 void \
324 ctors_section () \
326 if (in_section != in_ctors) \
328 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
329 in_section = in_ctors; \
333 #define DTORS_SECTION_FUNCTION \
334 void \
335 dtors_section () \
337 if (in_section != in_dtors) \
339 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
340 in_section = in_dtors; \
344 #if 0
345 /* Currently gas chokes on this; that's not too hard to fix, but there's
346 not a lot of impeteus to do it, either. If it is done, gas will have
347 to handle long section name escapes (which are defined in the COFF/PE
348 document as /nnn where nnn is a string table index). The benefit:
349 section attributes and -ffunction-sections, neither of which seem to
350 be critical. */
351 /* gas may have been fixed? bfd was. */
353 /* Switch into a generic section.
354 This is currently only used to support section attributes.
356 We make the section read-only and executable for a function decl,
357 read-only for a const data decl, and writable for a non-const data decl. */
358 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
359 fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
360 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
361 (DECL) && TREE_READONLY (DECL) ? "a" : "aw")
362 #endif
364 #define INT_ASM_OP ".long"
366 /* The MS compilers take alignment as a number of bytes, so we do as well */
367 #undef ASM_OUTPUT_ALIGN
368 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
369 if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG))
371 /* A C statement (sans semicolon) to output an element in the table of
372 global constructors. */
373 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
374 do { \
375 ctors_section (); \
376 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
377 assemble_name (FILE, NAME); \
378 fprintf (FILE, "\n"); \
379 } while (0)
381 /* A C statement (sans semicolon) to output an element in the table of
382 global destructors. */
383 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
384 do { \
385 dtors_section (); \
386 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
387 assemble_name (FILE, NAME); \
388 fprintf (FILE, "\n"); \
389 } while (0)
391 /* The linker will take care of this, and having them causes problems with
392 ld -r (specifically -rU). */
393 #define CTOR_LISTS_DEFINED_EXTERNALLY 1
395 #define SET_ASM_OP ".set"
396 /* Output a definition (implements alias) */
397 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
398 do \
400 fprintf ((FILE), "\t%s\t", SET_ASM_OP); \
401 assemble_name (FILE, LABEL1); \
402 fprintf (FILE, ","); \
403 assemble_name (FILE, LABEL2); \
404 fprintf (FILE, "\n"); \
406 while (0)
408 #define HOST_PTR_PRINTF "%p"
409 #define HOST_PTR_AS_INT unsigned long
411 #define PCC_BITFIELD_TYPE_MATTERS 1
412 #define PCC_BITFIELD_TYPE_TEST TYPE_NATIVE(rec)
413 #define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
415 /* The following two flags are usually "off" for i386, because some non-gnu
416 tools (for the i386) don't handle them. However, we don't have that
417 problem, so.... */
419 /* Forward references to tags are allowed. */
420 #define SDB_ALLOW_FORWARD_REFERENCES
422 /* Unknown tags are also allowed. */
423 #define SDB_ALLOW_UNKNOWN_REFERENCES
425 /* The integer half of this list needs to be constant. However, there's
426 a lot of disagreement about what the floating point adjustments should
427 be. We pick one that works with gdb. (The underlying problem is
428 what to do about the segment registers. Since we have access to them
429 from /proc, we'll allow them to be accessed in gdb, even tho the
430 gcc compiler can't generate them. (There's some evidence that
431 MSVC does, but possibly only for certain special "canned" sequences.) */
433 #undef DBX_REGISTER_NUMBER
434 #define DBX_REGISTER_NUMBER(n) \
435 ((n) == 0 ? 0 \
436 : (n) == 1 ? 2 \
437 : (n) == 2 ? 1 \
438 : (n) == 3 ? 3 \
439 : (n) == 4 ? 6 \
440 : (n) == 5 ? 7 \
441 : (n) == 6 ? 5 \
442 : (n) == 7 ? 4 \
443 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+8 \
444 : (-1))
446 /* Define this macro if references to a symbol must be treated
447 differently depending on something about the variable or
448 function named by the symbol (such as what section it is in).
450 Apply stddef, handle (as yet unimplemented) pic.
452 stddef renaming does NOT apply to Alpha. */
454 char *gen_stdcall_suffix ();
456 #undef ENCODE_SECTION_INFO
457 #define ENCODE_SECTION_INFO(DECL) \
458 do \
460 if (flag_pic) \
462 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
463 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \
464 SYMBOL_REF_FLAG (XEXP (rtl, 0)) \
465 = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
466 || ! TREE_PUBLIC (DECL)); \
468 if (TREE_CODE (DECL) == FUNCTION_DECL) \
469 if (lookup_attribute ("stdcall", \
470 TYPE_ATTRIBUTES (TREE_TYPE (DECL)))) \
471 XEXP (DECL_RTL (DECL), 0) = \
472 gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL)); \
474 while (0)
476 /* This macro gets just the user-specified name
477 out of the string in a SYMBOL_REF. Discard
478 trailing @[NUM] encoded by ENCODE_SECTION_INFO. */
479 #undef STRIP_NAME_ENCODING
480 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
481 do { \
482 const char *_p; \
483 const char *_name = SYMBOL_NAME; \
484 for (_p = _name; *_p && *_p != '@'; ++_p) \
486 if (*_p == '@') \
488 int _len = _p - _name; \
489 _new_name = (char *) alloca (_len + 1); \
490 strncpy (_new_name, _name, _len); \
491 _new_name[_len] = '\0'; \
492 (VAR) = _new_name; \
494 else \
495 (VAR) = _name; \
496 } while (0)
498 #if 0
499 /* Turn this back on when the linker is updated to handle grouped
500 .data$ sections correctly. See corresponding note in i386/interix.c.
501 MK. */
503 /* Define this macro if in some cases global symbols from one translation
504 unit may not be bound to undefined symbols in another translation unit
505 without user intervention. For instance, under Microsoft Windows
506 symbols must be explicitly imported from shared libraries (DLLs). */
507 #define MULTIPLE_SYMBOL_SPACES
509 #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
510 extern void i386_pe_unique_section ();
511 #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
513 #define SUPPORTS_ONE_ONLY 1
515 /* A C statement to output something to the assembler file to switch to section
516 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
517 NULL_TREE. Some target formats do not support arbitrary sections. Do not
518 define this macro in such cases. */
519 #undef ASM_OUTPUT_SECTION_NAME
520 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
521 do { \
522 static struct section_info \
524 struct section_info *next; \
525 char *name; \
526 enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
527 } *sections; \
528 struct section_info *s; \
529 const char *mode; \
530 enum sect_enum type; \
532 for (s = sections; s; s = s->next) \
533 if (!strcmp (NAME, s->name)) \
534 break; \
536 if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
537 type = SECT_EXEC, mode = "x"; \
538 else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
539 type = SECT_RO, mode = "r"; \
540 else \
541 type = SECT_RW, mode = "w"; \
543 if (s == 0) \
545 s = (struct section_info *) xmalloc (sizeof (struct section_info)); \
546 s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \
547 strcpy (s->name, NAME); \
548 s->type = type; \
549 s->next = sections; \
550 sections = s; \
551 fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \
552 /* Functions may have been compiled at various levels of \
553 optimization so we can't use `same_size' here. Instead, \
554 have the linker pick one. */ \
555 if ((DECL) && DECL_ONE_ONLY (DECL)) \
556 fprintf (STREAM, "\t.linkonce %s\n", \
557 TREE_CODE (DECL) == FUNCTION_DECL \
558 ? "discard" : "same_size"); \
560 else \
562 fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \
564 } while (0)
566 #endif /* 0 */
568 /* DWARF2 Unwinding doesn't work with exception handling yet. */
569 #define DWARF2_UNWIND_INFO 0
571 /* Don't assume anything about the header files. */
572 #define NO_IMPLICIT_EXTERN_C