cranelift: Support bool vectors in trampoline
This commit is contained in:
@@ -127,6 +127,21 @@ impl Type {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a type with the same number of lanes as this type, but with the lanes replaced by
|
||||
/// integers of the same size.
|
||||
///
|
||||
/// Scalar types follow this same rule, but `b1` is converted into `i8`
|
||||
pub fn as_int(self) -> Self {
|
||||
self.replace_lanes(match self.lane_type() {
|
||||
B1 | B8 => I8,
|
||||
B16 => I16,
|
||||
B32 => I32,
|
||||
B64 => I64,
|
||||
B128 => I128,
|
||||
_ => unimplemented!(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Get a type with the same number of lanes as this type, but with lanes that are half the
|
||||
/// number of bits.
|
||||
pub fn half_width(self) -> Option<Self> {
|
||||
@@ -530,4 +545,13 @@ mod tests {
|
||||
assert_eq!(I32X4.as_bool_pedantic(), B32X4);
|
||||
assert_eq!(I32.as_bool_pedantic(), B32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn as_int() {
|
||||
assert_eq!(B32X4.as_int(), I32X4);
|
||||
assert_eq!(B8X8.as_int(), I8X8);
|
||||
assert_eq!(B1.as_int(), I8);
|
||||
assert_eq!(B8.as_int(), I8);
|
||||
assert_eq!(B128.as_int(), I128);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user