Struct cranelift_codegen::ir::types::Type
source · pub struct Type(_);
Expand description
The type of an SSA value.
The INVALID
type isn’t a real type, and is used as a placeholder in the IR where a type
field is present put no type is needed, such as the controlling type variable for a
non-polymorphic instruction.
Basic integer types: I8
, I16
, I32
, and I64
. These types are sign-agnostic.
Basic floating point types: F32
and F64
. IEEE single and double precision.
Boolean types: B1
, B8
, B16
, B32
, and B64
. These all encode ‘true’ or ‘false’. The
larger types use redundant bits.
SIMD vector types have power-of-two lanes, up to 256. Lanes can be any int/float/bool type.
Implementations§
source§impl Type
impl Type
sourcepub fn lane_type(self) -> Self
pub fn lane_type(self) -> Self
Get the lane type of this SIMD vector type.
A lane type is the same as a SIMD vector type with one lane, so it returns itself.
sourcepub fn log2_lane_bits(self) -> u8
pub fn log2_lane_bits(self) -> u8
Get log_2 of the number of bits in a lane.
sourcepub fn as_bool_pedantic(self) -> Self
pub fn as_bool_pedantic(self) -> Self
Get a type with the same number of lanes as this type, but with the lanes replaced by booleans of the same size.
Scalar types are treated as vectors with one lane, so they are converted to the multi-bit boolean types.
sourcepub fn as_bool(self) -> Self
pub fn as_bool(self) -> Self
Get a type with the same number of lanes as this type, but with the lanes replaced by booleans of the same size.
Scalar types are all converted to b1
which is usually what you want.
sourcepub fn half_width(self) -> Option<Self>
pub fn half_width(self) -> Option<Self>
Get a type with the same number of lanes as this type, but with lanes that are half the number of bits.
sourcepub fn double_width(self) -> Option<Self>
pub fn double_width(self) -> Option<Self>
Get a type with the same number of lanes as this type, but with lanes that are twice the number of bits.
sourcepub fn is_invalid(self) -> bool
pub fn is_invalid(self) -> bool
Is this the INVALID type?
sourcepub fn is_special(self) -> bool
pub fn is_special(self) -> bool
Is this a special type?
sourcepub fn is_lane(self) -> bool
pub fn is_lane(self) -> bool
Is this a lane type?
This is a scalar type that can also appear as the lane type of a SIMD vector.
sourcepub fn log2_lane_count(self) -> u8
pub fn log2_lane_count(self) -> u8
Get log_2 of the number of lanes in this SIMD vector type.
All SIMD types have a lane count that is a power of two and no larger than 256, so this will be a number in the range 0-8.
A scalar type is the same as a SIMD vector type with one lane, so it returns 0.
sourcepub fn lane_count(self) -> u16
pub fn lane_count(self) -> u16
Get the number of lanes in this SIMD vector type.
A scalar type is the same as a SIMD vector type with one lane, so it returns 1.
sourcepub fn by(self, n: u16) -> Option<Self>
pub fn by(self, n: u16) -> Option<Self>
Get a SIMD vector type with n
times more lanes than this one.
If this is a scalar type, this produces a SIMD type with this as a lane type and n
lanes.
If this is already a SIMD vector type, this produces a SIMD vector type with n * self.lane_count()
lanes.
sourcepub fn half_vector(self) -> Option<Self>
pub fn half_vector(self) -> Option<Self>
Get a SIMD vector with half the number of lanes.
There is no double_vector()
method. Use t.by(2)
instead.
sourcepub fn wider_or_equal(self, other: Self) -> bool
pub fn wider_or_equal(self, other: Self) -> bool
True iff:
self.lane_count() == other.lane_count()
andself.lane_bits() >= other.lane_bits()