Hi,

I'm working on a gcc/gnat port  for a private target (gcc 4.5.2, gnat 6.4.2).
On this target, scalar values shall be stored in $R registers whereas pointer 
values shall be stored in $C registers. My current ABI for procedure/function 
calls uses $R and $C registers depending on arguments and return values type 
(scalar or pointer). I need an ABI of this kind for performance reasons (the 
instruction set does not allow $R and $C everywhere and copying $R in $C for 
each procedure calls is too expensive).

I tested this ABI through GCC C and C++ torture suite and everything is ok 
(after solving special cases for implicit calls)

During my tests I tried to mix ADA and C sources code using the 'pragma 
import/export'. For example I tried to implement the "__gnat_malloc" expected 
by the ZFP runtime by an ADA function and 'pragma export' :

        function Gnat_Malloc (Size : in Integer) return System.Address is
        begin
                -- implementation
        end Gnat_Malloc;
        pragma Export (C, Gnat_Malloc, "__gnat_malloc");

Here is my problem :
* the caller of __gnat_malloc expects that return value of type pointer to be 
in a $C register (as defined in the ABI)
* the called function Gnat_Malloc return a value of type system.address in $R 
register because system.address is considered as a scalar value (system.ads:   
type Address is mod Memory_Size;) 
    ==> caller and callee return values doesn't match, the ABI is broken

I tried to modified system.ads so that system.address arguments become pointers 
(using access keyword) but I can't figure out how to do this because the System 
package is 'pragma Pure' ...

Is there a way to modify something somewhere (runtime, backend, frontend ...) 
so that arguments of type system.address are seen as pointers and not scalar 
values ?

Regards,

  Selim Belbachir





Reply via email to