diff options
author | Tom Smeding <tom@tomsmeding.com> | 2021-09-24 22:49:44 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2021-09-24 22:49:44 +0200 |
commit | 070772f008bcb5edb63f3f2c2c5f10c4eb9cb008 (patch) | |
tree | 4b3278f339c140b17f7f2cc9d9bbcee83235526a /SC/Defs.hs | |
parent | f42d7f4562ea2e5c9ef634665952e38630f17ae4 (diff) |
Potentially generate some code for Generate
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 -- ------------------------- |