Move verify calls back into Context, using FlagsOrIsa.

With FlagsOrIsa, we can pass around the information we need to run
the verifier from the Context even when a TargetIsa is not available.
This commit is contained in:
Dan Gohman
2017-09-20 16:37:55 -07:00
parent f80ee7af39
commit ed6630dc02
4 changed files with 17 additions and 18 deletions

View File

@@ -40,8 +40,7 @@ impl SubTest for TestLICM {
comp_ctx.flowgraph(); comp_ctx.flowgraph();
comp_ctx.compute_loop_analysis(); comp_ctx.compute_loop_analysis();
comp_ctx.licm(); comp_ctx.licm(context.flags_or_isa()).map_err(|e| {
comp_ctx.verify(context.flags_or_isa()).map_err(|e| {
pretty_error(&comp_ctx.func, context.isa, Into::into(e)) pretty_error(&comp_ctx.func, context.isa, Into::into(e))
})?; })?;

View File

@@ -39,8 +39,7 @@ impl SubTest for TestSimpleGVN {
comp_ctx.func = func.into_owned(); comp_ctx.func = func.into_owned();
comp_ctx.flowgraph(); comp_ctx.flowgraph();
comp_ctx.simple_gvn(); comp_ctx.simple_gvn(context.flags_or_isa()).map_err(|e| {
comp_ctx.verify(context.flags_or_isa()).map_err(|e| {
pretty_error(&comp_ctx.func, context.isa, Into::into(e)) pretty_error(&comp_ctx.func, context.isa, Into::into(e))
})?; })?;

View File

@@ -20,7 +20,7 @@ use std::path::Path;
use std::process::Command; use std::process::Command;
use tempdir::TempDir; use tempdir::TempDir;
use term; use term;
use utils::pretty_verifier_error; use utils::{pretty_verifier_error, pretty_error};
macro_rules! vprintln { macro_rules! vprintln {
($x: expr, $($tts:tt)*) => { ($x: expr, $($tts:tt)*) => {
@@ -182,13 +182,11 @@ fn handle_module(
})?; })?;
context.flowgraph(); context.flowgraph();
context.compute_loop_analysis(); context.compute_loop_analysis();
context.licm(); context.licm(*fisa).map_err(|err| {
context.verify(*fisa).map_err(|err| { pretty_error(&context.func, fisa.isa, err)
pretty_verifier_error(&context.func, fisa.isa, err)
})?; })?;
context.simple_gvn(); context.simple_gvn(*fisa).map_err(|err| {
context.verify(*fisa).map_err(|err| { pretty_error(&context.func, fisa.isa, err)
pretty_verifier_error(&context.func, fisa.isa, err)
})?; })?;
} }
terminal.fg(term::color::GREEN).unwrap(); terminal.fg(term::color::GREEN).unwrap();

View File

@@ -92,9 +92,10 @@ impl Context {
} }
/// Run the verifier only if the `enable_verifier` setting is true. /// Run the verifier only if the `enable_verifier` setting is true.
pub fn verify_if(&self, isa: &TargetIsa) -> CtonResult { pub fn verify_if<'a, FOI: Into<FlagsOrIsa<'a>>>(&self, fisa: FOI) -> CtonResult {
if isa.flags().enable_verifier() { let fisa = fisa.into();
self.verify(isa).map_err(Into::into) if fisa.flags.enable_verifier() {
self.verify(fisa).map_err(Into::into)
} else { } else {
Ok(()) Ok(())
} }
@@ -136,18 +137,20 @@ impl Context {
} }
/// Perform simple GVN on the function. /// Perform simple GVN on the function.
pub fn simple_gvn(&mut self) { pub fn simple_gvn<'a, FOI: Into<FlagsOrIsa<'a>>>(&mut self, fisa: FOI) -> CtonResult {
do_simple_gvn(&mut self.func, &mut self.cfg, &mut self.domtree) do_simple_gvn(&mut self.func, &mut self.cfg, &mut self.domtree);
self.verify_if(fisa)
} }
/// Perform LICM on the function. /// Perform LICM on the function.
pub fn licm(&mut self) { pub fn licm<'a, FOI: Into<FlagsOrIsa<'a>>>(&mut self, fisa: FOI) -> CtonResult {
do_licm( do_licm(
&mut self.func, &mut self.func,
&mut self.cfg, &mut self.cfg,
&mut self.domtree, &mut self.domtree,
&mut self.loop_analysis, &mut self.loop_analysis,
) );
self.verify_if(fisa)
} }
/// Run the register allocator. /// Run the register allocator.