From patchwork Sun Jul 5 07:52:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 491280 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 2CF3A140D58 for ; Sun, 5 Jul 2015 17:52:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ilyuIKdF; 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=AKIWPBAFLeB5oKBQ vWCQXk6uC2F97w22ngdmRT9z+MV6+ysJVLq53Xza/xKJ1MIlU2lXohun0CGUh1WJ sVtD2vufkvpSOI/ofQb9ixtq6xUBx0GAEglLohpc8Bb7mxGWQQ8Wf7XV6uhIz6WZ m3rMXkTFGCiIJTEzd4YuyHiVurQ= 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=nBj1TzXie18f5+H8d93GyA 3HE+Y=; b=ilyuIKdFRmfW03Rs2Wz0V472a17yuW0xdsSNeGi4wFEd2jYzpA0mcs CMXB1lMDTa6nJnnHg7qQHywo8idu5lMb0ZjTjG8Zu5dx6r84mYv4Lx9NhW1C1j23 dPYZ6bPvMBkfScr2xzuI4fDLB0x6eoqivja2WRGaopyb8W3rtSH5o= Received: (qmail 116995 invoked by alias); 5 Jul 2015 07:52:44 -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 116986 invoked by uid 89); 5 Jul 2015 07:52:44 -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) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 05 Jul 2015 07:52:43 +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-24-8QimfxFVS3ew4NU8CVxbFA-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:52:37 +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 save/restore stack Date: Sun, 05 Jul 2015 08:52:37 +0100 Message-ID: <87615zm46y.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: 8QimfxFVS3ew4NU8CVxbFA-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 (restore_stack_block, restore_stack_function) (restore_stack_nonlocal, save_stack_block, save_stack_function) (save_stack_nonlocal): New targetm instruction patterns. * builtins.c (expand_builtin_apply): Use them instead of HAVE_*/gen_* interface. * explow.c (emit_stack_save, emit_stack_restore): Likewise. Index: gcc/target-insns.def =================================================================== --- gcc/target-insns.def 2015-07-05 08:51:23.963477604 +0100 +++ gcc/target-insns.def 2015-07-05 08:51:23.955477687 +0100 @@ -46,7 +46,13 @@ DEF_TARGET_INSN (nonlocal_goto, (rtx x0, DEF_TARGET_INSN (nonlocal_goto_receiver, (void)) DEF_TARGET_INSN (prefetch, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (prologue, (void)) +DEF_TARGET_INSN (restore_stack_block, (rtx x0, rtx x1)) +DEF_TARGET_INSN (restore_stack_function, (rtx x0, rtx x1)) +DEF_TARGET_INSN (restore_stack_nonlocal, (rtx x0, rtx x1)) DEF_TARGET_INSN (return, (void)) +DEF_TARGET_INSN (save_stack_block, (rtx x0, rtx x1)) +DEF_TARGET_INSN (save_stack_function, (rtx x0, rtx x1)) +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 (store_multiple, (rtx x0, rtx x1, rtx x2)) Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2015-07-05 08:51:23.963477604 +0100 +++ gcc/builtins.c 2015-07-05 08:51:23.955477687 +0100 @@ -1611,11 +1611,9 @@ expand_builtin_apply (rtx function, rtx NO_DEFER_POP; /* Save the stack with nonlocal if available. */ -#ifdef HAVE_save_stack_nonlocal - if (HAVE_save_stack_nonlocal) + if (targetm.have_save_stack_nonlocal ()) emit_stack_save (SAVE_NONLOCAL, &old_stack_level); else -#endif emit_stack_save (SAVE_BLOCK, &old_stack_level); /* Allocate a block of memory onto the stack and copy the memory @@ -1732,11 +1730,9 @@ expand_builtin_apply (rtx function, rtx add_function_usage_to (call_insn, call_fusage); /* Restore the stack. */ -#ifdef HAVE_save_stack_nonlocal - if (HAVE_save_stack_nonlocal) + if (targetm.have_save_stack_nonlocal ()) emit_stack_restore (SAVE_NONLOCAL, old_stack_level); else -#endif emit_stack_restore (SAVE_BLOCK, old_stack_level); fixup_args_size_notes (call_insn, get_last_insn (), 0); Index: gcc/explow.c =================================================================== --- gcc/explow.c 2015-07-05 08:51:23.963477604 +0100 +++ gcc/explow.c 2015-07-05 08:51:23.955477687 +0100 @@ -973,30 +973,24 @@ emit_stack_save (enum save_level save_le { rtx sa = *psave; /* The default is that we use a move insn and save in a Pmode object. */ - rtx (*fcn) (rtx, rtx) = gen_move_insn_uncast; + rtx_insn *(*fcn) (rtx, rtx) = gen_move_insn; machine_mode mode = STACK_SAVEAREA_MODE (save_level); /* See if this machine has anything special to do for this kind of save. */ switch (save_level) { -#ifdef HAVE_save_stack_block case SAVE_BLOCK: - if (HAVE_save_stack_block) - fcn = gen_save_stack_block; + if (targetm.have_save_stack_block ()) + fcn = targetm.gen_save_stack_block; break; -#endif -#ifdef HAVE_save_stack_function case SAVE_FUNCTION: - if (HAVE_save_stack_function) - fcn = gen_save_stack_function; + if (targetm.have_save_stack_function ()) + fcn = targetm.gen_save_stack_function; break; -#endif -#ifdef HAVE_save_stack_nonlocal case SAVE_NONLOCAL: - if (HAVE_save_stack_nonlocal) - fcn = gen_save_stack_nonlocal; + if (targetm.have_save_stack_nonlocal ()) + fcn = targetm.gen_save_stack_nonlocal; break; -#endif default: break; } @@ -1028,7 +1022,7 @@ emit_stack_save (enum save_level save_le emit_stack_restore (enum save_level save_level, rtx sa) { /* The default is that we use a move insn. */ - rtx (*fcn) (rtx, rtx) = gen_move_insn_uncast; + rtx_insn *(*fcn) (rtx, rtx) = gen_move_insn; /* If stack_realign_drap, the x86 backend emits a prologue that aligns both STACK_POINTER and HARD_FRAME_POINTER. @@ -1047,24 +1041,18 @@ emit_stack_restore (enum save_level save /* See if this machine has anything special to do for this kind of save. */ switch (save_level) { -#ifdef HAVE_restore_stack_block case SAVE_BLOCK: - if (HAVE_restore_stack_block) - fcn = gen_restore_stack_block; + if (targetm.have_restore_stack_block ()) + fcn = targetm.gen_restore_stack_block; break; -#endif -#ifdef HAVE_restore_stack_function case SAVE_FUNCTION: - if (HAVE_restore_stack_function) - fcn = gen_restore_stack_function; + if (targetm.have_restore_stack_function ()) + fcn = targetm.gen_restore_stack_function; break; -#endif -#ifdef HAVE_restore_stack_nonlocal case SAVE_NONLOCAL: - if (HAVE_restore_stack_nonlocal) - fcn = gen_restore_stack_nonlocal; + if (targetm.have_restore_stack_nonlocal ()) + fcn = targetm.gen_restore_stack_nonlocal; break; -#endif default: break; }