APCS-32 & 'float' argument passing

Nick Burrett nick at dsvr.net
Fri Jun 11 01:10:25 PDT 2004


Nick Burrett wrote:
> John Tytgat wrote:
> 
>> 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.
> 
> 
> I don't know where you got this document from, but it is wrong and as 
> far as I am concerned, the Norcroft compiler is wrong.

Sorry, John.  Immediately after I posted this, I found the additional 
paragraphs that you wrote about.

> Have a look at the APCS defined here:
>   http://www.iyonix.com/32bit/download/32bitv19a.zip
> 
>   A floating-point value not passed in a floating-point register is
>   treated as 1, 2 or 3 integer values, as appropriate to its precision.

Certainly this holds true, but the bit that John quotes referrs 
compatibility between ANSI C and K&R C, which is reflected in a 
situation where you have a prototype such as:

   double foo ();

All parameters passed to 'foo' will be promoted to double, if they are 
float types.

I looked into this problem in more detail last night.  The changes to 
GCC are non-trivial since there is no actual mechanism in the middle-end 
or back-end to do this auto-promotion.

Making this change would be a violation of the ISO C99 standard.

Nick.

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




More information about the gcc mailing list