From 0ebe9a48cf38f84ea2a365f776c854947fd90a30 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 6 Apr 2010 17:11:45 +0200 Subject: [PATCH] Add variant of splitNormalized for non-representable expressions. --- "c\316\273ash/CLasH/Normalize.hs" | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 85be0d0..8e6926a 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -852,14 +852,21 @@ normalizeExpr what expr = do return expr' -- | Split a normalized expression into the argument binders, top level --- bindings and the result binder. +-- bindings and the result binder. This function returns an error if +-- the type of the expression is not representable. splitNormalized :: CoreExpr -- ^ The normalized expression -> ([CoreBndr], [Binding], CoreBndr) -splitNormalized expr = (args, binds, res) +splitNormalized expr = + case splitNormalizedNonRep expr of + (args, binds, Var res) -> (args, binds, res) + _ -> error $ "Normalize.splitNormalized: Not in normal form: " ++ pprString expr ++ "\n" + +-- Split a normalized expression, whose type can be unrepresentable. +splitNormalizedNonRep:: + CoreExpr -- ^ The normalized expression + -> ([CoreBndr], [Binding], CoreExpr) +splitNormalizedNonRep expr = (args, binds, resexpr) where (args, letexpr) = CoreSyn.collectBinders expr (binds, resexpr) = flattenLets letexpr - res = case resexpr of - (Var x) -> x - _ -> error $ "Normalize.splitNormalized: Not in normal form: " ++ pprString expr ++ "\n" -- 2.30.2