2 # Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
10 # ====================================================================
11 # Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
12 # project. The module is, however, dual licensed under OpenSSL and
13 # CRYPTOGAMS licenses depending on where you obtain it. For further
14 # details see http://www.openssl.org/~appro/cryptogams/.
15 # ====================================================================
19 # Performance is 2x of gcc 3.4.6 on z10. Coding "secret" is to
20 # "cluster" Address Generation Interlocks, so that one pipeline stall
21 # resolves several dependencies.
25 # Adapt for -m31 build. If kernel supports what's called "highgprs"
26 # feature on Linux [see /proc/cpuinfo], it's possible to use 64-bit
27 # instructions and achieve "64-bit" performance even in 31-bit legacy
28 # application context. The feature is not specific to any particular
29 # processor, as long as it's "z-CPU". Latter implies that the code
30 # remains z/Architecture specific. On z990 it was measured to perform
31 # 50% better than code generated by gcc 4.3.
35 if ($flavour =~ /3[12]/) {
43 while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
44 open STDOUT,">$output";
53 # void RC4(RC4_KEY *key,size_t len,const void *inp,void *out)
72 stm${g} %r6,%r11,6*$SIZE_T($sp)
74 $code.=<<___ if ($flavour =~ /3[12]/);
84 llgc $TX[0],2($XX[0],$key)
91 for ($i=0;$i<8;$i++) {
93 la $YY,0($YY,$TX[0]) # $i
98 $code.=<<___ if ($i==1);
101 $code.=<<___ if ($i>1);
107 stc $TX[0],2($YY,$key)
108 llgc $TX[1],2($XX[1],$key)
109 stc $TY,2($XX[0],$key)
117 push(@TX,shift(@TX)); push(@XX,shift(@XX)); # "rotate" registers
141 stc $TX[0],2($YY,$key)
142 stc $TY,2($XX[0],$key)
150 llgc $TX[0],2($XX[0],$key)
160 lm${g} %r6,%r11,6*$SIZE_T($sp)
163 .string "RC4 for s390x, CRYPTOGAMS by <appro\@openssl.org>"
168 # void RC4_set_key(RC4_KEY *key,unsigned int len,const void *inp)
182 .type RC4_set_key,\@function
185 stm${g} %r6,%r8,6*$SIZE_T($sp)
191 stc $idx,2($idx,$key)
201 llgc $acc,2+256($ikey,$key)
202 llgc $dat,0($iinp,$inp)
209 llgc $dat,2($idx,$key)
210 stc $dat,2+256-1($ikey,$key)
211 stc $acc,2($idx,$key)
218 lm${g} %r6,%r8,6*$SIZE_T($sp)
220 .size RC4_set_key,.-RC4_set_key
225 # const char *RC4_options()
228 .type RC4_options,\@function
233 .size RC4_options,.-RC4_options
237 .string "rc4(8x,char)"
241 close STDOUT; # force flush