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

Visualize types in dot

parent dbbda86e
No related branches found
No related tags found
1 merge request!134Do dynamic constant substitution in GCM
Pipeline #201242 passed
......@@ -16,6 +16,7 @@ use crate::*;
pub fn xdot_module(
module: &ir::Module,
reverse_postorders: &Vec<Vec<NodeID>>,
typing: Option<&ModuleTyping>,
doms: Option<&Vec<DomTree>>,
fork_join_maps: Option<&Vec<HashMap<NodeID, NodeID>>>,
devices: Option<&Vec<Device>>,
......@@ -30,6 +31,7 @@ pub fn xdot_module(
write_dot(
&module,
&reverse_postorders,
typing,
doms,
fork_join_maps,
devices,
......@@ -53,6 +55,7 @@ pub fn xdot_module(
pub fn write_dot<W: Write>(
module: &ir::Module,
reverse_postorders: &Vec<Vec<NodeID>>,
typing: Option<&ModuleTyping>,
doms: Option<&Vec<DomTree>>,
fork_join_maps: Option<&Vec<HashMap<NodeID, NodeID>>>,
devices: Option<&Vec<Device>>,
......@@ -89,6 +92,7 @@ pub fn write_dot<W: Write>(
function_id,
color,
module,
typing,
&function.schedules[node_id.idx()],
w,
)?;
......@@ -249,6 +253,7 @@ fn write_node<W: Write>(
function_id: FunctionID,
color: &str,
module: &Module,
typing: Option<&ModuleTyping>,
schedules: &Vec<Schedule>,
w: &mut W,
) -> std::fmt::Result {
......@@ -331,30 +336,37 @@ fn write_node<W: Write>(
} else {
format!("{} ({})", node.upper_case_name(), suffix)
};
let xlabel = format!("{}", node_id.idx());
let mut tylabel = String::new();
if let Some(ty) = typing.map(|typing| typing[function_id.idx()][node_id.idx()]) {
module.write_type(ty, &mut tylabel)?;
}
let mut iter = schedules.into_iter();
if let Some(first) = iter.next() {
let subtitle = iter.fold(format!("{:?}", first), |b, i| format!("{}, {:?}", b, i));
let schedules = iter.fold(format!("{:?}", first), |b, i| format!("{}, {:?}", b, i));
write!(
w,
"{}_{}_{} [xlabel={}, label=<{}<BR /><FONT POINT-SIZE=\"8\">{}</FONT>>, color={}];\n",
"{}_{}_{} [xlabel={}, label=<{}<BR /><FONT POINT-SIZE=\"8\">{}</FONT><BR /><FONT POINT-SIZE=\"8\">{}</FONT>>, color={}];\n",
node.lower_case_name(),
function_id.idx(),
node_id.idx(),
node_id.idx(),
xlabel,
label,
subtitle,
tylabel,
schedules,
color
)?;
} else {
write!(
w,
"{}_{}_{} [xlabel={}, label=\"{}\", color={}];\n",
"{}_{}_{} [xlabel={}, label=<{}<BR /><FONT POINT-SIZE=\"8\">{}</FONT>>, color={}];\n",
node.lower_case_name(),
function_id.idx(),
node_id.idx(),
node_id.idx(),
xlabel,
label,
tylabel,
color
)?;
}
......
......@@ -1636,12 +1636,14 @@ fn run_pass(
pm.make_reverse_postorders();
if force_analyses {
pm.make_typing();
pm.make_doms();
pm.make_fork_join_maps();
pm.make_devices();
}
let reverse_postorders = pm.reverse_postorders.take().unwrap();
let typing = pm.typing.take();
let doms = pm.doms.take();
let fork_join_maps = pm.fork_join_maps.take();
let devices = pm.devices.take();
......@@ -1650,6 +1652,7 @@ fn run_pass(
xdot_module(
module,
&reverse_postorders,
typing.as_ref(),
doms.as_ref(),
fork_join_maps.as_ref(),
devices.as_ref(),
......
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