xref: /openbmc/linux/arch/arm/include/asm/neon.h (revision d2912cb1)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
273c132c1SArd Biesheuvel /*
373c132c1SArd Biesheuvel  * linux/arch/arm/include/asm/neon.h
473c132c1SArd Biesheuvel  *
573c132c1SArd Biesheuvel  * Copyright (C) 2013 Linaro Ltd <ard.biesheuvel@linaro.org>
673c132c1SArd Biesheuvel  */
773c132c1SArd Biesheuvel 
873c132c1SArd Biesheuvel #include <asm/hwcap.h>
973c132c1SArd Biesheuvel 
1073c132c1SArd Biesheuvel #define cpu_has_neon()		(!!(elf_hwcap & HWCAP_NEON))
1173c132c1SArd Biesheuvel 
1273c132c1SArd Biesheuvel #ifdef __ARM_NEON__
1373c132c1SArd Biesheuvel 
1473c132c1SArd Biesheuvel /*
1573c132c1SArd Biesheuvel  * If you are affected by the BUILD_BUG below, it probably means that you are
1673c132c1SArd Biesheuvel  * using NEON code /and/ calling the kernel_neon_begin() function from the same
1773c132c1SArd Biesheuvel  * compilation unit. To prevent issues that may arise from GCC reordering or
1873c132c1SArd Biesheuvel  * generating(1) NEON instructions outside of these begin/end functions, the
1973c132c1SArd Biesheuvel  * only supported way of using NEON code in the kernel is by isolating it in a
2073c132c1SArd Biesheuvel  * separate compilation unit, and calling it from another unit from inside a
2173c132c1SArd Biesheuvel  * kernel_neon_begin/kernel_neon_end pair.
2273c132c1SArd Biesheuvel  *
2373c132c1SArd Biesheuvel  * (1) Current GCC (4.7) might generate NEON instructions at O3 level if
2473c132c1SArd Biesheuvel  *     -mpfu=neon is set.
2573c132c1SArd Biesheuvel  */
2673c132c1SArd Biesheuvel 
2773c132c1SArd Biesheuvel #define kernel_neon_begin() \
2873c132c1SArd Biesheuvel 	BUILD_BUG_ON_MSG(1, "kernel_neon_begin() called from NEON code")
2973c132c1SArd Biesheuvel 
3073c132c1SArd Biesheuvel #else
3173c132c1SArd Biesheuvel void kernel_neon_begin(void);
3273c132c1SArd Biesheuvel #endif
3373c132c1SArd Biesheuvel void kernel_neon_end(void);
34