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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [iq2000/] [abi] - Blame information for rev 282

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
                        IQ2000 ABI
2
                        =========
3
 
4
Sizes and alignments
5
--------------------
6
 
7
        Type            Size (bytes)    Alignment (bytes)
8
 
9
        char            1               1
10
        short           2               2
11
        int             4               4
12
        unsigned        4               4
13
        long            4               4
14
        long long       8               8
15
        float           4               4
16
        double          8               8
17
        pointers        4               4
18
 
19
* alignment within aggregates (structs and unions) is as above, with
20
  padding added if needed
21
* aggregates have alignment equal to that of their most aligned
22
  member
23
* aggregates have sizes which are a multiple of their alignment
24
 
25
 
26
Floating point
27
--------------
28
 
29
All emulated using IEEE floating point conventions.
30
 
31
Registers
32
----------------
33
 
34
%0              always zero
35
%1              call clobbered
36
%2              return value
37
%3              return value
38
%4              argument register 1
39
%5              argument register 2
40
%6              argument register 3
41
%7              argument register 4
42
%8              argument register 5
43
%9              argument register 6
44
%10             argument register 7
45
%11             argument register 8
46
%12             call clobbered
47
%13             call clobbered
48
%14             call clobbered
49
%15             call clobbered
50
%16             call saved
51
%17             call saved
52
%18             call saved
53
%19             call saved
54
%20             call saved
55
%21             call saved
56
%22             call saved
57
%23             call saved
58
%24             call clobbered
59
%25             call clobbered
60
%26             reserved
61
%27             frame ptr
62
%28             global ptr
63
%29             stack ptr
64
%30             reserved
65
%31             return address
66
 
67
Stack alignment         8 bytes
68
 
69
Structures passed       <= 32 bits as values, else as pointers
70
 
71
The IQ2000 Stack
72
---------------
73
 
74
Space is allocated as needed in the stack frame for the following at compile
75
time:
76
 
77
* Outgoing parameters beyond the eighth
78
 
79
* All automatic arrays, automatic data aggregates, automatic
80
  scalars which must be addressable, and automatic scalars for
81
  which there is no room in registers
82
 
83
* Compiler-generated temporary values (typically when there are
84
  too many for the compiler to keep them all in registers)
85
 
86
Space can be allocated dynamically (at runtime) in the stack frame for the
87
following:
88
 
89
* Memory allocated using the alloca() function of the C library
90
 
91
Addressable automatic variables on the stack are addressed with positive
92
offsets relative to %27; dynamically allocated space is addressed with positive
93
offsets from the pointer returned by alloca().
94
 
95
Stack Frame
96
-----------
97
 
98
        +-----------------------+
99
        |    Caller memory args |
100
        +-----------------------+ <-sp
101
        |    Return address     |
102
        +-----------------------+
103
        |    Previous FP        |
104
        +-----------------------+
105
        |    Saved Registers    |
106
        +-----------------------+
107
        |        ...            |
108
        +-----------------------+
109
        |    Local Variables    |
110
        +-----------------------+ <-fp
111
        |    Alloca             |
112
        +-----------------------+
113
        |        ...            |
114
        +-----------------------+
115
        |   Parameter Word 2    |
116
        +-----------------------+
117
        |   Parameter Word 1    |
118
        +-----------------------+ <-sp
119
 
120
 
121
Parameter Assignment to Registers
122
---------------------------------
123
 
124
Consider the parameters in a function call as ordered from left (first
125
parameter) to right.  GR contains the number of the next available
126
general-purpose register.  STARG is the address of the next available stack
127
parameter word.
128
 
129
INITIALIZE:
130
        Set GR=r4 and STARG to point to parameter word 1.
131
 
132
SCAN:
133
        If there are no more parameters, terminate.
134
        Otherwise, select one of the following depending on the type
135
        of the next parameter:
136
 
137
    SIMPLE ARG:
138
 
139
        A SIMPLE ARG is one of the following:
140
 
141
        * One of the simple integer types which will fit into a
142
          general-purpose register,
143
        * A pointer to an object of any type,
144
        * A struct or union small enough to fit in a register (<= 32 bits)
145
        * A larger struct or union, which shall be treated as a
146
          pointer to the object or to a copy of the object.
147
          (See below for when copies are made.)
148
 
149
        If GR > r11, go to STACK.  Otherwise, load the parameter value into
150
        general-purpose register GR and advance GR to the next general-purpose
151
        register.  Values shorter than the register size are sign-extended or
152
        zero-extended depending on whether they are signed or unsigned.  Then
153
        go to SCAN.
154
 
155
    DOUBLE or LONG LONG
156
 
157
        If GR > r10, go to STACK.  Otherwise, if GR is odd, advance GR to the
158
        next register.  Load the 64-bit long long or double value into register
159
        pair GR and GR+1.  Advance GR to GR+2 and go to SCAN.
160
 
161
    STACK:
162
 
163
        Parameters not otherwise handled above are passed in the parameter
164
        words of the caller's stack frame.  SIMPLE ARGs, as defined above, are
165
        considered to have size and alignment equal to the size of a
166
        general-purpose register, with simple argument types shorter than this
167
        sign- or zero-extended to this width.  Round STARG up to a multiple of
168
        the alignment requirement of the parameter and copy the argument
169
        byte-for-byte into STARG, STARG+1, ...  STARG+size-1.  Set STARG to
170
        STARG+size and go to SCAN.
171
 
172
 
173
Structure passing
174
-----------------
175
 
176
As noted above, code which passes structures and unions by value is implemented
177
specially.  (In this section, "struct" will refer to structs and unions
178
inclusively.)  Structs small enough to fit in a register are passed by value in
179
a single register or in a stack frame slot the size of a register.  Structs
180
containing a single double or long long component are passed by value in two
181
registers or in a stack frame slot the size of two registers.  Other structs
182
are handled by passing the address of the structure.  In this case, a copy of
183
the structure will be made if necessary in order to preserve the pass-by-value
184
semantics.
185
 
186
Copies of large structs are made under the following rules:
187
 
188
                        ANSI mode                       K&R Mode
189
                        ---------                       --------
190
Normal param            Callee copies if needed         Caller copies
191
Varargs (...) param     Caller copies                   Caller copies
192
 
193
In the case of normal (non-varargs) large-struct parameters in ANSI mode, the
194
callee is responsible for producing the same effect as if a copy of the
195
structure were passed, preserving the pass-by-value semantics.  This may be
196
accomplished by having the callee make a copy, but in some cases the callee may
197
be able to determine that a copy is not necessary in order to produce the same
198
results.  In such cases, the callee may choose to avoid making a copy of the
199
parameter.
200
 
201
 
202
Varargs handling
203
----------------
204
 
205
No special changes are needed for handling varargs parameters other than the
206
caller knowing that a copy is needed on struct parameters larger than a
207
register (see above).
208
 
209
The varargs macros set up a register save area for the general-purpose
210
registers to be saved.  Because the save area lies between the caller and
211
callee stack frames, the saved register parameters are contiguous with
212
parameters passed on the stack.  A pointer advances from the register save area
213
into the caller's stack frame.
214
 
215
 
216
Function return values
217
----------------------
218
 
219
        Type            Register
220
        ----            --------
221
        int             r2
222
        short           r2
223
        long            r2
224
        long long       r2-r3
225
        float           r2
226
        double          r2-r3
227
        struct/union    see below
228
 
229
Structs/unions which will fit into two general-purpose registers are returned
230
in r2, or in r2-r3 if necessary.  Larger structs/unions are handled by the
231
caller passing as a "hidden" first argument a pointer to space allocated to
232
receive the return value.
233
 
234
 
235
Copyright (C) 2003 Free Software Foundation, Inc.
236
 
237
Copying and distribution of this file, with or without modification,
238
are permitted in any medium without royalty provided the copyright
239
notice and this notice are preserved.

powered by: WebSVN 2.1.0

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