About attributes¶
In LLVM, there are various kinds of attributes.
All attributes related to instructions are accessible by the corresponding class attributes.
However, there are attributes such as parameter attributes, function attributes, call site attributes and global attributes.
Attributes can be categorized into groups:
Attributes without arguments (zeroext, inreg, noalias…).
Attributes with a number argument (align(n), alignstack(n), …).
Attributes with an type argument (byref(ty), preallocated(ty), …).
Other attributes.
There is attributes with two params (vscale_range(min, max)).
All such attributes are stored in a dictionary, where the key is the attribute name and the value is the attribute argument tuple.
attrs = {
"zeroext": (),
"align": n,
"alignstack": n,
"byref": ty,
"preallocated": ty,
"vscale": (min, max)
}
You can find these attributes in the classes:
llvm2py.ir.function.Function
,
llvm2py.ir.global_variable.GlobalVariable
,
llvm2py.ir.instruction.Invoke
,
llvm2py.ir.instruction.CallBr
,
llvm2py.ir.instruction.Call
.
Fast math flags are represented by a set of strings, where the possible strings are bounded by the set: {“nnan”, “ninf”, “nsz”, “arcp”, “contract”, “afn”, “reassoc”}.
One of the classes: llvm2py.ir.instruction.BinOp
.