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:
@@ -21,7 +21,7 @@ use cranelift_codegen::ir::{
|
||||
HeapStyle, JumpTable, JumpTableData, MemFlags, Opcode, SigRef, Signature, StackSlot,
|
||||
StackSlotData, StackSlotKind, Table, TableData, Type, Value, ValueLoc,
|
||||
};
|
||||
use cranelift_codegen::isa::{self, CallConv, Encoding, RegUnit, TargetIsa};
|
||||
use cranelift_codegen::isa::{self, BackendVariant, CallConv, Encoding, RegUnit, TargetIsa};
|
||||
use cranelift_codegen::packed_option::ReservedValue;
|
||||
use cranelift_codegen::{settings, settings::Configurable, timing};
|
||||
use smallvec::SmallVec;
|
||||
@@ -94,33 +94,6 @@ pub fn parse_test<'a>(text: &'a str, options: ParseOptions<'a>) -> ParseResult<T
|
||||
};
|
||||
let features = parser.parse_cranelift_features()?;
|
||||
|
||||
#[cfg(feature = "experimental_x64")]
|
||||
{
|
||||
// If the test mentioned that it must run on x86_64, and the experimental_x64 feature is
|
||||
// not present, we might run into parsing errors, because some TargetIsa information is
|
||||
// left unimplemented in the new backend (e.g. register names).
|
||||
//
|
||||
// Users of this function must do some special treatment when the test requires to run on
|
||||
// x86_64 without the experimental_x64 feature, until we switch to using the new x64
|
||||
// backend by default.
|
||||
//
|
||||
// In the meanwhile, return a minimal TestFile containing the features/isa_spec, so the
|
||||
// caller can ignore this.
|
||||
if let isaspec::IsaSpec::Some(ref isas) = isa_spec {
|
||||
if isas.iter().any(|isa| isa.name() == "x64")
|
||||
&& !features.contains(&Feature::With("experimental_x64"))
|
||||
{
|
||||
return Ok(TestFile {
|
||||
commands,
|
||||
isa_spec,
|
||||
features,
|
||||
preamble_comments: Vec::new(),
|
||||
functions: Vec::new(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decide between using the calling convention passed in the options or using the
|
||||
// host's calling convention--if any tests are to be run on the host we should default to the
|
||||
// host's calling convention.
|
||||
@@ -1221,7 +1194,7 @@ impl<'a> Parser<'a> {
|
||||
let loc = self.loc;
|
||||
// Grab the whole line so the lexer won't go looking for tokens on the
|
||||
// following lines.
|
||||
let mut words = self.consume_line().trim().split_whitespace();
|
||||
let mut words = self.consume_line().trim().split_whitespace().peekable();
|
||||
// Look for `target foo`.
|
||||
let target_name = match words.next() {
|
||||
Some(w) => w,
|
||||
@@ -1231,7 +1204,19 @@ impl<'a> Parser<'a> {
|
||||
Ok(triple) => triple,
|
||||
Err(err) => return err!(loc, err),
|
||||
};
|
||||
let mut isa_builder = match isa::lookup(triple) {
|
||||
// Look for `machinst` or `legacy` option before instantiating IsaBuilder.
|
||||
let variant = match words.peek() {
|
||||
Some(&"machinst") => {
|
||||
words.next();
|
||||
BackendVariant::MachInst
|
||||
}
|
||||
Some(&"legacy") => {
|
||||
words.next();
|
||||
BackendVariant::Legacy
|
||||
}
|
||||
_ => BackendVariant::Any,
|
||||
};
|
||||
let mut isa_builder = match isa::lookup_variant(triple, variant) {
|
||||
Err(isa::LookupError::SupportDisabled) => {
|
||||
continue;
|
||||
}
|
||||
@@ -3714,10 +3699,7 @@ mod tests {
|
||||
IsaSpec::None(_) => panic!("Expected some ISA"),
|
||||
IsaSpec::Some(v) => {
|
||||
assert_eq!(v.len(), 1);
|
||||
#[cfg(not(feature = "experimental_x64"))]
|
||||
assert_eq!(v[0].name(), "x86");
|
||||
#[cfg(feature = "experimental_x64")]
|
||||
assert_eq!(v[0].name(), "x64");
|
||||
assert!(v[0].name() == "x64" || v[0].name() == "x86");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user