Background: I have written a toy Lisp interpreter that I am trying to add LLVM JIT functionality to. For the moment, have imposed the following limitations:
I don't know if it's possible to do this with just the EDSL from LLVM.Core
(the types are indeed quite hairy), but if you look at LLVM.FFI.Core, you'll find the lower-level functionality for manipulating LLVM function types and creating LLVM functions. This leads to the following plan of action:
TypeRef
for your function with functionType
.addFunction
.appendBasicBlock
/insertBasicBlock
. Use getParam
to reference function arguments inside your basic blocks.It should be possible to utilise the nice monadic EDSL syntax for constructing the basic blocks. Also, look at LLVM.Core.Util, it contains some helper functions for working with the FFI layer.