Comments
Patch
@@ -8749,6 +8749,10 @@ This target hook emits assembly directives required to unwind the
given instruction. This is only used when TARGET_UNWIND_INFO is set.
@end deftypefn
+@deftypevr {Target Hook} bool TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
+True if the @code{TARGET_ASM_UNWIND_EMIT} hook should be called before the assembly for @var{insn} has been emitted, false if the hook should be called afterward.
+@end deftypevr
+
@node Exception Region Output
@subsection Assembler Commands for Exception Regions
@@ -8739,6 +8739,8 @@ This target hook emits assembly directives required to unwind the
given instruction. This is only used when TARGET_UNWIND_INFO is set.
@end deftypefn
+@hook TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
+
@node Exception Region Output
@subsection Assembler Commands for Exception Regions
@@ -2655,7 +2655,8 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
/* ??? This will put the directives in the wrong place if
get_insn_template outputs assembly directly. However calling it
before get_insn_template breaks if the insns is split. */
- if (targetm.asm_out.unwind_emit)
+ if (targetm.asm_out.unwind_emit_before_insn
+ && targetm.asm_out.unwind_emit)
targetm.asm_out.unwind_emit (asm_out_file, insn);
if (CALL_P (insn))
@@ -2713,6 +2714,10 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
dwarf2out_frame_debug (insn, true);
#endif
+ if (!targetm.asm_out.unwind_emit_before_insn
+ && targetm.asm_out.unwind_emit)
+ targetm.asm_out.unwind_emit (asm_out_file, insn);
+
current_output_insn = debug_insn = 0;
}
}
@@ -152,6 +152,13 @@ DEFHOOK
void, (FILE *stream, rtx insn),
NULL)
+DEFHOOKPOD
+(unwind_emit_before_insn,
+ "True if the @code{TARGET_ASM_UNWIND_EMIT} hook should be called before\
+ the assembly for @var{insn} has been emitted, false if the hook should\
+ be called afterward.",
+ bool, true)
+
/* Output an internal label. */
DEFHOOK
(internal_label,
The IA-64 and ARM target specific unwind directives go in front of the instruction to which they apply, but the x64 SEH unwind directives go after the instruction (which makes a lot more sense on an arch with variable-length insns). This hook allows the middle-end to emit the directive in the right place for each. Tested with x86_64-w64-mingw32 (plus other patches), cross to ia64-linux and arm-linux-eabi, and x86_64-linux sanity check. Committed. r~ * target.def (unwind_emit_before_insn): New hook. * doc/tm.texi.in: Add @hook marker for it. * doc/tm.texi: Rebuild. * final.c (final_scan_insn): Respect unwind_emit_before_insn. commit 4c9a2205151fbb9e284e527427674b7c82ea5ae0 Author: Richard Henderson <rth@twiddle.net> Date: Mon Aug 9 10:25:47 2010 -0700 Define target hook TARGET_UNWIND_EMIT_BEFORE_INSN.