You want to read the documentation for HARD_REGNO_NREGS. With that, you can define the first few registers as their QImode parts, and use the macro to tell gcc how to combine those parts into HImode and SImode registers. The remaining registers can be defined as SImode only with the sample definition.