Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the size of the argument list isn't known 'till runtime, you would need to convert the function to something operating on a list anyway. Note that the (IORef [Word32]) type means that an IO action will read/write a (mutable) Word32 list during program execution. Haskell programs only have to say <em>how</em> to mutate/read/write the list -- hence the IO() monad.</p> <p>There's an examples/List.hs file in the LLVM git project you referenced. It constructs an LLVM assembly routine "arrayLoop",</p> <pre><code>arrayLoop :: (Phi a, IsType b, Num i, IsConst i, IsInteger i, IsFirstClass i, CmpRet i Bool) =&gt; Value i -&gt; Value (Ptr b) -&gt; a -&gt; (Value (Ptr b) -&gt; a -&gt; CodeGenFunction r a) -&gt; CodeGenFunction r a arrayLoop len ptr start loopBody = do </code></pre> <p>that increments a pointer to a list of ints, p, and decrements the remaining length, i, in each invocation of the 'body' block. That block repeatedly calls 'loopBody' and stores the result in 'vars', which is eventually returned (untouched at zero) to 's' inside the mList function:</p> <pre><code>mList :: CodeGenModule (Function (StablePtr (IORef [Word32]) -&gt; Word32 -&gt; Ptr Word32 -&gt; IO Int32)) mList = createFunction ExternalLinkage $ \ ref size ptr -&gt; do next &lt;- staticFunction nelem let _ = next :: Function (StablePtr (IORef [Word32]) -&gt; IO Word32) s &lt;- arrayLoop size ptr (valueOf 0) $ \ ptri y -&gt; do flip store ptri =&lt;&lt; call next ref return y ret (s :: Value Int32) </code></pre> <p>All the extra stuff about nelem/NextListElement is used inside their example for 'loopBody,' which shifts the list once to the left. That repo also mentions a mailing list: haskell-llvm@projects.haskellorg.</p> <p>GHC7 can compile using LLVM, but I guess this would not help in a Haskell program interpreting a language unless GHC also does JIT compilation - anyone know if this is the case?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload