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: Viktor Pobedin <viktor dot pobedin at gmail dot com>
- To: GCC Development <gcc at gcc dot gnu dot org>, rdsandiford at googlemail dot com
- Date: Wed, 14 Aug 2013 11:53:41 +0300
- 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>
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.