From patchwork Sat Oct 25 09:28:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 403000 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 3A6C3140096 for ; Sat, 25 Oct 2014 20:28:31 +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=O/SBWFxc5XwjJv1U0sgIpt7l3mr7d06QRa3VJc22WuDIRKvFZn C2pWZ/GomlNwCOjLf1FrxfsCYW8eEHi5f7k34wf5uSTCm8DmGqYo0us4pmSGNNCn RWDRkqOGSwpPiObCqbnx2tvsLv49WVO66EgEQ8rv0bk3dblfR9f47yVgY= 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=bnUWzfrhKjNoFP85/0lmVQ51lRs=; b=Lw9oAX7arR6T1wE5Qfm3 2Wv8tdtCdD0mnWEuMNU9FHVIJkD0NjG2qwkZmFabqj/YSnfw+QjnWZnnSoLn3NDc VGsLO3CK4GjGPKAbbf2H1dwTskc32Z2mzqFAVFDCp5AlIXbboV5tvfw4aybX0lqt AWLirFVD8CR8EzjeNeu3vpc= Received: (qmail 12479 invoked by alias); 25 Oct 2014 09:28:25 -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 12469 invoked by uid 89); 25 Oct 2014 09:28:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-wi0-f177.google.com Received: from mail-wi0-f177.google.com (HELO mail-wi0-f177.google.com) (209.85.212.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 25 Oct 2014 09:28:23 +0000 Received: by mail-wi0-f177.google.com with SMTP id ex7so2953986wid.10 for ; Sat, 25 Oct 2014 02:28:20 -0700 (PDT) X-Received: by 10.194.61.208 with SMTP id s16mr2495747wjr.104.1414229300361; Sat, 25 Oct 2014 02:28:20 -0700 (PDT) Received: from localhost ([95.144.14.167]) by mx.google.com with ESMTPSA id wl1sm8251994wjb.4.2014.10.25.02.28.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Oct 2014 02:28:19 -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 mips_small_data_pattern_p Date: Sat, 25 Oct 2014 10:28:19 +0100 Message-ID: <878uk4zefg.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: Include rtl-iter.h. (mips_small_data_pattern_1): Take an rtx rather than an rtx pointer. Take the context as a parameter instead of the containing MEM. Iterate over all subrtxes. (mips_small_data_pattern_p): Update call accordingly. Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c 2014-10-25 09:48:52.737534781 +0100 +++ gcc/config/mips/mips.c 2014-10-25 09:51:19.145827388 +0100 @@ -76,6 +76,7 @@ the Free Software Foundation; either ver #include "context.h" #include "cgraph.h" #include "builtins.h" +#include "rtl-iter.h" /* True if X is an UNSPEC wrapper around a SYMBOL_REF or LABEL_REF. */ #define UNSPEC_ADDRESS_P(X) \ @@ -3449,29 +3450,32 @@ mips_rewrite_small_data_p (rtx x, enum m && symbol_type == SYMBOL_GP_RELATIVE); } -/* A for_each_rtx callback for mips_small_data_pattern_p. DATA is the - containing MEM, or null if none. */ +/* Return true if OP refers to small data symbols directly, not through + a LO_SUM. CONTEXT is the context in which X appears. */ static int -mips_small_data_pattern_1 (rtx *loc, void *data) +mips_small_data_pattern_1 (rtx x, enum mips_symbol_context context) { - enum mips_symbol_context context; - - /* Ignore things like "g" constraints in asms. We make no particular - guarantee about which symbolic constants are acceptable as asm operands - versus which must be forced into a GPR. */ - if (GET_CODE (*loc) == LO_SUM || GET_CODE (*loc) == ASM_OPERANDS) - return -1; - - if (MEM_P (*loc)) + subrtx_var_iterator::array_type array; + FOR_EACH_SUBRTX_VAR (iter, array, x, ALL) { - if (for_each_rtx (&XEXP (*loc, 0), mips_small_data_pattern_1, *loc)) - return 1; - return -1; - } + rtx x = *iter; - context = data ? SYMBOL_CONTEXT_MEM : SYMBOL_CONTEXT_LEA; - return mips_rewrite_small_data_p (*loc, context); + /* Ignore things like "g" constraints in asms. We make no particular + guarantee about which symbolic constants are acceptable as asm operands + versus which must be forced into a GPR. */ + if (GET_CODE (x) == LO_SUM || GET_CODE (x) == ASM_OPERANDS) + iter.skip_subrtxes (); + else if (MEM_P (x)) + { + if (mips_small_data_pattern_1 (XEXP (x, 0), SYMBOL_CONTEXT_MEM)) + return true; + iter.skip_subrtxes (); + } + else if (mips_rewrite_small_data_p (x, context)) + return true; + } + return false; } /* Return true if OP refers to small data symbols directly, not through @@ -3480,7 +3484,7 @@ mips_small_data_pattern_1 (rtx *loc, voi bool mips_small_data_pattern_p (rtx op) { - return for_each_rtx (&op, mips_small_data_pattern_1, NULL); + return mips_small_data_pattern_1 (op, SYMBOL_CONTEXT_LEA); } /* A for_each_rtx callback, used by mips_rewrite_small_data.