OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [iq2000/] [abi] - Diff between revs 38 and 154

Only display areas with differences | Details | Blame | View Log

Rev 38 Rev 154
                        IQ2000 ABI
                        IQ2000 ABI
                        =========
                        =========
Sizes and alignments
Sizes and alignments
--------------------
--------------------
        Type            Size (bytes)    Alignment (bytes)
        Type            Size (bytes)    Alignment (bytes)
        char            1               1
        char            1               1
        short           2               2
        short           2               2
        int             4               4
        int             4               4
        unsigned        4               4
        unsigned        4               4
        long            4               4
        long            4               4
        long long       8               8
        long long       8               8
        float           4               4
        float           4               4
        double          8               8
        double          8               8
        pointers        4               4
        pointers        4               4
* alignment within aggregates (structs and unions) is as above, with
* alignment within aggregates (structs and unions) is as above, with
  padding added if needed
  padding added if needed
* aggregates have alignment equal to that of their most aligned
* aggregates have alignment equal to that of their most aligned
  member
  member
* aggregates have sizes which are a multiple of their alignment
* aggregates have sizes which are a multiple of their alignment
Floating point
Floating point
--------------
--------------
All emulated using IEEE floating point conventions.
All emulated using IEEE floating point conventions.
Registers
Registers
----------------
----------------
%0              always zero
%0              always zero
%1              call clobbered
%1              call clobbered
%2              return value
%2              return value
%3              return value
%3              return value
%4              argument register 1
%4              argument register 1
%5              argument register 2
%5              argument register 2
%6              argument register 3
%6              argument register 3
%7              argument register 4
%7              argument register 4
%8              argument register 5
%8              argument register 5
%9              argument register 6
%9              argument register 6
%10             argument register 7
%10             argument register 7
%11             argument register 8
%11             argument register 8
%12             call clobbered
%12             call clobbered
%13             call clobbered
%13             call clobbered
%14             call clobbered
%14             call clobbered
%15             call clobbered
%15             call clobbered
%16             call saved
%16             call saved
%17             call saved
%17             call saved
%18             call saved
%18             call saved
%19             call saved
%19             call saved
%20             call saved
%20             call saved
%21             call saved
%21             call saved
%22             call saved
%22             call saved
%23             call saved
%23             call saved
%24             call clobbered
%24             call clobbered
%25             call clobbered
%25             call clobbered
%26             reserved
%26             reserved
%27             frame ptr
%27             frame ptr
%28             global ptr
%28             global ptr
%29             stack ptr
%29             stack ptr
%30             reserved
%30             reserved
%31             return address
%31             return address
Stack alignment         8 bytes
Stack alignment         8 bytes
Structures passed       <= 32 bits as values, else as pointers
Structures passed       <= 32 bits as values, else as pointers
The IQ2000 Stack
The IQ2000 Stack
---------------
---------------
Space is allocated as needed in the stack frame for the following at compile
Space is allocated as needed in the stack frame for the following at compile
time:
time:
* Outgoing parameters beyond the eighth
* Outgoing parameters beyond the eighth
* All automatic arrays, automatic data aggregates, automatic
* All automatic arrays, automatic data aggregates, automatic
  scalars which must be addressable, and automatic scalars for
  scalars which must be addressable, and automatic scalars for
  which there is no room in registers
  which there is no room in registers
* Compiler-generated temporary values (typically when there are
* Compiler-generated temporary values (typically when there are
  too many for the compiler to keep them all in registers)
  too many for the compiler to keep them all in registers)
Space can be allocated dynamically (at runtime) in the stack frame for the
Space can be allocated dynamically (at runtime) in the stack frame for the
following:
following:
* Memory allocated using the alloca() function of the C library
* Memory allocated using the alloca() function of the C library
Addressable automatic variables on the stack are addressed with positive
Addressable automatic variables on the stack are addressed with positive
offsets relative to %27; dynamically allocated space is addressed with positive
offsets relative to %27; dynamically allocated space is addressed with positive
offsets from the pointer returned by alloca().
offsets from the pointer returned by alloca().
Stack Frame
Stack Frame
-----------
-----------
        +-----------------------+
        +-----------------------+
        |    Caller memory args |
        |    Caller memory args |
        +-----------------------+ <-sp
        +-----------------------+ <-sp
        |    Return address     |
        |    Return address     |
        +-----------------------+
        +-----------------------+
        |    Previous FP        |
        |    Previous FP        |
        +-----------------------+
        +-----------------------+
        |    Saved Registers    |
        |    Saved Registers    |
        +-----------------------+
        +-----------------------+
        |        ...            |
        |        ...            |
        +-----------------------+
        +-----------------------+
        |    Local Variables    |
        |    Local Variables    |
        +-----------------------+ <-fp
        +-----------------------+ <-fp
        |    Alloca             |
        |    Alloca             |
        +-----------------------+
        +-----------------------+
        |        ...            |
        |        ...            |
        +-----------------------+
        +-----------------------+
        |   Parameter Word 2    |
        |   Parameter Word 2    |
        +-----------------------+
        +-----------------------+
        |   Parameter Word 1    |
        |   Parameter Word 1    |
        +-----------------------+ <-sp
        +-----------------------+ <-sp
Parameter Assignment to Registers
Parameter Assignment to Registers
---------------------------------
---------------------------------
Consider the parameters in a function call as ordered from left (first
Consider the parameters in a function call as ordered from left (first
parameter) to right.  GR contains the number of the next available
parameter) to right.  GR contains the number of the next available
general-purpose register.  STARG is the address of the next available stack
general-purpose register.  STARG is the address of the next available stack
parameter word.
parameter word.
INITIALIZE:
INITIALIZE:
        Set GR=r4 and STARG to point to parameter word 1.
        Set GR=r4 and STARG to point to parameter word 1.
SCAN:
SCAN:
        If there are no more parameters, terminate.
        If there are no more parameters, terminate.
        Otherwise, select one of the following depending on the type
        Otherwise, select one of the following depending on the type
        of the next parameter:
        of the next parameter:
    SIMPLE ARG:
    SIMPLE ARG:
        A SIMPLE ARG is one of the following:
        A SIMPLE ARG is one of the following:
        * One of the simple integer types which will fit into a
        * One of the simple integer types which will fit into a
          general-purpose register,
          general-purpose register,
        * A pointer to an object of any type,
        * A pointer to an object of any type,
        * A struct or union small enough to fit in a register (<= 32 bits)
        * A struct or union small enough to fit in a register (<= 32 bits)
        * A larger struct or union, which shall be treated as a
        * A larger struct or union, which shall be treated as a
          pointer to the object or to a copy of the object.
          pointer to the object or to a copy of the object.
          (See below for when copies are made.)
          (See below for when copies are made.)
        If GR > r11, go to STACK.  Otherwise, load the parameter value into
        If GR > r11, go to STACK.  Otherwise, load the parameter value into
        general-purpose register GR and advance GR to the next general-purpose
        general-purpose register GR and advance GR to the next general-purpose
        register.  Values shorter than the register size are sign-extended or
        register.  Values shorter than the register size are sign-extended or
        zero-extended depending on whether they are signed or unsigned.  Then
        zero-extended depending on whether they are signed or unsigned.  Then
        go to SCAN.
        go to SCAN.
    DOUBLE or LONG LONG
    DOUBLE or LONG LONG
        If GR > r10, go to STACK.  Otherwise, if GR is odd, advance GR to the
        If GR > r10, go to STACK.  Otherwise, if GR is odd, advance GR to the
        next register.  Load the 64-bit long long or double value into register
        next register.  Load the 64-bit long long or double value into register
        pair GR and GR+1.  Advance GR to GR+2 and go to SCAN.
        pair GR and GR+1.  Advance GR to GR+2 and go to SCAN.
    STACK:
    STACK:
        Parameters not otherwise handled above are passed in the parameter
        Parameters not otherwise handled above are passed in the parameter
        words of the caller's stack frame.  SIMPLE ARGs, as defined above, are
        words of the caller's stack frame.  SIMPLE ARGs, as defined above, are
        considered to have size and alignment equal to the size of a
        considered to have size and alignment equal to the size of a
        general-purpose register, with simple argument types shorter than this
        general-purpose register, with simple argument types shorter than this
        sign- or zero-extended to this width.  Round STARG up to a multiple of
        sign- or zero-extended to this width.  Round STARG up to a multiple of
        the alignment requirement of the parameter and copy the argument
        the alignment requirement of the parameter and copy the argument
        byte-for-byte into STARG, STARG+1, ...  STARG+size-1.  Set STARG to
        byte-for-byte into STARG, STARG+1, ...  STARG+size-1.  Set STARG to
        STARG+size and go to SCAN.
        STARG+size and go to SCAN.
Structure passing
Structure passing
-----------------
-----------------
As noted above, code which passes structures and unions by value is implemented
As noted above, code which passes structures and unions by value is implemented
specially.  (In this section, "struct" will refer to structs and unions
specially.  (In this section, "struct" will refer to structs and unions
inclusively.)  Structs small enough to fit in a register are passed by value in
inclusively.)  Structs small enough to fit in a register are passed by value in
a single register or in a stack frame slot the size of a register.  Structs
a single register or in a stack frame slot the size of a register.  Structs
containing a single double or long long component are passed by value in two
containing a single double or long long component are passed by value in two
registers or in a stack frame slot the size of two registers.  Other structs
registers or in a stack frame slot the size of two registers.  Other structs
are handled by passing the address of the structure.  In this case, a copy of
are handled by passing the address of the structure.  In this case, a copy of
the structure will be made if necessary in order to preserve the pass-by-value
the structure will be made if necessary in order to preserve the pass-by-value
semantics.
semantics.
Copies of large structs are made under the following rules:
Copies of large structs are made under the following rules:
                        ANSI mode                       K&R Mode
                        ANSI mode                       K&R Mode
                        ---------                       --------
                        ---------                       --------
Normal param            Callee copies if needed         Caller copies
Normal param            Callee copies if needed         Caller copies
Varargs (...) param     Caller copies                   Caller copies
Varargs (...) param     Caller copies                   Caller copies
In the case of normal (non-varargs) large-struct parameters in ANSI mode, the
In the case of normal (non-varargs) large-struct parameters in ANSI mode, the
callee is responsible for producing the same effect as if a copy of the
callee is responsible for producing the same effect as if a copy of the
structure were passed, preserving the pass-by-value semantics.  This may be
structure were passed, preserving the pass-by-value semantics.  This may be
accomplished by having the callee make a copy, but in some cases the callee may
accomplished by having the callee make a copy, but in some cases the callee may
be able to determine that a copy is not necessary in order to produce the same
be able to determine that a copy is not necessary in order to produce the same
results.  In such cases, the callee may choose to avoid making a copy of the
results.  In such cases, the callee may choose to avoid making a copy of the
parameter.
parameter.
Varargs handling
Varargs handling
----------------
----------------
No special changes are needed for handling varargs parameters other than the
No special changes are needed for handling varargs parameters other than the
caller knowing that a copy is needed on struct parameters larger than a
caller knowing that a copy is needed on struct parameters larger than a
register (see above).
register (see above).
The varargs macros set up a register save area for the general-purpose
The varargs macros set up a register save area for the general-purpose
registers to be saved.  Because the save area lies between the caller and
registers to be saved.  Because the save area lies between the caller and
callee stack frames, the saved register parameters are contiguous with
callee stack frames, the saved register parameters are contiguous with
parameters passed on the stack.  A pointer advances from the register save area
parameters passed on the stack.  A pointer advances from the register save area
into the caller's stack frame.
into the caller's stack frame.
Function return values
Function return values
----------------------
----------------------
        Type            Register
        Type            Register
        ----            --------
        ----            --------
        int             r2
        int             r2
        short           r2
        short           r2
        long            r2
        long            r2
        long long       r2-r3
        long long       r2-r3
        float           r2
        float           r2
        double          r2-r3
        double          r2-r3
        struct/union    see below
        struct/union    see below
Structs/unions which will fit into two general-purpose registers are returned
Structs/unions which will fit into two general-purpose registers are returned
in r2, or in r2-r3 if necessary.  Larger structs/unions are handled by the
in r2, or in r2-r3 if necessary.  Larger structs/unions are handled by the
caller passing as a "hidden" first argument a pointer to space allocated to
caller passing as a "hidden" first argument a pointer to space allocated to
receive the return value.
receive the return value.
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.