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, I64, and I128. These types are sign-agnostic.

Basic floating point types: F32 and F64. IEEE single and double precision.

Boolean types: B1, B8, B16, B32, B64, and B128. 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

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.

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.

Get log_2 of the number of bits in a lane.

Get the number of bits in a lane.

Get the (minimum, maximum) values represented by each lane in the type. Note that these are returned as unsigned ‘bit patterns’.

Get an integer type with the requested number of bits.

For the same thing but in bytes, use Self::int_with_byte_size.

Get an integer type with the requested number of bytes.

For the same thing but in bits, use Self::int.

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.

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.

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

Get a type with the same number of lanes as this type, but with lanes that are half the number of bits.

Get a type with the same number of lanes as this type, but with lanes that are twice the number of bits.

Is this the INVALID type?

Is this a special type?

Is this a lane type?

This is a scalar type that can also appear as the lane type of a SIMD vector.

Is this a SIMD vector type?

A vector type has 2 or more lanes.

Is this a scalar boolean type?

Is this a vector boolean type?

Is this a scalar integer type?

Is this a scalar floating point type?

Is this a CPU flags type?

Is this a ref type?

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.

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.

Get the total number of bits used to represent this type.

Get the number of bytes used to store this type in memory.

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.

Get a SIMD vector with half the number of lanes.

There is no double_vector() method. Use t.by(2) instead.

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.

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.

Index of this type, for use with hash tables etc.

True iff:

  1. self.lane_count() == other.lane_count() and
  2. self.lane_bits() >= other.lane_bits()

Return the pointer type for the given target triple.

Coerces boolean types (scalar and vectors) into their integer counterparts. B1 is converted into I8.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.