From: Matthijs Kooijman Date: Tue, 6 Apr 2010 15:11:45 +0000 (+0200) Subject: Add variant of splitNormalized for non-representable expressions. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=0ebe9a48cf38f84ea2a365f776c854947fd90a30;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add variant of splitNormalized for non-representable expressions. --- 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"