X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=c%CE%BBash%2FCLasH%2FNormalize%2FNormalizeTypes.hs;h=6d9ced83af43b3dff289e9334e56fe3257ff6f4d;hb=bf9f8e9e9cfce93ae1e35cf524b371beb34f5010;hp=56cba91a411666a078e0eed852ffe5c084fea0f9;hpb=ec4378a8a765c5a064b5cbed347b40c353c778a0;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 56cba91..6d9ced8 100644 --- "a/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" +++ "b/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" @@ -1,5 +1,5 @@ {-# LANGUAGE TemplateHaskell #-} -module NormalizeTypes where +module CLasH.Normalize.NormalizeTypes where -- Standard modules @@ -13,45 +13,33 @@ import Debug.Trace -- GHC API import CoreSyn -import qualified UniqSupply import qualified VarSet import Outputable ( Outputable, showSDoc, ppr ) -- Local imports -import CoreShow -import Pretty -import VHDLTypes -- For TypeState - -data TransformState = TransformState { - tsUniqSupply_ :: UniqSupply.UniqSupply - , tsBindings_ :: Map.Map CoreBndr CoreExpr - , tsNormalized_ :: VarSet.VarSet -- ^ The binders that have been normalized - , tsType_ :: TypeState -} - -$( Data.Accessor.Template.deriveAccessors ''TransformState ) - --- A session of multiple transformations over multiple expressions -type TransformSession = (State.State TransformState) --- Wrap a writer around a TransformSession, to run a single transformation +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 TransformSession +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 -> TransformSession (Maybe CoreExpr) +getGlobalBind :: CoreBndr -> TranslatorSession (Maybe CoreExpr) getGlobalBind bndr = do bindings <- getA tsBindings return $ Map.lookup bndr bindings -- Adds a new global binding with the given value -addGlobalBind :: CoreBndr -> CoreExpr -> TransformSession () +addGlobalBind :: CoreBndr -> CoreExpr -> TranslatorSession () addGlobalBind bndr expr = modA tsBindings (Map.insert bndr expr) -- Returns a list of all global binders -getGlobalBinders :: TransformSession [CoreBndr] +getGlobalBinders :: TranslatorSession [CoreBndr] getGlobalBinders = do bindings <- getA tsBindings return $ Map.keys bindings