From e74b5270eaa6133386aa5a793700acf079dfc97d Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 14 Aug 2009 15:29:12 +0200 Subject: [PATCH] Move flattenLets from Normalize to CoreTools. --- "c\316\273ash/CLasH/Normalize.hs" | 15 --------------- "c\316\273ash/CLasH/Utils/Core/CoreTools.hs" | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 8cbebad..53bec02 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -620,18 +620,3 @@ splitNormalized expr = (args, binds, res) res = case resexpr of (Var x) -> x _ -> error $ "Normalize.splitNormalized: Not in normal form: " ++ pprString expr ++ "\n" - --- | Flattens nested lets into a single list of bindings. The expression --- passed does not have to be a let expression, if it isn't an empty list of --- bindings is returned. -flattenLets :: - CoreExpr -- ^ The expression to flatten. - -> ([Binding], CoreExpr) -- ^ The bindings and resulting expression. -flattenLets (Let binds expr) = - (bindings ++ bindings', expr') - where - -- Recursively flatten the contained expression - (bindings', expr') =flattenLets expr - -- Flatten our own bindings to remove the Rec / NonRec constructors - bindings = CoreSyn.flattenBinds [binds] -flattenLets expr = ([], expr) diff --git "a/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" "b/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" index d8f4289..21c5e14 100644 --- "a/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" +++ "b/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" @@ -298,6 +298,21 @@ hasStateType expr = case getType expr of Just ty -> isStateType ty +-- | Flattens nested lets into a single list of bindings. The expression +-- passed does not have to be a let expression, if it isn't an empty list of +-- bindings is returned. +flattenLets :: + CoreSyn.CoreExpr -- ^ The expression to flatten. + -> ([Binding], CoreSyn.CoreExpr) -- ^ The bindings and resulting expression. +flattenLets (CoreSyn.Let binds expr) = + (bindings ++ bindings', expr') + where + -- Recursively flatten the contained expression + (bindings', expr') =flattenLets expr + -- Flatten our own bindings to remove the Rec / NonRec constructors + bindings = CoreSyn.flattenBinds [binds] +flattenLets expr = ([], expr) + -- | A class of things that (optionally) have a core Type. The type is -- optional, since Type expressions don't have a type themselves. class TypedThing t where -- 2.30.2