clash 0.1.0.1 → 0.1.0.2
raw patch · 3 files changed
+37/−27 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CLasH/Normalize.hs +11/−8
- CLasH/Utils/GhcTools.hs +25/−18
- clash.cabal +1/−1
CLasH/Normalize.hs view
@@ -380,7 +380,7 @@ -- We could use is_applicable here instead of is_fun, but I think -- arguments to functions could only have forall typing when existential -- typing is enabled. Not sure, though.- doarg arg | not (is_simple arg) && is_fun arg = do+ doarg arg | not (is_simple arg) && is_fun arg && not (has_free_tyvars arg) = do -- Create a new top level binding that binds the argument. Its body will -- be extended with lambda expressions, to take any free variables used -- by the argument expression.@@ -410,15 +410,14 @@ -- Make sure the scrutinee of a case expression is a local variable -- reference. scrutsimpl :: Transform--- Don't touch scrutinees that are already simple-scrutsimpl c expr@(Case (Var _) _ _ _) = return expr--- Replace all other cases with a let that binds the scrutinee and a new+-- Replace a case expression with a let that binds the scrutinee and a new -- simple scrutinee, but only when the scrutinee is representable (to prevent -- loops with inlinenonrep, though I don't think a non-representable scrutinee--- will be supported anyway...) +-- will be supported anyway...) and is not a local variable already. scrutsimpl c expr@(Case scrut b ty alts) = do repr <- isRepr scrut- if repr+ local_var <- Trans.lift $ is_local_var scrut+ if repr && not local_var then do id <- Trans.lift $ mkBinderFor scrut "scrut" change $ Let (NonRec id scrut) (Case (Var id) b ty alts)@@ -753,7 +752,7 @@ -- that is fully applied (i.e., dos not have a function type) but is not -- representable. We apply in any context, since non-representable -- expressions are generally left alone and can occur anywhere.-inlinenonrepresult context expr | not (is_fun expr) =+inlinenonrepresult context expr | not (is_applicable expr) && not (has_free_tyvars expr) = case collectArgs expr of (Var f, args) | not (Id.isDictId f) -> do repr <- isRepr expr@@ -821,6 +820,10 @@ -- Leave all other expressions unchanged inlinenonrepresult c expr = return expr +----------------------------------------------------------------+-- Type-class transformations+----------------------------------------------------------------+ -------------------------------- -- ClassOp resolution --------------------------------@@ -952,7 +955,7 @@ -- What transforms to run? transforms = [ ("inlinedict", inlinedict) , ("inlinetoplevel", inlinetoplevel)- -- , ("inlinenonrepresult", inlinenonrepresult)+ , ("inlinenonrepresult", inlinenonrepresult) , ("knowncase", knowncase) , ("classopresolution", classopresolution) , ("argprop", argprop)
CLasH/Utils/GhcTools.hs view
@@ -19,6 +19,7 @@ import qualified Serialized import qualified Var import qualified Outputable+import Outputable(($+$), (<+>), nest, empty, text, vcat) import qualified Class -- Local Imports@@ -27,6 +28,11 @@ import CLasH.Translator.Annotations import CLasH.Utils +-- How far to indent the values after a Foo: header+align = 20+-- How far to indent all lines after the first+indent = 5+ listBindings :: FilePath -> [FilePath] -> IO () listBindings libdir filenames = do (cores,_,_) <- loadModules libdir filenames Nothing@@ -37,27 +43,28 @@ mapM listClass classes return () +-- Slightly different version of hang, that always uses vcat instead of+-- sep, so the first line of d2 preserves its nesting.+hang' d1 n d2 = vcat [d1, nest n d2]+ listBinding :: (CoreSyn.CoreBndr, CoreSyn.CoreExpr) -> IO ()-listBinding (b, e) = do- putStr "\nBinder: "- putStr $ show b ++ "[" ++ show (Var.varUnique b) ++ "]"- putStr "\nType of Binder: \n"- putStr $ Outputable.showSDoc $ Outputable.ppr $ Var.varType b- putStr "\n\nExpression: \n"- putStr $ prettyShow e- putStr "\n\n"- putStr $ Outputable.showSDoc $ Outputable.ppr e- putStr "\n\nType of Expression: \n"- putStr $ Outputable.showSDoc $ Outputable.ppr $ CoreUtils.exprType e- putStr "\n\n"+listBinding (b, e) = putStr $ Outputable.showSDoc $+ (text "Binder:") <+> (text $ show b ++ "[" ++ show (Var.varUnique b) ++ "]")+ $+$ nest indent (+ hang' (text "Type of Binder:") align (Outputable.ppr $ Var.varType b)+ $+$ hang' (text "Expression:") align (text $ prettyShow e)+ $+$ nest align (Outputable.ppr e)+ $+$ hang' (text "Type of Expression:") align (Outputable.ppr $ CoreUtils.exprType e)+ )+ $+$ (text "\n") -- Add an empty line listClass :: Class.Class -> IO ()-listClass c = do- putStr "\nClass: "- putStr $ show (Class.className c)- putStr "\nSelectors: "- putStr $ show (Class.classSelIds c)- putStr "\n"+listClass c = putStr $ Outputable.showSDoc $+ (text "Class:") <+> (text $ show (Class.className c))+ $+$ nest indent (+ hang' (text "Selectors:") align (text $ show (Class.classSelIds c))+ )+ $+$ (text "\n") -- Add an empty line -- | Show the core structure of the given binds in the given file. listBind :: FilePath -> [FilePath] -> String -> IO ()
clash.cabal view
@@ -1,5 +1,5 @@ name: clash-version: 0.1.0.1+version: 0.1.0.2 build-type: Simple synopsis: CAES Language for Synchronous Hardware (CLaSH) description: CLaSH is a tool-chain/language to translate subsets of