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
| Field | Description | Type |
|---|---|---|
BLOCK | Block operation type | IRTermKind |
INSN | Instruction operation type | IRTermKind |
PHI | PHI operation type | IRTermKind |
ASSIGN | Assignment operation type | IRTermKind |
STORE | Store operation type | IRTermKind |
BRANCH | Branch operation type | IRTermKind |
CBRANCH | Conditional branch operation type | IRTermKind |
CALL | Call operation type | IRTermKind |
RETURN | Return operation type | IRTermKind |
SKIP | Skip operation type | IRTermKind |
INTRINSIC | Intrinsic operation type | IRTermKind |
OFFSET | Offset operation type | IRTermKind |
LOCATION | Location operation type | IRTermKind |
VAR | Variable operation type | IRTermKind |
VAL | Value operation type | IRTermKind |
LOAD | Load operation type | IRTermKind |
CAST | Cast operation type | IRTermKind |
IFELSE | If-else operation type | IRTermKind |
EXTRACT | Extract operation type | IRTermKind |
CONCAT | Concatenation operation type | IRTermKind |
CHOICE | Choice operation type | IRTermKind |
NAN | NaN operation type | IRTermKind |
NOT | NOT operation type | IRTermKind |
NEG | Negation operation type | IRTermKind |
ABS | Absolute value operation type | IRTermKind |
SQRT | Square root operation type | IRTermKind |
CEILING | Ceiling operation type | IRTermKind |
FLOOR | Floor operation type | IRTermKind |
ROUND | Round operation type | IRTermKind |
POPCOUNT | Population count operation type | IRTermKind |
AND | AND operation type | IRTermKind |
OR | OR operation type | IRTermKind |
XOR | XOR operation type | IRTermKind |
ADD | Addition operation type | IRTermKind |
SUB | Subtraction operation type | IRTermKind |
DIV | Division operation type | IRTermKind |
SDIV | Signed division operation type | IRTermKind |
MUL | Multiplication operation type | IRTermKind |
REM | Remainder operation type | IRTermKind |
SREM | Signed remainder operation type | IRTermKind |
SHL | Shift left operation type | IRTermKind |
SAR | Arithmetic right shift operation type | IRTermKind |
SHR | Logical right shift operation type | IRTermKind |
EQ | Equality operation type | IRTermKind |
NEQ | Inequality operation type | IRTermKind |
LT | Less than operation type | IRTermKind |
LE | Less than or equal operation type | IRTermKind |
SLT | Signed less than operation type | IRTermKind |
SLE | Signed less than or equal operation type | IRTermKind |
SBORROW | Signed borrow operation type | IRTermKind |
CARRY | Carry operation type | IRTermKind |
SCARRY | Signed carry operation type | IRTermKind |
TYPE | Type operation type | IRTermKind |
STRUCT_FIELD | Struct field operation type | IRTermKind |
FUNC_ARG | Function argument operation type | IRTermKind |
ENUM_VARIANT | Enum variant operation type | IRTermKind |
UNION_VARIANT | Union variant operation type | IRTermKind |
Methods
Each constant has a correspondingis_* method that returns true when the kind matches. For example, kind:is_call() is equivalent to kind == IRTermKind.CALL.
| Method | Description | Parameters | Return Type |
|---|---|---|---|
is_block | Returns true if kind is BLOCK | — | boolean |
is_insn | Returns true if kind is INSN | — | boolean |
is_phi | Returns true if kind is PHI | — | boolean |
is_assign | Returns true if kind is ASSIGN | — | boolean |
is_store | Returns true if kind is STORE | — | boolean |
is_branch | Returns true if kind is BRANCH | — | boolean |
is_cbranch | Returns true if kind is CBRANCH | — | boolean |
is_call | Returns true if kind is CALL | — | boolean |
is_return | Returns true if kind is RETURN | — | boolean |
is_skip | Returns true if kind is SKIP | — | boolean |
is_intrinsic | Returns true if kind is INTRINSIC | — | boolean |
is_offset | Returns true if kind is OFFSET | — | boolean |
is_location | Returns true if kind is LOCATION | — | boolean |
is_var | Returns true if kind is VAR | — | boolean |
is_val | Returns true if kind is VAL | — | boolean |
is_load | Returns true if kind is LOAD | — | boolean |
is_cast | Returns true if kind is CAST | — | boolean |
is_ifelse | Returns true if kind is IFELSE | — | boolean |
is_extract | Returns true if kind is EXTRACT | — | boolean |
is_concat | Returns true if kind is CONCAT | — | boolean |
is_choice | Returns true if kind is CHOICE | — | boolean |
is_nan | Returns true if kind is NAN | — | boolean |
is_not | Returns true if kind is NOT | — | boolean |
is_neg | Returns true if kind is NEG | — | boolean |
is_abs | Returns true if kind is ABS | — | boolean |
is_sqrt | Returns true if kind is SQRT | — | boolean |
is_ceiling | Returns true if kind is CEILING | — | boolean |
is_floor | Returns true if kind is FLOOR | — | boolean |
is_round | Returns true if kind is ROUND | — | boolean |
is_popcount | Returns true if kind is POPCOUNT | — | boolean |
is_and | Returns true if kind is AND | — | boolean |
is_or | Returns true if kind is OR | — | boolean |
is_xor | Returns true if kind is XOR | — | boolean |
is_add | Returns true if kind is ADD | — | boolean |
is_sub | Returns true if kind is SUB | — | boolean |
is_div | Returns true if kind is DIV | — | boolean |
is_signed_div | Returns true if kind is SDIV | — | boolean |
is_mul | Returns true if kind is MUL | — | boolean |
is_rem | Returns true if kind is REM | — | boolean |
is_signed_rem | Returns true if kind is SREM | — | boolean |
is_shl | Returns true if kind is SHL | — | boolean |
is_signed_shr | Returns true if kind is SAR | — | boolean |
is_shr | Returns true if kind is SHR | — | boolean |
is_eq | Returns true if kind is EQ | — | boolean |
is_neq | Returns true if kind is NEQ | — | boolean |
is_lt | Returns true if kind is LT | — | boolean |
is_le | Returns true if kind is LE | — | boolean |
is_signed_lt | Returns true if kind is SLT | — | boolean |
is_signed_le | Returns true if kind is SLE | — | boolean |
is_signed_borrow | Returns true if kind is SBORROW | — | boolean |
is_carry | Returns true if kind is CARRY | — | boolean |
is_signed_carry | Returns true if kind is SCARRY | — | boolean |
is_type | Returns true if kind is TYPE | — | boolean |
is_struct_field | Returns true if kind is STRUCT_FIELD | — | boolean |
is_function_argument | Returns true if kind is FUNC_ARG | — | boolean |
is_enum_variant | Returns true if kind is ENUM_VARIANT | — | boolean |
is_union_variant | Returns true if kind is UNION_VARIANT | — | boolean |
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.INTRINSICcan also appear as an expression when it produces a value.
Expression kinds
VAR: a variable reference. Access the underlying variable via thevariablefield.VAL: a constant value. Access it via thevaluefield orto_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 (seelsb,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,XORare bitwise operations.SHLis shift left,SHRis logical (unsigned) shift right,SARis arithmetic (signed) shift right.EQ,NEQtest equality/inequality.LT,LEare unsigned comparisons.SLT,SLEare signed comparisons.CARRY,SCARRY,SBORROWdetect carry and borrow for arithmetic operations.
Type-related kinds
TYPE: a type descriptor term. Usesub_kindto 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.