Skip to content
Snippets Groups Projects

Clean up repairable

Merged rarbore2 requested to merge repairable2 into main
Files
17
use crate::*;
/*
* Top level function to get all anti-dependencies.
*/
pub fn antideps(function: &Function, def_use: &ImmutableDefUseMap) -> Vec<(NodeID, NodeID)> {
generic_antideps(
function,
def_use,
(0..function.nodes.len()).map(NodeID::new),
)
}
/*
* Sometimes, we are only interested in anti-dependence edges involving arrays.
*/
pub fn array_antideps(
function: &Function,
def_use: &ImmutableDefUseMap,
types: &Vec<Type>,
typing: &Vec<TypeID>,
) -> Vec<(NodeID, NodeID)> {
generic_antideps(
function,
def_use,
(0..function.nodes.len())
.map(NodeID::new)
.filter(|id| types[typing[id.idx()].idx()].is_array()),
)
}
/*
* Function to assemble anti-dependence edges. Returns a list of pairs of nodes.
* The first item in the pair is the read node, and the second item is the write
* node. Take an iterator of nodes in case we want a subset of all anti-
* dependencies.
* node.
*/
fn generic_antideps<I: Iterator<Item = NodeID>>(
function: &Function,
def_use: &ImmutableDefUseMap,
nodes: I,
) -> Vec<(NodeID, NodeID)> {
pub fn antideps(function: &Function, def_use: &ImmutableDefUseMap) -> Vec<(NodeID, NodeID)> {
// Anti-dependence edges are between a write node and a read node, where
// each node uses the same array value. The read must be scheduled before
// the write to avoid incorrect compilation.
let mut antideps = vec![];
for id in nodes {
for id in (0..function.nodes.len()).map(NodeID::new) {
// Collect the reads and writes to / from this collection.
let users = def_use.get_users(id);
let reads = users.iter().filter(|user| {
@@ -78,9 +44,6 @@ fn generic_antideps<I: Iterator<Item = NodeID>>(
antideps.push((*read, *write));
}
}
// TODO: Multiple write uses should clone the collection for N - 1 of the writes.
assert!(writes.next() == None, "Can't form anti-dependencies when there are two independent writes depending on a single collection value.");
}
antideps
Loading