cranelift: Add is_bool_vector helper

This commit is contained in:
Afonso Bordado
2021-09-10 15:46:14 +01:00
parent 85d468dc5a
commit 3c1133379c
2 changed files with 7 additions and 6 deletions

View File

@@ -208,6 +208,11 @@ impl Type {
}
}
/// Is this a vector boolean type?
pub fn is_bool_vector(self) -> bool {
self.is_vector() && self.lane_type().is_bool()
}
/// Is this a scalar integer type?
pub fn is_int(self) -> bool {
match self {

View File

@@ -307,16 +307,12 @@ fn make_trampoline(signature: &ir::Signature, isa: &dyn TargetIsa) -> Function {
(i * UnboxedValues::SLOT_SIZE) as i32,
);
let is_scalar_bool = param.value_type.is_bool();
let is_vector_bool =
param.value_type.is_vector() && param.value_type.lane_type().is_bool();
// For booleans, we want to type-convert the loaded integer into a boolean and ensure
// that we are using the architecture's canonical boolean representation (presumably
// comparison will emit this).
if is_scalar_bool {
if param.value_type.is_bool() {
builder.ins().icmp_imm(IntCC::NotEqual, loaded, 0)
} else if is_vector_bool {
} else if param.value_type.is_bool_vector() {
let zero_constant = builder.func.dfg.constants.insert(vec![0; 16].into());
let zero_vec = builder.ins().vconst(ty, zero_constant);
builder.ins().icmp(IntCC::NotEqual, loaded, zero_vec)