Struct inkwell::values::FunctionValue
source · pub struct FunctionValue<'ctx> { /* private fields */ }
Implementations§
source§impl<'ctx> FunctionValue<'ctx>
impl<'ctx> FunctionValue<'ctx>
sourcepub unsafe fn new(value: LLVMValueRef) -> Option<Self>
pub unsafe fn new(value: LLVMValueRef) -> Option<Self>
pub fn get_linkage(self) -> Linkage
pub fn set_linkage(self, linkage: Linkage)
pub fn is_null(self) -> bool
pub fn is_undef(self) -> bool
pub fn print_to_stderr(self)
pub fn verify(self, print: bool) -> bool
pub fn get_next_function(self) -> Option<Self>
pub fn get_previous_function(self) -> Option<Self>
pub fn get_first_param(self) -> Option<BasicValueEnum<'ctx>>
pub fn get_last_param(self) -> Option<BasicValueEnum<'ctx>>
pub fn get_first_basic_block(self) -> Option<BasicBlock<'ctx>>
pub fn get_nth_param(self, nth: u32) -> Option<BasicValueEnum<'ctx>>
pub fn count_params(self) -> u32
pub fn count_basic_blocks(self) -> u32
pub fn get_basic_block_iter(self) -> BasicBlockIter<'ctx>
pub fn get_basic_blocks(self) -> Vec<BasicBlock<'ctx>>
pub fn get_param_iter(self) -> ParamValueIter<'ctx>
pub fn get_params(self) -> Vec<BasicValueEnum<'ctx>>
pub fn get_last_basic_block(self) -> Option<BasicBlock<'ctx>>
sourcepub fn view_function_cfg(self)
pub fn view_function_cfg(self)
View the control flow graph and produce a .dot file
sourcepub fn view_function_cfg_only(self)
pub fn view_function_cfg_only(self)
Only view the control flow graph
pub unsafe fn delete(self)
pub fn get_type(self) -> FunctionType<'ctx>
pub fn has_personality_function(self) -> bool
pub fn get_personality_function(self) -> Option<FunctionValue<'ctx>>
pub fn set_personality_function(self, personality_fn: FunctionValue<'ctx>)
pub fn get_intrinsic_id(self) -> u32
pub fn get_call_conventions(self) -> u32
pub fn set_call_conventions(self, call_conventions: u32)
pub fn get_gc(&self) -> &CStr
pub fn set_gc(self, gc: &str)
pub fn replace_all_uses_with(self, other: FunctionValue<'ctx>)
sourcepub fn add_attribute(self, loc: AttributeLoc, attribute: Attribute)
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);
sourcepub fn count_attributes(self, loc: AttributeLoc) -> u32
pub fn count_attributes(self, loc: AttributeLoc) -> u32
Counts the number of Attribute
s 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);
sourcepub fn attributes(self, loc: AttributeLoc) -> Vec<Attribute>
pub fn attributes(self, loc: AttributeLoc) -> Vec<Attribute>
Get all Attribute
s 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]);
sourcepub fn remove_string_attribute(self, loc: AttributeLoc, key: &str)
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");
sourcepub fn remove_enum_attribute(self, loc: AttributeLoc, kind_id: u32)
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);
sourcepub fn get_enum_attribute(
self,
loc: AttributeLoc,
kind_id: u32,
) -> Option<Attribute>
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));
sourcepub fn get_string_attribute(
self,
loc: AttributeLoc,
key: &str,
) -> Option<Attribute>
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));
pub fn set_param_alignment(self, param_index: u32, alignment: u32)
sourcepub fn as_global_value(self) -> GlobalValue<'ctx>
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
.
sourcepub fn set_subprogram(self, subprogram: DISubprogram<'ctx>)
pub fn set_subprogram(self, subprogram: DISubprogram<'ctx>)
Set the debug info descriptor
sourcepub fn get_subprogram(self) -> Option<DISubprogram<'ctx>>
pub fn get_subprogram(self) -> Option<DISubprogram<'ctx>>
Get the debug info descriptor
sourcepub fn get_section(&self) -> Option<&CStr>
pub fn get_section(&self) -> Option<&CStr>
Get the section to which this function belongs
sourcepub fn set_section(self, section: Option<&str>)
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>
impl<'ctx> AnyValue<'ctx> for FunctionValue<'ctx>
source§fn as_any_value_enum(&self) -> AnyValueEnum<'ctx>
fn as_any_value_enum(&self) -> AnyValueEnum<'ctx>
AnyValue
.source§fn print_to_string(&self) -> LLVMString
fn print_to_string(&self) -> LLVMString
LLVMString
source§impl AsValueRef for FunctionValue<'_>
impl AsValueRef for FunctionValue<'_>
fn as_value_ref(&self) -> LLVMValueRef
source§impl<'ctx> Clone for FunctionValue<'ctx>
impl<'ctx> Clone for FunctionValue<'ctx>
source§fn clone(&self) -> FunctionValue<'ctx>
fn clone(&self) -> FunctionValue<'ctx>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FunctionValue<'_>
impl Debug for FunctionValue<'_>
source§impl Display for FunctionValue<'_>
impl Display for FunctionValue<'_>
source§impl<'ctx> From<FunctionValue<'ctx>> for AnyValueEnum<'ctx>
impl<'ctx> From<FunctionValue<'ctx>> for AnyValueEnum<'ctx>
source§fn from(value: FunctionValue<'_>) -> AnyValueEnum<'_>
fn from(value: FunctionValue<'_>) -> AnyValueEnum<'_>
source§impl<'ctx> Hash for FunctionValue<'ctx>
impl<'ctx> Hash for FunctionValue<'ctx>
source§impl<'ctx> PartialEq<AnyValueEnum<'ctx>> for FunctionValue<'ctx>
impl<'ctx> PartialEq<AnyValueEnum<'ctx>> for FunctionValue<'ctx>
source§fn eq(&self, other: &AnyValueEnum<'ctx>) -> bool
fn eq(&self, other: &AnyValueEnum<'ctx>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'ctx> PartialEq<FunctionValue<'ctx>> for AnyValueEnum<'ctx>
impl<'ctx> PartialEq<FunctionValue<'ctx>> for AnyValueEnum<'ctx>
source§fn eq(&self, other: &FunctionValue<'ctx>) -> bool
fn eq(&self, other: &FunctionValue<'ctx>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'ctx> PartialEq for FunctionValue<'ctx>
impl<'ctx> PartialEq for FunctionValue<'ctx>
source§fn eq(&self, other: &FunctionValue<'ctx>) -> bool
fn eq(&self, other: &FunctionValue<'ctx>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'ctx> PassManagerSubType for FunctionValue<'ctx>
impl<'ctx> PassManagerSubType for FunctionValue<'ctx>
type Input = Module<'ctx>
unsafe fn create<I: Borrow<Self::Input>>(input: I) -> LLVMPassManagerRef
unsafe fn run_in_pass_manager(&self, pass_manager: &PassManager<Self>) -> bool
source§impl<'ctx> TryFrom<AnyValueEnum<'ctx>> for FunctionValue<'ctx>
impl<'ctx> TryFrom<AnyValueEnum<'ctx>> for FunctionValue<'ctx>
impl<'ctx> Copy for FunctionValue<'ctx>
impl<'ctx> Eq for FunctionValue<'ctx>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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