From patchwork Fri Oct 14 20:12:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 682432 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 3swdJz0C76z9s3T for ; Sat, 15 Oct 2016 06:41:54 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wSCC1hxD; dkim-atps=neutral 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:in-reply-to:references; q=dns; s= default; b=i4SIhhcdRd6MIRAvK3WHq426b29ih251GseQfrIp7GoN8NzeWkI2T OINX3hiK1SoYIjOdDQJKyzFb0nLYA+x56a5GA+mf6vo6DIB/x1DZhMGZQEn/7CrM LbhZzTv6xUDHt2fAPT+Q4YzmDdY5RUhlba2dCDtqtqRhPX6c2woPco= 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:in-reply-to:references; s= default; bh=pvIIJLoQbHqDKyWCO7s2R28EHyA=; b=wSCC1hxDYNplBfLt8EIX SSGWZjH/z//x/Jew+l+cwivgTwVBOZ7lBuu59wIboIGoJo012CgNEMNudQx18IjR P5NsHD/LKu4h+Wqz4UYtoz4vGqMJ1bPMX+CmmzyUg8naGf8MVSBTa6nOXv+Uu0wX s7QMTTeYicTt85yU4IrE0UE= Received: (qmail 7957 invoked by alias); 14 Oct 2016 19:41:34 -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 7897 invoked by uid 89); 14 Oct 2016 19:41:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=400, 14, 400, 6, 40014, Express 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; Fri, 14 Oct 2016 19:41:31 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 31DCC883A9 for ; Fri, 14 Oct 2016 19:41:30 +0000 (UTC) Received: from c64.redhat.com (vpn-237-194.phx2.redhat.com [10.3.237.194]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9EJfTh8006071; Fri, 14 Oct 2016 15:41:29 -0400 From: David Malcolm To: Bernd Schmidt , gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH] (v2) Tweaks to print_rtx_function Date: Fri, 14 Oct 2016 16:12:30 -0400 Message-Id: <1476475950-61673-1-git-send-email-dmalcolm@redhat.com> In-Reply-To: References: X-IsSubscribed: yes On Thu, 2016-10-13 at 16:18 +0200, Bernd Schmidt wrote: > On 10/13/2016 04:08 PM, David Malcolm wrote: > > I thought it might be useful to brainstorm [1] some ideas on this, > > so here are various possible ways it could be printed for this use > > -case: > > > > * Offset by LAST_VIRTUAL_REGISTER + 1 (as in the patch), and > > printed > > just as a number, giving: > > > > (reg:SI 3) > > Unambiguous in the compact format, nice low register numbers, but > some > potential for confusion with hard regs based on what people are used > to. > > > * Prefixed by a "sigil" character: > > > (reg:SI %3) > > Avoids the confusion issue and shouldn't overlap with hard register > names. I think this is the one I prefer, followed by plain (reg:SI > 3). > > > (reg:SI P3) > > Can't use this, as there are machines with P3 registers. > > > * Prefixed so it looks like a register name: > > > > (reg:SI pseudo-3) > > (reg:SI pseudo_3) > > (reg:SI pseudo+3) > > Not too different from just a "%" prefix and probably too verbose. > > > Looking at print_rtx_operand_code_r there are also things like > > ORIGINAL_REGNO, REG_EXPR and REG_OFFSET which get printed after the > > main regno, e.g.: > > > > (reg:SI 1 [ ]) > > That's the REG_EXPR here presumably? The interesting part comes when > parsing this. Indeed, but that seems like an issue for another patch... Here's an updated version of the patch, which uses the '%' sigil for non-virtual pseudos. Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. OK for trunk? gcc/ChangeLog: * print-rtl-function.c (print_edge): Omit "(flags)" when none are set. (print_rtx_function): Update example in comment for... * print-rtl.c (print_rtx_operand_code_r): In compact mode, print non-virtual pseudos with a '%' sigil followed by the regno, offset by (LAST_VIRTUAL_REGISTER + 1), so that the first non-virtual pseudo is dumped as "%0". --- gcc/print-rtl-function.c | 29 ++++++++++++++++++----------- gcc/print-rtl.c | 8 ++++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gcc/print-rtl-function.c b/gcc/print-rtl-function.c index 2abae84..f46304b 100644 --- a/gcc/print-rtl-function.c +++ b/gcc/print-rtl-function.c @@ -60,9 +60,11 @@ print_edge (FILE *outfile, edge e, bool from) /* Express edge flags as a string with " | " separator. e.g. (flags "FALLTHRU | DFS_BACK"). */ - fprintf (outfile, " (flags \""); - bool seen_flag = false; -#define DEF_EDGE_FLAG(NAME,IDX) \ + if (e->flags) + { + fprintf (outfile, " (flags \""); + bool seen_flag = false; +#define DEF_EDGE_FLAG(NAME,IDX) \ do { \ if (e->flags & EDGE_##NAME) \ { \ @@ -75,7 +77,10 @@ print_edge (FILE *outfile, edge e, bool from) #include "cfg-flags.def" #undef DEF_EDGE_FLAG - fprintf (outfile, "\"))\n"); + fprintf (outfile, "\")"); + } + + fprintf (outfile, ")\n"); } /* If BB is non-NULL, print the start of a "(block)" directive for it @@ -132,7 +137,9 @@ can_have_basic_block_p (const rtx_insn *insn) If COMPACT, then instructions are printed in a compact form: - INSN_UIDs are omitted, except for jumps and CODE_LABELs, - INSN_CODEs are omitted, - - register numbers are omitted for hard and virtual regs + - register numbers are omitted for hard and virtual regs, and + non-virtual pseudos are offset relative to the first such reg, and + printed with a '%' sigil e.g. "%0" for (LAST_VIRTUAL_REGISTER + 1), - insn names are prefixed with "c" (e.g. "cinsn", "cnote", etc) Example output (with COMPACT==true): @@ -148,13 +155,13 @@ can_have_basic_block_p (const rtx_insn *insn) (reg:SI di [ i ])) "t.c":2 (nil)) (cnote NOTE_INSN_FUNCTION_BEG) - (cinsn (set (reg:SI 89) + (cinsn (set (reg:SI %2) (mem/c:SI (plus:DI (reg/f:DI virtual-stack-vars) (const_int -4)) [1 i+0 S4 A32])) "t.c":3 (nil)) (cinsn (parallel [ - (set (reg:SI 87 [ _2 ]) - (ashift:SI (reg:SI 89) + (set (reg:SI %0 [ _2 ]) + (ashift:SI (reg:SI %2) (const_int 1))) (clobber (reg:CC flags)) ]) "t.c":3 @@ -162,11 +169,11 @@ can_have_basic_block_p (const rtx_insn *insn) (const_int -4)) [1 i+0 S4 A32]) (const_int 1)) (nil))) - (cinsn (set (reg:SI 88 [ ]) - (reg:SI 87 [ _2 ])) "t.c":3 + (cinsn (set (reg:SI %1 [ ]) + (reg:SI %0 [ _2 ])) "t.c":3 (nil)) (cinsn (set (reg/i:SI ax) - (reg:SI 88 [ ])) "t.c":4 + (reg:SI %1 [ ])) "t.c":4 (nil)) (cinsn (use (reg/i:SI ax)) "t.c":4 (nil)) diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index f114cb4..46f3c4d 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -400,6 +400,14 @@ print_rtx_operand_code_r (const_rtx in_rtx) #endif if (flag_dump_unnumbered && is_insn) fputc ('#', outfile); + else if (flag_compact) + { + /* In compact mode, print pseudos with a '%' sigil following + by the regno, offset by (LAST_VIRTUAL_REGISTER + 1), so that the + first non-virtual pseudo is dumped as "%0". */ + gcc_assert (regno > LAST_VIRTUAL_REGISTER); + fprintf (outfile, " %%%d", regno - (LAST_VIRTUAL_REGISTER + 1)); + } else fprintf (outfile, " %d", regno);