[Haskell-cafe] LLVM, getElementPtr?
lemming at henning-thielemann.de
Sun Dec 5 19:28:34 CET 2010
On Sun, 5 Dec 2010, Lally Singh wrote:
> Hey all, I'm trying to get started generating LLVM code, but I'm
> getting a rather cryptic error.
Btw. there is haskell-llvm at projects.haskell.org
> buildReaderFun :: String -> CodeGenModule (Function (IO ()))
> buildReaderFun nm = do
> puts <- newNamedFunction ExternalLinkage "puts" :: TFunction (Ptr
> Word8 -> IO Word32)
> greetz <- createStringNul nm
> func <- createFunction ExternalLinkage $ do
> tmp <- getElementPtr0 greetz (0 :: Word32, ())
You have to add a type annotation to greetz like
(greetz :: Array D42 Word8)
which limits your string to a length of 42 bytes.
If you do not know the length, better use withStringNul.
I implemented the current behavior, because the former implementation was
> call puts tmp -- Throw away return value.
> ret ()
> return func
> My attempts at figuring out what type-level has to do with this, and
> how to satisfy it have so far proven unsuccessful.
type-level provides type level integers, and thus allows for static
checking of sizes, such as the number of bits of an integer type.
More information about the Haskell-Cafe