Commit c00adcf3 authored by qinsoon's avatar qinsoon

[wip] output original IR and final IR separately

parent d0bd8e72
......@@ -134,7 +134,7 @@ impl fmt::Debug for MuFunctionVersion {
write!(f, "Empty\n").unwrap();
}
if self.block_trace.is_some() {
write!(f, "{:?}\n", self.block_trace.as_ref().unwrap())
write!(f, "Block Trace: {:?}\n", self.block_trace.as_ref().unwrap())
} else {
write!(f, "Trace not available\n")
}
......
......@@ -35,15 +35,38 @@ impl CodeEmission {
// create emit directory
create_emit_directory(vm);
let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(func.name().unwrap().to_string() + ".muir");
let mut file = match File::create(file_path.as_path()) {
Err(why) => panic!("couldn't create muir file {}: {}", file_path.to_str().unwrap(), why),
Ok(file) => file
};
// final IR
{
let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(func.name().unwrap().to_string() + ".muir");
let mut file = match File::create(file_path.as_path()) {
Err(why) => panic!("couldn't create muir file {}: {}", file_path.to_str().unwrap(), why),
Ok(file) => file
};
file.write_fmt(format_args!("{:?}", func)).unwrap();
file.write_fmt(format_args!("{:?}", func)).unwrap();
}
// original IR (source/input)
{
let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(func.name().unwrap().to_string() + "_orig.muir");
let mut file = match File::create(file_path.as_path()) {
Err(why) => panic!("couldn't create muir file {}: {}", file_path.to_str().unwrap(), why),
Ok(file) => file
};
file.write_fmt(format_args!("FuncVer {} of Func #{}\n", func.hdr, func.func_id)).unwrap();
file.write_fmt(format_args!("Signature: {}\n", func.sig)).unwrap();
file.write_fmt(format_args!("IR:\n")).unwrap();
if func.get_orig_ir().is_some() {
file.write_fmt(format_args!("{:?}\n", func.get_orig_ir().as_ref().unwrap())).unwrap();
} else {
file.write_fmt(format_args!("Empty\n")).unwrap();
}
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment