Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pairs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
software
pairs
Commits
32c12900
Commit
32c12900
authored
3 years ago
by
Rafael Ravedutti
Browse files
Options
Downloads
Patches
Plain Diff
Only add resize logic when size varies
Signed-off-by:
Rafael Ravedutti
<
rafaelravedutti@gmail.com
>
parent
cdfbfb11
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pairs/transformations/modules.py
+10
-3
10 additions, 3 deletions
src/pairs/transformations/modules.py
with
10 additions
and
3 deletions
src/pairs/transformations/modules.py
+
10
−
3
View file @
32c12900
...
@@ -4,6 +4,7 @@ from pairs.ir.bin_op import BinOp
...
@@ -4,6 +4,7 @@ from pairs.ir.bin_op import BinOp
from
pairs.ir.block
import
Block
from
pairs.ir.block
import
Block
from
pairs.ir.branches
import
Branch
,
Filter
from
pairs.ir.branches
import
Branch
,
Filter
from
pairs.ir.data_types
import
Type_Vector
from
pairs.ir.data_types
import
Type_Vector
from
pairs.ir.lit
import
Lit
from
pairs.ir.loops
import
While
from
pairs.ir.loops
import
While
from
pairs.ir.memory
import
Realloc
from
pairs.ir.memory
import
Realloc
from
pairs.ir.module
import
Module
,
Module_Call
from
pairs.ir.module
import
Module
,
Module_Call
...
@@ -89,6 +90,9 @@ class AddResizeLogic(Mutator):
...
@@ -89,6 +90,9 @@ class AddResizeLogic(Mutator):
for
node
in
nodes
:
for
node
in
nodes
:
if
isinstance
(
node
,
(
Array
,
Var
)):
if
isinstance
(
node
,
(
Array
,
Var
)):
capacity
=
self
.
get_capacity_for_size
(
node
)
capacity
=
self
.
get_capacity_for_size
(
node
)
elif
isinstance
(
node
,
ArrayAccess
):
# We just want to look into mutable elements, not indexes
capacity
=
self
.
lookup_capacity
([
node
.
array
])
else
:
else
:
capacity
=
self
.
lookup_capacity
(
node
.
children
())
capacity
=
self
.
lookup_capacity
(
node
.
children
())
...
@@ -99,8 +103,11 @@ class AddResizeLogic(Mutator):
...
@@ -99,8 +103,11 @@ class AddResizeLogic(Mutator):
def
mutate_Assign
(
self
,
ast_node
):
def
mutate_Assign
(
self
,
ast_node
):
for
dest
,
src
in
ast_node
.
assignments
:
for
dest
,
src
in
ast_node
.
assignments
:
if
isinstance
(
dest
,
ArrayAccess
):
if
not
isinstance
(
src
,
Lit
):
match_capacity
=
self
.
lookup_capacity
(
ast_node
.
children
())
match_capacity
=
None
if
isinstance
(
dest
,
(
ArrayAccess
,
Var
)):
match_capacity
=
self
.
lookup_capacity
([
dest
])
# Resize var is used in index, this statement should be checked for safety
# Resize var is used in index, this statement should be checked for safety
if
match_capacity
is
not
None
:
if
match_capacity
is
not
None
:
...
@@ -108,7 +115,7 @@ class AddResizeLogic(Mutator):
...
@@ -108,7 +115,7 @@ class AddResizeLogic(Mutator):
resizes
=
list
(
self
.
module_resizes
[
module
].
keys
())
resizes
=
list
(
self
.
module_resizes
[
module
].
keys
())
capacities
=
list
(
self
.
module_resizes
[
module
].
values
())
capacities
=
list
(
self
.
module_resizes
[
module
].
values
())
resize_id
=
resizes
[
capacities
.
index
(
match_capacity
)]
resize_id
=
resizes
[
capacities
.
index
(
match_capacity
)]
return
Branch
(
ast_node
.
sim
,
dest
<
match_capacity
,
return
Branch
(
ast_node
.
sim
,
src
<
match_capacity
,
blk_if
=
Block
(
ast_node
.
sim
,
ast_node
),
blk_if
=
Block
(
ast_node
.
sim
,
ast_node
),
blk_else
=
Block
(
ast_node
.
sim
,
ast_node
.
sim
.
resizes
[
resize_id
].
set
(
src
)))
blk_else
=
Block
(
ast_node
.
sim
,
ast_node
.
sim
.
resizes
[
resize_id
].
set
(
src
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment