Imaginary registers

The MOS 65xx series has a 256-byte range of low memory referred to as zero page. Memory stored in this region is significantly faster to access and modify.

Like all modern compilers, LLVM assumes generally that the target machine has a large number of target registers that are more or less interchangeable. This restriction is loosened, at some cost to code complexity, for the X86 targets, but generally most targets assume that you have a range of compiler-controllable registers.

Because "virtual registers" has another predefined meaning in LLVM land, we use the term imaginary register to refer to a byte in zero page memory. It's represented at codegen time by a symbol like __rc17 or __rs5, which is then translated to an actual memory address by the linker at link time.

Presently, the compiler requires 16 imaginary pointers (two contiguous bytes each), and the compiler doesn't presently have the means to make use of more. In the future, the compiler should make use of otherwise unused sections of the zero page for temporaries, local, and global variables.

LLVM-MOS does not assume that imaginary registers need to be consecutive! Many targets have non-consecutive usable zero page memory locations.

[[Category:C]]