Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
52867 views
1
/****************************************************************************
2
* checkasm-aarch64.S: assembly check tool
3
*****************************************************************************
4
* Copyright (C) 2015-2016 x264 project
5
*
6
* Authors: Martin Storsjo <[email protected]>
7
*
8
* This program 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
* This program 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
* This program is also available under a commercial proprietary license.
23
* For more information, contact us at [email protected].
24
*****************************************************************************/
25
26
#include "../common/aarch64/asm.S"
27
28
.section .rodata
29
.align 4
30
register_init:
31
.quad 0x21f86d66c8ca00ce
32
.quad 0x75b6ba21077c48ad
33
.quad 0xed56bb2dcb3c7736
34
.quad 0x8bda43d3fd1a7e06
35
.quad 0xb64a9c9e5d318408
36
.quad 0xdf9a54b303f1d3a3
37
.quad 0x4a75479abd64e097
38
.quad 0x249214109d5d1c88
39
.quad 0x1a1b2550a612b48c
40
.quad 0x79445c159ce79064
41
.quad 0x2eed899d5a28ddcd
42
.quad 0x86b2536fcd8cf636
43
.quad 0xb0856806085e7943
44
.quad 0x3f2bf84fc0fcca4e
45
.quad 0xacbd382dcf5b8de2
46
.quad 0xd229e1f5b281303f
47
.quad 0x71aeaff20b095fd9
48
.quad 0xab63e2e11fa38ed9
49
50
51
error_message:
52
.asciz "failed to preserve register"
53
54
.text
55
56
// max number of args used by any x264 asm function.
57
#define MAX_ARGS 15
58
59
#define ARG_STACK ((8*(MAX_ARGS - 6) + 15) & ~15)
60
61
function x264_checkasm_call, export=1
62
stp x29, x30, [sp, #-16]!
63
mov x29, sp
64
stp x19, x20, [sp, #-16]!
65
stp x21, x22, [sp, #-16]!
66
stp x23, x24, [sp, #-16]!
67
stp x25, x26, [sp, #-16]!
68
stp x27, x28, [sp, #-16]!
69
stp d8, d9, [sp, #-16]!
70
stp d10, d11, [sp, #-16]!
71
stp d12, d13, [sp, #-16]!
72
stp d14, d15, [sp, #-16]!
73
74
movrel x9, register_init
75
ldp d8, d9, [x9], #16
76
ldp d10, d11, [x9], #16
77
ldp d12, d13, [x9], #16
78
ldp d14, d15, [x9], #16
79
ldp x19, x20, [x9], #16
80
ldp x21, x22, [x9], #16
81
ldp x23, x24, [x9], #16
82
ldp x25, x26, [x9], #16
83
ldp x27, x28, [x9], #16
84
85
str x1, [sp, #-16]!
86
87
sub sp, sp, #ARG_STACK
88
.equ pos, 0
89
// first two stacked args are copied to x6, x7
90
.rept MAX_ARGS-6
91
ldr x9, [x29, #16 + 16 + pos]
92
str x9, [sp, #pos]
93
.equ pos, pos + 8
94
.endr
95
96
mov x12, x0
97
mov x0, x2
98
mov x1, x3
99
mov x2, x4
100
mov x3, x5
101
mov x4, x6
102
mov x5, x7
103
ldp x6, x7, [x29, #16]
104
blr x12
105
add sp, sp, #ARG_STACK
106
ldr x2, [sp]
107
stp x0, x1, [sp]
108
movrel x9, register_init
109
movi v3.8h, #0
110
111
.macro check_reg_neon reg1, reg2
112
ldr q0, [x9], #16
113
uzp1 v1.2d, v\reg1\().2d, v\reg2\().2d
114
eor v0.16b, v0.16b, v1.16b
115
orr v3.16b, v3.16b, v0.16b
116
.endm
117
check_reg_neon 8, 9
118
check_reg_neon 10, 11
119
check_reg_neon 12, 13
120
check_reg_neon 14, 15
121
uqxtn v3.8b, v3.8h
122
umov x3, v3.d[0]
123
124
.macro check_reg reg1, reg2
125
ldp x0, x1, [x9], #16
126
eor x0, x0, \reg1
127
eor x1, x1, \reg2
128
orr x3, x3, x0
129
orr x3, x3, x1
130
.endm
131
check_reg x19, x20
132
check_reg x21, x22
133
check_reg x23, x24
134
check_reg x25, x26
135
check_reg x27, x28
136
137
cbz x3, 0f
138
139
mov w9, #0
140
str w9, [x2]
141
movrel x0, error_message
142
bl puts
143
0:
144
ldp x0, x1, [sp], #16
145
ldp d14, d15, [sp], #16
146
ldp d12, d13, [sp], #16
147
ldp d10, d11, [sp], #16
148
ldp d8, d9, [sp], #16
149
ldp x27, x28, [sp], #16
150
ldp x25, x26, [sp], #16
151
ldp x23, x24, [sp], #16
152
ldp x21, x22, [sp], #16
153
ldp x19, x20, [sp], #16
154
ldp x29, x30, [sp], #16
155
ret
156
endfunc
157
158