Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv2v
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
sv2v
Commits
8e1f2bba
Commit
8e1f2bba
authored
Feb 11, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more aggressive binop simplification
parent
465060ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
src/Convert/Simplify.hs
+15
-3
No files found.
src/Convert/Simplify.hs
View file @
8e1f2bba
...
...
@@ -113,9 +113,14 @@ convertExpr info (Mux cc aa bb) =
bb'
=
convertExpr
info
bb
cc'
=
convertExpr
info
cc
convertExpr
info
(
BinOp
op
e1
e2
)
=
simplifyStep
$
BinOp
op
(
convertExpr
info
e1
)
(
convertExpr
info
e2
)
case
simplifyStep
$
BinOp
op
e1'Sub
e2'Sub
of
Number
n
->
Number
n
_
->
simplifyStep
$
BinOp
op
e1'
e2'
where
e1'
=
convertExpr
info
e1
e2'
=
convertExpr
info
e2
e1'Sub
=
substituteIdent
info
e1'
e2'Sub
=
substituteIdent
info
e2'
convertExpr
info
(
UniOp
op
expr
)
=
simplifyStep
$
UniOp
op
$
convertExpr
info
expr
convertExpr
info
(
Repeat
expr
exprs
)
=
...
...
@@ -138,3 +143,10 @@ substitute scopes expr =
Just
(
_
,
_
,
e
)
->
e
substitute'
other
=
traverseSinglyNestedExprs
substitute'
other
substituteIdent
::
Scopes
Expr
->
Expr
->
Expr
substituteIdent
scopes
(
Ident
x
)
=
case
lookupElem
scopes
x
of
Just
(
_
,
_
,
n
@
Number
{})
->
n
_
->
Ident
x
substituteIdent
_
other
=
other
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment