commit: fefb82678bd82c02fd177e58170a7558df504b9c
parent 9b4962ff1c89d5c3babd45e14542dba97d4ae74f
Author: Michael Forney <mforney@mforney.org>
Date: Tue, 7 Sep 2021 13:35:38 -0700
ffmpeg: Probe for inline asm and intrinsics
Diffstat:
6 files changed, 60 insertions(+), 24 deletions(-)
diff --git a/pkg/ffmpeg/config.h b/pkg/ffmpeg/config.h
@@ -1,3 +1,14 @@
+/* probe */
+#ifndef HAVE_INLINE_ASM
+# define HAVE_INLINE_ASM 0
+#endif
+#ifndef HAVE_MMINTRIN_H
+# define HAVE_MMINTRIN_H 0
+#endif
+#ifndef PIC
+# define PIC 0
+#endif
+
#define ARCH_AARCH64 0
#define ARCH_ALPHA 0
#define ARCH_ARM 0
@@ -128,23 +139,23 @@
#define HAVE_POWER8_INLINE 0
#define HAVE_PPC4XX_INLINE 0
#define HAVE_VSX_INLINE 0
-#define HAVE_AESNI_INLINE 1
-#define HAVE_AMD3DNOW_INLINE 1
-#define HAVE_AMD3DNOWEXT_INLINE 1
-#define HAVE_AVX_INLINE 1
-#define HAVE_AVX2_INLINE 1
-#define HAVE_AVX512_INLINE 1
-#define HAVE_FMA3_INLINE 1
-#define HAVE_FMA4_INLINE 1
-#define HAVE_MMX_INLINE 1
-#define HAVE_MMXEXT_INLINE 1
-#define HAVE_SSE_INLINE 1
-#define HAVE_SSE2_INLINE 1
-#define HAVE_SSE3_INLINE 1
-#define HAVE_SSE4_INLINE 1
-#define HAVE_SSE42_INLINE 1
-#define HAVE_SSSE3_INLINE 1
-#define HAVE_XOP_INLINE 1
+#define HAVE_AESNI_INLINE HAVE_INLINE_ASM
+#define HAVE_AMD3DNOW_INLINE HAVE_INLINE_ASM
+#define HAVE_AMD3DNOWEXT_INLINE HAVE_INLINE_ASM
+#define HAVE_AVX_INLINE HAVE_INLINE_ASM
+#define HAVE_AVX2_INLINE HAVE_INLINE_ASM
+#define HAVE_AVX502_INLINE HAVE_INLINE_ASM
+#define HAVE_FMA3_INLINE HAVE_INLINE_ASM
+#define HAVE_FMA4_INLINE HAVE_INLINE_ASM
+#define HAVE_MMX_INLINE HAVE_INLINE_ASM
+#define HAVE_MMXEXT_INLINE HAVE_INLINE_ASM
+#define HAVE_SSE_INLINE HAVE_INLINE_ASM
+#define HAVE_SSE2_INLINE HAVE_INLINE_ASM
+#define HAVE_SSE3_INLINE HAVE_INLINE_ASM
+#define HAVE_SSE4_INLINE HAVE_INLINE_ASM
+#define HAVE_SSE42_INLINE HAVE_INLINE_ASM
+#define HAVE_SSSE3_INLINE HAVE_INLINE_ASM
+#define HAVE_XOP_INLINE HAVE_INLINE_ASM
#define HAVE_CPUNOP_INLINE 0
#define HAVE_I686_INLINE 0
#define HAVE_MIPSFPU_INLINE 0
@@ -171,13 +182,13 @@
#define HAVE_ATOMIC_CAS_PTR 0
#define HAVE_MACHINE_RW_BARRIER 0
#define HAVE_MEMORYBARRIER 0
-#define HAVE_MM_EMPTY 1
+#define HAVE_MM_EMPTY HAVE_MMINTRIN_H
#define HAVE_RDTSC 0
#define HAVE_SEM_TIMEDWAIT 1
#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1
#define HAVE_CABS 1
#define HAVE_CEXP 1
-#define HAVE_INLINE_ASM 1
+/* probe HAVE_INLINE_ASM */
#define HAVE_SYMVER 1
#define HAVE_X86ASM 1
#define HAVE_BIGENDIAN 0
@@ -324,8 +335,8 @@
#define HAVE_AS_OBJECT_ARCH 0
#define HAVE_ASM_MOD_Q 0
#define HAVE_BLOCKS_EXTENSION 0
-#define HAVE_EBP_AVAILABLE 1
-#define HAVE_EBX_AVAILABLE 1
+#define HAVE_EBP_AVAILABLE HAVE_INLINE_ASM
+#define HAVE_EBX_AVAILABLE HAVE_INLINE_ASM
#define HAVE_GNU_AS 0
#define HAVE_GNU_WINDRES 0
#define HAVE_IBM_ASM 0
diff --git a/pkg/ffmpeg/gen.lua b/pkg/ffmpeg/gen.lua
@@ -27,9 +27,15 @@ pkg.deps = {
'$gendir/headers',
}
-build('cat', '$outdir/config.h', {'$dir/config-head.h', '$dir/config.h', '$builddir/probe/PIC', '$dir/config-tail.h'})
-build('awk', '$outdir/config.asm', {'$dir/config.h', '$builddir/probe/PIC'}, {
- expr=[['{print "%define " substr($$0, length("#define ") + 1)}']],
+local probe = {
+ '$builddir/probe/PIC',
+ '$builddir/probe/HAVE_INLINE_ASM',
+ '$builddir/probe/HAVE_MMINTRIN_H',
+}
+
+build('cat', '$outdir/config.h', {'$dir/config-head.h', probe, '$dir/config.h', '$dir/config-tail.h'})
+build('sed', '$outdir/config.asm', {probe, '$dir/config.h'}, {
+ expr=[[-n -e 's,^# *,%,p']],
})
build('awk', '$outdir/config.texi', '$dir/config.h', {
expr=[['$$3 == "1" {gsub("_", "-", $$2); print "@set", tolower($$2), "yes"}']],
@@ -92,6 +98,10 @@ for line in iterlines('sources.txt', 1) do
end
end
end
+-- combination option in libavutil/x86/Makefile
+if options.HAVE_MMX_EXTERNAL then
+ sources.libavutil['libavutil/x86/emms.asm'] = true
+end
for lib, srcs in pairs(sources) do
sources[lib] = table.keys(srcs)
end
diff --git a/probe/HAVE_EMMINTRIN_H b/probe/HAVE_EMMINTRIN_H
@@ -0,0 +1,4 @@
+#include <emmintrin.h>
+int main(void) {
+ return 0;
+}
diff --git a/probe/HAVE_INLINE_ASM b/probe/HAVE_INLINE_ASM
@@ -0,0 +1,4 @@
+int main(void) {
+ __asm__("");
+ return 0;
+}
diff --git a/probe/HAVE_MMINTRIN_H b/probe/HAVE_MMINTRIN_H
@@ -0,0 +1,4 @@
+#include <mmintrin.h>
+int main(void) {
+ return 0;
+}
diff --git a/probe/gen.lua b/probe/gen.lua
@@ -2,7 +2,10 @@ local function probe(var)
build('probe', '$outdir/'..var, {'$dir/'..var, '|', '$basedir/scripts/probe.sh'}, {var=var})
end
+probe('HAVE_EMMINTRIN_H')
probe('HAVE_IMMINTRIN_H')
+probe('HAVE_INLINE_ASM')
+probe('HAVE_MMINTRIN_H')
probe('HAVE__MM_MOVEMASK_EPI8')
probe('HAVE__THREAD_LOCAL')
probe('HAVE___BUILTIN_ASSUME_ALIGNED')