Skip to content
Snippets Groups Projects

Misc. improvements

Merged rarbore2 requested to merge misc into main
1 file
+ 44
2
Compare changes
  • Side-by-side
  • Inline
+ 44
2
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