[vlc-devel] [PATCH] aarch64: Check for the .arch_extension directive

Martin Storsjö martin at martin.st
Thu Dec 20 23:12:35 CET 2018


Clang doesn't support this directive for aarch64 at the moment.

If this directive isn't supported, don't add the extra -march
attributes when detecting tool support for simd/sve. This allows
compiling with either of them if they are enabled by default in
the toolchain, even if .arch_extension isn't available.
---
 configure.ac                                   | 27 ++++++++++++++++++++++++--
 modules/video_filter/Makefile.am               |  3 +++
 modules/video_filter/deinterlace/merge_arm64.S |  2 ++
 modules/video_filter/deinterlace/merge_sve.S   |  2 ++
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 19dd4c3..e98a710 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1478,6 +1478,20 @@ AC_ARG_ENABLE([neon],
       ;;
   esac
 ])
+AS_IF([test "${host_cpu}" = "aarch64"], [
+  # Check if .arch_extension is usable for enabling features
+  AC_CACHE_CHECK([if $CCAS supports .arch_extension], [ac_cv_arch_extension], [
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM(,[[
+volatile(".arch_extension simd");
+]])
+    ], [
+      ac_cv_arch_extension="yes"
+    ], [
+      ac_cv_arch_extension="no"
+    ])
+  ])
+])
 AS_IF([test "${enable_neon}" != "no"], [
   VLC_SAVE_FLAGS
   AC_CACHE_CHECK([if $CCAS groks ARM NEON assembly], [ac_cv_arm_neon], [
@@ -1493,7 +1507,11 @@ asm volatile("vqmovun.s64 d0, q1":::"d0");
         ac_cv_arm_neon="no"
       ])
     ], [
-      CFLAGS="${CFLAGS} -march=armv8-a+simd"
+      AS_IF([test "${ac_cv_arch_extension}" = "yes"], [
+        # Only enable more features via -march for the test, if we can do the
+        # same via .arch_extension.
+        CFLAGS="${CFLAGS} -march=armv8-a+simd"
+      ])
       AC_COMPILE_IFELSE([
         AC_LANG_PROGRAM(,[[
 asm volatile("uhadd v0.8b, v0.8b, v1.8b":::"v0");
@@ -1509,6 +1527,7 @@ asm volatile("uhadd v0.8b, v0.8b, v1.8b":::"v0");
 ])
 AM_CONDITIONAL([HAVE_NEON], [test "${ac_cv_arm_neon}" = "32"])
 AM_CONDITIONAL([HAVE_ARM64], [test "${ac_cv_arm_neon}" = "64"])
+AM_CONDITIONAL([HAVE_ARCH_EXTENSION], [test "${ac_cv_arch_extension}" = "yes"])
 
 AC_ARG_ENABLE([sve],
   AS_HELP_STRING([--disable-sve],
@@ -1517,7 +1536,11 @@ AC_ARG_ENABLE([sve],
 ])
 AS_IF([test "${enable_sve}" != "no"], [
   VLC_SAVE_FLAGS
-  CFLAGS="${CFLAGS} -march=armv8-a+sve"
+  AS_IF([test "${ac_cv_arch_extension}" = "yes"], [
+    # Only enable more features via -march for the test, if we can do the
+    # same via .arch_extension.
+    CFLAGS="${CFLAGS} -march=armv8-a+sve"
+  ])
   AC_CACHE_CHECK([if $CCAS groks ARM SVE assembly], [ac_cv_arm_sve], [
     AC_COMPILE_IFELSE([
       AC_LANG_PROGRAM(,[[
diff --git a/modules/video_filter/Makefile.am b/modules/video_filter/Makefile.am
index d3db0c0..4c86247 100644
--- a/modules/video_filter/Makefile.am
+++ b/modules/video_filter/Makefile.am
@@ -136,6 +136,9 @@ libdeinterlace_plugin_la_SOURCES = \
 	video_filter/deinterlace/algo_ivtc.c video_filter/deinterlace/algo_ivtc.h
 # inline ASM doesn't build with -O0
 libdeinterlace_plugin_la_CFLAGS = $(AM_CFLAGS) -O2
+if HAVE_ARCH_EXTENSION
+libdeinterlace_plugin_la_CFLAGS += -DHAVE_ARCH_EXTENSION
+endif
 if HAVE_NEON
 libdeinterlace_plugin_la_SOURCES += video_filter/deinterlace/merge_arm.S
 libdeinterlace_plugin_la_CFLAGS += -DCAN_COMPILE_ARM
diff --git a/modules/video_filter/deinterlace/merge_arm64.S b/modules/video_filter/deinterlace/merge_arm64.S
index 9efc8f7..08d15f1 100644
--- a/modules/video_filter/deinterlace/merge_arm64.S
+++ b/modules/video_filter/deinterlace/merge_arm64.S
@@ -21,7 +21,9 @@
 
 #include "../../arm_neon/asm.S"
 
+#ifdef HAVE_ARCH_EXTENSION
 	.arch_extension simd
+#endif
 	.text
 
 #define	DEST	x0
diff --git a/modules/video_filter/deinterlace/merge_sve.S b/modules/video_filter/deinterlace/merge_sve.S
index 9213d8b..43d8110 100644
--- a/modules/video_filter/deinterlace/merge_sve.S
+++ b/modules/video_filter/deinterlace/merge_sve.S
@@ -18,7 +18,9 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#ifdef HAVE_ARCH_EXTENSION
 	.arch_extension sve
+#endif
 
 	/* TODO: prefetch, unroll */
 
-- 
2.7.4



More information about the vlc-devel mailing list