This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: converting rtx object to the assembly instruction.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]