Use existing is_equal predicate with the newly-shared condition codes
This removes the `HasConditionCode(&'static str)` predicate and the associated issues with that.
This commit is contained in:
@@ -13,6 +13,7 @@ use crate::cdsl::operands::Operand;
|
|||||||
use crate::cdsl::type_inference::Constraint;
|
use crate::cdsl::type_inference::Constraint;
|
||||||
use crate::cdsl::types::{LaneType, ReferenceType, ValueType, VectorType};
|
use crate::cdsl::types::{LaneType, ReferenceType, ValueType, VectorType};
|
||||||
use crate::cdsl::typevar::TypeVar;
|
use crate::cdsl::typevar::TypeVar;
|
||||||
|
use cranelift_codegen_shared::condcodes::IntCC;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub struct OpcodeNumber(u32);
|
pub struct OpcodeNumber(u32);
|
||||||
@@ -630,7 +631,7 @@ pub enum FormatPredicateKind {
|
|||||||
IsColocatedData,
|
IsColocatedData,
|
||||||
|
|
||||||
/// Does the operation have a specific condition code?
|
/// Does the operation have a specific condition code?
|
||||||
HasConditionCode(&'static str),
|
HasConditionCode(IntCC),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Hash, PartialEq, Eq)]
|
#[derive(Clone, Hash, PartialEq, Eq)]
|
||||||
@@ -718,7 +719,7 @@ impl FormatPredicateNode {
|
|||||||
format!("predicates::is_colocated_data({}, func)", self.member_name)
|
format!("predicates::is_colocated_data({}, func)", self.member_name)
|
||||||
}
|
}
|
||||||
FormatPredicateKind::HasConditionCode(code) => format!(
|
FormatPredicateKind::HasConditionCode(code) => format!(
|
||||||
"predicates::match_condition_code_to_str({}, \"{}\")",
|
"predicates::is_equal({}, IntCC::{:?})",
|
||||||
self.member_name, code
|
self.member_name, code
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@@ -1006,7 +1007,7 @@ impl InstructionPredicate {
|
|||||||
|
|
||||||
pub fn new_has_condition_code(
|
pub fn new_has_condition_code(
|
||||||
format: &InstructionFormat,
|
format: &InstructionFormat,
|
||||||
condition_code: &'static str,
|
condition_code: IntCC,
|
||||||
field_name: &'static str,
|
field_name: &'static str,
|
||||||
) -> InstructionPredicateNode {
|
) -> InstructionPredicateNode {
|
||||||
InstructionPredicateNode::FormatPredicate(FormatPredicateNode::new(
|
InstructionPredicateNode::FormatPredicate(FormatPredicateNode::new(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
|
use cranelift_codegen_shared::condcodes::IntCC;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::cdsl::encodings::{Encoding, EncodingBuilder};
|
use crate::cdsl::encodings::{Encoding, EncodingBuilder};
|
||||||
@@ -2071,7 +2072,7 @@ pub(crate) fn define(
|
|||||||
let instruction = icmp.bind_vector_from_lane(ty, sse_vector_size);
|
let instruction = icmp.bind_vector_from_lane(ty, sse_vector_size);
|
||||||
let f_int_compare = formats.get(formats.by_name("IntCompare"));
|
let f_int_compare = formats.get(formats.by_name("IntCompare"));
|
||||||
let has_eq_condition_code =
|
let has_eq_condition_code =
|
||||||
InstructionPredicate::new_has_condition_code(f_int_compare, "eq", "cond");
|
InstructionPredicate::new_has_condition_code(f_int_compare, IntCC::Equal, "cond");
|
||||||
let template = rec_icscc_fpr.nonrex().opcodes(opcodes.clone());
|
let template = rec_icscc_fpr.nonrex().opcodes(opcodes.clone());
|
||||||
e.enc_32_64_func(instruction, template, |builder| {
|
e.enc_32_64_func(instruction, template, |builder| {
|
||||||
let builder = builder.inst_predicate(has_eq_condition_code);
|
let builder = builder.inst_predicate(has_eq_condition_code);
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
//! dead code warning.
|
//! dead code warning.
|
||||||
|
|
||||||
use crate::ir;
|
use crate::ir;
|
||||||
use crate::ir::condcodes::IntCC;
|
|
||||||
use std::string::ToString;
|
|
||||||
|
|
||||||
/// Check that an integer value is zero.
|
/// Check that an integer value is zero.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@@ -85,14 +83,6 @@ pub fn has_length_of(value_list: &ir::ValueList, num: usize, func: &ir::Function
|
|||||||
value_list.len(&func.dfg.value_lists) == num
|
value_list.len(&func.dfg.value_lists) == num
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn match_condition_code_to_str(
|
|
||||||
condition_code: IntCC,
|
|
||||||
stringified_condition_code: &str,
|
|
||||||
) -> bool {
|
|
||||||
condition_code.to_string().eq(stringified_condition_code)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -146,10 +136,4 @@ mod tests {
|
|||||||
assert!(!is_all_ones_128_bit(&[0; 16]));
|
assert!(!is_all_ones_128_bit(&[0; 16]));
|
||||||
assert!(is_all_ones_128_bit(&[0xff; 16]));
|
assert!(is_all_ones_128_bit(&[0xff; 16]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn condition_code() {
|
|
||||||
assert!(match_condition_code_to_str(IntCC::Equal, "eq"));
|
|
||||||
assert!(!match_condition_code_to_str(IntCC::Equal, "ne"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user