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