diff options
Diffstat (limited to 'SC/Defs.hs')
-rw-r--r-- | SC/Defs.hs | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -4,6 +4,7 @@ module SC.Defs where import Data.Array.Accelerate.AST.Idx import Data.Array.Accelerate.Representation.Array +import Data.Array.Accelerate.Representation.Shape import Data.Array.Accelerate.Type import qualified Language.C as C @@ -59,6 +60,9 @@ type ANames = ITup TypedAName type Exprs = ITup C.Expr +itupEvars :: ITup TypedName t -> Exprs t +itupEvars = itupmap (\(TypedName _ n) -> C.EVar n) + -- Type is the pointer type of the type that this name is supposed to be according to the type index. data TypedAName = TypedAName C.Type Name @@ -84,6 +88,20 @@ shnamesList :: ShNames sh -> [TypedName] shnamesList ShZ = [] shnamesList (ShS n shns) = TypedName (C.TInt C.B64) n : shnamesList shns +makeShNames :: ShapeR sh -> ITup TypedName sh -> ShNames sh +makeShNames ShapeRz ITupIgnore = ShZ +makeShNames (ShapeRsnoc sht) (ITupPair ns (ITupSingle (TypedName _ n))) = + ShS n (makeShNames sht ns) +makeShNames _ _ = error "wat" + +fromShNames :: ShNames sh -> ITup TypedName sh +fromShNames ShZ = ITupIgnore +fromShNames (ShS n ns) = ITupPair (fromShNames ns) (ITupSingle (TypedName (C.TInt C.B64) n)) + +shNamesShape :: ShNames sh -> ShapeR sh +shNamesShape ShZ = ShapeRz +shNamesShape (ShS _ ns) = ShapeRsnoc (shNamesShape ns) + -- GENERATING VARIABLE NAMES -- ------------------------- |