This section discusses the macros that describe which kinds of values (specifically, which machine modes) each register can hold, and how many consecutive registers are needed for a given mode.
HARD_REGNO_NREGS (regno, mode)
#define HARD_REGNO_NREGS(REGNO, MODE) \ ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \ / UNITS_PER_WORD))
ALTER_HARD_SUBREG (tgt_mode, word, src_mode, regno)
(subreg:tgt_mode (reg:src_mode regno) word)This may be needed if the target machine has mixed sized big-endian registers, like Sparc v9.
HARD_REGNO_MODE_OK (regno, mode)
#define HARD_REGNO_MODE_OK(REGNO, MODE) 1You need not include code to check for the numbers of fixed registers, because the allocation mechanism considers them to be always occupied. On some machines, double-precision values must be kept in even/odd register pairs. You can implement that by defining this macro to reject odd register numbers for such modes. The minimum requirement for a mode to be OK in a register is that the `movmode' instruction pattern support moves between the register and other hard register in the same class and that moving a value into the register and back out not alter it. Since the same instruction used to move
word_modewill work for all narrower integer modes, it is not necessary on any machine for
HARD_REGNO_MODE_OKto distinguish between these modes, provided you define patterns `movhi', etc., to take advantage of this. This is useful because of the interaction between
MODES_TIEABLE_P; it is very desirable for all integer modes to be tieable. Many machines have special registers for floating point arithmetic. Often people assume that floating point machine modes are allowed only in floating point registers. This is not true. Any registers that can hold integers can safely hold a floating point machine mode, whether or not floating arithmetic can be done on it in those registers. Integer move instructions can be used to move the values. On some machines, though, the converse is true: fixed-point machine modes may not go in floating registers. This is true if the floating registers normalize any value stored in them, because storing a non-floating value there would garble it. In this case,
HARD_REGNO_MODE_OKshould reject fixed-point machine modes in floating registers. But if the floating registers do not automatically normalize, if you can store any bit pattern in one and retrieve it unchanged without a trap, then any machine mode may go in a floating register, so you can define this macro to say so. The primary significance of special floating registers is rather that they are the registers acceptable in floating point arithmetic instructions. However, this is of no concern to
HARD_REGNO_MODE_OK. You handle it by writing the proper constraints for those instructions. On some machines, the floating registers are especially slow to access, so that it is better to store a value in a stack frame than in such a register if floating point arithmetic is not being done. As long as the floating registers are not in class
GENERAL_REGS, they will not be used unless some pattern's constraint asks for one.
MODES_TIEABLE_P (mode1, mode2)
HARD_REGNO_MODE_OK (r, mode1)and
HARD_REGNO_MODE_OK (r, mode2)are always the same for any r, then
MODES_TIEABLE_P (mode1, mode2)should be nonzero. If they differ for any r, you should define this macro to return zero unless some other mechanism ensures the accessibility of the value in a narrower mode. You should define this macro to return nonzero in as many cases as possible since doing so will allow GNU CC to perform better register allocation.
CCmoderegisters. You should only define this macro if support fo copying to/from