2
0

neontest.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * check NEON registers for clobbering
  3. * Copyright (c) 2008 Ramiro Polla <ramiro.polla@gmail.com>
  4. * Copyright (c) 2013 Martin Storsjo
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVUTIL_AARCH64_NEONTEST_H
  23. #define AVUTIL_AARCH64_NEONTEST_H
  24. #include <inttypes.h>
  25. #include <stdint.h>
  26. #include <stdlib.h>
  27. #include <stdarg.h>
  28. #include <string.h>
  29. #include "libavutil/bswap.h"
  30. #define storeneonregs(mem) \
  31. __asm__ volatile( \
  32. "stp d8, d9, [%0]\n\t" \
  33. "stp d10, d11, [%0, #16]\n\t" \
  34. "stp d12, d13, [%0, #32]\n\t" \
  35. "stp d14, d15, [%0, #48]\n\t" \
  36. :: "r"(mem) : "memory")
  37. #define testneonclobbers(func, ctx, ...) \
  38. uint64_t neon[2][8]; \
  39. int ret; \
  40. storeneonregs(neon[0]); \
  41. ret = __real_ ## func(ctx, __VA_ARGS__); \
  42. storeneonregs(neon[1]); \
  43. if (memcmp(neon[0], neon[1], sizeof(neon[0]))) { \
  44. int i; \
  45. av_log(ctx, AV_LOG_ERROR, \
  46. "NEON REGS CLOBBERED IN %s!\n", #func); \
  47. for (i = 0; i < 8; i ++) \
  48. if (neon[0][i] != neon[1][i]) { \
  49. av_log(ctx, AV_LOG_ERROR, \
  50. "d%-2d = %016"PRIx64"\n", \
  51. 8 + i, av_bswap64(neon[0][i])); \
  52. av_log(ctx, AV_LOG_ERROR, \
  53. " -> %016"PRIx64"\n", \
  54. av_bswap64(neon[1][i])); \
  55. } \
  56. abort(); \
  57. } \
  58. return ret
  59. #define wrap(func) \
  60. int __real_ ## func; \
  61. int __wrap_ ## func; \
  62. int __wrap_ ## func
  63. #endif /* AVUTIL_AARCH64_NEONTEST_H */