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

A PointerType is the type of a pointer constant or variable.

Implementations§

Create PointerType from LLVMTypeRef

Safety

Undefined behavior, if referenced type isn’t pointer type

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();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
let f32_ptr_type_size = f32_ptr_type.size_of();

Gets the alignment 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();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
let f32_ptr_type_alignment = f32_ptr_type.get_alignment();

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();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
let f32_ptr_ptr_type = f32_ptr_type.ptr_type(AddressSpace::default());

#[cfg(not(feature = "llvm15-0"))]
assert_eq!(f32_ptr_ptr_type.get_element_type().into_pointer_type(), f32_ptr_type);

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();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());

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

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();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
let fn_type = f32_ptr_type.fn_type(&[], false);

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();
let f32_ptr_type = f32_type.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);

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();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());

assert_eq!(f32_ptr_type.get_address_space(), AddressSpace::default());

Print the definition of a PointerType to LLVMString.

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();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
let f32_ptr_null = f32_ptr_type.const_null();

assert!(f32_ptr_null.is_null());

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();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
let f32_ptr_zero = f32_ptr_type.const_zero();

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();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::default());
let f32_ptr_undef = f32_ptr_type.get_undef();

assert!(f32_ptr_undef.is_undef());

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();
let f32_ptr_type = f32_type.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);

Creates a constant ArrayValue.

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

let context = Context::create();
let f32_type = context.f32_type();
let f32_ptr_type = f32_type.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§

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
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
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.