Allow filecheck directives with "test compile".
Things like inserted prologues and epilogues in #201 can be tested this way.
This commit is contained in:
@@ -352,3 +352,14 @@ Test the simple GVN pass.
|
||||
|
||||
The simple GVN pass is run on each function, and then results are run
|
||||
through filecheck.
|
||||
|
||||
`test compile`
|
||||
--------------
|
||||
|
||||
Test the whole code generation pipeline.
|
||||
|
||||
Each function is passed through the full ``Context::compile()`` function
|
||||
which is normally used to compile code. This type of test often depends
|
||||
on assertions or verifier errors, but it is also possible to use
|
||||
filecheck directives which will be matched against the final form of the
|
||||
Cretonne IL right before binary machine code emission.
|
||||
|
||||
@@ -6,8 +6,9 @@ use cretonne::binemit;
|
||||
use cretonne::ir;
|
||||
use cretonne;
|
||||
use cton_reader::TestCommand;
|
||||
use filetest::subtest::{SubTest, Context, Result};
|
||||
use filetest::subtest::{SubTest, Context, Result, run_filecheck};
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::Write;
|
||||
use utils::pretty_error;
|
||||
|
||||
struct TestCompile;
|
||||
@@ -51,7 +52,7 @@ impl SubTest for TestCompile {
|
||||
comp_ctx.func.display(isa)
|
||||
);
|
||||
|
||||
// Finally verify that the returned code size matches the emitted bytes.
|
||||
// Verify that the returned code size matches the emitted bytes.
|
||||
let mut sink = SizeSink { offset: 0 };
|
||||
binemit::emit_function(
|
||||
&comp_ctx.func,
|
||||
@@ -67,7 +68,11 @@ impl SubTest for TestCompile {
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
// Run final code through filecheck.
|
||||
let mut text = String::new();
|
||||
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))
|
||||
.map_err(|e| e.to_string())?;
|
||||
run_filecheck(&text, context)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user