OSDN Git Service

PR target/34970
[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
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_64BIT_MS_ABI
37 #define TARGET_64BIT_MS_ABI TARGET_64BIT
38
39 #undef DBX_REGISTER_NUMBER
40 #define DBX_REGISTER_NUMBER(n)                          \
41   (TARGET_64BIT ? dbx64_register_map[n]                 \
42    : (write_symbols == DWARF2_DEBUG                     \
43       ? svr4_dbx_register_map[n] : dbx_register_map[n]))
44
45 /* Map gcc register number to DWARF 2 CFA column number. For 32 bit
46    target, always use the svr4_dbx_register_map for DWARF .eh_frame
47    even if we don't use DWARF .debug_frame. */
48 #undef DWARF_FRAME_REGNUM
49 #define DWARF_FRAME_REGNUM(n) TARGET_64BIT \
50         ? dbx64_register_map[(n)] : svr4_dbx_register_map[(n)] 
51
52 #ifdef HAVE_GAS_PE_SECREL32_RELOC
53 /* Use section relative relocations for debugging offsets.  Unlike
54    other targets that fake this by putting the section VMA at 0, PE
55    won't allow it.  */
56 #define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, SECTION)     \
57   do {                                                          \
58     if (SIZE != 4)                                              \
59       abort ();                                                 \
60                                                                 \
61     fputs ("\t.secrel32\t", FILE);                              \
62     assemble_name (FILE, LABEL);                                \
63   } while (0)
64 #endif
65
66 #define TARGET_EXECUTABLE_SUFFIX ".exe"
67
68 #include <stdio.h>
69
70 #define MAYBE_UWIN_CPP_BUILTINS() /* Nothing.  */
71
72 #define TARGET_OS_CPP_BUILTINS()                                        \
73   do                                                                    \
74     {                                                                   \
75         builtin_define ("_X86_=1");                                     \
76         builtin_assert ("system=winnt");                                \
77         builtin_define ("__stdcall=__attribute__((__stdcall__))");      \
78         builtin_define ("__fastcall=__attribute__((__fastcall__))");    \
79         builtin_define ("__cdecl=__attribute__((__cdecl__))");          \
80         if (!flag_iso)                                                  \
81           {                                                             \
82             builtin_define ("_stdcall=__attribute__((__stdcall__))");   \
83             builtin_define ("_fastcall=__attribute__((__fastcall__))"); \
84             builtin_define ("_cdecl=__attribute__((__cdecl__))");       \
85           }                                                             \
86         /* Even though linkonce works with static libs, this is needed  \
87             to compare typeinfo symbols across dll boundaries.  */      \
88         builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0");               \
89         builtin_define ("__GXX_TYPEINFO_EQUALITY_INLINE=0");            \
90         MAYBE_UWIN_CPP_BUILTINS ();                                     \
91         EXTRA_OS_CPP_BUILTINS ();                                       \
92   }                                                                     \
93   while (0)
94
95 /* Get tree.c to declare a target-specific specialization of
96    merge_decl_attributes.  */
97 #define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
98
99 /* This macro defines names of additional specifications to put in the specs
100    that can be used in various specifications like CC1_SPEC.  Its definition
101    is an initializer with a subgrouping for each command option.
102
103    Each subgrouping contains a string constant, that defines the
104    specification name, and a string constant that used by the GCC driver
105    program.
106
107    Do not define this macro if it does not need to do anything.  */
108
109 #undef  SUBTARGET_EXTRA_SPECS
110 #define SUBTARGET_EXTRA_SPECS                                           \
111   { "mingw_include_path", DEFAULT_TARGET_MACHINE }
112
113 #undef MATH_LIBRARY
114 #define MATH_LIBRARY ""
115
116 #define SIZE_TYPE (TARGET_64BIT ? "long long unsigned int" : "unsigned int")
117 #define PTRDIFF_TYPE (TARGET_64BIT ? "long long int" : "int")
118
119 #define WCHAR_TYPE_SIZE 16
120 #define WCHAR_TYPE "short unsigned int"
121
122 /* Windows64 continues to use a 32-bit long type.  */
123 #undef LONG_TYPE_SIZE
124 #define LONG_TYPE_SIZE 32
125 \f
126 #undef REG_PARM_STACK_SPACE
127 #define REG_PARM_STACK_SPACE(FNDECL) (TARGET_64BIT_MS_ABI ? 32 : 0)
128
129 #undef OUTGOING_REG_PARM_STACK_SPACE
130 #define OUTGOING_REG_PARM_STACK_SPACE (TARGET_64BIT_MS_ABI ? 1 : 0)
131
132 #undef REGPARM_MAX
133 #define REGPARM_MAX (TARGET_64BIT_MS_ABI ? 4 : 3)
134
135 #undef SSE_REGPARM_MAX
136 #define SSE_REGPARM_MAX (TARGET_64BIT_MS_ABI ? 4 : TARGET_SSE ? 3 : 0)
137 \f
138 /* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop).  */
139 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
140 /* Enable push_macro & pop_macro */
141 #define HANDLE_PRAGMA_PUSH_POP_MACRO 1
142
143 union tree_node;
144 #define TREE union tree_node *
145 \f
146 #define drectve_section() \
147   (fprintf (asm_out_file, "\t.section .drectve\n"), \
148    in_section = NULL)
149
150 /* Older versions of gas don't handle 'r' as data.
151    Explicitly set data flag with 'd'.  */  
152 #define READONLY_DATA_SECTION_ASM_OP "\t.section .rdata,\"dr\""
153
154 /* Don't allow flag_pic to propagate since gas may produce invalid code
155    otherwise.  */
156
157 #undef  SUBTARGET_OVERRIDE_OPTIONS
158 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
159 do {                                                                    \
160   if (flag_pic)                                                         \
161     {                                                                   \
162       warning (0, "-f%s ignored for target (all code is position independent)",\
163                (flag_pic > 1) ? "PIC" : "pic");                         \
164       flag_pic = 0;                                                     \
165     }                                                                   \
166 } while (0)                                                             \
167
168 /* Define this macro if references to a symbol must be treated
169    differently depending on something about the variable or
170    function named by the symbol (such as what section it is in).
171
172    On i386 running Windows NT, modify the assembler name with a suffix
173    consisting of an atsign (@) followed by string of digits that represents
174    the number of bytes of arguments passed to the function, if it has the
175    attribute STDCALL.
176
177    In addition, we must mark dll symbols specially. Definitions of
178    dllexport'd objects install some info in the .drectve section.
179    References to dllimport'd objects are fetched indirectly via
180    _imp__.  If both are declared, dllexport overrides.  This is also
181    needed to implement one-only vtables: they go into their own
182    section and we need to set DECL_SECTION_NAME so we do that here.
183    Note that we can be called twice on the same decl.  */
184
185 #define SUBTARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
186
187 /* Output a common block.  */
188 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
189 #define ASM_OUTPUT_ALIGNED_DECL_COMMON \
190   i386_pe_asm_output_aligned_decl_common
191
192 /* Output the label for an initialized variable.  */
193 #undef ASM_DECLARE_OBJECT_NAME
194 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)     \
195 do {                                                    \
196   i386_pe_maybe_record_exported_symbol (DECL, NAME, 1); \
197   ASM_OUTPUT_LABEL ((STREAM), (NAME));                  \
198 } while (0)
199
200 /* Output a reference to a label. Fastcall function symbols
201    keep their '@' prefix, while other symbols are prefixed
202    with USER_LABEL_PREFIX.  */
203 #undef ASM_OUTPUT_LABELREF
204 #define  ASM_OUTPUT_LABELREF(STREAM, NAME)      \
205 do {                                            \
206   if ((NAME)[0] != FASTCALL_PREFIX)             \
207     fputs (USER_LABEL_PREFIX, (STREAM));        \
208   fputs ((NAME), (STREAM));                     \
209 } while (0)
210
211 \f
212 /* Emit code to check the stack when allocating more than 4000
213    bytes in one go.  */
214 #define CHECK_STACK_LIMIT 4000
215
216 #undef STACK_BOUNDARY
217 #define STACK_BOUNDARY  (TARGET_64BIT_MS_ABI ? 128 : BITS_PER_WORD)
218
219 /* By default, target has a 80387, uses IEEE compatible arithmetic,
220    returns float values in the 387 and needs stack probes.
221    We also align doubles to 64-bits for MSVC default compatibility.  */
222
223 #undef TARGET_SUBTARGET_DEFAULT
224 #define TARGET_SUBTARGET_DEFAULT \
225         (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS \
226          | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE)
227
228 /* This is how to output an assembler line
229    that says to advance the location counter
230    to a multiple of 2**LOG bytes.  */
231
232 #undef ASM_OUTPUT_ALIGN
233 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
234     if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
235
236 /* Windows uses explicit import from shared libraries.  */
237 #define MULTIPLE_SYMBOL_SPACES 1
238
239 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
240 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
241
242 #define SUPPORTS_ONE_ONLY 1
243
244 /* Switch into a generic section.  */
245 #define TARGET_ASM_NAMED_SECTION  i386_pe_asm_named_section
246
247 /* Select attributes for named sections.  */
248 #define TARGET_SECTION_TYPE_FLAGS  i386_pe_section_type_flags
249
250 /* Write the extra assembler code needed to declare a function
251    properly.  If we are generating SDB debugging information, this
252    will happen automatically, so we only need to handle other cases.  */
253 #undef ASM_DECLARE_FUNCTION_NAME
254 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
255   do                                                                    \
256     {                                                                   \
257       i386_pe_maybe_record_exported_symbol (DECL, NAME, 0);             \
258       if (write_symbols != SDB_DEBUG)                                   \
259         i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \
260       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
261     }                                                                   \
262   while (0)
263
264 /* Add an external function to the list of functions to be declared at
265    the end of the file.  */
266 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)                           \
267   do                                                                    \
268     {                                                                   \
269       if (TREE_CODE (DECL) == FUNCTION_DECL)                            \
270         i386_pe_record_external_function ((DECL), (NAME));              \
271     }                                                                   \
272   while (0)
273
274 /* Declare the type properly for any external libcall.  */
275 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
276   i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
277
278 /* This says out to put a global symbol in the BSS section.  */
279 #undef ASM_OUTPUT_ALIGNED_BSS
280 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
281   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
282
283 /* Output function declarations at the end of the file.  */
284 #undef TARGET_ASM_FILE_END
285 #define TARGET_ASM_FILE_END i386_pe_file_end
286
287 #undef ASM_COMMENT_START
288 #define ASM_COMMENT_START " #"
289
290 #ifndef DWARF2_UNWIND_INFO
291 /* If configured with --disable-sjlj-exceptions, use DWARF2, else
292    default to SJLJ.  */
293 #if  (defined (CONFIG_SJLJ_EXCEPTIONS) && !CONFIG_SJLJ_EXCEPTIONS)
294 #define DWARF2_UNWIND_INFO 1
295 #else
296 #define DWARF2_UNWIND_INFO 0
297 #endif
298 #endif
299
300 /* Don't assume anything about the header files.  */
301 #define NO_IMPLICIT_EXTERN_C
302
303 #undef PROFILE_HOOK
304 #define PROFILE_HOOK(LABEL)                                             \
305   if (MAIN_NAME_P (DECL_NAME (current_function_decl)))                  \
306     {                                                                   \
307       emit_call_insn (gen_rtx_CALL (VOIDmode,                           \
308         gen_rtx_MEM (FUNCTION_MODE,                                     \
309                      gen_rtx_SYMBOL_REF (Pmode, "_monstartup")),        \
310         const0_rtx));                                                   \
311     }
312
313 /* Java Native Interface (JNI) methods on Win32 are invoked using the
314    stdcall calling convention.  */
315 #undef MODIFY_JNI_METHOD_CALL
316 #define MODIFY_JNI_METHOD_CALL(MDECL)                                         \
317   build_type_attribute_variant ((MDECL),                                      \
318                                build_tree_list (get_identifier ("stdcall"),   \
319                                                 NULL))
320
321 /* For Win32 ABI compatibility */
322 #undef DEFAULT_PCC_STRUCT_RETURN
323 #define DEFAULT_PCC_STRUCT_RETURN 0
324
325 /* MSVC returns aggregate types of up to 8 bytes via registers.
326    See i386.c:ix86_return_in_memory.  */
327 #undef MS_AGGREGATE_RETURN
328 #define MS_AGGREGATE_RETURN 1
329
330 /* No data type wants to be aligned rounder than this.  */
331 #undef  BIGGEST_ALIGNMENT
332 #define BIGGEST_ALIGNMENT 128
333
334 /* Biggest alignment supported by the object file format of this
335    machine.  Use this macro to limit the alignment which can be
336    specified using the `__attribute__ ((aligned (N)))' construct.  If
337    not defined, the default value is `BIGGEST_ALIGNMENT'.  */
338 /* IMAGE_SCN_ALIGN_8192BYTES is the largest section alignment flag
339    specified in the PECOFF60 spec.  Native MS compiler also limits
340    user-specified alignment to 8192 bytes.  */
341 #undef MAX_OFILE_ALIGNMENT
342 #define MAX_OFILE_ALIGNMENT (8192 * 8)
343
344 /* BIGGEST_FIELD_ALIGNMENT macro is used directly by libobjc, There, we
345    align internal doubles in structures on dword boundaries. Otherwise,
346    support vector modes using ADJUST_FIELD_ALIGN, defined in i386.h.  */
347 #ifdef IN_TARGET_LIBS
348 #undef  BIGGEST_FIELD_ALIGNMENT
349 #define BIGGEST_FIELD_ALIGNMENT 64
350 #endif
351
352 /* A bit-field declared as `int' forces `int' alignment for the struct.  */
353 #undef PCC_BITFIELD_TYPE_MATTERS
354 #define PCC_BITFIELD_TYPE_MATTERS 1
355 #define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
356
357 /* Enable alias attribute support.  */
358 #ifndef SET_ASM_OP
359 #define SET_ASM_OP "\t.set\t"
360 #endif
361
362 /* This implements the `alias' attribute, keeping any stdcall or
363    fastcall decoration.  */
364 #undef  ASM_OUTPUT_DEF_FROM_DECLS
365 #define ASM_OUTPUT_DEF_FROM_DECLS(STREAM, DECL, TARGET)                 \
366   do                                                                    \
367     {                                                                   \
368       const char *alias                                                 \
369         = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));              \
370       if (TREE_CODE (DECL) == FUNCTION_DECL)                            \
371         i386_pe_declare_function_type (STREAM, alias,                   \
372                                        TREE_PUBLIC (DECL));             \
373       ASM_OUTPUT_DEF (STREAM, alias, IDENTIFIER_POINTER (TARGET));      \
374     } while (0)
375
376 /* GNU as supports weak symbols on PECOFF. */
377 #ifdef HAVE_GAS_WEAK
378 #define ASM_WEAKEN_LABEL(FILE, NAME)  \
379   do                                  \
380     {                                 \
381       fputs ("\t.weak\t", (FILE));    \
382       assemble_name ((FILE), (NAME)); \
383       fputc ('\n', (FILE));           \
384     }                                 \
385   while (0)
386 #endif /* HAVE_GAS_WEAK */
387
388 /* FIXME: SUPPORTS_WEAK && TARGET_HAVE_NAMED_SECTIONS is true,
389    but for .jcr section to work we also need crtbegin and crtend
390    objects.  */
391 #define TARGET_USE_JCR_SECTION 0
392
393 /* Decide whether it is safe to use a local alias for a virtual function
394    when constructing thunks.  */
395 #undef TARGET_USE_LOCAL_THUNK_ALIAS_P
396 #define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) (!DECL_ONE_ONLY (DECL))
397
398 #define SUBTARGET_ATTRIBUTE_TABLE \
399   { "selectany", 0, 0, true, false, false, ix86_handle_selectany_attribute }
400   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
401
402 /*  mcount() does not need a counter variable.  */
403 #undef NO_PROFILE_COUNTERS
404 #define NO_PROFILE_COUNTERS 1
405
406 #define TARGET_VALID_DLLIMPORT_ATTRIBUTE_P i386_pe_valid_dllimport_attribute_p
407 #define TARGET_CXX_ADJUST_CLASS_AT_DEFINITION i386_pe_adjust_class_at_definition
408 #define TARGET_MANGLE_DECL_ASSEMBLER_NAME i386_pe_mangle_decl_assembler_name
409
410 #undef TREE
411
412 #ifndef BUFSIZ
413 # undef FILE
414 #endif