/****************************************************************************1* Assembly testing and benchmarking tool2* Copyright (c) 2015 Martin Storsjo3* Copyright (c) 2015 Janne Grunau4*5* This file is part of FFmpeg.6*7* FFmpeg is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12* FFmpeg is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.20*****************************************************************************/2122#include "libavutil/arm/asm.S"2324const register_init25.quad 0x21f86d66c8ca00ce26.quad 0x75b6ba21077c48ad27.quad 0xed56bb2dcb3c773628.quad 0x8bda43d3fd1a7e0629.quad 0xb64a9c9e5d31840830.quad 0xdf9a54b303f1d3a331.quad 0x4a75479abd64e09732.quad 0x249214109d5d1c8833endconst3435const error_message36.asciz "failed to preserve register"37endconst3839@ max number of args used by any asm function.40#define MAX_ARGS 154142#define ARG_STACK 4*(MAX_ARGS - 2)4344.macro clobbercheck variant45.equ pushed, 4*946function checkasm_checked_call_\variant, export=147push {r4-r11, lr}48.ifc \variant, vfp49vpush {d8-d15}50fmrx r4, FPSCR51push {r4}52.equ pushed, pushed + 16*4 + 453.endif5455movrel r12, register_init56.ifc \variant, vfp57vldm r12, {d8-d15}58.endif59ldm r12, {r4-r11}6061sub sp, sp, #ARG_STACK62.equ pos, 063.rept MAX_ARGS-264ldr r12, [sp, #ARG_STACK + pushed + 8 + pos]65str r12, [sp, #pos]66.equ pos, pos + 467.endr6869mov r12, r070mov r0, r271mov r1, r372ldrd r2, r3, [sp, #ARG_STACK + pushed]73blx r1274add sp, sp, #ARG_STACK7576push {r0, r1}77movrel r12, register_init78mov r3, #079.ifc \variant, vfp80.macro check_reg_vfp, dreg, inc=881ldrd r0, r1, [r12], #\inc82vmov r2, lr, \dreg83eor r0, r0, r284eor r1, r1, lr85orr r3, r3, r086orr r3, r3, r187.endm8889.irp n, 8, 9, 10, 11, 12, 13, 1490check_reg_vfp d\n91.endr92check_reg_vfp d15, -5693.purgem check_reg_vfp9495fmrx r0, FPSCR96ldr r1, [sp, #8]97eor r0, r0, r198@ Ignore changes in the topmost 5 bits99lsl r0, r0, #5100orr r3, r3, r0101.endif102103.macro check_reg reg1, reg2=104ldrd r0, r1, [r12], #8105eor r0, r0, \reg1106orrs r3, r3, r0107.ifnb \reg2108eor r1, r1, \reg2109orrs r3, r3, r1110.endif111.endm112check_reg r4, r5113check_reg r6, r7114@ r9 is a volatile register in the ios ABI115#ifdef __APPLE__116check_reg r8117#else118check_reg r8, r9119#endif120check_reg r10, r11121.purgem check_reg122123beq 0f124125movrel r0, error_message126blx X(checkasm_fail_func)1270:128pop {r0, r1}129.ifc \variant, vfp130pop {r2}131fmxr FPSCR, r2132vpop {d8-d15}133.endif134pop {r4-r11, pc}135endfunc136.endm137138#if HAVE_VFP || HAVE_NEON139clobbercheck vfp140#endif141clobbercheck novfp142143144