i386-interix.h revision 96263
1/* Target definitions for GNU compiler for Intel 80386 running Interix 2 Parts Copyright (C) 1991, 1999, 2000 Free Software Foundation, Inc. 3 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). 9 10This file is part of GNU CC. 11 12GNU CC is free software; you can redistribute it and/or modify 13it under the terms of the GNU General Public License as published by 14the Free Software Foundation; either version 2, or (at your option) 15any later version. 16 17GNU CC is distributed in the hope that it will be useful, 18but WITHOUT ANY WARRANTY; without even the implied warranty of 19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20GNU General Public License for more details. 21 22You should have received a copy of the GNU General Public License 23along with GNU CC; see the file COPYING. If not, write to 24the Free Software Foundation, 59 Temple Place - Suite 330, 25Boston, MA 02111-1307, USA. */ 26 27#define YES_UNDERSCORES 28 29/* YES_UNDERSCORES must precede gas.h */ 30#include <i386/gas.h> 31/* The rest must follow. */ 32 33#define DBX_DEBUGGING_INFO 34#define SDB_DEBUGGING_INFO 35#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG 36 37#define HANDLE_SYSV_PRAGMA 38#undef HANDLE_PRAGMA_WEAK /* until the link format can handle it */ 39 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 compatibility */ 43#undef TARGET_SUBTARGET_DEFAULT 44#define TARGET_SUBTARGET_DEFAULT \ 45 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \ 46 MASK_ALIGN_DOUBLE) 47 48#undef TARGET_CPU_DEFAULT 49#define TARGET_CPU_DEFAULT 2 /* 486 */ 50 51#define WCHAR_UNSIGNED 1 52#define WCHAR_TYPE_SIZE 16 53#define WCHAR_TYPE "short unsigned int" 54 55/* WinNT (and thus Interix) use unsigned int */ 56#define SIZE_TYPE "unsigned int" 57 58#define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n" 59 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 -D__declspec(x)=__attribute__((x)) \ 69 -Asystem=unix -Asystem=interix" 70 71#undef CPP_SPEC 72/* Write out the correct language type definition for the header files. 73 Unless we have assembler language, write out the symbols for C. 74 cpp_cpu is an Intel specific variant. See i386.h 75 mieee is an Alpha specific variant. Cross polination a bad idea. 76 */ 77#define CPP_SPEC "\ 78%{!.S: -D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}} \ 79%{.S: -D__LANGUAGE_ASSEMBLY__ -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \ 80%{.cc: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \ 81%{.cxx: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \ 82%{.C: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \ 83%{.m: -D__LANGUAGE_OBJECTIVE_C__ -D__LANGUAGE_OBJECTIVE_C} \ 84-remap \ 85%(cpp_cpu) \ 86%{posix:-D_POSIX_SOURCE} \ 87-isystem %$INTERIX_ROOT/usr/include" 88 89#undef TARGET_VERSION 90#define TARGET_VERSION fprintf (stderr, " (i386 Interix)"); 91 92/* The global __fltused is necessary to cause the printf/scanf routines 93 for outputting/inputting floating point numbers to be loaded. Since this 94 is kind of hard to detect, we just do it all the time. */ 95 96#ifdef ASM_FILE_START 97#undef ASM_FILE_START 98#endif 99#define ASM_FILE_START(FILE) \ 100 do { fprintf (FILE, "\t.file\t"); \ 101 output_quoted_string (FILE, dump_base_name); \ 102 fprintf (FILE, "\n"); \ 103 fprintf (FILE, ".global\t__fltused\n"); \ 104 } while (0) 105 106/* A table of bytes codes used by the ASM_OUTPUT_ASCII and 107 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table 108 corresponds to a particular byte value [0..255]. For any 109 given byte value, if the value in the corresponding table 110 position is zero, the given character can be output directly. 111 If the table value is 1, the byte must be output as a \ooo 112 octal escape. If the tables value is anything else, then the 113 byte value should be output as a \ followed by the value 114 in the table. Note that we can use standard UN*X escape 115 sequences for many control characters, but we don't use 116 \a to represent BEL because some svr4 assemblers (e.g. on 117 the i386) don't know about that. Also, we don't use \v 118 since some versions of gas, such as 2.2 did not accept it. */ 119 120#define ESCAPES \ 121"\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\ 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\ 124\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\ 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\ 128\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 130/* Some svr4 assemblers have a limit on the number of characters which 131 can appear in the operand of a .string directive. If your assembler 132 has such a limitation, you should define STRING_LIMIT to reflect that 133 limit. Note that at least some svr4 assemblers have a limit on the 134 actual number of bytes in the double-quoted string, and that they 135 count each character in an escape sequence as one byte. Thus, an 136 escape sequence like \377 would count as four bytes. 137 138 If your target assembler doesn't support the .string directive, you 139 should define this to zero. 140*/ 141 142#define STRING_LIMIT ((unsigned) 256) 143 144#define STRING_ASM_OP "\t.string\t" 145 146/* The routine used to output NUL terminated strings. We use a special 147 version of this for most svr4 targets because doing so makes the 148 generated assembly code more compact (and thus faster to assemble) 149 as well as more readable, especially for targets like the i386 150 (where the only alternative is to output character sequences as 151 comma separated lists of numbers). */ 152 153#define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \ 154 do \ 155 { \ 156 register const unsigned char *_limited_str = \ 157 (const unsigned char *) (STR); \ 158 register unsigned ch; \ 159 fprintf ((FILE), "%s\"", STRING_ASM_OP); \ 160 for (; (ch = *_limited_str); _limited_str++) \ 161 { \ 162 register int escape = ESCAPES[ch]; \ 163 switch (escape) \ 164 { \ 165 case 0: \ 166 putc (ch, (FILE)); \ 167 break; \ 168 case 1: \ 169 fprintf ((FILE), "\\%03o", ch); \ 170 break; \ 171 default: \ 172 putc ('\\', (FILE)); \ 173 putc (escape, (FILE)); \ 174 break; \ 175 } \ 176 } \ 177 fprintf ((FILE), "\"\n"); \ 178 } \ 179 while (0) 180 181/* The routine used to output sequences of byte values. We use a special 182 version of this for most svr4 targets because doing so makes the 183 generated assembly code more compact (and thus faster to assemble) 184 as well as more readable. Note that if we find subparts of the 185 character sequence which end with NUL (and which are shorter than 186 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ 187 188#undef ASM_OUTPUT_ASCII 189#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ 190 do \ 191 { \ 192 register const unsigned char *_ascii_bytes = \ 193 (const unsigned char *) (STR); \ 194 register const unsigned char *limit = _ascii_bytes + (LENGTH); \ 195 register unsigned bytes_in_chunk = 0; \ 196 for (; _ascii_bytes < limit; _ascii_bytes++) \ 197 { \ 198 register const unsigned char *p; \ 199 if (bytes_in_chunk >= 64) \ 200 { \ 201 fputc ('\n', (FILE)); \ 202 bytes_in_chunk = 0; \ 203 } \ 204 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ 205 continue; \ 206 if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT) \ 207 { \ 208 if (bytes_in_chunk > 0) \ 209 { \ 210 fputc ('\n', (FILE)); \ 211 bytes_in_chunk = 0; \ 212 } \ 213 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \ 214 _ascii_bytes = p; \ 215 } \ 216 else \ 217 { \ 218 if (bytes_in_chunk == 0) \ 219 fprintf ((FILE), "\t.byte\t"); \ 220 else \ 221 fputc (',', (FILE)); \ 222 fprintf ((FILE), "0x%02x", *_ascii_bytes); \ 223 bytes_in_chunk += 5; \ 224 } \ 225 } \ 226 if (bytes_in_chunk > 0) \ 227 fprintf ((FILE), "\n"); \ 228 } \ 229 while (0) 230 231/* Emit code to check the stack when allocating more that 4000 232 bytes in one go. */ 233 234#define CHECK_STACK_LIMIT 0x1000 235 236/* the following are OSF linker (not gld) specific... we don't want them */ 237#undef HAS_INIT_SECTION 238#undef LD_INIT_SWITCH 239#undef LD_FINI_SWITCH 240 241#define EH_FRAME_IN_DATA_SECTION 242 243/* Note that there appears to be two different ways to support const 244 sections at the moment. You can either #define the symbol 245 READONLY_DATA_SECTION (giving it some code which switches to the 246 readonly data section) or else you can #define the symbols 247 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and 248 SELECT_RTX_SECTION. We do both here just to be on the safe side. */ 249 250#define USE_CONST_SECTION 1 251 252#define CONST_SECTION_ASM_OP "\t.section\t.rdata,\"r\"" 253 254/* A default list of other sections which we might be "in" at any given 255 time. For targets that use additional sections (e.g. .tdesc) you 256 should override this definition in the target-specific file which 257 includes this file. */ 258 259#undef EXTRA_SECTIONS 260#define EXTRA_SECTIONS in_const 261 262/* A default list of extra section function definitions. For targets 263 that use additional sections (e.g. .tdesc) you should override this 264 definition in the target-specific file which includes this file. */ 265 266#undef EXTRA_SECTION_FUNCTIONS 267#define EXTRA_SECTION_FUNCTIONS \ 268 CONST_SECTION_FUNCTION 269 270#undef READONLY_DATA_SECTION 271#define READONLY_DATA_SECTION() const_section () 272 273#define CONST_SECTION_FUNCTION \ 274void \ 275const_section () \ 276{ \ 277 if (!USE_CONST_SECTION) \ 278 text_section(); \ 279 else if (in_section != in_const) \ 280 { \ 281 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \ 282 in_section = in_const; \ 283 } \ 284} 285 286/* The MS compilers take alignment as a number of bytes, so we do as well */ 287#undef ASM_OUTPUT_ALIGN 288#define ASM_OUTPUT_ALIGN(FILE,LOG) \ 289 if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG)) 290 291/* The linker will take care of this, and having them causes problems with 292 ld -r (specifically -rU). */ 293#define CTOR_LISTS_DEFINED_EXTERNALLY 1 294 295#define SET_ASM_OP "\t.set\t" 296/* Output a definition (implements alias) */ 297#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ 298do \ 299{ \ 300 fprintf ((FILE), "%s", SET_ASM_OP); \ 301 assemble_name (FILE, LABEL1); \ 302 fprintf (FILE, ","); \ 303 assemble_name (FILE, LABEL2); \ 304 fprintf (FILE, "\n"); \ 305 } \ 306while (0) 307 308#define HOST_PTR_PRINTF "%p" 309#define HOST_PTR_AS_INT unsigned long 310 311#define PCC_BITFIELD_TYPE_MATTERS 1 312#define PCC_BITFIELD_TYPE_TEST TYPE_NATIVE(rec) 313#define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec) 314 315/* The following two flags are usually "off" for i386, because some non-gnu 316 tools (for the i386) don't handle them. However, we don't have that 317 problem, so.... */ 318 319/* Forward references to tags are allowed. */ 320#define SDB_ALLOW_FORWARD_REFERENCES 321 322/* Unknown tags are also allowed. */ 323#define SDB_ALLOW_UNKNOWN_REFERENCES 324 325/* The integer half of this list needs to be constant. However, there's 326 a lot of disagreement about what the floating point adjustments should 327 be. We pick one that works with gdb. (The underlying problem is 328 what to do about the segment registers. Since we have access to them 329 from /proc, we'll allow them to be accessed in gdb, even tho the 330 gcc compiler can't generate them. (There's some evidence that 331 MSVC does, but possibly only for certain special "canned" sequences.) */ 332 333#undef DBX_REGISTER_NUMBER 334#define DBX_REGISTER_NUMBER(n) \ 335(TARGET_64BIT ? dbx64_register_map[n] \ 336 : (n) == 0 ? 0 \ 337 : (n) == 1 ? 2 \ 338 : (n) == 2 ? 1 \ 339 : (n) == 3 ? 3 \ 340 : (n) == 4 ? 6 \ 341 : (n) == 5 ? 7 \ 342 : (n) == 6 ? 5 \ 343 : (n) == 7 ? 4 \ 344 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+8 \ 345 : (-1)) 346 347/* Define this macro if references to a symbol must be treated 348 differently depending on something about the variable or 349 function named by the symbol (such as what section it is in). 350 351 Apply stddef, handle (as yet unimplemented) pic. 352 353 stddef renaming does NOT apply to Alpha. */ 354 355union tree_node; 356const char *gen_stdcall_suffix PARAMS ((union tree_node *)); 357 358#undef ENCODE_SECTION_INFO 359#define ENCODE_SECTION_INFO(DECL) \ 360do \ 361 { \ 362 if (flag_pic) \ 363 { \ 364 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ 365 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \ 366 SYMBOL_REF_FLAG (XEXP (rtl, 0)) \ 367 = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ 368 || ! TREE_PUBLIC (DECL)); \ 369 } \ 370 if (TREE_CODE (DECL) == FUNCTION_DECL) \ 371 if (lookup_attribute ("stdcall", \ 372 TYPE_ATTRIBUTES (TREE_TYPE (DECL)))) \ 373 XEXP (DECL_RTL (DECL), 0) = \ 374 gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL)); \ 375 } \ 376while (0) 377 378/* This macro gets just the user-specified name 379 out of the string in a SYMBOL_REF. Discard 380 trailing @[NUM] encoded by ENCODE_SECTION_INFO. */ 381#undef STRIP_NAME_ENCODING 382#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ 383do { \ 384 const char *_p; \ 385 const char *_name = SYMBOL_NAME; \ 386 for (_p = _name; *_p && *_p != '@'; ++_p) \ 387 ; \ 388 if (*_p == '@') \ 389 { \ 390 int _len = _p - _name; \ 391 char *_new_name = (char *) alloca (_len + 1); \ 392 strncpy (_new_name, _name, _len); \ 393 _new_name[_len] = '\0'; \ 394 (VAR) = _new_name; \ 395 } \ 396 else \ 397 (VAR) = _name; \ 398} while (0) 399 400#if 0 401/* Turn this back on when the linker is updated to handle grouped 402 .data$ sections correctly. See corresponding note in i386/interix.c. 403 MK. */ 404 405/* Define this macro if in some cases global symbols from one translation 406 unit may not be bound to undefined symbols in another translation unit 407 without user intervention. For instance, under Microsoft Windows 408 symbols must be explicitly imported from shared libraries (DLLs). */ 409#define MULTIPLE_SYMBOL_SPACES 410 411extern void i386_pe_unique_section (); 412#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC) 413 414#define SUPPORTS_ONE_ONLY 1 415#endif /* 0 */ 416 417/* Switch into a generic section. */ 418#define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section 419 420/* DWARF2 Unwinding doesn't work with exception handling yet. */ 421#define DWARF2_UNWIND_INFO 0 422 423/* Don't assume anything about the header files. */ 424#define NO_IMPLICIT_EXTERN_C 425 426/* MSVC returns structs of up to 8 bytes via registers. */ 427 428#define DEFAULT_PCC_STRUCT_RETURN 0 429 430#undef RETURN_IN_MEMORY 431#define RETURN_IN_MEMORY(TYPE) \ 432 (TYPE_MODE (TYPE) == BLKmode || \ 433 (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes(TYPE) > 8 )) 434