From patchwork Tue Sep 7 17:29:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 64037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id EBF8CB6EEB for ; Wed, 8 Sep 2010 03:30:02 +1000 (EST) Received: (qmail 26403 invoked by alias); 7 Sep 2010 17:30:00 -0000 Received: (qmail 26393 invoked by uid 22791); 7 Sep 2010 17:29:59 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Sep 2010 17:29:51 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o87HTnp8024517 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 7 Sep 2010 13:29:49 -0400 Received: from anchor.twiddle.home (ovpn-113-40.phx2.redhat.com [10.3.113.40]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o87HTnbm024650 for ; Tue, 7 Sep 2010 13:29:49 -0400 Message-ID: <4C86768D.3010206@redhat.com> Date: Tue, 07 Sep 2010 10:29:49 -0700 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Thunderbird/3.1.2 MIME-Version: 1.0 To: GCC Patches Subject: [PATCH, SEH] Add hook for location of target-unwind directives X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 Date: Mon Aug 9 10:25:47 2010 -0700 Define target hook TARGET_UNWIND_EMIT_BEFORE_INSN. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 5954ea3..a8db902 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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 diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 24f5c1b..2efc1ae 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -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 diff --git a/gcc/final.c b/gcc/final.c index 73c6069..06ebc17 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 f11328b..e62a977 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,