Make ConstantData a container for any-size constant values
Previously, ConstantData was a type alias for `Vec<u8>` which prevented it from having an implementation; this meant that `V128Imm` and `&[u8; 16]` were used in places that otherwise could have accepted types of different byte lengths.
This commit is contained in:
@@ -734,10 +734,10 @@ pub enum FormatPredicateKind {
|
||||
IsZero64BitFloat,
|
||||
|
||||
/// Is the immediate format field member equal zero in all lanes?
|
||||
IsAllZeroes128Bit,
|
||||
IsAllZeroes,
|
||||
|
||||
/// Does the immediate format field member have ones in all bits of all lanes?
|
||||
IsAllOnes128Bit,
|
||||
IsAllOnes,
|
||||
|
||||
/// Has the value list (in member_name) the size specified in parameter?
|
||||
LengthEquals(usize),
|
||||
@@ -818,12 +818,12 @@ impl FormatPredicateNode {
|
||||
FormatPredicateKind::IsZero64BitFloat => {
|
||||
format!("predicates::is_zero_64_bit_float({})", self.member_name)
|
||||
}
|
||||
FormatPredicateKind::IsAllZeroes128Bit => format!(
|
||||
"predicates::is_all_zeroes_128_bit(func.dfg.constants.get({}))",
|
||||
FormatPredicateKind::IsAllZeroes => format!(
|
||||
"predicates::is_all_zeroes(func.dfg.constants.get({}))",
|
||||
self.member_name
|
||||
),
|
||||
FormatPredicateKind::IsAllOnes128Bit => format!(
|
||||
"predicates::is_all_ones_128_bit(func.dfg.constants.get({}))",
|
||||
FormatPredicateKind::IsAllOnes => format!(
|
||||
"predicates::is_all_ones(func.dfg.constants.get({}))",
|
||||
self.member_name
|
||||
),
|
||||
FormatPredicateKind::LengthEquals(num) => format!(
|
||||
@@ -1069,25 +1069,25 @@ impl InstructionPredicate {
|
||||
))
|
||||
}
|
||||
|
||||
pub fn new_is_all_zeroes_128bit(
|
||||
pub fn new_is_all_zeroes(
|
||||
format: &InstructionFormat,
|
||||
field_name: &'static str,
|
||||
) -> InstructionPredicateNode {
|
||||
InstructionPredicateNode::FormatPredicate(FormatPredicateNode::new(
|
||||
format,
|
||||
field_name,
|
||||
FormatPredicateKind::IsAllZeroes128Bit,
|
||||
FormatPredicateKind::IsAllZeroes,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn new_is_all_ones_128bit(
|
||||
pub fn new_is_all_ones(
|
||||
format: &InstructionFormat,
|
||||
field_name: &'static str,
|
||||
) -> InstructionPredicateNode {
|
||||
InstructionPredicateNode::FormatPredicate(FormatPredicateNode::new(
|
||||
format,
|
||||
field_name,
|
||||
FormatPredicateKind::IsAllOnes128Bit,
|
||||
FormatPredicateKind::IsAllOnes,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -1848,14 +1848,14 @@ pub(crate) fn define<'defs>(
|
||||
let instruction = vconst.bind(vector(ty, sse_vector_size));
|
||||
|
||||
let is_zero_128bit =
|
||||
InstructionPredicate::new_is_all_zeroes_128bit(f_unary_const, "constant_handle");
|
||||
InstructionPredicate::new_is_all_zeroes(f_unary_const, "constant_handle");
|
||||
let template = rec_vconst_optimized.nonrex().opcodes(&PXOR);
|
||||
e.enc_32_64_func(instruction.clone(), template, |builder| {
|
||||
builder.inst_predicate(is_zero_128bit)
|
||||
});
|
||||
|
||||
let is_ones_128bit =
|
||||
InstructionPredicate::new_is_all_ones_128bit(f_unary_const, "constant_handle");
|
||||
InstructionPredicate::new_is_all_ones(f_unary_const, "constant_handle");
|
||||
let template = rec_vconst_optimized.nonrex().opcodes(&PCMPEQB);
|
||||
e.enc_32_64_func(instruction, template, |builder| {
|
||||
builder.inst_predicate(is_ones_128bit)
|
||||
|
||||
Reference in New Issue
Block a user