From: Matthijs Kooijman Date: Fri, 14 Aug 2009 12:17:51 +0000 (+0200) Subject: Make letsimpl work on and generate a non-recursive let. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=40f6fa36c61009396934942a580be62d8cc58da2;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Make letsimpl work on and generate a non-recursive let. Previously, letsimpl would work on a recursive let only, and add a new binding to that recursive let. Now, it works on any let and produces a new non-recursive let. --- diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 6eee47b..dd8244d 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -148,7 +148,7 @@ letderectop = everywhere ("letderec", letderec) letsimpl, letsimpltop :: Transform -- Put the "in ..." value of a let in its own binding, but not when the -- expression is already a local variable, or not representable (to prevent loops with inlinenonrep). -letsimpl expr@(Let (Rec binds) res) = do +letsimpl expr@(Let binds res) = do repr <- isRepr res local_var <- Trans.lift $ is_local_var res if not local_var && repr @@ -156,8 +156,7 @@ letsimpl expr@(Let (Rec binds) res) = do -- If the result is not a local var already (to prevent loops with -- ourselves), extract it. id <- Trans.lift $ mkBinderFor res "foo" - let bind = (id, res) - change $ Let (Rec (bind:binds)) (Var id) + change $ Let binds (Let (NonRec id res) (Var id)) else -- If the result is already a local var, don't extract it. return expr