[Haskell-cafe] Problems with high-level interface to LLVM
crazy.fizruk at gmail.com
Sun May 15 11:23:53 CEST 2011
I use llvm package for building compiler for a small C-like language and it
have some problems with high-level interface that package provides. I use
[parser] -> (untyped AST) -> [analyser] -> (typed AST) -> [LLVM] -> (object
At first, as I want to use high-level interface, typed AST must satisfy all
needed class constraints. For simple types and operations this can be solved
by adding neccessary constraints to the corresponding definitions. But it's
not very good solution, because in general typed AST can represent
high-level data structures, that would have certain representation, known
when generating code, but not checking logic.
Problem becomes much more complex when I want to add function calls into my
language. Type class CallArgs has an instance CallArgs (IO a)
(CodeGenFunction r (Value a)), which can't be given as a constraint in typed
AST because of free variable r. For a long time I have had no idea of how I
can add function calls into my language.
The only solution I see at the moment is to reject high-level llvm interface
provided by llvm library and use directly FFI bindings to C.
But I can't get rid of feeling that I'm missing something or doing all stuff
totally wrong. It would be great if someone, who has experience in using
high-level interface to LLVM for building a compiler, could help me.
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe