From patchwork Sun Jul 5 07:56:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 491282 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 8A3EE1409A0 for ; Sun, 5 Jul 2015 17:57:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=yySyDI3E; 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=uIkF0sGd4fyMg7za pG+L9V4M5m3QDIGGLd57X2FKuu4MPe4S1bjvdy6GCD1t8TbAVCsVppyyewm9t24C MKM26NkHKX3Rf5thrOKoPLGVDxbasFn6jBfzhVdTWCLoaQ0UvdZKgv2YQatejQsL K8JOGjN6dLokv0Cd/msv8dGwUC0= 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=fJ9h2HqpsU97G3ymYVHGPQ 5oaOc=; b=yySyDI3EZmX3nxkO9mAv3q1laXHcax7ZkD66QOgdziWZ6sKkf2API+ LrR8X6UCMkVXnMvv5Mz9f2x53mewuI4q646dYqdUkw323JyvK9s7Zt+xWbLE3inY qJ48VG/Xubkpg04DrUwkkSr5iK0favQLgEvyqOE65xZAc5NK4/kC8= Received: (qmail 121716 invoked by alias); 5 Jul 2015 07:56:59 -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 121706 invoked by uid 89); 5 Jul 2015 07:56:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL, BAYES_50, 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) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 05 Jul 2015 07:56:57 +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-21-Op-dLT_7S_KjMLRhQepN0w-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:56:48 +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 stack_protect_{set,test} Date: Sun, 05 Jul 2015 08:56:49 +0100 Message-ID: <87wpyfkpfi.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: Op-dLT_7S_KjMLRhQepN0w-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 (stack_protect_set, stack_protect_test): New targetm instruction patterns. * cfgexpand.c (stack_protect_prologue): Use them instead of HAVE_*/gen_* interface. * function.c (stack_protect_epilogue): Likewise. Index: gcc/target-insns.def =================================================================== --- gcc/target-insns.def 2015-07-05 08:55:39.336569730 +0100 +++ gcc/target-insns.def 2015-07-05 08:55:39.332569792 +0100 @@ -55,6 +55,8 @@ DEF_TARGET_INSN (save_stack_function, (r DEF_TARGET_INSN (save_stack_nonlocal, (rtx x0, rtx x1)) DEF_TARGET_INSN (sibcall_epilogue, (void)) DEF_TARGET_INSN (simple_return, (void)) +DEF_TARGET_INSN (stack_protect_set, (rtx x0, rtx x1)) +DEF_TARGET_INSN (stack_protect_test, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (store_multiple, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (tablejump, (rtx x0, rtx x1)) DEF_TARGET_INSN (trap, (void)) Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2015-07-05 08:55:39.336569730 +0100 +++ gcc/cfgexpand.c 2015-07-05 08:55:39.328569856 +0100 @@ -5767,11 +5767,6 @@ expand_main_function (void) /* Expand code to initialize the stack_protect_guard. This is invoked at the beginning of a function to be protected. */ -#ifndef HAVE_stack_protect_set -# define HAVE_stack_protect_set 0 -# define gen_stack_protect_set(x,y) (gcc_unreachable (), NULL_RTX) -#endif - static void stack_protect_prologue (void) { @@ -5783,15 +5778,12 @@ stack_protect_prologue (void) /* Allow the target to copy from Y to X without leaking Y into a register. */ - if (HAVE_stack_protect_set) - { - rtx insn = gen_stack_protect_set (x, y); - if (insn) - { - emit_insn (insn); - return; - } - } + if (targetm.have_stack_protect_set ()) + if (rtx_insn *insn = targetm.gen_stack_protect_set (x, y)) + { + emit_insn (insn); + return; + } /* Otherwise do a straight move. */ emit_move_insn (x, y); Index: gcc/function.c =================================================================== --- gcc/function.c 2015-07-05 08:55:39.336569730 +0100 +++ gcc/function.c 2015-07-05 08:55:39.332569792 +0100 @@ -4874,11 +4874,6 @@ init_function_start (tree subr) /* Expand code to verify the stack_protect_guard. This is invoked at the end of a function to be protected. */ -#ifndef HAVE_stack_protect_test -# define HAVE_stack_protect_test 0 -# define gen_stack_protect_test(x, y, z) (gcc_unreachable (), NULL_RTX) -#endif - void stack_protect_epilogue (void) { @@ -4891,13 +4886,12 @@ stack_protect_epilogue (void) /* Allow the target to compare Y with X without leaking either into a register. */ - switch (HAVE_stack_protect_test != 0) + switch (targetm.have_stack_protect_test ()) { case 1: - tmp = gen_stack_protect_test (x, y, label); - if (tmp) + if (rtx_insn *seq = targetm.gen_stack_protect_test (x, y, label)) { - emit_insn (tmp); + emit_insn (seq); break; } /* FALLTHRU */