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:

  • llvmlite.binding.name

    This type’s name, as a string.

  • llvmlite.binding.is_struct
    • True—The type is a struct type

    • False—The type is not a struct type

  • llvmlite.binding.is_pointer
    • True—The type is a pointer type

    • False—The type is not a pointer type

  • llvmlite.binding.is_array
    • True—The type is an array type

    • False—The type is not an array type

  • llvmlite.binding.is_vector
    • True—The type is a vector type

    • False—The type is not a vector type

  • llvmlite.binding.is_function_vararg
    • True— The function type accepts a variable number of arguments

    • False—The function type accepts a fixed number of arguments

  • llvmlite.binding.elements

    Returns an iterator over enclosing types. For example, the elements of an array or members of a struct.

  • llvmlite.binding.element_type

    If the type is a pointer, return the pointed-to type. Raises a ValueError if the type is not a pointer type.

  • llvmlite.binding.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.

  • llvmlite.binding.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.

  • llvmlite.binding.type_kind

    Returns the LLVMTypeKind enumeration of this type.

  • llvmlite.binding.__str__(self)

    Get the string IR representation of the type.