$PTR_SLL="sll";
$SZREG=4;
}
-$SAVED_REGS_MASK = ($flavour =~ /nubi/i) ? 0x00fff008 : 0x00ff0000;
#
# <appro@openssl.org>
#
$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";
$t2="\$30"; # fp
$K="\$31"; # ra
-$FRAMESIZE=16;
-
sub BODY_00_14 {
my ($i,$a,$b,$c,$d,$e)=@_;
my $j=$i+1;
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)
___
}
+$FRAMESIZE=16; # large enough to accomodate NUBI saved registers
+$SAVED_REGS_MASK = ($flavour =~ /nubi/i) ? 0xc0fff008 : 0xc0ff0000;
+
$code=<<___;
.text
.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)
$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)
$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)
$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)