Skip to content

Commit

Permalink
(isla-axiomatic/graph) rustfmt
Browse files Browse the repository at this point in the history
bensimner committed Mar 20, 2024
1 parent 5098a62 commit 0e6ae65
Showing 4 changed files with 18 additions and 26 deletions.
6 changes: 3 additions & 3 deletions isla-axiomatic/src/graph/graph_events.rs
Original file line number Diff line number Diff line change
@@ -673,13 +673,13 @@ pub fn parse_relname_opt(rel: &str) -> (&str, RelType) {
let mut relty = RelType { trans: RelTransType::Normal, preferred: Vec::new() };

if rel.ends_with('-') {
relname = &rel[0 .. rel.len()-1];
relname = &rel[0..rel.len() - 1];
relty.trans = RelTransType::TransReduction;
} else if rel.ends_with('+') {
relname = &rel[0 .. rel.len()-1];
relname = &rel[0..rel.len() - 1];
relty.trans = RelTransType::TransClosure;
} else if rel.ends_with('~') {
relname = &rel[0 .. rel.len()-1];
relname = &rel[0..rel.len() - 1];
} else {
let trans_reductions: HashSet<String> =
GraphOpts::DEFAULT_REL_TRANSITIVE_REDUCE.iter().cloned().map(String::from).collect();
24 changes: 9 additions & 15 deletions isla-axiomatic/src/graph/graph_opts.rs
Original file line number Diff line number Diff line change
@@ -38,23 +38,17 @@ impl GraphOpts {
/// can explicitly do this by postfixing a relation with -
/// can also do the opposite by postfixing a relation with + to get the transitive closure instead.
pub const DEFAULT_REL_TRANSITIVE_REDUCE: &'static [&'static str] =
&[
"po", "iio", "fpo", "instruction-order",
"co", "wco",
"ctrl"
];
&["po", "iio", "fpo", "instruction-order", "co", "wco", "ctrl"];

/// by default we do not show relations where a higher-priority one overrides it
/// i.e. if e1 R e2 and e1 R' e2 and R' is higher priority then do not draw e1 R e2 in the graph.
/// the below is a list of (R', R) where R' is the higher-priority one
pub const DEFAULT_REL_PRIORITY: &'static [(&'static str, &'static str)] =
&[
// dependencies are subsets of po so don't render po between them separately
("addr", "po"),
("ctrl", "po"),
("data", "po"),

// co is a subset of wco
("co", "wco"),
];
pub const DEFAULT_REL_PRIORITY: &'static [(&'static str, &'static str)] = &[
// dependencies are subsets of po so don't render po between them separately
("addr", "po"),
("ctrl", "po"),
("data", "po"),
// co is a subset of wco
("co", "wco"),
];
}
11 changes: 5 additions & 6 deletions isla-axiomatic/src/graph/grid_layout.rs
Original file line number Diff line number Diff line change
@@ -266,12 +266,11 @@ fn transitively_close(edges: &HashSet<(String, String)>) -> HashSet<(String, Str
}

pub fn simplify_edges(relty: &RelType, edges: &HashSet<(String, String)>) -> HashSet<(String, String)> {
let modified =
match relty.trans {
RelTransType::TransReduction => transitively_reduce(edges),
RelTransType::TransClosure => transitively_close(edges),
RelTransType::Normal => edges.clone(),
};
let modified = match relty.trans {
RelTransType::TransReduction => transitively_reduce(edges),
RelTransType::TransClosure => transitively_close(edges),
RelTransType::Normal => edges.clone(),
};

modified
}
3 changes: 1 addition & 2 deletions isla-axiomatic/src/graph/gv_backend.rs
Original file line number Diff line number Diff line change
@@ -983,8 +983,7 @@ pub fn draw_graph_gv(f: &mut dyn io::Write, graph: &Graph, _opts: &GraphOpts) ->
let edges = &rel.all_edges;

// hide edges between hidden nodes
let edges: HashSet<(String, String)> =
edges
let edges: HashSet<(String, String)> = edges
.iter()
.filter(|(from, to)| displayed_event_names.contains(from) && displayed_event_names.contains(to))
.map(|(from, to)| (from.clone(), to.clone()))

0 comments on commit 0e6ae65

Please sign in to comment.