xref: /linux/arch/arm/include/asm/neon.h (revision 73c132c15da504789b924871e2491479a18e4f6a)
1*73c132c1SArd Biesheuvel /*
2*73c132c1SArd Biesheuvel  * linux/arch/arm/include/asm/neon.h
3*73c132c1SArd Biesheuvel  *
4*73c132c1SArd Biesheuvel  * Copyright (C) 2013 Linaro Ltd <ard.biesheuvel@linaro.org>
5*73c132c1SArd Biesheuvel  *
6*73c132c1SArd Biesheuvel  * This program is free software; you can redistribute it and/or modify
7*73c132c1SArd Biesheuvel  * it under the terms of the GNU General Public License version 2 as
8*73c132c1SArd Biesheuvel  * published by the Free Software Foundation.
9*73c132c1SArd Biesheuvel  */
10*73c132c1SArd Biesheuvel 
11*73c132c1SArd Biesheuvel #include <asm/hwcap.h>
12*73c132c1SArd Biesheuvel 
13*73c132c1SArd Biesheuvel #define cpu_has_neon()		(!!(elf_hwcap & HWCAP_NEON))
14*73c132c1SArd Biesheuvel 
15*73c132c1SArd Biesheuvel #ifdef __ARM_NEON__
16*73c132c1SArd Biesheuvel 
17*73c132c1SArd Biesheuvel /*
18*73c132c1SArd Biesheuvel  * If you are affected by the BUILD_BUG below, it probably means that you are
19*73c132c1SArd Biesheuvel  * using NEON code /and/ calling the kernel_neon_begin() function from the same
20*73c132c1SArd Biesheuvel  * compilation unit. To prevent issues that may arise from GCC reordering or
21*73c132c1SArd Biesheuvel  * generating(1) NEON instructions outside of these begin/end functions, the
22*73c132c1SArd Biesheuvel  * only supported way of using NEON code in the kernel is by isolating it in a
23*73c132c1SArd Biesheuvel  * separate compilation unit, and calling it from another unit from inside a
24*73c132c1SArd Biesheuvel  * kernel_neon_begin/kernel_neon_end pair.
25*73c132c1SArd Biesheuvel  *
26*73c132c1SArd Biesheuvel  * (1) Current GCC (4.7) might generate NEON instructions at O3 level if
27*73c132c1SArd Biesheuvel  *     -mpfu=neon is set.
28*73c132c1SArd Biesheuvel  */
29*73c132c1SArd Biesheuvel 
30*73c132c1SArd Biesheuvel #define kernel_neon_begin() \
31*73c132c1SArd Biesheuvel 	BUILD_BUG_ON_MSG(1, "kernel_neon_begin() called from NEON code")
32*73c132c1SArd Biesheuvel 
33*73c132c1SArd Biesheuvel #else
34*73c132c1SArd Biesheuvel void kernel_neon_begin(void);
35*73c132c1SArd Biesheuvel #endif
36*73c132c1SArd Biesheuvel void kernel_neon_end(void);
37