Debian Codegraph @

apple-aarch64/crypto/fipsmodule/bn-armv8-apple.S

raw
1 // This file is generated from a similarly-named Perl script in the BoringSSL
2 // source tree. Do not edit by hand.
3
4 #if !defined(__has_feature)
5 #define __has_feature(x) 0
6 #endif
7 #if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM)
8 #define OPENSSL_NO_ASM
9 #endif
10
11 #if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__)
12 #if defined(BORINGSSL_PREFIX)
13 #include <boringssl_prefix_symbols_asm.h>
14 #endif
15 #include <openssl/arm_arch.h>
16
17 .text
18
19 // BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
20 // size_t num);
21
22 .globl _bn_add_words
23 .private_extern _bn_add_words
24 .align 4
25 _bn_add_words:
26 AARCH64_VALID_CALL_TARGET
27 # Clear the carry flag.
28 cmn xzr, xzr
29
30 # aarch64 can load two registers at a time, so we do two loop iterations at
31 # at a time. Split x3 = 2 * x8 + x3. This allows loop
32 # operations to use CBNZ without clobbering the carry flag.
33 lsr x8, x3, #1
34 and x3, x3, #1
35
36 cbz x8, Ladd_tail
37 Ladd_loop:
38 ldp x4, x5, [x1], #16
39 ldp x6, x7, [x2], #16
40 sub x8, x8, #1
41 adcs x4, x4, x6
42 adcs x5, x5, x7
43 stp x4, x5, [x0], #16
44 cbnz x8, Ladd_loop
45
46 Ladd_tail:
47 cbz x3, Ladd_exit
48 ldr x4, [x1], #8
49 ldr x6, [x2], #8
50 adcs x4, x4, x6
51 str x4, [x0], #8
52
53 Ladd_exit:
54 cset x0, cs
55 ret
56
57
58 // BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
59 // size_t num);
60
61 .globl _bn_sub_words
62 .private_extern _bn_sub_words
63 .align 4
64 _bn_sub_words:
65 AARCH64_VALID_CALL_TARGET
66 # Set the carry flag. Arm's borrow bit is flipped from the carry flag,
67 # so we want C = 1 here.
68 cmp xzr, xzr
69
70 # aarch64 can load two registers at a time, so we do two loop iterations at
71 # at a time. Split x3 = 2 * x8 + x3. This allows loop
72 # operations to use CBNZ without clobbering the carry flag.
73 lsr x8, x3, #1
74 and x3, x3, #1
75
76 cbz x8, Lsub_tail
77 Lsub_loop:
78 ldp x4, x5, [x1], #16
79 ldp x6, x7, [x2], #16
80 sub x8, x8, #1
81 sbcs x4, x4, x6
82 sbcs x5, x5, x7
83 stp x4, x5, [x0], #16
84 cbnz x8, Lsub_loop
85
86 Lsub_tail:
87 cbz x3, Lsub_exit
88 ldr x4, [x1], #8
89 ldr x6, [x2], #8
90 sbcs x4, x4, x6
91 str x4, [x0], #8
92
93 Lsub_exit:
94 cset x0, cc
95 ret
96
97 #endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__)
98 #if defined(__ELF__)
99 // See https://www.airs.com/blog/archives/518.
100 .section .note.GNU-stack,"",%progbits
101 #endif