1*6f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 296433f6eSDavid Howells #ifndef _UAPI__ALPHA_COMPILER_H 396433f6eSDavid Howells #define _UAPI__ALPHA_COMPILER_H 496433f6eSDavid Howells 596433f6eSDavid Howells /* 696433f6eSDavid Howells * Herein are macros we use when describing various patterns we want to GCC. 796433f6eSDavid Howells * In all cases we can get better schedules out of the compiler if we hide 896433f6eSDavid Howells * as little as possible inside inline assembly. However, we want to be 996433f6eSDavid Howells * able to know what we'll get out before giving up inline assembly. Thus 1096433f6eSDavid Howells * these tests and macros. 1196433f6eSDavid Howells */ 1296433f6eSDavid Howells 1396433f6eSDavid Howells #if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3 1496433f6eSDavid Howells # define __kernel_insbl(val, shift) __builtin_alpha_insbl(val, shift) 1596433f6eSDavid Howells # define __kernel_inswl(val, shift) __builtin_alpha_inswl(val, shift) 1696433f6eSDavid Howells # define __kernel_insql(val, shift) __builtin_alpha_insql(val, shift) 1796433f6eSDavid Howells # define __kernel_inslh(val, shift) __builtin_alpha_inslh(val, shift) 1896433f6eSDavid Howells # define __kernel_extbl(val, shift) __builtin_alpha_extbl(val, shift) 1996433f6eSDavid Howells # define __kernel_extwl(val, shift) __builtin_alpha_extwl(val, shift) 2096433f6eSDavid Howells # define __kernel_cmpbge(a, b) __builtin_alpha_cmpbge(a, b) 2196433f6eSDavid Howells #else 2296433f6eSDavid Howells # define __kernel_insbl(val, shift) \ 2396433f6eSDavid Howells ({ unsigned long __kir; \ 2496433f6eSDavid Howells __asm__("insbl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \ 2596433f6eSDavid Howells __kir; }) 2696433f6eSDavid Howells # define __kernel_inswl(val, shift) \ 2796433f6eSDavid Howells ({ unsigned long __kir; \ 2896433f6eSDavid Howells __asm__("inswl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \ 2996433f6eSDavid Howells __kir; }) 3096433f6eSDavid Howells # define __kernel_insql(val, shift) \ 3196433f6eSDavid Howells ({ unsigned long __kir; \ 3296433f6eSDavid Howells __asm__("insql %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \ 3396433f6eSDavid Howells __kir; }) 3496433f6eSDavid Howells # define __kernel_inslh(val, shift) \ 3596433f6eSDavid Howells ({ unsigned long __kir; \ 3696433f6eSDavid Howells __asm__("inslh %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \ 3796433f6eSDavid Howells __kir; }) 3896433f6eSDavid Howells # define __kernel_extbl(val, shift) \ 3996433f6eSDavid Howells ({ unsigned long __kir; \ 4096433f6eSDavid Howells __asm__("extbl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \ 4196433f6eSDavid Howells __kir; }) 4296433f6eSDavid Howells # define __kernel_extwl(val, shift) \ 4396433f6eSDavid Howells ({ unsigned long __kir; \ 4496433f6eSDavid Howells __asm__("extwl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val)); \ 4596433f6eSDavid Howells __kir; }) 4696433f6eSDavid Howells # define __kernel_cmpbge(a, b) \ 4796433f6eSDavid Howells ({ unsigned long __kir; \ 4896433f6eSDavid Howells __asm__("cmpbge %r2,%1,%0" : "=r"(__kir) : "rI"(b), "rJ"(a)); \ 4996433f6eSDavid Howells __kir; }) 5096433f6eSDavid Howells #endif 5196433f6eSDavid Howells 5296433f6eSDavid Howells #ifdef __alpha_cix__ 5396433f6eSDavid Howells # if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3 5496433f6eSDavid Howells # define __kernel_cttz(x) __builtin_ctzl(x) 5596433f6eSDavid Howells # define __kernel_ctlz(x) __builtin_clzl(x) 5696433f6eSDavid Howells # define __kernel_ctpop(x) __builtin_popcountl(x) 5796433f6eSDavid Howells # else 5896433f6eSDavid Howells # define __kernel_cttz(x) \ 5996433f6eSDavid Howells ({ unsigned long __kir; \ 6096433f6eSDavid Howells __asm__("cttz %1,%0" : "=r"(__kir) : "r"(x)); \ 6196433f6eSDavid Howells __kir; }) 6296433f6eSDavid Howells # define __kernel_ctlz(x) \ 6396433f6eSDavid Howells ({ unsigned long __kir; \ 6496433f6eSDavid Howells __asm__("ctlz %1,%0" : "=r"(__kir) : "r"(x)); \ 6596433f6eSDavid Howells __kir; }) 6696433f6eSDavid Howells # define __kernel_ctpop(x) \ 6796433f6eSDavid Howells ({ unsigned long __kir; \ 6896433f6eSDavid Howells __asm__("ctpop %1,%0" : "=r"(__kir) : "r"(x)); \ 6996433f6eSDavid Howells __kir; }) 7096433f6eSDavid Howells # endif 7196433f6eSDavid Howells #else 7296433f6eSDavid Howells # define __kernel_cttz(x) \ 7396433f6eSDavid Howells ({ unsigned long __kir; \ 7496433f6eSDavid Howells __asm__(".arch ev67; cttz %1,%0" : "=r"(__kir) : "r"(x)); \ 7596433f6eSDavid Howells __kir; }) 7696433f6eSDavid Howells # define __kernel_ctlz(x) \ 7796433f6eSDavid Howells ({ unsigned long __kir; \ 7896433f6eSDavid Howells __asm__(".arch ev67; ctlz %1,%0" : "=r"(__kir) : "r"(x)); \ 7996433f6eSDavid Howells __kir; }) 8096433f6eSDavid Howells # define __kernel_ctpop(x) \ 8196433f6eSDavid Howells ({ unsigned long __kir; \ 8296433f6eSDavid Howells __asm__(".arch ev67; ctpop %1,%0" : "=r"(__kir) : "r"(x)); \ 8396433f6eSDavid Howells __kir; }) 8496433f6eSDavid Howells #endif 8596433f6eSDavid Howells 8696433f6eSDavid Howells 8796433f6eSDavid Howells /* 8896433f6eSDavid Howells * Beginning with EGCS 1.1, GCC defines __alpha_bwx__ when the BWX 8996433f6eSDavid Howells * extension is enabled. Previous versions did not define anything 9096433f6eSDavid Howells * we could test during compilation -- too bad, so sad. 9196433f6eSDavid Howells */ 9296433f6eSDavid Howells 9396433f6eSDavid Howells #if defined(__alpha_bwx__) 9496433f6eSDavid Howells #define __kernel_ldbu(mem) (mem) 9596433f6eSDavid Howells #define __kernel_ldwu(mem) (mem) 9696433f6eSDavid Howells #define __kernel_stb(val,mem) ((mem) = (val)) 9796433f6eSDavid Howells #define __kernel_stw(val,mem) ((mem) = (val)) 9896433f6eSDavid Howells #else 9996433f6eSDavid Howells #define __kernel_ldbu(mem) \ 10096433f6eSDavid Howells ({ unsigned char __kir; \ 10196433f6eSDavid Howells __asm__(".arch ev56; \ 10296433f6eSDavid Howells ldbu %0,%1" : "=r"(__kir) : "m"(mem)); \ 10396433f6eSDavid Howells __kir; }) 10496433f6eSDavid Howells #define __kernel_ldwu(mem) \ 10596433f6eSDavid Howells ({ unsigned short __kir; \ 10696433f6eSDavid Howells __asm__(".arch ev56; \ 10796433f6eSDavid Howells ldwu %0,%1" : "=r"(__kir) : "m"(mem)); \ 10896433f6eSDavid Howells __kir; }) 10996433f6eSDavid Howells #define __kernel_stb(val,mem) \ 11096433f6eSDavid Howells __asm__(".arch ev56; \ 11196433f6eSDavid Howells stb %1,%0" : "=m"(mem) : "r"(val)) 11296433f6eSDavid Howells #define __kernel_stw(val,mem) \ 11396433f6eSDavid Howells __asm__(".arch ev56; \ 11496433f6eSDavid Howells stw %1,%0" : "=m"(mem) : "r"(val)) 11596433f6eSDavid Howells #endif 11696433f6eSDavid Howells 11796433f6eSDavid Howells 11896433f6eSDavid Howells #endif /* _UAPI__ALPHA_COMPILER_H */ 119