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>
22 #include <asm/isa-rev.h>
26 * Emit CFI data in .debug_frame sections, not .eh_frame sections.
27 * We don't do DWARF unwinding at runtime, so only the offline DWARF
28 * information is useful to anyone. Note we should change this if we
29 * ever decide to enable DWARF unwinding at runtime.
31 #define CFI_SECTIONS .cfi_sections .debug_frame
34 * For the vDSO, emit both runtime unwind information and debug
35 * symbols for the .dbg file.
42 * LEAF - declare leaf routine
44 #define LEAF(symbol) \
48 .type symbol, @function; \
50 symbol: .frame sp, 0, ra; \
55 * NESTED - declare nested routine entry point
57 #define NESTED(symbol, framesize, rpc) \
61 .type symbol, @function; \
63 symbol: .frame sp, framesize, rpc; \
68 * END - mark end of function
70 #define END(function) \
73 .size function, .-function
76 * EXPORT - export definition of symbol
78 #define EXPORT(symbol) \
83 * FEXPORT - export definition of a function symbol
85 #define FEXPORT(symbol) \
87 .type symbol, @function; \
91 * ABS - export absolute symbol
93 #define ABS(symbol,value) \
102 #define ASM_PANIC(msg) \
112 * Print formatted string
115 #define ASM_PRINT(string) \
123 #define ASM_PRINT(string)
126 #endif /* __ASSEMBLY__ */
131 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
135 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
141 * Macros to handle different pointer/register sizes for 32/64-bit code
154 * Use the following macros in assemblercode to load/store registers,
157 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
160 #define REG_SUBU subu
161 #define REG_ADDU addu
163 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
166 #define REG_SUBU dsubu
167 #define REG_ADDU daddu
171 * How to add/sub/load/store/shift C int variables.
173 #if (_MIPS_SZINT == 32)
175 #define INT_ADDU addu
176 #define INT_ADDI addi
177 #define INT_ADDIU addiu
179 #define INT_SUBU subu
183 #define INT_SLLV sllv
185 #define INT_SRLV srlv
187 #define INT_SRAV srav
190 #if (_MIPS_SZINT == 64)
192 #define INT_ADDU daddu
193 #define INT_ADDI daddi
194 #define INT_ADDIU daddiu
196 #define INT_SUBU dsubu
200 #define INT_SLLV dsllv
202 #define INT_SRLV dsrlv
204 #define INT_SRAV dsrav
208 * How to add/sub/load/store/shift C long variables.
210 #if (_MIPS_SZLONG == 32)
212 #define LONG_ADDU addu
213 #define LONG_ADDI addi
214 #define LONG_ADDIU addiu
216 #define LONG_SUBU subu
223 #define LONG_SLLV sllv
225 #define LONG_SRLV srlv
227 #define LONG_SRAV srav
239 #if (_MIPS_SZLONG == 64)
240 #define LONG_ADD dadd
241 #define LONG_ADDU daddu
242 #define LONG_ADDI daddi
243 #define LONG_ADDIU daddiu
244 #define LONG_SUB dsub
245 #define LONG_SUBU dsubu
251 #define LONG_SLL dsll
252 #define LONG_SLLV dsllv
253 #define LONG_SRL dsrl
254 #define LONG_SRLV dsrlv
255 #define LONG_SRA dsra
256 #define LONG_SRAV dsrav
257 #define LONG_INS dins
258 #define LONG_EXT dext
269 * How to add/sub/load/store/shift pointers.
271 #if (_MIPS_SZPTR == 32)
273 #define PTR_ADDU addu
274 #define PTR_ADDI addi
275 #define PTR_ADDIU addiu
277 #define PTR_SUBU subu
283 #define PTR_SLLV sllv
285 #define PTR_SRLV srlv
287 #define PTR_SRAV srav
289 #define PTR_SCALESHIFT 2
296 #if (_MIPS_SZPTR == 64)
298 #define PTR_ADDU daddu
299 #define PTR_ADDI daddi
300 #define PTR_ADDIU daddiu
302 #define PTR_SUBU dsubu
308 #define PTR_SLLV dsllv
310 #define PTR_SRLV dsrlv
312 #define PTR_SRAV dsrav
314 #define PTR_SCALESHIFT 3
316 #define PTR_WD .dword
322 * Some cp0 registers were extended to 64bit for MIPS III.
324 #if (_MIPS_SIM == _MIPS_SIM_ABI32)
328 #if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
333 #define SSNOP sll zero, zero, 1
336 * Using a branch-likely instruction to check the result of an sc instruction
337 * works around a bug present in R10000 CPUs prior to revision 3.0 that could
338 * cause ll-sc sequences to execute non-atomically.
340 #ifdef CONFIG_WAR_R10000_LLSC
341 # define SC_BEQZ beqzl
342 #elif !defined(CONFIG_CC_HAS_BROKEN_INLINE_COMPAT_BRANCH) && MIPS_ISA_REV >= 6
343 # define SC_BEQZ beqzc
345 # define SC_BEQZ beqz
348 #ifdef CONFIG_SGI_IP28
349 /* Inhibit speculative stores to volatile (e.g.DMA) or invalid addresses. */
350 #include <asm/cacheops.h>
351 #define R10KCBARRIER(addr) cache Cache_Barrier, addr;
353 #define R10KCBARRIER(addr)
356 #endif /* __ASM_ASM_H */