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