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