Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/cranelift/filetests/src/test_print_cfg.rs
1691 views
1
//! The `print-cfg` sub-command.
2
//!
3
//! Read a series of Cranelift IR files and print their control flow graphs
4
//! in graphviz format.
5
6
use std::borrow::Cow;
7
8
use crate::subtest::{self, Context, SubTest};
9
use cranelift_codegen::cfg_printer::CFGPrinter;
10
use cranelift_codegen::ir::Function;
11
use cranelift_reader::TestCommand;
12
13
/// Object implementing the `test print-cfg` sub-test.
14
struct TestPrintCfg;
15
16
pub fn subtest(parsed: &TestCommand) -> anyhow::Result<Box<dyn SubTest>> {
17
assert_eq!(parsed.command, "print-cfg");
18
if !parsed.options.is_empty() {
19
anyhow::bail!("No options allowed on {}", parsed);
20
}
21
Ok(Box::new(TestPrintCfg))
22
}
23
24
impl SubTest for TestPrintCfg {
25
fn name(&self) -> &'static str {
26
"print-cfg"
27
}
28
29
fn needs_verifier(&self) -> bool {
30
false
31
}
32
33
fn run(&self, func: Cow<Function>, context: &Context) -> anyhow::Result<()> {
34
subtest::run_filecheck(&CFGPrinter::new(&func).to_string(), context)
35
}
36
}
37
38