The g5, g6, and g7 registers can be used as temporary registers in generic code if they are not reserved for a specific usage by the OS or system libraries. This can for example be the case when compiling for a bare metal system or when compiling the OS kernel. In GCC the corresponding option is called -fcall-used-g[5,6,7] and is used when compiling the Linux kernel.
The code is simplified by using markSuperRegs() that also reserves the corresponding covering register pairs when needed.