From e09aea48e04c3c7f2d361e32b78e4296dde130de Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Sat, 24 Dec 2022 01:01:33 -0700 Subject: [PATCH] type inference for localparams performed lazily The implicit type of a localparam is not always needed. This improves performance when complex localparam expressions are processed. --- src/Convert/TypeOf.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Convert/TypeOf.hs b/src/Convert/TypeOf.hs index 9ecbc2f..932dd8c 100644 --- a/src/Convert/TypeOf.hs +++ b/src/Convert/TypeOf.hs @@ -22,6 +22,7 @@ module Convert.TypeOf (convert) where +import Control.Monad.State.Strict import Data.Tuple (swap) import Convert.ExprUtils (dimensionsSize, endianCondRange, simplify) @@ -71,7 +72,8 @@ traverseDeclM decl = do -- rewrite and store a non-genvar data declaration's type information insertType :: Identifier -> Type -> ST () insertType ident typ = do - typ' <- scopeType typ + -- hack to make this evaluation lazy + typ' <- gets $ evalState $ scopeType typ insertElem ident typ' -- convert TypeOf in a ModuleItem