[−][src]Struct inkwell::values::CallSiteValue
A value resulting from a function call. It may have function attributes applied to it.
This struct may be removed in the future in favor of an InstructionValue<CallSite>
type.
Methods
impl CallSiteValue
[src]
pub fn set_tail_call(&self, tail_call: bool)
[src]
Sets whether or not this call is a tail call.
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_fn", fn_type, None); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.set_tail_call(true);
pub fn is_tail_call(&self) -> bool
[src]
Determines whether or not this call is a tail call.
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_fn", fn_type, None); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.set_tail_call(true); assert!(call_site_value.is_tail_call());
pub fn try_as_basic_value(&self) -> Either<BasicValueEnum, InstructionValue>
[src]
Try to convert this CallSiteValue
to a BasicValueEnum
if not a void return type.
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_fn", fn_type, None); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); assert!(call_site_value.try_as_basic_value().is_right());
pub fn add_attribute(&self, loc: AttributeLoc, attribute: Attribute)
[src]
Adds an Attribute
to this CallSiteValue
.
Example
use inkwell::attributes::AttributeLoc; 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_fn", fn_type, None); let string_attribute = context.create_string_attribute("my_key", "my_val"); let enum_attribute = context.create_enum_attribute(1, 1); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.add_attribute(AttributeLoc::Return, string_attribute); call_site_value.add_attribute(AttributeLoc::Return, enum_attribute);
pub fn get_called_fn_value(&self) -> FunctionValue
[src]
Gets the FunctionValue
this CallSiteValue
is based on.
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_fn", fn_type, None); let string_attribute = context.create_string_attribute("my_key", "my_val"); let enum_attribute = context.create_enum_attribute(1, 1); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); assert_eq!(call_site_value.get_called_fn_value(), fn_value);
pub fn count_attributes(&self, loc: AttributeLoc) -> u32
[src]
Counts the number of Attribute
s on this CallSiteValue
at an index.
Example
use inkwell::attributes::AttributeLoc; 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_fn", fn_type, None); let string_attribute = context.create_string_attribute("my_key", "my_val"); let enum_attribute = context.create_enum_attribute(1, 1); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.add_attribute(AttributeLoc::Return, string_attribute); call_site_value.add_attribute(AttributeLoc::Return, enum_attribute); assert_eq!(call_site_value.count_attributes(AttributeLoc::Return), 2);
pub fn get_enum_attribute(
&self,
loc: AttributeLoc,
kind_id: u32
) -> Option<Attribute>
[src]
&self,
loc: AttributeLoc,
kind_id: u32
) -> Option<Attribute>
Gets an enum Attribute
on this CallSiteValue
at an index and kind id.
Example
use inkwell::attributes::AttributeLoc; 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_fn", fn_type, None); let string_attribute = context.create_string_attribute("my_key", "my_val"); let enum_attribute = context.create_enum_attribute(1, 1); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.add_attribute(AttributeLoc::Return, string_attribute); call_site_value.add_attribute(AttributeLoc::Return, enum_attribute); assert_eq!(call_site_value.get_enum_attribute(AttributeLoc::Return, 1).unwrap(), enum_attribute);
pub fn get_string_attribute(
&self,
loc: AttributeLoc,
key: &str
) -> Option<Attribute>
[src]
&self,
loc: AttributeLoc,
key: &str
) -> Option<Attribute>
Gets a string Attribute
on this CallSiteValue
at an index and key.
Example
use inkwell::attributes::AttributeLoc; 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_fn", fn_type, None); let string_attribute = context.create_string_attribute("my_key", "my_val"); let enum_attribute = context.create_enum_attribute(1, 1); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.add_attribute(AttributeLoc::Return, string_attribute); call_site_value.add_attribute(AttributeLoc::Return, enum_attribute); assert_eq!(call_site_value.get_string_attribute(AttributeLoc::Return, "my_key").unwrap(), string_attribute);
pub fn remove_enum_attribute(&self, loc: AttributeLoc, kind_id: u32)
[src]
Removes an enum Attribute
on this CallSiteValue
at an index and kind id.
Example
use inkwell::attributes::AttributeLoc; 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_fn", fn_type, None); let string_attribute = context.create_string_attribute("my_key", "my_val"); let enum_attribute = context.create_enum_attribute(1, 1); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.add_attribute(AttributeLoc::Return, string_attribute); call_site_value.add_attribute(AttributeLoc::Return, enum_attribute); call_site_value.remove_enum_attribute(AttributeLoc::Return, 1); assert_eq!(call_site_value.get_enum_attribute(AttributeLoc::Return, 1), None);
pub fn remove_string_attribute(&self, loc: AttributeLoc, key: &str)
[src]
Removes a string Attribute
on this CallSiteValue
at an index and key.
Example
use inkwell::attributes::AttributeLoc; 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_fn", fn_type, None); let string_attribute = context.create_string_attribute("my_key", "my_val"); let enum_attribute = context.create_enum_attribute(1, 1); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.add_attribute(AttributeLoc::Return, string_attribute); call_site_value.add_attribute(AttributeLoc::Return, enum_attribute); call_site_value.remove_string_attribute(AttributeLoc::Return, "my_key"); assert_eq!(call_site_value.get_string_attribute(AttributeLoc::Return, "my_key"), None);
pub fn count_arguments(&self) -> u32
[src]
Counts the number of arguments this CallSiteValue
was called with.
Example
use inkwell::attributes::AttributeLoc; 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_fn", fn_type, None); let string_attribute = context.create_string_attribute("my_key", "my_val"); let enum_attribute = context.create_enum_attribute(1, 1); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); assert_eq!(call_site_value.count_arguments(), 0);
pub fn get_call_convention(&self) -> u32
[src]
Gets the calling convention for this CallSiteValue
.
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_fn", fn_type, None); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); assert_eq!(call_site_value.get_call_convention(), 0);
pub fn set_call_convention(&self, conv: u32)
[src]
Sets the calling convention for this CallSiteValue
.
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_fn", fn_type, None); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.set_call_convention(2); assert_eq!(call_site_value.get_call_convention(), 2);
pub fn set_alignment_attribute(&self, loc: AttributeLoc, alignment: u32)
[src]
Shortcut for setting the alignment Attribute
for this CallSiteValue
.
Panics
When the alignment is not a power of 2.
Example
use inkwell::attributes::AttributeLoc; 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_fn", fn_type, None); let entry_bb = fn_value.append_basic_block("entry"); builder.position_at_end(&entry_bb); let call_site_value = builder.build_call(fn_value, &[], "my_fn"); call_site_value.set_alignment_attribute(AttributeLoc::Param(0), 2);
pub fn print_to_string(&self) -> LLVMString
[src]
Prints the definition of a CallSiteValue
to a LLVMString
.
Trait Implementations
impl AnyValue for CallSiteValue
[src]
fn as_any_value_enum(&self) -> AnyValueEnum
[src]
impl Clone for CallSiteValue
[src]
fn clone(&self) -> CallSiteValue
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl PartialEq<CallSiteValue> for CallSiteValue
[src]
fn eq(&self, other: &CallSiteValue) -> bool
[src]
fn ne(&self, other: &CallSiteValue) -> bool
[src]
impl Copy for CallSiteValue
[src]
impl Hash for CallSiteValue
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Debug for CallSiteValue
[src]
Auto Trait Implementations
impl !Sync for CallSiteValue
impl !Send for CallSiteValue
impl Unpin for CallSiteValue
impl UnwindSafe for CallSiteValue
impl RefUnwindSafe for CallSiteValue
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,