generate machine code directly via LLVM API -


with following code, can generate llvm bitcode file module:

llvm::module * module;  // fill module code module = ...;  std::error_code ec; llvm::raw_fd_ostream out("anonymous.bc", ec, llvm::sys::fs::f_none);  llvm::writebitcodetofile(module, out); 

i can use bitcode file generate executable machine code file, e.g.:

clang -o anonymous anonymous.bc 

alternatively:

llc anonymous.bc gcc -o anonymous anonymous.s 

my question is: can generate machine code directly in c++ llvm api without first needing write bitcode file?

i looking either a code example or @ least starting points in llvm api, e.g. classes use, nudging me in right direction might enough.

take @ llc tool source, spcifically compilemodule() function. in short, creates target, sets options via targetoptions, uses addpassestoemitfile() , asks passmanager perform planned tasks.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -