Use Context::for_function to simplify the code.
This commit is contained in:
@@ -36,10 +36,7 @@ impl SubTest for TestCompile {
|
||||
|
||||
fn run(&self, func: Cow<ir::Function>, context: &Context) -> Result<()> {
|
||||
let isa = context.isa.expect("compile needs an ISA");
|
||||
|
||||
// Create a compilation context, and drop in the function.
|
||||
let mut comp_ctx = cretonne_codegen::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
let code_size = comp_ctx
|
||||
.compile(isa)
|
||||
|
||||
@@ -34,9 +34,7 @@ impl SubTest for TestDCE {
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
// Create a compilation context, and drop in the function.
|
||||
let mut comp_ctx = cretonne_codegen::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.compute_loop_analysis();
|
||||
|
||||
@@ -36,8 +36,7 @@ impl SubTest for TestLegalizer {
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
let mut comp_ctx = cretonne_codegen::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
let isa = context.isa.expect("legalizer needs an ISA");
|
||||
|
||||
comp_ctx.compute_cfg();
|
||||
|
||||
@@ -34,9 +34,7 @@ impl SubTest for TestLICM {
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
// Create a compilation context, and drop in the function.
|
||||
let mut comp_ctx = cretonne_codegen::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.compute_loop_analysis();
|
||||
|
||||
@@ -31,9 +31,7 @@ impl SubTest for TestPostopt {
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
// Create a compilation context, and drop in the function.
|
||||
let mut comp_ctx = cretonne_codegen::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
let isa = context.isa.expect("postopt needs an ISA");
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
|
||||
@@ -31,9 +31,7 @@ impl SubTest for TestPreopt {
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
// Create a compilation context, and drop in the function.
|
||||
let mut comp_ctx = cretonne_codegen::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
let isa = context.isa.expect("preopt needs an ISA");
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
|
||||
@@ -39,10 +39,7 @@ impl SubTest for TestRegalloc {
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
let isa = context.isa.expect("register allocator needs an ISA");
|
||||
|
||||
// Create a compilation context, and drop in the function.
|
||||
let mut comp_ctx = cretonne_codegen::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
comp_ctx.compute_cfg();
|
||||
// TODO: Should we have an option to skip legalization?
|
||||
|
||||
@@ -34,9 +34,7 @@ impl SubTest for TestSimpleGVN {
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
// Create a compilation context, and drop in the function.
|
||||
let mut comp_ctx = cretonne_codegen::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx
|
||||
|
||||
Reference in New Issue
Block a user