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 #ifdef CONFIG_CPU_HAS_PREFETCH
133 #define PREF(hint,addr) \
136 #define PREFX(hint,addr) \
139 #else /* !CONFIG_CPU_HAS_PREFETCH */
141 #define PREF(hint,addr)
142 #define PREFX(hint,addr)
144 #endif /* !CONFIG_CPU_HAS_PREFETCH */
147 * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
149 #if (_MIPS_ISA == _MIPS_ISA_MIPS1)
150 #define MOVN(rd,rs,rt) \
157 #define MOVZ(rd,rs,rt) \
164 #endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
165 #if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
166 #define MOVN(rd,rs,rt) \
173 #define MOVZ(rd,rs,rt) \
180 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
181 #if (_MIPS_ISA == _MIPS_ISA_MIPS4 ) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
182 (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
183 #define MOVN(rd,rs,rt) \
185 #define MOVZ(rd,rs,rt) \
187 #endif /* MIPS IV, MIPS V, MIPS32 or MIPS64 */
192 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2) || \
193 (_MIPS_ISA == _MIPS_ISA_MIPS32)
197 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
198 (_MIPS_ISA == _MIPS_ISA_MIPS5) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
204 * Macros to handle different pointer/register sizes for 32/64-bit code
217 * Use the following macros in assemblercode to load/store registers,
220 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2) || \
221 (_MIPS_ISA == _MIPS_ISA_MIPS32)
224 #define REG_SUBU subu
225 #define REG_ADDU addu
227 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
228 (_MIPS_ISA == _MIPS_ISA_MIPS5) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
231 #define REG_SUBU dsubu
232 #define REG_ADDU daddu
236 * How to add/sub/load/store/shift C int variables.
238 #if (_MIPS_SZINT == 32)
240 #define INT_ADDU addu
241 #define INT_ADDI addi
242 #define INT_ADDIU addiu
244 #define INT_SUBU subu
248 #define INT_SLLV sllv
250 #define INT_SRLV srlv
252 #define INT_SRAV srav
255 #if (_MIPS_SZINT == 64)
257 #define INT_ADDU daddu
258 #define INT_ADDI daddi
259 #define INT_ADDIU daddiu
261 #define INT_SUBU dsubu
265 #define INT_SLLV dsllv
267 #define INT_SRLV dsrlv
269 #define INT_SRAV dsrav
273 * How to add/sub/load/store/shift C long variables.
275 #if (_MIPS_SZLONG == 32)
277 #define LONG_ADDU addu
278 #define LONG_ADDI addi
279 #define LONG_ADDIU addiu
281 #define LONG_SUBU subu
285 #define LONG_SLLV sllv
287 #define LONG_SRLV srlv
289 #define LONG_SRAV srav
296 #if (_MIPS_SZLONG == 64)
297 #define LONG_ADD dadd
298 #define LONG_ADDU daddu
299 #define LONG_ADDI daddi
300 #define LONG_ADDIU daddiu
301 #define LONG_SUB dsub
302 #define LONG_SUBU dsubu
305 #define LONG_SLL dsll
306 #define LONG_SLLV dsllv
307 #define LONG_SRL dsrl
308 #define LONG_SRLV dsrlv
309 #define LONG_SRA dsra
310 #define LONG_SRAV dsrav
318 * How to add/sub/load/store/shift pointers.
320 #if (_MIPS_SZPTR == 32)
322 #define PTR_ADDU addu
323 #define PTR_ADDI addi
324 #define PTR_ADDIU addiu
326 #define PTR_SUBU subu
331 #define PTR_SLLV sllv
333 #define PTR_SRLV srlv
335 #define PTR_SRAV srav
337 #define PTR_SCALESHIFT 2
344 #if (_MIPS_SZPTR == 64)
346 #define PTR_ADDU daddu
347 #define PTR_ADDI daddi
348 #define PTR_ADDIU daddiu
350 #define PTR_SUBU dsubu
355 #define PTR_SLLV dsllv
357 #define PTR_SRLV dsrlv
359 #define PTR_SRAV dsrav
361 #define PTR_SCALESHIFT 3
369 * Some cp0 registers were extended to 64bit for MIPS III.
371 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2) || \
372 (_MIPS_ISA == _MIPS_ISA_MIPS32)
376 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
377 (_MIPS_ISA == _MIPS_ISA_MIPS5) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
382 #define SSNOP sll zero,zero,1
384 #endif /* __ASM_ASM_H */