From: Matthijs Kooijman Date: Fri, 5 Mar 2010 17:20:51 +0000 (+0100) Subject: Let inlinetoplevel use getNormalized_maybe. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=bb9442c6efb3b7dc6b16d56234e4b064c45bfb75;hp=c499e901a25eb7df0bfac03d57ee3401ad6cb7e7;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Let inlinetoplevel use getNormalized_maybe. This makes the transformation slightly simpler and prepares it for inlining dictionaries next. --- diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 82cc89b..91033b5 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -338,23 +338,19 @@ inlinetoplevel, inlinetopleveltop :: Transform -- Any system name is candidate for inlining. Never inline user-defined -- functions, to preserve structure. inlinetoplevel expr@(Var f) | not $ isUserDefined f = do - norm <- isNormalizeable f - -- See if this is a top level binding for which we have a body - body_maybe <- Trans.lift $ getGlobalBind f - if norm && Maybe.isJust body_maybe - then do - -- Get the normalized version - norm <- Trans.lift $ getNormalized f - if needsInline norm - then do - -- Regenerate all uniques in the to-be-inlined expression - norm_uniqued <- Trans.lift $ genUniques norm - change norm_uniqued - else - return expr - else + norm_maybe <- Trans.lift $ getNormalized_maybe f + case norm_maybe of -- No body or not normalizeable. - return expr + Nothing -> return expr + Just norm -> if needsInline norm then do + -- Regenerate all uniques in the to-be-inlined expression + norm_uniqued <- Trans.lift $ genUniques norm + -- And replace the variable reference with the unique'd body. + change norm_uniqued + else + -- No need to inline + return expr + -- Leave all other expressions unchanged inlinetoplevel expr = return expr inlinetopleveltop = everywhere ("inlinetoplevel", inlinetoplevel)