Hi,
I don't see a way to convert an Instruction to a string or const char
*, although '<<' works on it.
http://llvm.org/doxygen/classllvm_1_1Instruction.html
How to figure this out? Thanks.
Hi,
I don't see a way to convert an Instruction to a string or const char
*, although '<<' works on it.
http://llvm.org/doxygen/classllvm_1_1Instruction.html
How to figure this out? Thanks.
Is Value::getName() not what you want?
he probably means text representation like in text IR
Zhang
Yes. Something like "store i32 %4, i32* @u.3, align 4, !dbg !22".
Value::print(…)?
Create a raw_string_ostream object and use << to print to it. The underlying string will contain the textual representation.
-Krzysztof
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?
> 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.
> 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?
Were .dump() functions mentioned already?
--
Regards,
Peng
Roman.
I don't see a way to convert an Instruction to a string or const char
*, although '<<' works on it.
LLVM: llvm::Instruction Class Reference
How to figure this out? Thanks.Create a raw_string_ostream object and use << to print to it. The underlying string will contain the textual representation.
llvm/Support/ScopedPrinter.h has a to_string() template which does this.