Add a ControlFlowGraph argument to legalize_function.
Legalizing some instructions may require modifications to the control flow graph, and some operations need to use the CFG analysis. The CFG reference is threaded through all the legalization functions to reach the generated expansion functions as well as the legalizer::split module where it will be used first.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
use std::borrow::Cow;
|
||||
use cretonne::{legalize_function, write_function};
|
||||
use cretonne::flowgraph::ControlFlowGraph;
|
||||
use cretonne::ir::Function;
|
||||
use cton_reader::TestCommand;
|
||||
use filetest::subtest::{SubTest, Context, Result, run_filecheck};
|
||||
@@ -36,7 +37,8 @@ impl SubTest for TestLegalizer {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
let mut func = func.into_owned();
|
||||
let isa = context.isa.expect("legalizer needs an ISA");
|
||||
legalize_function(&mut func, isa);
|
||||
let mut cfg = ControlFlowGraph::with_function(&func);
|
||||
legalize_function(&mut func, &mut cfg, isa);
|
||||
|
||||
let mut text = String::new();
|
||||
write_function(&mut text, &func, Some(isa)).map_err(|e| e.to_string())?;
|
||||
|
||||
@@ -42,10 +42,9 @@ impl SubTest for TestRegalloc {
|
||||
let mut comp_ctx = cretonne::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
// TODO: Should we have an option to skip legalization?
|
||||
comp_ctx.legalize(isa);
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.regalloc(isa);
|
||||
|
||||
let mut text = String::new();
|
||||
|
||||
Reference in New Issue
Block a user