I’m implementing code generator for in-house target. In this target there is a status register SR which consists of status bits representing different machine settings. This status bits are modeled as registers (subregisters of SR) and are marked as reserved. However, some bits of SR are used as binary registers which are used by logical instructions just like “ordinary” register.
Should SR be marked as a reserved register if it contains both reserved and unreserved parts?
You probably do not want to do this. There’s sometimes confusion between unallocatable and reserved registers. Status / flag registers generally should be unallocatable only, not reserved.
Yes, if one register is reserved, all aliasing registers should also be reserved (really we should track reservations on the regunit level)
Yes. Flag registers are still trackable defs. Reserved is for cases where there are possible changes to the register that aren’t compiler visible. It’s more like volatile
There’s an isAllocatable field on the RegisterClass if the status register belongs to a class. Generally a flag register would just not belong to an allocatable class