macros_mipsr1.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /***********************************************************************
  2. Copyright (c) 2006-2011, Skype Limited. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions
  5. are met:
  6. - Redistributions of source code must retain the above copyright notice,
  7. this list of conditions and the following disclaimer.
  8. - Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. - Neither the name of Internet Society, IETF or IETF Trust, nor the
  12. names of specific contributors, may be used to endorse or promote
  13. products derived from this software without specific prior written
  14. permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  19. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. POSSIBILITY OF SUCH DAMAGE.
  26. ***********************************************************************/
  27. #ifndef __SILK_MACROS_MIPSR1_H__
  28. #define __SILK_MACROS_MIPSR1_H__
  29. #define mips_clz(x) __builtin_clz(x)
  30. #undef silk_SMULWB
  31. static inline int silk_SMULWB(int a, int b)
  32. {
  33. long long ac;
  34. int c;
  35. ac = __builtin_mips_mult(a, (opus_int32)(opus_int16)b);
  36. c = __builtin_mips_extr_w(ac, 16);
  37. return c;
  38. }
  39. #undef silk_SMLAWB
  40. #define silk_SMLAWB(a32, b32, c32) ((a32) + silk_SMULWB(b32, c32))
  41. #undef silk_SMULWW
  42. static inline int silk_SMULWW(int a, int b)
  43. {
  44. long long ac;
  45. int c;
  46. ac = __builtin_mips_mult(a, b);
  47. c = __builtin_mips_extr_w(ac, 16);
  48. return c;
  49. }
  50. #undef silk_SMLAWW
  51. static inline int silk_SMLAWW(int a, int b, int c)
  52. {
  53. long long ac;
  54. int res;
  55. ac = __builtin_mips_mult(b, c);
  56. res = __builtin_mips_extr_w(ac, 16);
  57. res += a;
  58. return res;
  59. }
  60. #define OVERRIDE_silk_CLZ16
  61. static inline opus_int32 silk_CLZ16(opus_int16 in16)
  62. {
  63. int re32;
  64. opus_int32 in32 = (opus_int32 )in16;
  65. re32 = mips_clz(in32);
  66. re32-=16;
  67. return re32;
  68. }
  69. #define OVERRIDE_silk_CLZ32
  70. static inline opus_int32 silk_CLZ32(opus_int32 in32)
  71. {
  72. int re32;
  73. re32 = mips_clz(in32);
  74. return re32;
  75. }
  76. #endif /* __SILK_MACROS_MIPSR1_H__ */