mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-22 15:32:35 +00:00
The inverse of the encoder: read the header (detecting endianness from the magic word), walk the instruction stream, and lower each instruction by opcode back into the structured Module -- the ir core (types/constants/globals/ functions, the generic table-driven operation decode), the SPIR-V sections (preamble / debug / annotations), and the flat <id> space into the side id tables (with an id->Type_Ref map so type-naming operands recover TYPE operands). Single allocator pass (context.allocator), one reused per-instruction word scratch buffer. Validated: encode -> decode -> re-encode is byte-exact on the void compute main module (116 bytes; caps/types/functions/blocks/ops/ids/bound all recovered). Same gaps as the encoder (OpFunctionParameter, ARRAY/bool, enum-parameter operands); big-endian sources a later refinement.