X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=c%CE%BBash%2FCLasH%2FNormalize%2FNormalizeTypes.hs;h=a7de6dced1645a69539b4d7c0ec39b916aeaea42;hb=3deb1d21f696f8495cd99345c9677210e2a2fc79;hp=6d9ced83af43b3dff289e9334e56fe3257ff6f4d;hpb=bf9f8e9e9cfce93ae1e35cf524b371beb34f5010;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git "a/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" "b/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" index 6d9ced8..a7de6dc 100644 --- "a/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" +++ "b/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" @@ -1,45 +1,21 @@ -{-# LANGUAGE TemplateHaskell #-} module CLasH.Normalize.NormalizeTypes where - -- Standard modules import qualified Control.Monad.Trans.Writer as Writer -import qualified Control.Monad.Trans.State as State import qualified Data.Monoid as Monoid -import qualified Data.Accessor.Template -import Data.Accessor -import qualified Data.Map as Map -import Debug.Trace -- GHC API -import CoreSyn -import qualified VarSet -import Outputable ( Outputable, showSDoc, ppr ) +import qualified CoreSyn -- Local imports -import CLasH.Utils.Core.CoreShow -import CLasH.Utils.Pretty import CLasH.Translator.TranslatorTypes -- Wrap a writer around a TranslatorSession, to run a single transformation -- over a single expression and track if the expression was changed. type TransformMonad = Writer.WriterT Monoid.Any TranslatorSession --- | Transforms a CoreExpr and keeps track if it has changed. -type Transform = CoreExpr -> TransformMonad CoreExpr - --- Finds the value of a global binding, if available -getGlobalBind :: CoreBndr -> TranslatorSession (Maybe CoreExpr) -getGlobalBind bndr = do - bindings <- getA tsBindings - return $ Map.lookup bndr bindings +-- | In what context does a core expression occur? +data CoreContext = Other -- ^ Another context --- Adds a new global binding with the given value -addGlobalBind :: CoreBndr -> CoreExpr -> TranslatorSession () -addGlobalBind bndr expr = modA tsBindings (Map.insert bndr expr) - --- Returns a list of all global binders -getGlobalBinders :: TranslatorSession [CoreBndr] -getGlobalBinders = do - bindings <- getA tsBindings - return $ Map.keys bindings +-- | Transforms a CoreExpr and keeps track if it has changed. +type Transform = [CoreContext] -> CoreSyn.CoreExpr -> TransformMonad CoreSyn.CoreExpr