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; \
62 * NESTED - declare nested routine entry point
64 #define NESTED(symbol, framesize, rpc) \
67 .type symbol, @function; \
69 symbol: .frame sp, framesize, rpc; \
74 * END - mark end of function
76 #define END(function) \
79 .size function, .-function
82 * EXPORT - export definition of symbol
84 #define EXPORT(symbol) \
89 * FEXPORT - export definition of a function symbol
91 #define FEXPORT(symbol) \
93 .type symbol, @function; \
97 * ABS - export absolute symbol
99 #define ABS(symbol,value) \
113 * Print formatted string
116 #define PRINT(string) \
124 #define PRINT(string)
128 .pushsection .data; \
135 #define TTABLE(string) \
136 .pushsection .text; \
139 .pushsection .data; \
144 * MIPS IV pref instruction.
145 * Use with .set noreorder only!
147 * MIPS IV implementations are free to treat this as a nop. The R5000
148 * is one of them. So we should have an option not to use this instruction.
150 #ifdef CONFIG_CPU_HAS_PREFETCH
152 #define PREF(hint,addr) \
158 #define PREFE(hint, addr) \
165 #define PREFX(hint,addr) \
171 #else /* !CONFIG_CPU_HAS_PREFETCH */
173 #define PREF(hint, addr)
174 #define PREFE(hint, addr)
175 #define PREFX(hint, addr)
177 #endif /* !CONFIG_CPU_HAS_PREFETCH */
180 * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
182 #if (_MIPS_ISA == _MIPS_ISA_MIPS1)
183 #define MOVN(rd, rs, rt) \
190 #define MOVZ(rd, rs, rt) \
197 #endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
198 #if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
199 #define MOVN(rd, rs, rt) \
206 #define MOVZ(rd, rs, rt) \
213 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
214 #if (_MIPS_ISA == _MIPS_ISA_MIPS4 ) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
215 (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
216 #define MOVN(rd, rs, rt) \
218 #define MOVZ(rd, rs, rt) \
220 #endif /* MIPS IV, MIPS V, MIPS32 or MIPS64 */
225 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
229 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
235 * Macros to handle different pointer/register sizes for 32/64-bit code
248 * Use the following macros in assemblercode to load/store registers,
251 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
254 #define REG_SUBU subu
255 #define REG_ADDU addu
257 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
260 #define REG_SUBU dsubu
261 #define REG_ADDU daddu
265 * How to add/sub/load/store/shift C int variables.
267 #if (_MIPS_SZINT == 32)
269 #define INT_ADDU addu
270 #define INT_ADDI addi
271 #define INT_ADDIU addiu
273 #define INT_SUBU subu
277 #define INT_SLLV sllv
279 #define INT_SRLV srlv
281 #define INT_SRAV srav
284 #if (_MIPS_SZINT == 64)
286 #define INT_ADDU daddu
287 #define INT_ADDI daddi
288 #define INT_ADDIU daddiu
290 #define INT_SUBU dsubu
294 #define INT_SLLV dsllv
296 #define INT_SRLV dsrlv
298 #define INT_SRAV dsrav
302 * How to add/sub/load/store/shift C long variables.
304 #if (_MIPS_SZLONG == 32)
306 #define LONG_ADDU addu
307 #define LONG_ADDI addi
308 #define LONG_ADDIU addiu
310 #define LONG_SUBU subu
315 #define LONG_SLLV sllv
317 #define LONG_SRLV srlv
319 #define LONG_SRAV srav
327 #if (_MIPS_SZLONG == 64)
328 #define LONG_ADD dadd
329 #define LONG_ADDU daddu
330 #define LONG_ADDI daddi
331 #define LONG_ADDIU daddiu
332 #define LONG_SUB dsub
333 #define LONG_SUBU dsubu
337 #define LONG_SLL dsll
338 #define LONG_SLLV dsllv
339 #define LONG_SRL dsrl
340 #define LONG_SRLV dsrlv
341 #define LONG_SRA dsra
342 #define LONG_SRAV dsrav
351 * How to add/sub/load/store/shift pointers.
353 #if (_MIPS_SZPTR == 32)
355 #define PTR_ADDU addu
356 #define PTR_ADDI addi
357 #define PTR_ADDIU addiu
359 #define PTR_SUBU subu
365 #define PTR_SLLV sllv
367 #define PTR_SRLV srlv
369 #define PTR_SRAV srav
371 #define PTR_SCALESHIFT 2
378 #if (_MIPS_SZPTR == 64)
380 #define PTR_ADDU daddu
381 #define PTR_ADDI daddi
382 #define PTR_ADDIU daddiu
384 #define PTR_SUBU dsubu
390 #define PTR_SLLV dsllv
392 #define PTR_SRLV dsrlv
394 #define PTR_SRAV dsrav
396 #define PTR_SCALESHIFT 3
404 * Some cp0 registers were extended to 64bit for MIPS III.
406 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
410 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
415 #define SSNOP sll zero, zero, 1
417 #ifdef CONFIG_SGI_IP28
418 /* Inhibit speculative stores to volatile (e.g.DMA) or invalid addresses. */
419 #include <asm/cacheops.h>
420 #define R10KCBARRIER(addr) cache Cache_Barrier, addr;
422 #define R10KCBARRIER(addr)
425 #endif /* __ASM_ASM_H */