Value references

A value reference is a wrapper around an LLVM value for you to inspect. You cannot create a value reference yourself. You get them from methods of the ModuleRef and ValueRef classes.

Enumerations

class llvmlite.binding.Linkage

The linkage types allowed for global values are:

  • external
  • available_externally
  • linkonce_any
  • linkonce_odr
  • linkonce_odr_autohide
  • weak_any
  • weak_odr
  • appending
  • internal
  • private
  • dllimport
  • dllexport
  • external_weak
  • ghost
  • common
  • linker_private
  • linker_private_weak
class llvmlite.binding.Visibility

The visibility styles allowed for global values are:

class llvmlite.binding.StorageClass

The storage classes allowed for global values are:

class llvmlite.binding.ValueKind

The value kinds allowed are:

  • argument
  • basic_block
  • memory_use
  • memory_def
  • memory_phi
  • function
  • global_alias
  • global_ifunc
  • global_variable
  • block_address
  • constant_expr
  • constant_array
  • constant_struct
  • constant_vector
  • undef_value
  • constant_aggregate_zero
  • constant_data_array
  • constant_data_vector
  • constant_int
  • constant_fp
  • constant_pointer_null
  • constant_token_none
  • metadata_as_value
  • inline_asm
  • instruction
  • poison_value

The ValueRef class

class llvmlite.binding.ValueRef

A wrapper around an LLVM value. The attributes available are:

  • is_declaration
    • True—The global value is a mere declaration.

    • False—The global value is defined in the given module.

  • linkage

    The linkage type—a Linkage instance—for this value. This attribute can be set.

  • module

    The module—a ModuleRef instance—that this value is defined in.

  • function

    The function—a ValueRef instance—that this value is defined in.

  • block

    The basic block—a ValueRef instance—that this value is defined in.

  • instruction

    The instruction—a ValueRef instance—that this value is defined in.

  • name

    This value’s name, as a string. This attribute can be set.

  • type

    This value’s LLVM type as TypeRef object.

  • storage_class

    The storage class—a StorageClass instance—for this value. This attribute can be set.

  • visibility

    The visibility style—a Visibility instance—for this value. This attribute can be set.

  • value_kind

    The LLVM value kind—a ValueKind instance—for this value.

  • blocks

    An iterator over the basic blocks in this function. Each block is a ValueRef instance.

  • arguments

    An iterator over the arguments of this function. Each argument is a ValueRef instance.

  • instructions

    An iterator over the instructions in this basic block. Each instruction is a ValueRef instance.

  • incoming_blocks

    An iterator over the incoming blocks of a phi instruction. Each block is a ValueRef instance.

  • operands

    An iterator over the operands in this instruction. Each operand is a ValueRef instance.

  • opcode

    The instruction’s opcode, as a string.

  • attributes

    An iterator over the attributes in this value. Each attribute is a bytes instance. Values that have attributes are: function, argument (and others for which attributes support has not been implemented)

  • is_global

    The value is a global variable.

  • is_function

    The value is a function.

  • is_argument

    The value is a function’s argument.

  • is_block

    The value is a function’s basic block.

  • is_instruction

    The value is a basic block’s instruction.

  • is_operand

    The value is a instruction’s operand.

  • is_constant

    The value is a constant.

  • get_constant_value(self, signed_int=False, round_fp=False)

    Return the constant value, either as a literal (for example, int or float) when supported, or as a string otherwise. Keyword arguments specify the preferences during conversion:

    • If signed_int is True and the constant is an integer, returns a signed integer.

    • If round_fp True and the constant is a floating point value, rounds the result upon accuracy loss (e.g., when querying an fp128 value). By default, raises an exception on accuracy loss.