From dd5974654c419466c9b5e7d32c7a35ddc7e691ae Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 4 Nov 2020 12:00:54 -0800 Subject: [PATCH] peepmatic: Make the test-we-can-get-and-rebuild peephole optimizers test work on arm64 This change means that running cargo test --features "enable-peepmatic rebuild-peephole-optimizers" inside `cranelift/codegen` will rebuild peephole optimizers on not only x86_64 but also aarch64. --- cranelift/codegen/src/peepmatic.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cranelift/codegen/src/peepmatic.rs b/cranelift/codegen/src/peepmatic.rs index bf0f440865..d676dbad93 100644 --- a/cranelift/codegen/src/peepmatic.rs +++ b/cranelift/codegen/src/peepmatic.rs @@ -1312,19 +1312,31 @@ unsafe impl<'a, 'b> InstructionSet<'b> for &'a dyn TargetIsa { } #[cfg(test)] -#[cfg(feature = "x86")] +#[cfg(any(feature = "x64", feature = "x86", feature = "arm64"))] mod tests { use super::*; - use crate::isa::lookup; + use crate::isa::{lookup, TargetIsa}; use crate::settings::{builder, Flags}; use std::str::FromStr; use target_lexicon::triple; + fn isa() -> Box { + // We need a triple to instantiate and run the peephole optimizer, but we + // don't care which one when we're just trying to trigger a rebuild of the + // peephole optimizer (it doesn't affect the serialized bytes at all). + let triple = if cfg!(any(feature = "x64", feature = "x86")) { + triple!("x86_64") + } else if cfg!(feature = "arm64") { + triple!("aarch64") + } else { + panic!("unknown arch") + }; + lookup(triple).unwrap().finish(Flags::new(builder())) + } + #[test] fn get_peepmatic_preopt() { - let isa = lookup(triple!("x86_64")) - .expect("expect x86 ISA") - .finish(Flags::new(builder())); + let isa = isa(); let _ = preopt(&*isa); } }