From: Matthijs Kooijman Date: Tue, 6 Apr 2010 14:50:39 +0000 (+0200) Subject: Switch order of clauses in retvalsimpl to match thesis. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=cd796dfc08504e019813a812c0184a3d03ced4db;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Switch order of clauses in retvalsimpl to match thesis. --- 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