Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
Hercules
Commits
fcfe3409
Commit
fcfe3409
authored
10 months ago
by
Russel Arbore
Browse files
Options
Downloads
Patches
Plain Diff
assemble old to new id mapping
parent
6c8dca75
No related branches found
No related tags found
1 merge request
!25
Misc. improvements
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hercules_opt/src/sroa.rs
+44
-2
44 additions, 2 deletions
hercules_opt/src/sroa.rs
with
44 additions
and
2 deletions
hercules_opt/src/sroa.rs
+
44
−
2
View file @
fcfe3409
extern
crate
bitvec
;
extern
crate
hercules_ir
;
use
std
::
collections
::
HashMap
;
use
self
::
bitvec
::
prelude
::
*
;
use
self
::
hercules_ir
::
dataflow
::
*
;
...
...
@@ -195,8 +197,48 @@ pub fn sroa(
let
to_replace
=
sroa_dfs
(
constant_node_id
,
function
,
def_use
);
println!
(
"{:?}"
,
to_replace
);
// Assemble a mapping from old nodes acting on the product constant to
// new nodes operating on the field constants.
// Assemble a mapping from old nodes IDs acting on the product constant
// to new nodes IDs operating on the field constants.
let
map
:
HashMap
<
NodeID
,
Vec
<
NodeID
>>
=
to_replace
.iter
()
.map
(|
old_id
|
match
function
.nodes
[
old_id
.idx
()]
{
Node
::
Phi
{
control
:
_
,
data
:
_
,
}
|
Node
::
Reduce
{
control
:
_
,
init
:
_
,
reduct
:
_
,
}
|
Node
::
Constant
{
id
:
_
}
|
Node
::
Ternary
{
op
:
_
,
first
:
_
,
second
:
_
,
third
:
_
,
}
|
Node
::
Write
{
collect
:
_
,
data
:
_
,
indices
:
_
,
}
=>
{
let
new_ids
=
(
0
..
constant_fields
.len
())
.map
(|
_
|
{
let
id
=
NodeID
::
new
(
function
.nodes
.len
());
function
.nodes
.push
(
Node
::
Start
);
id
})
.collect
();
(
*
old_id
,
new_ids
)
}
Node
::
Read
{
collect
:
_
,
indices
:
_
,
}
=>
(
*
old_id
,
vec!
[]),
_
=>
panic!
(
"PANIC: Invalid node using a constant product found during SROA."
),
})
.collect
();
// Replace the old nodes with the new nodes.
}
...
...
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