cranelift x64: add instruction set checks for popcnt/tzcnt/lzcnt;

This commit is contained in:
Benjamin Bouvier
2021-01-30 13:38:55 +01:00
parent a4eaefc670
commit 13027ad670
3 changed files with 24 additions and 4 deletions

View File

@@ -410,6 +410,17 @@ pub enum UnaryRmROpcode {
Popcnt,
}
impl UnaryRmROpcode {
pub(crate) fn available_from(&self) -> Option<InstructionSet> {
match self {
UnaryRmROpcode::Bsr | UnaryRmROpcode::Bsf => None,
UnaryRmROpcode::Lzcnt => Some(InstructionSet::Lzcnt),
UnaryRmROpcode::Tzcnt => Some(InstructionSet::BMI1),
UnaryRmROpcode::Popcnt => Some(InstructionSet::Popcnt),
}
}
}
impl fmt::Debug for UnaryRmROpcode {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match self {
@@ -442,6 +453,10 @@ pub(crate) enum InstructionSet {
SSSE3,
SSE41,
SSE42,
Popcnt,
Lzcnt,
BMI1,
BMI2,
}
/// Some SSE operations requiring 2 operands r/m and r.