[llvm-dev] How to get the string representation of an instruction?
Jonathan Smith via llvm-dev
llvm-dev at lists.llvm.org
Wed Jan 16 09:25:17 PST 2019
> > Create a raw_string_ostream object and use << to print to it. The
> > underlying string will contain the textual representation.
> This is cumbersome. There is not a way to directly get the std::string
> or char * representation of IR text?
Directly? No. Take a look at AssemblyWriter::printInstruction() in
AsmWriter.cpp. There is a lot of logic involved in generating an
accurate, IR-parse-able representation of an instruction. Each operand
must be generated in string form which have their own complexities. A
string representation of an instruction could perhaps be cached with
it, but it would need to be updated every time the instruction is
modified -- and not every application of an instruction necessitates
having a text version of it.
More information about the llvm-dev