[haskell-llvm] [Haskell-cafe] LLVM, type-level?
Lally Singh
lally.singh at gmail.com
Sat Dec 11 14:42:14 EST 2010
First, thank you for all your help.
On Fri, Dec 10, 2010 at 5:35 AM, Henning Thielemann
<lemming at henning-thielemann.de> wrote:
> I think the type annotation is wrong. It must be
> argv ::Value (Ptr (Ptr Word8))
>
I had tried that as well, but figured it would be best to post about
exactly what you had told me :-)
Heres' what I have:
buildReaderFun :: String -> CodeGenModule (MainFunction)
buildReaderFun nm = do
puts <- newNamedFunction ExternalLinkage "puts" ::
TFunction (Ptr Word8 -> IO Word32)
let callPuts format = (
createNamedFunction ExternalLinkage "main" $
\ argc argv -> do
tmp <- getElementPtr (argv ::Value (Ptr (Ptr Word8)))
(0 :: Int32, (1 :: Int32, ()))
_ <- call puts tmp
ret (0 :: Int32)) :: CodeGenModule (MainFunction)
withStringNul nm callPuts
And the result:
/research/phd/libmet/Listener.hs:51:17:
No instance for (GetElementPtr (Ptr Word8) (Int32, ()) Word8)
arising from a use of `getElementPtr'
at /research/phd/libmet/Listener.hs:(51,17)-(52,47)
Possible fix:
add an instance declaration for
(GetElementPtr (Ptr Word8) (Int32, ()) Word8)
In a stmt of a 'do' expression:
tmp <- getElementPtr
(argv :: Value (Ptr (Ptr Word8))) (0 :: Int32, (1 ::
Int32, ()))
In the expression:
do { tmp <- getElementPtr
(argv :: Value (Ptr (Ptr Word8))) (0 :: Int32,
(1 :: Int32, ()));
_ <- call puts tmp;
ret (0 :: Int32) }
In the second argument of `($)', namely
`\ argc argv
-> do { tmp <- getElementPtr
(argv :: Value (Ptr (Ptr Word8))) (0 ::
Int32, (1 :: Int32, ()));
_ <- call puts tmp;
.... }'
Is there another instance I should add? Should I just shove it into
my build of the llvm package?
Cheers,
-Lally
More information about the Haskell-llvm
mailing list