1 use cranelift::prelude::isa::TargetIsa;
2 use target_lexicon::Architecture;
3 
4 pub trait TargetIsaExtras {
supports_simd(&self) -> bool5     fn supports_simd(&self) -> bool;
6 }
7 
8 impl TargetIsaExtras for &dyn TargetIsa {
supports_simd(&self) -> bool9     fn supports_simd(&self) -> bool {
10         match self.triple().architecture {
11             // RISC-V only supports SIMD with the V extension.
12             Architecture::Riscv64(_) => self
13                 .isa_flags()
14                 .iter()
15                 .find(|f| f.name == "has_v")
16                 .and_then(|f| f.as_bool())
17                 .unwrap_or(false),
18             _ => true,
19         }
20     }
21 }
22