Commit 39f0e9b4 by Zachary Snow

minor perf optimization

parent 336b180d
...@@ -55,8 +55,7 @@ traverseStmtM :: Stmt -> State Info Stmt ...@@ -55,8 +55,7 @@ traverseStmtM :: Stmt -> State Info Stmt
traverseStmtM stmt = traverseStmtExprsM traverseExprM stmt traverseStmtM stmt = traverseStmtExprsM traverseExprM stmt
traverseExprM :: Expr -> State Info Expr traverseExprM :: Expr -> State Info Expr
traverseExprM = traverseNestedExprsM $ stately converter traverseExprM = traverseNestedExprsM $ stately convertExpr
where converter a b = simplify $ (traverseNestedExprs (convertExpr a) b)
-- elaborate integer atom types to have explicit dimensions -- elaborate integer atom types to have explicit dimensions
elaborateType :: Type -> Type elaborateType :: Type -> Type
......
...@@ -71,6 +71,8 @@ convertExpr info (Mux cc aa bb) = ...@@ -71,6 +71,8 @@ convertExpr info (Mux cc aa bb) =
where where
before = substitute info cc before = substitute info cc
after = simplify before after = simplify before
convertExpr _ (other @ Repeat{}) = traverseNestedExprs simplify other
convertExpr _ (other @ Concat{}) = simplify other
convertExpr _ other = other convertExpr _ other = other
substitute :: Info -> Expr -> Expr substitute :: Info -> Expr -> Expr
......
...@@ -76,7 +76,7 @@ castFn e sg = ...@@ -76,7 +76,7 @@ castFn e sg =
Function (Just Automatic) t fnName [decl] [Return $ Ident inp] Function (Just Automatic) t fnName [decl] [Return $ Ident inp]
where where
inp = "inp" inp = "inp"
r = (BinOp Sub e (Number "1"), Number "0") r = (simplify $ BinOp Sub e (Number "1"), Number "0")
t = IntegerVector TLogic sg [r] t = IntegerVector TLogic sg [r]
fnName = castFnName e sg fnName = castFnName e sg
decl = Variable Input t inp [] Nothing decl = Variable Input t inp [] Nothing
......
...@@ -349,9 +349,7 @@ traverseAssertionExprsM mapper = assertionMapper ...@@ -349,9 +349,7 @@ traverseAssertionExprsM mapper = assertionMapper
propExprMapper (PropExprIff p1 p2) = propExprMapper (PropExprIff p1 p2) =
ppMapper PropExprIff p1 p2 ppMapper PropExprIff p1 p2
propSpecMapper (PropertySpec ms me pe) = do propSpecMapper (PropertySpec ms me pe) = do
me' <- case me of me' <- maybeExprMapper me
Nothing -> return Nothing
Just e -> mapper e >>= return . Just
pe' <- propExprMapper pe pe' <- propExprMapper pe
return $ PropertySpec ms me' pe' return $ PropertySpec ms me' pe'
assertionExprMapper (Left e) = assertionExprMapper (Left e) =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment