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
Merge requests
!25
Misc. improvements
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Misc. improvements
misc
into
main
Overview
0
Commits
21
Pipelines
0
Changes
1
Merged
rarbore2
requested to merge
misc
into
main
10 months ago
Overview
0
Commits
21
Pipelines
0
Changes
1
Expand
Emit non-zero array constants properly
Emit only actually used array constants per runtime wrapper
Juno CLI
Use repr(C) structs for product types
Minimal implementation of SROA
TODO: inlining, codegen cast, intrinsics, dynamic constant math
Edited
9 months ago
by
rarbore2
0
0
Merge request reports
Viewing commit
fcfe3409
Prev
Next
Show latest version
1 file
+
44
−
2
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
fcfe3409
assemble old to new id mapping
· fcfe3409
Russel Arbore
authored
9 months ago
hercules_opt/src/sroa.rs
+
44
−
2
Options
extern
crate
bitvec
;
extern
crate
bitvec
;
extern
crate
hercules_ir
;
extern
crate
hercules_ir
;
use
std
::
collections
::
HashMap
;
use
self
::
bitvec
::
prelude
::
*
;
use
self
::
bitvec
::
prelude
::
*
;
use
self
::
hercules_ir
::
dataflow
::
*
;
use
self
::
hercules_ir
::
dataflow
::
*
;
@@ -195,8 +197,48 @@ pub fn sroa(
@@ -195,8 +197,48 @@ pub fn sroa(
let
to_replace
=
sroa_dfs
(
constant_node_id
,
function
,
def_use
);
let
to_replace
=
sroa_dfs
(
constant_node_id
,
function
,
def_use
);
println!
(
"{:?}"
,
to_replace
);
println!
(
"{:?}"
,
to_replace
);
// Assemble a mapping from old nodes acting on the product constant to
// Assemble a mapping from old nodes IDs acting on the product constant
// new nodes operating on the field constants.
// 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.
// Replace the old nodes with the new nodes.
}
}
Loading