X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=c%CE%BBash%2FCLasH%2FNormalize.hs;h=7d28473e0d2b10bd09ca435ee6788faf8c8b0dee;hb=dda227b02df4fc23e7fd658dd9e5a7ee93f494bc;hp=4366949a524cb6bbb28e0a84baad08cb8e214fc7;hpb=cda7d41d556f8cc179cf29579b213dc480ab5dba;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git 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 ::