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 (from parent 1:
2e46e22
)
Let eta expansion use the passed context instead of using notappargs.
author
Matthijs Kooijman
<matthijs@stdin.nl>
Tue, 30 Mar 2010 12:59:43 +0000
(14:59 +0200)
committer
Matthijs Kooijman
<matthijs@stdin.nl>
Tue, 30 Mar 2010 12:59:43 +0000
(14:59 +0200)
cλash/CLasH/Normalize.hs
patch
|
blob
|
history
diff --git
a/cλash/CLasH/Normalize.hs
b/cλash/CLasH/Normalize.hs
index fa6ae8c25f9f387fdcdea2b8708329463e2e6cd3..a5b2a9474d290dbb7fb6d0804c7f3c6622fb41b7 100644
(file)
--- a/
cλash/CLasH/Normalize.hs
+++ b/
cλash/CLasH/Normalize.hs
@@
-48,13
+48,20
@@
import CLasH.Utils.Pretty
-- η abstraction
--------------------------------
eta, etatop :: Transform
-- η abstraction
--------------------------------
eta, etatop :: Transform
+-- Don't apply to expressions that are applied, since that would cause
+-- us to apply to our own result indefinitely.
+eta (AppFirst:_) expr = return expr
+-- Also don't apply to arguments, since this can cause loops with
+-- funextract. This isn't the proper solution, but due to an
+-- implementation bug in notappargs, this is how it used to work so far.
+eta (AppSecond:_) expr = return expr
eta c expr | is_fun expr && not (is_lam expr) = do
let arg_ty = (fst . Type.splitFunTy . CoreUtils.exprType) expr
id <- Trans.lift $ mkInternalVar "param" arg_ty
change (Lam id (App expr (Var id)))
-- Leave all other expressions unchanged
eta c e = return e
eta c expr | is_fun expr && not (is_lam expr) = do
let arg_ty = (fst . Type.splitFunTy . CoreUtils.exprType) expr
id <- Trans.lift $ mkInternalVar "param" arg_ty
change (Lam id (App expr (Var id)))
-- Leave all other expressions unchanged
eta c e = return e
-etatop =
notappargs
("eta", eta)
+etatop =
everywhere
("eta", eta)
--------------------------------
-- β-reduction
--------------------------------
-- β-reduction