Commit fdb3b3ac authored by Jonathan Lennox's avatar Jonathan Lennox Committed by Timothy B. Terriberry
Browse files

Add named constants for ARM architecture variants.


Signed-off-by: Timothy B. Terriberry's avatarTimothy B. Terriberry <tterribe@xiph.org>
parent 920ff718
...@@ -37,11 +37,12 @@ ...@@ -37,11 +37,12 @@
#include "cpu_support.h" #include "cpu_support.h"
#include "os_support.h" #include "os_support.h"
#include "opus_types.h" #include "opus_types.h"
#include "arch.h"
#define OPUS_CPU_ARM_V4 (1) #define OPUS_CPU_ARM_V4_FLAG (1<<OPUS_ARCH_ARM_V4)
#define OPUS_CPU_ARM_EDSP (1<<1) #define OPUS_CPU_ARM_EDSP_FLAG (1<<OPUS_ARCH_ARM_EDSP)
#define OPUS_CPU_ARM_MEDIA (1<<2) #define OPUS_CPU_ARM_MEDIA_FLAG (1<<OPUS_ARCH_ARM_MEDIA)
#define OPUS_CPU_ARM_NEON (1<<3) #define OPUS_CPU_ARM_NEON_FLAG (1<<OPUS_ARCH_ARM_NEON)
#if defined(_MSC_VER) #if defined(_MSC_VER)
/*For GetExceptionCode() and EXCEPTION_ILLEGAL_INSTRUCTION.*/ /*For GetExceptionCode() and EXCEPTION_ILLEGAL_INSTRUCTION.*/
...@@ -59,7 +60,7 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){ ...@@ -59,7 +60,7 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){
__try{ __try{
/*PLD [r13]*/ /*PLD [r13]*/
__emit(0xF5DDF000); __emit(0xF5DDF000);
flags|=OPUS_CPU_ARM_EDSP; flags|=OPUS_CPU_ARM_EDSP_FLAG;
} }
__except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){
/*Ignore exception.*/ /*Ignore exception.*/
...@@ -68,7 +69,7 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){ ...@@ -68,7 +69,7 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){
__try{ __try{
/*SHADD8 r3,r3,r3*/ /*SHADD8 r3,r3,r3*/
__emit(0xE6333F93); __emit(0xE6333F93);
flags|=OPUS_CPU_ARM_MEDIA; flags|=OPUS_CPU_ARM_MEDIA_FLAG;
} }
__except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){
/*Ignore exception.*/ /*Ignore exception.*/
...@@ -77,7 +78,7 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){ ...@@ -77,7 +78,7 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){
__try{ __try{
/*VORR q0,q0,q0*/ /*VORR q0,q0,q0*/
__emit(0xF2200150); __emit(0xF2200150);
flags|=OPUS_CPU_ARM_NEON; flags|=OPUS_CPU_ARM_NEON_FLAG;
} }
__except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){
/*Ignore exception.*/ /*Ignore exception.*/
...@@ -115,13 +116,13 @@ opus_uint32 opus_cpu_capabilities(void) ...@@ -115,13 +116,13 @@ opus_uint32 opus_cpu_capabilities(void)
# if defined(OPUS_ARM_MAY_HAVE_EDSP) # if defined(OPUS_ARM_MAY_HAVE_EDSP)
p = strstr(buf, " edsp"); p = strstr(buf, " edsp");
if(p != NULL && (p[5] == ' ' || p[5] == '\n')) if(p != NULL && (p[5] == ' ' || p[5] == '\n'))
flags |= OPUS_CPU_ARM_EDSP; flags |= OPUS_CPU_ARM_EDSP_FLAG;
# endif # endif
# if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) # if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
p = strstr(buf, " neon"); p = strstr(buf, " neon");
if(p != NULL && (p[5] == ' ' || p[5] == '\n')) if(p != NULL && (p[5] == ' ' || p[5] == '\n'))
flags |= OPUS_CPU_ARM_NEON; flags |= OPUS_CPU_ARM_NEON_FLAG;
# endif # endif
} }
# endif # endif
...@@ -134,7 +135,7 @@ opus_uint32 opus_cpu_capabilities(void) ...@@ -134,7 +135,7 @@ opus_uint32 opus_cpu_capabilities(void)
version = atoi(buf+17); version = atoi(buf+17);
if(version >= 6) if(version >= 6)
flags |= OPUS_CPU_ARM_MEDIA; flags |= OPUS_CPU_ARM_MEDIA_FLAG;
} }
# endif # endif
} }
...@@ -156,18 +157,26 @@ int opus_select_arch(void) ...@@ -156,18 +157,26 @@ int opus_select_arch(void)
opus_uint32 flags = opus_cpu_capabilities(); opus_uint32 flags = opus_cpu_capabilities();
int arch = 0; int arch = 0;
if(!(flags & OPUS_CPU_ARM_EDSP)) if(!(flags & OPUS_CPU_ARM_EDSP_FLAG)) {
/* Asserts ensure arch values are sequential */
celt_assert(arch == OPUS_ARCH_ARM_V4);
return arch; return arch;
}
arch++; arch++;
if(!(flags & OPUS_CPU_ARM_MEDIA)) if(!(flags & OPUS_CPU_ARM_MEDIA_FLAG)) {
celt_assert(arch == OPUS_ARCH_ARM_EDSP);
return arch; return arch;
}
arch++; arch++;
if(!(flags & OPUS_CPU_ARM_NEON)) if(!(flags & OPUS_CPU_ARM_NEON_FLAG)) {
celt_assert(arch == OPUS_ARCH_ARM_MEDIA);
return arch; return arch;
}
arch++; arch++;
celt_assert(arch == OPUS_ARCH_ARM_NEON);
return arch; return arch;
} }
......
...@@ -66,6 +66,12 @@ ...@@ -66,6 +66,12 @@
# if defined(OPUS_HAVE_RTCD) # if defined(OPUS_HAVE_RTCD)
int opus_select_arch(void); int opus_select_arch(void);
#define OPUS_ARCH_ARM_V4 (0)
#define OPUS_ARCH_ARM_EDSP (1)
#define OPUS_ARCH_ARM_MEDIA (2)
#define OPUS_ARCH_ARM_NEON (3)
# endif # endif
#endif #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment