Adds fountline-msabi-xlogues to common.opt and various fields to structs machine_function and ix86_frame --- gcc/common.opt | 7 +++++++ gcc/config/i386/i386.c | 35 ++++++++++++++++++++++++++++++----- gcc/config/i386/i386.h | 18 ++++++++++++++++++ 3 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/gcc/common.opt b/gcc/common.opt index 5e8d72d..e9570b0 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -3075,4 +3075,11 @@ fipa-ra Common Report Var(flag_ipa_ra) Optimization Use caller save register across calls if possible. +foutline-msabi-xlogues +Common Report Var(flag_outline_msabi_xlogues) Optimization +Outline pro/epilogues to save/restore registers clobbered by calling +sysv_abi functions from within a 64-bit ms_abi function. This reduces +.text size at the expense of a few more instructions being executed +per function. + ; This comment is to ensure we retain the blank line above. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 5ed8fb6..4cc3c8f 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2449,13 +2449,37 @@ struct GTY(()) stack_local_entry { saved frame pointer if frame_pointer_needed <- HARD_FRAME_POINTER - [saved regs] - <- regs_save_offset - [padding0] + [Normal case: - [saved SSE regs] + [saved regs] + <- regs_save_offset + [padding0] + + [saved SSE regs] + + ][ms x64 --> sysv with -foutline-msabi-xlogues: + [padding0] + <- Start of out-of-line, stub-saved/restored regs + (see libgcc/config/i386/msabi.S) + [XMM6-15] + [RSI] + [RDI] + [?RBX] only if RBX is clobbered + [?RBP] only if RBP and RBX are clobbered + [?R12] only if R12 and all previous regs are clobbered + [?R13] only if R13 and all previous regs are clobbered + [?R14] only if R14 and all previous regs are clobbered + [?R15] only if R15 and all previous regs are clobbered + <- end of stub-saved/restored regs + [padding1] + <- outlined_save_offset + [saved regs] Any remaning regs are saved in-line + <- regs_save_offset + [saved SSE regs] not yet verified, but I *think* that there should be no + other SSE regs to save here. + ] <- sse_regs_save_offset - [padding1] | + [padding2] | <- FRAME_POINTER [va_arg registers] | | @@ -2477,6 +2501,7 @@ struct ix86_frame HOST_WIDE_INT hard_frame_pointer_offset; HOST_WIDE_INT stack_pointer_offset; HOST_WIDE_INT hfp_save_offset; + HOST_WIDE_INT outlined_save_offset; HOST_WIDE_INT reg_save_offset; HOST_WIDE_INT sse_reg_save_offset; diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index a45b66a..e6b79df 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2575,6 +2575,24 @@ struct GTY(()) machine_function { pass arguments and can be used for indirect sibcall. */ BOOL_BITFIELD arg_reg_available : 1; + /* If true, we're out-of-lining reg save/restore for regs clobbered + by ms_abi functions calling a sysv function. */ + BOOL_BITFIELD outline_ms_sysv : 1; + + /* If true, the incoming 16-byte aligned stack has an offset (of 8) and + needs padding. */ + BOOL_BITFIELD outline_ms_sysv_pad_in : 1; + + /* If true, the size of the stub save area plus inline int reg saves will + result in an 8 byte offset, so needs padding. */ + BOOL_BITFIELD outline_ms_sysv_pad_out : 1; + + /* This is the number of extra registers saved by stub (valid range is + 0-6). Each additional register is only saved/restored by the stubs + if all successive ones are. (Will always be zero when using a hard + frame pointer.) */ + unsigned int outline_ms_sysv_extra_regs:3; + /* During prologue/epilogue generation, the current frame state. Otherwise, the frame state at the end of the prologue. */ struct machine_frame_state fs; -- 2.9.0