[llvm-dev] How to get the string representation of an instruction?

Daniel Sanders via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 16 13:21:07 PST 2019



> On Jan 16, 2019, at 08:00, Krzysztof Parzyszek via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> On 1/16/2019 9:24 AM, Peng Yu via llvm-dev wrote:
>> 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.
> 
> 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.

> -Krzysztof
> 
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list