[LLVMdev] Programmatic compilation of C++ file into bitcode
Trevor Harmon
Trevor.W.Harmon at nasa.gov
Wed Feb 24 17:40:54 PST 2010
I'm building a static analysis tool on top of LLVM. It needs to take
in a C++ source file and have LLVM translate it into bitcode. In other
words, it basically needs to do this:
llvmc hello.cpp -emit-llvm -O0 -S -g
Except that instead of writing the bitcode to a file, it needs to load
it into memory (presumably as an instance of Module) for further
processing and analysis. So my goal is to do essentially what llvmc
does, but programmatically by invoking the LLVM API directly.
I thought I could use lib/CompilerDriver/Main.cpp as a guide, but
after studying the code and associated docs, I'm stumped. Much of the
logic is woven through TableGen'd drivers, so I can't even figure out
how the command line options are fed into the LLVM API.
Any suggestions? Thanks,
Trevor
More information about the llvm-dev
mailing list