Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/crypto/alphacpuid.pl

raw
1 #! /usr/bin/env perl
2 # Copyright 2010-2025 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
8
9
10 $output = pop and open STDOUT,">$output";
11
12 print <<'___';
13 .text
14
15 .set noat
16
17 .globl OPENSSL_cpuid_setup
18 .ent OPENSSL_cpuid_setup
19 OPENSSL_cpuid_setup:
20 .frame $30,0,$26
21 .prologue 0
22 ret ($26)
23 .end OPENSSL_cpuid_setup
24
25 .globl OPENSSL_atomic_add
26 .ent OPENSSL_atomic_add
27 OPENSSL_atomic_add:
28 .frame $30,0,$26
29 .prologue 0
30 1: ldl_l $0,0($16)
31 addl $0,$17,$1
32 stl_c $1,0($16)
33 beq $1,1b
34 addl $0,$17,$0
35 ret ($26)
36 .end OPENSSL_atomic_add
37
38 .globl OPENSSL_rdtsc
39 .ent OPENSSL_rdtsc
40 OPENSSL_rdtsc:
41 .frame $30,0,$26
42 .prologue 0
43 rpcc $0
44 ret ($26)
45 .end OPENSSL_rdtsc
46
47 .globl OPENSSL_cleanse
48 .ent OPENSSL_cleanse
49 OPENSSL_cleanse:
50 .frame $30,0,$26
51 .prologue 0
52 beq $17,.Ldone
53 and $16,7,$0
54 bic $17,7,$at
55 beq $at,.Little
56 beq $0,.Laligned
57
58 .Little:
59 subq $0,8,$0
60 ldq_u $1,0($16)
61 mov $16,$2
62 .Lalign:
63 mskbl $1,$16,$1
64 lda $16,1($16)
65 subq $17,1,$17
66 addq $0,1,$0
67 beq $17,.Lout
68 bne $0,.Lalign
69 .Lout: stq_u $1,0($2)
70 beq $17,.Ldone
71 bic $17,7,$at
72 beq $at,.Little
73
74 .Laligned:
75 stq $31,0($16)
76 subq $17,8,$17
77 lda $16,8($16)
78 bic $17,7,$at
79 bne $at,.Laligned
80 bne $17,.Little
81 .Ldone: ret ($26)
82 .end OPENSSL_cleanse
83
84 .globl CRYPTO_memcmp
85 .ent CRYPTO_memcmp
86 CRYPTO_memcmp:
87 .frame $30,0,$26
88 .prologue 0
89 xor $0,$0,$0
90 beq $18,.Lno_data
91
92 xor $1,$1,$1
93 nop
94 .Loop_cmp:
95 ldq_u $2,0($16)
96 subq $18,1,$18
97 ldq_u $3,0($17)
98 extbl $2,$16,$2
99 lda $16,1($16)
100 extbl $3,$17,$3
101 lda $17,1($17)
102 xor $3,$2,$2
103 or $2,$0,$0
104 bne $18,.Loop_cmp
105
106 subq $31,$0,$0
107 srl $0,63,$0
108 .Lno_data:
109 ret ($26)
110 .end CRYPTO_memcmp
111 ___
112 {
113 my ($out,$cnt,$max)=("\$16","\$17","\$18");
114 my ($tick,$lasttick)=("\$19","\$20");
115 my ($diff,$lastdiff)=("\$21","\$22");
116 my ($v0,$ra,$sp,$zero)=("\$0","\$26","\$30","\$31");
117
118 print <<___;
119 .globl OPENSSL_instrument_bus
120 .ent OPENSSL_instrument_bus
121 OPENSSL_instrument_bus:
122 .frame $sp,0,$ra
123 .prologue 0
124 mov $cnt,$v0
125
126 rpcc $lasttick
127 mov 0,$diff
128
129 ecb ($out)
130 ldl_l $tick,0($out)
131 addl $diff,$tick,$tick
132 mov $tick,$diff
133 stl_c $tick,0($out)
134 stl $diff,0($out)
135
136 .Loop: rpcc $tick
137 subq $tick,$lasttick,$diff
138 mov $tick,$lasttick
139
140 ecb ($out)
141 ldl_l $tick,0($out)
142 addl $diff,$tick,$tick
143 mov $tick,$diff
144 stl_c $tick,0($out)
145 stl $diff,0($out)
146
147 subl $cnt,1,$cnt
148 lda $out,4($out)
149 bne $cnt,.Loop
150
151 ret ($ra)
152 .end OPENSSL_instrument_bus
153
154 .globl OPENSSL_instrument_bus2
155 .ent OPENSSL_instrument_bus2
156 OPENSSL_instrument_bus2:
157 .frame $sp,0,$ra
158 .prologue 0
159 mov $cnt,$v0
160
161 rpcc $lasttick
162 mov 0,$diff
163
164 ecb ($out)
165 ldl_l $tick,0($out)
166 addl $diff,$tick,$tick
167 mov $tick,$diff
168 stl_c $tick,0($out)
169 stl $diff,0($out)
170
171 rpcc $tick
172 subq $tick,$lasttick,$diff
173 mov $tick,$lasttick
174 mov $diff,$lastdiff
175 .Loop2:
176 ecb ($out)
177 ldl_l $tick,0($out)
178 addl $diff,$tick,$tick
179 mov $tick,$diff
180 stl_c $tick,0($out)
181 stl $diff,0($out)
182
183 subl $max,1,$max
184 beq $max,.Ldone2
185
186 rpcc $tick
187 subq $tick,$lasttick,$diff
188 mov $tick,$lasttick
189 subq $lastdiff,$diff,$tick
190 mov $diff,$lastdiff
191 cmovne $tick,1,$tick
192 subl $cnt,$tick,$cnt
193 s4addq $tick,$out,$out
194 bne $cnt,.Loop2
195
196 .Ldone2:
197 subl $v0,$cnt,$v0
198 ret ($ra)
199 .end OPENSSL_instrument_bus2
200 ___
201 }
202
203 close STDOUT or die "error closing STDOUT: $!";