You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.7KB

  1. /*
  2. * simple math operations
  3. * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #ifdef FRAC_BITS
  20. # define MULL(a, b) \
  21. ({ int lo, hi;\
  22. asm("smull %0, %1, %2, %3 \n\t"\
  23. "mov %0, %0, lsr %4\n\t"\
  24. "add %1, %0, %1, lsl %5\n\t"\
  25. : "=&r"(lo), "=&r"(hi)\
  26. : "r"(b), "r"(a), "i"(FRAC_BITS), "i"(32-FRAC_BITS));\
  27. hi; })
  28. #endif
  29. #define MULH(a, b) \
  30. ({ int lo, hi;\
  31. asm ("smull %0, %1, %2, %3" : "=&r"(lo), "=&r"(hi) : "r"(b), "r"(a));\
  32. hi; })
  33. #if defined(HAVE_ARMV5TE)
  34. /* signed 16x16 -> 32 multiply add accumulate */
  35. # define MAC16(rt, ra, rb) \
  36. asm ("smlabb %0, %2, %3, %0" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb));
  37. /* signed 16x16 -> 32 multiply */
  38. # define MUL16(ra, rb) \
  39. ({ int __rt; \
  40. asm ("smulbb %0, %1, %2" : "=r" (__rt) : "r" (ra), "r" (rb)); \
  41. __rt; })
  42. #endif