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 <linux/config.h>
21 #include <asm/sgidefs.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
110 #define PRINT(string) \
119 .pushsection .data; \
126 #define TTABLE(string) \
127 .pushsection .text; \
130 .pushsection .data; \
135 * MIPS IV pref instruction.
136 * Use with .set noreorder only!
138 * MIPS IV implementations are free to treat this as a nop. The R5000
139 * is one of them. So we should have an option not to use this instruction.
141 #ifdef CONFIG_CPU_HAS_PREFETCH
143 #define PREF(hint,addr) \
149 #define PREFX(hint,addr) \
155 #else /* !CONFIG_CPU_HAS_PREFETCH */
157 #define PREF(hint,addr)
158 #define PREFX(hint,addr)
160 #endif /* !CONFIG_CPU_HAS_PREFETCH */
163 * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
165 #if (_MIPS_ISA == _MIPS_ISA_MIPS1)
166 #define MOVN(rd,rs,rt) \
173 #define MOVZ(rd,rs,rt) \
180 #endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
181 #if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
182 #define MOVN(rd,rs,rt) \
189 #define MOVZ(rd,rs,rt) \
196 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
197 #if (_MIPS_ISA == _MIPS_ISA_MIPS4 ) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
198 (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
199 #define MOVN(rd,rs,rt) \
201 #define MOVZ(rd,rs,rt) \
203 #endif /* MIPS IV, MIPS V, MIPS32 or MIPS64 */
208 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
212 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
218 * Macros to handle different pointer/register sizes for 32/64-bit code
231 * Use the following macros in assemblercode to load/store registers,
234 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
237 #define REG_SUBU subu
238 #define REG_ADDU addu
240 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
243 #define REG_SUBU dsubu
244 #define REG_ADDU daddu
248 * How to add/sub/load/store/shift C int variables.
250 #if (_MIPS_SZINT == 32)
252 #define INT_ADDU addu
253 #define INT_ADDI addi
254 #define INT_ADDIU addiu
256 #define INT_SUBU subu
260 #define INT_SLLV sllv
262 #define INT_SRLV srlv
264 #define INT_SRAV srav
267 #if (_MIPS_SZINT == 64)
269 #define INT_ADDU daddu
270 #define INT_ADDI daddi
271 #define INT_ADDIU daddiu
273 #define INT_SUBU dsubu
277 #define INT_SLLV dsllv
279 #define INT_SRLV dsrlv
281 #define INT_SRAV dsrav
285 * How to add/sub/load/store/shift C long variables.
287 #if (_MIPS_SZLONG == 32)
289 #define LONG_ADDU addu
290 #define LONG_ADDI addi
291 #define LONG_ADDIU addiu
293 #define LONG_SUBU subu
297 #define LONG_SLLV sllv
299 #define LONG_SRLV srlv
301 #define LONG_SRAV srav
309 #if (_MIPS_SZLONG == 64)
310 #define LONG_ADD dadd
311 #define LONG_ADDU daddu
312 #define LONG_ADDI daddi
313 #define LONG_ADDIU daddiu
314 #define LONG_SUB dsub
315 #define LONG_SUBU dsubu
318 #define LONG_SLL dsll
319 #define LONG_SLLV dsllv
320 #define LONG_SRL dsrl
321 #define LONG_SRLV dsrlv
322 #define LONG_SRA dsra
323 #define LONG_SRAV dsrav
332 * How to add/sub/load/store/shift pointers.
334 #if (_MIPS_SZPTR == 32)
336 #define PTR_ADDU addu
337 #define PTR_ADDI addi
338 #define PTR_ADDIU addiu
340 #define PTR_SUBU subu
345 #define PTR_SLLV sllv
347 #define PTR_SRLV srlv
349 #define PTR_SRAV srav
351 #define PTR_SCALESHIFT 2
358 #if (_MIPS_SZPTR == 64)
360 #define PTR_ADDU daddu
361 #define PTR_ADDI daddi
362 #define PTR_ADDIU daddiu
364 #define PTR_SUBU dsubu
369 #define PTR_SLLV dsllv
371 #define PTR_SRLV dsrlv
373 #define PTR_SRAV dsrav
375 #define PTR_SCALESHIFT 3
383 * Some cp0 registers were extended to 64bit for MIPS III.
385 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
389 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
394 #define SSNOP sll zero,zero,1
396 #endif /* __ASM_ASM_H */