[Haskell-cafe] Problems with high-level interface to LLVM

Николай Кудасов crazy.fizruk at gmail.com
Sun May 15 11:23:53 CEST 2011

Hi there,

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
simple scheme:

[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...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110515/87b14c36/attachment-0001.htm>

More information about the Haskell-Cafe mailing list