From: Matthijs Kooijman Date: Mon, 17 Aug 2009 14:30:08 +0000 (+0200) Subject: Add (temporary) simplres normalization pass. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=dda227b02df4fc23e7fd658dd9e5a7ee93f494bc;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add (temporary) simplres normalization pass. This pass ensures that trivial top level bindings that only reference another top level binder still get normalized correctly. --- diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 4366949..7d28473 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -637,6 +637,22 @@ funextract expr = return expr -- Perform this transform everywhere funextracttop = everywhere ("funextract", funextract) +-------------------------------- +-- Ensure that a function that just returns another function (or rather, +-- another top-level binder) is still properly normalized. This is a temporary +-- solution, we should probably integrate this pass with lambdasimpl and +-- letsimpl instead. +-------------------------------- +simplrestop expr@(Lam _ _) = return expr +simplrestop expr@(Let _ _) = return expr +simplrestop expr = do + local_var <- Trans.lift $ is_local_var expr + if local_var + then + return expr + else do + id <- Trans.lift $ mkBinderFor expr "res" + change $ Let (NonRec id expr) (Var id) -------------------------------- -- End of transformations -------------------------------- @@ -645,7 +661,7 @@ funextracttop = everywhere ("funextract", funextract) -- What transforms to run? -transforms = [inlinetopleveltop, argproptop, funextracttop, etatop, betatop, castproptop, letremovesimpletop, letderectop, letremovetop, letsimpltop, letflattop, scrutsimpltop, casesimpltop, caseremovetop, inlinenonreptop, appsimpltop, letremoveunusedtop, castsimpltop, lambdasimpltop] +transforms = [inlinetopleveltop, argproptop, funextracttop, etatop, betatop, castproptop, letremovesimpletop, letderectop, letremovetop, letsimpltop, letflattop, scrutsimpltop, casesimpltop, caseremovetop, inlinenonreptop, appsimpltop, letremoveunusedtop, castsimpltop, lambdasimpltop, simplrestop] -- | Returns the normalized version of the given function. getNormalized ::