@@ -40,14 +40,9 @@ along with GCC; see the file COPYING3. If not see
4040#define SYMBOL_REF_STUBVAR_P (X ) \
4141 ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_STUBVAR) != 0)
4242
43- /* Disable SEH and declare the required SEH-related macros that are
44- still needed for compilation. */
45- #undef TARGET_SEH
46- #define TARGET_SEH 0
47-
4843#define SSE_REGNO_P (N ) (gcc_unreachable (), 0)
4944#define GENERAL_REGNO_P (N ) (gcc_unreachable (), 0)
50- #define SEH_MAX_FRAME_SIZE (gcc_unreachable (), 0)
45+ // #define SEH_MAX_FRAME_SIZE (gcc_unreachable (), 0)
5146
5247#undef TARGET_PECOFF
5348#define TARGET_PECOFF 1
@@ -57,6 +52,35 @@ still needed for compilation. */
5752#undef PREFERRED_DEBUGGING_TYPE
5853#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
5954
55+
56+ /* Support hooks for SEH. */
57+ #undef TARGET_ASM_UNWIND_EMIT
58+ #define TARGET_ASM_UNWIND_EMIT i386_pe_seh_unwind_emit
59+ #undef TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
60+ #define TARGET_ASM_UNWIND_EMIT_BEFORE_INSN false
61+ // #undef TARGET_ASM_FUNCTION_PROLOGUE
62+ // #define TARGET_ASM_FUNCTION_PROLOGUE aarch64_pe_seh_function_prologue
63+ #undef TARGET_ASM_FUNCTION_END_PROLOGUE
64+ #define TARGET_ASM_FUNCTION_END_PROLOGUE i386_pe_seh_end_prologue
65+ #undef TARGET_ASM_EMIT_EXCEPT_PERSONALITY
66+ #define TARGET_ASM_EMIT_EXCEPT_PERSONALITY i386_pe_seh_emit_except_personality
67+ #undef TARGET_ASM_INIT_SECTIONS
68+ #define TARGET_ASM_INIT_SECTIONS i386_pe_seh_init_sections
69+ #undef SUBTARGET_ASM_UNWIND_INIT
70+ #define SUBTARGET_ASM_UNWIND_INIT i386_pe_seh_init
71+ // #undef TARGET_ASM_FINAL_POSTSCAN_INSN
72+ // #define TARGET_ASM_FINAL_POSTSCAN_INSN aarch64_pe_seh_asm_final_postscan_insn
73+
74+ #undef TARGET_PECOFF
75+ #define TARGET_PECOFF 1
76+
77+ // #if ! defined (USE_MINGW64_LEADING_UNDERSCORES)
78+ // #undef USER_LABEL_PREFIX
79+ // #define USER_LABEL_PREFIX (TARGET_64BIT ? "" : "_")
80+
81+ // #undef LOCAL_LABEL_PREFIX
82+ // #define LOCAL_LABEL_PREFIX (TARGET_64BIT ? "." : "")
83+
6084#include <stdbool.h>
6185#ifdef __MINGW32__
6286#include <stdio.h>
@@ -70,6 +94,26 @@ still needed for compilation. */
7094#define TARGET_ASM_UNIQUE_SECTION mingw_pe_unique_section
7195#define TARGET_ENCODE_SECTION_INFO mingw_pe_encode_section_info
7296
97+ #undef TARGET_SEH
98+ #define TARGET_SEH 1
99+
100+ /* SEH support */
101+ extern void i386_pe_seh_init (FILE * );
102+ extern void i386_pe_seh_end_prologue (FILE * );
103+ // extern void aarch64_pe_seh_function_prologue (FILE *);
104+ // extern void aarch64_pe_seh_cold_init (FILE *, const char *);
105+ extern void i386_pe_seh_unwind_emit (FILE * , rtx_insn * );
106+ extern void i386_pe_seh_emit_except_personality (rtx );
107+ extern void i386_pe_seh_init_sections (void );
108+ // extern void aarch64_pe_seh_asm_final_postscan_insn (FILE *stream, rtx_insn *insn, rtx*, int);
109+
110+ /* In winnt */
111+ // extern void aarch64_print_reg (rtx, int, FILE*);
112+ extern void i386_pe_end_function (FILE * f , const char * , tree );
113+ extern void i386_pe_end_cold_function (FILE * f , const char * , tree );
114+ // extern void aarch64_pe_end_epilogue (FILE *file);
115+ // extern void aarch64_pe_begin_epilogue (FILE *file);
116+
73117#define TARGET_VALID_DLLIMPORT_ATTRIBUTE_P mingw_pe_valid_dllimport_attribute_p
74118
75119/* Output function declarations at the end of the file. */
@@ -86,6 +130,7 @@ still needed for compilation. */
86130 builtin_define ("__MSVCRT__"); \
87131 builtin_define ("__MINGW32__"); \
88132 builtin_define ("_WIN32"); \
133+ builtin_define ("__SEH__"); \
89134 builtin_define_std ("WIN32"); \
90135 builtin_define_std ("WINNT"); \
91136 builtin_define_with_int_value ("_INTEGRAL_MAX_BITS", \
@@ -217,6 +262,17 @@ still needed for compilation. */
217262 } \
218263 } while (0 )
219264
265+ #undef ASM_DECLARE_FUNCTION_SIZE
266+ #define ASM_DECLARE_FUNCTION_SIZE (FILE ,NAME ,DECL ) \
267+ i386_pe_end_function (FILE, NAME, DECL)
268+
269+ #undef ASM_DECLARE_COLD_FUNCTION_SIZE
270+ #define ASM_DECLARE_COLD_FUNCTION_SIZE (FILE ,NAME ,DECL ) \
271+ i386_pe_end_cold_function (FILE, NAME, DECL)
272+
273+ // #undef TARGET_ASM_FUNCTION_BEGIN_EPILOGUE
274+ // #define TARGET_ASM_FUNCTION_BEGIN_EPILOGUE aarch64_pe_begin_epilogue
275+
220276#define SUBTARGET_ATTRIBUTE_TABLE \
221277 { "selectany", 0, 0, true, false, false, false, \
222278 mingw_handle_selectany_attribute, NULL }
@@ -231,6 +287,10 @@ still needed for compilation. */
231287
232288#define HAVE_GAS_ALIGNED_COMM 1
233289
290+ #undef DWARF2_UNWIND_INFO
291+ #define DWARF2_UNWIND_INFO 0
292+
293+
234294#undef MAX_OFILE_ALIGNMENT
235295#define MAX_OFILE_ALIGNMENT (8192 * 8)
236296
@@ -241,4 +301,16 @@ still needed for compilation. */
241301
242302#define HAVE_64BIT_POINTERS 1
243303
304+ /* According to Windows x64 software convention, the maximum stack allocatable
305+ in the prologue is 4G - 8 bytes. Furthermore, there is a limited set of
306+ instructions allowed to adjust the stack pointer in the epilog, forcing the
307+ use of frame pointer for frames larger than 2 GB. This theorical limit
308+ is reduced by 256, an over-estimated upper bound for the stack use by the
309+ prologue.
310+ We define only one threshold for both the prolog and the epilog. When the
311+ frame size is larger than this threshold, we allocate the area to save SSE
312+ regs, then save them, and then allocate the remaining. There is no SEH
313+ unwind info for this later allocation. */
314+ #define SEH_MAX_FRAME_SIZE ((2U << 30) - 256)
315+
244316#endif
0 commit comments