Struct inkwell::values::FunctionValue

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

Implementations§

source§

impl<'ctx> FunctionValue<'ctx>

source

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

Get a value from an LLVMValueRef.

§Safety

The ref must be valid and of type function.

source

pub fn get_linkage(self) -> Linkage

source

pub fn set_linkage(self, linkage: Linkage)

source

pub fn is_null(self) -> bool

source

pub fn is_undef(self) -> bool

source

pub fn print_to_stderr(self)

source

pub fn verify(self, print: bool) -> bool

source

pub fn get_next_function(self) -> Option<Self>

source

pub fn get_previous_function(self) -> Option<Self>

source

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

source

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

source

pub fn get_first_basic_block(self) -> Option<BasicBlock<'ctx>>

source

pub fn get_nth_param(self, nth: u32) -> Option<BasicValueEnum<'ctx>>

source

pub fn count_params(self) -> u32

source

pub fn count_basic_blocks(self) -> u32

source

pub fn get_basic_block_iter(self) -> BasicBlockIter<'ctx>

source

pub fn get_basic_blocks(self) -> Vec<BasicBlock<'ctx>>

source

pub fn get_param_iter(self) -> ParamValueIter<'ctx>

source

pub fn get_params(self) -> Vec<BasicValueEnum<'ctx>>

source

pub fn get_last_basic_block(self) -> Option<BasicBlock<'ctx>>

source

pub fn get_name(&self) -> &CStr

Gets the name of a FunctionValue.

source

pub fn view_function_cfg(self)

View the control flow graph and produce a .dot file

source

pub fn view_function_cfg_only(self)

Only view the control flow graph

source

pub unsafe fn delete(self)

source

pub fn get_type(self) -> FunctionType<'ctx>

source

pub fn has_personality_function(self) -> bool

source

pub fn get_personality_function(self) -> Option<FunctionValue<'ctx>>

source

pub fn set_personality_function(self, personality_fn: FunctionValue<'ctx>)

source

pub fn get_intrinsic_id(self) -> u32

source

pub fn get_call_conventions(self) -> u32

source

pub fn set_call_conventions(self, call_conventions: u32)

source

pub fn get_gc(&self) -> &CStr

source

pub fn set_gc(self, gc: &str)

source

pub fn replace_all_uses_with(self, other: FunctionValue<'ctx>)

source

pub fn add_attribute(self, loc: AttributeLoc, attribute: Attribute)

Adds an Attribute to a particular location in this FunctionValue.

§Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
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_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, string_attribute);
fn_value.add_attribute(AttributeLoc::Return, enum_attribute);
source

pub fn count_attributes(self, loc: AttributeLoc) -> u32

Counts the number of Attributes belonging to the specified location in this FunctionValue.

§Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
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_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, string_attribute);
fn_value.add_attribute(AttributeLoc::Return, enum_attribute);

assert_eq!(fn_value.count_attributes(AttributeLoc::Return), 2);
source

pub fn attributes(self, loc: AttributeLoc) -> Vec<Attribute>

Get all Attributes belonging to the specified location in this FunctionValue.

§Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
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_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, string_attribute);
fn_value.add_attribute(AttributeLoc::Return, enum_attribute);

assert_eq!(fn_value.attributes(AttributeLoc::Return), vec![string_attribute, enum_attribute]);
source

pub fn remove_string_attribute(self, loc: AttributeLoc, key: &str)

Removes a string Attribute belonging to the specified location in this FunctionValue.

§Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
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_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");

fn_value.add_attribute(AttributeLoc::Return, string_attribute);
fn_value.remove_string_attribute(AttributeLoc::Return, "my_key");
source

pub fn remove_enum_attribute(self, loc: AttributeLoc, kind_id: u32)

Removes an enum Attribute belonging to the specified location in this FunctionValue.

§Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
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_fn", fn_type, None);
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, enum_attribute);
fn_value.remove_enum_attribute(AttributeLoc::Return, 1);
source

pub fn get_enum_attribute( self, loc: AttributeLoc, kind_id: u32, ) -> Option<Attribute>

Gets an enum Attribute belonging to the specified location in this FunctionValue.

§Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
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_fn", fn_type, None);
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, enum_attribute);

assert_eq!(fn_value.get_enum_attribute(AttributeLoc::Return, 1), Some(enum_attribute));
source

pub fn get_string_attribute( self, loc: AttributeLoc, key: &str, ) -> Option<Attribute>

Gets a string Attribute belonging to the specified location in this FunctionValue.

§Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
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_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");

fn_value.add_attribute(AttributeLoc::Return, string_attribute);

assert_eq!(fn_value.get_string_attribute(AttributeLoc::Return, "my_key"), Some(string_attribute));
source

pub fn set_param_alignment(self, param_index: u32, alignment: u32)

source

pub fn as_global_value(self) -> GlobalValue<'ctx>

Gets the GlobalValue version of this FunctionValue. This allows you to further inspect its global properties or even convert it to a PointerValue.

source

pub fn set_subprogram(self, subprogram: DISubprogram<'ctx>)

Set the debug info descriptor

source

pub fn get_subprogram(self) -> Option<DISubprogram<'ctx>>

Get the debug info descriptor

source

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

Get the section to which this function belongs

source

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

Set the section to which this function should belong

Trait Implementations§

source§

impl<'ctx> AnyValue<'ctx> for FunctionValue<'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

Returns whether the value is poison
source§

impl AsValueRef for FunctionValue<'_>

source§

impl<'ctx> Clone for FunctionValue<'ctx>

source§

fn clone(&self) -> FunctionValue<'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 Debug for FunctionValue<'_>

source§

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

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

impl Display for FunctionValue<'_>

source§

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

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

impl<'ctx> From<FunctionValue<'ctx>> for AnyValueEnum<'ctx>

source§

fn from(value: FunctionValue<'_>) -> AnyValueEnum<'_>

Converts to this type from the input type.
source§

impl<'ctx> Hash for FunctionValue<'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<AnyValueEnum<'ctx>> for FunctionValue<'ctx>

source§

fn eq(&self, other: &AnyValueEnum<'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> PartialEq<FunctionValue<'ctx>> for AnyValueEnum<'ctx>

source§

fn eq(&self, other: &FunctionValue<'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> PartialEq for FunctionValue<'ctx>

source§

fn eq(&self, other: &FunctionValue<'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> PassManagerSubType for FunctionValue<'ctx>

§

type Input = Module<'ctx>

source§

unsafe fn create<I: Borrow<Self::Input>>(input: I) -> LLVMPassManagerRef

source§

unsafe fn run_in_pass_manager(&self, pass_manager: &PassManager<Self>) -> bool

source§

impl<'ctx> TryFrom<AnyValueEnum<'ctx>> for FunctionValue<'ctx>

§

type Error = ()

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

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

Performs the conversion.
source§

impl<'ctx> Copy for FunctionValue<'ctx>

source§

impl<'ctx> Eq for FunctionValue<'ctx>

source§

impl<'ctx> StructuralPartialEq for FunctionValue<'ctx>

Auto Trait Implementations§

§

impl<'ctx> Freeze for FunctionValue<'ctx>

§

impl<'ctx> RefUnwindSafe for FunctionValue<'ctx>

§

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

§

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

§

impl<'ctx> Unpin for FunctionValue<'ctx>

§

impl<'ctx> UnwindSafe for FunctionValue<'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.