Use 'xor r, r' to set registers to 0 instead of mov (#766)

This commit is contained in:
Andy Wortman
2019-09-16 14:35:55 +00:00
committed by Benjamin Bouvier
parent b95508c51a
commit 99380fad1a
9 changed files with 193 additions and 7 deletions

View File

@@ -606,6 +606,8 @@ pub enum FormatPredicateKind {
/// `2^scale`.
IsUnsignedInt(usize, usize),
/// Is the immediate format field member an integer equal to zero?
IsZeroInt,
/// Is the immediate format field member equal to zero? (float32 version)
IsZero32BitFloat,
@@ -679,6 +681,9 @@ impl FormatPredicateNode {
"predicates::is_unsigned_int({}, {}, {})",
self.member_name, width, scale
),
FormatPredicateKind::IsZeroInt => {
format!("predicates::is_zero_int({})", self.member_name)
}
FormatPredicateKind::IsZero32BitFloat => {
format!("predicates::is_zero_32_bit_float({})", self.member_name)
}
@@ -891,6 +896,17 @@ impl InstructionPredicate {
))
}
pub fn new_is_zero_int(
format: &InstructionFormat,
field_name: &'static str,
) -> InstructionPredicateNode {
InstructionPredicateNode::FormatPredicate(FormatPredicateNode::new(
format,
field_name,
FormatPredicateKind::IsZeroInt,
))
}
pub fn new_is_zero_32bit_float(
format: &InstructionFormat,
field_name: &'static str,