From patchwork Sat Oct 25 09:36:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 403005 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 6DF88140097 for ; Sat, 25 Oct 2014 20:37:05 +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=EvLRZwfuMPIeKWxLpirfnksjk0EPEkVDtnBX0ocXozOkbNAl4B rGNRXieT+uVhbklqV1cnXfx2+f4jts/ljuEXUcDtcwNS7eBejuuvOaMq2hy6aUYr fulmCmkfHI7I3APiVZbP4CkmmvkVEf8Raq4MDdFAjsdL+VEE5IL+RL9RM= 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=18LBXnPVgPxnTo6sP6zNtNeqAtc=; b=T+OGKOuJkSA/3mfCL8gu KDPMtt1U6WDZoz7mAN2OY66dmbj1x0r1ilhLoFV+VfTNvvSbBIstNazL4f6gsHz3 I6m5PJ6CBEA8S7Y+W2zzv/PDIdr+C9E27s+cEubCwm11Q6nlMkjzZ7Ri9TrJWMbz kzfxq7QOpTTNtlP51udit+M= Received: (qmail 20714 invoked by alias); 25 Oct 2014 09:36:58 -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 20703 invoked by uid 89); 25 Oct 2014 09:36:57 -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-f169.google.com Received: from mail-wi0-f169.google.com (HELO mail-wi0-f169.google.com) (209.85.212.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 25 Oct 2014 09:36:55 +0000 Received: by mail-wi0-f169.google.com with SMTP id q5so2769724wiv.2 for ; Sat, 25 Oct 2014 02:36:53 -0700 (PDT) X-Received: by 10.180.14.73 with SMTP id n9mr9526523wic.39.1414229812995; Sat, 25 Oct 2014 02:36:52 -0700 (PDT) Received: from localhost ([95.144.14.167]) by mx.google.com with ESMTPSA id ji10sm4612783wid.7.2014.10.25.02.36.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Oct 2014 02:36:52 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, clm@codesourcery.com, matthew.fortune@imgtec.com, rdsandiford@googlemail.com Cc: clm@codesourcery.com, matthew.fortune@imgtec.com Subject: [MIPS] RFA: Use new rtl iterators in r10k_needs_protection_p_1 Date: Sat, 25 Oct 2014 10:36:52 +0100 Message-ID: <87r3xwxzgr.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 mips64-elf. OK to install? Thanks, Richard gcc/ * config/mips/mips.c (r10k_needs_protection_p_1): Take an rtx rather than an rtx pointer. Change type of insn from "void *" to its real type. Return bool rather than int. Iterate over all subrtxes here. (r10k_needs_protection_p_store): Update accordingly. (r10k_needs_protection_p): Likewise. Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c 2014-10-25 09:51:20.330837950 +0100 +++ gcc/config/mips/mips.c 2014-10-25 09:51:20.718841409 +0100 @@ -15063,28 +15063,28 @@ r10k_safe_mem_expr_p (tree expr, unsigne return offset < tree_to_uhwi (DECL_SIZE_UNIT (inner)); } -/* A for_each_rtx callback for which DATA points to the instruction - containing *X. Stop the search if we find a MEM that is not safe - from R10K speculation. */ +/* Return true if X contains a MEM that is not safe from R10K speculation. + INSN is the instruction that contains X. */ -static int -r10k_needs_protection_p_1 (rtx *loc, void *data) +static bool +r10k_needs_protection_p_1 (rtx x, rtx_insn *insn) { - rtx mem; - - mem = *loc; - if (!MEM_P (mem)) - return 0; - - if (MEM_EXPR (mem) - && MEM_OFFSET_KNOWN_P (mem) - && r10k_safe_mem_expr_p (MEM_EXPR (mem), MEM_OFFSET (mem))) - return -1; - - if (r10k_safe_address_p (XEXP (mem, 0), (rtx_insn *) data)) - return -1; - - return 1; + subrtx_var_iterator::array_type array; + FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST) + { + rtx mem = *iter; + if (MEM_P (mem)) + { + if ((MEM_EXPR (mem) + && MEM_OFFSET_KNOWN_P (mem) + && r10k_safe_mem_expr_p (MEM_EXPR (mem), MEM_OFFSET (mem))) + || r10k_safe_address_p (XEXP (mem, 0), insn)) + iter.skip_subrtxes (); + else + return true; + } + } + return false; } /* A note_stores callback for which DATA points to an instruction pointer. @@ -15098,7 +15098,7 @@ r10k_needs_protection_p_store (rtx x, co rtx_insn **insn_ptr; insn_ptr = (rtx_insn **) data; - if (*insn_ptr && for_each_rtx (&x, r10k_needs_protection_p_1, *insn_ptr)) + if (*insn_ptr && r10k_needs_protection_p_1 (x, *insn_ptr)) *insn_ptr = NULL; } @@ -15136,7 +15136,7 @@ r10k_needs_protection_p (rtx_insn *insn) return insn == NULL_RTX; } - return for_each_rtx (&PATTERN (insn), r10k_needs_protection_p_1, insn); + return r10k_needs_protection_p_1 (PATTERN (insn), insn); } /* Return true if BB is only reached by blocks in PROTECTED_BBS and if every