kiss_fft_armv4.h 4.4 KB

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