[opus] [PATCH 5/8] Arm64 assembly for Silk math.

Jonathan Lennox jonathan at vidyo.com
Wed Aug 5 11:17:27 PDT 2015


---
 silk/SigProc_FIX.h           |  4 +++
 silk/arm/SigProc_FIX_arm64.h | 46 ++++++++++++++++++++++++++++++
 silk/arm/macros_arm64.h      | 66 ++++++++++++++++++++++++++++++++++++++++++++
 silk/macros.h                |  4 +++
 silk_headers.mk              |  2 ++
 5 files changed, 122 insertions(+)
 create mode 100644 silk/arm/SigProc_FIX_arm64.h
 create mode 100644 silk/arm/macros_arm64.h

diff --git a/silk/SigProc_FIX.h b/silk/SigProc_FIX.h
index b632994..0a6969d 100644
--- a/silk/SigProc_FIX.h
+++ b/silk/SigProc_FIX.h
@@ -603,6 +603,10 @@ static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b)
 #include "arm/SigProc_FIX_armv5e.h"
 #endif
 
+#ifdef OPUS_ARM64_INLINE_ASM
+#include "arm/SigProc_FIX_arm64.h"
+#endif
+
 #if defined(MIPSr1_ASM)
 #include "mips/sigproc_fix_mipsr1.h"
 #endif
diff --git a/silk/arm/SigProc_FIX_arm64.h b/silk/arm/SigProc_FIX_arm64.h
new file mode 100644
index 0000000..faa5900
--- /dev/null
+++ b/silk/arm/SigProc_FIX_arm64.h
@@ -0,0 +1,46 @@
+/***********************************************************************
+Copyright (C) 2014 Vidyo
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+- Neither the name of Internet Society, IETF or IETF Trust, nor the
+names of specific contributors, may be used to endorse or promote
+products derived from this software without specific prior written
+permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#ifndef SILK_SIGPROC_FIX_ARM64_H
+#define SILK_SIGPROC_FIX_ARM64_H
+
+#undef silk_MLA
+static OPUS_INLINE opus_int32 silk_MLA_arm64(opus_int32 a, opus_int32 b,
+ opus_int32 c)
+{
+  opus_int32 res;
+  __asm__(
+      "#silk_MLA\n\t"
+      "madd %w0, %w1, %w2, %w3\n\t"
+      : "=&r"(res)
+      : "r"(b), "r"(c), "r"(a)
+  );
+  return res;
+}
+#define silk_MLA(a, b, c) (silk_MLA_arm64(a, b, c))
+
+#endif
diff --git a/silk/arm/macros_arm64.h b/silk/arm/macros_arm64.h
new file mode 100644
index 0000000..fe794de
--- /dev/null
+++ b/silk/arm/macros_arm64.h
@@ -0,0 +1,66 @@
+/***********************************************************************
+Copyright (C) 2014 Vidyo
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+- Neither the name of Internet Society, IETF or IETF Trust, nor the
+names of specific contributors, may be used to endorse or promote
+products derived from this software without specific prior written
+permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#ifndef SILK_MACROS_ARM64_H
+#define SILK_MACROS_ARM64_H
+
+/* (a32 * b32) >> 16 */
+#undef silk_SMULWW
+static OPUS_INLINE opus_int32 silk_SMULWW_arm64(opus_int32 a, opus_int32 b)
+{
+  opus_int64 rd;
+  __asm__(
+    "#silk_SMULWW\n\t"
+    "smull %x0, %w1, %w2\n\t"
+    : "=&r"(rd)
+    : "%r"(a), "r"(b)
+  );
+  rd >>= 16;
+  rd &= 0xFFFFFFFF;
+  return rd;
+}
+#define silk_SMULWW(a, b) (silk_SMULWW_arm64(a, b))
+
+#undef silk_SMLAWW
+static OPUS_INLINE opus_int32 silk_SMLAWW_arm64(opus_int32 a, opus_int32 b,
+ opus_int32 c)
+{
+  opus_int64 rd;
+  __asm__(
+    "#silk_SMLAWW\n\t"
+    "smull %x0, %w1, %w2\n\t"
+    : "=&r"(rd)
+    : "%r"(b), "r"(c)
+  );
+  rd >>= 16;
+  rd &= 0xFFFFFFFF;
+
+  return a + rd;
+}
+#define silk_SMLAWW(a, b, c) (silk_SMLAWW_arm64(a, b, c))
+
+#endif /* SILK_MACROS_ARM64_H */
diff --git a/silk/macros.h b/silk/macros.h
index bc30303..e7ab7f5 100644
--- a/silk/macros.h
+++ b/silk/macros.h
@@ -149,5 +149,9 @@ static OPUS_INLINE opus_int32 silk_CLZ32(opus_int32 in32)
 #include "arm/macros_armv5e.h"
 #endif
 
+#ifdef OPUS_ARM64_INLINE_ADM
+#include "arm/macros_arm64.h"
+#endif
+
 #endif /* SILK_MACROS_H */
 
diff --git a/silk_headers.mk b/silk_headers.mk
index 679ff8f..6676133 100644
--- a/silk_headers.mk
+++ b/silk_headers.mk
@@ -23,8 +23,10 @@ silk/SigProc_FIX.h \
 silk/x86/SigProc_FIX_sse.h \
 silk/arm/macros_armv4.h \
 silk/arm/macros_armv5e.h \
+silk/arm/macros_arm64.h \
 silk/arm/SigProc_FIX_armv4.h \
 silk/arm/SigProc_FIX_armv5e.h \
+silk/arm/SigProc_FIX_arm64.h \
 silk/fixed/main_FIX.h \
 silk/fixed/structs_FIX.h \
 silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h \
-- 
2.3.2 (Apple Git-55)



More information about the opus mailing list