neontest.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #include <inttypes.h>
  23. #include <stdint.h>
  24. #include <stdlib.h>
  25. #include <stdarg.h>
  26. #include <string.h>
  27. #include "libavutil/bswap.h"
  28. #define storeneonregs(mem) \
  29. __asm__ volatile( \
  30. "vstm %0, {d8-d15}\n\t" \
  31. :: "r"(mem) : "memory")
  32. #define testneonclobbers(func, ctx, ...) \
  33. uint64_t neon[2][8]; \
  34. int ret; \
  35. storeneonregs(neon[0]); \
  36. ret = __real_ ## func(ctx, __VA_ARGS__); \
  37. storeneonregs(neon[1]); \
  38. if (memcmp(neon[0], neon[1], sizeof(neon[0]))) { \
  39. int i; \
  40. av_log(ctx, AV_LOG_ERROR, \
  41. "NEON REGS CLOBBERED IN %s!\n", #func); \
  42. for (i = 0; i < 8; i ++) \
  43. if (neon[0][i] != neon[1][i]) { \
  44. av_log(ctx, AV_LOG_ERROR, \
  45. "d%-2d = %016"PRIx64"\n", \
  46. 8 + i, av_bswap64(neon[0][i])); \
  47. av_log(ctx, AV_LOG_ERROR, \
  48. " -> %016"PRIx64"\n", \
  49. av_bswap64(neon[1][i])); \
  50. } \
  51. abort(); \
  52. } \
  53. return ret
  54. #define wrap(func) \
  55. int __real_ ## func; \
  56. int __wrap_ ## func; \
  57. int __wrap_ ## func