]> git.sesse.net Git - x264/blobdiff - configure
aarch64: add utility functions for asm
[x264] / configure
index 7d56fd8a28dfcff1f21b6e40f38762a318f93e44..fe4a9c23c70ed9b89602b0acbe3253a1f5b7551e 100755 (executable)
--- a/configure
+++ b/configure
@@ -197,8 +197,9 @@ cpp_check() {
 
 as_check() {
     log_check "whether $AS supports $1"
-    echo "$1" > conftest.asm
-    if $AS conftest.asm $ASFLAGS $2 -o conftest.o >conftest.log 2>&1; then
+    echo "$1" > conftest$AS_EXT
+    as_cmd="$AS conftest$AS_EXT $ASFLAGS $2 -o conftest.o"
+    if $as_cmd >conftest.log 2>&1; then
         res=$?
         log_ok
     else
@@ -206,12 +207,12 @@ as_check() {
         log_fail
         log_msg "Failed commandline was:"
         log_msg "--------------------------------------------------"
-        log_msg "$AS conftest.asm $ASFLAGS $2 -o conftest.o"
+        log_msg "$as_cmd"
         cat conftest.log >> config.log
         log_msg "--------------------------------------------------"
         log_msg "Failed program was:"
         log_msg "--------------------------------------------------"
-        cat conftest.asm >> config.log
+        cat conftest$AS_EXT >> config.log
         log_msg "--------------------------------------------------"
     fi
     return $res
@@ -302,10 +303,13 @@ HAVE_GETOPT_LONG=1
 cross_prefix=""
 
 EXE=""
+AS_EXT=".S"
+NL="
+"
 
 # list of all preprocessor HAVE values we can define
 CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F SWSCALE \
-             LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH X86_INLINE_ASM"
+             LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH X86_INLINE_ASM AS_FUNC"
 
 # parse options
 
@@ -586,6 +590,7 @@ case $host_cpu in
     i*86)
         ARCH="X86"
         AS="yasm"
+        AS_EXT=".asm"
         ASFLAGS="$ASFLAGS -O2 -DARCH_X86_64=0 -I\$(SRCPATH)/common/x86/"
         if [ $compiler = GNU ]; then
             if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
@@ -626,6 +631,7 @@ case $host_cpu in
     x86_64)
         ARCH="X86_64"
         AS="yasm"
+        AS_EXT=".asm"
         ASFLAGS="$ASFLAGS -DARCH_X86_64=1 -I\$(SRCPATH)/common/x86/"
         [ $compiler = GNU ] && CFLAGS="-m64 $CFLAGS" && LDFLAGS="-m64 $LDFLAGS"
         if [ "$SYS" = MACOSX ]; then
@@ -649,6 +655,7 @@ case $host_cpu in
         if [ $asm = auto ] ; then
             define HAVE_ALTIVEC
             AS="${AS-${CC}}"
+            AS_EXT=".c"
             if [ $SYS = MACOSX ] ; then
                 CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
             else
@@ -677,6 +684,15 @@ case $host_cpu in
             AS="${AS-${CC}}"
         fi
         ;;
+    aarch64)
+        ARCH="AARCH64"
+        if [ "$SYS" = MACOSX ] ; then
+            AS="${AS-extras/gas-preprocessor.pl $CC}"
+            ASFLAGS="$ASFLAGS -DPREFIX"
+        else
+            AS="${AS-${CC}}"
+        fi
+        ;;
     s390|s390x)
         ARCH="S390"
         ;;
@@ -760,6 +776,24 @@ if [ $asm = auto -a $ARCH = ARM ] ; then
     fi
 fi
 
+if [ $asm = auto -a $ARCH = AARCH64 ] ; then
+    # set flags so neon is built by default
+    echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-arch)' || CFLAGS="$CFLAGS -arch arm64 -mfpu=neon"
+
+    if  cc_check '' '' '__asm__("cmeq v0.8h, v0.8h, #0");' ; then define HAVE_NEON
+        ASFLAGS="$ASFLAGS -c"
+    else
+        echo "no NEON support, try adding -mfpu=neon to CFLAGS"
+        echo "If you really want to run on such a CPU, configure with --disable-asm."
+        exit 1
+    fi
+fi
+
+if [ $asm = auto -a \( $ARCH = ARM -o $ARCH = AARCH64 \) ] ; then
+    # check if the assembler supports '.func' (clang 3.5 does not)
+    as_check ".func test${NL}.endfunc" && define HAVE_AS_FUNC 1
+fi
+
 [ $asm = no ] && AS=""
 [ "x$AS" = x ] && asm="no" || asm="yes"
 
@@ -1306,7 +1340,7 @@ cat conftest.log
 rm conftest.log
 
 [ "$SRCPATH" != "." ] && ln -sf ${SRCPATH}/Makefile ./Makefile
-mkdir -p common/{arm,ppc,x86} encoder extras filters/video input output tools
+mkdir -p common/{aarch64,arm,ppc,x86} encoder extras filters/video input output tools
 
 echo
 echo "You can run 'make' or 'make fprofiled' now."