references/bnil-llil.md
GitHubLLIL Instruction Reference
Low Level IL is the closest IL to native assembly. Registers, flags, and memory operations are preserved. Instructions form expression trees -- operands can be composed of sub-operations.
Example tree for eax = eax + ecx * 4:
=
/ \
eax +
/ \
eax *
/ \
ecx 4
Key Properties of LowLevelILInstruction
address-- virtual address of the corresponding assembly instructioninstr_index-- unique index of this IL instruction (distinct from address due to many-to-many mapping)operation-- enumeration value (e.g.,LowLevelILOperation.LLIL_SET_REG)operands-- list of all operandssrc-- source operanddest-- destination operandsize-- size of operation in bytes
Registers, Constants & Flags
LLIL_REG-- Register terminalLLIL_CONST-- Constant integer terminalLLIL_SET_REG-- Set register to result ofsrcexpressionLLIL_SET_REG_SPLIT-- Set a pair of registers as one double-sized registerLLIL_SET_FLAG-- Set flag to result ofsrcexpression
Memory Load & Store
LLIL_LOAD-- Load value from memoryLLIL_STORE-- Store value to memoryLLIL_PUSH-- Store to stack, adjust stack pointer by sizeof(value)LLIL_POP-- Load from stack, adjust stack pointer by sizeof(value)
Control Flow & Conditionals
LLIL_JUMP-- Branch to address from IL expressionLLIL_JUMP_TO-- Jump table: expression + list of possible targetsLLIL_CALL-- Call function at address from IL expressionLLIL_TAILCALL-- Tail call withdest,params,outputLLIL_RET-- Return to callerLLIL_NORET-- Marks unreachable code after non-returning callLLIL_SYSCALL-- System callLLIL_IF-- Conditional: ifconditionthen true_label else false_labelLLIL_GOTO-- Branch to IL label (not address)LLIL_FLAG_COND-- Flag condition expression
Comparison Operations
LLIL_CMP_E-- equalLLIL_CMP_NE-- not equalLLIL_CMP_SLT/LLIL_CMP_ULT-- signed/unsigned less thanLLIL_CMP_SLE/LLIL_CMP_ULE-- signed/unsigned less than or equalLLIL_CMP_SGE/LLIL_CMP_UGE-- signed/unsigned greater than or equalLLIL_CMP_SGT/LLIL_CMP_UGT-- signed/unsigned greater than
Arithmetic & Logical
LLIL_ADD/LLIL_ADC-- Add / Add with carryLLIL_SUB/LLIL_SBB-- Subtract / Subtract with borrowLLIL_AND/LLIL_OR/LLIL_XOR-- Bitwise AND/OR/XORLLIL_LSL/LLIL_LSR/LLIL_ASR-- Logical shift left/right, Arithmetic shift rightLLIL_ROL/LLIL_ROR-- Rotate left/rightLLIL_RLC/LLIL_RRC-- Rotate left/right with carryLLIL_MUL-- Multiply (single precision)LLIL_MULU_DP/LLIL_MULS_DP-- Unsigned/Signed multiply (double precision)LLIL_DIVU/LLIL_DIVS-- Unsigned/Signed divide (single precision)LLIL_DIVU_DP/LLIL_DIVS_DP-- Unsigned/Signed divide (double precision)LLIL_MODU/LLIL_MODS-- Unsigned/Signed modulus (single precision)LLIL_MODU_DP/LLIL_MODS_DP-- Unsigned/Signed modulus (double precision)LLIL_NEG-- Sign negationLLIL_NOT-- Bitwise complementLLIL_TEST_BIT-- Test if bitrightis set inleftLLIL_BOOL_TO_INT-- Convert bool to integer
Floating Point
LLIL_FLOAT_CONST-- FP constantLLIL_FADD/LLIL_FSUB/LLIL_FMUL/LLIL_FDIV-- FP arithmeticLLIL_FSQRT/LLIL_FNEG/LLIL_FABS-- FP square root/negate/absoluteLLIL_FLOAT_TO_INT/LLIL_INT_TO_FLOAT/LLIL_FLOAT_CONV-- FP conversionsLLIL_ROUND_TO_INT/LLIL_FLOOR/LLIL_CEILING/LLIL_FTRUNC-- FP rounding
FP Comparisons
LLIL_FCMP_E/LLIL_FCMP_NE/LLIL_FCMP_LT/LLIL_FCMP_LE/LLIL_FCMP_GE/LLIL_FCMP_GTLLIL_FCMP_O(ordered) /LLIL_FCMP_UO(unordered)
Special Instructions
LLIL_NOP-- No operationLLIL_BP-- BreakpointLLIL_TRAP-- Trap/interruptLLIL_SX-- Sign extendLLIL_ZX-- Zero extendLLIL_LOW_PART--sizebytes from the low end ofsrcLLIL_UNDEF-- Undefined behaviorLLIL_UNIMPL-- Unimplemented instructionLLIL_UNIMPL_MEM-- Unimplemented memory accessLLIL_EXTERN_PTR-- Synthesized pointer to external dataLLIL_INTRINSIC-- Architecture intrinsic (e.g., AES instructions) withoutput,params,intrinsicLLIL_MEM_PHI-- Memory PHI for SSA (memory modifications across basic block merges)