From patchwork Sun Jul 5 07:48:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 491276 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 76B8D1409A0 for ; Sun, 5 Jul 2015 17:48:41 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=IpZJdujn; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=Jh21QjSisRumaLiY 4B59fXHR1VfgncyJ9SQwStnFQC4u0PjUPJKbIaHD+foKjigPcAq21uE8FbaHNVmT aCx3s4ikPcYamA4g/zDeP+AspMbyMJOHLE3pMg2c9YRBzDA6tbUF+9xL5OdDijON sJ4WRRohFUDYeNvfccpQ6FEVuY8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=Df53y6O91RaUqvifXyb9Sk IJ2p8=; b=IpZJdujnwhF/UFJ1RAYYRD6vaxvUPWOaL++PIWgoHXuxaTZpj0CxoN 0P1+j6KNUCdQ9c2QUr2ASOeWkuOBfEW3xyuc/idOzNmPITrEk9Q4h/mvyP/hnPD9 fHnjL8JjsgoOD7JnFQSwk/dsfzUyiebkhVAGXvUbFvwq+LIteDM54= Received: (qmail 106231 invoked by alias); 5 Jul 2015 07:48:34 -0000 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 Received: (qmail 106217 invoked by uid 89); 5 Jul 2015 07:48:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 05 Jul 2015 07:48:31 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-28-8bA1u7noT-mXZNu7UG37DQ-1 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 5 Jul 2015 08:48:17 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] Use target-insns.def for forms of non-local goto Date: Sun, 05 Jul 2015 08:48:17 +0100 Message-ID: <87mvzbm4e6.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: 8bA1u7noT-mXZNu7UG37DQ-1 Bootstrapped & regression-tested on x86_64-linux-gnu and aarch64-linux-gnu. Also tested via config-list.mk. Committed as preapproved. Thanks, Richard gcc/ * target-insns.def (builtin_longjmp, builtin_setjmp_receiver) (builtin_setjmp_setup, exception_receiver, nonlocal_goto) (nonlocal_goto_receiver): New targetm instruction patterns. * builtins.c (expand_builtin_setjmp_setup): Use them instead of HAVE_*/gen_* interface. (expand_builtin_setjmp_receiver): Likewise. (expand_builtin_longjmp, expand_builtin_nonlocal_goto): Likewise. * except.c (expand_dw2_landing_pad_for_region): Likewise. Index: gcc/target-insns.def =================================================================== --- gcc/target-insns.def 2015-07-05 08:46:04.679111129 +0100 +++ gcc/target-insns.def 2015-07-05 08:46:04.675111157 +0100 @@ -30,14 +30,20 @@ Patterns that take no operands should have a prototype "(void)". Instructions should be documented in md.texi rather than here. */ +DEF_TARGET_INSN (builtin_longjmp, (rtx x0)) +DEF_TARGET_INSN (builtin_setjmp_receiver, (rtx x0)) +DEF_TARGET_INSN (builtin_setjmp_setup, (rtx x0)) DEF_TARGET_INSN (canonicalize_funcptr_for_compare, (rtx x0, rtx x1)) DEF_TARGET_INSN (casesi, (rtx x0, rtx x1, rtx x2, rtx x3, rtx x4)) DEF_TARGET_INSN (epilogue, (void)) +DEF_TARGET_INSN (exception_receiver, (void)) DEF_TARGET_INSN (jump, (rtx x0)) DEF_TARGET_INSN (load_multiple, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (mem_signal_fence, (rtx x0)) DEF_TARGET_INSN (mem_thread_fence, (rtx x0)) DEF_TARGET_INSN (memory_barrier, (void)) +DEF_TARGET_INSN (nonlocal_goto, (rtx x0, rtx x1, rtx x2, rtx x3)) +DEF_TARGET_INSN (nonlocal_goto_receiver, (void)) DEF_TARGET_INSN (prologue, (void)) DEF_TARGET_INSN (return, (void)) DEF_TARGET_INSN (sibcall_epilogue, (void)) Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2015-07-05 08:46:04.679111129 +0100 +++ gcc/builtins.c 2015-07-05 08:46:04.671111199 +0100 @@ -889,10 +889,8 @@ expand_builtin_setjmp_setup (rtx buf_add emit_stack_save (SAVE_NONLOCAL, &stack_save); /* If there is further processing to do, do it. */ -#ifdef HAVE_builtin_setjmp_setup - if (HAVE_builtin_setjmp_setup) - emit_insn (gen_builtin_setjmp_setup (buf_addr)); -#endif + if (targetm.have_builtin_setjmp_setup ()) + emit_insn (targetm.gen_builtin_setjmp_setup (buf_addr)); /* We have a nonlocal label. */ cfun->has_nonlocal_label = 1; @@ -903,7 +901,7 @@ expand_builtin_setjmp_setup (rtx buf_add If RECEIVER_LABEL is NULL, instead contruct a nonlocal goto handler. */ void -expand_builtin_setjmp_receiver (rtx receiver_label ATTRIBUTE_UNUSED) +expand_builtin_setjmp_receiver (rtx receiver_label) { rtx chain; @@ -919,9 +917,7 @@ expand_builtin_setjmp_receiver (rtx rece /* Now put in the code to restore the frame pointer, and argument pointer, if needed. */ -#ifdef HAVE_nonlocal_goto - if (! HAVE_nonlocal_goto) -#endif + if (! targetm.have_nonlocal_goto ()) { /* First adjust our frame pointer to its actual value. It was previously set to the start of the virtual area corresponding to @@ -972,17 +968,12 @@ expand_builtin_setjmp_receiver (rtx rece } #endif -#ifdef HAVE_builtin_setjmp_receiver - if (receiver_label != NULL && HAVE_builtin_setjmp_receiver) - emit_insn (gen_builtin_setjmp_receiver (receiver_label)); + if (receiver_label != NULL && targetm.have_builtin_setjmp_receiver ()) + emit_insn (targetm.gen_builtin_setjmp_receiver (receiver_label)); + else if (targetm.have_nonlocal_goto_receiver ()) + emit_insn (targetm.gen_nonlocal_goto_receiver ()); else -#endif -#ifdef HAVE_nonlocal_goto_receiver - if (HAVE_nonlocal_goto_receiver) - emit_insn (gen_nonlocal_goto_receiver ()); - else -#endif - { /* Nothing */ } + { /* Nothing */ } /* We must not allow the code we just generated to be reordered by scheduling. Specifically, the update of the frame pointer must @@ -1019,11 +1010,9 @@ expand_builtin_longjmp (rtx buf_addr, rt gcc_assert (value == const1_rtx); last = get_last_insn (); -#ifdef HAVE_builtin_longjmp - if (HAVE_builtin_longjmp) - emit_insn (gen_builtin_longjmp (buf_addr)); + if (targetm.have_builtin_longjmp ()) + emit_insn (targetm.gen_builtin_longjmp (buf_addr)); else -#endif { fp = gen_rtx_MEM (Pmode, buf_addr); lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, buf_addr, @@ -1037,14 +1026,12 @@ expand_builtin_longjmp (rtx buf_addr, rt /* Pick up FP, label, and SP from the block and jump. This code is from expand_goto in stmt.c; see there for detailed comments. */ -#ifdef HAVE_nonlocal_goto - if (HAVE_nonlocal_goto) + if (targetm.have_nonlocal_goto ()) /* We have to pass a value to the nonlocal_goto pattern that will get copied into the static_chain pointer, but it does not matter what that value is, because builtin_setjmp does not use it. */ - emit_insn (gen_nonlocal_goto (value, lab, stack, fp)); + emit_insn (targetm.gen_nonlocal_goto (value, lab, stack, fp)); else -#endif { lab = copy_to_reg (lab); @@ -1166,12 +1153,10 @@ expand_builtin_nonlocal_goto (tree exp) crtl->has_nonlocal_goto = 1; -#ifdef HAVE_nonlocal_goto /* ??? We no longer need to pass the static chain value, afaik. */ - if (HAVE_nonlocal_goto) - emit_insn (gen_nonlocal_goto (const0_rtx, r_label, r_sp, r_fp)); + if (targetm.have_nonlocal_goto ()) + emit_insn (targetm.gen_nonlocal_goto (const0_rtx, r_label, r_sp, r_fp)); else -#endif { r_label = copy_to_reg (r_label); Index: gcc/except.c =================================================================== --- gcc/except.c 2015-07-05 08:46:04.679111129 +0100 +++ gcc/except.c 2015-07-05 08:46:04.675111157 +0100 @@ -959,16 +959,11 @@ emit_to_new_bb_before (rtx_insn *seq, rt void expand_dw2_landing_pad_for_region (eh_region region) { -#ifdef HAVE_exception_receiver - if (HAVE_exception_receiver) - emit_insn (gen_exception_receiver ()); + if (targetm.have_exception_receiver ()) + emit_insn (targetm.gen_exception_receiver ()); + else if (targetm.have_nonlocal_goto_receiver ()) + emit_insn (targetm.gen_nonlocal_goto_receiver ()); else -#endif -#ifdef HAVE_nonlocal_goto_receiver - if (HAVE_nonlocal_goto_receiver) - emit_insn (gen_nonlocal_goto_receiver ()); - else -#endif { /* Nothing */ } if (region->exc_ptr_reg)