Switch default to new x86_64 backend.

This PR switches the default backend on x86, for both the
`cranelift-codegen` crate and for Wasmtime, to the new
(`MachInst`-style, `VCode`-based) backend that has been under
development and testing for some time now.

The old backend is still available by default in builds with the
`old-x86-backend` feature, or by requesting `BackendVariant::Legacy`
from the appropriate APIs.

As part of that switch, it adds some more runtime-configurable plumbing
to the testing infrastructure so that tests can be run using the
appropriate backend. `clif-util test` is now capable of parsing a
backend selector option from filetests and instantiating the correct
backend.

CI has been updated so that the old x86 backend continues to run its
tests, just as we used to run the new x64 backend separately.

At some point, we will remove the old x86 backend entirely, once we are
satisfied that the new backend has not caused any unforeseen issues and
we do not need to revert.
This commit is contained in:
Chris Fallin
2021-03-09 23:43:11 -08:00
parent b7b47e380d
commit cb48ea406e
243 changed files with 316 additions and 442 deletions

View File

@@ -4,10 +4,10 @@ use cranelift_codegen::binemit::{NullRelocSink, NullStackMapSink, NullTrapSink};
use cranelift_codegen::data_value::DataValue;
use cranelift_codegen::ir::immediates::{Ieee32, Ieee64};
use cranelift_codegen::ir::{condcodes::IntCC, Function, InstBuilder, Signature, Type};
use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::isa::{BackendVariant, TargetIsa};
use cranelift_codegen::{ir, settings, CodegenError, Context};
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use cranelift_native::builder as host_isa_builder;
use cranelift_native::builder_with_options;
use log::trace;
use memmap2::{Mmap, MmapMut};
use std::cmp::max;
@@ -48,8 +48,9 @@ impl SingleFunctionCompiler {
}
/// Build a [SingleFunctionCompiler] using the host machine's ISA and the passed flags.
pub fn with_host_isa(flags: settings::Flags) -> Self {
let builder = host_isa_builder().expect("Unable to build a TargetIsa for the current host");
pub fn with_host_isa(flags: settings::Flags, variant: BackendVariant) -> Self {
let builder = builder_with_options(variant, true)
.expect("Unable to build a TargetIsa for the current host");
let isa = builder.finish(flags);
Self::new(isa)
}
@@ -58,7 +59,7 @@ impl SingleFunctionCompiler {
/// ISA.
pub fn with_default_host_isa() -> Self {
let flags = settings::Flags::new(settings::builder());
Self::with_host_isa(flags)
Self::with_host_isa(flags, BackendVariant::Any)
}
/// Compile the passed [Function] to a `CompiledFunction`. This function will: