Expand description
Typed 32-bit indices.
The compiler stores its trees, its IR and its machine code in flat vectors and refers to
elements by index rather than by pointer. A u32 index is half the size of a pointer,
it is stable across a reallocation of the backing vector, and it serialises without
fixups, all of which matter at the sizes a translation unit reaches.
The cost of a bare u32 is that every index in the program has the same type, so a block
number can be passed where an instruction number was wanted and the compiler will not
object. Idx<T> is the fix: it is still a u32 at runtime and it is a distinct type at
compile time.