Skip to content
Snippets Groups Projects
Commit fcfe3409 authored by Russel Arbore's avatar Russel Arbore
Browse files

assemble old to new id mapping

parent 6c8dca75
No related branches found
No related tags found
1 merge request!25Misc. improvements
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.
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment