Home | History | Annotate | Download | only in arm
      1 /*Copyright (c) 2013, Xiph.Org Foundation and contributors.
      2 
      3   All rights reserved.
      4 
      5   Redistribution and use in source and binary forms, with or without
      6    modification, are permitted provided that the following conditions are met:
      7 
      8     * Redistributions of source code must retain the above copyright notice,
      9        this list of conditions and the following disclaimer.
     10     * Redistributions in binary form must reproduce the above copyright notice,
     11        this list of conditions and the following disclaimer in the
     12        documentation and/or other materials provided with the distribution.
     13 
     14   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     15   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     18   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     19   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     20   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     21   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     22   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     23   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     24   POSSIBILITY OF SUCH DAMAGE.*/
     25 
     26 #ifndef KISS_FFT_ARMv4_H
     27 #define KISS_FFT_ARMv4_H
     28 
     29 #if !defined(KISS_FFT_GUTS_H)
     30 #error "This file should only be included from _kiss_fft_guts.h"
     31 #endif
     32 
     33 #ifdef FIXED_POINT
     34 
     35 #undef C_MUL
     36 #define C_MUL(m,a,b) \
     37     do{ \
     38        int br__; \
     39        int bi__; \
     40        int tt__; \
     41         __asm__ __volatile__( \
     42             "#C_MUL\n\t" \
     43             "ldrsh %[br], [%[bp], #0]\n\t" \
     44             "ldm %[ap], {r0,r1}\n\t" \
     45             "ldrsh %[bi], [%[bp], #2]\n\t" \
     46             "smull %[tt], %[mi], r1, %[br]\n\t" \
     47             "smlal %[tt], %[mi], r0, %[bi]\n\t" \
     48             "rsb %[bi], %[bi], #0\n\t" \
     49             "smull %[br], %[mr], r0, %[br]\n\t" \
     50             "mov %[tt], %[tt], lsr #15\n\t" \
     51             "smlal %[br], %[mr], r1, %[bi]\n\t" \
     52             "orr %[mi], %[tt], %[mi], lsl #17\n\t" \
     53             "mov %[br], %[br], lsr #15\n\t" \
     54             "orr %[mr], %[br], %[mr], lsl #17\n\t" \
     55             : [mr]"=r"((m).r), [mi]"=r"((m).i), \
     56               [br]"=&r"(br__), [bi]"=r"(bi__), [tt]"=r"(tt__) \
     57             : [ap]"r"(&(a)), [bp]"r"(&(b)) \
     58             : "r0", "r1" \
     59         ); \
     60     } \
     61     while(0)
     62 
     63 #undef C_MUL4
     64 #define C_MUL4(m,a,b) \
     65     do{ \
     66        int br__; \
     67        int bi__; \
     68        int tt__; \
     69         __asm__ __volatile__( \
     70             "#C_MUL4\n\t" \
     71             "ldrsh %[br], [%[bp], #0]\n\t" \
     72             "ldm %[ap], {r0,r1}\n\t" \
     73             "ldrsh %[bi], [%[bp], #2]\n\t" \
     74             "smull %[tt], %[mi], r1, %[br]\n\t" \
     75             "smlal %[tt], %[mi], r0, %[bi]\n\t" \
     76             "rsb %[bi], %[bi], #0\n\t" \
     77             "smull %[br], %[mr], r0, %[br]\n\t" \
     78             "mov %[tt], %[tt], lsr #17\n\t" \
     79             "smlal %[br], %[mr], r1, %[bi]\n\t" \
     80             "orr %[mi], %[tt], %[mi], lsl #15\n\t" \
     81             "mov %[br], %[br], lsr #17\n\t" \
     82             "orr %[mr], %[br], %[mr], lsl #15\n\t" \
     83             : [mr]"=r"((m).r), [mi]"=r"((m).i), \
     84               [br]"=&r"(br__), [bi]"=r"(bi__), [tt]"=r"(tt__) \
     85             : [ap]"r"(&(a)), [bp]"r"(&(b)) \
     86             : "r0", "r1" \
     87         ); \
     88     } \
     89     while(0)
     90 
     91 #undef C_MULC
     92 #define C_MULC(m,a,b) \
     93     do{ \
     94        int br__; \
     95        int bi__; \
     96        int tt__; \
     97         __asm__ __volatile__( \
     98             "#C_MULC\n\t" \
     99             "ldrsh %[br], [%[bp], #0]\n\t" \
    100             "ldm %[ap], {r0,r1}\n\t" \
    101             "ldrsh %[bi], [%[bp], #2]\n\t" \
    102             "smull %[tt], %[mr], r0, %[br]\n\t" \
    103             "smlal %[tt], %[mr], r1, %[bi]\n\t" \
    104             "rsb %[bi], %[bi], #0\n\t" \
    105             "smull %[br], %[mi], r1, %[br]\n\t" \
    106             "mov %[tt], %[tt], lsr #15\n\t" \
    107             "smlal %[br], %[mi], r0, %[bi]\n\t" \
    108             "orr %[mr], %[tt], %[mr], lsl #17\n\t" \
    109             "mov %[br], %[br], lsr #15\n\t" \
    110             "orr %[mi], %[br], %[mi], lsl #17\n\t" \
    111             : [mr]"=r"((m).r), [mi]"=r"((m).i), \
    112               [br]"=&r"(br__), [bi]"=r"(bi__), [tt]"=r"(tt__) \
    113             : [ap]"r"(&(a)), [bp]"r"(&(b)) \
    114             : "r0", "r1" \
    115         ); \
    116     } \
    117     while(0)
    118 
    119 #endif /* FIXED_POINT */
    120 
    121 #endif /* KISS_FFT_ARMv4_H */
    122