pub struct PointerType<'ctx> { /* private fields */ }Expand description
A PointerType is the type of a pointer constant or variable.
Implementations§
Source§impl<'ctx> PointerType<'ctx>
impl<'ctx> PointerType<'ctx>
Sourcepub unsafe fn new(ptr_type: LLVMTypeRef) -> Self
pub unsafe fn new(ptr_type: LLVMTypeRef) -> Self
Create PointerType from LLVMTypeRef
§Safety
Undefined behavior, if referenced type isn’t pointer type
Sourcepub fn size_of(self) -> IntValue<'ctx>
pub fn size_of(self) -> IntValue<'ctx>
Gets the size of this PointerType. Value may vary depending on the target architecture.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_type_size = f32_ptr_type.size_of();Sourcepub 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.
pub fn ptr_type(self, address_space: AddressSpace) -> PointerType<'ctx>
Starting from version 15.0, LLVM doesn’t differentiate between pointer types. Use Context::ptr_type instead.
Creates a PointerType with this PointerType for its element type.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_ptr_type = f32_ptr_type.ptr_type(AddressSpace::default());
#[cfg(feature = "typed-pointers")]
assert_eq!(f32_ptr_ptr_type.get_element_type().into_pointer_type(), f32_ptr_type);Sourcepub fn get_context(self) -> ContextRef<'ctx>
pub fn get_context(self) -> ContextRef<'ctx>
Gets a reference to the Context this PointerType was created in.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
assert_eq!(f32_ptr_type.get_context(), context);Sourcepub fn fn_type(
self,
param_types: &[BasicMetadataTypeEnum<'ctx>],
is_var_args: bool,
) -> FunctionType<'ctx>
pub fn fn_type( self, param_types: &[BasicMetadataTypeEnum<'ctx>], is_var_args: bool, ) -> FunctionType<'ctx>
Creates a FunctionType with this PointerType for its return type.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let fn_type = f32_ptr_type.fn_type(&[], false);Sourcepub fn array_type(self, size: u32) -> ArrayType<'ctx>
pub fn array_type(self, size: u32) -> ArrayType<'ctx>
Creates an ArrayType with this PointerType for its element type.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_array_type = f32_ptr_type.array_type(3);
assert_eq!(f32_ptr_array_type.len(), 3);
assert_eq!(f32_ptr_array_type.get_element_type().into_pointer_type(), f32_ptr_type);Sourcepub fn get_address_space(self) -> AddressSpace
pub fn get_address_space(self) -> AddressSpace
Gets the AddressSpace a PointerType was created with.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
assert_eq!(f32_ptr_type.get_address_space(), AddressSpace::default());Sourcepub fn print_to_string(self) -> LLVMString
pub fn print_to_string(self) -> LLVMString
Print the definition of a PointerType to LLVMString.
Sourcepub fn const_null(self) -> PointerValue<'ctx>
pub fn const_null(self) -> PointerValue<'ctx>
Creates a null PointerValue of this PointerType.
It will be automatically assigned this PointerType’s Context.
§Example
use inkwell::AddressSpace;
use inkwell::context::Context;
// Local Context
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_null = f32_ptr_type.const_null();
assert!(f32_ptr_null.is_null());Sourcepub fn const_zero(self) -> PointerValue<'ctx>
pub fn const_zero(self) -> PointerValue<'ctx>
Creates a constant null value of this PointerType.
This is practically the same as calling const_null for this particular type and
so this function may be removed in the future.
§Example
use inkwell::AddressSpace;
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_zero = f32_ptr_type.const_zero();Sourcepub fn get_undef(self) -> PointerValue<'ctx>
pub fn get_undef(self) -> PointerValue<'ctx>
Creates an undefined instance of a PointerType.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_undef = f32_ptr_type.get_undef();
assert!(f32_ptr_undef.is_undef());Sourcepub fn get_poison(self) -> PointerValue<'ctx>
Available on crate features llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-1 or llvm19-1 or llvm20-1 or llvm21-1 or llvm22-1 only.
pub fn get_poison(self) -> PointerValue<'ctx>
llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-1 or llvm19-1 or llvm20-1 or llvm21-1 or llvm22-1 only.Creates a poison instance of a PointerType.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
use inkwell::values::AnyValue;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_undef = f32_ptr_type.get_poison();
assert!(f32_ptr_undef.is_poison());Sourcepub fn vec_type(self, size: u32) -> VectorType<'ctx>
pub fn vec_type(self, size: u32) -> VectorType<'ctx>
Creates a VectorType with this PointerType for its element type.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_vec_type = f32_ptr_type.vec_type(3);
assert_eq!(f32_ptr_vec_type.get_size(), 3);
assert_eq!(f32_ptr_vec_type.get_element_type().into_pointer_type(), f32_ptr_type);Sourcepub fn scalable_vec_type(self, size: u32) -> ScalableVectorType<'ctx>
Available on crate features llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-1 or llvm19-1 or llvm20-1 or llvm21-1 or llvm22-1 only.
pub fn scalable_vec_type(self, size: u32) -> ScalableVectorType<'ctx>
llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-1 or llvm19-1 or llvm20-1 or llvm21-1 or llvm22-1 only.Creates a ScalableVectorType with this PointerType for its element type.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_scalable_vec_type = f32_ptr_type.scalable_vec_type(3);
assert_eq!(f32_ptr_scalable_vec_type.get_size(), 3);
assert_eq!(f32_ptr_scalable_vec_type.get_element_type().into_pointer_type(), f32_ptr_type);Sourcepub fn const_array(self, values: &[PointerValue<'ctx>]) -> ArrayValue<'ctx>
pub fn const_array(self, values: &[PointerValue<'ctx>]) -> ArrayValue<'ctx>
Creates a constant ArrayValue.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
#[cfg(feature = "typed-pointers")]
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
#[cfg(not(feature = "typed-pointers"))]
let f32_ptr_type = context.ptr_type(AddressSpace::default());
let f32_ptr_val = f32_ptr_type.const_null();
let f32_ptr_array = f32_ptr_type.const_array(&[f32_ptr_val, f32_ptr_val]);
assert!(f32_ptr_array.is_const());Trait Implementations§
Source§impl<'ctx> AnyType<'ctx> for PointerType<'ctx>
impl<'ctx> AnyType<'ctx> for PointerType<'ctx>
Source§fn as_any_type_enum(&self) -> AnyTypeEnum<'ctx>
fn as_any_type_enum(&self) -> AnyTypeEnum<'ctx>
AnyTypeEnum that represents the current type.Source§fn print_to_string(&self) -> LLVMString
fn print_to_string(&self) -> LLVMString
LLVMString.Source§impl AsTypeRef for PointerType<'_>
impl AsTypeRef for PointerType<'_>
Source§fn as_type_ref(&self) -> LLVMTypeRef
fn as_type_ref(&self) -> LLVMTypeRef
Source§impl<'ctx> BasicType<'ctx> for PointerType<'ctx>
impl<'ctx> BasicType<'ctx> for PointerType<'ctx>
Source§fn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx>
fn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx>
BasicTypeEnum that represents the current type.Source§fn fn_type(
&self,
param_types: &[BasicMetadataTypeEnum<'ctx>],
is_var_args: bool,
) -> FunctionType<'ctx>
fn fn_type( &self, param_types: &[BasicMetadataTypeEnum<'ctx>], is_var_args: bool, ) -> FunctionType<'ctx>
Source§fn is_sized(&self) -> bool
fn is_sized(&self) -> bool
BasicType is sized or not.
For example, opaque structs are unsized. Read moreSource§fn size_of(&self) -> Option<IntValue<'ctx>>
fn size_of(&self) -> Option<IntValue<'ctx>>
BasicType. Value may vary depending on the target architecture. Read moreSource§fn get_alignment(&self) -> IntValue<'ctx>
fn get_alignment(&self) -> IntValue<'ctx>
BasicType. Value may vary depending on the target architecture. Read moreSource§fn array_type(&self, size: u32) -> ArrayType<'ctx>
fn array_type(&self, size: u32) -> ArrayType<'ctx>
Source§fn ptr_type(&self, address_space: AddressSpace) -> PointerType<'ctx>
fn ptr_type(&self, address_space: AddressSpace) -> PointerType<'ctx>
Starting from version 15.0, LLVM doesn’t differentiate between pointer types. Use Context::ptr_type instead.
Source§impl<'ctx> Clone for PointerType<'ctx>
impl<'ctx> Clone for PointerType<'ctx>
Source§fn clone(&self) -> PointerType<'ctx>
fn clone(&self) -> PointerType<'ctx>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more