From patchwork Mon Nov 7 15:23:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 81108 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1067274qge; Mon, 7 Nov 2016 07:24:05 -0800 (PST) X-Received: by 10.107.55.136 with SMTP id e130mr7722034ioa.76.1478532245301; Mon, 07 Nov 2016 07:24:05 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n9si26617362pad.79.2016.11.07.07.24.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Nov 2016 07:24:05 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-440633-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-440633-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-440633-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:date:in-reply-to:references :content-type:mime-version; q=dns; s=default; b=qPk8/GG3pgf1DM7j Kvi+K82/fRaPImRZyflhQS+jlM0rpqOegsz7/uBdHjoyotHo0CjIWSRCCAbcdskJ 1krvFmS4qvgcvE1nhuPCDJ3c7YWQ0Rsu66WCNg6DvvOrdpVJkPej8Ido2ZXMRkP8 gQA20HIF1x4y8YVoMjW0NUWHfqI= 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 :message-id:subject:from:to:date:in-reply-to:references :content-type:mime-version; s=default; bh=VpYJDrRFiuxAws2GHnZusO aYlYk=; b=IHhJmlVRjJFMC54U5TCVaPnJsJ1QqRUwkNeMvD0kvEdndjk5AFFhg0 0stijnweEFl40pGFnfs3ZHgFYizkz/fWYnN4JP7w56aNMQ7sqrYsIm353eRgodFB eDwy/5XkUaHtCDvgmtvx+rDbzA38iiSG9M1cuVrReeZE1yKWh7KWg= Received: (qmail 33511 invoked by alias); 7 Nov 2016 15:23:48 -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 33497 invoked by uid 89); 7 Nov 2016 15:23:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=122, 7, 1768, xstr, 6819 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Nov 2016 15:23:46 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 535343D95D for ; Mon, 7 Nov 2016 15:23:45 +0000 (UTC) Received: from vpn-224-54.phx2.redhat.com (vpn-224-54.phx2.redhat.com [10.3.224.54]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA7FNia3009694; Mon, 7 Nov 2016 10:23:44 -0500 Message-ID: <1478532224.7673.2.camel@redhat.com> Subject: Re: [PATCH] rtx_writer: avoid printing trailing default values From: David Malcolm To: Bernd Schmidt , gcc-patches@gcc.gnu.org Date: Mon, 07 Nov 2016 10:23:44 -0500 In-Reply-To: References: <152fd27d-71fb-9f15-7d0e-065ee141c1be@redhat.com> <1478286848-7165-1-git-send-email-dmalcolm@redhat.com> <5ea9aa3f-6a42-b416-4074-5dff0721f4c5@redhat.com> <1478287521.28626.110.camel@redhat.com> Mime-Version: 1.0 X-IsSubscribed: yes On Fri, 2016-11-04 at 20:40 +0100, Bernd Schmidt wrote: > On 11/04/2016 08:25 PM, David Malcolm wrote: > > > return m_compact; > > Ok with this one plus a comment. > Thanks. Using m_compact required turning the static function into a (private) member function. For reference, here's what I committed (r241908), having verified bootstrap®rtest. Index: gcc/ChangeLog =================================================================== --- gcc/ChangeLog (revision 241907) +++ gcc/ChangeLog (revision 241908) @@ -1,3 +1,16 @@ +2016-11-07 David Malcolm + + * print-rtl.c (rtx_writer::operand_has_default_value_p): New + method. + (rtx_writer::print_rtx): In compact mode, omit trailing operands + that have the default values. + * print-rtl.h (rtx_writer::operand_has_default_value_p): New + method. + * rtl-tests.c (selftest::test_dumping_insns): Remove empty + label string from expected dump. + (seltest::test_uncond_jump): Remove trailing "(nil)" for REG_NOTES + from expected dump. + 2016-11-07 Jakub Jelinek PR target/77834 Index: gcc/print-rtl.c =================================================================== --- gcc/print-rtl.c (revision 241907) +++ gcc/print-rtl.c (revision 241908) @@ -564,6 +564,43 @@ } } +/* Subroutine of rtx_writer::print_rtx. + In compact mode, determine if operand IDX of IN_RTX is interesting + to dump, or (if in a trailing position) it can be omitted. */ + +bool +rtx_writer::operand_has_default_value_p (const_rtx in_rtx, int idx) +{ + const char *format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)); + + switch (format_ptr[idx]) + { + case 'e': + case 'u': + return XEXP (in_rtx, idx) == NULL_RTX; + + case 's': + return XSTR (in_rtx, idx) == NULL; + + case '0': + switch (GET_CODE (in_rtx)) + { + case JUMP_INSN: + /* JUMP_LABELs are always omitted in compact mode, so treat + any value here as omittable, so that earlier operands can + potentially be omitted also. */ + return m_compact; + + default: + return false; + + } + + default: + return false; + } +} + /* Print IN_RTX onto m_outfile. This is the recursive part of printing. */ void @@ -681,9 +718,18 @@ fprintf (m_outfile, " %d", INSN_UID (in_rtx)); } + /* Determine which is the final operand to print. + In compact mode, skip trailing operands that have the default values + e.g. trailing "(nil)" values. */ + int limit = GET_RTX_LENGTH (GET_CODE (in_rtx)); + if (m_compact) + while (limit > idx && operand_has_default_value_p (in_rtx, limit - 1)) + limit--; + /* Get the format string and skip the first elements if we have handled them already. */ - for (; idx < GET_RTX_LENGTH (GET_CODE (in_rtx)); idx++) + + for (; idx < limit; idx++) print_rtx_operand (in_rtx, idx); switch (GET_CODE (in_rtx)) Index: gcc/print-rtl.h =================================================================== --- gcc/print-rtl.h (revision 241907) +++ gcc/print-rtl.h (revision 241908) @@ -39,6 +39,7 @@ void print_rtx_operand_code_r (const_rtx in_rtx); void print_rtx_operand_code_u (const_rtx in_rtx, int idx); void print_rtx_operand (const_rtx in_rtx, int idx); + bool operand_has_default_value_p (const_rtx in_rtx, int idx); private: FILE *m_outfile; Index: gcc/rtl-tests.c =================================================================== --- gcc/rtl-tests.c (revision 241907) +++ gcc/rtl-tests.c (revision 241908) @@ -122,7 +122,7 @@ /* Labels. */ rtx_insn *label = gen_label_rtx (); CODE_LABEL_NUMBER (label) = 42; - ASSERT_RTL_DUMP_EQ ("(clabel 0 42 \"\")\n", label); + ASSERT_RTL_DUMP_EQ ("(clabel 0 42)\n", label); LABEL_NAME (label)= "some_label"; ASSERT_RTL_DUMP_EQ ("(clabel 0 42 (\"some_label\"))\n", label); @@ -176,8 +176,7 @@ ASSERT_TRUE (control_flow_insn_p (jump_insn)); ASSERT_RTL_DUMP_EQ ("(cjump_insn 1 (set (pc)\n" - " (label_ref 0))\n" - " (nil))\n", + " (label_ref 0)))\n", jump_insn); }