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