1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Some useful macros for LoongArch assembler code
5 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
8 * Copyright (C) 1995, 1996, 1997, 1999, 2001 by Ralf Baechle
9 * Copyright (C) 1999 by Silicon Graphics, Inc.
10 * Copyright (C) 2001 MIPS Technologies, Inc.
11 * Copyright (C) 2002 Maciej W. Rozycki
16 /* LoongArch pref instruction. */
17 #ifdef CONFIG_CPU_HAS_PREFETCH
19 #define PREF(hint, addr, offs) \
20 preld hint, addr, offs; \
22 #define PREFX(hint, addr, index) \
23 preldx hint, addr, index; \
25 #else /* !CONFIG_CPU_HAS_PREFETCH */
27 #define PREF(hint, addr, offs)
28 #define PREFX(hint, addr, index)
30 #endif /* !CONFIG_CPU_HAS_PREFETCH */
35 #define STACK_ALIGN ~(0xf)
38 * Macros to handle different pointer/register sizes for 32/64-bit code
51 * Use the following macros in assemblercode to load/store registers,
59 #else /* SZREG == 8 */
67 * How to add/sub/load/store/shift C int variables.
69 #if (__SIZEOF_INT__ == 4)
71 #define INT_ADDI addi.w
75 #define INT_SLL slli.w
76 #define INT_SLLV sll.w
77 #define INT_SRL srli.w
78 #define INT_SRLV srl.w
79 #define INT_SRA srai.w
80 #define INT_SRAV sra.w
83 #if (__SIZEOF_INT__ == 8)
85 #define INT_ADDI addi.d
89 #define INT_SLL slli.d
90 #define INT_SLLV sll.d
91 #define INT_SRL srli.d
92 #define INT_SRLV srl.d
93 #define INT_SRA srai.d
94 #define INT_SRAV sra.d
98 * How to add/sub/load/store/shift C long variables.
100 #if (__SIZEOF_LONG__ == 4)
101 #define LONG_ADD add.w
102 #define LONG_ADDI addi.w
103 #define LONG_SUB sub.w
106 #define LONG_SLL slli.w
107 #define LONG_SLLV sll.w
108 #define LONG_SRL srli.w
109 #define LONG_SRLV srl.w
110 #define LONG_SRA srai.w
111 #define LONG_SRAV sra.w
121 #if (__SIZEOF_LONG__ == 8)
122 #define LONG_ADD add.d
123 #define LONG_ADDI addi.d
124 #define LONG_SUB sub.d
127 #define LONG_SLL slli.d
128 #define LONG_SLLV sll.d
129 #define LONG_SRL srli.d
130 #define LONG_SRLV srl.d
131 #define LONG_SRA srai.d
132 #define LONG_SRAV sra.d
143 * How to add/sub/load/store/shift pointers.
145 #if (__SIZEOF_POINTER__ == 4)
146 #define PTR_ADD add.w
147 #define PTR_ADDI addi.w
148 #define PTR_SUB sub.w
152 #define PTR_SLL slli.w
153 #define PTR_SLLV sll.w
154 #define PTR_SRL srli.w
155 #define PTR_SRLV srl.w
156 #define PTR_SRA srai.w
157 #define PTR_SRAV sra.w
159 #define PTR_SCALESHIFT 2
168 #if (__SIZEOF_POINTER__ == 8)
169 #define PTR_ADD add.d
170 #define PTR_ADDI addi.d
171 #define PTR_SUB sub.d
175 #define PTR_SLL slli.d
176 #define PTR_SLLV sll.d
177 #define PTR_SRL srli.d
178 #define PTR_SRLV srl.d
179 #define PTR_SRA srai.d
180 #define PTR_SRAV sra.d
182 #define PTR_SCALESHIFT 3
191 /* Annotate a function as being unsuitable for kprobes. */
192 #ifdef CONFIG_KPROBES
193 #define _ASM_NOKPROBE(name) \
194 .pushsection "_kprobe_blacklist", "aw"; \
198 #define _ASM_NOKPROBE(name)
201 #endif /* __ASM_ASM_H */