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.

146 lines
3.7KB

  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, align=3
  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. @ align the used stack space to 8 to preserve the stack alignment
  40. #define ARG_STACK_A (((ARG_STACK + pushed + 7) & ~7) - pushed)
  41. .macro clobbercheck variant
  42. .equ pushed, 4*9
  43. function checkasm_checked_call_\variant, export=1
  44. push {r4-r11, lr}
  45. .ifc \variant, vfp
  46. vpush {d8-d15}
  47. fmrx r4, FPSCR
  48. push {r4}
  49. .equ pushed, pushed + 16*4 + 4
  50. .endif
  51. movrel r12, register_init
  52. .ifc \variant, vfp
  53. vldm r12, {d8-d15}
  54. .endif
  55. ldm r12, {r4-r11}
  56. sub sp, sp, #ARG_STACK_A
  57. .equ pos, 0
  58. .rept MAX_ARGS-2
  59. ldr r12, [sp, #ARG_STACK_A + pushed + 8 + pos]
  60. str r12, [sp, #pos]
  61. .equ pos, pos + 4
  62. .endr
  63. mov r12, r0
  64. mov r0, r2
  65. mov r1, r3
  66. ldrd r2, r3, [sp, #ARG_STACK_A + pushed]
  67. blx r12
  68. add sp, sp, #ARG_STACK_A
  69. push {r0, r1}
  70. movrel r12, register_init
  71. mov r3, #0
  72. .ifc \variant, vfp
  73. .macro check_reg_vfp, dreg, inc=8
  74. ldrd r0, r1, [r12], #\inc
  75. vmov r2, lr, \dreg
  76. eor r0, r0, r2
  77. eor r1, r1, lr
  78. orr r3, r3, r0
  79. orr r3, r3, r1
  80. .endm
  81. .irp n, 8, 9, 10, 11, 12, 13, 14
  82. check_reg_vfp d\n
  83. .endr
  84. check_reg_vfp d15, -56
  85. .purgem check_reg_vfp
  86. fmrx r0, FPSCR
  87. ldr r1, [sp, #8]
  88. eor r0, r0, r1
  89. @ Ignore changes in the topmost 5 bits
  90. lsl r0, r0, #5
  91. orr r3, r3, r0
  92. .endif
  93. .macro check_reg reg1, reg2=
  94. ldrd r0, r1, [r12], #8
  95. eor r0, r0, \reg1
  96. orrs r3, r3, r0
  97. .ifnb \reg2
  98. eor r1, r1, \reg2
  99. orrs r3, r3, r1
  100. .endif
  101. .endm
  102. check_reg r4, r5
  103. check_reg r6, r7
  104. @ r9 is a volatile register in the ios ABI
  105. #ifdef __APPLE__
  106. check_reg r8
  107. #else
  108. check_reg r8, r9
  109. #endif
  110. check_reg r10, r11
  111. .purgem check_reg
  112. beq 0f
  113. movrel r0, error_message
  114. blx X(checkasm_fail_func)
  115. 0:
  116. pop {r0, r1}
  117. .ifc \variant, vfp
  118. pop {r2}
  119. fmxr FPSCR, r2
  120. vpop {d8-d15}
  121. .endif
  122. pop {r4-r11, pc}
  123. endfunc
  124. .endm
  125. #if HAVE_VFP || HAVE_NEON
  126. clobbercheck vfp
  127. #endif
  128. clobbercheck novfp