[haskell-llvm] [Haskell-cafe] LLVM, type-level?
lally.singh at gmail.com
Wed Dec 8 09:15:45 EST 2010
On Tue, Dec 7, 2010 at 8:38 PM, Nathan Howell <nathan.d.howell at gmail.com> wrote:
> 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 . 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)
> : https://gist.github.com/44bb32c5c89a75481951
I didn't figure out how to add an instance for GetElementPtr within my
module -- I think it was because IsIndexable.getArg and getIxList
weren't exported -- perhaps it should be in the llvm. But, changing
the type to Ptr(Array D0 Word8) made it work.
More information about the Haskell-llvm