2 # Copyright 2009-2018 The OpenSSL Project Authors. All Rights Reserved.
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
10 # $output is the last argument if it looks like a file (it has an extension)
11 # $flavour is the first argument if it doesn't look like a file
12 $output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
13 $flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
15 $output and open STDOUT,">$output";
17 if ($flavour =~ /64/) {
34 .SUBSPA \$CODE\$,QUAD=0,ALIGN=8,ACCESS=0x2C,CODE_ONLY
36 .EXPORT OPENSSL_cpuid_setup,ENTRY
47 .EXPORT OPENSSL_rdtsc,ENTRY
59 .EXPORT OPENSSL_wipe_cpu,ENTRY
104 .EXPORT OPENSSL_cleanse,ENTRY,ARGW0=GR,ARGW1=GR
110 cmpib,*= 0,$len,L\$done
112 cmpib,*>>= 15,$len,L\$ittle
116 and,*<> $inp,%r1,%r28
127 addib,*<> -$SIZE_T,%r28,L\$ot
128 ldo $SIZE_T($inp),$inp
130 and,*<> $len,%r1,$len
134 addib,*<> -1,$len,L\$ittle
144 my ($in1,$in2,$len)=("%r26","%r25","%r24");
147 .EXPORT CRYPTO_memcmp,ENTRY,ARGW0=GR,ARGW1=GR,ARGW1=GR
153 cmpib,*= 0,$len,L\$no_data
162 addib,*<> -1,$len,L\$oop_cmp
175 my ($out,$cnt,$max)=("%r26","%r25","%r24");
176 my ($tick,$lasttick)=("%r23","%r22");
177 my ($diff,$lastdiff)=("%r21","%r20");
180 .EXPORT OPENSSL_instrument_bus,ENTRY,ARGW0=GR,ARGW1=GR
182 OPENSSL_instrument_bus
193 add $diff,$tick,$tick
197 sub $tick,$lasttick,$diff
202 add $diff,$tick,$tick
205 addib,<> -1,$cnt,L\$oop
213 .EXPORT OPENSSL_instrument_bus2,ENTRY,ARGW0=GR,ARGW1=GR
215 OPENSSL_instrument_bus2
228 add $diff,$tick,$tick
232 sub $tick,$lasttick,$diff
238 add $diff,$tick,$tick
241 addib,= -1,$max,L\$done2
245 sub $tick,$lasttick,$diff
247 cmpclr,<> $lastdiff,$diff,$tick
252 addb,<> $tick,$cnt,L\$oop2
253 shladd,l $tick,2,$out,$out
262 if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
263 =~ /GNU assembler/) {
267 foreach(split("\n",$code)) {
269 s/(\.LEVEL\s+2\.0)W/$1w/ if ($gnuas && $SIZE_T==8);
270 s/\.SPACE\s+\$TEXT\$/.text/ if ($gnuas && $SIZE_T==8);
271 s/\.SUBSPA.*// if ($gnuas && $SIZE_T==8);
272 s/cmpib,\*/comib,/ if ($SIZE_T==4);
273 s/,\*/,/ if ($SIZE_T==4);
274 s/\bbv\b/bve/ if ($SIZE_T==8);
278 close STDOUT or die "error closing STDOUT: $!";