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>
21 #include <asm/asm-eva.h>
25 #define __CAT(str1, str2) str1##str2
27 #define __CAT(str1, str2) str1/**/str2
29 #define CAT(str1, str2) __CAT(str1, str2)
33 * PIC specific declarations
34 * Not used for the kernel but here seems to be the right place.
37 #define CPRESTORE(register) \
39 #define CPADD(register) \
41 #define CPLOAD(register) \
44 #define CPRESTORE(register)
45 #define CPADD(register)
46 #define CPLOAD(register)
50 * LEAF - declare leaf routine
52 #define LEAF(symbol) \
55 .type symbol, @function; \
57 symbol: .frame sp, 0, ra
60 * NESTED - declare nested routine entry point
62 #define NESTED(symbol, framesize, rpc) \
65 .type symbol, @function; \
67 symbol: .frame sp, framesize, rpc
70 * END - mark end of function
72 #define END(function) \
74 .size function, .-function
77 * EXPORT - export definition of symbol
79 #define EXPORT(symbol) \
84 * FEXPORT - export definition of a function symbol
86 #define FEXPORT(symbol) \
88 .type symbol, @function; \
92 * ABS - export absolute symbol
94 #define ABS(symbol,value) \
108 * Print formatted string
111 #define PRINT(string) \
119 #define PRINT(string)
123 .pushsection .data; \
130 #define TTABLE(string) \
131 .pushsection .text; \
134 .pushsection .data; \
139 * MIPS IV pref instruction.
140 * Use with .set noreorder only!
142 * MIPS IV implementations are free to treat this as a nop. The R5000
143 * is one of them. So we should have an option not to use this instruction.
145 #ifdef CONFIG_CPU_HAS_PREFETCH
147 #define PREF(hint,addr) \
153 #define PREFE(hint, addr) \
160 #define PREFX(hint,addr) \
166 #else /* !CONFIG_CPU_HAS_PREFETCH */
168 #define PREF(hint, addr)
169 #define PREFE(hint, addr)
170 #define PREFX(hint, addr)
172 #endif /* !CONFIG_CPU_HAS_PREFETCH */
175 * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
177 #if (_MIPS_ISA == _MIPS_ISA_MIPS1)
178 #define MOVN(rd, rs, rt) \
185 #define MOVZ(rd, rs, rt) \
192 #endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
193 #if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
194 #define MOVN(rd, rs, rt) \
201 #define MOVZ(rd, rs, rt) \
208 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
209 #if (_MIPS_ISA == _MIPS_ISA_MIPS4 ) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
210 (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
211 #define MOVN(rd, rs, rt) \
213 #define MOVZ(rd, rs, rt) \
215 #endif /* MIPS IV, MIPS V, MIPS32 or MIPS64 */
220 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
224 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
230 * Macros to handle different pointer/register sizes for 32/64-bit code
243 * Use the following macros in assemblercode to load/store registers,
246 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
249 #define REG_SUBU subu
250 #define REG_ADDU addu
252 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
255 #define REG_SUBU dsubu
256 #define REG_ADDU daddu
260 * How to add/sub/load/store/shift C int variables.
262 #if (_MIPS_SZINT == 32)
264 #define INT_ADDU addu
265 #define INT_ADDI addi
266 #define INT_ADDIU addiu
268 #define INT_SUBU subu
272 #define INT_SLLV sllv
274 #define INT_SRLV srlv
276 #define INT_SRAV srav
279 #if (_MIPS_SZINT == 64)
281 #define INT_ADDU daddu
282 #define INT_ADDI daddi
283 #define INT_ADDIU daddiu
285 #define INT_SUBU dsubu
289 #define INT_SLLV dsllv
291 #define INT_SRLV dsrlv
293 #define INT_SRAV dsrav
297 * How to add/sub/load/store/shift C long variables.
299 #if (_MIPS_SZLONG == 32)
301 #define LONG_ADDU addu
302 #define LONG_ADDI addi
303 #define LONG_ADDIU addiu
305 #define LONG_SUBU subu
310 #define LONG_SLLV sllv
312 #define LONG_SRLV srlv
314 #define LONG_SRAV srav
322 #if (_MIPS_SZLONG == 64)
323 #define LONG_ADD dadd
324 #define LONG_ADDU daddu
325 #define LONG_ADDI daddi
326 #define LONG_ADDIU daddiu
327 #define LONG_SUB dsub
328 #define LONG_SUBU dsubu
332 #define LONG_SLL dsll
333 #define LONG_SLLV dsllv
334 #define LONG_SRL dsrl
335 #define LONG_SRLV dsrlv
336 #define LONG_SRA dsra
337 #define LONG_SRAV dsrav
346 * How to add/sub/load/store/shift pointers.
348 #if (_MIPS_SZPTR == 32)
350 #define PTR_ADDU addu
351 #define PTR_ADDI addi
352 #define PTR_ADDIU addiu
354 #define PTR_SUBU subu
360 #define PTR_SLLV sllv
362 #define PTR_SRLV srlv
364 #define PTR_SRAV srav
366 #define PTR_SCALESHIFT 2
373 #if (_MIPS_SZPTR == 64)
375 #define PTR_ADDU daddu
376 #define PTR_ADDI daddi
377 #define PTR_ADDIU daddiu
379 #define PTR_SUBU dsubu
385 #define PTR_SLLV dsllv
387 #define PTR_SRLV dsrlv
389 #define PTR_SRAV dsrav
391 #define PTR_SCALESHIFT 3
399 * Some cp0 registers were extended to 64bit for MIPS III.
401 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
405 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
410 #define SSNOP sll zero, zero, 1
412 #ifdef CONFIG_SGI_IP28
413 /* Inhibit speculative stores to volatile (e.g.DMA) or invalid addresses. */
414 #include <asm/cacheops.h>
415 #define R10KCBARRIER(addr) cache Cache_Barrier, addr;
417 #define R10KCBARRIER(addr)
420 #endif /* __ASM_ASM_H */