Commit 91a45ce2 by Zachary Snow

constant folding evaluates localparam casts where possible

parent a6b872bf
{-# LANGUAGE PatternSynonyms #-}
{- sv2v {- sv2v
- Author: Zachary Snow <zach@zachjs.com> - Author: Zachary Snow <zach@zachjs.com>
- -
...@@ -44,7 +45,15 @@ traverseDeclM decl = do ...@@ -44,7 +45,15 @@ traverseDeclM decl = do
_ -> return () _ -> return ()
return decl' return decl'
pattern SimpleVector :: Signing -> Integer -> Integer -> Type
pattern SimpleVector sg l r <- IntegerVector _ sg [(RawNum l, RawNum r)]
insertExpr :: Identifier -> Expr -> Scoper Expr () insertExpr :: Identifier -> Expr -> Scoper Expr ()
insertExpr ident (Cast (Left (SimpleVector sg l r)) (Number n)) =
insertExpr ident $ Number $ numberCast signed size n
where
signed = sg == Signed
size = fromIntegral $ abs $ l - r + 1
insertExpr ident expr = do insertExpr ident expr = do
expr' <- substituteExprM expr expr' <- substituteExprM expr
when (isSimpleExpr expr') $ insertElem ident expr' when (isSimpleExpr expr') $ insertElem ident expr'
......
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