/****************************************************************************1* checkasm-arm.S: assembly check tool2*****************************************************************************3* Copyright (C) 2015-2016 x264 project4*5* Authors: Martin Storsjo <[email protected]>6*7* This program 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* This program 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*21* This program is also available under a commercial proprietary license.22* For more information, contact us at [email protected].23*****************************************************************************/2425#include "../common/arm/asm.S"2627.section .rodata28.align 429register_init:30.quad 0x21f86d66c8ca00ce31.quad 0x75b6ba21077c48ad32.quad 0xed56bb2dcb3c773633.quad 0x8bda43d3fd1a7e0634.quad 0xb64a9c9e5d31840835.quad 0xdf9a54b303f1d3a336.quad 0x4a75479abd64e09737.quad 0x249214109d5d1c883839error_message:40.asciz "failed to preserve register"4142.text4344@ max number of args used by any x264 asm function.45#define MAX_ARGS 154647#define ARG_STACK 4*(MAX_ARGS - 2)4849.macro clobbercheck variant50.equ pushed, 4*1051function x264_checkasm_call_\variant52push {r4-r11, lr}53.ifc \variant, neon54vpush {q4-q7}55.equ pushed, pushed + 16*456.endif5758movrel r12, register_init59.ifc \variant, neon60vldm r12, {q4-q7}61.endif62ldm r12, {r4-r11}6364push {r1}6566sub sp, sp, #ARG_STACK67.equ pos, 068.rept MAX_ARGS-269ldr r12, [sp, #ARG_STACK + pushed + 8 + pos]70str r12, [sp, #pos]71.equ pos, pos + 472.endr7374mov r12, r075mov r0, r276mov r1, r377ldrd r2, r3, [sp, #ARG_STACK + pushed]78blx r1279add sp, sp, #ARG_STACK80pop {r2}8182push {r0, r1}83movrel r12, register_init84.ifc \variant, neon85vldm r12, {q0-q3}86veor q0, q0, q487veor q1, q1, q588veor q2, q2, q689veor q3, q3, q790vorr q0, q0, q191vorr q0, q0, q292vorr q0, q0, q393vorr d0, d0, d194vrev64.32 d1, d095vorr d0, d0, d196vmov.32 r3, d0[0]97.else98mov r3, #099.endif100101.macro check_reg reg1, reg2=102ldrd r0, r1, [r12], #8103eor r0, r0, \reg1104orr r3, r3, r0105.ifnb \reg2106eor r1, r1, \reg2107orr r3, r3, r1108.endif109.endm110check_reg r4, r5111check_reg r6, r7112@ r9 is a volatile register in the ios ABI113#if SYS_MACOSX114check_reg r8115#else116check_reg r8, r9117#endif118check_reg r10, r11119.purgem check_reg120121cmp r3, #0122beq 0f123124mov r12, #0125str r12, [r2]126movrel r0, error_message127blx X(puts)1280:129pop {r0, r1}130.ifc \variant, neon131vpop {q4-q7}132.endif133pop {r4-r11, pc}134endfunc135.endm136137clobbercheck neon138clobbercheck noneon139140141