ex
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/external/speex/libspeex/fixed_arm5e.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | /* Copyright (C) 2003 Jean-Marc Valin */ |
| TMBOY | 47:9e361da97763 | 2 | /** |
| TMBOY | 47:9e361da97763 | 3 | @file fixed_arm5e.h |
| TMBOY | 47:9e361da97763 | 4 | @brief ARM-tuned fixed-point operations |
| TMBOY | 47:9e361da97763 | 5 | */ |
| TMBOY | 47:9e361da97763 | 6 | /* |
| TMBOY | 47:9e361da97763 | 7 | Redistribution and use in source and binary forms, with or without |
| TMBOY | 47:9e361da97763 | 8 | modification, are permitted provided that the following conditions |
| TMBOY | 47:9e361da97763 | 9 | are met: |
| TMBOY | 47:9e361da97763 | 10 | |
| TMBOY | 47:9e361da97763 | 11 | - Redistributions of source code must retain the above copyright |
| TMBOY | 47:9e361da97763 | 12 | notice, this list of conditions and the following disclaimer. |
| TMBOY | 47:9e361da97763 | 13 | |
| TMBOY | 47:9e361da97763 | 14 | - Redistributions in binary form must reproduce the above copyright |
| TMBOY | 47:9e361da97763 | 15 | notice, this list of conditions and the following disclaimer in the |
| TMBOY | 47:9e361da97763 | 16 | documentation and/or other materials provided with the distribution. |
| TMBOY | 47:9e361da97763 | 17 | |
| TMBOY | 47:9e361da97763 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its |
| TMBOY | 47:9e361da97763 | 19 | contributors may be used to endorse or promote products derived from |
| TMBOY | 47:9e361da97763 | 20 | this software without specific prior written permission. |
| TMBOY | 47:9e361da97763 | 21 | |
| TMBOY | 47:9e361da97763 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| TMBOY | 47:9e361da97763 | 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| TMBOY | 47:9e361da97763 | 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| TMBOY | 47:9e361da97763 | 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
| TMBOY | 47:9e361da97763 | 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| TMBOY | 47:9e361da97763 | 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| TMBOY | 47:9e361da97763 | 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| TMBOY | 47:9e361da97763 | 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| TMBOY | 47:9e361da97763 | 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| TMBOY | 47:9e361da97763 | 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| TMBOY | 47:9e361da97763 | 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| TMBOY | 47:9e361da97763 | 33 | */ |
| TMBOY | 47:9e361da97763 | 34 | |
| TMBOY | 47:9e361da97763 | 35 | #ifndef FIXED_ARM5E_H |
| TMBOY | 47:9e361da97763 | 36 | #define FIXED_ARM5E_H |
| TMBOY | 47:9e361da97763 | 37 | |
| TMBOY | 47:9e361da97763 | 38 | #undef MULT16_16 |
| TMBOY | 47:9e361da97763 | 39 | static inline spx_word32_t MULT16_16(spx_word16_t x, spx_word16_t y) { |
| TMBOY | 47:9e361da97763 | 40 | int res; |
| TMBOY | 47:9e361da97763 | 41 | asm ("smulbb %0,%1,%2;\n" |
| TMBOY | 47:9e361da97763 | 42 | : "=&r"(res) |
| TMBOY | 47:9e361da97763 | 43 | : "%r"(x),"r"(y)); |
| TMBOY | 47:9e361da97763 | 44 | return(res); |
| TMBOY | 47:9e361da97763 | 45 | } |
| TMBOY | 47:9e361da97763 | 46 | |
| TMBOY | 47:9e361da97763 | 47 | #undef MAC16_16 |
| TMBOY | 47:9e361da97763 | 48 | static inline spx_word32_t MAC16_16(spx_word32_t a, spx_word16_t x, spx_word32_t y) { |
| TMBOY | 47:9e361da97763 | 49 | int res; |
| TMBOY | 47:9e361da97763 | 50 | asm ("smlabb %0,%1,%2,%3;\n" |
| TMBOY | 47:9e361da97763 | 51 | : "=&r"(res) |
| TMBOY | 47:9e361da97763 | 52 | : "%r"(x),"r"(y),"r"(a)); |
| TMBOY | 47:9e361da97763 | 53 | return(res); |
| TMBOY | 47:9e361da97763 | 54 | } |
| TMBOY | 47:9e361da97763 | 55 | |
| TMBOY | 47:9e361da97763 | 56 | #undef MULT16_32_Q15 |
| TMBOY | 47:9e361da97763 | 57 | static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) { |
| TMBOY | 47:9e361da97763 | 58 | int res; |
| TMBOY | 47:9e361da97763 | 59 | asm ("smulwb %0,%1,%2;\n" |
| TMBOY | 47:9e361da97763 | 60 | : "=&r"(res) |
| TMBOY | 47:9e361da97763 | 61 | : "%r"(y<<1),"r"(x)); |
| TMBOY | 47:9e361da97763 | 62 | return(res); |
| TMBOY | 47:9e361da97763 | 63 | } |
| TMBOY | 47:9e361da97763 | 64 | |
| TMBOY | 47:9e361da97763 | 65 | #undef MAC16_32_Q15 |
| TMBOY | 47:9e361da97763 | 66 | static inline spx_word32_t MAC16_32_Q15(spx_word32_t a, spx_word16_t x, spx_word32_t y) { |
| TMBOY | 47:9e361da97763 | 67 | int res; |
| TMBOY | 47:9e361da97763 | 68 | asm ("smlawb %0,%1,%2,%3;\n" |
| TMBOY | 47:9e361da97763 | 69 | : "=&r"(res) |
| TMBOY | 47:9e361da97763 | 70 | : "%r"(y<<1),"r"(x),"r"(a)); |
| TMBOY | 47:9e361da97763 | 71 | return(res); |
| TMBOY | 47:9e361da97763 | 72 | } |
| TMBOY | 47:9e361da97763 | 73 | |
| TMBOY | 47:9e361da97763 | 74 | #undef MULT16_32_Q11 |
| TMBOY | 47:9e361da97763 | 75 | static inline spx_word32_t MULT16_32_Q11(spx_word16_t x, spx_word32_t y) { |
| TMBOY | 47:9e361da97763 | 76 | int res; |
| TMBOY | 47:9e361da97763 | 77 | asm ("smulwb %0,%1,%2;\n" |
| TMBOY | 47:9e361da97763 | 78 | : "=&r"(res) |
| TMBOY | 47:9e361da97763 | 79 | : "%r"(y<<5),"r"(x)); |
| TMBOY | 47:9e361da97763 | 80 | return(res); |
| TMBOY | 47:9e361da97763 | 81 | } |
| TMBOY | 47:9e361da97763 | 82 | |
| TMBOY | 47:9e361da97763 | 83 | #undef MAC16_32_Q11 |
| TMBOY | 47:9e361da97763 | 84 | static inline spx_word32_t MAC16_32_Q11(spx_word32_t a, spx_word16_t x, spx_word32_t y) { |
| TMBOY | 47:9e361da97763 | 85 | int res; |
| TMBOY | 47:9e361da97763 | 86 | asm ("smlawb %0,%1,%2,%3;\n" |
| TMBOY | 47:9e361da97763 | 87 | : "=&r"(res) |
| TMBOY | 47:9e361da97763 | 88 | : "%r"(y<<5),"r"(x),"r"(a)); |
| TMBOY | 47:9e361da97763 | 89 | return(res); |
| TMBOY | 47:9e361da97763 | 90 | } |
| TMBOY | 47:9e361da97763 | 91 | |
| TMBOY | 47:9e361da97763 | 92 | #undef DIV32_16 |
| TMBOY | 47:9e361da97763 | 93 | static inline short DIV32_16(int a, int b) |
| TMBOY | 47:9e361da97763 | 94 | { |
| TMBOY | 47:9e361da97763 | 95 | int res=0; |
| TMBOY | 47:9e361da97763 | 96 | int dead1, dead2, dead3, dead4, dead5; |
| TMBOY | 47:9e361da97763 | 97 | __asm__ __volatile__ ( |
| TMBOY | 47:9e361da97763 | 98 | "\teor %5, %0, %1\n" |
| TMBOY | 47:9e361da97763 | 99 | "\tmovs %4, %0\n" |
| TMBOY | 47:9e361da97763 | 100 | "\trsbmi %0, %0, #0 \n" |
| TMBOY | 47:9e361da97763 | 101 | "\tmovs %4, %1\n" |
| TMBOY | 47:9e361da97763 | 102 | "\trsbmi %1, %1, #0 \n" |
| TMBOY | 47:9e361da97763 | 103 | "\tmov %4, #1\n" |
| TMBOY | 47:9e361da97763 | 104 | |
| TMBOY | 47:9e361da97763 | 105 | "\tsubs %3, %0, %1, asl #14 \n" |
| TMBOY | 47:9e361da97763 | 106 | "\torrpl %2, %2, %4, asl #14 \n" |
| TMBOY | 47:9e361da97763 | 107 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 108 | |
| TMBOY | 47:9e361da97763 | 109 | "\tsubs %3, %0, %1, asl #13 \n" |
| TMBOY | 47:9e361da97763 | 110 | "\torrpl %2, %2, %4, asl #13 \n" |
| TMBOY | 47:9e361da97763 | 111 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 112 | |
| TMBOY | 47:9e361da97763 | 113 | "\tsubs %3, %0, %1, asl #12 \n" |
| TMBOY | 47:9e361da97763 | 114 | "\torrpl %2, %2, %4, asl #12 \n" |
| TMBOY | 47:9e361da97763 | 115 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 116 | |
| TMBOY | 47:9e361da97763 | 117 | "\tsubs %3, %0, %1, asl #11 \n" |
| TMBOY | 47:9e361da97763 | 118 | "\torrpl %2, %2, %4, asl #11 \n" |
| TMBOY | 47:9e361da97763 | 119 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 120 | |
| TMBOY | 47:9e361da97763 | 121 | "\tsubs %3, %0, %1, asl #10 \n" |
| TMBOY | 47:9e361da97763 | 122 | "\torrpl %2, %2, %4, asl #10 \n" |
| TMBOY | 47:9e361da97763 | 123 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 124 | |
| TMBOY | 47:9e361da97763 | 125 | "\tsubs %3, %0, %1, asl #9 \n" |
| TMBOY | 47:9e361da97763 | 126 | "\torrpl %2, %2, %4, asl #9 \n" |
| TMBOY | 47:9e361da97763 | 127 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 128 | |
| TMBOY | 47:9e361da97763 | 129 | "\tsubs %3, %0, %1, asl #8 \n" |
| TMBOY | 47:9e361da97763 | 130 | "\torrpl %2, %2, %4, asl #8 \n" |
| TMBOY | 47:9e361da97763 | 131 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 132 | |
| TMBOY | 47:9e361da97763 | 133 | "\tsubs %3, %0, %1, asl #7 \n" |
| TMBOY | 47:9e361da97763 | 134 | "\torrpl %2, %2, %4, asl #7 \n" |
| TMBOY | 47:9e361da97763 | 135 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 136 | |
| TMBOY | 47:9e361da97763 | 137 | "\tsubs %3, %0, %1, asl #6 \n" |
| TMBOY | 47:9e361da97763 | 138 | "\torrpl %2, %2, %4, asl #6 \n" |
| TMBOY | 47:9e361da97763 | 139 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 140 | |
| TMBOY | 47:9e361da97763 | 141 | "\tsubs %3, %0, %1, asl #5 \n" |
| TMBOY | 47:9e361da97763 | 142 | "\torrpl %2, %2, %4, asl #5 \n" |
| TMBOY | 47:9e361da97763 | 143 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 144 | |
| TMBOY | 47:9e361da97763 | 145 | "\tsubs %3, %0, %1, asl #4 \n" |
| TMBOY | 47:9e361da97763 | 146 | "\torrpl %2, %2, %4, asl #4 \n" |
| TMBOY | 47:9e361da97763 | 147 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 148 | |
| TMBOY | 47:9e361da97763 | 149 | "\tsubs %3, %0, %1, asl #3 \n" |
| TMBOY | 47:9e361da97763 | 150 | "\torrpl %2, %2, %4, asl #3 \n" |
| TMBOY | 47:9e361da97763 | 151 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 152 | |
| TMBOY | 47:9e361da97763 | 153 | "\tsubs %3, %0, %1, asl #2 \n" |
| TMBOY | 47:9e361da97763 | 154 | "\torrpl %2, %2, %4, asl #2 \n" |
| TMBOY | 47:9e361da97763 | 155 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 156 | |
| TMBOY | 47:9e361da97763 | 157 | "\tsubs %3, %0, %1, asl #1 \n" |
| TMBOY | 47:9e361da97763 | 158 | "\torrpl %2, %2, %4, asl #1 \n" |
| TMBOY | 47:9e361da97763 | 159 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 160 | |
| TMBOY | 47:9e361da97763 | 161 | "\tsubs %3, %0, %1 \n" |
| TMBOY | 47:9e361da97763 | 162 | "\torrpl %2, %2, %4 \n" |
| TMBOY | 47:9e361da97763 | 163 | "\tmovpl %0, %3 \n" |
| TMBOY | 47:9e361da97763 | 164 | |
| TMBOY | 47:9e361da97763 | 165 | "\tmovs %5, %5, lsr #31 \n" |
| TMBOY | 47:9e361da97763 | 166 | "\trsbne %2, %2, #0 \n" |
| TMBOY | 47:9e361da97763 | 167 | : "=r" (dead1), "=r" (dead2), "=r" (res), |
| TMBOY | 47:9e361da97763 | 168 | "=r" (dead3), "=r" (dead4), "=r" (dead5) |
| TMBOY | 47:9e361da97763 | 169 | : "0" (a), "1" (b), "2" (res) |
| TMBOY | 47:9e361da97763 | 170 | : "memory", "cc" |
| TMBOY | 47:9e361da97763 | 171 | ); |
| TMBOY | 47:9e361da97763 | 172 | return res; |
| TMBOY | 47:9e361da97763 | 173 | } |
| TMBOY | 47:9e361da97763 | 174 | |
| TMBOY | 47:9e361da97763 | 175 | |
| TMBOY | 47:9e361da97763 | 176 | |
| TMBOY | 47:9e361da97763 | 177 | |
| TMBOY | 47:9e361da97763 | 178 | #endif |
