Skip to content

Commit 458a592

Browse files
author
Kevin Ahrendt
authored
verify xtensa processor for assembly functions (#14)
1 parent 488d1e0 commit 458a592

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/mp3_decoder.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
#include <stdlib.h>
44
#include <string.h>
5+
#ifdef __XTENSA__
56
#include <xtensa/config/core-isa.h>
7+
#else
8+
#include <cmath>
9+
#endif
610

711
namespace esp_audio_libs {
812
namespace helix_decoder {
@@ -50,6 +54,7 @@ typedef long long Word64;
5054
static __inline Word64 MADD64(Word64 sum64, int x, int y) { return (sum64 + ((long long) x * y)); }
5155

5256
static __inline int MULSHIFT32(int x, int y) {
57+
#ifdef __XTENSA__
5358
/* important rules for smull RdLo, RdHi, Rm, Rs:
5459
* RdHi and Rm can't be the same register
5560
* RdLo and Rm can't be the same register
@@ -63,12 +68,19 @@ static __inline int MULSHIFT32(int x, int y) {
6368
int ret;
6469
asm volatile("mulsh %0, %1, %2" : "=r"(ret) : "r"(x), "r"(y));
6570
return ret;
71+
#else
72+
return ((uint64_t) x * (uint64_t) y >> 32);
73+
#endif
6674
}
6775

6876
static __inline int FASTABS(int x) {
77+
#ifdef __XTENSA__
6978
int ret;
7079
asm volatile("abs %0, %1" : "=r"(ret) : "r"(x));
7180
return ret;
81+
#else
82+
return std::abs(x);
83+
#endif
7284
}
7385

7486
static __inline Word64 SAR64(Word64 x, int n) { return x >> n; }

0 commit comments

Comments
 (0)