summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2011-06-28 12:41:19 +0000
committerAndy Polyakov <appro@openssl.org>2011-06-28 12:41:19 +0000
commit5a0876cb8c4df346b2346a02856b06267c643ee7 (patch)
tree6fd7ba57634f8b8716ad8f84610f15d8484d29e3 /crypto
parenta908b711ac0ee74b2005a3e84e5099acbaecee60 (diff)
crypto/sha/asm/sha[1|512]-mips.pl: minor updates.
Diffstat (limited to 'crypto')
-rw-r--r--crypto/sha/asm/sha1-mips.pl22
-rw-r--r--crypto/sha/asm/sha512-mips.pl10
2 files changed, 16 insertions, 16 deletions
diff --git a/crypto/sha/asm/sha1-mips.pl b/crypto/sha/asm/sha1-mips.pl
index 75a6fb49c6..a69dfbd8d2 100644
--- a/crypto/sha/asm/sha1-mips.pl
+++ b/crypto/sha/asm/sha1-mips.pl
@@ -59,7 +59,6 @@ if ($flavour =~ /64|n32/i) {
$PTR_SLL="sll";
$SZREG=4;
}
-$SAVED_REGS_MASK = ($flavour =~ /nubi/i) ? 0x00fff008 : 0x00ff0000;
#
# <appro@openssl.org>
#
@@ -77,11 +76,11 @@ if (!defined($big_endian))
$MSB=$big_endian?0:3;
$LSB=3&~$MSB;
-@X=( "\$8", "\$9", "\$10", "\$11", "\$12", "\$13", "\$14", "\$15",
- "\$16", "\$17", "\$18", "\$19", "\$20", "\$21", "\$22", "\$23");
-$ctx="\$4"; # a0
-$inp="\$5"; # a1
-$num="\$6"; # a2
+@X=map("\$$_",(8..23)); # a4-a7,s0-s11
+
+$ctx=$a0;
+$inp=$a1;
+$num=$a2;
$A="\$1";
$B="\$2";
$C="\$3";
@@ -92,8 +91,6 @@ $t1=$num; # $num is offloaded to stack
$t2="\$30"; # fp
$K="\$31"; # ra
-$FRAMESIZE=16;
-
sub BODY_00_14 {
my ($i,$a,$b,$c,$d,$e)=@_;
my $j=$i+1;
@@ -105,8 +102,8 @@ $code.=<<___ if (!$big_endian);
andi $t1,0xFF00
sll $t2,$t2,8
or @X[$i],$t0
+ or $t1,$t2
or @X[$i],$t1
- or @X[$i],$t2
___
$code.=<<___;
lwl @X[$j],$j*4+$MSB($inp)
@@ -236,6 +233,9 @@ $code.=<<___ if ($i<79);
___
}
+$FRAMESIZE=16; # large enough to accomodate NUBI saved registers
+$SAVED_REGS_MASK = ($flavour =~ /nubi/i) ? 0xc0fff008 : 0xc0ff0000;
+
$code=<<___;
.text
@@ -246,7 +246,7 @@ $code=<<___;
.ent sha1_block_data_order
sha1_block_data_order:
.frame $sp,$FRAMESIZE*$SZREG,$ra
- .mask 0xd0000000|$SAVED_REGS_MASK,-$SZREG
+ .mask $SAVED_REGS_MASK,-$SZREG
.set noreorder
$PTR_SUB $sp,$FRAMESIZE*$SZREG
$REG_S $ra,($FRAMESIZE-1)*$SZREG($sp)
@@ -260,7 +260,7 @@ sha1_block_data_order:
$REG_S $s5,($FRAMESIZE-9)*$SZREG($sp)
$REG_S $s4,($FRAMESIZE-10)*$SZREG($sp)
___
-$code.=<<___ if ($flavour =~ /nubi/i);
+$code.=<<___ if ($flavour =~ /nubi/i); # optimize non-nubi prologue
$REG_S $s3,($FRAMESIZE-11)*$SZREG($sp)
$REG_S $s2,($FRAMESIZE-12)*$SZREG($sp)
$REG_S $s1,($FRAMESIZE-13)*$SZREG($sp)
diff --git a/crypto/sha/asm/sha512-mips.pl b/crypto/sha/asm/sha512-mips.pl
index 8cd88dbda2..988f6f4c6a 100644
--- a/crypto/sha/asm/sha512-mips.pl
+++ b/crypto/sha/asm/sha512-mips.pl
@@ -314,12 +314,15 @@ for (;$i<32;$i++)
$code.=<<___;
and @X[6],0xfff
li @X[7],$lastK
- $PTR_ADD $Ktbl,16*$SZ # Ktbl+=16
+ .set noreorder
bne @X[6],@X[7],.L16_xx
+ $PTR_ADD $Ktbl,16*$SZ # Ktbl+=16
+ $REG_L @X[15],16*$SZ($sp) # restore pointer to the end of input
$LD @X[0],0*$SZ($ctx)
$LD @X[1],1*$SZ($ctx)
$LD @X[2],2*$SZ($ctx)
+ $PTR_ADD $inp,16*$SZ
$LD @X[3],3*$SZ($ctx)
$ADDU $A,@X[0]
$LD @X[4],4*$SZ($ctx)
@@ -337,17 +340,14 @@ $code.=<<___;
$ST $C,2*$SZ($ctx)
$ADDU $H,@X[7]
$ST $D,3*$SZ($ctx)
- $PTR_ADD $inp,16*$SZ
$ST $E,4*$SZ($ctx)
- $REG_L @X[15],16*$SZ($sp) # restore pointer to the end of input
$ST $F,5*$SZ($ctx)
$ST $G,6*$SZ($ctx)
$ST $H,7*$SZ($ctx)
+ bnel $inp,@X[15],.Loop
$PTR_SUB $Ktbl,`($rounds-16)*$SZ` # rewind $Ktbl
- bne $inp,@X[15],.Loop
- .set noreorder
$REG_L $ra,$FRAMESIZE-1*$SZREG($sp)
$REG_L $fp,$FRAMESIZE-2*$SZREG($sp)
$REG_L $s11,$FRAMESIZE-3*$SZREG($sp)