Attribute Macro inkwell_internals::llvm_enum
source · #[llvm_enum]
Expand description
This attribute macro allows you to decorate an enum declaration which represents an LLVM enum with versioning constraints and/or custom variant names. There are a few expectations around the LLVM and Rust enums:
- Both enums have the same number of variants
- The name of the LLVM variant can be derived by appending ‘LLVM’ to the Rust variant
The latter can be worked around manually with #[llvm_variant]
if desired.
§Examples
ⓘ
#[llvm_enum(LLVMOpcode)]
enum InstructionOpcode {
Call,
#[llvm_versions(3.8..)]
CatchPad,
...,
#[llvm_variant(LLVMRet)]
Return,
...
}
The use of #[llvm_variant(NAME)]
allows you to override the default
naming scheme by providing the variant name which the source enum maps
to. In the above example, Ret
was deemed unnecessarily concise, so the
source variant is named Return
and mapped manually to LLVMRet
.