Always require a Flags reference for verifying functions.
Add a settings::FlagsOrIsa struct which represents a flags reference and optionally the ISA it belongs to. Use this for passing flags/isa information to the verifier. The verify_function() and verify_context() functions are now generic so they accept either a &Flags or a &TargetISa argument. Fix the return_at_end verifier tests which no longer require an ISA specified. The signle "set return_at_end" flag setting now makes it to the verifier even when no ISA is present to carry it.
This commit is contained in:
@@ -41,7 +41,7 @@ impl SubTest for TestLICM {
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.compute_loop_analysis();
|
||||
comp_ctx.licm();
|
||||
comp_ctx.verify(context.isa).map_err(|e| {
|
||||
comp_ctx.verify(context.flags_or_isa()).map_err(|e| {
|
||||
pretty_error(&comp_ctx.func, context.isa, Into::into(e))
|
||||
})?;
|
||||
|
||||
|
||||
@@ -119,9 +119,11 @@ fn run_one_test<'a>(
|
||||
|
||||
// Should we run the verifier before this test?
|
||||
if !context.verified && test.needs_verifier() {
|
||||
verify_function(&func, isa).map_err(|e| {
|
||||
pretty_verifier_error(&func, isa, e)
|
||||
})?;
|
||||
verify_function(&func, context.flags_or_isa()).map_err(
|
||||
|e| {
|
||||
pretty_verifier_error(&func, isa, e)
|
||||
},
|
||||
)?;
|
||||
context.verified = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ impl SubTest for TestSimpleGVN {
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.simple_gvn();
|
||||
comp_ctx.verify(context.isa).map_err(|e| {
|
||||
comp_ctx.verify(context.flags_or_isa()).map_err(|e| {
|
||||
pretty_error(&comp_ctx.func, context.isa, Into::into(e))
|
||||
})?;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::result;
|
||||
use std::borrow::Cow;
|
||||
use cretonne::ir::Function;
|
||||
use cretonne::isa::TargetIsa;
|
||||
use cretonne::settings::Flags;
|
||||
use cretonne::settings::{Flags, FlagsOrIsa};
|
||||
use cton_reader::{Details, Comment};
|
||||
use filecheck::{self, CheckerBuilder, Checker, Value as FCValue};
|
||||
|
||||
@@ -29,6 +29,16 @@ pub struct Context<'a> {
|
||||
pub isa: Option<&'a TargetIsa>,
|
||||
}
|
||||
|
||||
impl<'a> Context<'a> {
|
||||
/// Get a `FlagsOrIsa` object for passing to the verifier.
|
||||
pub fn flags_or_isa(&self) -> FlagsOrIsa<'a> {
|
||||
FlagsOrIsa {
|
||||
flags: self.flags,
|
||||
isa: self.isa,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Common interface for implementations of test commands.
|
||||
///
|
||||
/// Each `.cton` test file may contain multiple test commands, each represented by a `SubTest`
|
||||
|
||||
@@ -51,7 +51,7 @@ impl SubTest for TestVerifier {
|
||||
}
|
||||
}
|
||||
|
||||
match verify_function(func, context.isa) {
|
||||
match verify_function(func, context.flags_or_isa()) {
|
||||
Ok(_) => {
|
||||
match expected {
|
||||
None => Ok(()),
|
||||
|
||||
@@ -61,7 +61,6 @@ pub fn run(
|
||||
&mut flag_builder,
|
||||
&Location { line_number: 0 },
|
||||
).map_err(|err| err.to_string())?;
|
||||
let flags = settings::Flags::new(&flag_builder);
|
||||
|
||||
let mut words = flag_isa.trim().split_whitespace();
|
||||
// Look for `isa foo`.
|
||||
@@ -84,7 +83,6 @@ pub fn run(
|
||||
flag_check,
|
||||
path.to_path_buf(),
|
||||
name,
|
||||
&flags,
|
||||
&*isa,
|
||||
)?;
|
||||
}
|
||||
@@ -97,7 +95,6 @@ fn handle_module(
|
||||
flag_check: bool,
|
||||
path: PathBuf,
|
||||
name: String,
|
||||
flags: &settings::Flags,
|
||||
isa: &TargetIsa,
|
||||
) -> Result<(), String> {
|
||||
let mut terminal = term::stdout().unwrap();
|
||||
@@ -144,7 +141,7 @@ fn handle_module(
|
||||
}
|
||||
}
|
||||
};
|
||||
let mut dummy_runtime = DummyRuntime::with_flags(flags.clone());
|
||||
let mut dummy_runtime = DummyRuntime::with_flags(isa.flags().clone());
|
||||
let translation = {
|
||||
let runtime: &mut WasmRuntime = &mut dummy_runtime;
|
||||
translate_module(&data, runtime)?
|
||||
@@ -157,8 +154,8 @@ fn handle_module(
|
||||
vprint!(flag_verbose, "Checking... ");
|
||||
terminal.reset().unwrap();
|
||||
for func in &translation.functions {
|
||||
verifier::verify_function(func, Some(isa)).map_err(|err| {
|
||||
pretty_verifier_error(func, Some(isa), err)
|
||||
verifier::verify_function(func, isa).map_err(|err| {
|
||||
pretty_verifier_error(func, None, err)
|
||||
})?;
|
||||
}
|
||||
terminal.fg(term::color::GREEN).unwrap();
|
||||
@@ -172,18 +169,18 @@ fn handle_module(
|
||||
for func in &translation.functions {
|
||||
let mut context = Context::new();
|
||||
context.func = func.clone();
|
||||
context.verify(Some(isa)).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, Some(isa), err)
|
||||
context.verify(isa).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, None, err)
|
||||
})?;
|
||||
context.flowgraph();
|
||||
context.compute_loop_analysis();
|
||||
context.licm();
|
||||
context.verify(Some(isa)).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, Some(isa), err)
|
||||
context.verify(isa).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, None, err)
|
||||
})?;
|
||||
context.simple_gvn();
|
||||
context.verify(Some(isa)).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, Some(isa), err)
|
||||
context.verify(isa).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, None, err)
|
||||
})?;
|
||||
}
|
||||
terminal.fg(term::color::GREEN).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user