From patchwork Sat Oct 25 09:48:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 403013 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 8A0F6140097 for ; Sat, 25 Oct 2014 20:48:20 +1100 (AEDT) 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:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=H0OVJbKd13IkDNmxMGqm041VPW/Iz4gqtcadtRsgNUfRT/u/Qi 6JkhfRCr7ehahnEJnIcM8QzHV3mELRoTGeMdk4Llf+eAUnY0iDo4c0x24flBXkbX cDpsXTWqS4jqFpserw4AoYPH1vLN+Gvf/Awb9eDiXXnJfxz0yg4k2GhLQ= 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:cc:subject:date:message-id:mime-version:content-type; s= default; bh=tERLksDpXwX/wIE7/KDiBWzfIXI=; b=wPrnMBEZhTpCRD3yT85G n1kK15xpxDqWsJM2XVG6YDoYnEzllP3T2hKJOokumfOWUeMML/wjJya6UiXfMTwK UzGy+8culmmCD+ap1zeZ4PQLzkZGS/qjpwwRPWz3cx+lUaEvQcIz/wZJ4Hoo9DSM gYztq12nmGz5gbn/k9qexJg= Received: (qmail 735 invoked by alias); 25 Oct 2014 09:48:13 -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 725 invoked by uid 89); 25 Oct 2014 09:48:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f170.google.com Received: from mail-wi0-f170.google.com (HELO mail-wi0-f170.google.com) (209.85.212.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 25 Oct 2014 09:48:12 +0000 Received: by mail-wi0-f170.google.com with SMTP id n3so2790060wiv.5 for ; Sat, 25 Oct 2014 02:48:09 -0700 (PDT) X-Received: by 10.194.133.229 with SMTP id pf5mr10641194wjb.73.1414230489047; Sat, 25 Oct 2014 02:48:09 -0700 (PDT) Received: from localhost ([95.144.14.167]) by mx.google.com with ESMTPSA id l9sm7822983wia.0.2014.10.25.02.48.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Oct 2014 02:48:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, nickc@redhat.com, aoliva@redhat.com, rdsandiford@googlemail.com Cc: nickc@redhat.com, aoliva@redhat.com Subject: [FRV] RFA: Use new rtl iterators in frv_registers_conflict_p_1 Date: Sat, 25 Oct 2014 10:48:08 +0100 Message-ID: <87tx2swkdj.fsf@googlemail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 This is part of a series to remove uses of for_each_rtx from the ports. Tested by making sure there were no code changes for gcc.dg, gcc.c-torture and g++.dg for frv-elf. OK to install? Thanks, Richard gcc/ * config/frv/frv.c (frv_registers_conflict_p_1): Take an rtx rather than an rtx *. Take the regstate_t directly rather than via a void *. Return a bool rather than an int. Iterate over all subrtxes here. (frv_registers_conflict_p): Update accordingly. Index: gcc/config/frv/frv.c =================================================================== --- gcc/config/frv/frv.c 2014-10-25 09:51:23.053862222 +0100 +++ gcc/config/frv/frv.c 2014-10-25 09:51:23.450865761 +0100 @@ -334,7 +334,6 @@ static unsigned int frv_insn_unit (rtx_ static bool frv_issues_to_branch_unit_p (rtx_insn *); static int frv_cond_flags (rtx); static bool frv_regstate_conflict_p (regstate_t, regstate_t); -static int frv_registers_conflict_p_1 (rtx *, void *); static bool frv_registers_conflict_p (rtx); static void frv_registers_update_1 (rtx, const_rtx, void *); static void frv_registers_update (rtx); @@ -7162,53 +7161,49 @@ frv_regstate_conflict_p (regstate_t cond } -/* A for_each_rtx callback. Return 1 if *X depends on an instruction in - the current packet. DATA points to a regstate_t that describes the - condition under which *X might be set or used. */ +/* Return true if an instruction with pattern PAT depends on an + instruction in the current packet. COND describes the condition + under which PAT might be set or used. */ -static int -frv_registers_conflict_p_1 (rtx *x, void *data) +static bool +frv_registers_conflict_p_1 (rtx pat, regstate_t cond) { - unsigned int regno, i; - regstate_t cond; - - cond = *(regstate_t *) data; - - if (GET_CODE (*x) == REG) - FOR_EACH_REGNO (regno, *x) - if ((frv_packet.regstate[regno] & REGSTATE_MODIFIED) != 0) - if (frv_regstate_conflict_p (frv_packet.regstate[regno], cond)) - return 1; - - if (GET_CODE (*x) == MEM) + subrtx_var_iterator::array_type array; + FOR_EACH_SUBRTX_VAR (iter, array, pat, NONCONST) { - /* If we ran out of memory slots, assume a conflict. */ - if (frv_packet.num_mems > ARRAY_SIZE (frv_packet.mems)) - return 1; + rtx x = *iter; + if (GET_CODE (x) == REG) + { + unsigned int regno; + FOR_EACH_REGNO (regno, x) + if ((frv_packet.regstate[regno] & REGSTATE_MODIFIED) != 0) + if (frv_regstate_conflict_p (frv_packet.regstate[regno], cond)) + return true; + } + else if (GET_CODE (x) == MEM) + { + /* If we ran out of memory slots, assume a conflict. */ + if (frv_packet.num_mems > ARRAY_SIZE (frv_packet.mems)) + return 1; - /* Check for output or true dependencies with earlier MEMs. */ - for (i = 0; i < frv_packet.num_mems; i++) - if (frv_regstate_conflict_p (frv_packet.mems[i].cond, cond)) - { - if (true_dependence (frv_packet.mems[i].mem, VOIDmode, *x)) - return 1; + /* Check for output or true dependencies with earlier MEMs. */ + for (unsigned int i = 0; i < frv_packet.num_mems; i++) + if (frv_regstate_conflict_p (frv_packet.mems[i].cond, cond)) + { + if (true_dependence (frv_packet.mems[i].mem, VOIDmode, x)) + return true; - if (output_dependence (frv_packet.mems[i].mem, *x)) - return 1; - } - } + if (output_dependence (frv_packet.mems[i].mem, x)) + return true; + } + } - /* The return values of calls aren't significant: they describe - the effect of the call as a whole, not of the insn itself. */ - if (GET_CODE (*x) == SET && GET_CODE (SET_SRC (*x)) == CALL) - { - if (for_each_rtx (&SET_SRC (*x), frv_registers_conflict_p_1, data)) - return 1; - return -1; + /* The return values of calls aren't significant: they describe + the effect of the call as a whole, not of the insn itself. */ + else if (GET_CODE (x) == SET && GET_CODE (SET_SRC (x)) == CALL) + iter.substitute (SET_SRC (x)); } - - /* Check subexpressions. */ - return 0; + return false; } @@ -7223,13 +7218,13 @@ frv_registers_conflict_p (rtx x) flags = 0; if (GET_CODE (x) == COND_EXEC) { - if (for_each_rtx (&XEXP (x, 0), frv_registers_conflict_p_1, &flags)) + if (frv_registers_conflict_p_1 (XEXP (x, 0), flags)) return true; flags |= frv_cond_flags (XEXP (x, 0)); x = XEXP (x, 1); } - return for_each_rtx (&x, frv_registers_conflict_p_1, &flags); + return frv_registers_conflict_p_1 (x, flags); }