Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Synopsis
- derefFillPtr :: Importer (Ptr param -> Word -> Ptr struct -> IO Word)
- compile :: (C a, T a ~ value, C param, Struct param ~ paramStruct) => (Exp param -> T value) -> IO (Ptr paramStruct -> Word -> Ptr a -> IO Word)
- runAux :: (C p, C a, T a ~ value) => (Exp p -> T value) -> IO (IO () -> Int -> p -> IO (Vector a))
- run_ :: (C p, C a, T a ~ value) => (Exp p -> T value) -> IO (Int -> p -> IO (Vector a))
- derefStartPtr :: Importer (Ptr param -> IO (Ptr globalState))
- derefStopPtr :: Importer (Ptr globalState -> IO ())
- derefChunkPtr :: Importer (Ptr globalState -> Word -> Ptr a -> IO Word)
- type MemoryPtr a = Ptr (Struct a)
- type WithGlobalState param = Struct (param, ())
- type Pair a b = Struct (a, (b, ()))
- type Triple a b c = Struct (a, (b, (c, ())))
- tripleStruct :: (IsSized a, IsSized b, IsSized c) => Value a -> Value b -> Value c -> CodeGenFunction r (Value (Triple a b c))
- compileHandler :: (C param, Struct param ~ paramStruct, C a, T a ~ value) => (Exp param -> T value) -> CodeGenModule (Function (Word8 -> Ptr paramStruct -> Word -> Ptr a -> IO (Pair (Ptr (WithGlobalState paramStruct)) Word)))
- compileChunky :: (IsSized paramStruct, Value (Ptr paramStruct) ~ pPtr, C state, Struct state ~ stateStruct, C global, Struct global ~ globalStruct, Triple paramStruct globalStruct stateStruct ~ triple, IsSized local, C a, T a ~ value) => (forall r z. Phi z => pPtr -> global -> Value (Ptr local) -> () -> state -> T r z (value, state)) -> (forall r. pPtr -> CodeGenFunction r (global, state)) -> (forall r. pPtr -> global -> CodeGenFunction r ()) -> IO (Ptr paramStruct -> IO (Ptr triple), Finalizer triple, Ptr triple -> Word -> Ptr a -> IO Word)
- runChunkyAux :: (C a, T a ~ value, C p) => (Exp p -> T value) -> IO (IO () -> ChunkSize -> p -> IO (Vector a))
- runChunky :: (C a, T a ~ value, C p) => (Exp p -> T value) -> IO (ChunkSize -> p -> IO (Vector a))
- runChunkyOnVector :: (C a, T a ~ al) => (C b, T b ~ bl) => (T al -> T bl) -> IO (ChunkSize -> Vector a -> IO (Vector b))
- class Run f where
- class RunIO a where
- buildIOGen :: Monad m => (final -> shape -> p -> m a) -> m (p, final) -> shape -> m a
- data BuildArg a = forall al.C al => BuildArg (Exp al -> DSLArg a) (a -> IO (al, IO ()))
- class RunArg a where
- primitiveArg :: (C a, DSLArg a ~ Exp a) => BuildArg a
- newtype Buffer a = Buffer (Vector a)
- buffer :: Vector a -> Buffer a
- newDisposeArg :: C handle => (a -> IO handle) -> (handle -> IO ()) -> (Exp handle -> DSLArg a) -> BuildArg a
- class TimeInteger int where
- subdivideLong :: T (T int) a -> T Int a
- run :: Run f => DSL f -> IO (Shape f -> f)
Documentation
compile :: (C a, T a ~ value, C param, Struct param ~ paramStruct) => (Exp param -> T value) -> IO (Ptr paramStruct -> Word -> Ptr a -> IO Word) Source #
runAux :: (C p, C a, T a ~ value) => (Exp p -> T value) -> IO (IO () -> Int -> p -> IO (Vector a)) Source #
derefStartPtr :: Importer (Ptr param -> IO (Ptr globalState)) Source #
derefStopPtr :: Importer (Ptr globalState -> IO ()) Source #
type WithGlobalState param = Struct (param, ()) Source #
tripleStruct :: (IsSized a, IsSized b, IsSized c) => Value a -> Value b -> Value c -> CodeGenFunction r (Value (Triple a b c)) Source #
compileHandler :: (C param, Struct param ~ paramStruct, C a, T a ~ value) => (Exp param -> T value) -> CodeGenModule (Function (Word8 -> Ptr paramStruct -> Word -> Ptr a -> IO (Pair (Ptr (WithGlobalState paramStruct)) Word))) Source #
This is a pretty ugly hack, but its seems to be the least ugly one.
We need to solve the following problem:
We have a function of type Exp param -> T value
.
This means that all methods in T value
depend on Exp param
.
We need to choose one piece of LLVM code in Exp param
that generates appropriate code for all methods in T value
.
If we access a function parameter via Memory.load paramPtr
this means that all methods must end up in the same LLVM function
in order to access this parameter.
Thus I have to put all functionality in one LLVM function
and then the three functions in compileChunky
jump into the handler function with a Word8
code
specifying the actual sub-routine.
We need to squeeze all possible inputs and outputs
through one function interface.
However, since the handler is marked as internal
the optimizer inlines it in the three functions from compileChunky
and eliminates dead code.
This way, we end up with the code that we would have written otherwise.
The alternative would be to construct T value
multiple times.
Due to existential quantification we cannot prove
that the pointer types of different methods match,
so we need to cast pointers.
However, with the current approach we also have to do that.
compileChunky :: (IsSized paramStruct, Value (Ptr paramStruct) ~ pPtr, C state, Struct state ~ stateStruct, C global, Struct global ~ globalStruct, Triple paramStruct globalStruct stateStruct ~ triple, IsSized local, C a, T a ~ value) => (forall r z. Phi z => pPtr -> global -> Value (Ptr local) -> () -> state -> T r z (value, state)) -> (forall r. pPtr -> CodeGenFunction r (global, state)) -> (forall r. pPtr -> global -> CodeGenFunction r ()) -> IO (Ptr paramStruct -> IO (Ptr triple), Finalizer triple, Ptr triple -> Word -> Ptr a -> IO Word) Source #
runChunkyAux :: (C a, T a ~ value, C p) => (Exp p -> T value) -> IO (IO () -> ChunkSize -> p -> IO (Vector a)) Source #
runChunky :: (C a, T a ~ value, C p) => (Exp p -> T value) -> IO (ChunkSize -> p -> IO (Vector a)) Source #
runChunkyOnVector :: (C a, T a ~ al) => (C b, T b ~ bl) => (T al -> T bl) -> IO (ChunkSize -> Vector a -> IO (Vector b)) Source #
buildIOGen :: Monad m => (final -> shape -> p -> m a) -> m (p, final) -> shape -> m a Source #
Instances
RunArg Word32 Source # | |
RunArg () Source # | |
RunArg Float Source # | |
RunArg Int Source # | |
RunArg Word Source # | |
a ~ ChunkSize => RunArg (T a) Source # | |
RunArg a => RunArg (T a) Source # | |
C a => RunArg (Vector a) Source # | |
C a => RunArg (Vector a) Source # | |
C a => RunArg (Buffer a) Source # | |
RunArg a => RunArg (SampleRate a) Source # | |
Defined in Synthesizer.LLVM.Server.Common type DSLArg (SampleRate a) Source # buildArg :: BuildArg (SampleRate a) Source # | |
(time ~ T int, TimeInteger int, C a) => RunArg (T time a) Source # | |
(Natural n, C a, IsSized (Struct a), Natural (n :*: SizeOf (Struct a))) => RunArg (Array n a) Source # | |
(RunArg a, RunArg b) => RunArg (a, b) Source # | |
(RunArg a, RunArg b, RunArg c) => RunArg (a, b, c) Source # | |
newDisposeArg :: C handle => (a -> IO handle) -> (handle -> IO ()) -> (Exp handle -> DSLArg a) -> BuildArg a Source #
class TimeInteger int where Source #
Instances
TimeInteger Integer Source # | |
Defined in Synthesizer.LLVM.Generator.Render | |
TimeInteger Int Source # | |
Defined in Synthesizer.LLVM.Generator.Render |