Type references
A type reference wraps an LLVM type. It allows accessing type’s name and
IR representation. It is also accepted by methods like
TargetData.get_abi_size()
.
The TypeRef class
- class llvmlite.binding.TypeRef
A wrapper around an LLVM type. The attributes available are:
- name
This type’s name, as a string.
- is_struct
True
—The type is a struct typeFalse
—The type is not a struct type
- is_pointer
True
—The type is a pointer typeFalse
—The type is not a pointer type
- is_array
True
—The type is an array typeFalse
—The type is not an array type
- is_vector
True
—The type is a vector typeFalse
—The type is not a vector type
- is_function_vararg
True
— The function type accepts a variable number of argumentsFalse
—The function type accepts a fixed number of arguments
- elements
Returns an iterator over enclosing types. For example, the elements of an array or members of a struct.
- element_type
If the type is a pointer, return the pointed-to type. Raises a ValueError if the type is not a pointer type.
- element_count
Returns the number of elements in an array or a vector. For scalable vectors, returns minimum number of elements. When the type is neither an array nor a vector, raises exception.
- type_width
Return the basic size of this type if it is a primitive type. These are fixed by LLVM and are not target-dependent. This will return zero if the type does not have a size or is not a primitive type.
If this is a scalable vector type, the scalable property will be set and the runtime size will be a positive integer multiple of the base size.
Note that this may not reflect the size of memory allocated for an instance of the type or the number of bytes that are written when an instance of the type is stored to memory.
- type_kind
Returns the
LLVMTypeKind
enumeration of this type.
- as_ir(self, ir_ctx)
Convert into an
llvmlite.ir.Type
.
- __str__(self)
Get the string IR representation of the type.