Register Allocation Table - RAT

When targeting the ATMega328P we have 32 general-purpose Registers, some of which have special restrictions on which instructions they can be used with.

For this Reason we maintain a Register Allocation Table, so during Assembly Code Generation, we can make a good choice on which Register to use for a temporary value.

Properties as an Allocator

As an Allocator, the RAT manages 32 Registers. Registers can be allocated / freed in any order. When allocating a Register, it is important to know what it will be used for. Because we only manage 32 Registers, we can keep a lot of metadata, as opposed to e.g. Memory Allocators.

image displaying the structure of the Register Allocation Table

Implementation