* config/i386/i386.opt: Add option -moutline-msabi-xlogues. * config/i386/i386.h (x86_64_ms_sysv_extra_clobbered_registers): Change type to unsigned. (NUM_X86_64_MS_CLOBBERED_REGS): New macro. (struct machine_function): Add new members outline_ms_sysv, outline_ms_sysv_pad_in, outline_ms_sysv_pad_out and outline_ms_sysv_extra_regs. * config/i386/i386.c (enum xlogue_stub): New enum. (enum xlogue_stub_sets): New enum. (class xlogue_layout): New class. (struct ix86_frame): Add outlined_save_offset member, modify comments to detail stack layout when using out-of-line stubs. (ix86_target_string): Add -moutline-msabi-xlogues option. (stub_managed_regs): New static variable. (ix86_save_reg): Add new parameter ignore_outlined to optionally omit registers managed by out-of-line stub. (ix86_nsaved_regs): Modify to accommodate changes to ix86_save_reg. (ix86_nsaved_sseregs): Likewise. (ix86_emit_save_regs): Likewise. (ix86_emit_save_regs_using_mov): Likewise. (ix86_emit_save_sse_regs_using_mov): Likewise. (get_scratch_register_on_entry): Likewise. (ix86_compute_frame_layout): Modify to disable m->outline_ms_sysv when appropriate and compute frame layout for out-of-line stubs. (gen_frame_set): New function. (gen_frame_load): Likewise. (gen_frame_store): Likewise. (emit_msabi_outlined_save): Likewise. (ix86_expand_prologue): Modify to call emit_msabi_outlined_save when appropriate. (ix86_emit_leave): Add parameter rtx_insn *insn, allowing it to be used to only generate the notes. (emit_msabi_outlined_restore): New function. (ix86_expand_epilogue): Modify to call emit_msabi_outlined_restore when appropriate. (ix86_expand_call): Modify to enable m->outline_ms_sysv when appropriate. * config/i386/predicates.md (save_multiple): New predicate. (restore_multiple): Likewise. * config/i386/sse.md (save_multiple): New pattern. (save_multiple_realign): Likewise. (restore_multiple): Likewise. (restore_multiple_and_return): Likewise. (restore_multiple_leave_return): Likewise.