2 * include/asm-mips/asm.h
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * Copyright (C) 1995, 1996, 1997 by Ralf Baechle
10 * Some useful macros for MIPS assembler code
12 * Some of the routines below contain useless nops that will be optimized
13 * away by gas in -O mode. These nops are however required to fill delay
14 * slots in noreorder mode.
19 #include <asm/sgidefs.h>
23 #define __CAT(str1,str2) str1##str2
25 #define __CAT(str1,str2) str1/**/str2
27 #define CAT(str1,str2) __CAT(str1,str2)
31 * Macros to handle different pointer/register sizes for 32/64-bit code
33 * 64 bit address space isn't used yet, so we may use the R3000 32 bit
41 * PIC specific declarations
42 * Not used for the kernel but here seems to be the right place.
45 #define CPRESTORE(register) \
47 #define CPADD(register) \
49 #define CPLOAD(register) \
52 #define CPRESTORE(register)
53 #define CPADD(register)
54 #define CPLOAD(register)
58 * LEAF - declare leaf routine
60 #define LEAF(symbol) \
63 .type symbol,@function; \
65 symbol: .frame sp,0,ra
68 * NESTED - declare nested routine entry point
70 #define NESTED(symbol, framesize, rpc) \
73 .type symbol,@function; \
75 symbol: .frame sp, framesize, rpc
78 * END - mark end of function
80 #define END(function) \
82 .size function,.-function
85 * EXPORT - export definition of symbol
87 #define EXPORT(symbol) \
92 * ABS - export absolute symbol
94 #define ABS(symbol,value) \
108 * Print formated string
110 #define PRINT(string) \
126 #define TTABLE(string) \
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 #if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5)
142 #define PREF(hint,addr) \
144 #define PREFX(hint,addr) \
152 * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
154 #if _MIPS_ISA == _MIPS_ISA_MIPS1
155 #define MOVN(rd,rs,rt) \
162 #define MOVZ(rd,rs,rt) \
169 #endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
170 #if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
171 #define MOVN(rd,rs,rt) \
178 #define MOVZ(rd,rs,rt) \
185 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
186 #if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5)
187 #define MOVN(rd,rs,rt) \
189 #define MOVZ(rd,rs,rt) \
191 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5) */
196 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
200 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
201 (_MIPS_ISA == _MIPS_ISA_MIPS5)
216 * Use the following macros in assemblercode to load/store registers,
219 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
222 #define PTR_SUBU subu
223 #define PTR_ADDU addu
225 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
226 (_MIPS_ISA == _MIPS_ISA_MIPS5)
229 /* We still live in a 32 bit address space ... */
230 #define PTR_SUBU subu
231 #define PTR_ADDU addu
235 * How to add/sub/load/store/shift C int variables.
237 #if (_MIPS_SZINT == 32)
239 #define INT_ADDI addi
240 #define INT_ADDU addu
241 #define INT_ADDIU addiu
243 #define INT_SUBI subi
244 #define INT_SUBU subu
245 #define INT_SUBIU subu
249 #define LONG_SLLV sllv
251 #define LONG_SRLV srlv
253 #define LONG_SRAV srav
256 #if (_MIPS_SZINT == 64)
258 #define INT_ADDI daddi
259 #define INT_ADDU daddu
260 #define INT_ADDIU daddiu
262 #define INT_SUBI dsubi
263 #define INT_SUBU dsubu
264 #define INT_SUBIU dsubu
267 #define LONG_SLL dsll
268 #define LONG_SLLV dsllv
269 #define LONG_SRL dsrl
270 #define LONG_SRLV dsrlv
271 #define LONG_SRA dsra
272 #define LONG_SRAV dsrav
276 * How to add/sub/load/store/shift C long variables.
278 #if (_MIPS_SZLONG == 32)
280 #define LONG_ADDI addi
281 #define LONG_ADDU addu
282 #define LONG_ADDIU addiu
284 #define LONG_SUBI subi
285 #define LONG_SUBU subu
286 #define LONG_SUBIU subu
290 #define LONG_SLLV sllv
292 #define LONG_SRLV srlv
294 #define LONG_SRAV srav
297 #if (_MIPS_SZLONG == 64)
298 #define LONG_ADD dadd
299 #define LONG_ADDI daddi
300 #define LONG_ADDU daddu
301 #define LONG_ADDIU daddiu
302 #define LONG_SUB dadd
303 #define LONG_SUBI dsubi
304 #define LONG_SUBU dsubu
305 #define LONG_SUBIU dsubu
308 #define LONG_SLL dsll
309 #define LONG_SLLV dsllv
310 #define LONG_SRL dsrl
311 #define LONG_SRLV dsrlv
312 #define LONG_SRA dsra
313 #define LONG_SRAV dsrav
317 * How to add/sub/load/store/shift pointers.
319 #if (_MIPS_SZLONG == 32)
321 #define PTR_ADDI addi
322 #define PTR_ADDU addu
323 #define PTR_ADDIU addiu
325 #define PTR_SUBI subi
326 #define PTR_SUBU subu
327 #define PTR_SUBIU subu
331 #define PTR_SLLV sllv
333 #define PTR_SRLV srlv
335 #define PTR_SRAV srav
337 #define PTR_SCALESHIFT 2
340 #if (_MIPS_SZLONG == 64)
342 #define PTR_ADDI daddi
343 #define PTR_ADDU daddu
344 #define PTR_ADDIU daddiu
346 #define PTR_SUBI dsubi
347 #define PTR_SUBU dsubu
348 #define PTR_SUBIU dsubu
352 #define PTR_SLLV dsllv
354 #define PTR_SRLV dsrlv
356 #define PTR_SRAV dsrav
358 #define PTR_SCALESHIFT 3
362 * Some cp0 registers were extended to 64bit for MIPS III.
364 #if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
368 #if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
369 (_MIPS_ISA == _MIPS_ISA_MIPS5)
374 #endif /* __ASM_ASM_H */