APCS-32 & 'float' argument passing

Nick Burrett nick at dsvr.net
Wed Jun 9 07:16:59 PDT 2004


John Tytgat wrote:
> Not sure if this has been discussed before (can't search the mail archives)
> but there seems to be an incompatibility between GCC 'float' argument
> passing and Norcroft's, both in APCS-32 output mode and results in a
> problem when using UnixLib with Norcroft.

> --8<--
> C Language Calling Conventions
> ------------------------------
> 
> 
> Argument Representation
> .......................
> 
> A floating point value occupies 1, 2, or 3 words, as appropriate to its type.
> Floating point values are encoded in IEEE 754 format, with the most significant 
> word of a double having the lowest address.
> 
> The C compiler widens arguments of type float to type double to support 
> inter-working between ANSI C and classic C.
> [...]
> --8<--
> 
> I can only conclude GCC is not completely APCS-32 compliant.

The reason is that GCC 3.3 and later conforms to the ATPCS:


Parameter passing is defined in terms of values of the fundamental 
machine types:

- 32-bit integers
- Single precision floating-point numbers
- Double precision floating-point numbers

These are the types of the underlying machine registers.

[...]

A source language parameter value is converted to a machine parameter 
value as follows

[...]

A homogeneous floating-point value (such as double or double complex) is 
converted to:
   - One or more floating-point values of the corresponding machine type 
(here double precision) if the called routine will use floating-point 
hardware.


In section 7.1

Conceptually primitive floating-point values (float, double) are handled 
at the machine level and require no conversion.


> Has this been discussed before ? Could this be fixed in GCC please (this
> means also a couple of fixes in UnixLib) ?

This has never been an issue before.  I'm 100% certain that APCS-R does 
not promote 32-bit float arguments to 64-bit double arguments. 
Otherwise the code would never have been written that way.

It should be straightforward to fix this by setting ARM_FLAG_ATPCS 
rather than ARM_FLAG_APCS_32 in riscos-aof.h.  This will probably change 
the ABI though.


-- 
Nick Burrett, Senior Systems and Network Engineer
Designer Servers Ltd.   http://www.dsvr.co.uk




More information about the gcc mailing list