Struct llvm_lib::core::context::AttributeRef

source ·
pub struct AttributeRef(/* private fields */);
Expand description

LLVM Attributes structure wrapper

Implementations§

source§

impl AttributeRef

source

pub fn get_enum_attribute_kind_for_name(name: &str) -> u32

Return the unique id given the name of the enum attribute, or 0 if no attribute by that name exists.

See http://llvm.org/docs/LangRef.html#parameter-attributes and http://llvm.org/docs/LangRef.html#function-attributes for the list of available attributes.

§Note

Attribute names and/or id are subject to change without going through the C API deprecation cycle.

§Details

Retrieves the enum attribute kind ID associated with a given name.

This function wraps the LLVMGetEnumAttributeKindForName function from the LLVM core library. It returns the kind ID of the enum attribute that corresponds to the provided name. This is useful for looking up the kind ID of an enum attribute by its name, allowing you to work with attributes in a more human-readable way.

§Parameters
  • name: A string slice (&str) representing the name of the enum attribute.
§Returns

Returns a u32 representing the kind ID associated with the provided attribute name.

source

pub fn get_last_enum_attribute_kind() -> u32

Get last enum attribute

§Details

Retrieves the highest (last) enum attribute kind ID used in LLVM.

This function wraps the LLVMGetLastEnumAttributeKind function from the LLVM core library. It returns the highest (last) enum attribute kind ID that is currently defined in LLVM. This can be useful for determining the range of valid enum attribute kinds or for iterating over all possible enum attributes.

§Returns

Returns a u32 representing the highest (last) enum attribute kind ID.

source

pub fn create_enum_attribute( context: &ContextRef, kind_id: u32, val: u64, ) -> Self

Create an enum attribute.

§Details

Creates an enum attribute in the specified LLVM context.

This function wraps the LLVMCreateEnumAttribute function from the LLVM core library. It creates and returns an enum attribute with the specified kind ID and value within the given LLVM context. Enum attributes in LLVM IR represent attributes that have a fixed set of possible values, and this function allows you to create such attributes with a specific value.

§Parameters
  • context: A reference to the ContextRef in which the enum attribute will be created.
  • kind_id: A u32 representing the kind ID of the enum attribute. This ID specifies the kind of the attribute.
  • val: A u64 representing the value of the enum attribute.
§Returns

Returns an instance of AttributeRef representing the created enum attribute.

source

pub fn get_enum_attribute_kind(&self) -> u32

Get the unique id corresponding to the enum attribute passed as argument.

§Details

Retrieves the kind (ID) of an enum attribute as a u32.

This function wraps the LLVMGetEnumAttributeKind function from the LLVM core library. It returns the kind or ID associated with the enum attribute represented by self. The kind ID identifies the specific attribute within the set of possible enum attributes in LLVM IR.

§Returns

Returns a u32 representing the kind (ID) of the enum attribute.

source

pub fn get_enum_attribute_value(&self) -> u64

Get the enum attribute’s value. 0 is returned if none exists.

§Details

Retrieves the value of an enum attribute as a u64.

This function wraps the LLVMGetEnumAttributeValue function from the LLVM core library. It returns the numeric value associated with the enum attribute represented by self. Enum attributes in LLVM IR typically represent attributes that have a fixed set of possible values, and this function allows you to access the value of such attributes.

§Returns

Returns a u64 representing the value of the enum attribute.

source

pub fn create_type_attribute( context: &ContextRef, kind_id: u32, type_ref: &TypeRef, ) -> Self

Create a type attribute

§Details

Creates a type attribute in the specified LLVM context.

This function wraps the LLVMCreateTypeAttribute function from the LLVM core library. It creates and returns a type attribute with the specified kind ID and associated type within the given LLVM context. Type attributes are used to annotate functions, instructions, or other entities with additional type information in LLVM IR.

§Parameters
  • context: A reference to the ContextRef in which the type attribute will be created.
  • kind_id: A u32 representing the kind ID of the type attribute. This ID specifies the kind of the attribute.
  • type_ref: A reference to the TypeRef representing the type associated with the attribute.
§Returns

Returns an instance of AttributeRef representing the created type attribute.

source

pub fn get_type_attribute_value(&self) -> TypeRef

Get the type attribute’s value.

§Details

Retrieves the type value of a type attribute.

This function wraps the LLVMGetTypeAttributeValue function from the LLVM core library. It returns the type associated with the type attribute represented by self. This function is useful for accessing the type information stored within a type attribute in LLVM IR.

§Returns

Returns a TypeRef representing the type value associated with the type attribute.

source

pub fn create_string_attribute( context: &ContextRef, key: &str, value: &str, ) -> Self

Create a string attribute.

§Details

Creates a string attribute in the specified LLVM context.

This function wraps the LLVMCreateStringAttribute function from the LLVM core library. It creates and returns a string attribute with the specified key and value within the given LLVM context. String attributes in LLVM IR are typically used to annotate functions, instructions, or other entities with additional metadata in the form of key-value pairs.

§Parameters
  • context: A reference to the ContextRef in which the string attribute will be created.
  • key: A string slice (&str) representing the key (kind) of the attribute.
  • value: A string slice (&str) representing the value of the attribute.
§Returns

Returns an instance of AttributeRef representing the created string attribute.

source

pub fn get_string_attribute_kind(&self) -> Option<String>

Get the string attribute’s kind.

§Details

Retrieves the kind (key) of a string attribute as a String.

This function wraps the LLVMGetStringAttributeKind function from the LLVM core library. It returns the kind or key associated with a string attribute represented by self. The kind is returned as a String if it exists; otherwise, None is returned. This function is useful for extracting the key part of key-value pair attributes in LLVM IR.

§Returns

Returns an Option<String>:

  • Some(String) containing the attribute kind (key) if it exists.
  • None if the attribute has no kind or the kind could not be retrieved.
source

pub fn get_string_attribute_value(&self) -> Option<String>

Get the string attribute’s value.

§Details

Retrieves the value of a string attribute as a String.

This function wraps the LLVMGetStringAttributeValue function from the LLVM core library. It returns the value associated with a string attribute represented by self. The value is returned as a String if the attribute has a value; otherwise, None is returned. This function is useful for extracting the value part of key-value pair attributes in LLVM IR.

§Returns

Returns an Option<String>:

  • Some(String) containing the attribute value if it exists.
  • None if the attribute has no value or the value could not be retrieved.
source

pub fn is_enum(&self) -> bool

Check for the types of attributes.

§Details

Checks whether the attribute is a string attribute.

This function wraps the LLVMIsStringAttribute function from the LLVM core library. It determines whether the attribute represented by self is a string attribute. String attributes are typically key-value pairs where the key is a string and the value may also be a string or other data.

§Returns

Returns true if the attribute is a string attribute, otherwise returns false.

source

pub fn is_string_attribute(&self) -> bool

Check for the types of attributes.

source

pub fn is_type_attribute(&self) -> bool

Check for the types of attributes.

§Details

Checks whether the attribute is a type attribute.

This function wraps the LLVMIsTypeAttribute function from the LLVM core library. It determines whether the attribute represented by self is a type attribute. Type attributes are associated with types rather than with functions or parameters.

§Returns

Returns true if the attribute is a type attribute, otherwise returns false.

Trait Implementations§

source§

impl From<*mut LLVMOpaqueAttributeRef> for AttributeRef

source§

fn from(value: LLVMAttributeRef) -> Self

Converts to this type from the input type.
source§

impl GetRef for AttributeRef

source§

type RawRef = *mut LLVMOpaqueAttributeRef

Raw LLVM reference type
source§

fn get_ref(&self) -> Self::RawRef

Get LLVM raw reference

Auto Trait Implementations§

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