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:
@@ -40,8 +40,7 @@ impl SubTest for TestLICM {
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.compute_loop_analysis();
|
||||
comp_ctx.licm();
|
||||
comp_ctx.verify(context.flags_or_isa()).map_err(|e| {
|
||||
comp_ctx.licm(context.flags_or_isa()).map_err(|e| {
|
||||
pretty_error(&comp_ctx.func, context.isa, Into::into(e))
|
||||
})?;
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ impl SubTest for TestSimpleGVN {
|
||||
comp_ctx.func = func.into_owned();
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.simple_gvn();
|
||||
comp_ctx.verify(context.flags_or_isa()).map_err(|e| {
|
||||
comp_ctx.simple_gvn(context.flags_or_isa()).map_err(|e| {
|
||||
pretty_error(&comp_ctx.func, context.isa, Into::into(e))
|
||||
})?;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::path::Path;
|
||||
use std::process::Command;
|
||||
use tempdir::TempDir;
|
||||
use term;
|
||||
use utils::pretty_verifier_error;
|
||||
use utils::{pretty_verifier_error, pretty_error};
|
||||
|
||||
macro_rules! vprintln {
|
||||
($x: expr, $($tts:tt)*) => {
|
||||
@@ -182,13 +182,11 @@ fn handle_module(
|
||||
})?;
|
||||
context.flowgraph();
|
||||
context.compute_loop_analysis();
|
||||
context.licm();
|
||||
context.verify(*fisa).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, fisa.isa, err)
|
||||
context.licm(*fisa).map_err(|err| {
|
||||
pretty_error(&context.func, fisa.isa, err)
|
||||
})?;
|
||||
context.simple_gvn();
|
||||
context.verify(*fisa).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, fisa.isa, err)
|
||||
context.simple_gvn(*fisa).map_err(|err| {
|
||||
pretty_error(&context.func, fisa.isa, err)
|
||||
})?;
|
||||
}
|
||||
terminal.fg(term::color::GREEN).unwrap();
|
||||
|
||||
@@ -92,9 +92,10 @@ impl Context {
|
||||
}
|
||||
|
||||
/// Run the verifier only if the `enable_verifier` setting is true.
|
||||
pub fn verify_if(&self, isa: &TargetIsa) -> CtonResult {
|
||||
if isa.flags().enable_verifier() {
|
||||
self.verify(isa).map_err(Into::into)
|
||||
pub fn verify_if<'a, FOI: Into<FlagsOrIsa<'a>>>(&self, fisa: FOI) -> CtonResult {
|
||||
let fisa = fisa.into();
|
||||
if fisa.flags.enable_verifier() {
|
||||
self.verify(fisa).map_err(Into::into)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
@@ -136,18 +137,20 @@ impl Context {
|
||||
}
|
||||
|
||||
/// Perform simple GVN on the function.
|
||||
pub fn simple_gvn(&mut self) {
|
||||
do_simple_gvn(&mut self.func, &mut self.cfg, &mut self.domtree)
|
||||
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);
|
||||
self.verify_if(fisa)
|
||||
}
|
||||
|
||||
/// 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(
|
||||
&mut self.func,
|
||||
&mut self.cfg,
|
||||
&mut self.domtree,
|
||||
&mut self.loop_analysis,
|
||||
)
|
||||
);
|
||||
self.verify_if(fisa)
|
||||
}
|
||||
|
||||
/// Run the register allocator.
|
||||
|
||||
Reference in New Issue
Block a user