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