OSDN Git Service

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