2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1995, 1996, 1997, 1999, 2001 by Ralf Baechle
7 * Copyright (C) 1999 by Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
9 * Copyright (C) 2002 Maciej W. Rozycki
11 * Some useful macros for MIPS assembler code
13 * Some of the routines below contain useless nops that will be optimized
14 * away by gas in -O mode. These nops are however required to fill delay
15 * slots in noreorder mode.
20 #include <asm/sgidefs.h>
23 * PIC specific declarations
24 * Not used for the kernel but here seems to be the right place.
27 #define CPRESTORE(register) \
29 #define CPADD(register) \
31 #define CPLOAD(register) \
34 #define CPRESTORE(register)
35 #define CPADD(register)
36 #define CPLOAD(register)
40 * LEAF - declare leaf routine
42 #define LEAF(symbol) \
45 .type symbol,@function; \
47 symbol: .frame sp,0,ra
50 * NESTED - declare nested routine entry point
52 #define NESTED(symbol, framesize, rpc) \
55 .type symbol,@function; \
57 symbol: .frame sp, framesize, rpc
60 * END - mark end of function
62 #define END(function) \
64 .size function,.-function
67 * EXPORT - export definition of symbol
69 #define EXPORT(symbol) \
74 * FEXPORT - export definition of a function symbol
76 #define FEXPORT(symbol) \
78 .type symbol,@function; \
82 * ABS - export absolute symbol
84 #define ABS(symbol,value) \
98 * Print formatted string
100 #define PRINT(string) \
109 .pushsection .data; \
116 #define TTABLE(string) \
117 .pushsection .text; \
120 .pushsection .data; \
125 * MIPS IV pref instruction.
126 * Use with .set noreorder only!
128 * MIPS IV implementations are free to treat this as a nop. The R5000
129 * is one of them. So we should have an option not to use this instruction.
131 #if (_MIPS_ISA == _MIPS_ISA_MIPS4 ) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
132 (_MIPS_ISA == _MIPS_ISA_MIPS64)
134 #define PREF(hint,addr) \
140 #define PREFX(hint,addr) \
148 #define PREF(hint,addr)
149 #define PREFX(hint,addr)
154 * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
156 #if (_MIPS_ISA == _MIPS_ISA_MIPS1)
157 #define MOVN(rd,rs,rt) \
164 #define MOVZ(rd,rs,rt) \
171 #endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
172 #if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
173 #define MOVN(rd,rs,rt) \
180 #define MOVZ(rd,rs,rt) \
187 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
188 #if (_MIPS_ISA == _MIPS_ISA_MIPS4 ) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
189 (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
190 #define MOVN(rd,rs,rt) \
192 #define MOVZ(rd,rs,rt) \
194 #endif /* MIPS IV, MIPS V, MIPS32 or MIPS64 */
199 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2) || \
200 (_MIPS_ISA == _MIPS_ISA_MIPS32)
204 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
205 (_MIPS_ISA == _MIPS_ISA_MIPS5) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
211 * Macros to handle different pointer/register sizes for 32/64-bit code
224 * Use the following macros in assemblercode to load/store registers,
227 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2) || \
228 (_MIPS_ISA == _MIPS_ISA_MIPS32)
231 #define REG_SUBU subu
232 #define REG_ADDU addu
234 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
235 (_MIPS_ISA == _MIPS_ISA_MIPS5) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
238 #define REG_SUBU dsubu
239 #define REG_ADDU daddu
243 * How to add/sub/load/store/shift C int variables.
245 #if (_MIPS_SZINT == 32)
247 #define INT_ADDU addu
248 #define INT_ADDI addi
249 #define INT_ADDIU addiu
251 #define INT_SUBU subu
255 #define INT_SLLV sllv
257 #define INT_SRLV srlv
259 #define INT_SRAV srav
262 #if (_MIPS_SZINT == 64)
264 #define INT_ADDU daddu
265 #define INT_ADDI daddi
266 #define INT_ADDIU daddiu
268 #define INT_SUBU dsubu
272 #define INT_SLLV dsllv
274 #define INT_SRLV dsrlv
276 #define INT_SRAV dsrav
280 * How to add/sub/load/store/shift C long variables.
282 #if (_MIPS_SZLONG == 32)
284 #define LONG_ADDU addu
285 #define LONG_ADDI addi
286 #define LONG_ADDIU addiu
288 #define LONG_SUBU subu
292 #define LONG_SLLV sllv
294 #define LONG_SRLV srlv
296 #define LONG_SRAV srav
299 #if (_MIPS_SZLONG == 64)
300 #define LONG_ADD dadd
301 #define LONG_ADDU daddu
302 #define LONG_ADDI daddi
303 #define LONG_ADDIU daddiu
304 #define LONG_SUB dsub
305 #define LONG_SUBU dsubu
308 #define LONG_SLL dsll
309 #define LONG_SLLV dsllv
310 #define LONG_SRL dsrl
311 #define LONG_SRLV dsrlv
312 #define LONG_SRA dsra
313 #define LONG_SRAV dsrav
317 * How to add/sub/load/store/shift pointers.
319 #if (_MIPS_SZPTR == 32)
321 #define PTR_ADDU addu
322 #define PTR_ADDI addi
323 #define PTR_ADDIU addiu
325 #define PTR_SUBU subu
330 #define PTR_SLLV sllv
332 #define PTR_SRLV srlv
334 #define PTR_SRAV srav
336 #define PTR_SCALESHIFT 2
343 #if (_MIPS_SZPTR == 64)
345 #define PTR_ADDU daddu
346 #define PTR_ADDI daddi
347 #define PTR_ADDIU daddiu
349 #define PTR_SUBU dsubu
354 #define PTR_SLLV dsllv
356 #define PTR_SRLV dsrlv
358 #define PTR_SRAV dsrav
360 #define PTR_SCALESHIFT 3
368 * Some cp0 registers were extended to 64bit for MIPS III.
370 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2) || \
371 (_MIPS_ISA == _MIPS_ISA_MIPS32)
375 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
376 (_MIPS_ISA == _MIPS_ISA_MIPS5) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
381 #define SSNOP sll zero,zero,1
383 #endif /* __ASM_ASM_H */