public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] debug: Support "phrs" for dumping a HARD_REG_SET
@ 2023-02-14  2:33 Hans-Peter Nilsson
  2023-02-14  9:57 ` Richard Sandiford
  0 siblings, 1 reply; 2+ messages in thread
From: Hans-Peter Nilsson @ 2023-02-14  2:33 UTC (permalink / raw)
  To: gcc-patches

Ok to commit?  It survived both a cris-elf regtest and a
x86_64-linux-gnu native regtest. :)

---- 8< ----
The debug-function in sel-sched-dump.cc that would be
suitable for a hookup to a command in gdb is guarded by
#ifdef INSN_SCHEDULING, thus can't be used for all targets.
Better move the function marked DEBUG_FUNCTION elsewhere,
here to a file with a suitable static function to call.

There are multiple sets of similar functions dumping
HARD_REG_SETs, but cleaning that up is better left to a
separate commit.

gcc:
	* gdbinit.in (phrs): New command.
	* sel-sched-dump.cc (debug_hard_reg_set): Remove debug-function.
	* ira-color.cc (debug_hard_reg_set): New, calling print_hard_reg_set.
---
 gcc/gdbinit.in        | 12 ++++++++++++
 gcc/ira-color.cc      |  7 +++++++
 gcc/sel-sched-dump.cc | 10 ----------
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/gcc/gdbinit.in b/gcc/gdbinit.in
index 1f7592b0e26a..a76079a46af7 100644
--- a/gcc/gdbinit.in
+++ b/gcc/gdbinit.in
@@ -31,6 +31,7 @@ GCC gdbinit file introduces several debugging shorthands:
     pdd [dw_die_ref],
     pbm [bitmap],
     pel [location_t],
+    phrs [HARD_REG_SET]
     pp, pbs, pcfun
 
 They are generally implemented by calling a function that prints to stderr,
@@ -145,6 +146,17 @@ Print given GENERIC expression in C syntax.
 See also 'help-gcc-hooks'.
 end
 
+define phrs
+eval "set $debug_arg = $%s", $argc ? "arg0" : ""
+call debug_hard_reg_set ($debug_arg)
+end
+
+document phrs
+GCC hook: debug_hard_reg_set (HARD_REG_SET)
+Print given HARD_REG_SET.
+See also 'help-gcc-hooks'.
+end
+
 define pmz
 eval "set $debug_arg = $%s", $argc ? "arg0" : ""
 call mpz_out_str(stderr, 10, $debug_arg)
diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc
index fe6dfc6e7692..1fb2958bddd0 100644
--- a/gcc/ira-color.cc
+++ b/gcc/ira-color.cc
@@ -512,6 +512,13 @@ print_hard_reg_set (FILE *f, HARD_REG_SET set, bool new_line_p)
     fprintf (f, "\n");
 }
 
+/* Dump a hard reg set SET to stderr.  */
+DEBUG_FUNCTION void
+debug_hard_reg_set (HARD_REG_SET set)
+{
+  print_hard_reg_set (stderr, set, true);
+}
+
 /* Print allocno hard register subforest given by ROOTS and its LEVEL
    to F.  */
 static void
diff --git a/gcc/sel-sched-dump.cc b/gcc/sel-sched-dump.cc
index b4eef8803df9..05de98409375 100644
--- a/gcc/sel-sched-dump.cc
+++ b/gcc/sel-sched-dump.cc
@@ -986,16 +986,6 @@ debug_blist (blist_t bnds)
   restore_dump ();
 }
 
-/* Dump a hard reg set SET to stderr.  */
-DEBUG_FUNCTION void
-debug_hard_reg_set (HARD_REG_SET set)
-{
-  switch_dump (stderr);
-  dump_hard_reg_set ("", set);
-  sel_print ("\n");
-  restore_dump ();
-}
-
 /* Debug a cfg region with default flags.  */
 void
 sel_debug_cfg (void)
-- 
2.30.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] debug: Support "phrs" for dumping a HARD_REG_SET
  2023-02-14  2:33 [PATCH] debug: Support "phrs" for dumping a HARD_REG_SET Hans-Peter Nilsson
@ 2023-02-14  9:57 ` Richard Sandiford
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2023-02-14  9:57 UTC (permalink / raw)
  To: Hans-Peter Nilsson via Gcc-patches; +Cc: Hans-Peter Nilsson

Hans-Peter Nilsson via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> Ok to commit?  It survived both a cris-elf regtest and a
> x86_64-linux-gnu native regtest. :)

OK, thanks.

Richard

> ---- 8< ----
> The debug-function in sel-sched-dump.cc that would be
> suitable for a hookup to a command in gdb is guarded by
> #ifdef INSN_SCHEDULING, thus can't be used for all targets.
> Better move the function marked DEBUG_FUNCTION elsewhere,
> here to a file with a suitable static function to call.
>
> There are multiple sets of similar functions dumping
> HARD_REG_SETs, but cleaning that up is better left to a
> separate commit.
>
> gcc:
> 	* gdbinit.in (phrs): New command.
> 	* sel-sched-dump.cc (debug_hard_reg_set): Remove debug-function.
> 	* ira-color.cc (debug_hard_reg_set): New, calling print_hard_reg_set.
> ---
>  gcc/gdbinit.in        | 12 ++++++++++++
>  gcc/ira-color.cc      |  7 +++++++
>  gcc/sel-sched-dump.cc | 10 ----------
>  3 files changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/gcc/gdbinit.in b/gcc/gdbinit.in
> index 1f7592b0e26a..a76079a46af7 100644
> --- a/gcc/gdbinit.in
> +++ b/gcc/gdbinit.in
> @@ -31,6 +31,7 @@ GCC gdbinit file introduces several debugging shorthands:
>      pdd [dw_die_ref],
>      pbm [bitmap],
>      pel [location_t],
> +    phrs [HARD_REG_SET]
>      pp, pbs, pcfun
>  
>  They are generally implemented by calling a function that prints to stderr,
> @@ -145,6 +146,17 @@ Print given GENERIC expression in C syntax.
>  See also 'help-gcc-hooks'.
>  end
>  
> +define phrs
> +eval "set $debug_arg = $%s", $argc ? "arg0" : ""
> +call debug_hard_reg_set ($debug_arg)
> +end
> +
> +document phrs
> +GCC hook: debug_hard_reg_set (HARD_REG_SET)
> +Print given HARD_REG_SET.
> +See also 'help-gcc-hooks'.
> +end
> +
>  define pmz
>  eval "set $debug_arg = $%s", $argc ? "arg0" : ""
>  call mpz_out_str(stderr, 10, $debug_arg)
> diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc
> index fe6dfc6e7692..1fb2958bddd0 100644
> --- a/gcc/ira-color.cc
> +++ b/gcc/ira-color.cc
> @@ -512,6 +512,13 @@ print_hard_reg_set (FILE *f, HARD_REG_SET set, bool new_line_p)
>      fprintf (f, "\n");
>  }
>  
> +/* Dump a hard reg set SET to stderr.  */
> +DEBUG_FUNCTION void
> +debug_hard_reg_set (HARD_REG_SET set)
> +{
> +  print_hard_reg_set (stderr, set, true);
> +}
> +
>  /* Print allocno hard register subforest given by ROOTS and its LEVEL
>     to F.  */
>  static void
> diff --git a/gcc/sel-sched-dump.cc b/gcc/sel-sched-dump.cc
> index b4eef8803df9..05de98409375 100644
> --- a/gcc/sel-sched-dump.cc
> +++ b/gcc/sel-sched-dump.cc
> @@ -986,16 +986,6 @@ debug_blist (blist_t bnds)
>    restore_dump ();
>  }
>  
> -/* Dump a hard reg set SET to stderr.  */
> -DEBUG_FUNCTION void
> -debug_hard_reg_set (HARD_REG_SET set)
> -{
> -  switch_dump (stderr);
> -  dump_hard_reg_set ("", set);
> -  sel_print ("\n");
> -  restore_dump ();
> -}
> -
>  /* Debug a cfg region with default flags.  */
>  void
>  sel_debug_cfg (void)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-14  9:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14  2:33 [PATCH] debug: Support "phrs" for dumping a HARD_REG_SET Hans-Peter Nilsson
2023-02-14  9:57 ` Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).