[x264-devel] [PATCH 3/9] aarch64: add utility functions for asm

Janne Grunau janne-x264 at jannau.net
Sat Jul 19 20:57:49 CEST 2014


---
 common/aarch64/asm.S | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure            |  6 ++++
 2 files changed, 98 insertions(+)
 create mode 100644 common/aarch64/asm.S

diff --git a/common/aarch64/asm.S b/common/aarch64/asm.S
new file mode 100644
index 0000000..1c1012d
--- /dev/null
+++ b/common/aarch64/asm.S
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ * asm.S: AArch64 utility macros
+ *****************************************************************************
+ * Copyright (C) 2008-2014 x264 project
+ *
+ * Authors: Mans Rullgard <mans at mansr.com>
+ *          David Conrad <lessen42 at gmail.com>
+ *          Janne Grunau <janne-x264 at jannau.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing at x264.com.
+ *****************************************************************************/
+
+#include "config.h"
+
+#ifdef PREFIX
+#   define EXTERN_ASM _
+#else
+#   define EXTERN_ASM
+#endif
+
+#ifdef __ELF__
+#   define ELF
+#else
+#   define ELF  #
+#endif
+
+#if HAVE_AS_FUNC
+#   define FUNC
+#else
+#   define FUNC #
+#endif
+
+.macro  function name, export=0, align=2
+    .macro endfunc
+ELF     .size   \name, . - \name
+FUNC    .endfunc
+        .purgem endfunc
+    .endm
+        .text
+        .align          \align
+    .if \export
+        .global EXTERN_ASM\name
+ELF     .type   EXTERN_ASM\name, %function
+FUNC    .func   EXTERN_ASM\name
+EXTERN_ASM\name:
+    .else
+ELF     .type   \name, %function
+FUNC    .func   \name
+\name:
+    .endif
+.endm
+
+.macro  const   name, align=2
+    .macro endconst
+ELF     .size   \name, . - \name
+        .purgem endconst
+    .endm
+        .section        .rodata
+        .align          \align
+\name:
+.endm
+
+.macro  movrel rd, val
+#if defined(PIC) && defined(__APPLE__)
+        adrp            \rd, \val at PAGE
+        add             \rd, \rd, \val at PAGEOFF
+#elif defined(PIC)
+        adrp            \rd, \val
+        add             \rd, \rd, :lo12:\val
+#else
+        ldr             \rd, =\val
+#endif
+.endm
+
+#define GLUE(a, b) a ## b
+#define JOIN(a, b) GLUE(a, b)
+#define X(s) JOIN(EXTERN_ASM, s)
diff --git a/configure b/configure
index 2d61a86..fe0f044 100755
--- a/configure
+++ b/configure
@@ -780,6 +780,12 @@ if [ $asm = auto -a $ARCH = AARCH64 ] ; then
         echo "If you really want to run on such a CPU, configure with --disable-asm."
         exit 1
     fi
+    # check if the assembler supports '.func' (clang 3.5 does not)
+    if as_check ".func test\n.endfunc" ; then
+        define HAVE_AS_FUNC 1
+    else
+        define HAVE_AS_FUNC 0
+    fi
 fi
 
 [ $asm = no ] && AS=""
-- 
2.0.0



More information about the x264-devel mailing list