From cd796dfc08504e019813a812c0184a3d03ced4db Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 6 Apr 2010 16:50:39 +0200 Subject: [PATCH] Switch order of clauses in retvalsimpl to match thesis. --- "c\316\273ash/CLasH/Normalize.hs" | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 36990df..85be0d0 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -128,6 +128,16 @@ castsimpltop = everywhere ("castsimpl", castsimpl) -- transformation ensures that the lambda abstractions always contain a -- recursive let and that, when the return value is representable, the -- let contains a local variable reference in its body. +retvalsimpl c expr | all (== LambdaBody) c && not (is_lam expr) && not (is_let expr) = do + local_var <- Trans.lift $ is_local_var expr + repr <- isRepr expr + if not local_var && repr + then do + id <- Trans.lift $ mkBinderFor expr "res" + change $ Let (Rec [(id, expr)]) (Var id) + else + return expr + retvalsimpl c expr@(Let (Rec binds) body) | all (== LambdaBody) c = do -- Don't extract values that are already a local variable, to prevent -- loops with ourselves. @@ -142,15 +152,6 @@ retvalsimpl c expr@(Let (Rec binds) body) | all (== LambdaBody) c = do else return expr -retvalsimpl c expr | all (== LambdaBody) c && not (is_lam expr) && not (is_let expr) = do - local_var <- Trans.lift $ is_local_var expr - repr <- isRepr expr - if not local_var && repr - then do - id <- Trans.lift $ mkBinderFor expr "res" - change $ Let (Rec [(id, expr)]) (Var id) - else - return expr -- Leave all other expressions unchanged retvalsimpl c expr = return expr -- 2.30.2