{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Synthesizer.LLVM.Interpolation (
C(margin),
loadNodes,
indexNodes,
loadNodesExp,
indexNodesExp,
Margin(..),
zipMargin,
unzipMargin,
toMargin,
marginNumberExp,
marginOffsetExp,
T,
Nodes02(..),
linear,
linearVector,
Nodes13(..),
cubic,
cubicVector,
) where
import qualified Synthesizer.LLVM.Value as Value
import qualified Synthesizer.LLVM.Frame.SerialVector.Class as Serial
import qualified Synthesizer.Interpolation.Core as Interpolation
import qualified LLVM.DSL.Expression as Expr
import qualified LLVM.Extra.Multi.Value as MultiValue
import qualified LLVM.Extra.Scalar as Scalar
import qualified LLVM.Extra.Arithmetic as A
import qualified LLVM.Extra.Tuple as Tuple
import qualified LLVM.Extra.Storable as Storable
import qualified LLVM.Extra.Memory as Memory
import qualified LLVM.Core as LLVM
import LLVM.Core (CodeGenFunction, Value)
import Foreign.Storable (Storable)
import Foreign.Ptr (Ptr)
import Data.Word (Word)
import qualified Type.Data.Num.Decimal as TypeNum
import qualified Control.Monad.Trans.State as MS
import Control.Applicative (Applicative, liftA2, pure, (<*>))
import Data.Traversable (Traversable, traverse, sequenceA, foldMapDefault)
import Data.Foldable (Foldable, foldMap)
data Margin nodes = Margin { forall nodes. Margin nodes -> Int
marginNumber, forall nodes. Margin nodes -> Int
marginOffset :: Int }
deriving (Int -> Margin nodes -> ShowS
[Margin nodes] -> ShowS
Margin nodes -> String
(Int -> Margin nodes -> ShowS)
-> (Margin nodes -> String)
-> ([Margin nodes] -> ShowS)
-> Show (Margin nodes)
forall nodes. Int -> Margin nodes -> ShowS
forall nodes. [Margin nodes] -> ShowS
forall nodes. Margin nodes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall nodes. Int -> Margin nodes -> ShowS
showsPrec :: Int -> Margin nodes -> ShowS
$cshow :: forall nodes. Margin nodes -> String
show :: Margin nodes -> String
$cshowList :: forall nodes. [Margin nodes] -> ShowS
showList :: [Margin nodes] -> ShowS
Show, Margin nodes -> Margin nodes -> Bool
(Margin nodes -> Margin nodes -> Bool)
-> (Margin nodes -> Margin nodes -> Bool) -> Eq (Margin nodes)
forall nodes. Margin nodes -> Margin nodes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall nodes. Margin nodes -> Margin nodes -> Bool
== :: Margin nodes -> Margin nodes -> Bool
$c/= :: forall nodes. Margin nodes -> Margin nodes -> Bool
/= :: Margin nodes -> Margin nodes -> Bool
Eq)
singletonMargin :: MultiValue.T Int -> MultiValue.T (Margin nodes)
singletonMargin :: forall nodes. T Int -> T (Margin nodes)
singletonMargin T Int
n = T Int -> T Int -> T (Margin nodes)
forall nodes. T Int -> T Int -> T (Margin nodes)
zipMargin T Int
n T Int
n
unzipMargin ::
MultiValue.T (Margin nodes) -> (MultiValue.T Int, MultiValue.T Int)
unzipMargin :: forall nodes. T (Margin nodes) -> (T Int, T Int)
unzipMargin (MultiValue.Cons (Value Int
from, Value Int
to)) =
(Repr Int -> T Int
forall a. Repr a -> T a
MultiValue.Cons Repr Int
Value Int
from, Repr Int -> T Int
forall a. Repr a -> T a
MultiValue.Cons Repr Int
Value Int
to)
zipMargin :: MultiValue.T Int -> MultiValue.T Int -> MultiValue.T (Margin nodes)
zipMargin :: forall nodes. T Int -> T Int -> T (Margin nodes)
zipMargin (MultiValue.Cons Repr Int
from) (MultiValue.Cons Repr Int
to) =
Repr (Margin nodes) -> T (Margin nodes)
forall a. Repr a -> T a
MultiValue.Cons (Repr Int
Value Int
from, Repr Int
Value Int
to)
marginNumberExp :: (Expr.Value val) => val (Margin nodes) -> val Int
marginNumberExp :: forall (val :: * -> *) nodes.
Value val =>
val (Margin nodes) -> val Int
marginNumberExp = (T (Margin nodes) -> T Int) -> val (Margin nodes) -> val Int
forall a b. (T a -> T b) -> val a -> val b
forall (val :: * -> *) a b.
Value val =>
(T a -> T b) -> val a -> val b
Expr.lift1 ((T Int, T Int) -> T Int
forall a b. (a, b) -> a
fst ((T Int, T Int) -> T Int)
-> (T (Margin nodes) -> (T Int, T Int))
-> T (Margin nodes)
-> T Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T (Margin nodes) -> (T Int, T Int)
forall nodes. T (Margin nodes) -> (T Int, T Int)
unzipMargin)
marginOffsetExp :: (Expr.Value val) => val (Margin nodes) -> val Int
marginOffsetExp :: forall (val :: * -> *) nodes.
Value val =>
val (Margin nodes) -> val Int
marginOffsetExp = (T (Margin nodes) -> T Int) -> val (Margin nodes) -> val Int
forall a b. (T a -> T b) -> val a -> val b
forall (val :: * -> *) a b.
Value val =>
(T a -> T b) -> val a -> val b
Expr.lift1 ((T Int, T Int) -> T Int
forall a b. (a, b) -> b
snd ((T Int, T Int) -> T Int)
-> (T (Margin nodes) -> (T Int, T Int))
-> T (Margin nodes)
-> T Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T (Margin nodes) -> (T Int, T Int)
forall nodes. T (Margin nodes) -> (T Int, T Int)
unzipMargin)
instance MultiValue.C (Margin nodes) where
type Repr (Margin nodes) = (LLVM.Value Int, LLVM.Value Int)
cons :: Margin nodes -> T (Margin nodes)
cons (Margin Int
start Int
len) =
T Int -> T Int -> T (Margin nodes)
forall nodes. T Int -> T Int -> T (Margin nodes)
zipMargin (Int -> T Int
forall a. C a => a -> T a
MultiValue.cons Int
start) (Int -> T Int
forall a. C a => a -> T a
MultiValue.cons Int
len)
undef :: T (Margin nodes)
undef = T Int -> T (Margin nodes)
forall nodes. T Int -> T (Margin nodes)
singletonMargin T Int
forall a. C a => T a
MultiValue.undef
zero :: T (Margin nodes)
zero = T Int -> T (Margin nodes)
forall nodes. T Int -> T (Margin nodes)
singletonMargin T Int
forall a. C a => T a
MultiValue.zero
phi :: forall r.
BasicBlock
-> T (Margin nodes) -> CodeGenFunction r (T (Margin nodes))
phi BasicBlock
bb T (Margin nodes)
a =
case T (Margin nodes) -> (T Int, T Int)
forall nodes. T (Margin nodes) -> (T Int, T Int)
unzipMargin T (Margin nodes)
a of
(T Int
a0,T Int
a1) ->
(T Int -> T Int -> T (Margin nodes))
-> CodeGenFunction r (T Int)
-> CodeGenFunction r (T Int)
-> CodeGenFunction r (T (Margin nodes))
forall a b c.
(a -> b -> c)
-> CodeGenFunction r a
-> CodeGenFunction r b
-> CodeGenFunction r c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 T Int -> T Int -> T (Margin nodes)
forall nodes. T Int -> T Int -> T (Margin nodes)
zipMargin (BasicBlock -> T Int -> CodeGenFunction r (T Int)
forall a r. C a => BasicBlock -> T a -> CodeGenFunction r (T a)
forall r. BasicBlock -> T Int -> CodeGenFunction r (T Int)
MultiValue.phi BasicBlock
bb T Int
a0) (BasicBlock -> T Int -> CodeGenFunction r (T Int)
forall a r. C a => BasicBlock -> T a -> CodeGenFunction r (T a)
forall r. BasicBlock -> T Int -> CodeGenFunction r (T Int)
MultiValue.phi BasicBlock
bb T Int
a1)
addPhi :: forall r.
BasicBlock
-> T (Margin nodes) -> T (Margin nodes) -> CodeGenFunction r ()
addPhi BasicBlock
bb T (Margin nodes)
a T (Margin nodes)
b =
case (T (Margin nodes) -> (T Int, T Int)
forall nodes. T (Margin nodes) -> (T Int, T Int)
unzipMargin T (Margin nodes)
a, T (Margin nodes) -> (T Int, T Int)
forall nodes. T (Margin nodes) -> (T Int, T Int)
unzipMargin T (Margin nodes)
b) of
((T Int
a0,T Int
a1), (T Int
b0,T Int
b1)) -> do
BasicBlock -> T Int -> T Int -> CodeGenFunction r ()
forall a r. C a => BasicBlock -> T a -> T a -> CodeGenFunction r ()
forall r. BasicBlock -> T Int -> T Int -> CodeGenFunction r ()
MultiValue.addPhi BasicBlock
bb T Int
a0 T Int
b0
BasicBlock -> T Int -> T Int -> CodeGenFunction r ()
forall a r. C a => BasicBlock -> T a -> T a -> CodeGenFunction r ()
forall r. BasicBlock -> T Int -> T Int -> CodeGenFunction r ()
MultiValue.addPhi BasicBlock
bb T Int
a1 T Int
b1
class (Applicative nodes, Traversable nodes) => C nodes where
margin :: Margin (nodes a)
type T r nodes a v = a -> nodes v -> CodeGenFunction r v
toMargin ::
(C nodes) =>
(forall r. T r nodes a v) ->
Margin (nodes v)
toMargin :: forall (nodes :: * -> *) a v.
C nodes =>
(forall r. T r nodes a v) -> Margin (nodes v)
toMargin forall r. T r nodes a v
_ = Margin (nodes v)
forall a. Margin (nodes a)
forall (nodes :: * -> *) a. C nodes => Margin (nodes a)
margin
data Nodes02 a = Nodes02 {forall a. Nodes02 a -> a
nodes02_0, forall a. Nodes02 a -> a
nodes02_1 :: a}
instance C Nodes02 where
margin :: forall a. Margin (Nodes02 a)
margin = Margin { marginNumber :: Int
marginNumber = Int
2, marginOffset :: Int
marginOffset = Int
0 }
instance Functor Nodes02 where
fmap :: forall a b. (a -> b) -> Nodes02 a -> Nodes02 b
fmap a -> b
f (Nodes02 a
x0 a
x1) = b -> b -> Nodes02 b
forall a. a -> a -> Nodes02 a
Nodes02 (a -> b
f a
x0) (a -> b
f a
x1)
instance Applicative Nodes02 where
pure :: forall a. a -> Nodes02 a
pure a
x = a -> a -> Nodes02 a
forall a. a -> a -> Nodes02 a
Nodes02 a
x a
x
(Nodes02 a -> b
f0 a -> b
f1) <*> :: forall a b. Nodes02 (a -> b) -> Nodes02 a -> Nodes02 b
<*> (Nodes02 a
x0 a
x1) = b -> b -> Nodes02 b
forall a. a -> a -> Nodes02 a
Nodes02 (a -> b
f0 a
x0) (a -> b
f1 a
x1)
instance Foldable Nodes02 where
foldMap :: forall m a. Monoid m => (a -> m) -> Nodes02 a -> m
foldMap = (a -> m) -> Nodes02 a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault
instance Traversable Nodes02 where
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Nodes02 a -> f (Nodes02 b)
traverse a -> f b
f (Nodes02 a
x0 a
x1) = (b -> b -> Nodes02 b) -> f b -> f b -> f (Nodes02 b)
forall a b c. (a -> b -> c) -> f a -> f b -> f c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 b -> b -> Nodes02 b
forall a. a -> a -> Nodes02 a
Nodes02 (a -> f b
f a
x0) (a -> f b
f a
x1)
instance (Serial.Sized value) => Serial.Sized (Nodes02 value) where
type Size (Nodes02 value) = Serial.Size value
instance (Serial.Read v) => Serial.Read (Nodes02 v) where
type Element (Nodes02 v) = Nodes02 (Serial.Element v)
type ReadIt (Nodes02 v) = Nodes02 (Serial.ReadIt v)
extract :: forall r.
Value Word32
-> Nodes02 v -> CodeGenFunction r (Element (Nodes02 v))
extract = Value Word32
-> Nodes02 v -> CodeGenFunction r (Element (Nodes02 v))
Value Word32
-> Nodes02 v -> CodeGenFunction r (Nodes02 (Element v))
forall v (f :: * -> *) r.
(Read v, Traversable f) =>
Value Word32 -> f v -> CodeGenFunction r (f (Element v))
Serial.extractTraversable
readStart :: forall r.
Nodes02 v
-> CodeGenFunction
r (ReadIterator (ReadIt (Nodes02 v)) (Nodes02 v))
readStart = Nodes02 v
-> CodeGenFunction
r (ReadIterator (ReadIt (Nodes02 v)) (Nodes02 v))
Nodes02 v
-> CodeGenFunction
r (ReadIterator (Nodes02 (ReadIt v)) (Nodes02 v))
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Read v) =>
f v -> CodeGenFunction r (ReadIterator (f (ReadIt v)) (f v))
Serial.readStartTraversable
readNext :: forall r.
ReadIterator (ReadIt (Nodes02 v)) (Nodes02 v)
-> CodeGenFunction
r
(Element (Nodes02 v),
ReadIterator (ReadIt (Nodes02 v)) (Nodes02 v))
readNext = ReadIterator (ReadIt (Nodes02 v)) (Nodes02 v)
-> CodeGenFunction
r
(Element (Nodes02 v),
ReadIterator (ReadIt (Nodes02 v)) (Nodes02 v))
ReadIterator (Nodes02 (ReadIt v)) (Nodes02 v)
-> CodeGenFunction
r
(Nodes02 (Element v),
ReadIterator (Nodes02 (ReadIt v)) (Nodes02 v))
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Read v) =>
ReadIterator (f (ReadIt v)) (f v)
-> CodeGenFunction
r (f (Element v), ReadIterator (f (ReadIt v)) (f v))
Serial.readNextTraversable
instance (Serial.Write v) => Serial.Write (Nodes02 v) where
type WriteIt (Nodes02 v) = Nodes02 (Serial.WriteIt v)
insert :: forall r.
Value Word32
-> Element (Nodes02 v)
-> Nodes02 v
-> CodeGenFunction r (Nodes02 v)
insert = Value Word32
-> Element (Nodes02 v)
-> Nodes02 v
-> CodeGenFunction r (Nodes02 v)
Value Word32
-> Nodes02 (Element v)
-> Nodes02 v
-> CodeGenFunction r (Nodes02 v)
forall v (f :: * -> *) r.
(Write v, Traversable f, Applicative f) =>
Value Word32 -> f (Element v) -> f v -> CodeGenFunction r (f v)
Serial.insertTraversable
writeStart :: forall r.
CodeGenFunction r (WriteIterator (WriteIt (Nodes02 v)) (Nodes02 v))
writeStart = CodeGenFunction r (WriteIterator (WriteIt (Nodes02 v)) (Nodes02 v))
CodeGenFunction r (WriteIterator (Nodes02 (WriteIt v)) (Nodes02 v))
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Write v) =>
CodeGenFunction r (WriteIterator (f (WriteIt v)) (f v))
Serial.writeStartTraversable
writeNext :: forall r.
Element (Nodes02 v)
-> WriteIterator (WriteIt (Nodes02 v)) (Nodes02 v)
-> CodeGenFunction
r (WriteIterator (WriteIt (Nodes02 v)) (Nodes02 v))
writeNext = Element (Nodes02 v)
-> WriteIterator (WriteIt (Nodes02 v)) (Nodes02 v)
-> CodeGenFunction
r (WriteIterator (WriteIt (Nodes02 v)) (Nodes02 v))
Nodes02 (Element v)
-> WriteIterator (Nodes02 (WriteIt v)) (Nodes02 v)
-> CodeGenFunction
r (WriteIterator (Nodes02 (WriteIt v)) (Nodes02 v))
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Write v) =>
f (Element v)
-> WriteIterator (f (WriteIt v)) (f v)
-> CodeGenFunction r (WriteIterator (f (WriteIt v)) (f v))
Serial.writeNextTraversable
writeStop :: forall r.
WriteIterator (WriteIt (Nodes02 v)) (Nodes02 v)
-> CodeGenFunction r (Nodes02 v)
writeStop = WriteIterator (WriteIt (Nodes02 v)) (Nodes02 v)
-> CodeGenFunction r (Nodes02 v)
WriteIterator (Nodes02 (WriteIt v)) (Nodes02 v)
-> CodeGenFunction r (Nodes02 v)
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Write v) =>
WriteIterator (f (WriteIt v)) (f v) -> CodeGenFunction r (f v)
Serial.writeStopTraversable
instance (Tuple.Undefined a) => Tuple.Undefined (Nodes02 a) where
undef :: Nodes02 a
undef = Nodes02 a
forall a (f :: * -> *). (Undefined a, Applicative f) => f a
Tuple.undefPointed
instance (Tuple.Phi a) => Tuple.Phi (Nodes02 a) where
phi :: forall r. BasicBlock -> Nodes02 a -> CodeGenFunction r (Nodes02 a)
phi = BasicBlock -> Nodes02 a -> CodeGenFunction r (Nodes02 a)
forall a (f :: * -> *) r.
(Phi a, Traversable f) =>
BasicBlock -> f a -> CodeGenFunction r (f a)
Tuple.phiTraversable
addPhi :: forall r.
BasicBlock -> Nodes02 a -> Nodes02 a -> CodeGenFunction r ()
addPhi = BasicBlock -> Nodes02 a -> Nodes02 a -> CodeGenFunction r ()
forall a (f :: * -> *) r.
(Phi a, Foldable f, Applicative f) =>
BasicBlock -> f a -> f a -> CodeGenFunction r ()
Tuple.addPhiFoldable
type Struct02 a = LLVM.Struct (a, (a, ()))
memory02 ::
(Memory.C l) =>
Memory.Record r (Struct02 (Memory.Struct l)) (Nodes02 l)
memory02 :: forall l r. C l => Record r (Struct02 (Struct l)) (Nodes02 l)
memory02 =
(l -> l -> Nodes02 l)
-> Element r (Struct02 (Struct l)) (Nodes02 l) l
-> Element r (Struct02 (Struct l)) (Nodes02 l) l
-> Element r (Struct02 (Struct l)) (Nodes02 l) (Nodes02 l)
forall a b c.
(a -> b -> c)
-> Element r (Struct02 (Struct l)) (Nodes02 l) a
-> Element r (Struct02 (Struct l)) (Nodes02 l) b
-> Element r (Struct02 (Struct l)) (Nodes02 l) c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 l -> l -> Nodes02 l
forall a. a -> a -> Nodes02 a
Nodes02
((Nodes02 l -> l)
-> Proxy D0 -> Element r (Struct02 (Struct l)) (Nodes02 l) l
forall x o n v r.
(C x, GetValue o n, ValueType o n ~ Struct x,
GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) =>
(v -> x) -> n -> Element r o v x
Memory.element Nodes02 l -> l
forall a. Nodes02 a -> a
nodes02_0 Proxy D0
TypeNum.d0)
((Nodes02 l -> l)
-> Proxy D1 -> Element r (Struct02 (Struct l)) (Nodes02 l) l
forall x o n v r.
(C x, GetValue o n, ValueType o n ~ Struct x,
GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) =>
(v -> x) -> n -> Element r o v x
Memory.element Nodes02 l -> l
forall a. Nodes02 a -> a
nodes02_1 Proxy D1
TypeNum.d1)
instance (Memory.C l) => Memory.C (Nodes02 l) where
type Struct (Nodes02 l) = Struct02 (Memory.Struct l)
load :: forall r.
Value (Ptr (Struct (Nodes02 l))) -> CodeGenFunction r (Nodes02 l)
load = Record r (Struct02 (Struct l)) (Nodes02 l)
-> Value (Ptr (Struct02 (Struct l)))
-> CodeGenFunction r (Nodes02 l)
forall r o llvmValue.
Record r o llvmValue
-> Value (Ptr o) -> CodeGenFunction r llvmValue
Memory.loadRecord Record r (Struct02 (Struct l)) (Nodes02 l)
forall l r. C l => Record r (Struct02 (Struct l)) (Nodes02 l)
memory02
store :: forall r.
Nodes02 l
-> Value (Ptr (Struct (Nodes02 l))) -> CodeGenFunction r ()
store = Record r (Struct02 (Struct l)) (Nodes02 l)
-> Nodes02 l
-> Value (Ptr (Struct02 (Struct l)))
-> CodeGenFunction r ()
forall r o llvmValue.
Record r o llvmValue
-> llvmValue -> Value (Ptr o) -> CodeGenFunction r ()
Memory.storeRecord Record r (Struct02 (Struct l)) (Nodes02 l)
forall l r. C l => Record r (Struct02 (Struct l)) (Nodes02 l)
memory02
decompose :: forall r.
Value (Struct (Nodes02 l)) -> CodeGenFunction r (Nodes02 l)
decompose = Record r (Struct02 (Struct l)) (Nodes02 l)
-> Value (Struct02 (Struct l)) -> CodeGenFunction r (Nodes02 l)
forall r o llvmValue.
Record r o llvmValue -> Value o -> CodeGenFunction r llvmValue
Memory.decomposeRecord Record r (Struct02 (Struct l)) (Nodes02 l)
forall l r. C l => Record r (Struct02 (Struct l)) (Nodes02 l)
memory02
compose :: forall r.
Nodes02 l -> CodeGenFunction r (Value (Struct (Nodes02 l)))
compose = Record r (Struct02 (Struct l)) (Nodes02 l)
-> Nodes02 l -> CodeGenFunction r (Value (Struct02 (Struct l)))
forall o r llvmValue.
IsType o =>
Record r o llvmValue -> llvmValue -> CodeGenFunction r (Value o)
Memory.composeRecord Record r (Struct02 (Struct l)) (Nodes02 l)
forall l r. C l => Record r (Struct02 (Struct l)) (Nodes02 l)
memory02
linear ::
(A.PseudoRing a, A.IntegerConstant a) =>
T r Nodes02 a a
linear :: forall a r. (PseudoRing a, IntegerConstant a) => T r Nodes02 a a
linear a
r (Nodes02 a
a a
b) =
(T a -> T a -> T a -> CodeGenFunction r (T a))
-> a -> a -> a -> CodeGenFunction r a
forall (m :: * -> *) a b c r.
Monad m =>
(T a -> T b -> T c -> m (T r)) -> a -> b -> c -> m r
Scalar.unliftM3 ((T (T a) -> T (T a) -> T (T a) -> T (T a))
-> forall r.
T a -> T a -> T a -> CodeGenFunction r (Registers (T (T a)))
forall value a b c.
Flatten value =>
(T a -> T b -> T c -> value)
-> forall r. a -> b -> c -> CodeGenFunction r (Registers value)
Value.unlift3 T (T a) -> T (T a) -> T (T a) -> T (T a)
forall a v. C a v => v -> v -> a -> v
Interpolation.linear) a
a a
b a
r
linearVector ::
(A.PseudoModule v, A.Scalar v ~ a, A.IntegerConstant a) =>
T r Nodes02 a v
linearVector :: forall v a r.
(PseudoModule v, Scalar v ~ a, IntegerConstant a) =>
T r Nodes02 a v
linearVector a
r (Nodes02 v
a v
b) =
(T v -> T v -> T a -> T v)
-> forall r. v -> v -> a -> CodeGenFunction r (Registers (T v))
forall value a b c.
Flatten value =>
(T a -> T b -> T c -> value)
-> forall r. a -> b -> c -> CodeGenFunction r (Registers value)
Value.unlift3 T v -> T v -> T a -> T v
forall a v. C a v => v -> v -> a -> v
Interpolation.linear v
a v
b a
r
data Nodes13 a = Nodes13 {forall a. Nodes13 a -> a
nodes13_0, forall a. Nodes13 a -> a
nodes13_1, forall a. Nodes13 a -> a
nodes13_2, forall a. Nodes13 a -> a
nodes13_3 :: a}
instance C Nodes13 where
margin :: forall a. Margin (Nodes13 a)
margin = Margin { marginNumber :: Int
marginNumber = Int
4, marginOffset :: Int
marginOffset = Int
1 }
instance Functor Nodes13 where
fmap :: forall a b. (a -> b) -> Nodes13 a -> Nodes13 b
fmap a -> b
f (Nodes13 a
x0 a
x1 a
x2 a
x3) = b -> b -> b -> b -> Nodes13 b
forall a. a -> a -> a -> a -> Nodes13 a
Nodes13 (a -> b
f a
x0) (a -> b
f a
x1) (a -> b
f a
x2) (a -> b
f a
x3)
instance Applicative Nodes13 where
pure :: forall a. a -> Nodes13 a
pure a
x = a -> a -> a -> a -> Nodes13 a
forall a. a -> a -> a -> a -> Nodes13 a
Nodes13 a
x a
x a
x a
x
(Nodes13 a -> b
f0 a -> b
f1 a -> b
f2 a -> b
f3) <*> :: forall a b. Nodes13 (a -> b) -> Nodes13 a -> Nodes13 b
<*> (Nodes13 a
x0 a
x1 a
x2 a
x3) =
b -> b -> b -> b -> Nodes13 b
forall a. a -> a -> a -> a -> Nodes13 a
Nodes13 (a -> b
f0 a
x0) (a -> b
f1 a
x1) (a -> b
f2 a
x2) (a -> b
f3 a
x3)
instance Foldable Nodes13 where
foldMap :: forall m a. Monoid m => (a -> m) -> Nodes13 a -> m
foldMap = (a -> m) -> Nodes13 a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault
instance Traversable Nodes13 where
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Nodes13 a -> f (Nodes13 b)
traverse a -> f b
f (Nodes13 a
x0 a
x1 a
x2 a
x3) =
(b -> b -> b -> b -> Nodes13 b)
-> f (b -> b -> b -> b -> Nodes13 b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure b -> b -> b -> b -> Nodes13 b
forall a. a -> a -> a -> a -> Nodes13 a
Nodes13 f (b -> b -> b -> b -> Nodes13 b)
-> f b -> f (b -> b -> b -> Nodes13 b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
x0 f (b -> b -> b -> Nodes13 b) -> f b -> f (b -> b -> Nodes13 b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
x1 f (b -> b -> Nodes13 b) -> f b -> f (b -> Nodes13 b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
x2 f (b -> Nodes13 b) -> f b -> f (Nodes13 b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
x3
instance (Serial.Sized value) => Serial.Sized (Nodes13 value) where
type Size (Nodes13 value) = Serial.Size value
instance (Serial.Read v) => Serial.Read (Nodes13 v) where
type Element (Nodes13 v) = Nodes13 (Serial.Element v)
type ReadIt (Nodes13 v) = Nodes13 (Serial.ReadIt v)
extract :: forall r.
Value Word32
-> Nodes13 v -> CodeGenFunction r (Element (Nodes13 v))
extract = Value Word32
-> Nodes13 v -> CodeGenFunction r (Element (Nodes13 v))
Value Word32
-> Nodes13 v -> CodeGenFunction r (Nodes13 (Element v))
forall v (f :: * -> *) r.
(Read v, Traversable f) =>
Value Word32 -> f v -> CodeGenFunction r (f (Element v))
Serial.extractTraversable
readStart :: forall r.
Nodes13 v
-> CodeGenFunction
r (ReadIterator (ReadIt (Nodes13 v)) (Nodes13 v))
readStart = Nodes13 v
-> CodeGenFunction
r (ReadIterator (ReadIt (Nodes13 v)) (Nodes13 v))
Nodes13 v
-> CodeGenFunction
r (ReadIterator (Nodes13 (ReadIt v)) (Nodes13 v))
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Read v) =>
f v -> CodeGenFunction r (ReadIterator (f (ReadIt v)) (f v))
Serial.readStartTraversable
readNext :: forall r.
ReadIterator (ReadIt (Nodes13 v)) (Nodes13 v)
-> CodeGenFunction
r
(Element (Nodes13 v),
ReadIterator (ReadIt (Nodes13 v)) (Nodes13 v))
readNext = ReadIterator (ReadIt (Nodes13 v)) (Nodes13 v)
-> CodeGenFunction
r
(Element (Nodes13 v),
ReadIterator (ReadIt (Nodes13 v)) (Nodes13 v))
ReadIterator (Nodes13 (ReadIt v)) (Nodes13 v)
-> CodeGenFunction
r
(Nodes13 (Element v),
ReadIterator (Nodes13 (ReadIt v)) (Nodes13 v))
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Read v) =>
ReadIterator (f (ReadIt v)) (f v)
-> CodeGenFunction
r (f (Element v), ReadIterator (f (ReadIt v)) (f v))
Serial.readNextTraversable
instance (Serial.Write v) => Serial.Write (Nodes13 v) where
type WriteIt (Nodes13 v) = Nodes13 (Serial.WriteIt v)
insert :: forall r.
Value Word32
-> Element (Nodes13 v)
-> Nodes13 v
-> CodeGenFunction r (Nodes13 v)
insert = Value Word32
-> Element (Nodes13 v)
-> Nodes13 v
-> CodeGenFunction r (Nodes13 v)
Value Word32
-> Nodes13 (Element v)
-> Nodes13 v
-> CodeGenFunction r (Nodes13 v)
forall v (f :: * -> *) r.
(Write v, Traversable f, Applicative f) =>
Value Word32 -> f (Element v) -> f v -> CodeGenFunction r (f v)
Serial.insertTraversable
writeStart :: forall r.
CodeGenFunction r (WriteIterator (WriteIt (Nodes13 v)) (Nodes13 v))
writeStart = CodeGenFunction r (WriteIterator (WriteIt (Nodes13 v)) (Nodes13 v))
CodeGenFunction r (WriteIterator (Nodes13 (WriteIt v)) (Nodes13 v))
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Write v) =>
CodeGenFunction r (WriteIterator (f (WriteIt v)) (f v))
Serial.writeStartTraversable
writeNext :: forall r.
Element (Nodes13 v)
-> WriteIterator (WriteIt (Nodes13 v)) (Nodes13 v)
-> CodeGenFunction
r (WriteIterator (WriteIt (Nodes13 v)) (Nodes13 v))
writeNext = Element (Nodes13 v)
-> WriteIterator (WriteIt (Nodes13 v)) (Nodes13 v)
-> CodeGenFunction
r (WriteIterator (WriteIt (Nodes13 v)) (Nodes13 v))
Nodes13 (Element v)
-> WriteIterator (Nodes13 (WriteIt v)) (Nodes13 v)
-> CodeGenFunction
r (WriteIterator (Nodes13 (WriteIt v)) (Nodes13 v))
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Write v) =>
f (Element v)
-> WriteIterator (f (WriteIt v)) (f v)
-> CodeGenFunction r (WriteIterator (f (WriteIt v)) (f v))
Serial.writeNextTraversable
writeStop :: forall r.
WriteIterator (WriteIt (Nodes13 v)) (Nodes13 v)
-> CodeGenFunction r (Nodes13 v)
writeStop = WriteIterator (WriteIt (Nodes13 v)) (Nodes13 v)
-> CodeGenFunction r (Nodes13 v)
WriteIterator (Nodes13 (WriteIt v)) (Nodes13 v)
-> CodeGenFunction r (Nodes13 v)
forall (f :: * -> *) v r.
(Traversable f, Applicative f, Write v) =>
WriteIterator (f (WriteIt v)) (f v) -> CodeGenFunction r (f v)
Serial.writeStopTraversable
instance (Tuple.Undefined a) => Tuple.Undefined (Nodes13 a) where
undef :: Nodes13 a
undef = Nodes13 a
forall a (f :: * -> *). (Undefined a, Applicative f) => f a
Tuple.undefPointed
instance (Tuple.Phi a) => Tuple.Phi (Nodes13 a) where
phi :: forall r. BasicBlock -> Nodes13 a -> CodeGenFunction r (Nodes13 a)
phi = BasicBlock -> Nodes13 a -> CodeGenFunction r (Nodes13 a)
forall a (f :: * -> *) r.
(Phi a, Traversable f) =>
BasicBlock -> f a -> CodeGenFunction r (f a)
Tuple.phiTraversable
addPhi :: forall r.
BasicBlock -> Nodes13 a -> Nodes13 a -> CodeGenFunction r ()
addPhi = BasicBlock -> Nodes13 a -> Nodes13 a -> CodeGenFunction r ()
forall a (f :: * -> *) r.
(Phi a, Foldable f, Applicative f) =>
BasicBlock -> f a -> f a -> CodeGenFunction r ()
Tuple.addPhiFoldable
type Struct13 a = LLVM.Struct (a, (a, (a, (a, ()))))
memory13 ::
(Memory.C l) =>
Memory.Record r (Struct13 (Memory.Struct l)) (Nodes13 l)
memory13 :: forall l r. C l => Record r (Struct13 (Struct l)) (Nodes13 l)
memory13 =
(l -> l -> l -> l -> Nodes13 l)
-> Element
r (Struct13 (Struct l)) (Nodes13 l) (l -> l -> l -> l -> Nodes13 l)
forall a. a -> Element r (Struct13 (Struct l)) (Nodes13 l) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure l -> l -> l -> l -> Nodes13 l
forall a. a -> a -> a -> a -> Nodes13 a
Nodes13
Element
r (Struct13 (Struct l)) (Nodes13 l) (l -> l -> l -> l -> Nodes13 l)
-> Element r (Struct13 (Struct l)) (Nodes13 l) l
-> Element
r (Struct13 (Struct l)) (Nodes13 l) (l -> l -> l -> Nodes13 l)
forall a b.
Element r (Struct13 (Struct l)) (Nodes13 l) (a -> b)
-> Element r (Struct13 (Struct l)) (Nodes13 l) a
-> Element r (Struct13 (Struct l)) (Nodes13 l) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Nodes13 l -> l)
-> Proxy D0 -> Element r (Struct13 (Struct l)) (Nodes13 l) l
forall x o n v r.
(C x, GetValue o n, ValueType o n ~ Struct x,
GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) =>
(v -> x) -> n -> Element r o v x
Memory.element Nodes13 l -> l
forall a. Nodes13 a -> a
nodes13_0 Proxy D0
TypeNum.d0
Element
r (Struct13 (Struct l)) (Nodes13 l) (l -> l -> l -> Nodes13 l)
-> Element r (Struct13 (Struct l)) (Nodes13 l) l
-> Element
r (Struct13 (Struct l)) (Nodes13 l) (l -> l -> Nodes13 l)
forall a b.
Element r (Struct13 (Struct l)) (Nodes13 l) (a -> b)
-> Element r (Struct13 (Struct l)) (Nodes13 l) a
-> Element r (Struct13 (Struct l)) (Nodes13 l) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Nodes13 l -> l)
-> Proxy D1 -> Element r (Struct13 (Struct l)) (Nodes13 l) l
forall x o n v r.
(C x, GetValue o n, ValueType o n ~ Struct x,
GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) =>
(v -> x) -> n -> Element r o v x
Memory.element Nodes13 l -> l
forall a. Nodes13 a -> a
nodes13_1 Proxy D1
TypeNum.d1
Element r (Struct13 (Struct l)) (Nodes13 l) (l -> l -> Nodes13 l)
-> Element r (Struct13 (Struct l)) (Nodes13 l) l
-> Element r (Struct13 (Struct l)) (Nodes13 l) (l -> Nodes13 l)
forall a b.
Element r (Struct13 (Struct l)) (Nodes13 l) (a -> b)
-> Element r (Struct13 (Struct l)) (Nodes13 l) a
-> Element r (Struct13 (Struct l)) (Nodes13 l) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Nodes13 l -> l)
-> Proxy D2 -> Element r (Struct13 (Struct l)) (Nodes13 l) l
forall x o n v r.
(C x, GetValue o n, ValueType o n ~ Struct x,
GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) =>
(v -> x) -> n -> Element r o v x
Memory.element Nodes13 l -> l
forall a. Nodes13 a -> a
nodes13_2 Proxy D2
TypeNum.d2
Element r (Struct13 (Struct l)) (Nodes13 l) (l -> Nodes13 l)
-> Element r (Struct13 (Struct l)) (Nodes13 l) l
-> Element r (Struct13 (Struct l)) (Nodes13 l) (Nodes13 l)
forall a b.
Element r (Struct13 (Struct l)) (Nodes13 l) (a -> b)
-> Element r (Struct13 (Struct l)) (Nodes13 l) a
-> Element r (Struct13 (Struct l)) (Nodes13 l) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Nodes13 l -> l)
-> Proxy D3 -> Element r (Struct13 (Struct l)) (Nodes13 l) l
forall x o n v r.
(C x, GetValue o n, ValueType o n ~ Struct x,
GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) =>
(v -> x) -> n -> Element r o v x
Memory.element Nodes13 l -> l
forall a. Nodes13 a -> a
nodes13_3 Proxy D3
TypeNum.d3
instance (Memory.C l) => Memory.C (Nodes13 l) where
type Struct (Nodes13 l) = Struct13 (Memory.Struct l)
load :: forall r.
Value (Ptr (Struct (Nodes13 l))) -> CodeGenFunction r (Nodes13 l)
load = Record r (Struct13 (Struct l)) (Nodes13 l)
-> Value (Ptr (Struct13 (Struct l)))
-> CodeGenFunction r (Nodes13 l)
forall r o llvmValue.
Record r o llvmValue
-> Value (Ptr o) -> CodeGenFunction r llvmValue
Memory.loadRecord Record r (Struct13 (Struct l)) (Nodes13 l)
forall l r. C l => Record r (Struct13 (Struct l)) (Nodes13 l)
memory13
store :: forall r.
Nodes13 l
-> Value (Ptr (Struct (Nodes13 l))) -> CodeGenFunction r ()
store = Record r (Struct13 (Struct l)) (Nodes13 l)
-> Nodes13 l
-> Value (Ptr (Struct13 (Struct l)))
-> CodeGenFunction r ()
forall r o llvmValue.
Record r o llvmValue
-> llvmValue -> Value (Ptr o) -> CodeGenFunction r ()
Memory.storeRecord Record r (Struct13 (Struct l)) (Nodes13 l)
forall l r. C l => Record r (Struct13 (Struct l)) (Nodes13 l)
memory13
decompose :: forall r.
Value (Struct (Nodes13 l)) -> CodeGenFunction r (Nodes13 l)
decompose = Record r (Struct13 (Struct l)) (Nodes13 l)
-> Value (Struct13 (Struct l)) -> CodeGenFunction r (Nodes13 l)
forall r o llvmValue.
Record r o llvmValue -> Value o -> CodeGenFunction r llvmValue
Memory.decomposeRecord Record r (Struct13 (Struct l)) (Nodes13 l)
forall l r. C l => Record r (Struct13 (Struct l)) (Nodes13 l)
memory13
compose :: forall r.
Nodes13 l -> CodeGenFunction r (Value (Struct (Nodes13 l)))
compose = Record r (Struct13 (Struct l)) (Nodes13 l)
-> Nodes13 l -> CodeGenFunction r (Value (Struct13 (Struct l)))
forall o r llvmValue.
IsType o =>
Record r o llvmValue -> llvmValue -> CodeGenFunction r (Value o)
Memory.composeRecord Record r (Struct13 (Struct l)) (Nodes13 l)
forall l r. C l => Record r (Struct13 (Struct l)) (Nodes13 l)
memory13
cubic ::
(A.Field a, A.RationalConstant a) =>
T r Nodes13 a a
cubic :: forall a r. (Field a, RationalConstant a) => T r Nodes13 a a
cubic a
r (Nodes13 a
a a
b a
c a
d) =
(T a -> T a -> T a -> T a -> T a -> CodeGenFunction r (T a))
-> a -> a -> a -> a -> a -> CodeGenFunction r a
forall (m :: * -> *) a b c d e r.
Monad m =>
(T a -> T b -> T c -> T d -> T e -> m (T r))
-> a -> b -> c -> d -> e -> m r
Scalar.unliftM5 ((T (T a) -> T (T a) -> T (T a) -> T (T a) -> T (T a) -> T (T a))
-> forall r.
T a
-> T a
-> T a
-> T a
-> T a
-> CodeGenFunction r (Registers (T (T a)))
forall value a b c d e.
Flatten value =>
(T a -> T b -> T c -> T d -> T e -> value)
-> forall r.
a -> b -> c -> d -> e -> CodeGenFunction r (Registers value)
Value.unlift5 T (T a) -> T (T a) -> T (T a) -> T (T a) -> T (T a) -> T (T a)
forall a v. (C a v, C a) => v -> v -> v -> v -> a -> v
Interpolation.cubic) a
a a
b a
c a
d a
r
cubicVector ::
(A.PseudoModule v, A.Scalar v ~ a, A.Field a, A.RationalConstant a) =>
T r Nodes13 a v
cubicVector :: forall v a r.
(PseudoModule v, Scalar v ~ a, Field a, RationalConstant a) =>
T r Nodes13 a v
cubicVector a
r (Nodes13 v
a v
b v
c v
d) =
(T v -> T v -> T v -> T v -> T a -> T v)
-> forall r.
v -> v -> v -> v -> a -> CodeGenFunction r (Registers (T v))
forall value a b c d e.
Flatten value =>
(T a -> T b -> T c -> T d -> T e -> value)
-> forall r.
a -> b -> c -> d -> e -> CodeGenFunction r (Registers value)
Value.unlift5 T v -> T v -> T v -> T v -> T a -> T v
forall a v. (C a v, C a) => v -> v -> v -> v -> a -> v
Interpolation.cubic v
a v
b v
c v
d a
r
loadNodesExp ::
(C nodes, Storable am) =>
(Value (Ptr am) -> CodeGenFunction r a) ->
MultiValue.T Int ->
Value (Ptr am) -> CodeGenFunction r (nodes a)
loadNodesExp :: forall (nodes :: * -> *) am r a.
(C nodes, Storable am) =>
(Value (Ptr am) -> CodeGenFunction r a)
-> T Int -> Value (Ptr am) -> CodeGenFunction r (nodes a)
loadNodesExp Value (Ptr am) -> CodeGenFunction r a
loadNode (MultiValue.Cons Repr Int
step) =
StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
-> Value (Ptr am) -> CodeGenFunction r (nodes a)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
MS.evalStateT (StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
-> Value (Ptr am) -> CodeGenFunction r (nodes a))
-> StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
-> Value (Ptr am)
-> CodeGenFunction r (nodes a)
forall a b. (a -> b) -> a -> b
$ nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
-> StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => nodes (f a) -> f (nodes a)
sequenceA (nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
-> StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a))
-> nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
-> StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
forall a b. (a -> b) -> a -> b
$ StateT (Value (Ptr am)) (CodeGenFunction r) a
-> nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
forall a. a -> nodes a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StateT (Value (Ptr am)) (CodeGenFunction r) a
-> nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a))
-> StateT (Value (Ptr am)) (CodeGenFunction r) a
-> nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
forall a b. (a -> b) -> a -> b
$ (Value (Ptr am) -> CodeGenFunction r a)
-> Value Int -> StateT (Value (Ptr am)) (CodeGenFunction r) a
forall am r a.
Storable am =>
(Value (Ptr am) -> CodeGenFunction r a)
-> Value Int -> StateT (Value (Ptr am)) (CodeGenFunction r) a
loadNext Value (Ptr am) -> CodeGenFunction r a
loadNode Repr Int
Value Int
step
loadNodes ::
(C nodes, Storable am) =>
(Value (Ptr am) -> CodeGenFunction r a) ->
Value Int ->
Value (Ptr am) -> CodeGenFunction r (nodes a)
loadNodes :: forall (nodes :: * -> *) am r a.
(C nodes, Storable am) =>
(Value (Ptr am) -> CodeGenFunction r a)
-> Value Int -> Value (Ptr am) -> CodeGenFunction r (nodes a)
loadNodes Value (Ptr am) -> CodeGenFunction r a
loadNode Value Int
step =
StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
-> Value (Ptr am) -> CodeGenFunction r (nodes a)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
MS.evalStateT (StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
-> Value (Ptr am) -> CodeGenFunction r (nodes a))
-> StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
-> Value (Ptr am)
-> CodeGenFunction r (nodes a)
forall a b. (a -> b) -> a -> b
$ nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
-> StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => nodes (f a) -> f (nodes a)
sequenceA (nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
-> StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a))
-> nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
-> StateT (Value (Ptr am)) (CodeGenFunction r) (nodes a)
forall a b. (a -> b) -> a -> b
$ StateT (Value (Ptr am)) (CodeGenFunction r) a
-> nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
forall a. a -> nodes a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StateT (Value (Ptr am)) (CodeGenFunction r) a
-> nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a))
-> StateT (Value (Ptr am)) (CodeGenFunction r) a
-> nodes (StateT (Value (Ptr am)) (CodeGenFunction r) a)
forall a b. (a -> b) -> a -> b
$ (Value (Ptr am) -> CodeGenFunction r a)
-> Value Int -> StateT (Value (Ptr am)) (CodeGenFunction r) a
forall am r a.
Storable am =>
(Value (Ptr am) -> CodeGenFunction r a)
-> Value Int -> StateT (Value (Ptr am)) (CodeGenFunction r) a
loadNext Value (Ptr am) -> CodeGenFunction r a
loadNode Value Int
step
loadNext ::
(Storable am) =>
(Value (Ptr am) -> CodeGenFunction r a) ->
Value Int ->
MS.StateT (Value (Ptr am)) (CodeGenFunction r) a
loadNext :: forall am r a.
Storable am =>
(Value (Ptr am) -> CodeGenFunction r a)
-> Value Int -> StateT (Value (Ptr am)) (CodeGenFunction r) a
loadNext Value (Ptr am) -> CodeGenFunction r a
loadNode Value Int
step =
(Value (Ptr am) -> CodeGenFunction r (a, Value (Ptr am)))
-> StateT (Value (Ptr am)) (CodeGenFunction r) a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
MS.StateT ((Value (Ptr am) -> CodeGenFunction r (a, Value (Ptr am)))
-> StateT (Value (Ptr am)) (CodeGenFunction r) a)
-> (Value (Ptr am) -> CodeGenFunction r (a, Value (Ptr am)))
-> StateT (Value (Ptr am)) (CodeGenFunction r) a
forall a b. (a -> b) -> a -> b
$ \Value (Ptr am)
ptr -> (a -> Value (Ptr am) -> (a, Value (Ptr am)))
-> CodeGenFunction r a
-> CodeGenFunction r (Value (Ptr am))
-> CodeGenFunction r (a, Value (Ptr am))
forall a b c.
(a -> b -> c)
-> CodeGenFunction r a
-> CodeGenFunction r b
-> CodeGenFunction r c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (,) (Value (Ptr am) -> CodeGenFunction r a
loadNode Value (Ptr am)
ptr) (Value Int -> Value (Ptr am) -> CodeGenFunction r (Value (Ptr am))
forall a ptr r.
(Storable a, Value (Ptr a) ~ ptr) =>
Value Int -> ptr -> CodeGenFunction r ptr
Storable.advancePtr Value Int
step Value (Ptr am)
ptr)
indexNodesExp ::
(C nodes) =>
(MultiValue.T Word -> CodeGenFunction r v) ->
MultiValue.T Word ->
MultiValue.T Word -> CodeGenFunction r (nodes v)
indexNodesExp :: forall (nodes :: * -> *) r v.
C nodes =>
(T Word -> CodeGenFunction r v)
-> T Word -> T Word -> CodeGenFunction r (nodes v)
indexNodesExp T Word -> CodeGenFunction r v
indexNode (MultiValue.Cons Repr Word
step) (MultiValue.Cons Repr Word
offset) =
(Value Word -> CodeGenFunction r v)
-> Value Word -> Value Word -> CodeGenFunction r (nodes v)
forall (nodes :: * -> *) r v.
C nodes =>
(Value Word -> CodeGenFunction r v)
-> Value Word -> Value Word -> CodeGenFunction r (nodes v)
indexNodes (T Word -> CodeGenFunction r v
indexNode (T Word -> CodeGenFunction r v)
-> (Value Word -> T Word) -> Value Word -> CodeGenFunction r v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Repr Word -> T Word
Value Word -> T Word
forall a. Repr a -> T a
MultiValue.Cons) Repr Word
Value Word
step Repr Word
Value Word
offset
indexNodes ::
(C nodes) =>
(Value Word -> CodeGenFunction r v) ->
Value Word ->
Value Word -> CodeGenFunction r (nodes v)
indexNodes :: forall (nodes :: * -> *) r v.
C nodes =>
(Value Word -> CodeGenFunction r v)
-> Value Word -> Value Word -> CodeGenFunction r (nodes v)
indexNodes Value Word -> CodeGenFunction r v
indexNode Value Word
step =
StateT (Value Word) (CodeGenFunction r) (nodes v)
-> Value Word -> CodeGenFunction r (nodes v)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
MS.evalStateT (StateT (Value Word) (CodeGenFunction r) (nodes v)
-> Value Word -> CodeGenFunction r (nodes v))
-> StateT (Value Word) (CodeGenFunction r) (nodes v)
-> Value Word
-> CodeGenFunction r (nodes v)
forall a b. (a -> b) -> a -> b
$ nodes (StateT (Value Word) (CodeGenFunction r) v)
-> StateT (Value Word) (CodeGenFunction r) (nodes v)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => nodes (f a) -> f (nodes a)
sequenceA (nodes (StateT (Value Word) (CodeGenFunction r) v)
-> StateT (Value Word) (CodeGenFunction r) (nodes v))
-> nodes (StateT (Value Word) (CodeGenFunction r) v)
-> StateT (Value Word) (CodeGenFunction r) (nodes v)
forall a b. (a -> b) -> a -> b
$ StateT (Value Word) (CodeGenFunction r) v
-> nodes (StateT (Value Word) (CodeGenFunction r) v)
forall a. a -> nodes a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StateT (Value Word) (CodeGenFunction r) v
-> nodes (StateT (Value Word) (CodeGenFunction r) v))
-> StateT (Value Word) (CodeGenFunction r) v
-> nodes (StateT (Value Word) (CodeGenFunction r) v)
forall a b. (a -> b) -> a -> b
$ (Value Word -> CodeGenFunction r v)
-> Value Word -> StateT (Value Word) (CodeGenFunction r) v
forall r v.
(Value Word -> CodeGenFunction r v)
-> Value Word -> StateT (Value Word) (CodeGenFunction r) v
indexNext Value Word -> CodeGenFunction r v
indexNode Value Word
step
indexNext ::
(Value Word -> CodeGenFunction r v) ->
Value Word ->
MS.StateT (Value Word) (CodeGenFunction r) v
indexNext :: forall r v.
(Value Word -> CodeGenFunction r v)
-> Value Word -> StateT (Value Word) (CodeGenFunction r) v
indexNext Value Word -> CodeGenFunction r v
indexNode Value Word
step =
(Value Word -> CodeGenFunction r (v, Value Word))
-> StateT (Value Word) (CodeGenFunction r) v
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
MS.StateT ((Value Word -> CodeGenFunction r (v, Value Word))
-> StateT (Value Word) (CodeGenFunction r) v)
-> (Value Word -> CodeGenFunction r (v, Value Word))
-> StateT (Value Word) (CodeGenFunction r) v
forall a b. (a -> b) -> a -> b
$ \Value Word
i -> (v -> Value Word -> (v, Value Word))
-> CodeGenFunction r v
-> CodeGenFunction r (Value Word)
-> CodeGenFunction r (v, Value Word)
forall a b c.
(a -> b -> c)
-> CodeGenFunction r a
-> CodeGenFunction r b
-> CodeGenFunction r c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (,) (Value Word -> CodeGenFunction r v
indexNode Value Word
i) (Value Word -> Value Word -> CodeGenFunction r (Value Word)
forall a r. Additive a => a -> a -> CodeGenFunction r a
forall r.
Value Word -> Value Word -> CodeGenFunction r (Value Word)
A.add Value Word
i Value Word
step)