The CONSTANTS block (11) and the FUNCTION block (12) hold the values and instructions
of a module. LLVM’s Bitcode File Format document leaves both as placeholders, so the
codes below come from LLVM’s LLVMBitCodes.h, with the operand lists from
its comments, and from the current writer where noted (see
sources). Records marked old are no longer written.
Operands
From module version 1, instruction operands that refer to values are relative value
IDs, and PHI operands are signed VBRs. The current writer writes most value operands
either as the value alone or as the value followed by its type (its
pushValue and pushValueAndType helpers). The constants’
integer records use signed VBRs.
CONSTANTS block (11)
| Code | Record | Operands |
|---|---|---|
1 | SETTYPE | [typeid]: the type of the following constants |
2 | NULL | — |
3 | UNDEF | — |
4 | INTEGER | [intval], a signed VBR |
5 | WIDE_INTEGER | [n × intval], signed VBRs |
6 | FLOAT | [fpval] |
7 | AGGREGATE | [n × value number] |
8 | STRING | [values] |
9 | CSTRING | [values] |
10 | CE_BINOP | [opcode, opval, opval]: a binary operator expression |
11 | CE_CAST | [opcode, opty, opval]: a cast expression |
12 | CE_GEP_OLD | [n × operands] (old) |
13 | CE_SELECT | [opval, opval, opval] |
14 | CE_EXTRACTELT | [opty, opval, opval] |
15 | CE_INSERTELT | [opval, opval, opval] |
16 | CE_SHUFFLEVEC | [opval, opval, opval] |
17 | CE_CMP | [opty, opval, opval, pred]; predicates |
18 | INLINEASM_OLD | [sideeffect|alignstack, asmstr, conststr] (old) |
19 | CE_SHUFVEC_EX | [opty, opval, opval, opval] |
20 | CE_INBOUNDS_GEP | [n × operands] |
21 | BLOCKADDRESS | [fnty, fnval, bb#] |
22 | DATA | [n × elements] |
23 | INLINEASM_OLD2 | [sideeffect|alignstack|asmdialect, asmstr, conststr] (old) |
24 | CE_GEP_WITH_INRANGE_INDEX_OLD | [opty, flags, n × operands] (old) |
25 | CE_UNOP | [opcode, opval] |
26 | POISON | — |
27 | DSO_LOCAL_EQUIVALENT | [gvty, gv] |
28 | INLINEASM_OLD3 | [sideeffect|alignstack|asmdialect|unwind, asmstr, conststr] (old) |
29 | NO_CFI_VALUE | [fty, f] |
30 | INLINEASM | [fnty, sideeffect|alignstack|asmdialect|unwind, asmstr, conststr] |
31 | CE_GEP_WITH_INRANGE | [opty, flags, range, n × operands] |
32 | CE_GEP | [opty, flags, n × operands]; GEP flags |
33 | PTRAUTH | [ptr, key, disc, addrdisc] |
34 | PTRAUTH2 | [ptr, key, disc, addrdisc, deactivation_symbol] |
35 | BYTE | [intval]; recent, not documented |
36 | WIDE_BYTE | [n × intval]; recent, not documented |
FUNCTION block (12)
A FUNCTION block holds one function body and may contain CONSTANTS, VALUE_SYMTAB and METADATA_ATTACHMENT blocks as well as these records.
| Code | Record | Operands (header comment) |
|---|---|---|
1 | DECLAREBLOCKS | [n] |
2 | INST_BINOP | [opcode, ty, opval, opval] |
3 | INST_CAST | [opcode, ty, opty, opval] |
4 | INST_GEP_OLD | [n × operands] (old) |
5 | INST_SELECT | [ty, opval, opval, opval] |
6 | INST_EXTRACTELT | [opty, opval, opval] |
7 | INST_INSERTELT | [ty, opval, opval, opval] |
8 | INST_SHUFFLEVEC | [ty, opval, opval, opval] |
9 | INST_CMP | [opty, opval, opval, pred] |
10 | INST_RET | [opty, opval], both optional |
11 | INST_BR | [bb#, bb#, cond] or [bb#] |
12 | INST_SWITCH | [opty, op0, op1, …] |
13 | INST_INVOKE | [attr, fnty, op0, op1, …] |
14 | — | unused |
15 | INST_UNREACHABLE | — |
16 | INST_PHI | [ty, val0, bb0, …] |
17, 18 | — | unused |
19 | INST_ALLOCA | [instty, opty, op, align] |
20 | INST_LOAD | [opty, op, align, vol] |
21, 22 | — | unused |
23 | INST_VAARG | [valistty, valist, instty] |
24 | INST_STORE_OLD | [ptrty, ptr, val, align, vol] (old) |
25 | — | unused |
26 | INST_EXTRACTVAL | [n × operands] |
27 | INST_INSERTVAL | [n × operands] |
28 | INST_CMP2 | [opty, opval, opval, pred] |
29 | INST_VSELECT | [ty, opval, opval, predty, pred] |
30 | INST_INBOUNDS_GEP_OLD | [n × operands] (old) |
31 | INST_INDIRECTBR | [opty, op0, op1, …] |
32 | — | unused |
33 | DEBUG_LOC_AGAIN | — (same debug location as before) |
34 | INST_CALL | [attr, cc, fnty, fnid, args…] |
35 | DEBUG_LOC | [Line, Col, ScopeVal, IAVal] |
36 | INST_FENCE | [ordering, syncscope] |
37 | INST_CMPXCHG_OLD | [ptrty, ptr, cmp, val, vol, ordering, syncscope, failure_ordering?, weak?] (old) |
38 | INST_ATOMICRMW_OLD | [ptrty, ptr, val, operation, align, vol, ordering, syncscope] (old) |
39 | INST_RESUME | [opval] |
40 | INST_LANDINGPAD_OLD | [ty, val, val, num, id0, val0, …] (old) |
41 | INST_LOADATOMIC | [opty, op, align, vol, ordering, syncscope] |
42 | INST_STOREATOMIC_OLD | [ptrty, ptr, val, align, vol, ordering, syncscope] (old) |
43 | INST_GEP | [inbounds, n × operands] |
44 | INST_STORE | [ptrty, ptr, valty, val, align, vol] |
45 | INST_STOREATOMIC | [ptrty, ptr, val, align, vol, …] |
46 | INST_CMPXCHG | [ptrty, ptr, cmp, val, vol, success_ordering, syncscope, failure_ordering, weak] |
47 | INST_LANDINGPAD | [ty, val, num, id0, val0, …] |
48 | INST_CLEANUPRET | [val] or [val, bb#] |
49 | INST_CATCHRET | [val, bb#] |
50 | INST_CATCHPAD | [bb#, bb#, num, args…] |
51 | INST_CLEANUPPAD | [num, args…] |
52 | INST_CATCHSWITCH | [num, args…] or [num, args…, bb] |
53, 54 | — | unused |
55 | OPERAND_BUNDLE | [tag#, value…] |
56 | INST_UNOP | [opcode, ty, opval] |
57 | INST_CALLBR | [attr, cc, norm, transfs, fnty, fnid, args…] |
58 | INST_FREEZE | [opty, opval] |
59 | INST_ATOMICRMW | [ptrty, ptr, valty, val, operation, align, vol, ordering, syncscope] |
60 | BLOCKADDR_USERS | [value…] |
61 | DEBUG_RECORD_VALUE | [DILocation, DILocalVariable, DIExpression, ValueAsMetadata] |
62 | DEBUG_RECORD_DECLARE | [DILocation, DILocalVariable, DIExpression, ValueAsMetadata] |
63 | DEBUG_RECORD_ASSIGN | [DILocation, DILocalVariable, DIExpression, ValueAsMetadata, DIAssignID, DIExpression (addr), ValueAsMetadata (addr)] |
64 | DEBUG_RECORD_VALUE_SIMPLE | [DILocation, DILocalVariable, DIExpression, Value] |
65 | DEBUG_RECORD_LABEL | [DILocation, DILabel] |
66 | DEBUG_RECORD_DECLARE_VALUE | [DILocation, DILocalVariable, DIExpression, ValueAsMetadata]; recent |
67 | INST_BITINSERT | [opval, opval, opval]; recent, not documented |
68 | INST_BITEXTRACT | [ty, opval, opval]; recent, not documented |
What the current writer emits
For these records LLVM’s current writer uses a different order from the header comments:
| Record | Operands as written |
|---|---|
INST_BINOP | left operand (value and type), right operand (value), opcode, flags if any |
INST_CAST | operand (value and type), destination type, opcode, flags if any |
INST_LOAD | pointer (value and type), loaded type, encoded alignment, volatile; atomic loads add ordering and sync scope |
INST_STORE | pointer and value (each value and type), encoded alignment, volatile; atomic stores add ordering and sync scope |
INST_GEP | GEP flags, source element type, then each operand (value and type) |
INST_CALL | attribute list, call flags word, fast-math flags (only if any), function type, callee (value and type), fixed arguments (values), variable arguments (value and type) |
INST_ALLOCA | allocated type, size type, size value (an absolute ID), a packed word holding the alignment and the in-alloca, explicit-type and swifterror flags; an address space if not the default |
DEBUG_LOC | line, column, scope, inlined-at, implicit-code flag, atom group, atom rank |
The bit positions inside the alloca word are not described in the sources read.
Operation codes
Cast opcodes
| Code | Cast | Code | Cast |
|---|---|---|---|
0 | TRUNC | 7 | FPTRUNC |
1 | ZEXT | 8 | FPEXT |
2 | SEXT | 9 | PTRTOINT |
3 | FPTOUI | 10 | INTTOPTR |
4 | FPTOSI | 11 | BITCAST |
5 | UITOFP | 12 | ADDRSPACECAST |
6 | SITOFP | 13 | PTRTOADDR |
Unary opcodes
0: FNEG.
Binary opcodes
| Code | Operator | Code | Operator |
|---|---|---|---|
0 | ADD | 7 | SHL |
1 | SUB | 8 | LSHR |
2 | MUL | 9 | ASHR |
3 | UDIV | 10 | AND |
4 | SDIV (also used for floating point) | 11 | OR |
5 | UREM | 12 | XOR |
6 | SREM (also used for floating point) |
Optional flags
Enum in LLVMBitCodes.h | Bit | Flag |
|---|---|---|
OverflowingBinaryOperatorOptionalFlags | 0 | OBO_NO_UNSIGNED_WRAP |
| 1 | OBO_NO_SIGNED_WRAP | |
PossiblyExactOperatorOptionalFlags | 0 | PEO_EXACT |
PossiblyDisjointInstOptionalFlags | 0 | PDI_DISJOINT |
TruncInstOptionalFlags | 0 | TIO_NO_UNSIGNED_WRAP |
| 1 | TIO_NO_SIGNED_WRAP |
Fast-math flags
| Bit | Value | Flag |
|---|---|---|
| 0 | 0x01 | UnsafeAlgebra (legacy) |
| 1 | 0x02 | NoNaNs |
| 2 | 0x04 | NoInfs |
| 3 | 0x08 | NoSignedZeros |
| 4 | 0x10 | AllowReciprocal |
| 5 | 0x20 | AllowContract |
| 6 | 0x40 | ApproxFunc |
| 7 | 0x80 | AllowReassoc |
GEP flags
| Bit | Flag |
|---|---|
| 0 | GEP_INBOUNDS |
| 1 | GEP_NUSW |
| 2 | GEP_NUW |
Call flags
| Bit | Name | Meaning |
|---|---|---|
| 0 | CALL_TAIL | tail call |
| 1–13 | CALL_CCONV | the calling convention, shifted left by 1 |
| 14 | CALL_MUSTTAIL | must be a tail call |
| 15 | CALL_EXPLICIT_TYPE | the function type is given |
| 16 | CALL_NOTAIL | must not be a tail call |
| 17 | CALL_FMF | fast-math flags follow |
atomicrmw operations
| Code | Operation | Code | Operation |
|---|---|---|---|
0 | RMW_XCHG | 12 | RMW_FSUB |
1 | RMW_ADD | 13 | RMW_FMAX |
2 | RMW_SUB | 14 | RMW_FMIN |
3 | RMW_AND | 15 | RMW_UINC_WRAP |
4 | RMW_NAND | 16 | RMW_UDEC_WRAP |
5 | RMW_OR | 17 | RMW_USUB_COND |
6 | RMW_XOR | 18 | RMW_USUB_SAT |
7 | RMW_MAX | 19 | RMW_FMAXIMUM |
8 | RMW_MIN | 20 | RMW_FMINIMUM |
9 | RMW_UMAX | 21 | RMW_FMAXIMUMNUM |
10 | RMW_UMIN | 22 | RMW_FMINIMUMNUM |
11 | RMW_FADD |
Atomic ordering
| Code | Ordering |
|---|---|
0 | ORDERING_NOTATOMIC |
1 | ORDERING_UNORDERED |
2 | ORDERING_MONOTONIC |
3 | ORDERING_ACQUIRE |
4 | ORDERING_RELEASE |
5 | ORDERING_ACQREL |
6 | ORDERING_SEQCST |
Comparison predicates
| Code | Predicate | Code | Predicate |
|---|---|---|---|
0 | FCMP_FALSE: always false | 8 | FCMP_UNO: unordered (either is NaN) |
1 | FCMP_OEQ: ordered and equal | 9 | FCMP_UEQ: unordered or equal |
2 | FCMP_OGT: ordered and greater than | 10 | FCMP_UGT: unordered or greater than |
3 | FCMP_OGE: ordered and greater or equal | 11 | FCMP_UGE: unordered, greater or equal |
4 | FCMP_OLT: ordered and less than | 12 | FCMP_ULT: unordered or less than |
5 | FCMP_OLE: ordered and less or equal | 13 | FCMP_ULE: unordered, less or equal |
6 | FCMP_ONE: ordered and unequal | 14 | FCMP_UNE: unordered or not equal |
7 | FCMP_ORD: ordered (no NaNs) | 15 | FCMP_TRUE: always true |
32 | ICMP_EQ: equal | 37 | ICMP_ULE: unsigned less or equal |
33 | ICMP_NE: not equal | 38 | ICMP_SGT: signed greater than |
34 | ICMP_UGT: unsigned greater than | 39 | ICMP_SGE: signed greater or equal |
35 | ICMP_UGE: unsigned greater or equal | 40 | ICMP_SLT: signed less than |
36 | ICMP_ULT: unsigned less than | 41 | ICMP_SLE: signed less or equal |
Sources
- LLVM Bitcode File Format – “Signed VBRs”, “MODULE_CODE_VERSION” (relative operands), CONSTANTS_BLOCK and FUNCTION_BLOCK placeholders
- LLVMBitCodes.h – ConstantsCodes, FunctionCodes, CastOpcodes, UnaryOpcodes, BinaryOpcodes, flag enums, FastMathMap, GetElementPtrOptionalFlags, CallMarkersFlags, RMWOperations, AtomicOrderingCodes (main branch, November 2026)
- InstrTypes.h –
CmpInst::Predicatevalues - BitcodeWriter.cpp – the operand orders in “What the current writer emits”