gccint: Values in Registers

1 
1 18.7.3 How Values Fit in Registers
1 ----------------------------------
1 
1 This section discusses the macros that describe which kinds of values
1 (specifically, which machine modes) each register can hold, and how many
1 consecutive registers are needed for a given mode.
1 
1  -- Target Hook: unsigned int TARGET_HARD_REGNO_NREGS (unsigned int
1           REGNO, machine_mode MODE)
1      This hook returns the number of consecutive hard registers,
1      starting at register number REGNO, required to hold a value of mode
1      MODE.  This hook must never return zero, even if a register cannot
1      hold the requested mode - indicate that with
1      'TARGET_HARD_REGNO_MODE_OK' and/or 'TARGET_CAN_CHANGE_MODE_CLASS'
1      instead.
1 
1      The default definition returns the number of words in MODE.
1 
1  -- Macro: HARD_REGNO_NREGS_HAS_PADDING (REGNO, MODE)
1      A C expression that is nonzero if a value of mode MODE, stored in
1      memory, ends with padding that causes it to take up more space than
1      in registers starting at register number REGNO (as determined by
1      multiplying GCC's notion of the size of the register when
1      containing this mode by the number of registers returned by
1      'TARGET_HARD_REGNO_NREGS').  By default this is zero.
1 
1      For example, if a floating-point value is stored in three 32-bit
1      registers but takes up 128 bits in memory, then this would be
1      nonzero.
1 
1      This macros only needs to be defined if there are cases where
1      'subreg_get_info' would otherwise wrongly determine that a 'subreg'
1      can be represented by an offset to the register number, when in
1      fact such a 'subreg' would contain some of the padding not stored
1      in registers and so not be representable.
1 
1  -- Macro: HARD_REGNO_NREGS_WITH_PADDING (REGNO, MODE)
1      For values of REGNO and MODE for which
1      'HARD_REGNO_NREGS_HAS_PADDING' returns nonzero, a C expression
1      returning the greater number of registers required to hold the
1      value including any padding.  In the example above, the value would
1      be four.
1 
1  -- Macro: REGMODE_NATURAL_SIZE (MODE)
1      Define this macro if the natural size of registers that hold values
1      of mode MODE is not the word size.  It is a C expression that
1      should give the natural size in bytes for the specified mode.  It
1      is used by the register allocator to try to optimize its results.
1      This happens for example on SPARC 64-bit where the natural size of
1      floating-point registers is still 32-bit.
1 
1  -- Target Hook: bool TARGET_HARD_REGNO_MODE_OK (unsigned int REGNO,
1           machine_mode MODE)
1      This hook returns true if it is permissible to store a value of
1      mode MODE in hard register number REGNO (or in several registers
1      starting with that one).  The default definition returns true
1      unconditionally.
1 
1      You need not include code to check for the numbers of fixed
1      registers, because the allocation mechanism considers them to be
1      always occupied.
1 
1      On some machines, double-precision values must be kept in even/odd
1      register pairs.  You can implement that by defining this hook to
1      reject odd register numbers for such modes.
1 
1      The minimum requirement for a mode to be OK in a register is that
1      the 'movMODE' instruction pattern support moves between the
1      register and other hard register in the same class and that moving
1      a value into the register and back out not alter it.
1 
1      Since the same instruction used to move 'word_mode' will work for
1      all narrower integer modes, it is not necessary on any machine for
1      this hook to distinguish between these modes, provided you define
1      patterns 'movhi', etc., to take advantage of this.  This is useful
1      because of the interaction between 'TARGET_HARD_REGNO_MODE_OK' and
1      'TARGET_MODES_TIEABLE_P'; it is very desirable for all integer
1      modes to be tieable.
1 
1      Many machines have special registers for floating point arithmetic.
1      Often people assume that floating point machine modes are allowed
1      only in floating point registers.  This is not true.  Any registers
1      that can hold integers can safely _hold_ a floating point machine
1      mode, whether or not floating arithmetic can be done on it in those
1      registers.  Integer move instructions can be used to move the
1      values.
1 
1      On some machines, though, the converse is true: fixed-point machine
1      modes may not go in floating registers.  This is true if the
1      floating registers normalize any value stored in them, because
1      storing a non-floating value there would garble it.  In this case,
1      'TARGET_HARD_REGNO_MODE_OK' should reject fixed-point machine modes
1      in floating registers.  But if the floating registers do not
1      automatically normalize, if you can store any bit pattern in one
1      and retrieve it unchanged without a trap, then any machine mode may
1      go in a floating register, so you can define this hook to say so.
1 
1      The primary significance of special floating registers is rather
1      that they are the registers acceptable in floating point arithmetic
1      instructions.  However, this is of no concern to
1      'TARGET_HARD_REGNO_MODE_OK'.  You handle it by writing the proper
1      constraints for those instructions.
1 
1      On some machines, the floating registers are especially slow to
1      access, so that it is better to store a value in a stack frame than
1      in such a register if floating point arithmetic is not being done.
1      As long as the floating registers are not in class 'GENERAL_REGS',
1      they will not be used unless some pattern's constraint asks for
1      one.
1 
1  -- Macro: HARD_REGNO_RENAME_OK (FROM, TO)
1      A C expression that is nonzero if it is OK to rename a hard
1      register FROM to another hard register TO.
1 
1      One common use of this macro is to prevent renaming of a register
1      to another register that is not saved by a prologue in an interrupt
1      handler.
1 
1      The default is always nonzero.
1 
1  -- Target Hook: bool TARGET_MODES_TIEABLE_P (machine_mode MODE1,
1           machine_mode MODE2)
1      This hook returns true if a value of mode MODE1 is accessible in
1      mode MODE2 without copying.
1 
1      If 'TARGET_HARD_REGNO_MODE_OK (R, MODE1)' and
1      'TARGET_HARD_REGNO_MODE_OK (R, MODE2)' are always the same for any
1      R, then 'TARGET_MODES_TIEABLE_P (MODE1, MODE2)' should be true.  If
1      they differ for any R, you should define this hook to return false
1      unless some other mechanism ensures the accessibility of the value
1      in a narrower mode.
1 
1      You should define this hook to return true in as many cases as
1      possible since doing so will allow GCC to perform better register
1      allocation.  The default definition returns true unconditionally.
1 
1  -- Target Hook: bool TARGET_HARD_REGNO_SCRATCH_OK (unsigned int REGNO)
1      This target hook should return 'true' if it is OK to use a hard
1      register REGNO as scratch reg in peephole2.
1 
1      One common use of this macro is to prevent using of a register that
1      is not saved by a prologue in an interrupt handler.
1 
1      The default version of this hook always returns 'true'.
1 
1  -- Macro: AVOID_CCMODE_COPIES
1      Define this macro if the compiler should avoid copies to/from
1      'CCmode' registers.  You should only define this macro if support
1      for copying to/from 'CCmode' is incomplete.
1