From: Matthijs Kooijman Date: Fri, 14 Aug 2009 13:19:28 +0000 (+0200) Subject: Add empty let removal normalization pass. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=c4aa528c379ea8c2fa2fb0d5f8d8c70ba41fb699;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add empty let removal normalization pass. --- diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 18010cf..8cbebad 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -185,6 +185,17 @@ letflat expr = return expr -- Perform this transform everywhere letflattop = everywhere ("letflat", letflat) +-------------------------------- +-- empty let removal +-------------------------------- +-- Remove empty (recursive) lets +letremove, letremovetop :: Transform +letremove (Let (Rec []) res) = change $ res +-- Leave all other expressions unchanged +letremove expr = return expr +-- Perform this transform everywhere +letremovetop = everywhere ("letremove", letremove) + -------------------------------- -- Simple let binding removal -------------------------------- @@ -556,7 +567,7 @@ funextracttop = everywhere ("funextract", funextract) -- What transforms to run? -transforms = [argproptop, funextracttop, etatop, betatop, castproptop, letremovesimpletop, letderectop, letsimpltop, letflattop, scrutsimpltop, casesimpltop, caseremovetop, inlinenonreptop, appsimpltop, letmergetop, letremoveunusedtop, castsimpltop] +transforms = [argproptop, funextracttop, etatop, betatop, castproptop, letremovesimpletop, letderectop, letremovetop, letsimpltop, letflattop, scrutsimpltop, casesimpltop, caseremovetop, inlinenonreptop, appsimpltop, letmergetop, letremoveunusedtop, castsimpltop] -- | Returns the normalized version of the given function. getNormalized ::