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>
24 #define __CAT(str1, str2) str1##str2
26 #define __CAT(str1, str2) str1/**/str2
28 #define CAT(str1, str2) __CAT(str1, str2)
32 * PIC specific declarations
33 * Not used for the kernel but here seems to be the right place.
36 #define CPRESTORE(register) \
38 #define CPADD(register) \
40 #define CPLOAD(register) \
43 #define CPRESTORE(register)
44 #define CPADD(register)
45 #define CPLOAD(register)
49 * LEAF - declare leaf routine
51 #define LEAF(symbol) \
54 .type symbol, @function; \
56 symbol: .frame sp, 0, ra
59 * NESTED - declare nested routine entry point
61 #define NESTED(symbol, framesize, rpc) \
64 .type symbol, @function; \
66 symbol: .frame sp, framesize, rpc
69 * END - mark end of function
71 #define END(function) \
73 .size function, .-function
76 * EXPORT - export definition of symbol
78 #define EXPORT(symbol) \
83 * FEXPORT - export definition of a function symbol
85 #define FEXPORT(symbol) \
87 .type symbol, @function; \
91 * ABS - export absolute symbol
93 #define ABS(symbol,value) \
107 * Print formatted string
110 #define PRINT(string) \
118 #define PRINT(string)
122 .pushsection .data; \
129 #define TTABLE(string) \
130 .pushsection .text; \
133 .pushsection .data; \
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 #ifdef CONFIG_CPU_HAS_PREFETCH
146 #define PREF(hint,addr) \
152 #define PREFX(hint,addr) \
158 #else /* !CONFIG_CPU_HAS_PREFETCH */
160 #define PREF(hint, addr)
161 #define PREFX(hint, addr)
163 #endif /* !CONFIG_CPU_HAS_PREFETCH */
166 * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
168 #if (_MIPS_ISA == _MIPS_ISA_MIPS1)
169 #define MOVN(rd, rs, rt) \
176 #define MOVZ(rd, rs, rt) \
183 #endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
184 #if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
185 #define MOVN(rd, rs, rt) \
192 #define MOVZ(rd, rs, rt) \
199 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
200 #if (_MIPS_ISA == _MIPS_ISA_MIPS4 ) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
201 (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
202 #define MOVN(rd, rs, rt) \
204 #define MOVZ(rd, rs, rt) \
206 #endif /* MIPS IV, MIPS V, MIPS32 or MIPS64 */
211 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
215 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
221 * Macros to handle different pointer/register sizes for 32/64-bit code
234 * Use the following macros in assemblercode to load/store registers,
237 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
240 #define REG_SUBU subu
241 #define REG_ADDU addu
243 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
246 #define REG_SUBU dsubu
247 #define REG_ADDU daddu
251 * How to add/sub/load/store/shift C int variables.
253 #if (_MIPS_SZINT == 32)
255 #define INT_ADDU addu
256 #define INT_ADDI addi
257 #define INT_ADDIU addiu
259 #define INT_SUBU subu
263 #define INT_SLLV sllv
265 #define INT_SRLV srlv
267 #define INT_SRAV srav
270 #if (_MIPS_SZINT == 64)
272 #define INT_ADDU daddu
273 #define INT_ADDI daddi
274 #define INT_ADDIU daddiu
276 #define INT_SUBU dsubu
280 #define INT_SLLV dsllv
282 #define INT_SRLV dsrlv
284 #define INT_SRAV dsrav
288 * How to add/sub/load/store/shift C long variables.
290 #if (_MIPS_SZLONG == 32)
292 #define LONG_ADDU addu
293 #define LONG_ADDI addi
294 #define LONG_ADDIU addiu
296 #define LONG_SUBU subu
300 #define LONG_SLLV sllv
302 #define LONG_SRLV srlv
304 #define LONG_SRAV srav
312 #if (_MIPS_SZLONG == 64)
313 #define LONG_ADD dadd
314 #define LONG_ADDU daddu
315 #define LONG_ADDI daddi
316 #define LONG_ADDIU daddiu
317 #define LONG_SUB dsub
318 #define LONG_SUBU dsubu
321 #define LONG_SLL dsll
322 #define LONG_SLLV dsllv
323 #define LONG_SRL dsrl
324 #define LONG_SRLV dsrlv
325 #define LONG_SRA dsra
326 #define LONG_SRAV dsrav
335 * How to add/sub/load/store/shift pointers.
337 #if (_MIPS_SZPTR == 32)
339 #define PTR_ADDU addu
340 #define PTR_ADDI addi
341 #define PTR_ADDIU addiu
343 #define PTR_SUBU subu
349 #define PTR_SLLV sllv
351 #define PTR_SRLV srlv
353 #define PTR_SRAV srav
355 #define PTR_SCALESHIFT 2
362 #if (_MIPS_SZPTR == 64)
364 #define PTR_ADDU daddu
365 #define PTR_ADDI daddi
366 #define PTR_ADDIU daddiu
368 #define PTR_SUBU dsubu
374 #define PTR_SLLV dsllv
376 #define PTR_SRLV dsrlv
378 #define PTR_SRAV dsrav
380 #define PTR_SCALESHIFT 3
388 * Some cp0 registers were extended to 64bit for MIPS III.
390 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
394 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
399 #define SSNOP sll zero, zero, 1
401 #endif /* __ASM_ASM_H */