public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Access RTX register information
@ 2020-05-05 22:57 eashan gupta
  2020-05-05 23:06 ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: eashan gupta @ 2020-05-05 22:57 UTC (permalink / raw)
  To: gcc-help

Hi,
Is it possible to access the variable name if we have an RTX which is a reg
that corresponds to a variable declared by the user?

I have found the macro REG_USERVAR_P (RTX) in rtl.h which returns the
boolean "1 if RTX is a reg that corresponds to a variable declared by the
user." But I am unable to get a suitable macro to get the variable name the
reg corresponds to.

On dumping the rtl output using the command:

print_rtl_single(stdout, in_rtx);

I get output:

(reg/v:SI 68 [ c ])

where "c" was the variable name defined by me. How do I access "c" given
the rtx statement, "in_rtx"?

Thank you very much in advance.
Eashan

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

* Re: Access RTX register information
  2020-05-05 22:57 Access RTX register information eashan gupta
@ 2020-05-05 23:06 ` Jeff Law
  2020-05-05 23:42   ` eashan gupta
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Law @ 2020-05-05 23:06 UTC (permalink / raw)
  To: eashan gupta, gcc-help

On Wed, 2020-05-06 at 04:27 +0530, eashan gupta via Gcc-help wrote:
> Hi,
> Is it possible to access the variable name if we have an RTX which is a reg
> that corresponds to a variable declared by the user?
> 
> I have found the macro REG_USERVAR_P (RTX) in rtl.h which returns the
> boolean "1 if RTX is a reg that corresponds to a variable declared by the
> user." But I am unable to get a suitable macro to get the variable name the
> reg corresponds to.
> 
> On dumping the rtl output using the command:
> 
> print_rtl_single(stdout, in_rtx);
> 
> I get output:
> 
> (reg/v:SI 68 [ c ])
> 
> where "c" was the variable name defined by me. How do I access "c" given
> the rtx statement, "in_rtx"?
If/when this information is available it would be in the REG_EXPR field which
would point back to the tree declaration.

jeff


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

* Re: Access RTX register information
  2020-05-05 23:06 ` Jeff Law
@ 2020-05-05 23:42   ` eashan gupta
  2020-05-06 17:35     ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: eashan gupta @ 2020-05-05 23:42 UTC (permalink / raw)
  To: law; +Cc: gcc-help

Hi,
Thanks a lot for replying.
I have tried tracing the print_rtl_single too following the REG_EXPR but it
ends up in the code of printing the complete tree.

Is it possible to access this information directly, ie get the variable
name stored in a string instead of printing it out?

I am not too familiar with the code for the tree and it would be very
helpful to me if I could get the method to get the variable name
stored/extracted from the tree.
Thanks in advance.

Eashan



On Wed, May 6, 2020 at 4:36 AM Jeff Law <law@redhat.com> wrote:

> On Wed, 2020-05-06 at 04:27 +0530, eashan gupta via Gcc-help wrote:
> > Hi,
> > Is it possible to access the variable name if we have an RTX which is a
> reg
> > that corresponds to a variable declared by the user?
> >
> > I have found the macro REG_USERVAR_P (RTX) in rtl.h which returns the
> > boolean "1 if RTX is a reg that corresponds to a variable declared by the
> > user." But I am unable to get a suitable macro to get the variable name
> the
> > reg corresponds to.
> >
> > On dumping the rtl output using the command:
> >
> > print_rtl_single(stdout, in_rtx);
> >
> > I get output:
> >
> > (reg/v:SI 68 [ c ])
> >
> > where "c" was the variable name defined by me. How do I access "c" given
> > the rtx statement, "in_rtx"?
> If/when this information is available it would be in the REG_EXPR field
> which
> would point back to the tree declaration.
>
> jeff
>
>

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

* Re: Access RTX register information
  2020-05-05 23:42   ` eashan gupta
@ 2020-05-06 17:35     ` Jeff Law
  2020-05-07 12:51       ` eashan gupta
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Law @ 2020-05-06 17:35 UTC (permalink / raw)
  To: eashan gupta; +Cc: gcc-help

On Wed, 2020-05-06 at 05:12 +0530, eashan gupta wrote:
> Hi,
> Thanks a lot for replying.
> I have tried tracing the print_rtl_single too following the REG_EXPR but it
> ends up in the code of printing the complete tree.
Right.  It's that tree structure that will have the name emebedded in it.

> 
> Is it possible to access this information directly, ie get the variable name
> stored in a string instead of printing it out?
Probably something like DECL_NAME (REG_EXPR (object)) or DECL_ASSEMBLER_NAME
(REG_EXPR (object))


> I am not too familiar with the code for the tree and it would be very helpful
> to me if I could get the method to get the variable name stored/extracted from
> the tree.
You're almost certainly going to need to refer to tree.h and tree.def to
understand how to dig out the information you want.

jeff
> 


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

* Re: Access RTX register information
  2020-05-06 17:35     ` Jeff Law
@ 2020-05-07 12:51       ` eashan gupta
  0 siblings, 0 replies; 5+ messages in thread
From: eashan gupta @ 2020-05-07 12:51 UTC (permalink / raw)
  To: law; +Cc: gcc-help

Hi,
Yes, thanks for replying.
The above command works but it returns an IDENTIFIER_NODE so it
requires IDENTIFIER_POINTER(DECL_NAME(CONST_CAST_TREE(REG_EXPR(object))))
to give the name of the variable.
Thanks.

Eashan

On Wed, May 6, 2020 at 11:05 PM Jeff Law <law@redhat.com> wrote:

> On Wed, 2020-05-06 at 05:12 +0530, eashan gupta wrote:
> > Hi,
> > Thanks a lot for replying.
> > I have tried tracing the print_rtl_single too following the REG_EXPR but
> it
> > ends up in the code of printing the complete tree.
> Right.  It's that tree structure that will have the name emebedded in it.
>
> >
> > Is it possible to access this information directly, ie get the variable
> name
> > stored in a string instead of printing it out?
> Probably something like DECL_NAME (REG_EXPR (object)) or
> DECL_ASSEMBLER_NAME
> (REG_EXPR (object))
>
>
> > I am not too familiar with the code for the tree and it would be very
> helpful
> > to me if I could get the method to get the variable name
> stored/extracted from
> > the tree.
> You're almost certainly going to need to refer to tree.h and tree.def to
> understand how to dig out the information you want.
>
> jeff
> >
>
>

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

end of thread, other threads:[~2020-05-07 12:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 22:57 Access RTX register information eashan gupta
2020-05-05 23:06 ` Jeff Law
2020-05-05 23:42   ` eashan gupta
2020-05-06 17:35     ` Jeff Law
2020-05-07 12:51       ` eashan gupta

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