IT lexicon › Programming › Register class

Register class

Programming På svenska → Updated: 2026-11-07

The set of physical registers a given value is allowed to live in — the compiler's way of knowing that a float can't move into rax.

Before register allocation the compiler works with unlimited virtual registers, but each one carries a class: general-purpose, floating-point or vector, or some narrower subset. On x86 a shift count must sit in cl, and only four registers have an addressable ah-style high byte, so LLVM has classes for exactly those cases. Classes and their overlaps are described in TableGen under names like GR32, GR64 and VR128.

For the allocator this means colouring with a different palette per node, and two classes sharing physical registers through subregisters interfere despite different names. A copy between classes — integer to vector, say — is a real instruction and can't be coalesced away. Putting a value in too narrow a class causes needless spills, which is why compilers sometimes widen the class after the fact.

← Back to the lexicon