Skip to main content
The IRTermKind type identifies the specific IR operation that an IRTerm represents. Every IRTerm has a kind field of this type, which you can compare against the constants below or test with the corresponding is_* methods. The constants are organized into several categories:
  • Structural: BLOCK, INSN, PHI
  • Statements: ASSIGN, STORE, BRANCH, CBRANCH, CALL, RETURN, SKIP, INTRINSIC
  • Operand expressions: OFFSET, LOCATION, VAR, VAL, LOAD, CAST, EXTRACT, CONCAT, IFELSE, CHOICE, INTRINSIC, NAN
  • Unary operations: NOT, NEG, ABS, SQRT, CEILING, FLOOR, ROUND, POPCOUNT
  • Binary arithmetic: ADD, SUB, MUL, DIV, SDIV, REM, SREM
  • Bitwise and shift: AND, OR, XOR, SHL, SHR, SAR
  • Comparison: EQ, NEQ, LT, LE, SLT, SLE
  • Carry/borrow: CARRY, SCARRY, SBORROW
  • Type-related: TYPE, STRUCT_FIELD, FUNC_ARG, ENUM_VARIANT, UNION_VARIANT

Fields

Methods

Each constant has a corresponding is_* method that returns true when the kind matches. For example, kind:is_call() is equivalent to kind == IRTermKind.CALL.

Reference

Structural kinds

  • BLOCK: a basic block containing a sequence of instructions.
  • INSN: a single instruction containing one or more statements.
  • PHI: an SSA phi node merging values from different control flow paths.

Statement kinds

  • ASSIGN: an assignment of a value to a variable.
  • STORE: a memory store operation.
  • BRANCH: an unconditional branch (jump) to a target address.
  • CBRANCH: a conditional branch that jumps based on a boolean condition.
  • CALL: a function call.
  • RETURN: a return from the current function.
  • SKIP: a no-op placeholder instruction.
  • INTRINSIC: a built-in operation with no direct IR equivalent. INTRINSIC can also appear as an expression when it produces a value.

Expression kinds

  • VAR: a variable reference. Access the underlying variable via the variable field.
  • VAL: a constant value. Access it via the value field or to_bitvec().
  • LOAD: a memory load operation.
  • OFFSET: an address offset computation.
  • LOCATION: a reference to a specific memory location.
  • CAST: a type cast operation.
  • EXTRACT: extracts a range of bits from a value (see lsb, msb).
  • CONCAT: concatenates two values.
  • IFELSE: a conditional (ternary) expression.
  • CHOICE: a choice between multiple alternative values.
  • INTRINSIC: a built-in operation with no direct IR equivalent. Can also appear as a statement (see above).
  • NAN: a Not-a-Number value.

Unary operations

NOT, NEG, ABS, SQRT, CEILING, FLOOR, ROUND, POPCOUNT are standard unary operations on a single operand.

Binary arithmetic

ADD, SUB, MUL, DIV, SDIV, REM, SREM are arithmetic operations. The S-prefixed variants operate on signed values.

Bitwise, shift, and comparison

  • AND, OR, XOR are bitwise operations.
  • SHL is shift left, SHR is logical (unsigned) shift right, SAR is arithmetic (signed) shift right.
  • EQ, NEQ test equality/inequality. LT, LE are unsigned comparisons. SLT, SLE are signed comparisons.
  • CARRY, SCARRY, SBORROW detect carry and borrow for arithmetic operations.
  • TYPE: a type descriptor term. Use sub_kind to determine the specific type category.
  • STRUCT_FIELD: a field within a struct type.
  • FUNC_ARG: an argument of a function type.
  • ENUM_VARIANT: a variant of an enum type.
  • UNION_VARIANT: a variant of a union type.

Example