I'm currently working on a compiler for a C/C++ like language. I have reached the compiling phase of code generation. I'm using the LLVM C++ api to create an LLVM IR from the input file.
As far as I understood it my module object (I'm working with just one module) should contain all information I need for getting the textual representation of the LLVM IR as a string.
But I really don't know how to do that.
If you wish to get the LLVM IR of your llvm::Module
you can use the llvm::Module::print
function. Use this in combination with the LLVM standard streams like this:
llvm::Module module = ...
module.print(llvm::errs()); // for stderr, llvm::outs() for stdout
See also dump() :
module.dump(); // print to stderr
Or use raw_ostream
llvm::outs() << module;
// or
llvm::errs() << module;
// or
llvm::dbgs() << module;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.