From patchwork Wed Sep 11 19:16:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1161263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-508917-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Ybr9qL7O"; dkim-atps=neutral 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 46TBV067CVz9s7T for ; Thu, 12 Sep 2019 05:16:56 +1000 (AEST) 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:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=mUnjabxuaVCm8YcoEJVrt+0AiJPYy F1ycRocFKnW5ZSfyzXAEkN1j4CdV+to7Ib+1wkF7ZmhlEiJCP28wudht/7MqF5Jq r3vklngeClPIX+ZZCz3bHYGFA64R15ZeyMyVEqEp5WxEJVA/f1KJDoToXkcjGeBi c7lmPVqpmbl2fA= 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:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=sHhaYarqzw+k5G8NZo0F3lTfsBU=; b=Ybr 9qL7OjadfMQawykn7Hc5/6OGS4MvLlvjHcJqziq9PH1FeytLxvaCGXruoH0OnV1c oDzrJNp8nPUjYGlKnJ5pYt6HzkirVEOt1KEsMFs7WSuYEvb0jsRE3H6QSGL/v8+K n8UCLD526LqFUDjHketU1zKR6Igw/CSmTstyVEdM= Received: (qmail 51677 invoked by alias); 11 Sep 2019 19:16:49 -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 51391 invoked by uid 89); 11 Sep 2019 19:16:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:inv_reg, find_reg X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Sep 2019 19:16:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 828291000 for ; Wed, 11 Sep 2019 12:16:46 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.99.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2A9443F59C for ; Wed, 11 Sep 2019 12:16:46 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [27/32] Remove global call sets: reload.c References: Date: Wed, 11 Sep 2019 20:16:45 +0100 In-Reply-To: (Richard Sandiford's message of "Wed, 11 Sep 2019 20:02:26 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes The inheritance code in find_equiv_reg can use clobbers_reg_p to test whether a call clobbers either of the equivalent registers. reload and find_reg use crtl->abi to test whether a register needs to be saved in the prologue before use. reload_as_needed can use full_and_partial_reg_clobbers and thus avoid needing to keep its own record of which registers are part call-clobbered. 2019-09-11 Richard Sandiford gcc/ * reload.c: Include function-abi.h. (find_equiv_reg): Use clobbers_reg_p to test whether either of the equivalent registers is clobbered by a call. * reload1.c: Include function-abi.h. (reg_reloaded_call_part_clobbered): Delete. (reload): Use crtl->abi to test which registers would need saving in the prologue before use. (find_reg): Likewise. (emit_reload_insns): Remove code for reg_reloaded_call_part_clobbered. (reload_as_needed): Likewise. Use full_and_partial_reg_clobbers instead of call_used_or_fixed_regs | reg_reloaded_call_part_clobbered. Index: gcc/reload.c =================================================================== --- gcc/reload.c 2019-09-11 19:47:32.902202887 +0100 +++ gcc/reload.c 2019-09-11 19:49:00.269587248 +0100 @@ -106,6 +106,7 @@ #define REG_OK_STRICT #include "reload.h" #include "addresses.h" #include "params.h" +#include "function-abi.h" /* True if X is a constant that can be forced into the constant pool. MODE is the mode of the operand, or VOIDmode if not known. */ @@ -6904,24 +6905,19 @@ find_equiv_reg (rtx goal, rtx_insn *insn if either of the two is in a call-clobbered register, or memory. */ if (CALL_P (p)) { - int i; - if (goal_mem || need_stable_sp) return 0; - if (regno >= 0 && regno < FIRST_PSEUDO_REGISTER) - for (i = 0; i < nregs; ++i) - if (call_used_or_fixed_reg_p (regno + i) - || targetm.hard_regno_call_part_clobbered (0, regno + i, - mode)) - return 0; + function_abi abi = call_insn_abi (p); + if (regno >= 0 + && regno < FIRST_PSEUDO_REGISTER + && abi.clobbers_reg_p (mode, regno)) + return 0; - if (valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER) - for (i = 0; i < valuenregs; ++i) - if (call_used_or_fixed_reg_p (valueno + i) - || targetm.hard_regno_call_part_clobbered (0, valueno + i, - mode)) - return 0; + if (valueno >= 0 + && valueno < FIRST_PSEUDO_REGISTER + && abi.clobbers_reg_p (mode, valueno)) + return 0; } if (INSN_P (p)) Index: gcc/reload1.c =================================================================== --- gcc/reload1.c 2019-09-11 19:47:32.902202887 +0100 +++ gcc/reload1.c 2019-09-11 19:49:00.273587220 +0100 @@ -42,6 +42,7 @@ Software Foundation; either version 3, o #include "except.h" #include "dumpfile.h" #include "rtl-iter.h" +#include "function-abi.h" /* This file contains the reload pass of the compiler, which is run after register allocation has been done. It checks that @@ -120,11 +121,6 @@ #define spill_indirect_levels \ This is only valid if reg_reloaded_contents is set and valid. */ static HARD_REG_SET reg_reloaded_dead; -/* Indicate whether the register's current value is one that is not - safe to retain across a call, even for registers that are normally - call-saved. This is only meaningful for members of reg_reloaded_valid. */ -static HARD_REG_SET reg_reloaded_call_part_clobbered; - /* Number of spill-regs so far; number of valid elements of spill_regs. */ static int n_spills; @@ -795,7 +791,7 @@ reload (rtx_insn *first, int global) if (crtl->saves_all_registers) for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (! call_used_or_fixed_reg_p (i) + if (! crtl->abi->clobbers_full_reg_p (i) && ! fixed_regs[i] && ! LOCAL_REGNO (i)) df_set_regs_ever_live (i, true); @@ -1908,8 +1904,8 @@ find_reg (class insn_chain *chain, int o && (inv_reg_alloc_order[regno] < inv_reg_alloc_order[best_reg]) #else - && call_used_or_fixed_reg_p (regno) - && ! call_used_or_fixed_reg_p (best_reg) + && crtl->abi->clobbers_full_reg_p (regno) + && !crtl->abi->clobbers_full_reg_p (best_reg) #endif )) { @@ -4464,7 +4460,6 @@ reload_as_needed (int live_known) reg_last_reload_reg = XCNEWVEC (rtx, max_regno); INIT_REG_SET (®_has_output_reload); CLEAR_HARD_REG_SET (reg_reloaded_valid); - CLEAR_HARD_REG_SET (reg_reloaded_call_part_clobbered); set_initial_elim_offsets (); @@ -4786,8 +4781,8 @@ reload_as_needed (int live_known) be partially clobbered by the call. */ else if (CALL_P (insn)) { - reg_reloaded_valid &= ~(call_used_or_fixed_regs - | reg_reloaded_call_part_clobbered); + reg_reloaded_valid + &= ~call_insn_abi (insn).full_and_partial_reg_clobbers (); /* If this is a call to a setjmp-type function, we must not reuse any reload reg contents across the call; that will @@ -8193,13 +8188,6 @@ emit_reload_insns (class insn_chain *cha : out_regno + k); reg_reloaded_insn[regno + k] = insn; SET_HARD_REG_BIT (reg_reloaded_valid, regno + k); - if (targetm.hard_regno_call_part_clobbered (0, regno + k, - mode)) - SET_HARD_REG_BIT (reg_reloaded_call_part_clobbered, - regno + k); - else - CLEAR_HARD_REG_BIT (reg_reloaded_call_part_clobbered, - regno + k); } } } @@ -8273,13 +8261,6 @@ emit_reload_insns (class insn_chain *cha : in_regno + k); reg_reloaded_insn[regno + k] = insn; SET_HARD_REG_BIT (reg_reloaded_valid, regno + k); - if (targetm.hard_regno_call_part_clobbered (0, regno + k, - mode)) - SET_HARD_REG_BIT (reg_reloaded_call_part_clobbered, - regno + k); - else - CLEAR_HARD_REG_BIT (reg_reloaded_call_part_clobbered, - regno + k); } } } @@ -8388,13 +8369,6 @@ emit_reload_insns (class insn_chain *cha reg_reloaded_insn[src_regno + k] = store_insn; CLEAR_HARD_REG_BIT (reg_reloaded_dead, src_regno + k); SET_HARD_REG_BIT (reg_reloaded_valid, src_regno + k); - if (targetm.hard_regno_call_part_clobbered - (0, src_regno + k, mode)) - SET_HARD_REG_BIT (reg_reloaded_call_part_clobbered, - src_regno + k); - else - CLEAR_HARD_REG_BIT (reg_reloaded_call_part_clobbered, - src_regno + k); SET_HARD_REG_BIT (reg_is_output_reload, src_regno + k); if (note) SET_HARD_REG_BIT (reg_reloaded_died, src_regno);