From patchwork Sat Oct 25 09:14:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 402994 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 45DB5140077 for ; Sat, 25 Oct 2014 20:14:36 +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=kcWXZLBUZbb1tpIKp/QsfTpKbi7P2OqM3duqAY/OV6GFoMFRMC /MUJbPxieeDm/GzGOQuMQ4XQEADeew5d59oQNWDhDd57KyH1EIaxwso/856j1db/ uykp/zdPDL4emn5qN9nlVbU9VOhZNqXHPc4YcgVpv8vTfsaJKKWbQk85s= 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=QXHs/12hd38jEzgxt9I1JPll/RE=; b=r3aCab9e1nYpqXFK2/R9 xkrlqusC7I4yGUGG4hwApSNFN3N3jyqZ16WE3rvtWG/+udWVndnKQTIB7dlVDRpJ JuSHUKzuvlCC4yMW0lSewzrgB+k4HtcM3ljKHHnnTvYLethixsaRZSppAYE0rH52 FNVmjapcJ4+JtU6uDDJeQSE= Received: (qmail 642 invoked by alias); 25 Oct 2014 09:14:29 -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 630 invoked by uid 89); 25 Oct 2014 09:14:28 -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-f181.google.com Received: from mail-wi0-f181.google.com (HELO mail-wi0-f181.google.com) (209.85.212.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 25 Oct 2014 09:14:27 +0000 Received: by mail-wi0-f181.google.com with SMTP id n3so2928594wiv.14 for ; Sat, 25 Oct 2014 02:14:24 -0700 (PDT) X-Received: by 10.180.75.179 with SMTP id d19mr9443476wiw.21.1414228464195; Sat, 25 Oct 2014 02:14:24 -0700 (PDT) Received: from localhost ([95.144.14.167]) by mx.google.com with ESMTPSA id lp8sm4547693wic.17.2014.10.25.02.14.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Oct 2014 02:14:23 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, schwab@linux-m68k.org, rdsandiford@googlemail.com Cc: schwab@linux-m68k.org Subject: [m68k] RFA: Use new rtl iterators in m68k_final_prescan_insn Date: Sat, 25 Oct 2014 10:14:23 +0100 Message-ID: <8738ac1pg0.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 m68k-elf. OK to install? Thanks, Richard gcc/ * config/m68k/m68k.c: Include rtl-iter.h. (m68k_final_prescan_insn_1): Delete. (m68k_final_prescan_insn): Use FOR_EACH_SUBRTX_VAR. Index: gcc/config/m68k/m68k.c =================================================================== --- gcc/config/m68k/m68k.c 2014-10-25 09:48:52.914536337 +0100 +++ gcc/config/m68k/m68k.c 2014-10-25 09:51:16.781806316 +0100 @@ -55,6 +55,7 @@ the Free Software Foundation; either ver #include "opts.h" #include "optabs.h" #include "builtins.h" +#include "rtl-iter.h" enum reg_class regno_reg_class[] = { @@ -2279,49 +2280,6 @@ m68k_unwrap_symbol (rtx orig, bool unwra return m68k_unwrap_symbol_1 (orig, unwrap_reloc32_p, NULL); } -/* Helper for m68k_final_prescan_insn. */ - -static int -m68k_final_prescan_insn_1 (rtx *x_ptr, void *data ATTRIBUTE_UNUSED) -{ - rtx x = *x_ptr; - - if (m68k_unwrap_symbol (x, true) != x) - /* For rationale of the below, see comment in m68k_final_prescan_insn. */ - { - rtx plus; - - gcc_assert (GET_CODE (x) == CONST); - plus = XEXP (x, 0); - - if (GET_CODE (plus) == PLUS || GET_CODE (plus) == MINUS) - { - rtx unspec; - rtx addend; - - unspec = XEXP (plus, 0); - gcc_assert (GET_CODE (unspec) == UNSPEC); - addend = XEXP (plus, 1); - gcc_assert (CONST_INT_P (addend)); - - /* We now have all the pieces, rearrange them. */ - - /* Move symbol to plus. */ - XEXP (plus, 0) = XVECEXP (unspec, 0, 0); - - /* Move plus inside unspec. */ - XVECEXP (unspec, 0, 0) = plus; - - /* Move unspec to top level of const. */ - XEXP (x, 0) = unspec; - } - - return -1; - } - - return 0; -} - /* Prescan insn before outputing assembler for it. */ void @@ -2347,13 +2305,47 @@ m68k_final_prescan_insn (rtx_insn *insn Note, that the top level of operand remains intact, so we don't have to patch up anything outside of the operand. */ + subrtx_var_iterator::array_type array; for (i = 0; i < n_operands; ++i) { rtx op; op = operands[i]; - for_each_rtx (&op, m68k_final_prescan_insn_1, NULL); + FOR_EACH_SUBRTX_VAR (iter, array, op, ALL) + { + rtx x = *iter; + if (m68k_unwrap_symbol (x, true) != x) + { + rtx plus; + + gcc_assert (GET_CODE (x) == CONST); + plus = XEXP (x, 0); + + if (GET_CODE (plus) == PLUS || GET_CODE (plus) == MINUS) + { + rtx unspec; + rtx addend; + + unspec = XEXP (plus, 0); + gcc_assert (GET_CODE (unspec) == UNSPEC); + addend = XEXP (plus, 1); + gcc_assert (CONST_INT_P (addend)); + + /* We now have all the pieces, rearrange them. */ + + /* Move symbol to plus. */ + XEXP (plus, 0) = XVECEXP (unspec, 0, 0); + + /* Move plus inside unspec. */ + XVECEXP (unspec, 0, 0) = plus; + + /* Move unspec to top level of const. */ + XEXP (x, 0) = unspec; + } + iter.skip_subrtxes (); + } + } } }