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