Latest update.
This commit is contained in:
@@ -86,6 +86,7 @@ $code.=<<___;
|
||||
.type __KeccakF1600,\@abi-omnipotent
|
||||
.align 32
|
||||
__KeccakF1600:
|
||||
.cfi_startproc
|
||||
mov $A[4][0](%rdi),@C[0]
|
||||
mov $A[4][1](%rdi),@C[1]
|
||||
mov $A[4][2](%rdi),@C[2]
|
||||
@@ -344,6 +345,7 @@ $code.=<<___;
|
||||
|
||||
lea -192($iotas),$iotas # rewind iotas
|
||||
ret
|
||||
.cfi_endproc
|
||||
.size __KeccakF1600,.-__KeccakF1600
|
||||
|
||||
.type KeccakF1600,\@abi-omnipotent
|
||||
|
||||
@@ -143,7 +143,7 @@ $ymm=1 if ($xmm && !$ymm && $ARGV[0] eq "win32" &&
|
||||
`ml 2>&1` =~ /Version ([0-9]+)\./ &&
|
||||
$1>=10); # first version supporting AVX
|
||||
|
||||
$ymm=1 if ($xmm && !$ymm && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9]\.[0-9]+)/ &&
|
||||
$ymm=1 if ($xmm && !$ymm && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([0-9]+\.[0-9]+)/ &&
|
||||
$2>=3.0); # first version supporting AVX
|
||||
|
||||
$shaext=$xmm; ### set to zero if compiling for 1.0.1
|
||||
|
||||
@@ -67,7 +67,7 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$avx = ($1>=10) + ($1>=11);
|
||||
}
|
||||
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([0-9]+\.[0-9]+)/) {
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$avx = ($1>=10) + ($1>=11);
|
||||
}
|
||||
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([2-9]\.[0-9]+)/) {
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([0-9]+\.[0-9]+)/) {
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
@@ -470,8 +470,8 @@ $code.=<<___ if ($win64);
|
||||
.Lepilogue_shaext:
|
||||
___
|
||||
$code.=<<___;
|
||||
.cfi_endproc
|
||||
ret
|
||||
.cfi_endproc
|
||||
.size sha1_block_data_order_shaext,.-sha1_block_data_order_shaext
|
||||
___
|
||||
}}}
|
||||
|
||||
@@ -95,7 +95,7 @@ if ($xmm && !$avx && $ARGV[0] eq "win32" &&
|
||||
$avx = ($1>=10) + ($1>=11);
|
||||
}
|
||||
|
||||
if ($xmm && !$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
if ($xmm && !$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([0-9]+\.[0-9]+)/) {
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$avx = ($1>=10) + ($1>=11);
|
||||
}
|
||||
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([0-9]+\.[0-9]+)/) {
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$avx = ($1>=10) + ($1>=11);
|
||||
}
|
||||
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([0-9]+\.[0-9]+)/) {
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
@@ -571,6 +571,7 @@ $code.=<<___;
|
||||
.align 64
|
||||
sha256_block_data_order_shaext:
|
||||
_shaext_shortcut:
|
||||
.cfi_startproc
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
lea `-8-5*16`(%rsp),%rsp
|
||||
@@ -714,6 +715,7 @@ $code.=<<___ if ($win64);
|
||||
___
|
||||
$code.=<<___;
|
||||
ret
|
||||
.cfi_endproc
|
||||
.size sha256_block_data_order_shaext,.-sha256_block_data_order_shaext
|
||||
___
|
||||
}}}
|
||||
@@ -1994,7 +1996,23 @@ $code.=<<___;
|
||||
vmovdqa $t0,0x00(%rsp)
|
||||
xor $a1,$a1
|
||||
vmovdqa $t1,0x20(%rsp)
|
||||
___
|
||||
$code.=<<___ if (!$win64);
|
||||
# temporarily use %rdi as frame pointer
|
||||
mov $_rsp,%rdi
|
||||
.cfi_def_cfa %rdi,8
|
||||
___
|
||||
$code.=<<___;
|
||||
lea -$PUSH8(%rsp),%rsp
|
||||
___
|
||||
$code.=<<___ if (!$win64);
|
||||
# the frame info is at $_rsp, but the stack is moving...
|
||||
# so a second frame pointer is saved at -8(%rsp)
|
||||
# that is in the red zone
|
||||
mov %rdi,-8(%rsp)
|
||||
.cfi_cfa_expression %rsp-8,deref,+8
|
||||
___
|
||||
$code.=<<___;
|
||||
mov $B,$a3
|
||||
vmovdqa $t2,0x00(%rsp)
|
||||
xor $C,$a3 # magic
|
||||
@@ -2014,7 +2032,18 @@ my @X = @_;
|
||||
my @insns = (&$body,&$body,&$body,&$body); # 96 instructions
|
||||
my $base = "+2*$PUSH8(%rsp)";
|
||||
|
||||
&lea ("%rsp","-$PUSH8(%rsp)") if (($j%2)==0);
|
||||
if (($j%2)==0) {
|
||||
&lea ("%rsp","-$PUSH8(%rsp)");
|
||||
$code.=<<___ if (!$win64);
|
||||
.cfi_cfa_expression %rsp+`$PUSH8-8`,deref,+8
|
||||
# copy secondary frame pointer to new location again at -8(%rsp)
|
||||
pushq $PUSH8-8(%rsp)
|
||||
.cfi_cfa_expression %rsp,deref,+8
|
||||
lea 8(%rsp),%rsp
|
||||
.cfi_cfa_expression %rsp-8,deref,+8
|
||||
___
|
||||
}
|
||||
|
||||
foreach (Xupdate_256_AVX()) { # 29 instructions
|
||||
eval;
|
||||
eval(shift(@insns));
|
||||
@@ -2085,7 +2114,23 @@ $code.=<<___;
|
||||
vmovdqa $t2,0x40(%rsp)
|
||||
vpaddq 0x40($Tbl),@X[6],$t2
|
||||
vmovdqa $t3,0x60(%rsp)
|
||||
___
|
||||
$code.=<<___ if (!$win64);
|
||||
# temporarily use %rdi as frame pointer
|
||||
mov $_rsp,%rdi
|
||||
.cfi_def_cfa %rdi,8
|
||||
___
|
||||
$code.=<<___;
|
||||
lea -$PUSH8(%rsp),%rsp
|
||||
___
|
||||
$code.=<<___ if (!$win64);
|
||||
# the frame info is at $_rsp, but the stack is moving...
|
||||
# so a second frame pointer is saved at -8(%rsp)
|
||||
# that is in the red zone
|
||||
mov %rdi,-8(%rsp)
|
||||
.cfi_cfa_expression %rsp-8,deref,+8
|
||||
___
|
||||
$code.=<<___;
|
||||
vpaddq 0x60($Tbl),@X[7],$t3
|
||||
vmovdqa $t0,0x00(%rsp)
|
||||
xor $a1,$a1
|
||||
@@ -2109,7 +2154,18 @@ my @X = @_;
|
||||
my @insns = (&$body,&$body); # 48 instructions
|
||||
my $base = "+2*$PUSH8(%rsp)";
|
||||
|
||||
&lea ("%rsp","-$PUSH8(%rsp)") if (($j%4)==0);
|
||||
if (($j%4)==0) {
|
||||
&lea ("%rsp","-$PUSH8(%rsp)");
|
||||
$code.=<<___ if (!$win64);
|
||||
.cfi_cfa_expression %rsp+`$PUSH8-8`,deref,+8
|
||||
# copy secondary frame pointer to new location again at -8(%rsp)
|
||||
pushq $PUSH8-8(%rsp)
|
||||
.cfi_cfa_expression %rsp,deref,+8
|
||||
lea 8(%rsp),%rsp
|
||||
.cfi_cfa_expression %rsp-8,deref,+8
|
||||
___
|
||||
}
|
||||
|
||||
foreach (Xupdate_512_AVX()) { # 23 instructions
|
||||
eval;
|
||||
if ($_ !~ /\;$/) {
|
||||
@@ -2184,6 +2240,8 @@ $code.=<<___;
|
||||
add $a1,$A
|
||||
#mov `2*$SZ*$rounds+8`(%rsp),$inp # $_inp
|
||||
lea `2*$SZ*($rounds-8)`(%rsp),%rsp
|
||||
# restore frame pointer to original location at $_rsp
|
||||
.cfi_cfa_expression $_rsp,deref,+8
|
||||
|
||||
add $SZ*0($ctx),$A
|
||||
add $SZ*1($ctx),$B
|
||||
@@ -2209,22 +2267,24 @@ $code.=<<___;
|
||||
|
||||
jbe .Loop_avx2
|
||||
lea (%rsp),$Tbl
|
||||
# temporarily use $Tbl as index to $_rsp
|
||||
# this avoids the need to save a secondary frame pointer at -8(%rsp)
|
||||
.cfi_cfa_expression $Tbl+`16*$SZ+3*8`,deref,+8
|
||||
|
||||
.Ldone_avx2:
|
||||
lea ($Tbl),%rsp
|
||||
mov $_rsp,%rsi
|
||||
mov `16*$SZ+3*8`($Tbl),%rsi
|
||||
.cfi_def_cfa %rsi,8
|
||||
vzeroupper
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
movaps 16*$SZ+32(%rsp),%xmm6
|
||||
movaps 16*$SZ+48(%rsp),%xmm7
|
||||
movaps 16*$SZ+64(%rsp),%xmm8
|
||||
movaps 16*$SZ+80(%rsp),%xmm9
|
||||
movaps 16*$SZ+32($Tbl),%xmm6
|
||||
movaps 16*$SZ+48($Tbl),%xmm7
|
||||
movaps 16*$SZ+64($Tbl),%xmm8
|
||||
movaps 16*$SZ+80($Tbl),%xmm9
|
||||
___
|
||||
$code.=<<___ if ($win64 && $SZ>4);
|
||||
movaps 16*$SZ+96(%rsp),%xmm10
|
||||
movaps 16*$SZ+112(%rsp),%xmm11
|
||||
movaps 16*$SZ+96($Tbl),%xmm10
|
||||
movaps 16*$SZ+112($Tbl),%xmm11
|
||||
___
|
||||
$code.=<<___;
|
||||
mov -48(%rsi),%r15
|
||||
|
||||
@@ -60,6 +60,14 @@
|
||||
# define SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
|
||||
#endif
|
||||
|
||||
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
|
||||
# define U64(C) C##UI64
|
||||
#elif defined(__arch64__)
|
||||
# define U64(C) C##UL
|
||||
#else
|
||||
# define U64(C) C##ULL
|
||||
#endif
|
||||
|
||||
int sha512_224_init(SHA512_CTX *c)
|
||||
{
|
||||
c->h[0] = U64(0x8c3d37c819544da2);
|
||||
|
||||
Reference in New Issue
Block a user