pub struct AttributeRef(/* private fields */);
Expand description
LLVM Attributes structure wrapper
Implementations§
Source§impl AttributeRef
impl AttributeRef
Sourcepub fn get_enum_attribute_kind_for_name(name: &str) -> u32
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.
Sourcepub fn get_last_enum_attribute_kind() -> u32
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.
Sourcepub fn create_enum_attribute(
context: &ContextRef,
kind_id: u32,
val: u64,
) -> Self
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 theContextRef
in which the enum attribute will be created.kind_id
: Au32
representing the kind ID of the enum attribute. This ID specifies the kind of the attribute.val
: Au64
representing the value of the enum attribute.
§Returns
Returns an instance of AttributeRef
representing the created enum attribute.
Sourcepub fn get_enum_attribute_kind(&self) -> u32
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.
Sourcepub fn get_enum_attribute_value(&self) -> u64
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.
Sourcepub fn create_type_attribute(
context: &ContextRef,
kind_id: u32,
type_ref: &TypeRef,
) -> Self
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 theContextRef
in which the type attribute will be created.kind_id
: Au32
representing the kind ID of the type attribute. This ID specifies the kind of the attribute.type_ref
: A reference to theTypeRef
representing the type associated with the attribute.
§Returns
Returns an instance of AttributeRef
representing the created type attribute.
Sourcepub fn get_type_attribute_value(&self) -> TypeRef
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.
Sourcepub fn create_string_attribute(
context: &ContextRef,
key: &str,
value: &str,
) -> Self
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 theContextRef
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.
Sourcepub fn get_string_attribute_kind(&self) -> Option<String>
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.
Sourcepub fn get_string_attribute_value(&self) -> Option<String>
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.
Sourcepub fn is_enum(&self) -> bool
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
.
Sourcepub fn is_string_attribute(&self) -> bool
pub fn is_string_attribute(&self) -> bool
Check for the types of attributes.
Sourcepub fn is_type_attribute(&self) -> bool
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
.