pub struct VectorType<'ctx> { /* private fields */ }
Expand description

A VectorType is the type of a multiple value SIMD constant or variable.

Implementations§

Create VectorType from LLVMTypeRef

Safety

Undefined behavior, if referenced type isn’t vector type

Gets the size of this VectorType. Value may vary depending on the target architecture.

Example
use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(3);
let f32_vec_type_size = f32_vec_type.size_of();

Gets the alignment of this VectorType. Value may vary depending on the target architecture.

Example
use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(7);
let f32_type_alignment = f32_vec_type.get_alignment();

Gets the size of this VectorType.

Example
use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vector_type = f32_type.vec_type(3);

assert_eq!(f32_vector_type.get_size(), 3);
assert_eq!(f32_vector_type.get_element_type().into_float_type(), f32_type);

Creates a constant VectorValue.

Example
use inkwell::context::Context;
use inkwell::types::VectorType;

let context = Context::create();
let f32_type = context.f32_type();
let f32_val = f32_type.const_float(0.);
let f32_val2 = f32_type.const_float(2.);
let f32_vec_val = VectorType::const_vector(&[f32_val, f32_val2]);

assert!(f32_vec_val.is_constant_vector());

Creates a constant zero value of this VectorType.

Example
use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(7);
let f32_vec_zero = f32_vec_type.const_zero();

Print the definition of a VectorType to LLVMString.

Creates an undefined instance of a VectorType.

Example
use inkwell::context::Context;
use inkwell::AddressSpace;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(3);
let f32_vec_undef = f32_vec_type.get_undef();

assert!(f32_vec_undef.is_undef());

Gets the element type of this VectorType.

Example
use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vector_type = f32_type.vec_type(3);

assert_eq!(f32_vector_type.get_size(), 3);
assert_eq!(f32_vector_type.get_element_type().into_float_type(), f32_type);

Creates a PointerType with this VectorType for its element type.

Example
use inkwell::context::Context;
use inkwell::AddressSpace;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(3);
let f32_vec_ptr_type = f32_vec_type.ptr_type(AddressSpace::default());

#[cfg(not(feature = "llvm15-0"))]
assert_eq!(f32_vec_ptr_type.get_element_type().into_vector_type(), f32_vec_type);

Creates a FunctionType with this VectorType for its return type.

Example
use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(3);
let fn_type = f32_vec_type.fn_type(&[], false);

Creates an ArrayType with this VectorType for its element type.

Example
use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(3);
let f32_vec_array_type = f32_vec_type.array_type(3);

assert_eq!(f32_vec_array_type.len(), 3);
assert_eq!(f32_vec_array_type.get_element_type().into_vector_type(), f32_vec_type);

Creates a constant ArrayValue.

Example
use inkwell::context::Context;
use inkwell::types::VectorType;

let context = Context::create();
let f32_type = context.f32_type();
let f32_val = f32_type.const_float(0.);
let f32_val2 = f32_type.const_float(2.);
let f32_vec_type = f32_type.vec_type(2);
let f32_vec_val = VectorType::const_vector(&[f32_val, f32_val2]);
let f32_array = f32_vec_type.const_array(&[f32_vec_val, f32_vec_val]);

assert!(f32_array.is_const());

Gets a reference to the Context this VectorType was created in.

Example
use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(7);

assert_eq!(f32_vec_type.get_context(), context);

Trait Implementations§

Returns an AnyTypeEnum that represents the current type.
Prints the definition of a Type to a LLVMString.
Returns a BasicTypeEnum that represents the current type.
Create a FunctionType with this BasicType as its return type. Read more
Determines whether or not this BasicType is sized or not. For example, opaque structs are unsized. Read more
Gets the size of this BasicType. Value may vary depending on the target architecture. Read more
Create an ArrayType with this BasicType as its elements. Read more
Create a PointerType that points to this BasicType. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
The value instance of a float or float vector type.
The type for float to int or float vector to int vector conversions.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
The value instance of an int or int vector type.
The type for int to float or int vector to float vector conversions.
The type for int to pointer or int vector to pointer vector conversions.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
The value instance of a pointer type.
The type for pointer to int or pointer vector to int conversions.
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.
The type returned in the event of a conversion error.
Performs the conversion.

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

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.