Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/os_cpu/bsd_aarch64/copy_bsd_aarch64.S
40930 views
1
/*
2
* Copyright (c) 2016, Linaro Ltd. All rights reserved.
3
* Copyright (c) 2021, Azul Systems, Inc. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*
24
*/
25
26
#define CFUNC(x) _##x
27
28
.global CFUNC(_Copy_conjoint_words)
29
.global CFUNC(_Copy_disjoint_words)
30
31
s .req x0
32
d .req x1
33
count .req x2
34
t0 .req x3
35
t1 .req x4
36
t2 .req x5
37
t3 .req x6
38
t4 .req x7
39
t5 .req x8
40
t6 .req x9
41
t7 .req x10
42
43
.align 6
44
CFUNC(_Copy_disjoint_words):
45
// Ensure 2 word aligned
46
tbz s, #3, fwd_copy_aligned
47
ldr t0, [s], #8
48
str t0, [d], #8
49
sub count, count, #1
50
51
fwd_copy_aligned:
52
// Bias s & d so we only pre index on the last copy
53
sub s, s, #16
54
sub d, d, #16
55
56
ldp t0, t1, [s, #16]
57
ldp t2, t3, [s, #32]
58
ldp t4, t5, [s, #48]
59
ldp t6, t7, [s, #64]!
60
61
subs count, count, #16
62
blo fwd_copy_drain
63
64
fwd_copy_again:
65
prfm pldl1keep, [s, #256]
66
stp t0, t1, [d, #16]
67
ldp t0, t1, [s, #16]
68
stp t2, t3, [d, #32]
69
ldp t2, t3, [s, #32]
70
stp t4, t5, [d, #48]
71
ldp t4, t5, [s, #48]
72
stp t6, t7, [d, #64]!
73
ldp t6, t7, [s, #64]!
74
subs count, count, #8
75
bhs fwd_copy_again
76
77
fwd_copy_drain:
78
stp t0, t1, [d, #16]
79
stp t2, t3, [d, #32]
80
stp t4, t5, [d, #48]
81
stp t6, t7, [d, #64]!
82
83
// count is now -8..-1 for 0..7 words to copy
84
adr t0, 0f
85
add t0, t0, count, lsl #5
86
br t0
87
88
.align 5
89
ret // -8 == 0 words
90
.align 5
91
ldr t0, [s, #16] // -7 == 1 word
92
str t0, [d, #16]
93
ret
94
.align 5
95
ldp t0, t1, [s, #16] // -6 = 2 words
96
stp t0, t1, [d, #16]
97
ret
98
.align 5
99
ldp t0, t1, [s, #16] // -5 = 3 words
100
ldr t2, [s, #32]
101
stp t0, t1, [d, #16]
102
str t2, [d, #32]
103
ret
104
.align 5
105
ldp t0, t1, [s, #16] // -4 = 4 words
106
ldp t2, t3, [s, #32]
107
stp t0, t1, [d, #16]
108
stp t2, t3, [d, #32]
109
ret
110
.align 5
111
ldp t0, t1, [s, #16] // -3 = 5 words
112
ldp t2, t3, [s, #32]
113
ldr t4, [s, #48]
114
stp t0, t1, [d, #16]
115
stp t2, t3, [d, #32]
116
str t4, [d, #48]
117
ret
118
.align 5
119
ldp t0, t1, [s, #16] // -2 = 6 words
120
ldp t2, t3, [s, #32]
121
ldp t4, t5, [s, #48]
122
stp t0, t1, [d, #16]
123
stp t2, t3, [d, #32]
124
stp t4, t5, [d, #48]
125
ret
126
.align 5
127
ldp t0, t1, [s, #16] // -1 = 7 words
128
ldp t2, t3, [s, #32]
129
ldp t4, t5, [s, #48]
130
ldr t6, [s, #64]
131
stp t0, t1, [d, #16]
132
stp t2, t3, [d, #32]
133
stp t4, t5, [d, #48]
134
str t6, [d, #64]
135
// Is always aligned here, code for 7 words is one instruction
136
// too large so it just falls through.
137
.align 5
138
0:
139
ret
140
141
.align 6
142
CFUNC(_Copy_conjoint_words):
143
sub t0, d, s
144
cmp t0, count, lsl #3
145
bhs CFUNC(_Copy_disjoint_words)
146
147
add s, s, count, lsl #3
148
add d, d, count, lsl #3
149
150
// Ensure 2 word aligned
151
tbz s, #3, bwd_copy_aligned
152
ldr t0, [s, #-8]!
153
str t0, [d, #-8]!
154
sub count, count, #1
155
156
bwd_copy_aligned:
157
ldp t0, t1, [s, #-16]
158
ldp t2, t3, [s, #-32]
159
ldp t4, t5, [s, #-48]
160
ldp t6, t7, [s, #-64]!
161
162
subs count, count, #16
163
blo bwd_copy_drain
164
165
bwd_copy_again:
166
prfum pldl1keep, [s, #-256]
167
stp t0, t1, [d, #-16]
168
ldp t0, t1, [s, #-16]
169
stp t2, t3, [d, #-32]
170
ldp t2, t3, [s, #-32]
171
stp t4, t5, [d, #-48]
172
ldp t4, t5, [s, #-48]
173
stp t6, t7, [d, #-64]!
174
ldp t6, t7, [s, #-64]!
175
subs count, count, #8
176
bhs bwd_copy_again
177
178
bwd_copy_drain:
179
stp t0, t1, [d, #-16]
180
stp t2, t3, [d, #-32]
181
stp t4, t5, [d, #-48]
182
stp t6, t7, [d, #-64]!
183
184
// count is now -8..-1 for 0..7 words to copy
185
adr t0, 0f
186
add t0, t0, count, lsl #5
187
br t0
188
189
.align 5
190
ret // -8 == 0 words
191
.align 5
192
ldr t0, [s, #-8] // -7 == 1 word
193
str t0, [d, #-8]
194
ret
195
.align 5
196
ldp t0, t1, [s, #-16] // -6 = 2 words
197
stp t0, t1, [d, #-16]
198
ret
199
.align 5
200
ldp t0, t1, [s, #-16] // -5 = 3 words
201
ldr t2, [s, #-24]
202
stp t0, t1, [d, #-16]
203
str t2, [d, #-24]
204
ret
205
.align 5
206
ldp t0, t1, [s, #-16] // -4 = 4 words
207
ldp t2, t3, [s, #-32]
208
stp t0, t1, [d, #-16]
209
stp t2, t3, [d, #-32]
210
ret
211
.align 5
212
ldp t0, t1, [s, #-16] // -3 = 5 words
213
ldp t2, t3, [s, #-32]
214
ldr t4, [s, #-40]
215
stp t0, t1, [d, #-16]
216
stp t2, t3, [d, #-32]
217
str t4, [d, #-40]
218
ret
219
.align 5
220
ldp t0, t1, [s, #-16] // -2 = 6 words
221
ldp t2, t3, [s, #-32]
222
ldp t4, t5, [s, #-48]
223
stp t0, t1, [d, #-16]
224
stp t2, t3, [d, #-32]
225
stp t4, t5, [d, #-48]
226
ret
227
.align 5
228
ldp t0, t1, [s, #-16] // -1 = 7 words
229
ldp t2, t3, [s, #-32]
230
ldp t4, t5, [s, #-48]
231
ldr t6, [s, #-56]
232
stp t0, t1, [d, #-16]
233
stp t2, t3, [d, #-32]
234
stp t4, t5, [d, #-48]
235
str t6, [d, #-56]
236
// Is always aligned here, code for 7 words is one instruction
237
// too large so it just falls through.
238
.align 5
239
0:
240
ret
241
242