5 if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
7 $win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
9 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
10 open STDOUT,"| $^X ${dir}perlasm/x86_64-xlate.pl $flavour $output";
12 if ($win64) { $arg1="%rcx"; $arg2="%rdx"; }
13 else { $arg1="%rdi"; $arg2="%rsi"; }
15 .extern OPENSSL_cpuid_setup
17 call OPENSSL_cpuid_setup
21 .globl OPENSSL_atomic_add
22 .type OPENSSL_atomic_add,\@abi-omnipotent
26 .Lspin: leaq ($arg2,%rax),%r8
31 .byte 0x48,0x98 # cltq/cdqe
33 .size OPENSSL_atomic_add,.-OPENSSL_atomic_add
36 .type OPENSSL_rdtsc,\@abi-omnipotent
43 .size OPENSSL_rdtsc,.-OPENSSL_rdtsc
45 .globl OPENSSL_ia32_cpuid
46 .type OPENSSL_ia32_cpuid,\@abi-omnipotent
53 mov %eax,%r11d # max value for standard query level
56 cmp \$0x756e6547,%ebx # "Genu"
59 cmp \$0x49656e69,%edx # "ineI"
62 cmp \$0x6c65746e,%ecx # "ntel"
64 or %eax,%r9d # 0 indicates Intel CPU
67 cmp \$0x68747541,%ebx # "Auth"
70 cmp \$0x69746E65,%edx # "enti"
73 cmp \$0x444D4163,%ecx # "cAMD"
75 or %eax,%r10d # 0 indicates AMD CPU
86 movzb %cl,%r10 # number of cores - 1
87 inc %r10 # number of cores
91 bt \$28,%edx # test hyper-threading bit
93 shr \$16,%ebx # number of logical processors
96 and \$0xefffffff,%edx # ~(1<<28)
105 mov \$0,%ecx # query L1D
109 and \$0xfff,%r10d # number of cores -1 per L1D
116 or \$0x00100000,%edx # use reserved 20th bit to engage RC4_CHAR
118 cmp \$15,%ah # examine Family ID
120 or \$0x40000000,%edx # use reserved bit to skip unrolled loop
122 bt \$28,%edx # test hyper-threading bit
124 and \$0xefffffff,%edx # ~(1<<28)
128 or \$0x10000000,%edx # 1<<28
130 cmp \$1,%bl # see if cache is shared
132 and \$0xefffffff,%edx # ~(1<<28)
139 .size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
141 .globl OPENSSL_cleanse
142 .type OPENSSL_cleanse,\@abi-omnipotent
173 .size OPENSSL_cleanse,.-OPENSSL_cleanse
176 print<<___ if (!$win64);
177 .globl OPENSSL_wipe_cpu
178 .type OPENSSL_wipe_cpu,\@abi-omnipotent
207 .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
209 print<<___ if ($win64);
210 .globl OPENSSL_wipe_cpu
211 .type OPENSSL_wipe_cpu,\@abi-omnipotent
228 .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
231 close STDOUT; # flush