machinst x64: enable clif testing

This adds a new feature experimental_x64 for CLIF tests.

A test is run in the new x64 backend iff:

- either the test doesn't have an x86_64 target requirement, signaling
it must be target agnostic or not run on this target.
- or the test does require the x86_64 target, and the test is marked
with the `experimental_x64` feature.

This required one workaround in the parser. The reason is that the
parser will try to use information not provided by the TargetIsa adapter
for the Mach backends, like register names. In particular, parsing test
may fail before the test runner realizes that the test must not be run.
In this case, we early return an almost-empty TestFile from the parser,
under the same conditions as above, so that the caller may filter out
the test properly.

This also copies two tests from the test suite using the new backend,
for demonstration purposes.
This commit is contained in:
Benjamin Bouvier
2020-09-24 17:22:42 +02:00
parent 5514c74b06
commit e2c286deeb
8 changed files with 109 additions and 10 deletions

View File

@@ -17,3 +17,7 @@ thiserror = "1.0.15"
[badges]
maintenance = { status = "experimental" }
[features]
default = []
experimental_x64 = []

View File

@@ -90,6 +90,33 @@ 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.