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 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:

 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.


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