1/* Target definitions for GCC for Intel 80386 running Interix 2 Parts Copyright (C) 1991, 1999, 2000, 2002, 2003, 2004 3 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 11This file is part of GCC. 12 13GCC is free software; you can redistribute it and/or modify 14it under the terms of the GNU General Public License as published by 15the Free Software Foundation; either version 2, or (at your option) 16any later version. 17 18GCC is distributed in the hope that it will be useful, 19but WITHOUT ANY WARRANTY; without even the implied warranty of 20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21GNU General Public License for more details. 22 23You should have received a copy of the GNU General Public License 24along with GCC; see the file COPYING. If not, write to 25the Free Software Foundation, 51 Franklin Street, Fifth Floor, 26Boston, MA 02110-1301, USA. */ 27 28/* The rest must follow. */ 29 30#define DBX_DEBUGGING_INFO 1 31#define SDB_DEBUGGING_INFO 1 32#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG 33 34#define HANDLE_SYSV_PRAGMA 1 35#undef HANDLE_PRAGMA_WEAK /* until the link format can handle it */ 36 37/* By default, target has a 80387, uses IEEE compatible arithmetic, 38 and returns float values in the 387 and needs stack probes 39 We also align doubles to 64-bits for MSVC default compatibility 40 We do bitfields MSVC-compatibly by default, too. */ 41#undef TARGET_SUBTARGET_DEFAULT 42#define TARGET_SUBTARGET_DEFAULT \ 43 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \ 44 MASK_ALIGN_DOUBLE | MASK_MS_BITFIELD_LAYOUT) 45 46#undef TARGET_CPU_DEFAULT 47#define TARGET_CPU_DEFAULT 2 /* 486 */ 48 49#define WCHAR_TYPE_SIZE 16 50#define WCHAR_TYPE "short unsigned int" 51 52/* WinNT (and thus Interix) use unsigned int */ 53#define SIZE_TYPE "unsigned int" 54 55#define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n" 56 57#define TARGET_DECLSPEC 1 58 59/* cpp handles __STDC__ */ 60#define TARGET_OS_CPP_BUILTINS() \ 61 do \ 62 { \ 63 builtin_define ("__INTERIX"); \ 64 builtin_define ("__OPENNT"); \ 65 builtin_define ("_M_IX86=300"); \ 66 builtin_define ("_X86_=1"); \ 67 builtin_define ("__stdcall=__attribute__((__stdcall__))"); \ 68 builtin_define ("__cdecl=__attribute__((__cdecl__))"); \ 69 builtin_assert ("system=unix"); \ 70 builtin_assert ("system=interix"); \ 71 if (preprocessing_asm_p ()) \ 72 builtin_define_std ("LANGUAGE_ASSEMBLY"); \ 73 else \ 74 { \ 75 builtin_define_std ("LANGUAGE_C"); \ 76 if (c_dialect_cxx ()) \ 77 builtin_define_std ("LANGUAGE_C_PLUS_PLUS"); \ 78 if (c_dialect_objc ()) \ 79 builtin_define_std ("LANGUAGE_OBJECTIVE_C"); \ 80 } \ 81 } \ 82 while (0) 83 84#undef CPP_SPEC 85/* Write out the correct language type definition for the header files. 86 Unless we have assembler language, write out the symbols for C. 87 mieee is an Alpha specific variant. Cross polination a bad idea. 88 */ 89#define CPP_SPEC "-remap %{posix:-D_POSIX_SOURCE} \ 90-isystem %$INTERIX_ROOT/usr/include" 91 92#define TARGET_VERSION fprintf (stderr, " (i386 Interix)"); 93 94/* The global __fltused is necessary to cause the printf/scanf routines 95 for outputting/inputting floating point numbers to be loaded. Since this 96 is kind of hard to detect, we just do it all the time. */ 97#undef X86_FILE_START_FLTUSED 98#define X86_FILE_START_FLTUSED 1 99 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. */ 113 114#define ESCAPES \ 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" 123 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. 131 132 If your target assembler doesn't support the .string directive, you 133 should define this to zero. 134*/ 135 136#define STRING_LIMIT ((unsigned) 256) 137 138#define STRING_ASM_OP "\t.string\t" 139 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). */ 146 147#define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \ 148 do \ 149 { \ 150 const unsigned char *_limited_str = \ 151 (const unsigned char *) (STR); \ 152 unsigned ch; \ 153 fprintf ((FILE), "%s\"", STRING_ASM_OP); \ 154 for (; (ch = *_limited_str); _limited_str++) \ 155 { \ 156 int escape = ESCAPES[ch]; \ 157 switch (escape) \ 158 { \ 159 case 0: \ 160 putc (ch, (FILE)); \ 161 break; \ 162 case 1: \ 163 fprintf ((FILE), "\\%03o", ch); \ 164 break; \ 165 default: \ 166 putc ('\\', (FILE)); \ 167 putc (escape, (FILE)); \ 168 break; \ 169 } \ 170 } \ 171 fprintf ((FILE), "\"\n"); \ 172 } \ 173 while (0) 174 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. */ 181 182#undef ASM_OUTPUT_ASCII 183#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ 184 do \ 185 { \ 186 const unsigned char *_ascii_bytes = \ 187 (const unsigned char *) (STR); \ 188 const unsigned char *limit = _ascii_bytes + (LENGTH); \ 189 unsigned bytes_in_chunk = 0; \ 190 for (; _ascii_bytes < limit; _ascii_bytes++) \ 191 { \ 192 const unsigned char *p; \ 193 if (bytes_in_chunk >= 64) \ 194 { \ 195 fputc ('\n', (FILE)); \ 196 bytes_in_chunk = 0; \ 197 } \ 198 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ 199 continue; \ 200 if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT) \ 201 { \ 202 if (bytes_in_chunk > 0) \ 203 { \ 204 fputc ('\n', (FILE)); \ 205 bytes_in_chunk = 0; \ 206 } \ 207 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \ 208 _ascii_bytes = p; \ 209 } \ 210 else \ 211 { \ 212 if (bytes_in_chunk == 0) \ 213 fprintf ((FILE), "\t.byte\t"); \ 214 else \ 215 fputc (',', (FILE)); \ 216 fprintf ((FILE), "0x%02x", *_ascii_bytes); \ 217 bytes_in_chunk += 5; \ 218 } \ 219 } \ 220 if (bytes_in_chunk > 0) \ 221 fprintf ((FILE), "\n"); \ 222 } \ 223 while (0) 224 225/* Emit code to check the stack when allocating more that 4000 226 bytes in one go. */ 227 228#define CHECK_STACK_LIMIT 0x1000 229 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 234 235/* The following are needed for us to be able to use winnt.c, but are not 236 otherwise meaningful to Interix. (The functions that use these are 237 never called because we don't do DLLs.) */ 238#define TARGET_NOP_FUN_DLLIMPORT 1 239#define drectve_section() /* nothing */ 240 241/* Objective-C has its own packing rules... 242 Objc tries to parallel the code in stor-layout.c at runtime 243 (see libobjc/encoding.c). This (compile-time) packing info isn't 244 available at runtime, so it's hopeless to try. 245 246 And if the user tries to set the flag for objc, give an error 247 so he has some clue. */ 248 249#undef SUBTARGET_OVERRIDE_OPTIONS 250#define SUBTARGET_OVERRIDE_OPTIONS \ 251do { \ 252 if (strcmp (lang_hooks.name, "GNU Objective-C") == 0) \ 253 { \ 254 if ((target_flags & MASK_MS_BITFIELD_LAYOUT) != 0 \ 255 && (target_flags_explicit & MASK_MS_BITFIELD_LAYOUT) != 0) \ 256 { \ 257 error ("ms-bitfields not supported for objc"); \ 258 } \ 259 target_flags &= ~MASK_MS_BITFIELD_LAYOUT; \ 260 } \ 261} while (0) 262 263#define EH_FRAME_IN_DATA_SECTION 264 265#define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rdata,\"r\"" 266 267/* The MS compilers take alignment as a number of bytes, so we do as well */ 268#undef ASM_OUTPUT_ALIGN 269#define ASM_OUTPUT_ALIGN(FILE,LOG) \ 270 if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG)) 271 272/* The linker will take care of this, and having them causes problems with 273 ld -r (specifically -rU). */ 274#define CTOR_LISTS_DEFINED_EXTERNALLY 1 275 276#define SET_ASM_OP "\t.set\t" 277/* Output a definition (implements alias) */ 278#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ 279do \ 280{ \ 281 fprintf ((FILE), "%s", SET_ASM_OP); \ 282 assemble_name (FILE, LABEL1); \ 283 fprintf (FILE, ","); \ 284 assemble_name (FILE, LABEL2); \ 285 fprintf (FILE, "\n"); \ 286 } \ 287while (0) 288 289#define HOST_PTR_AS_INT unsigned long 290 291#define PCC_BITFIELD_TYPE_MATTERS 1 292 293/* The following two flags are usually "off" for i386, because some non-gnu 294 tools (for the i386) don't handle them. However, we don't have that 295 problem, so.... */ 296 297/* Forward references to tags are allowed. */ 298#define SDB_ALLOW_FORWARD_REFERENCES 299 300/* Unknown tags are also allowed. */ 301#define SDB_ALLOW_UNKNOWN_REFERENCES 302 303/* The integer half of this list needs to be constant. However, there's 304 a lot of disagreement about what the floating point adjustments should 305 be. We pick one that works with gdb. (The underlying problem is 306 what to do about the segment registers. Since we have access to them 307 from /proc, we'll allow them to be accessed in gdb, even tho the 308 gcc compiler can't generate them. (There's some evidence that 309 MSVC does, but possibly only for certain special "canned" sequences.) */ 310 311#undef DBX_REGISTER_NUMBER 312#define DBX_REGISTER_NUMBER(n) \ 313(TARGET_64BIT ? dbx64_register_map[n] \ 314 : (n) == 0 ? 0 \ 315 : (n) == 1 ? 2 \ 316 : (n) == 2 ? 1 \ 317 : (n) == 3 ? 3 \ 318 : (n) == 4 ? 6 \ 319 : (n) == 5 ? 7 \ 320 : (n) == 6 ? 5 \ 321 : (n) == 7 ? 4 \ 322 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+8 \ 323 : (-1)) 324 325/* Define this macro if references to a symbol must be treated 326 differently depending on something about the variable or 327 function named by the symbol (such as what section it is in). */ 328 329#undef TARGET_ENCODE_SECTION_INFO 330#define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info 331#undef TARGET_STRIP_NAME_ENCODING 332#define TARGET_STRIP_NAME_ENCODING i386_pe_strip_name_encoding_full 333 334#if 0 335/* Turn this back on when the linker is updated to handle grouped 336 .data$ sections correctly. See corresponding note in i386/interix.c. 337 MK. */ 338 339/* Interix uses explicit import from shared libraries. */ 340#define MULTIPLE_SYMBOL_SPACES 1 341 342extern void i386_pe_unique_section (tree, int); 343#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section 344#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section 345 346#define SUPPORTS_ONE_ONLY 1 347#endif /* 0 */ 348 349/* Switch into a generic section. */ 350#define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section 351 352/* DWARF2 Unwinding doesn't work with exception handling yet. */ 353#define DWARF2_UNWIND_INFO 0 354 355/* Don't assume anything about the header files. */ 356#define NO_IMPLICIT_EXTERN_C 357 358/* MSVC returns structs of up to 8 bytes via registers. */ 359 360#define DEFAULT_PCC_STRUCT_RETURN 0 361 362#undef RETURN_IN_MEMORY 363#define RETURN_IN_MEMORY(TYPE) \ 364 (TYPE_MODE (TYPE) == BLKmode || \ 365 (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes(TYPE) > 8 )) 366