This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: converting rtx object to the assembly instruction.
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Viktor Pobedin <viktor dot pobedin at gmail dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>, rdsandiford at googlemail dot com
- Date: Wed, 14 Aug 2013 11:24:36 -0400
- Subject: Re: converting rtx object to the assembly instruction.
- References: <520A4E5B dot 2020506 at gmail dot com> <878v05idq7 dot fsf at talisman dot default> <520B42DB dot 2090303 at gmail dot com> <520B4595 dot 9010600 at gmail dot com>
On Wed, 2013-08-14 at 11:53 +0300, Viktor Pobedin wrote:
> On 8/13/2013 10:37 PM, Richard Sandiford wrote:
> > Viktor Pobedin<viktor.pobedin@gmail.com> writes:
> >> Is there a simple way to convert rtx object to the assemble
> >> insutruction? Ideally I would like to have function something like:
> >> const char *rtx2asm(rtx insn);
> >> returning a string with the asm instruction for the insn.
> >>
> >> Closest thing that I found is the final_scan_insn function in final.c
> >> but unfortunatelly it outputs the asm string to the file so it makes it
> >> not usefull for my purposes.
> > Yeah, I'm afraid that's all there is.
> >
> > Richard
>
> Richard,
>
> Thanks for the clarification. I found a relative easy way to implement
> this function by redirecting the FILE to char. Posting it here, maybe
> someone else will find it usefull:
Thanks for posting this.
> char *rtx2asm(rtx insn)
> {
> static char *bp;
> size_t size;
> int seen = 0;
> FILE *tmp = asm_out_file;
> asm_out_file = open_memstream(&bp, &size);
Out of interest, how portable is open_memstream (and if not, is there a
good portable way of doing this)? I have to do similar things in my
python plugin for GCC, and currently I'm using fmemopen. IIRC that
latter one is not available on OS X, and was one of the biggest issues
last time I tried to get it working there.
Thanks
Dave