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
!148
Do DC subst in float-collections
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Do DC subst in float-collections
fix-float
into
main
Overview
0
Commits
1
Pipelines
1
Changes
1
Merged
rarbore2
requested to merge
fix-float
into
main
2 months ago
Overview
0
Commits
1
Pipelines
1
Changes
1
Expand
Substitute dynamic constants when floating collections out of a function.
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
954339eb
1 commit,
2 months ago
1 file
+
14
−
5
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
hercules_opt/src/float_collections.rs
+
14
−
5
Options
use
std
::
collections
::
BTreeMap
;
use
std
::
collections
::
{
BTreeMap
,
HashMap
}
;
use
hercules_ir
::
*
;
use
hercules_ir
::
*
;
@@ -83,10 +83,6 @@ pub fn float_collections(
@@ -83,10 +83,6 @@ pub fn float_collections(
.map
(|(
idx
,
node
)|
(
NodeID
::
new
(
idx
),
node
.clone
()))
.map
(|(
idx
,
node
)|
(
NodeID
::
new
(
idx
),
node
.clone
()))
.collect
();
.collect
();
let
success
=
editors
.get_mut
(
&
caller
)
.unwrap
()
.edit
(|
mut
edit
|
{
let
success
=
editors
.get_mut
(
&
caller
)
.unwrap
()
.edit
(|
mut
edit
|
{
let
cons_ids
:
Vec
<
_
>
=
cons
.iter
()
.map
(|(
_
,
node
)|
edit
.add_node
(
node
.clone
()))
.collect
();
for
(
id
,
node
)
in
calls
{
for
(
id
,
node
)
in
calls
{
let
Node
::
Call
{
let
Node
::
Call
{
control
,
control
,
@@ -97,6 +93,19 @@ pub fn float_collections(
@@ -97,6 +93,19 @@ pub fn float_collections(
else
{
else
{
panic!
()
panic!
()
};
};
let
dc_args
=
(
0
..
dynamic_constants
.len
())
.map
(|
i
|
edit
.add_dynamic_constant
(
DynamicConstant
::
Parameter
(
i
)));
let
substs
=
dc_args
.zip
(
dynamic_constants
.iter
()
.map
(|
id
|
*
id
))
.collect
::
<
HashMap
<
_
,
_
>>
();
let
cons_ids
:
Vec
<
_
>
=
cons
.iter
()
.map
(|(
_
,
node
)|
{
let
mut
node
=
node
.clone
();
substitute_dynamic_constants_in_node
(
&
substs
,
&
mut
node
,
&
mut
edit
);
edit
.add_node
(
node
)
})
.collect
();
let
mut
args
=
Vec
::
from
(
args
);
let
mut
args
=
Vec
::
from
(
args
);
args
.extend
(
cons_ids
.iter
());
args
.extend
(
cons_ids
.iter
());
let
new_call
=
edit
.add_node
(
Node
::
Call
{
let
new_call
=
edit
.add_node
(
Node
::
Call
{
Loading