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.

143 lines
3.5KB

  1. /****************************************************************************
  2. * Assembly testing and benchmarking tool
  3. * Copyright (c) 2015 Martin Storsjo
  4. * Copyright (c) 2015 Janne Grunau
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (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
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
  21. *****************************************************************************/
  22. #include "libavutil/arm/asm.S"
  23. const register_init
  24. .quad 0x21f86d66c8ca00ce
  25. .quad 0x75b6ba21077c48ad
  26. .quad 0xed56bb2dcb3c7736
  27. .quad 0x8bda43d3fd1a7e06
  28. .quad 0xb64a9c9e5d318408
  29. .quad 0xdf9a54b303f1d3a3
  30. .quad 0x4a75479abd64e097
  31. .quad 0x249214109d5d1c88
  32. endconst
  33. const error_message
  34. .asciz "failed to preserve register"
  35. endconst
  36. @ max number of args used by any asm function.
  37. #define MAX_ARGS 15
  38. #define ARG_STACK 4*(MAX_ARGS - 2)
  39. .macro clobbercheck variant
  40. .equ pushed, 4*9
  41. function checkasm_checked_call_\variant, export=1
  42. push {r4-r11, lr}
  43. .ifc \variant, vfp
  44. vpush {d8-d15}
  45. fmrx r4, FPSCR
  46. push {r4}
  47. .equ pushed, pushed + 16*4 + 4
  48. .endif
  49. movrel r12, register_init
  50. .ifc \variant, vfp
  51. vldm r12, {d8-d15}
  52. .endif
  53. ldm r12, {r4-r11}
  54. sub sp, sp, #ARG_STACK
  55. .equ pos, 0
  56. .rept MAX_ARGS-2
  57. ldr r12, [sp, #ARG_STACK + pushed + 8 + pos]
  58. str r12, [sp, #pos]
  59. .equ pos, pos + 4
  60. .endr
  61. mov r12, r0
  62. mov r0, r2
  63. mov r1, r3
  64. ldrd r2, r3, [sp, #ARG_STACK + pushed]
  65. blx r12
  66. add sp, sp, #ARG_STACK
  67. push {r0, r1}
  68. movrel r12, register_init
  69. mov r3, #0
  70. .ifc \variant, vfp
  71. .macro check_reg_vfp, dreg, inc=8
  72. ldrd r0, r1, [r12], #\inc
  73. vmov r2, lr, \dreg
  74. eor r0, r0, r2
  75. eor r1, r1, lr
  76. orr r3, r3, r0
  77. orr r3, r3, r1
  78. .endm
  79. .irp n, 8, 9, 10, 11, 12, 13, 14
  80. check_reg_vfp d\n
  81. .endr
  82. check_reg_vfp d15, -56
  83. .purgem check_reg_vfp
  84. fmrx r0, FPSCR
  85. ldr r1, [sp, #8]
  86. eor r0, r0, r1
  87. @ Ignore changes in the topmost 5 bits
  88. lsl r0, r0, #5
  89. orr r3, r3, r0
  90. .endif
  91. .macro check_reg reg1, reg2=
  92. ldrd r0, r1, [r12], #8
  93. eor r0, r0, \reg1
  94. orrs r3, r3, r0
  95. .ifnb \reg2
  96. eor r1, r1, \reg2
  97. orrs r3, r3, r1
  98. .endif
  99. .endm
  100. check_reg r4, r5
  101. check_reg r6, r7
  102. @ r9 is a volatile register in the ios ABI
  103. #ifdef __APPLE__
  104. check_reg r8
  105. #else
  106. check_reg r8, r9
  107. #endif
  108. check_reg r10, r11
  109. .purgem check_reg
  110. beq 0f
  111. movrel r0, error_message
  112. blx X(checkasm_fail_func)
  113. 0:
  114. pop {r0, r1}
  115. .ifc \variant, vfp
  116. pop {r2}
  117. fmxr FPSCR, r2
  118. vpop {d8-d15}
  119. .endif
  120. pop {r4-r11, pc}
  121. endfunc
  122. .endm
  123. #if HAVE_VFP || HAVE_NEON
  124. clobbercheck vfp
  125. #endif
  126. clobbercheck novfp