1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI__ALPHA_COMPILER_H
3 #define _UAPI__ALPHA_COMPILER_H
6 * Herein are macros we use when describing various patterns we want to GCC.
7 * In all cases we can get better schedules out of the compiler if we hide
8 * as little as possible inside inline assembly. However, we want to be
9 * able to know what we'll get out before giving up inline assembly. Thus
10 * these tests and macros.
13 #if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3
14 # define __kernel_insbl(val, shift) __builtin_alpha_insbl(val, shift)
15 # define __kernel_inswl(val, shift) __builtin_alpha_inswl(val, shift)
16 # define __kernel_insql(val, shift) __builtin_alpha_insql(val, shift)
17 # define __kernel_inslh(val, shift) __builtin_alpha_inslh(val, shift)
18 # define __kernel_extbl(val, shift) __builtin_alpha_extbl(val, shift)
19 # define __kernel_extwl(val, shift) __builtin_alpha_extwl(val, shift)
20 # define __kernel_cmpbge(a, b) __builtin_alpha_cmpbge(a, b)
22 # define __kernel_insbl(val, shift) \
23 ({ unsigned long __kir; \
24 __asm__("insbl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
26 # define __kernel_inswl(val, shift) \
27 ({ unsigned long __kir; \
28 __asm__("inswl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
30 # define __kernel_insql(val, shift) \
31 ({ unsigned long __kir; \
32 __asm__("insql %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
34 # define __kernel_inslh(val, shift) \
35 ({ unsigned long __kir; \
36 __asm__("inslh %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
38 # define __kernel_extbl(val, shift) \
39 ({ unsigned long __kir; \
40 __asm__("extbl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
42 # define __kernel_extwl(val, shift) \
43 ({ unsigned long __kir; \
44 __asm__("extwl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \
46 # define __kernel_cmpbge(a, b) \
47 ({ unsigned long __kir; \
48 __asm__("cmpbge %r2,%1,%0" : "=r"(__kir) : "rI"(b), "rJ"(a)); \
53 # if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3
54 # define __kernel_cttz(x) __builtin_ctzl(x)
55 # define __kernel_ctlz(x) __builtin_clzl(x)
56 # define __kernel_ctpop(x) __builtin_popcountl(x)
58 # define __kernel_cttz(x) \
59 ({ unsigned long __kir; \
60 __asm__("cttz %1,%0" : "=r"(__kir) : "r"(x)); \
62 # define __kernel_ctlz(x) \
63 ({ unsigned long __kir; \
64 __asm__("ctlz %1,%0" : "=r"(__kir) : "r"(x)); \
66 # define __kernel_ctpop(x) \
67 ({ unsigned long __kir; \
68 __asm__("ctpop %1,%0" : "=r"(__kir) : "r"(x)); \
72 # define __kernel_cttz(x) \
73 ({ unsigned long __kir; \
74 __asm__(".arch ev67; cttz %1,%0" : "=r"(__kir) : "r"(x)); \
76 # define __kernel_ctlz(x) \
77 ({ unsigned long __kir; \
78 __asm__(".arch ev67; ctlz %1,%0" : "=r"(__kir) : "r"(x)); \
80 # define __kernel_ctpop(x) \
81 ({ unsigned long __kir; \
82 __asm__(".arch ev67; ctpop %1,%0" : "=r"(__kir) : "r"(x)); \
88 * Beginning with EGCS 1.1, GCC defines __alpha_bwx__ when the BWX
89 * extension is enabled. Previous versions did not define anything
90 * we could test during compilation -- too bad, so sad.
93 #if defined(__alpha_bwx__)
94 #define __kernel_ldbu(mem) (mem)
95 #define __kernel_ldwu(mem) (mem)
96 #define __kernel_stb(val,mem) ((mem) = (val))
97 #define __kernel_stw(val,mem) ((mem) = (val))
99 #define __kernel_ldbu(mem) \
100 ({ unsigned char __kir; \
101 __asm__(".arch ev56; \
102 ldbu %0,%1" : "=r"(__kir) : "m"(mem)); \
104 #define __kernel_ldwu(mem) \
105 ({ unsigned short __kir; \
106 __asm__(".arch ev56; \
107 ldwu %0,%1" : "=r"(__kir) : "m"(mem)); \
109 #define __kernel_stb(val,mem) \
110 __asm__(".arch ev56; \
111 stb %1,%0" : "=m"(mem) : "r"(val))
112 #define __kernel_stw(val,mem) \
113 __asm__(".arch ev56; \
114 stw %1,%0" : "=m"(mem) : "r"(val))
118 #endif /* _UAPI__ALPHA_COMPILER_H */