Skip to content
Snippets Groups Projects
Commit 435a8a48 authored by Lyndon Brown's avatar Lyndon Brown
Browse files

cpu: remove build-time influence on feature test macros

the `vlc_CPU_SSE2()` type macros are provided for run-time feature
detection. built-time target settings should have no influence on these,
except perhaps in rare cases where we happen to know that a feature to
absolutely definitely be available and wish to force enable it in the
build for that platform.

as an example, windows 8+ requires SSE2 (apparently), and so if we only
want to support windows 8+ for our windows builds, then we could force
enable SSE2 via use of the `-msse2` compile flag.

in general though, i'm not aware that we ever do such a thing; i'm not sure
we ever will want to, and we can easily hack in a necessary change if we
did at such time; it risks mistakes being made; and as things were, this
was just adding a lot of unnecessary mess.

i find it questionable whether we even need to conditionally define the
`VLC_SSE` type defines, but at leats there's only a couple of those.

with the arm stuff:
 - note that while linux specific feature detection works, we are missing
   detection for other platforms.
 - `HAVE_FPU` is built-time dependant, which possibly needs replacing with
   runtime detection?
parent ad426355
No related branches found
No related tags found
No related merge requests found
......@@ -59,121 +59,41 @@ unsigned vlc_CPU_raw(void);
# define VLC_CPU_LZCNT 0x00200000
# define VLC_CPU_AVX512 0x00400000
# define vlc_CPU_SSE() ((vlc_CPU() & VLC_CPU_SSE) != 0)
# define vlc_CPU_SSE2() ((vlc_CPU() & VLC_CPU_SSE2) != 0)
# define vlc_CPU_SSE3() ((vlc_CPU() & VLC_CPU_SSE3) != 0)
# define vlc_CPU_SSSE3() ((vlc_CPU() & VLC_CPU_SSSE3) != 0)
# define vlc_CPU_SSE4_1() ((vlc_CPU() & VLC_CPU_SSE4_1) != 0)
# define vlc_CPU_SSE4_2() ((vlc_CPU() & VLC_CPU_SSE4_2) != 0)
# define vlc_CPU_SSE4A() ((vlc_CPU() & VLC_CPU_SSE4A) != 0)
# define vlc_CPU_AVX() ((vlc_CPU() & VLC_CPU_AVX) != 0)
# define vlc_CPU_AVX2() ((vlc_CPU() & VLC_CPU_AVX2) != 0)
# define vlc_CPU_XOP() ((vlc_CPU() & VLC_CPU_XOP) != 0)
# define vlc_CPU_FMA3() ((vlc_CPU() & VLC_CPU_FMA3) != 0)
# define vlc_CPU_FMA4() ((vlc_CPU() & VLC_CPU_FMA4) != 0)
# define vlc_CPU_BMI1() ((vlc_CPU() & VLC_CPU_BMI1) != 0)
# define vlc_CPU_BMI2() ((vlc_CPU() & VLC_CPU_BMI2) != 0)
# define vlc_CPU_POPCNT() ((vlc_CPU() & VLC_CPU_POPCNT) != 0)
# define vlc_CPU_LZCNT() ((vlc_CPU() & VLC_CPU_LZCNT) != 0)
# define vlc_CPU_AVX512() ((vlc_CPU() & VLC_CPU_AVX512) != 0)
# if defined (__SSE__)
# define vlc_CPU_SSE() (1)
# define VLC_SSE
# else
# define vlc_CPU_SSE() ((vlc_CPU() & VLC_CPU_SSE) != 0)
# define VLC_SSE __attribute__ ((__target__ ("sse")))
# endif
# ifdef __SSE2__
# define vlc_CPU_SSE2() (1)
# else
# define vlc_CPU_SSE2() ((vlc_CPU() & VLC_CPU_SSE2) != 0)
# endif
# ifdef __SSE3__
# define vlc_CPU_SSE3() (1)
# else
# define vlc_CPU_SSE3() ((vlc_CPU() & VLC_CPU_SSE3) != 0)
# endif
# ifdef __SSSE3__
# define vlc_CPU_SSSE3() (1)
# else
# define vlc_CPU_SSSE3() ((vlc_CPU() & VLC_CPU_SSSE3) != 0)
# endif
# ifdef __SSE4_1__
# define vlc_CPU_SSE4_1() (1)
# else
# define vlc_CPU_SSE4_1() ((vlc_CPU() & VLC_CPU_SSE4_1) != 0)
# endif
# ifdef __SSE4_2__
# define vlc_CPU_SSE4_2() (1)
# else
# define vlc_CPU_SSE4_2() ((vlc_CPU() & VLC_CPU_SSE4_2) != 0)
# endif
# ifdef __SSE4A__
# define vlc_CPU_SSE4A() (1)
# else
# define vlc_CPU_SSE4A() ((vlc_CPU() & VLC_CPU_SSE4A) != 0)
# endif
# ifdef __AVX__
# define vlc_CPU_AVX() (1)
# define VLC_AVX
# else
# define vlc_CPU_AVX() ((vlc_CPU() & VLC_CPU_AVX) != 0)
# define VLC_AVX __attribute__ ((__target__ ("avx")))
# endif
# ifdef __AVX2__
# define vlc_CPU_AVX2() (1)
# else
# define vlc_CPU_AVX2() ((vlc_CPU() & VLC_CPU_AVX2) != 0)
# endif
# ifdef __XOP__
# define vlc_CPU_XOP() (1)
# else
# define vlc_CPU_XOP() ((vlc_CPU() & VLC_CPU_XOP) != 0)
# endif
# ifdef __FMA3__
# define vlc_CPU_FMA3() (1)
# else
# define vlc_CPU_FMA3() ((vlc_CPU() & VLC_CPU_FMA3) != 0)
# endif
# ifdef __FMA4__
# define vlc_CPU_FMA4() (1)
# else
# define vlc_CPU_FMA4() ((vlc_CPU() & VLC_CPU_FMA4) != 0)
# endif
# ifdef __BMI1__
# define vlc_CPU_BMI1() (1)
# else
# define vlc_CPU_BMI1() ((vlc_CPU() & VLC_CPU_BMI1) != 0)
# endif
# ifdef __BMI2__
# define vlc_CPU_BMI2() (1)
# else
# define vlc_CPU_BMI2() ((vlc_CPU() & VLC_CPU_BMI2) != 0)
# endif
# ifdef __POPCNT__
# define vlc_CPU_POPCNT() (1)
# else
# define vlc_CPU_POPCNT() ((vlc_CPU() & VLC_CPU_POPCNT) != 0)
# endif
# ifdef __LZCNT__
# define vlc_CPU_LZCNT() (1)
# else
# define vlc_CPU_LZCNT() ((vlc_CPU() & VLC_CPU_LZCNT) != 0)
# endif
# ifdef __AVX512__
# define vlc_CPU_AVX512() (1)
# else
# define vlc_CPU_AVX512() ((vlc_CPU() & VLC_CPU_AVX512) != 0)
# endif
# elif defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
# define HAVE_FPU 1
# define VLC_CPU_ALTIVEC 2
# ifdef ALTIVEC
# define vlc_CPU_ALTIVEC() (1)
# else
# define vlc_CPU_ALTIVEC() ((vlc_CPU() & VLC_CPU_ALTIVEC) != 0)
# endif
# define vlc_CPU_ALTIVEC() ((vlc_CPU() & VLC_CPU_ALTIVEC) != 0)
# elif defined (__arm__)
# if defined (__VFP_FP__) && !defined (__SOFTFP__)
......@@ -184,42 +104,16 @@ unsigned vlc_CPU_raw(void);
# define VLC_CPU_ARMv6 4
# define VLC_CPU_ARM_NEON 2
# if defined (__ARM_ARCH_7A__)
# define VLC_CPU_ARM_ARCH 7
# elif defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6T2__)
# define VLC_CPU_ARM_ARCH 6
# else
# define VLC_CPU_ARM_ARCH 4
# endif
# if (VLC_CPU_ARM_ARCH >= 6)
# define vlc_CPU_ARMv6() (1)
# else
# define vlc_CPU_ARMv6() ((vlc_CPU() & VLC_CPU_ARMv6) != 0)
# endif
# ifdef __ARM_NEON__
# define vlc_CPU_ARM_NEON() (1)
# else
# define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
# endif
# define vlc_CPU_ARMv6() ((vlc_CPU() & VLC_CPU_ARMv6) != 0)
# define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
# elif defined (__aarch64__)
# define HAVE_FPU 1
# define VLC_CPU_ARM_NEON 0x1
# define VLC_CPU_ARM_SVE 0x2
# ifdef __ARM_NEON
# define vlc_CPU_ARM_NEON() (1)
# else
# define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
# endif
# ifdef __ARM_FEATURE_SVE
# define vlc_CPU_ARM_SVE() (1)
# else
# define vlc_CPU_ARM_SVE() ((vlc_CPU() & VLC_CPU_ARM_SVE) != 0)
# endif
# define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
# define vlc_CPU_ARM_SVE() ((vlc_CPU() & VLC_CPU_ARM_SVE) != 0)
# elif defined (__sparc__)
# define HAVE_FPU 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment