gccint: Interface

1 
1 3 Interfacing to GCC Output
1 ***************************
1 
1 GCC is normally configured to use the same function calling convention
1 normally in use on the target system.  This is done with the
1 machine-description macros described (⇒Target Macros).
1 
1  However, returning of structure and union values is done differently on
1 some target machines.  As a result, functions compiled with PCC
1 returning such types cannot be called from code compiled with GCC, and
1 vice versa.  This does not cause trouble often because few Unix library
1 routines return structures or unions.
1 
1  GCC code returns structures and unions that are 1, 2, 4 or 8 bytes long
1 in the same registers used for 'int' or 'double' return values.  (GCC
1 typically allocates variables of such types in registers also.)
1 Structures and unions of other sizes are returned by storing them into
1 an address passed by the caller (usually in a register).  The target
1 hook 'TARGET_STRUCT_VALUE_RTX' tells GCC where to pass this address.
1 
1  By contrast, PCC on most target machines returns structures and unions
1 of any size by copying the data into an area of static storage, and then
1 returning the address of that storage as if it were a pointer value.
1 The caller must copy the data from that memory area to the place where
1 the value is wanted.  This is slower than the method used by GCC, and
1 fails to be reentrant.
1 
1  On some target machines, such as RISC machines and the 80386, the
1 standard system convention is to pass to the subroutine the address of
1 where to return the value.  On these machines, GCC has been configured
1 to be compatible with the standard compiler, when this method is used.
1 It may not be compatible for structures of 1, 2, 4 or 8 bytes.
1 
1  GCC uses the system's standard convention for passing arguments.  On
1 some machines, the first few arguments are passed in registers; in
1 others, all are passed on the stack.  It would be possible to use
1 registers for argument passing on any machine, and this would probably
1 result in a significant speedup.  But the result would be complete
1 incompatibility with code that follows the standard convention.  So this
1 change is practical only if you are switching to GCC as the sole C
1 compiler for the system.  We may implement register argument passing on
1 certain machines once we have a complete GNU system so that we can
1 compile the libraries with GCC.
1 
1  On some machines (particularly the SPARC), certain types of arguments
1 are passed "by invisible reference".  This means that the value is
1 stored in memory, and the address of the memory location is passed to
1 the subroutine.
1 
1  If you use 'longjmp', beware of automatic variables.  ISO C says that
1 automatic variables that are not declared 'volatile' have undefined
1 values after a 'longjmp'.  And this is all GCC promises to do, because
1 it is very difficult to restore register variables correctly, and one of
1 GCC's features is that it can put variables in registers without your
1 asking it to.
1