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 if ($flavour =~ /elf/) {
22 print ".section .note.GNU-stack,\"\",\@progbits\n"
28 .globl OPENSSL_atomic_add
29 .type OPENSSL_atomic_add,\@abi-omnipotent
33 .Lspin: leaq ($arg2,%rax),%r8
38 .byte 0x48,0x98 # cltq/cdqe
40 .size OPENSSL_atomic_add,.-OPENSSL_atomic_add
43 .type OPENSSL_rdtsc,\@abi-omnipotent
50 .size OPENSSL_rdtsc,.-OPENSSL_rdtsc
52 .globl OPENSSL_ia32_cpuid
53 .type OPENSSL_ia32_cpuid,\@abi-omnipotent
60 mov %eax,%r11d # max value for standard query level
63 cmp \$0x756e6547,%ebx # "Genu"
66 cmp \$0x49656e69,%edx # "ineI"
69 cmp \$0x6c65746e,%ecx # "ntel"
71 or %eax,%r9d # 0 indicates Intel CPU
74 cmp \$0x68747541,%ebx # "Auth"
77 cmp \$0x69746E65,%edx # "enti"
80 cmp \$0x444D4163,%ecx # "cAMD"
82 or %eax,%r10d # 0 indicates AMD CPU
93 movzb %cl,%r10 # number of cores - 1
94 inc %r10 # number of cores
98 bt \$28,%edx # test hyper-threading bit
100 shr \$16,%ebx # number of logical processors
103 and \$0xefffffff,%edx # ~(1<<28)
112 mov \$0,%ecx # query L1D
116 and \$0xfff,%r10d # number of cores -1 per L1D
123 or \$0x00100000,%edx # use reserved 20th bit to engage RC4_CHAR
125 cmp \$15,%ah # examine Family ID
127 or \$0x40000000,%edx # use reserved bit to skip unrolled loop
129 bt \$28,%edx # test hyper-threading bit
131 and \$0xefffffff,%edx # ~(1<<28)
135 or \$0x10000000,%edx # 1<<28
137 cmp \$1,%bl # see if cache is shared
139 and \$0xefffffff,%edx # ~(1<<28)
146 .size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
148 .globl OPENSSL_cleanse
149 .type OPENSSL_cleanse,\@abi-omnipotent
181 .size OPENSSL_cleanse,.-OPENSSL_cleanse
184 print<<___ if (!$win64);
185 .globl OPENSSL_wipe_cpu
186 .type OPENSSL_wipe_cpu,\@abi-omnipotent
215 .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
217 print<<___ if ($win64);
218 .globl OPENSSL_wipe_cpu
219 .type OPENSSL_wipe_cpu,\@abi-omnipotent
236 .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
239 close STDOUT; # flush