[haskell-llvm] [Haskell-cafe] LLVM, getElementPtr?
lemming at henning-thielemann.de
Sun Dec 5 16:36:27 EST 2010
On Sun, 5 Dec 2010, Lally Singh wrote:
> No wait, sorry.
> buildReaderFun :: String -> CodeGenModule (Function (IO ()))
> buildReaderFun nm = do
> puts <- newNamedFunction ExternalLinkage "puts" :: TFunction (Ptr
> Word8 -> IO Word32)
> let callPuts greetz = createFunction ExternalLinkage $ do
> tmp <- getElementPtr greetz (0 :: Word32,(0 :: Word32, ()))
> call puts tmp -- Throw away return value.
> ret ()
> withStringNul nm callPuts
> Is that how it's intended?
Right, however you have expaneded getElementPtr0 without need.
Whether the string length is determined at compile time or at run time,
depends on how much GHC unfolds. However, since 'nm' is a Haskell String
and not an LLVM value, it may be computed at Haskell runtime but it is
definitely evaluated at LLVM compile time.
More information about the Haskell-llvm