3 ms·
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?
by mehrdadn 8y ago
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?
- flamedoge 8y agoI think easiest way is just to write a backend that emits .NET IR since infra is already there.
- daeken 8y agoThere 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.
- lostmsu 8y agoThere is one, actually: https://github.com/UbiquityDotNET/Llvm.NET https://github.com/UbiquityDotNET/Llvm.NET
- daeken 8y agoI 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.
- mehrdadn 8y agoI see, okay thanks!