initial commit
[glibc.git] / sysdeps / sparc / sparc64 / multiarch / sha256-crop.S
1 /* SHA256 using sparc crypto opcodes.
2 Copyright (C) 2012-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19 #include <sysdep.h>
20
21 #define SHA256 \
22 .word 0x81b02840;
23
24 .text
25 .align 32
26 ENTRY(__sha256_process_block_crop)
27 /* %o0=buffer, %o1=len, %o2=CTX */
28 ldx [%o2 + 0x20], %g1
29 add %g1, %o1, %g1
30 stx %g1, [%o2 + 0x20]
31
32 ld [%o2 + 0x00], %f0
33 ld [%o2 + 0x04], %f1
34 ld [%o2 + 0x08], %f2
35 ld [%o2 + 0x0c], %f3
36 ld [%o2 + 0x10], %f4
37 ld [%o2 + 0x14], %f5
38 andcc %o1, 0x7, %g0
39 ld [%o2 + 0x18], %f6
40 bne,pn %xcc, 10f
41 ld [%o2 + 0x1c], %f7
42
43 1:
44 ldd [%o0 + 0x00], %f8
45 ldd [%o0 + 0x08], %f10
46 ldd [%o0 + 0x10], %f12
47 ldd [%o0 + 0x18], %f14
48 ldd [%o0 + 0x20], %f16
49 ldd [%o0 + 0x28], %f18
50 ldd [%o0 + 0x30], %f20
51 ldd [%o0 + 0x38], %f22
52
53 SHA256
54
55 subcc %o1, 0x40, %o1
56 bne,pt %xcc, 1b
57 add %o0, 0x40, %o0
58
59 5:
60 st %f0, [%o2 + 0x00]
61 st %f1, [%o2 + 0x04]
62 st %f2, [%o2 + 0x08]
63 st %f3, [%o2 + 0x0c]
64 st %f4, [%o2 + 0x10]
65 st %f5, [%o2 + 0x14]
66 st %f6, [%o2 + 0x18]
67 retl
68 st %f7, [%o2 + 0x1c]
69 10:
70 alignaddr %o0, %g0, %o0
71
72 ldd [%o0 + 0x00], %f10
73 1:
74 ldd [%o0 + 0x08], %f12
75 ldd [%o0 + 0x10], %f14
76 ldd [%o0 + 0x18], %f16
77 ldd [%o0 + 0x20], %f18
78 ldd [%o0 + 0x28], %f20
79 ldd [%o0 + 0x30], %f22
80 ldd [%o0 + 0x38], %f24
81 ldd [%o0 + 0x40], %f26
82
83 faligndata %f10, %f12, %f8
84 faligndata %f12, %f14, %f10
85 faligndata %f14, %f16, %f12
86 faligndata %f16, %f18, %f14
87 faligndata %f18, %f20, %f16
88 faligndata %f20, %f22, %f18
89 faligndata %f22, %f24, %f20
90 faligndata %f24, %f26, %f22
91
92 SHA256
93
94 subcc %o1, 0x40, %o1
95 fsrc2 %f26, %f10
96 bne,pt %xcc, 1b
97 add %o0, 0x40, %o0
98
99 ba,a,pt %xcc, 5b
100 END(__sha256_process_block_crop)