diff mbox

[1/3] Define target hook TARGET_UNWIND_EMIT_BEFORE_INSN.

Message ID 1281474444-8772-2-git-send-email-rth@redhat.com
State New
Headers show

Commit Message

Richard Henderson Aug. 10, 2010, 9:07 p.m. UTC
From: Richard Henderson <rth@twiddle.net>

---
 gcc/doc/tm.texi    |    4 ++++
 gcc/doc/tm.texi.in |    2 ++
 gcc/final.c        |    7 ++++++-
 gcc/target.def     |    7 +++++++
 4 files changed, 19 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index d59c55f..36bf0ab 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -8718,6 +8718,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
 
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 1b00ebc..2ef95c2 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -8708,6 +8708,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
 
diff --git a/gcc/final.c b/gcc/final.c
index f1cff34..46b4786 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -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;
       }
     }
diff --git a/gcc/target.def b/gcc/target.def
index 10013e6..9fa23e2 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -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,