Browse Source

Merge pull request #1741 from cfallin/filetest-vcode-compile

Merge `vcode` filetest mode into `compile`.
pull/1750/head
Chris Fallin 5 years ago
committed by GitHub
parent
commit
51f9ac2150
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cranelift/filetests/filetests/vcode/aarch64/arithmetic.clif
  2. 2
      cranelift/filetests/filetests/vcode/aarch64/basic1.clif
  3. 2
      cranelift/filetests/filetests/vcode/aarch64/bitops.clif
  4. 2
      cranelift/filetests/filetests/vcode/aarch64/call-indirect.clif
  5. 2
      cranelift/filetests/filetests/vcode/aarch64/call.clif
  6. 2
      cranelift/filetests/filetests/vcode/aarch64/condbr.clif
  7. 2
      cranelift/filetests/filetests/vcode/aarch64/condops.clif
  8. 2
      cranelift/filetests/filetests/vcode/aarch64/constants.clif
  9. 2
      cranelift/filetests/filetests/vcode/aarch64/extend-op.clif
  10. 2
      cranelift/filetests/filetests/vcode/aarch64/floating-point.clif
  11. 2
      cranelift/filetests/filetests/vcode/aarch64/jumptable.clif
  12. 2
      cranelift/filetests/filetests/vcode/aarch64/narrow-arithmetic.clif
  13. 2
      cranelift/filetests/filetests/vcode/aarch64/saturating-ops.clif
  14. 2
      cranelift/filetests/filetests/vcode/aarch64/shift-op.clif
  15. 2
      cranelift/filetests/filetests/vcode/aarch64/shift-rotate.clif
  16. 2
      cranelift/filetests/filetests/vcode/aarch64/stack-limit.clif
  17. 2
      cranelift/filetests/filetests/vcode/aarch64/stack.clif
  18. 2
      cranelift/filetests/filetests/vcode/aarch64/symbol-value.clif
  19. 2
      cranelift/filetests/filetests/vcode/aarch64/traps.clif
  20. 2
      cranelift/filetests/filetests/vcode/aarch64/uextend-sextend.clif
  21. 2
      cranelift/filetests/src/lib.rs
  22. 52
      cranelift/filetests/src/test_compile.rs
  23. 67
      cranelift/filetests/src/test_vcode.rs

2
cranelift/filetests/filetests/vcode/aarch64/arithmetic.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f1(i64, i64) -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/basic1.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f(i32, i32) -> i32 {

2
cranelift/filetests/filetests/vcode/aarch64/bitops.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %a(i8) -> i8 {

2
cranelift/filetests/filetests/vcode/aarch64/call-indirect.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f(i64, i64) -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/call.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f(i64) -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/condbr.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f(i64, i64) -> b1 {

2
cranelift/filetests/filetests/vcode/aarch64/condops.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f(i8, i64, i64) -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/constants.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f() -> b8 {

2
cranelift/filetests/filetests/vcode/aarch64/extend-op.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f(i8) -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/floating-point.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f1(f32, f32) -> f32 {

2
cranelift/filetests/filetests/vcode/aarch64/jumptable.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f(i64) -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/narrow-arithmetic.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %add8(i8, i8) -> i8 {

2
cranelift/filetests/filetests/vcode/aarch64/saturating-ops.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %uaddsat64(i64, i64) -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/shift-op.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f(i64) -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/shift-rotate.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

2
cranelift/filetests/filetests/vcode/aarch64/stack-limit.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %foo() {

2
cranelift/filetests/filetests/vcode/aarch64/stack.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %stack_addr_small() -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/symbol-value.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f() -> i64 {

2
cranelift/filetests/filetests/vcode/aarch64/traps.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f() {

2
cranelift/filetests/filetests/vcode/aarch64/uextend-sextend.clif

@ -1,4 +1,4 @@
test vcode
test compile
target aarch64
function %f_u_8_64(i8) -> i64 {

2
cranelift/filetests/src/lib.rs

@ -57,7 +57,6 @@ mod test_shrink;
mod test_simple_gvn;
mod test_simple_preopt;
mod test_unwind;
mod test_vcode;
mod test_verifier;
/// The result of running the test in a file.
@ -141,7 +140,6 @@ fn new_subtest(parsed: &TestCommand) -> subtest::SubtestResult<Box<dyn subtest::
"simple-gvn" => test_simple_gvn::subtest(parsed),
"simple_preopt" => test_simple_preopt::subtest(parsed),
"unwind" => test_unwind::subtest(parsed),
"vcode" => test_vcode::subtest(parsed),
"verifier" => test_verifier::subtest(parsed),
_ => Err(format!("unknown test command '{}'", parsed.command)),
}

52
cranelift/filetests/src/test_compile.rs

@ -40,6 +40,11 @@ impl SubTest for TestCompile {
let isa = context.isa.expect("compile needs an ISA");
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
if isa.get_mach_backend().is_some() {
// With `MachBackend`s, we need to explicitly request dissassembly results.
comp_ctx.set_disasm(true);
}
let CodeInfo { total_size, .. } = comp_ctx
.compile(isa)
.map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?;
@ -50,25 +55,36 @@ impl SubTest for TestCompile {
comp_ctx.func.display(isa)
);
// Verify that the returned code size matches the emitted bytes.
let mut sink = SizeSink { offset: 0 };
binemit::emit_function(
&comp_ctx.func,
|func, inst, div, sink, isa| isa.emit_inst(func, inst, div, sink),
&mut sink,
isa,
);
if sink.offset != total_size {
return Err(format!(
"Expected code size {}, got {}",
total_size, sink.offset
));
if !isa.get_mach_backend().is_some() {
// Verify that the returned code size matches the emitted bytes.
let mut sink = SizeSink { offset: 0 };
binemit::emit_function(
&comp_ctx.func,
|func, inst, div, sink, isa| isa.emit_inst(func, inst, div, sink),
&mut sink,
isa,
);
if sink.offset != total_size {
return Err(format!(
"Expected code size {}, got {}",
total_size, sink.offset
));
}
// Run final code through filecheck.
let text = comp_ctx.func.display(Some(isa)).to_string();
run_filecheck(&text, context)
} else {
let disasm = comp_ctx
.mach_compile_result
.as_ref()
.unwrap()
.disasm
.as_ref()
.unwrap();
run_filecheck(&disasm, context)
}
// Run final code through filecheck.
let text = comp_ctx.func.display(Some(isa)).to_string();
run_filecheck(&text, context)
}
}

67
cranelift/filetests/src/test_vcode.rs

@ -1,67 +0,0 @@
use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult};
use cranelift_codegen::ir::Function;
use cranelift_codegen::isa::lookup;
use cranelift_codegen::settings;
use cranelift_codegen::Context as CodegenContext;
use cranelift_reader::{TestCommand, TestOption};
use log::info;
use std::borrow::Cow;
use std::string::String;
struct TestVCode {
arch: String,
}
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "vcode");
let mut arch = "arm64".to_string();
for option in &parsed.options {
match option {
TestOption::Value(k, v) if k == &"arch" => {
arch = v.to_string();
}
_ => {}
}
}
Ok(Box::new(TestVCode { arch }))
}
impl SubTest for TestVCode {
fn name(&self) -> &'static str {
"vcode"
}
fn is_mutating(&self) -> bool {
true
}
fn needs_isa(&self) -> bool {
true
}
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let triple = context.isa.unwrap().triple().clone();
let func = func.into_owned();
let mut isa = lookup(triple)
.map_err(|_| format!("Could not look up backend for arch '{}'", self.arch))?
.finish(settings::Flags::new(settings::builder()));
let mut codectx = CodegenContext::for_function(func);
codectx.set_disasm(true);
codectx
.compile(&mut *isa)
.map_err(|e| format!("Could not compile with arch '{}': {:?}", self.arch, e))?;
let result = codectx.mach_compile_result.take().unwrap();
let text = result.disasm.unwrap();
info!("text input to filecheck is:\n{}\n", text);
run_filecheck(&text, context)
}
}
Loading…
Cancel
Save