1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __BPF_COMPILER_H__ 3 #define __BPF_COMPILER_H__ 4 5 #define DO_PRAGMA_(X) _Pragma(#X) 6 7 #if __clang__ 8 #define __pragma_loop_unroll DO_PRAGMA_(clang loop unroll(enable)) 9 #else 10 /* In GCC -funroll-loops, which is enabled with -O2, should have the 11 same impact than the loop-unroll-enable pragma above. */ 12 #define __pragma_loop_unroll 13 #endif 14 15 #if __clang__ 16 #define __pragma_loop_unroll_count(N) DO_PRAGMA_(clang loop unroll_count(N)) 17 #else 18 #define __pragma_loop_unroll_count(N) DO_PRAGMA_(GCC unroll N) 19 #endif 20 21 #if __clang__ 22 #define __pragma_loop_unroll_full DO_PRAGMA_(clang loop unroll(full)) 23 #else 24 #define __pragma_loop_unroll_full DO_PRAGMA_(GCC unroll 65534) 25 #endif 26 27 #if __clang__ 28 #define __pragma_loop_no_unroll DO_PRAGMA_(clang loop unroll(disable)) 29 #else 30 #define __pragma_loop_no_unroll DO_PRAGMA_(GCC unroll 1) 31 #endif 32 33 #endif 34