OSDN Git Service

Pizza-lize :-)
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / cygming.h
1 /* Operating system specific defines to be used when targeting GCC for
2    hosting on Windows32, using a Unix style C library and tools.
3    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4    2004, 2005, 2007, 2008, 2009, 2010, 2011
5    Free Software Foundation, Inc.
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
13
14 GCC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3.  If not see
21 <http://www.gnu.org/licenses/>.  */
22
23 #define DBX_DEBUGGING_INFO 1
24 #define SDB_DEBUGGING_INFO 1
25 #if TARGET_64BIT_DEFAULT || defined (HAVE_GAS_PE_SECREL32_RELOC)
26 #define DWARF2_DEBUGGING_INFO 1
27 #endif
28
29 #undef PREFERRED_DEBUGGING_TYPE
30 #if (DWARF2_DEBUGGING_INFO)
31 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
32 #else
33 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
34 #endif
35
36 #undef TARGET_SEH
37 #define TARGET_SEH  (TARGET_64BIT_MS_ABI && flag_unwind_tables)
38
39 /* Win64 with SEH cannot represent DRAP stack frames.  Disable its use.
40    Force the use of different mechanisms to allocate aligned local data.  */
41 #undef MAX_STACK_ALIGNMENT
42 #define MAX_STACK_ALIGNMENT  (TARGET_SEH ? 128 : MAX_OFILE_ALIGNMENT)
43
44 /* Support hooks for SEH.  */
45 #undef  TARGET_ASM_UNWIND_EMIT
46 #define TARGET_ASM_UNWIND_EMIT  i386_pe_seh_unwind_emit
47 #undef  TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
48 #define TARGET_ASM_UNWIND_EMIT_BEFORE_INSN  false
49 #undef  TARGET_ASM_FUNCTION_END_PROLOGUE
50 #define TARGET_ASM_FUNCTION_END_PROLOGUE  i386_pe_seh_end_prologue
51 #define SUBTARGET_ASM_UNWIND_INIT  i386_pe_seh_init
52
53 #undef DEFAULT_ABI
54 #define DEFAULT_ABI (TARGET_64BIT ? MS_ABI : SYSV_ABI)
55
56 #if ! defined (USE_MINGW64_LEADING_UNDERSCORES)
57 #undef USER_LABEL_PREFIX
58 #define USER_LABEL_PREFIX (TARGET_64BIT ? "" : "_")
59
60 #undef LOCAL_LABEL_PREFIX
61 #define LOCAL_LABEL_PREFIX (TARGET_64BIT ? "." : "")
62
63 #undef ASM_GENERATE_INTERNAL_LABEL
64 #define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER)  \
65   sprintf ((BUF), "*%s%s%ld", LOCAL_LABEL_PREFIX, \
66            (PREFIX), (long)(NUMBER))
67
68 #undef LPREFIX
69 #define LPREFIX (TARGET_64BIT ? ".L" : "L")
70
71 #endif
72
73 #undef DBX_REGISTER_NUMBER
74 #define DBX_REGISTER_NUMBER(n)                          \
75   (TARGET_64BIT ? dbx64_register_map[n]                 \
76    : (write_symbols == DWARF2_DEBUG                     \
77       ? svr4_dbx_register_map[n] : dbx_register_map[n]))
78
79 /* Map gcc register number to DWARF 2 CFA column number. For 32 bit
80    target, always use the svr4_dbx_register_map for DWARF .eh_frame
81    even if we don't use DWARF .debug_frame. */
82 #undef DWARF_FRAME_REGNUM
83 #define DWARF_FRAME_REGNUM(n)                           \
84   (TARGET_64BIT ? dbx64_register_map[(n)]               \
85                 : svr4_dbx_register_map[(n)])
86
87 /* The 64-bit MS_ABI changes the set of call-used registers.  */
88 #undef DWARF_FRAME_REGISTERS
89 #define DWARF_FRAME_REGISTERS (TARGET_64BIT ? 33 : 17)
90
91 #ifdef HAVE_GAS_PE_SECREL32_RELOC
92 /* Use section relative relocations for debugging offsets.  Unlike
93    other targets that fake this by putting the section VMA at 0, PE
94    won't allow it.  */
95 #define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, SECTION)     \
96   do {                                                          \
97     switch (SIZE)                                               \
98       {                                                         \
99       case 4:                                                   \
100         fputs ("\t.secrel32\t", FILE);                          \
101         assemble_name (FILE, LABEL);                            \
102         break;                                                  \
103       case 8:                                                   \
104         /* This is a hack.  There is no 64-bit section relative \
105            relocation.  However, the COFF format also does not  \
106            support 64-bit file offsets; 64-bit applications are \
107            limited to 32-bits of code+data in any one module.   \
108            Fake the 64-bit offset by zero-extending it.  */     \
109         fputs ("\t.secrel32\t", FILE);                          \
110         assemble_name (FILE, LABEL);                            \
111         fputs ("\n\t.long\t0", FILE);                           \
112         break;                                                  \
113       default:                                                  \
114         gcc_unreachable ();                                     \
115       }                                                         \
116   } while (0)
117 #endif
118
119 #define TARGET_EXECUTABLE_SUFFIX ".exe"
120
121 #define TARGET_OS_CPP_BUILTINS()                                        \
122   do                                                                    \
123     {                                                                   \
124         if (!TARGET_64BIT)                                              \
125           builtin_define ("_X86_=1");                                   \
126         if (TARGET_SEH)                                                 \
127           builtin_define ("__SEH__");                           \
128         builtin_assert ("system=winnt");                                \
129         builtin_define ("__stdcall=__attribute__((__stdcall__))");      \
130         builtin_define ("__fastcall=__attribute__((__fastcall__))");    \
131         builtin_define ("__thiscall=__attribute__((__thiscall__))");    \
132         builtin_define ("__cdecl=__attribute__((__cdecl__))");          \
133         if (!flag_iso)                                                  \
134           {                                                             \
135             builtin_define ("_stdcall=__attribute__((__stdcall__))");   \
136             builtin_define ("_fastcall=__attribute__((__fastcall__))"); \
137             builtin_define ("_thiscall=__attribute__((__thiscall__))"); \
138             builtin_define ("_cdecl=__attribute__((__cdecl__))");       \
139           }                                                             \
140         /* Even though linkonce works with static libs, this is needed  \
141             to compare typeinfo symbols across dll boundaries.  */      \
142         builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0");               \
143         builtin_define ("__GXX_TYPEINFO_EQUALITY_INLINE=0");            \
144         EXTRA_OS_CPP_BUILTINS ();                                       \
145   }                                                                     \
146   while (0)
147
148 /* Get tree.c to declare a target-specific specialization of
149    merge_decl_attributes.  */
150 #define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
151
152 /* This macro defines names of additional specifications to put in the specs
153    that can be used in various specifications like CC1_SPEC.  Its definition
154    is an initializer with a subgrouping for each command option.
155
156    Each subgrouping contains a string constant, that defines the
157    specification name, and a string constant that used by the GCC driver
158    program.
159
160    Do not define this macro if it does not need to do anything.  */
161
162 #undef  SUBTARGET_EXTRA_SPECS
163 #define SUBTARGET_EXTRA_SPECS                                           \
164   { "mingw_include_path", DEFAULT_TARGET_MACHINE }
165
166 #undef MATH_LIBRARY
167 #define MATH_LIBRARY ""
168
169 #define SIZE_TYPE (TARGET_64BIT ? "long long unsigned int" : "unsigned int")
170 #define PTRDIFF_TYPE (TARGET_64BIT ? "long long int" : "int")
171
172 #define WCHAR_TYPE_SIZE 16
173 #define WCHAR_TYPE "short unsigned int"
174
175 /* Windows64 continues to use a 32-bit long type.  */
176 #undef LONG_TYPE_SIZE
177 #define LONG_TYPE_SIZE 32
178 \f
179 #define drectve_section() \
180   (fprintf (asm_out_file, "\t.section .drectve\n"), \
181    in_section = NULL)
182
183 /* Older versions of gas don't handle 'r' as data.
184    Explicitly set data flag with 'd'.  */  
185 #define READONLY_DATA_SECTION_ASM_OP "\t.section .rdata,\"dr\""
186
187 /* Don't allow flag_pic to propagate since gas may produce invalid code
188    otherwise.  */
189
190 #undef  SUBTARGET_OVERRIDE_OPTIONS
191 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
192 do {                                                                    \
193   if (TARGET_64BIT && flag_pic != 1)                                    \
194     {                                                                   \
195       if (flag_pic > 1)                                                 \
196         warning (0,                                                     \
197                  "-fPIC ignored for target (all code is position independent)"\
198                  );                                                     \
199       flag_pic = 1;                                                     \
200     }                                                                   \
201   else if (!TARGET_64BIT && flag_pic)                                   \
202     {                                                                   \
203       warning (0, "-f%s ignored for target (all code is position independent)",\
204                (flag_pic > 1) ? "PIC" : "pic");                         \
205       flag_pic = 0;                                                     \
206     }                                                                   \
207 } while (0)
208
209 /* Define this macro if references to a symbol must be treated
210    differently depending on something about the variable or
211    function named by the symbol (such as what section it is in).
212
213    On i386 running Windows NT, modify the assembler name with a suffix
214    consisting of an atsign (@) followed by string of digits that represents
215    the number of bytes of arguments passed to the function, if it has the
216    attribute STDCALL.
217
218    In addition, we must mark dll symbols specially. Definitions of
219    dllexport'd objects install some info in the .drectve section.
220    References to dllimport'd objects are fetched indirectly via
221    _imp__.  If both are declared, dllexport overrides.  This is also
222    needed to implement one-only vtables: they go into their own
223    section and we need to set DECL_SECTION_NAME so we do that here.
224    Note that we can be called twice on the same decl.  */
225
226 #define SUBTARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
227
228 /* Output a common block.  */
229 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
230 #define ASM_OUTPUT_ALIGNED_DECL_COMMON \
231   i386_pe_asm_output_aligned_decl_common
232
233 /* Output the label for an initialized variable.  */
234 #undef ASM_DECLARE_OBJECT_NAME
235 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)     \
236 do {                                                    \
237   i386_pe_maybe_record_exported_symbol (DECL, NAME, 1); \
238   ASM_OUTPUT_LABEL ((STREAM), (NAME));                  \
239 } while (0)
240
241 /* Output a reference to a label. Fastcall function symbols
242    keep their '@' prefix, while other symbols are prefixed
243    with user_label_prefix.  */
244 #undef ASM_OUTPUT_LABELREF
245 #define  ASM_OUTPUT_LABELREF(STREAM, NAME)      \
246 do {                                            \
247   if ((NAME)[0] != FASTCALL_PREFIX)             \
248     fputs (user_label_prefix, (STREAM));        \
249   fputs ((NAME), (STREAM));                     \
250 } while (0)
251
252 /* This does much the same in memory rather than to a stream.  */
253 #undef TARGET_MANGLE_ASSEMBLER_NAME
254 #define TARGET_MANGLE_ASSEMBLER_NAME i386_pe_mangle_assembler_name
255
256 \f
257 /* Emit code to check the stack when allocating more than 4000
258    bytes in one go.  */
259 #define CHECK_STACK_LIMIT 4000
260
261 #undef STACK_BOUNDARY
262 #define STACK_BOUNDARY  (TARGET_64BIT && ix86_abi == MS_ABI ? 128 : BITS_PER_WORD)
263
264 /* By default, target has a 80387, uses IEEE compatible arithmetic,
265    returns float values in the 387 and needs stack probes.
266    We also align doubles to 64-bits for MSVC default compatibility.  */
267
268 #undef TARGET_SUBTARGET_DEFAULT
269 #define TARGET_SUBTARGET_DEFAULT \
270         (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS \
271          | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE)
272
273 #undef TARGET_SUBTARGET64_DEFAULT
274 #define TARGET_SUBTARGET64_DEFAULT \
275         MASK_128BIT_LONG_DOUBLE
276
277 /* This is how to output an assembler line
278    that says to advance the location counter
279    to a multiple of 2**LOG bytes.  */
280
281 #undef ASM_OUTPUT_ALIGN
282 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
283     if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
284
285 /* Windows uses explicit import from shared libraries.  */
286 #define MULTIPLE_SYMBOL_SPACES 1
287
288 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
289 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
290
291 #define SUPPORTS_ONE_ONLY 1
292
293 /* Switch into a generic section.  */
294 #define TARGET_ASM_NAMED_SECTION  i386_pe_asm_named_section
295
296 /* Select attributes for named sections.  */
297 #define TARGET_SECTION_TYPE_FLAGS  i386_pe_section_type_flags
298
299 /* Write the extra assembler code needed to declare a function
300    properly.  If we are generating SDB debugging information, this
301    will happen automatically, so we only need to handle other cases.  */
302 #undef ASM_DECLARE_FUNCTION_NAME
303 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
304   i386_pe_start_function (FILE, NAME, DECL)
305
306 #undef ASM_DECLARE_FUNCTION_SIZE
307 #define ASM_DECLARE_FUNCTION_SIZE(FILE,NAME,DECL) \
308   i386_pe_end_function (FILE, NAME, DECL)
309
310 /* Add an external function to the list of functions to be declared at
311    the end of the file.  */
312 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)                           \
313   do                                                                    \
314     {                                                                   \
315       if (TREE_CODE (DECL) == FUNCTION_DECL)                            \
316         i386_pe_record_external_function ((DECL), (NAME));              \
317     }                                                                   \
318   while (0)
319
320 /* Declare the type properly for any external libcall.  */
321 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
322   i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
323
324 /* This says out to put a global symbol in the BSS section.  */
325 #undef ASM_OUTPUT_ALIGNED_BSS
326 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
327   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
328
329 /* Put all *tf routines in libgcc.  */
330 #undef LIBGCC2_HAS_TF_MODE
331 #define LIBGCC2_HAS_TF_MODE 1
332 #define LIBGCC2_TF_CEXT q
333 #define TF_SIZE 113
334
335 /* Output function declarations at the end of the file.  */
336 #undef TARGET_ASM_FILE_END
337 #define TARGET_ASM_FILE_END i386_pe_file_end
338
339 #undef ASM_COMMENT_START
340 #define ASM_COMMENT_START " #"
341
342 #ifndef DWARF2_UNWIND_INFO
343 /* If configured with --disable-sjlj-exceptions, use DWARF2, else
344    default to SJLJ.  */
345 #if  (defined (CONFIG_SJLJ_EXCEPTIONS) && !CONFIG_SJLJ_EXCEPTIONS)
346 /* The logic of this #if must be kept synchronised with the logic
347    for selecting the tmake_eh_file fragment in config.gcc.  */
348 #define DWARF2_UNWIND_INFO 1
349 /* If multilib is selected break build as sjlj is required.  */
350 #if defined (TARGET_BI_ARCH)
351 #error For 64-bit windows and 32-bit based multilib version of gcc just SJLJ exceptions are supported.
352 #endif
353 #else
354 #define DWARF2_UNWIND_INFO 0
355 #endif
356 #endif
357
358 /* Don't assume anything about the header files.  */
359 #define NO_IMPLICIT_EXTERN_C
360
361 #undef PROFILE_HOOK
362 #define PROFILE_HOOK(LABEL)                                             \
363   if (MAIN_NAME_P (DECL_NAME (current_function_decl)))                  \
364     {                                                                   \
365       emit_call_insn (gen_rtx_CALL (VOIDmode,                           \
366         gen_rtx_MEM (FUNCTION_MODE,                                     \
367                      gen_rtx_SYMBOL_REF (Pmode, "_monstartup")),        \
368         const0_rtx));                                                   \
369     }
370
371 /* Java Native Interface (JNI) methods on Win32 are invoked using the
372    stdcall calling convention.  */
373 #undef MODIFY_JNI_METHOD_CALL
374 #define MODIFY_JNI_METHOD_CALL(MDECL)                                         \
375   build_type_attribute_variant ((MDECL),                                      \
376                                build_tree_list (get_identifier ("stdcall"),   \
377                                                 NULL))
378
379 /* For Win32 ABI compatibility */
380 #undef DEFAULT_PCC_STRUCT_RETURN
381 #define DEFAULT_PCC_STRUCT_RETURN 0
382
383 /* MSVC returns aggregate types of up to 8 bytes via registers.
384    See i386.c:ix86_return_in_memory.  */
385 #undef MS_AGGREGATE_RETURN
386 #define MS_AGGREGATE_RETURN 1
387
388 /* Biggest alignment supported by the object file format of this
389    machine.  Use this macro to limit the alignment which can be
390    specified using the `__attribute__ ((aligned (N)))' construct.  If
391    not defined, the default value is `BIGGEST_ALIGNMENT'.  */
392 /* IMAGE_SCN_ALIGN_8192BYTES is the largest section alignment flag
393    specified in the PECOFF60 spec.  Native MS compiler also limits
394    user-specified alignment to 8192 bytes.  */
395 #undef MAX_OFILE_ALIGNMENT
396 #define MAX_OFILE_ALIGNMENT (8192 * 8)
397
398 /* BIGGEST_FIELD_ALIGNMENT macro is used directly by libobjc, There, we
399    align internal doubles in structures on dword boundaries. Otherwise,
400    support vector modes using ADJUST_FIELD_ALIGN, defined in i386.h.  */
401 #ifdef IN_TARGET_LIBS
402 #undef  BIGGEST_FIELD_ALIGNMENT
403 #define BIGGEST_FIELD_ALIGNMENT 64
404 #endif
405
406 /* A bit-field declared as `int' forces `int' alignment for the struct.  */
407 #undef PCC_BITFIELD_TYPE_MATTERS
408 #define PCC_BITFIELD_TYPE_MATTERS 1
409 #define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
410
411 /* Enable alias attribute support.  */
412 #ifndef SET_ASM_OP
413 #define SET_ASM_OP "\t.set\t"
414 #endif
415
416 /* This implements the `alias' attribute, keeping any stdcall or
417    fastcall decoration.  */
418 #undef  ASM_OUTPUT_DEF_FROM_DECLS
419 #define ASM_OUTPUT_DEF_FROM_DECLS(STREAM, DECL, TARGET)                 \
420   do                                                                    \
421     {                                                                   \
422       const char *alias                                                 \
423         = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));              \
424       i386_pe_maybe_record_exported_symbol (DECL, alias, 0);            \
425       if (TREE_CODE (DECL) == FUNCTION_DECL)                            \
426         i386_pe_declare_function_type (STREAM, alias,                   \
427                                        TREE_PUBLIC (DECL));             \
428       ASM_OUTPUT_DEF (STREAM, alias, IDENTIFIER_POINTER (TARGET));      \
429     } while (0)
430
431 /* GNU as supports weak symbols on PECOFF. */
432 #ifdef HAVE_GAS_WEAK
433 #define ASM_WEAKEN_LABEL(FILE, NAME)  \
434   do                                  \
435     {                                 \
436       fputs ("\t.weak\t", (FILE));    \
437       assemble_name ((FILE), (NAME)); \
438       fputc ('\n', (FILE));           \
439     }                                 \
440   while (0)
441 #endif /* HAVE_GAS_WEAK */
442
443 /* FIXME: SUPPORTS_WEAK && TARGET_HAVE_NAMED_SECTIONS is true,
444    but for .jcr section to work we also need crtbegin and crtend
445    objects.  */
446 #define TARGET_USE_JCR_SECTION 1
447
448 /* Decide whether it is safe to use a local alias for a virtual function
449    when constructing thunks.  */
450 #undef TARGET_USE_LOCAL_THUNK_ALIAS_P
451 #define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) (!DECL_ONE_ONLY (DECL))
452
453 #define SUBTARGET_ATTRIBUTE_TABLE \
454   { "selectany", 0, 0, true, false, false, ix86_handle_selectany_attribute, \
455     false }
456   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
457        affects_type_identity } */
458
459 /*  mcount() does not need a counter variable.  */
460 #undef NO_PROFILE_COUNTERS
461 #define NO_PROFILE_COUNTERS 1
462
463 #define TARGET_VALID_DLLIMPORT_ATTRIBUTE_P i386_pe_valid_dllimport_attribute_p
464 #define TARGET_CXX_ADJUST_CLASS_AT_DEFINITION i386_pe_adjust_class_at_definition
465 #define TARGET_MANGLE_DECL_ASSEMBLER_NAME i386_pe_mangle_decl_assembler_name
466
467 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
468 #define TARGET_ASM_ASSEMBLE_VISIBILITY i386_pe_assemble_visibility
469
470 /* Static stack checking is supported by means of probes.  */
471 #define STACK_CHECK_STATIC_BUILTIN 1