1 /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ralf Baechle <ralf@gnu.org>.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 #define __CAT(str1,str2) str1##str2
29 #define __CAT(str1,str2) str1/**/str2
31 #define CAT(str1,str2) __CAT(str1,str2)
35 * Macros to handle different pointer/register sizes for 32/64-bit code
37 * 64 bit address space isn't used yet, so we may use the R3000 32 bit
45 * PIC specific declarations
48 #define CPRESTORE(register) \
50 #define CPADD(register) \
52 #define CPLOAD(register) \
55 #define CPRESTORE(register)
56 #define CPADD(register)
57 #define CPLOAD(register)
61 * LEAF - declare leaf routine
63 #define LEAF(symbol) \
66 .type symbol,@function; \
68 symbol: .frame sp,0,ra
71 * NESTED - declare nested routine entry point
73 #define NESTED(symbol, framesize, rpc) \
76 .type symbol,@function; \
78 symbol: .frame sp, framesize, rpc
81 * END - mark end of function
83 #define END(function) \
85 .size function,.-function
88 * EXPORT - export definition of symbol
90 #define EXPORT(symbol) \
95 * ABS - export absolute symbol
97 #define ABS(symbol,value) \
111 * Print formated string
113 #define PRINT(string) \
129 #define TTABLE(string) \
138 * MIPS IV pref instruction.
139 * Use with .set noreorder only!
141 * MIPS IV implementations are free to treat this as a nop. The R5000
142 * is one of them. So we should have an option not to use this instruction.
144 #if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5)
145 #define PREF(hint,addr) \
147 #define PREFX(hint,addr) \
155 * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
157 #if _MIPS_ISA == _MIPS_ISA_MIPS1
158 #define MOVN(rd,rs,rt) \
165 #define MOVZ(rd,rs,rt) \
172 #endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
173 #if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
174 #define MOVN(rd,rs,rt) \
181 #define MOVZ(rd,rs,rt) \
188 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
189 #if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5)
190 #define MOVN(rd,rs,rt) \
192 #define MOVZ(rd,rs,rt) \
194 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5) */
199 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
203 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
204 (_MIPS_ISA == _MIPS_ISA_MIPS5)
219 * Use the following macros in assemblercode to load/store registers,
222 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
225 #define PTR_SUBU subu
226 #define PTR_ADDU addu
228 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
229 (_MIPS_ISA == _MIPS_ISA_MIPS5)
232 /* We still live in a 32 bit address space ... */
233 #define PTR_SUBU subu
234 #define PTR_ADDU addu
238 * How to add/sub/load/store/shift C int variables.
240 #if (_MIPS_SZINT == 32)
242 #define INT_ADDI addi
243 #define INT_ADDU addu
244 #define INT_ADDIU addiu
246 #define INT_SUBI subi
247 #define INT_SUBU subu
248 #define INT_SUBIU subu
252 #define LONG_SLLV sllv
254 #define LONG_SRLV srlv
256 #define LONG_SRAV srav
259 #if (_MIPS_SZINT == 64)
261 #define INT_ADDI daddi
262 #define INT_ADDU daddu
263 #define INT_ADDIU daddiu
265 #define INT_SUBI dsubi
266 #define INT_SUBU dsubu
267 #define INT_SUBIU dsubu
270 #define LONG_SLL dsll
271 #define LONG_SLLV dsllv
272 #define LONG_SRL dsrl
273 #define LONG_SRLV dsrlv
274 #define LONG_SRA dsra
275 #define LONG_SRAV dsrav
279 * How to add/sub/load/store/shift C long variables.
281 #if (_MIPS_SZLONG == 32)
283 #define LONG_ADDI addi
284 #define LONG_ADDU addu
285 #define LONG_ADDIU addiu
287 #define LONG_SUBI subi
288 #define LONG_SUBU subu
289 #define LONG_SUBIU subu
293 #define LONG_SLLV sllv
295 #define LONG_SRLV srlv
297 #define LONG_SRAV srav
300 #if (_MIPS_SZLONG == 64)
301 #define LONG_ADD dadd
302 #define LONG_ADDI daddi
303 #define LONG_ADDU daddu
304 #define LONG_ADDIU daddiu
305 #define LONG_SUB dadd
306 #define LONG_SUBI dsubi
307 #define LONG_SUBU dsubu
308 #define LONG_SUBIU dsubu
311 #define LONG_SLL dsll
312 #define LONG_SLLV dsllv
313 #define LONG_SRL dsrl
314 #define LONG_SRLV dsrlv
315 #define LONG_SRA dsra
316 #define LONG_SRAV dsrav
320 * How to add/sub/load/store/shift pointers.
322 #if (_MIPS_SZLONG == 32)
324 #define PTR_ADDI addi
325 #define PTR_ADDU addu
326 #define PTR_ADDIU addiu
328 #define PTR_SUBI subi
329 #define PTR_SUBU subu
330 #define PTR_SUBIU subu
334 #define PTR_SLLV sllv
336 #define PTR_SRLV srlv
338 #define PTR_SRAV srav
340 #define PTR_SCALESHIFT 2
343 #if (_MIPS_SZLONG == 64)
345 #define PTR_ADDI daddi
346 #define PTR_ADDU daddu
347 #define PTR_ADDIU daddiu
349 #define PTR_SUBI dsubi
350 #define PTR_SUBU dsubu
351 #define PTR_SUBIU dsubu
355 #define PTR_SLLV dsllv
357 #define PTR_SRLV dsrlv
359 #define PTR_SRAV dsrav
361 #define PTR_SCALESHIFT 3
365 * Some cp0 registers were extended to 64bit for MIPS III.
367 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
371 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
372 (_MIPS_ISA == _MIPS_ISA_MIPS5)
377 #endif /* sys/asm.h */