inkwell::values

Struct GlobalValue

source
pub struct GlobalValue<'ctx> { /* private fields */ }

Implementations§

source§

impl<'ctx> GlobalValue<'ctx>

source

pub unsafe fn new(value: LLVMValueRef) -> Self

Get a value from an LLVMValueRef.

§Safety

The ref must be valid and of type global.

source

pub fn get_name(&self) -> &CStr

Get name of the GlobalValue.

source

pub fn set_name(&self, name: &str)

Set name of the GlobalValue.

source

pub fn get_previous_global(self) -> Option<GlobalValue<'ctx>>

source

pub fn get_next_global(self) -> Option<GlobalValue<'ctx>>

source

pub fn get_dll_storage_class(self) -> DLLStorageClass

source

pub fn set_dll_storage_class(self, dll_storage_class: DLLStorageClass)

source

pub fn get_initializer(self) -> Option<BasicValueEnum<'ctx>>

source

pub fn set_initializer(self, value: &dyn BasicValue<'ctx>)

source

pub fn is_thread_local(self) -> bool

source

pub fn set_thread_local(self, is_thread_local: bool)

source

pub fn get_thread_local_mode(self) -> Option<ThreadLocalMode>

source

pub fn set_thread_local_mode(self, thread_local_mode: Option<ThreadLocalMode>)

source

pub fn is_declaration(self) -> bool

Determines whether or not a GlobalValue is a declaration or a definition.

§Example
use inkwell::context::Context;

let context = Context::create();
let builder = context.create_builder();
let module = context.create_module("my_mod");
let void_type = context.void_type();
let fn_type = void_type.fn_type(&[], false);
let fn_value = module.add_function("my_func", fn_type, None);

assert!(fn_value.as_global_value().is_declaration());

context.append_basic_block(fn_value, "entry");

assert!(!fn_value.as_global_value().is_declaration());
source

pub fn has_unnamed_addr(self) -> bool

Available on crate features llvm7-0 or llvm8-0 or llvm9-0 or llvm10-0 or llvm11-0 or llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-0 only.
source

pub fn set_unnamed_addr(self, has_unnamed_addr: bool)

Available on crate features llvm7-0 or llvm8-0 or llvm9-0 or llvm10-0 or llvm11-0 or llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-0 only.
source

pub fn is_constant(self) -> bool

source

pub fn set_constant(self, is_constant: bool)

source

pub fn is_externally_initialized(self) -> bool

source

pub fn set_externally_initialized(self, externally_initialized: bool)

source

pub fn set_visibility(self, visibility: GlobalVisibility)

source

pub fn get_visibility(self) -> GlobalVisibility

source

pub fn get_section(&self) -> Option<&CStr>

Get section, this global value belongs to

source

pub fn set_section(self, section: Option<&str>)

Set section, this global value belongs to

source

pub unsafe fn delete(self)

source

pub fn as_pointer_value(self) -> PointerValue<'ctx>

source

pub fn get_alignment(self) -> u32

source

pub fn set_alignment(self, alignment: u32)

source

pub fn set_metadata(self, metadata: MetadataValue<'ctx>, kind_id: u32)

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

Sets a metadata of the given type on the GlobalValue

source

pub fn get_comdat(self) -> Option<Comdat>

Available on crate features llvm7-0 or llvm8-0 or llvm9-0 or llvm10-0 or llvm11-0 or llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-0 only.

Gets a Comdat assigned to this GlobalValue, if any.

source

pub fn set_comdat(self, comdat: Comdat)

Available on crate features llvm7-0 or llvm8-0 or llvm9-0 or llvm10-0 or llvm11-0 or llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-0 only.

Assigns a Comdat to this GlobalValue.

source

pub fn get_unnamed_address(self) -> UnnamedAddress

Available on crate features llvm7-0 or llvm8-0 or llvm9-0 or llvm10-0 or llvm11-0 or llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-0 only.
source

pub fn set_unnamed_address(self, address: UnnamedAddress)

Available on crate features llvm7-0 or llvm8-0 or llvm9-0 or llvm10-0 or llvm11-0 or llvm12-0 or llvm13-0 or llvm14-0 or llvm15-0 or llvm16-0 or llvm17-0 or llvm18-0 only.
source

pub fn get_linkage(self) -> Linkage

source

pub fn set_linkage(self, linkage: Linkage)

source

pub fn get_value_type(self) -> AnyTypeEnum<'ctx>

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

Trait Implementations§

source§

impl<'ctx> AnyValue<'ctx> for GlobalValue<'ctx>

source§

fn as_any_value_enum(&self) -> AnyValueEnum<'ctx>

Returns an enum containing a typed version of AnyValue.
source§

fn print_to_string(&self) -> LLVMString

Prints a value to a LLVMString
source§

fn is_poison(&self) -> bool

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.
Returns whether the value is poison
source§

impl AsValueRef for GlobalValue<'_>

source§

impl<'ctx> BasicValue<'ctx> for GlobalValue<'ctx>

source§

fn as_basic_value_enum(&self) -> BasicValueEnum<'ctx>

Returns an enum containing a typed version of the BasicValue.
source§

fn as_instruction_value(&self) -> Option<InstructionValue<'ctx>>

Most BasicValues are the byproduct of an instruction and so are convertible into an InstructionValue
source§

fn get_first_use(&self) -> Option<BasicValueUse<'_>>

source§

fn set_name(&self, name: &str)

Sets the name of a BasicValue. If the value is a constant, this is a noop.
source§

impl<'ctx> Clone for GlobalValue<'ctx>

source§

fn clone(&self) -> GlobalValue<'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 GlobalValue<'ctx>

source§

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

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

impl Display for GlobalValue<'_>

source§

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

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

impl<'ctx> Hash for GlobalValue<'ctx>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl<'ctx> PartialEq for GlobalValue<'ctx>

source§

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

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

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

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

impl<'ctx> Copy for GlobalValue<'ctx>

source§

impl<'ctx> Eq for GlobalValue<'ctx>

source§

impl<'ctx> StructuralPartialEq for GlobalValue<'ctx>

Auto Trait Implementations§

§

impl<'ctx> Freeze for GlobalValue<'ctx>

§

impl<'ctx> RefUnwindSafe for GlobalValue<'ctx>

§

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

§

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

§

impl<'ctx> Unpin for GlobalValue<'ctx>

§

impl<'ctx> UnwindSafe for GlobalValue<'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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

source§

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>,

source§

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>,

source§

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.