projects
/
matthijs
/
master-project
/
cλash.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
675ebbd
)
Move a part of β-reduction to application propagation.
author
Matthijs Kooijman
<matthijs@stdin.nl>
Tue, 18 May 2010 08:16:07 +0000
(10:16 +0200)
committer
Matthijs Kooijman
<matthijs@stdin.nl>
Tue, 18 May 2010 08:18:01 +0000
(10:18 +0200)
cλash/CLasH/Normalize.hs
patch
|
blob
|
history
diff --git
a/cλash/CLasH/Normalize.hs
b/cλash/CLasH/Normalize.hs
index 977cc0d804197915b776c77ed43645ff39fb1005..dc9606c756238d312ae2f8888b57efe660d38dbe 100644
(file)
--- a/
cλash/CLasH/Normalize.hs
+++ b/
cλash/CLasH/Normalize.hs
@@
-72,15
+72,22
@@
beta :: Transform
-- substitution.
beta c (App (Lam x expr) arg) | CoreSyn.isTyVar x = setChanged >> substitute x arg c expr
| otherwise = setChanged >> substitute_clone x arg c expr
-- substitution.
beta c (App (Lam x expr) arg) | CoreSyn.isTyVar x = setChanged >> substitute x arg c expr
| otherwise = setChanged >> substitute_clone x arg c expr
+-- Leave all other expressions unchanged
+beta c expr = return expr
+
+--------------------------------
+-- Application propagation
+--------------------------------
+appprop :: Transform
-- Propagate the application into the let
-- Propagate the application into the let
-
beta
c (App (Let binds expr) arg) = change $ Let binds (App expr arg)
+
appprop
c (App (Let binds expr) arg) = change $ Let binds (App expr arg)
-- Propagate the application into each of the alternatives
-- Propagate the application into each of the alternatives
-
beta
c (App (Case scrut b ty alts) arg) = change $ Case scrut b ty' alts'
+
appprop
c (App (Case scrut b ty alts) arg) = change $ Case scrut b ty' alts'
where
alts' = map (\(con, bndrs, expr) -> (con, bndrs, (App expr arg))) alts
ty' = CoreUtils.applyTypeToArg ty arg
-- Leave all other expressions unchanged
where
alts' = map (\(con, bndrs, expr) -> (con, bndrs, (App expr arg))) alts
ty' = CoreUtils.applyTypeToArg ty arg
-- Leave all other expressions unchanged
-
beta
c expr = return expr
+
appprop
c expr = return expr
--------------------------------
-- Case of known constructor simplification
--------------------------------
-- Case of known constructor simplification
@@
-910,6
+917,7
@@
transforms = [ ("inlinedict", inlinedict)
, ("funextract", funextract)
, ("eta", eta)
, ("beta", beta)
, ("funextract", funextract)
, ("eta", eta)
, ("beta", beta)
+ , ("appprop", appprop)
, ("castprop", castprop)
, ("letremovesimple", letremovesimple)
, ("letrec", letrec)
, ("castprop", castprop)
, ("letremovesimple", letremovesimple)
, ("letrec", letrec)