Working with registers
One of the main tasks of the backend is to go from an IR where the input program assumes an infinite number of registers in the SSA form to a program that uses only what’s available on the target architecture and that isn’t in SSA form.
In the Machine IR, the concept of a register maps to the Register
class. This class represents both physical and virtual registers. Physical registers represent what the target architecture can offer and are thus limited in number, whereas virtual registers represent the unlimited number of variables that the input program starts with.
We already showed you how to differentiate virtual registers from physical registers in the textual Machine IR; physical registers start with the $
character, whereas virtual registers start with the %
character.
Looking at the API, to find out whether you’re dealing with a physical or virtual register, you can use the Register::isVirtual()
or Register::isPhysical...