On 8/13/2013 10:37 PM, Richard Sandiford wrote:
Viktor Pobedin<viktor.pobe...@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:

 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);
                  final_scan_insn (insn, asm_out_file, 0, 0 , &seen);
                  fflush (asm_out_file);
                  asm_out_file = tmp;
                  bp[strlen(bp)-1] = 0;
                  return bp;
 }



 BR, Viktor.

Reply via email to