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: TARGET_PROMOTE_PROTOTYPES question


On Wed, 21 Oct 2015, Jeff Law wrote:

> > Now I know that we can't get rid of these truncation/extensions
> > entirely, but do we need both?  It seems like foo could say that
> > if the original registers (198 and 200) are argument registers
> > that were extended to SImode due to TARGET_PROMOTE_PROTOTYPES
> > then we don't need to do the truncation/extension in the callee
> > and could just use the SImode values directly.  Am I missing
> > something?  Or are we doing both just to have belts and suspenders
> > and want to keep it that way?
> From reading the docs for TARGET_PROMOTE_PROTYPES, it would seem like it's the
> caller's responsibility.
> 
> However, it's not clear from the docs if it's something the callee can rely
> on, particularly when interoperating with a non-GCC compiler.
> 
> Does the ABI say anything about sub-word argument handling on the caller or
> callee side?

 The 32-bit (o32) MIPS psABI[1] does:

"All integer-valued arguments are passed as 32-bit words, with signed or
unsigned bytes and halfwords expanded (promoted) as necessary."

The 64-bit documents[2][3] then say:

"All integer parameters are promoted (that is, sign- or zero-extended to 
64-bit integers and passed in a single register).  Normally, no code is 
required for the promotion."

Which I understand as making the caller responsible for the promotion.

References:

[1] "SYSTEM V APPLICATION BINARY INTERFACE, MIPS RISC Processor 
    Supplement, 3rd Edition", "Argument Passing", p. 3-18
    <http://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf>

[2] "MIPSpro 64-Bit Porting and Transition Guide", "Native 64-Bit 
    Subprogram Interface for MIPS Architectures", p. 21
    <http://techpubs.sgi.com/library/manuals/2000/007-2391-006/pdf/007-2391-006.pdf>

[3] "MIPSpro N32 ABI Handbook", "N32 and Native 64-Bit (N64) Subprogram 
    Interface for MIPS Architectures", p. 5
    <http://techpubs.sgi.com/library/manuals/2000/007-2816-004/pdf/007-2816-004.pdf>

  Maciej


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