This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CALL_USED_REGISTERS vs CALL_REALLY_USED_REGISTERS


Mohamed Shafi <shafitvm@gmail.com> writes:

> The GCC 4.4.0 internal says :
> [Macro] CALL_REALLY_USED_REGISTERS
> Like CALL_USED_REGISTERS except this macro doesnât require that the
> entire set of
> FIXED_REGISTERS be included. (CALL_USED_REGISTERS must be a superset of FIXED_
> REGISTERS). This macro is optional. If not specifed, it defaults to the value of
> CALL_USED_REGISTERS.
>
> But it doesn't say why one needs to use this.
> What is the need for the macro CALL_REALLY_USED_REGISTERS when
> compared to CALL_USED_REGISTERS?

As the doc says, CALL_USED_REGISTERS is required to include all fixed
registers.  However, some ABIs have fixed registers which appear in the
insn stream and are not modified by calls.  It can be useful for gcc to
know that those registers are not changed by a call instruction.  In
particular, this means that if gcc uses the value of the register in an
expression which includes a call, it knows that it does not have to copy
the register into a callee-saved register to preserve the value.

For example, the MIPS register $28 aka $gp has this characteristic.  It
is a fixed register in that it is not available for the register
allocator.  However, the instruction stream will contain code to use the
register to access global variables (or small variables, depending on
the ABI).  The register is not changed by function calls, so gcc does
not have to extra steps to preserve its value.  Also, gcc can CSE $gp
plus a large offset across a function call.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]