Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Out of curiosity, did this involve actually using the LLVM code itself much? Or do you mean you wrote your own interpreter for the IR that it emits?


I have a piece of code in C++ that uses the LLVM API to walk over a bytecode file generated by clang, which generates my own more easily parsed format. Then my C# takes over from there. So it has quite a lot of LLVM code, but it technically doesn't need to, in theory.


I see, okay thanks!


I think easiest way is just to write a backend that emits .NET IR since infra is already there.


There are four ways I considered for implementing this: write an LLVM backend that spits out .NET binaries; write an LLVM backend that spits out C# or CIL assembly; read the LLVM bytecode from .NET and then generate code from there; use the LLVM API to generate some intermediary then handle the compilation from .NET.

I tried #3 first, but landed on #4 in the interest of time. It's not the cleanest approach -- that'd be either using the LLVM API from .NET or implementing a proper backend (assuming there's some decent implementation of a .NET binary writer, since that's a mess) -- but it's stupid simple and effective.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: