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

Lally Singh lally.singh at gmail.com
Wed Dec 8 09:36:48 EST 2010

On Wed, Dec 8, 2010 at 9:15 AM, Lally Singh <lally.singh at gmail.com> wrote:
> 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 [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
> 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.

Ugh, it compiled, but LLVm didn't like the generated code when I ran lli.

The only way to get this to work is by modifying the llvm package, it
seems.  I think I'll have to modify GEP in general to make it work for
structure declarations.

More information about the Haskell-llvm mailing list