[haskell-llvm] [Haskell-cafe] LLVM, type-level?

Nathan Howell nathan.d.howell at gmail.com
Tue Dec 7 20:38:07 EST 2010

On Tue, Dec 7, 2010 at 4:39 PM, Lally Singh <lally.singh at gmail.com> wrote:
> Cool, so how do I:
> - declare main's signature?  I'm using createNamedFunction "main"
> - access those arguments inside main's body?

Good question... it looks like getElementPtr does allow indexing into
pointers [1]. It should be possible to either add a GetElementPtr
instance for Ptr or fall back to doing pointer math. This should at
least get you started:

bar :: CodeGenModule (Function (Int32 -> Ptr (Ptr Word8) -> IO Int32))
bar = createNamedFunction ExternalLinkage "main" $
  \ argc argv -> do
      entry <- newBasicBlock
      defineBasicBlock entry
      ret (0 :: Int32)

[1]: https://gist.github.com/44bb32c5c89a75481951

More information about the Haskell-llvm mailing list