3 # ====================================================================
4 # Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5 # project. The module is, however, dual licensed under OpenSSL and
6 # CRYPTOGAMS licenses depending on where you obtain it. For further
7 # details see http://www.openssl.org/~appro/cryptogams/.
8 # ====================================================================
12 # Performance is 2x of gcc 3.4.6 on z10. Coding "secret" is to
13 # "cluster" Address Generation Interlocks, so that one pipeline stall
14 # resolves several dependencies.
18 # Adapt for -m31 build. If kernel supports what's called "highgprs"
19 # feature on Linux [see /proc/cpuinfo], it's possible to use 64-bit
20 # instructions and achieve "64-bit" performance even in 31-bit legacy
21 # application context. The feature is not specific to any particular
22 # processor, as long as it's "z-CPU". Latter implies that the code
23 # remains z/Architecture specific. On z990 it was measured to perform
24 # 50% better than code generated by gcc 4.3.
28 if ($flavour =~ /3[12]/) {
36 while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
37 open STDOUT,">$output";
46 # void RC4(RC4_KEY *key,size_t len,const void *inp,void *out)
65 stm${g} %r6,%r11,6*$SIZE_T($sp)
67 $code.=<<___ if ($flavour =~ /3[12]/);
77 llgc $TX[0],2($XX[0],$key)
84 for ($i=0;$i<8;$i++) {
86 la $YY,0($YY,$TX[0]) # $i
91 $code.=<<___ if ($i==1);
94 $code.=<<___ if ($i>1);
100 stc $TX[0],2($YY,$key)
101 llgc $TX[1],2($XX[1],$key)
102 stc $TY,2($XX[0],$key)
110 push(@TX,shift(@TX)); push(@XX,shift(@XX)); # "rotate" registers
134 stc $TX[0],2($YY,$key)
135 stc $TY,2($XX[0],$key)
143 llgc $TX[0],2($XX[0],$key)
153 lm${g} %r6,%r11,6*$SIZE_T($sp)
156 .string "RC4 for s390x, CRYPTOGAMS by <appro\@openssl.org>"
161 # void RC4_set_key(RC4_KEY *key,unsigned int len,const void *inp)
175 .type RC4_set_key,\@function
178 stm${g} %r6,%r8,6*$SIZE_T($sp)
184 stc $idx,2($idx,$key)
194 llgc $acc,2+256($ikey,$key)
195 llgc $dat,0($iinp,$inp)
202 llgc $dat,2($idx,$key)
203 stc $dat,2+256-1($ikey,$key)
204 stc $acc,2($idx,$key)
211 lm${g} %r6,%r8,6*$SIZE_T($sp)
213 .size RC4_set_key,.-RC4_set_key
218 # const char *RC4_options()
221 .type RC4_options,\@function
226 .size RC4_options,.-RC4_options
230 .string "rc4(8x,char)"
234 close STDOUT; # force flush