On semantics of Reserved keyword for subregisters (original) (raw)

August 25, 2023, 10:04am 1

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?

arsenm August 25, 2023, 12:22pm 2

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)

totikom August 25, 2023, 12:35pm 3

Is that holds true even if status flags can be set by some instructions?

For instance, there are flags which enable/disable interrupts.

arsenm August 25, 2023, 12:37pm 4

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

totikom August 25, 2023, 12:43pm 5

Where I can mark a reg as unallocatable?
While working with reserved regs, I’ve marked them via TargetRegisterInfo::getReservedRegs method.

arsenm August 25, 2023, 12:49pm 6

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