Path: blob/main/cranelift/filetests/src/test_print_cfg.rs
1691 views
//! The `print-cfg` sub-command.1//!2//! Read a series of Cranelift IR files and print their control flow graphs3//! in graphviz format.45use std::borrow::Cow;67use crate::subtest::{self, Context, SubTest};8use cranelift_codegen::cfg_printer::CFGPrinter;9use cranelift_codegen::ir::Function;10use cranelift_reader::TestCommand;1112/// Object implementing the `test print-cfg` sub-test.13struct TestPrintCfg;1415pub fn subtest(parsed: &TestCommand) -> anyhow::Result<Box<dyn SubTest>> {16assert_eq!(parsed.command, "print-cfg");17if !parsed.options.is_empty() {18anyhow::bail!("No options allowed on {}", parsed);19}20Ok(Box::new(TestPrintCfg))21}2223impl SubTest for TestPrintCfg {24fn name(&self) -> &'static str {25"print-cfg"26}2728fn needs_verifier(&self) -> bool {29false30}3132fn run(&self, func: Cow<Function>, context: &Context) -> anyhow::Result<()> {33subtest::run_filecheck(&CFGPrinter::new(&func).to_string(), context)34}35}363738