public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* NTH_INSN macro like NEXT_INSN?
@ 2019-11-12 10:28 Maxim Blinov
  2019-11-12 11:11 ` Segher Boessenkool
  0 siblings, 1 reply; 3+ messages in thread
From: Maxim Blinov @ 2019-11-12 10:28 UTC (permalink / raw)
  To: gcc-help

Hi all,

I have an `rtx_insn`, and would like to view the Nth insn in that
list. From the debugger, I can do

(gdb) p debug_rtx (NEXT_INSN (first))
(gdb) p debug_rtx (NEXT_INSN (NEXT_INSN (first)))

and so on. Is there a macro I can use to get the Nth insn? E.g.

(gdb) p debug_rtx (NTH_INSN (first, 2))

Maxim

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

* Re: NTH_INSN macro like NEXT_INSN?
  2019-11-12 10:28 NTH_INSN macro like NEXT_INSN? Maxim Blinov
@ 2019-11-12 11:11 ` Segher Boessenkool
  2019-11-12 11:42   ` Maxim Blinov
  0 siblings, 1 reply; 3+ messages in thread
From: Segher Boessenkool @ 2019-11-12 11:11 UTC (permalink / raw)
  To: Maxim Blinov; +Cc: gcc-help

Hi!

On Tue, Nov 12, 2019 at 10:28:33AM +0000, Maxim Blinov wrote:
> I have an `rtx_insn`, and would like to view the Nth insn in that
> list. From the debugger, I can do
> 
> (gdb) p debug_rtx (NEXT_INSN (first))
> (gdb) p debug_rtx (NEXT_INSN (NEXT_INSN (first)))
> 
> and so on. Is there a macro I can use to get the Nth insn? E.g.
> 
> (gdb) p debug_rtx (NTH_INSN (first, 2))

It's not exactly the same, but debug_rtx_list (prl in our gdbinit) might
help you?


Segher

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

* Re: NTH_INSN macro like NEXT_INSN?
  2019-11-12 11:11 ` Segher Boessenkool
@ 2019-11-12 11:42   ` Maxim Blinov
  0 siblings, 0 replies; 3+ messages in thread
From: Maxim Blinov @ 2019-11-12 11:42 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-help

Hi Segher,

> It's not exactly the same, but debug_rtx_list (prl in our gdbinit) might
> help you?

I see, thanks. I ended up bodging it in print-rtl.c

Maxim

diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
index fbb108568b3..8c1f3dbf968 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -74,6 +74,18 @@ int flag_dump_unnumbered = 0;
 int flag_dump_unnumbered_links = 0;
 #endif

+DEBUG_FUNCTION const rtx_insn *
+NTH_INSN (const rtx_insn *insn, int nth)
+{
+  int i;
+  const_rtx next = (const_rtx) insn;
+
+  for (i = 0; i < nth; ++i)
+    next = XEXP (next, 1);
+
+  return (const rtx_insn *)next;
+}
+
 /* Constructor for rtx_writer.  */

 rtx_writer::rtx_writer (FILE *outf, int ind, bool simple, bool compact,

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

end of thread, other threads:[~2019-11-12 11:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 10:28 NTH_INSN macro like NEXT_INSN? Maxim Blinov
2019-11-12 11:11 ` Segher Boessenkool
2019-11-12 11:42   ` Maxim Blinov

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).