Baris Aktemur
2012-Sep-20 09:42 UTC
[LLVMdev] Programmatically converting LLVM IR to native code
I am generating LLVM IR code and I would like to convert this IR code to native code using the LLVM C++ API. This would be very similar to what's done in the Kaleidoscope tutorial, but instead of relying on JIT compilation, I'd like to emit native code -- the same native code that's produced by llc, for instance. I'm sure this is possible, but I wasn't able to find the resource I need. Any help would be much appreciated. Thanks in advance. -Baris Aktemur -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120920/45a2f1b9/attachment.html>
Eli Friedman
2012-Sep-20 09:57 UTC
[LLVMdev] Programmatically converting LLVM IR to native code
On Thu, Sep 20, 2012 at 2:42 AM, Baris Aktemur <baris.aktemur at ozyegin.edu.tr> wrote:> I am generating LLVM IR code and I would like to convert this IR code to > native code using the LLVM C++ API. This would be very similar to what's > done in the Kaleidoscope tutorial, but instead of relying on JIT > compilation, I'd like to emit native code -- the same native code that's > produced by llc, for instance. > > I'm sure this is possible, but I wasn't able to find the resource I need. > Any help would be much appreciated.Have you looked at the source code for "llc" itself (in tools/llc/llc.cpp)? The API you're looking for is TargetMachine::addPassesToEmitFile. -Eli
Baris Aktemur
2012-Sep-21 18:56 UTC
[LLVMdev] Programmatically converting LLVM IR to native code
On 20 Eyl 2012, at 12:57, Eli Friedman wrote:> On Thu, Sep 20, 2012 at 2:42 AM, Baris Aktemur > <baris.aktemur at ozyegin.edu.tr> wrote: >> I am generating LLVM IR code and I would like to convert this IR code to >> native code using the LLVM C++ API. This would be very similar to what's >> done in the Kaleidoscope tutorial, but instead of relying on JIT >> compilation, I'd like to emit native code -- the same native code that's >> produced by llc, for instance. >> >> I'm sure this is possible, but I wasn't able to find the resource I need. >> Any help would be much appreciated. > > Have you looked at the source code for "llc" itself (in > tools/llc/llc.cpp)? The API you're looking for is > TargetMachine::addPassesToEmitFile. > > -EliThank you. I've started adapting this code. -Baris Aktemur
Reasonably Related Threads
- [LLVMdev] Programmatically converting LLVM IR to native code
- [LLVMdev] Dynamically loading native code generated from LLVM IR
- [LLVMdev] Dynamically loading native code generated from LLVM IR
- [LLVMdev] Dynamically loading native code generated from LLVM IR
- [LLVMdev] Dynamically loading native code generated from LLVM IR