Struct Type
pub struct Type(/* private fields */);
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
, I64
, and I128
. These types are sign-agnostic.
Basic floating point types: F16
, F32
, F64
, and F128
. IEEE half, single, double, and quadruple precision.
SIMD vector types have power-of-two lanes, up to 256. Lanes can be any int/float type.
Note that this is encoded in a u16
currently for extensibility,
but allows only 14 bits to be used due to some bitpacking tricks
in the CLIF data structures.
Implementations§
§impl Type
impl Type
pub fn lane_type(self) -> Type
pub fn lane_type(self) -> Type
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.
pub fn lane_of(self) -> Type
pub fn lane_of(self) -> Type
The type transformation that returns the lane type of a type variable; it is just a renaming of lane_type() to be used in context where we think in terms of type variable transformations.
pub fn log2_lane_bits(self) -> u32
pub fn log2_lane_bits(self) -> u32
Get log_2 of the number of bits in a lane.
pub fn bounds(self, signed: bool) -> (u128, u128)
pub fn bounds(self, signed: bool) -> (u128, u128)
Get the (minimum, maximum) values represented by each lane in the type. Note that these are returned as unsigned ‘bit patterns’.
pub fn int(bits: u16) -> Option<Type>
pub fn int(bits: u16) -> Option<Type>
Get an integer type with the requested number of bits.
For the same thing but in bytes, use Self::int_with_byte_size
.
pub fn int_with_byte_size(bytes: u16) -> Option<Type>
pub fn int_with_byte_size(bytes: u16) -> Option<Type>
Get an integer type with the requested number of bytes.
For the same thing but in bits, use Self::int
.
pub fn as_truthy_pedantic(self) -> Type
pub fn as_truthy_pedantic(self) -> Type
Get a type with the same number of lanes as this type, but with the lanes replaced by booleans of the same size.
Lane types are treated as vectors with one lane, so they are converted to the multi-bit boolean types.
pub fn as_truthy(self) -> Type
pub fn as_truthy(self) -> Type
Get the type of a comparison result for the given type. For vectors this will be a vector
with the same number of lanes and integer elements, and for scalar types this will be i8
,
which is the result type of comparisons.
pub fn as_int(self) -> Type
pub fn as_int(self) -> Type
Get a type with the same number of lanes as this type, but with the lanes replaced by integers of the same size.
pub fn half_width(self) -> Option<Type>
pub fn half_width(self) -> Option<Type>
Get a type with the same number of lanes as this type, but with lanes that are half the number of bits.
pub fn double_width(self) -> Option<Type>
pub fn double_width(self) -> Option<Type>
Get a type with the same number of lanes as this type, but with lanes that are twice the number of bits.
pub fn is_invalid(self) -> bool
pub fn is_invalid(self) -> bool
Is this the INVALID type?
pub fn is_special(self) -> bool
pub fn is_special(self) -> bool
Is this a special type?
pub 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.
pub fn is_dynamic_vector(self) -> bool
pub fn is_dynamic_vector(self) -> bool
Is this a SIMD vector type with a runtime number of lanes?
pub fn log2_lane_count(self) -> u32
pub fn log2_lane_count(self) -> u32
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.
pub fn log2_min_lane_count(self) -> u32
pub fn log2_min_lane_count(self) -> u32
Get log_2 of the number of lanes in this vector/dynamic type.
pub fn lane_count(self) -> u32
pub fn lane_count(self) -> u32
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.
pub fn min_lane_count(self) -> u32
pub fn min_lane_count(self) -> u32
Get the minimum of lanes in this SIMD vector type, this supports both fixed and dynamic types.
pub fn by(self, n: u32) -> Option<Type>
pub fn by(self, n: u32) -> Option<Type>
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.
pub fn vector_to_dynamic(self) -> Option<Type>
pub fn vector_to_dynamic(self) -> Option<Type>
Convert a fixed vector type to a dynamic one.
pub fn dynamic_to_vector(self) -> Option<Type>
pub fn dynamic_to_vector(self) -> Option<Type>
Convert a dynamic vector type to a fixed one.
pub fn split_lanes(self) -> Option<Type>
pub fn split_lanes(self) -> Option<Type>
Split the lane width in half and double the number of lanes to maintain the same bit-width.
If this is a scalar type of n
bits, it produces a SIMD vector type of (n/2)x2
.
pub fn merge_lanes(self) -> Option<Type>
pub fn merge_lanes(self) -> Option<Type>
Merge lanes to half the number of lanes and double the lane width to maintain the same bit-width.
If this is a scalar type, it will return None
.
pub fn wider_or_equal(self, other: Type) -> bool
pub fn wider_or_equal(self, other: Type) -> bool
True iff:
self.lane_count() == other.lane_count()
andself.lane_bits() >= other.lane_bits()
pub fn triple_pointer_type(triple: &Triple) -> Type
pub fn triple_pointer_type(triple: &Triple) -> Type
Return the pointer type for the given target triple.
Trait Implementations§
§impl<'de> Deserialize<'de> for Type
impl<'de> Deserialize<'de> for Type
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Type, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Type, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Type
impl Serialize for Type
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Type
impl Eq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Freeze for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.