Rain: tidied up the transformEach pass
This commit is contained in:
parent
18fa9cdb65
commit
66fc1d706e
|
@ -19,22 +19,27 @@ rainPasses = runPasses passes
|
||||||
[ ("Convert seqeach/pareach loops into classic replicated SEQ/PAR",transformEach)
|
[ ("Convert seqeach/pareach loops into classic replicated SEQ/PAR",transformEach)
|
||||||
]
|
]
|
||||||
|
|
||||||
--TODO test this pass and then tidy it up
|
|
||||||
transformEach :: Data t => t -> PassM t
|
transformEach :: Data t => t -> PassM t
|
||||||
transformEach = everywhereM (mkM transformEach')
|
transformEach = everywhereM (mkM transformEach')
|
||||||
where
|
where
|
||||||
transformEach' :: A.Structured -> PassM A.Structured
|
transformEach' :: A.Structured -> PassM A.Structured
|
||||||
transformEach' (A.Rep m (A.ForEach m' loopVar loopExp) s)
|
transformEach' (A.Rep m (A.ForEach m' loopVar loopExp) s)
|
||||||
= do (spec,var) <- case loopExp of
|
= do (spec,var) <- case loopExp of
|
||||||
(A.ExprVariable _ v) -> return (\x -> x,v)
|
(A.ExprVariable _ v) -> return (id,v)
|
||||||
_ -> do t <- typeOfExpression loopExp
|
_ -> do t <- typeOfExpression loopExp
|
||||||
spec@(A.Specification _ n' _) <- makeNonceIsExpr "loopVar" m t loopExp
|
spec@(A.Specification _ n' _) <- makeNonceIsExpr "loopVar" m t loopExp
|
||||||
return (\x -> A.Spec m spec x,A.Variable m n')
|
return (A.Spec m spec,A.Variable m n')
|
||||||
--spec is a function A.Structured -> A.Structured, var is an A.Variable
|
--spec is a function A.Structured -> A.Structured, var is an A.Variable
|
||||||
|
|
||||||
loopVarType <- typeOfName loopVar
|
loopVarType <- typeOfName loopVar
|
||||||
loopIndex <- makeNonce "loopIndex"
|
loopIndex <- makeNonce "loopIndex"
|
||||||
let newRep = A.For m' (simpleName loopIndex) (intLiteral 0) (A.SizeVariable m' var)
|
let newRep = A.For m' (simpleName loopIndex) (intLiteral 0) (A.SizeVariable m' var)
|
||||||
let s' = A.Spec m' (A.Specification m' loopVar (A.Is m' A.Abbrev loopVarType (A.SubscriptedVariable m' (A.Subscript m' (A.ExprVariable m' (variable loopIndex))) var) )) s
|
let s' = A.Spec m'
|
||||||
|
(A.Specification m' loopVar
|
||||||
|
(A.Is m' A.Abbrev loopVarType
|
||||||
|
(A.SubscriptedVariable m' (A.Subscript m' (A.ExprVariable m' (variable loopIndex))) var)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
s
|
||||||
return (spec (A.Rep m newRep s'))
|
return (spec (A.Rep m newRep s'))
|
||||||
transformEach' s = return s
|
transformEach' s = return s
|
||||||
|
|
Loading…
Reference in New Issue
Block a user