Struct inkwell::types::VectorType

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

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

Implementations§

source§

impl<'ctx> VectorType<'ctx>

source

pub unsafe fn new(vector_type: LLVMTypeRef) -> Self

Create VectorType from LLVMTypeRef

§Safety

Undefined behavior, if referenced type isn’t vector type

source

pub fn size_of(self) -> Option<IntValue<'ctx>>

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();
source

pub fn get_alignment(self) -> IntValue<'ctx>

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();
source

pub fn get_size(self) -> u32

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);
source

pub fn const_vector<V: BasicValue<'ctx>>(values: &[V]) -> VectorValue<'ctx>

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());
source

pub fn const_zero(self) -> VectorValue<'ctx>

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();
source

pub fn print_to_string(self) -> LLVMString

Print the definition of a VectorType to LLVMString.

source

pub fn get_undef(self) -> VectorValue<'ctx>

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());
source

pub fn get_poison(self) -> VectorValue<'ctx>

Available on crate features llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-0 only.

Creates a poison 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_poison = f32_vec_type.get_undef();

assert!(f32_vec_poison.is_undef());
source

pub fn get_element_type(self) -> BasicTypeEnum<'ctx>

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);
source

pub fn ptr_type(self, address_space: AddressSpace) -> PointerType<'ctx>

👎Deprecated: Starting from version 15.0, LLVM doesn’t differentiate between pointer types. Use Context::ptr_type instead.

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(any(
    feature = "llvm4-0",
    feature = "llvm5-0",
    feature = "llvm6-0",
    feature = "llvm7-0",
    feature = "llvm8-0",
    feature = "llvm9-0",
    feature = "llvm10-0",
    feature = "llvm11-0",
    feature = "llvm12-0",
    feature = "llvm13-0",
    feature = "llvm14-0"
))]
assert_eq!(f32_vec_ptr_type.get_element_type().into_vector_type(), f32_vec_type);
source

pub fn fn_type( self, param_types: &[BasicMetadataTypeEnum<'ctx>], is_var_args: bool ) -> FunctionType<'ctx>

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);
source

pub fn array_type(self, size: u32) -> ArrayType<'ctx>

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);
source

pub fn const_array(self, values: &[VectorValue<'ctx>]) -> ArrayValue<'ctx>

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());
source

pub fn get_context(self) -> ContextRef<'ctx>

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§

source§

impl<'ctx> AnyType<'ctx> for VectorType<'ctx>

source§

fn as_any_type_enum(&self) -> AnyTypeEnum<'ctx>

Returns an AnyTypeEnum that represents the current type.
source§

fn print_to_string(&self) -> LLVMString

Prints the definition of a Type to a LLVMString.
source§

impl AsTypeRef for VectorType<'_>

source§

fn as_type_ref(&self) -> LLVMTypeRef

Returns the internal LLVM reference behind the type
source§

impl<'ctx> BasicType<'ctx> for VectorType<'ctx>

source§

fn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx>

Returns a BasicTypeEnum that represents the current type.
source§

fn fn_type( &self, param_types: &[BasicMetadataTypeEnum<'ctx>], is_var_args: bool ) -> FunctionType<'ctx>

Create a FunctionType with this BasicType as its return type. Read more
source§

fn is_sized(&self) -> bool

Determines whether or not this BasicType is sized or not. For example, opaque structs are unsized. Read more
source§

fn size_of(&self) -> Option<IntValue<'ctx>>

Gets the size of this BasicType. Value may vary depending on the target architecture. Read more
source§

fn array_type(&self, size: u32) -> ArrayType<'ctx>

Create an ArrayType with this BasicType as its elements. Read more
source§

fn ptr_type(&self, address_space: AddressSpace) -> PointerType<'ctx>

👎Deprecated: Starting from version 15.0, LLVM doesn’t differentiate between pointer types. Use Context::ptr_type instead.
Create a PointerType that points to this BasicType. Read more
source§

impl<'ctx> Clone for VectorType<'ctx>

source§

fn clone(&self) -> VectorType<'ctx>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'ctx> Debug for VectorType<'ctx>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for VectorType<'_>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'ctx> FloatMathType<'ctx> for VectorType<'ctx>

§

type ValueType = VectorValue<'ctx>

The value instance of a float or float vector type.
§

type MathConvType = VectorType<'ctx>

The type for float to int or float vector to int vector conversions.
source§

impl<'ctx> From<VectorType<'ctx>> for AnyTypeEnum<'ctx>

source§

fn from(value: VectorType<'_>) -> AnyTypeEnum<'_>

Converts to this type from the input type.
source§

impl<'ctx> From<VectorType<'ctx>> for BasicMetadataTypeEnum<'ctx>

source§

fn from(value: VectorType<'_>) -> BasicMetadataTypeEnum<'_>

Converts to this type from the input type.
source§

impl<'ctx> From<VectorType<'ctx>> for BasicTypeEnum<'ctx>

source§

fn from(value: VectorType<'_>) -> BasicTypeEnum<'_>

Converts to this type from the input type.
source§

impl<'ctx> IntMathType<'ctx> for VectorType<'ctx>

§

type ValueType = VectorValue<'ctx>

The value instance of an int or int vector type.
§

type MathConvType = VectorType<'ctx>

The type for int to float or int vector to float vector conversions.
§

type PtrConvType = VectorType<'ctx>

The type for int to pointer or int vector to pointer vector conversions.
source§

impl<'ctx> PartialEq for VectorType<'ctx>

source§

fn eq(&self, other: &VectorType<'ctx>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'ctx> PointerMathType<'ctx> for VectorType<'ctx>

§

type ValueType = VectorValue<'ctx>

The value instance of a pointer type.
§

type PtrConvType = VectorType<'ctx>

The type for pointer to int or pointer vector to int conversions.
source§

impl<'ctx> TryFrom<AnyTypeEnum<'ctx>> for VectorType<'ctx>

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: AnyTypeEnum<'ctx>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'ctx> TryFrom<BasicMetadataTypeEnum<'ctx>> for VectorType<'ctx>

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: BasicMetadataTypeEnum<'ctx>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'ctx> TryFrom<BasicTypeEnum<'ctx>> for VectorType<'ctx>

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: BasicTypeEnum<'ctx>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'ctx> Copy for VectorType<'ctx>

source§

impl<'ctx> Eq for VectorType<'ctx>

source§

impl<'ctx> StructuralPartialEq for VectorType<'ctx>

Auto Trait Implementations§

§

impl<'ctx> Freeze for VectorType<'ctx>

§

impl<'ctx> RefUnwindSafe for VectorType<'ctx>

§

impl<'ctx> !Send for VectorType<'ctx>

§

impl<'ctx> !Sync for VectorType<'ctx>

§

impl<'ctx> Unpin for VectorType<'ctx>

§

impl<'ctx> UnwindSafe for VectorType<'ctx>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.