1e1051a39Sopenharmony_ci#! /usr/bin/env perl
2e1051a39Sopenharmony_ci# Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
3e1051a39Sopenharmony_ci#
4e1051a39Sopenharmony_ci# Licensed under the Apache License 2.0 (the "License").  You may not use
5e1051a39Sopenharmony_ci# this file except in compliance with the License.  You can obtain a copy
6e1051a39Sopenharmony_ci# in the file LICENSE in the source distribution or at
7e1051a39Sopenharmony_ci# https://www.openssl.org/source/license.html
8e1051a39Sopenharmony_ci
9e1051a39Sopenharmony_ci
10e1051a39Sopenharmony_ci# ====================================================================
11e1051a39Sopenharmony_ci# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
12e1051a39Sopenharmony_ci# project. The module is, however, dual licensed under OpenSSL and
13e1051a39Sopenharmony_ci# CRYPTOGAMS licenses depending on where you obtain it. For further
14e1051a39Sopenharmony_ci# details see http://www.openssl.org/~appro/cryptogams/.
15e1051a39Sopenharmony_ci# ====================================================================
16e1051a39Sopenharmony_ci
17e1051a39Sopenharmony_ci# SHA256/512 block procedures for s390x.
18e1051a39Sopenharmony_ci
19e1051a39Sopenharmony_ci# April 2007.
20e1051a39Sopenharmony_ci#
21e1051a39Sopenharmony_ci# sha256_block_data_order is reportedly >3 times faster than gcc 3.3
22e1051a39Sopenharmony_ci# generated code (must be a bug in compiler, as improvement is
23e1051a39Sopenharmony_ci# "pathologically" high, in particular in comparison to other SHA
24e1051a39Sopenharmony_ci# modules). But the real twist is that it detects if hardware support
25e1051a39Sopenharmony_ci# for SHA256 is available and in such case utilizes it. Then the
26e1051a39Sopenharmony_ci# performance can reach >6.5x of assembler one for larger chunks.
27e1051a39Sopenharmony_ci#
28e1051a39Sopenharmony_ci# sha512_block_data_order is ~70% faster than gcc 3.3 generated code.
29e1051a39Sopenharmony_ci
30e1051a39Sopenharmony_ci# January 2009.
31e1051a39Sopenharmony_ci#
32e1051a39Sopenharmony_ci# Add support for hardware SHA512 and reschedule instructions to
33e1051a39Sopenharmony_ci# favour dual-issue z10 pipeline. Hardware SHA256/512 is ~4.7x faster
34e1051a39Sopenharmony_ci# than software.
35e1051a39Sopenharmony_ci
36e1051a39Sopenharmony_ci# November 2010.
37e1051a39Sopenharmony_ci#
38e1051a39Sopenharmony_ci# Adapt for -m31 build. If kernel supports what's called "highgprs"
39e1051a39Sopenharmony_ci# feature on Linux [see /proc/cpuinfo], it's possible to use 64-bit
40e1051a39Sopenharmony_ci# instructions and achieve "64-bit" performance even in 31-bit legacy
41e1051a39Sopenharmony_ci# application context. The feature is not specific to any particular
42e1051a39Sopenharmony_ci# processor, as long as it's "z-CPU". Latter implies that the code
43e1051a39Sopenharmony_ci# remains z/Architecture specific. On z990 SHA256 was measured to
44e1051a39Sopenharmony_ci# perform 2.4x and SHA512 - 13x better than code generated by gcc 4.3.
45e1051a39Sopenharmony_ci
46e1051a39Sopenharmony_ci# $output is the last argument if it looks like a file (it has an extension)
47e1051a39Sopenharmony_ci# $flavour is the first argument if it doesn't look like a file
48e1051a39Sopenharmony_ci$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
49e1051a39Sopenharmony_ci$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
50e1051a39Sopenharmony_ci
51e1051a39Sopenharmony_ciif ($flavour =~ /3[12]/) {
52e1051a39Sopenharmony_ci	$SIZE_T=4;
53e1051a39Sopenharmony_ci	$g="";
54e1051a39Sopenharmony_ci} else {
55e1051a39Sopenharmony_ci	$SIZE_T=8;
56e1051a39Sopenharmony_ci	$g="g";
57e1051a39Sopenharmony_ci}
58e1051a39Sopenharmony_ci
59e1051a39Sopenharmony_ci$t0="%r0";
60e1051a39Sopenharmony_ci$t1="%r1";
61e1051a39Sopenharmony_ci$ctx="%r2";	$t2="%r2";
62e1051a39Sopenharmony_ci$inp="%r3";
63e1051a39Sopenharmony_ci$len="%r4";	# used as index in inner loop
64e1051a39Sopenharmony_ci
65e1051a39Sopenharmony_ci$A="%r5";
66e1051a39Sopenharmony_ci$B="%r6";
67e1051a39Sopenharmony_ci$C="%r7";
68e1051a39Sopenharmony_ci$D="%r8";
69e1051a39Sopenharmony_ci$E="%r9";
70e1051a39Sopenharmony_ci$F="%r10";
71e1051a39Sopenharmony_ci$G="%r11";
72e1051a39Sopenharmony_ci$H="%r12";	@V=($A,$B,$C,$D,$E,$F,$G,$H);
73e1051a39Sopenharmony_ci$tbl="%r13";
74e1051a39Sopenharmony_ci$T1="%r14";
75e1051a39Sopenharmony_ci$sp="%r15";
76e1051a39Sopenharmony_ci
77e1051a39Sopenharmony_ciopen STDOUT,">$output";
78e1051a39Sopenharmony_ci
79e1051a39Sopenharmony_ciif ($output =~ /512/) {
80e1051a39Sopenharmony_ci	$label="512";
81e1051a39Sopenharmony_ci	$SZ=8;
82e1051a39Sopenharmony_ci	$LD="lg";	# load from memory
83e1051a39Sopenharmony_ci	$ST="stg";	# store to memory
84e1051a39Sopenharmony_ci	$ADD="alg";	# add with memory operand
85e1051a39Sopenharmony_ci	$ROT="rllg";	# rotate left
86e1051a39Sopenharmony_ci	$SHR="srlg";	# logical right shift [see even at the end]
87e1051a39Sopenharmony_ci	@Sigma0=(25,30,36);
88e1051a39Sopenharmony_ci	@Sigma1=(23,46,50);
89e1051a39Sopenharmony_ci	@sigma0=(56,63, 7);
90e1051a39Sopenharmony_ci	@sigma1=( 3,45, 6);
91e1051a39Sopenharmony_ci	$rounds=80;
92e1051a39Sopenharmony_ci	$kimdfunc=3;	# 0 means unknown/unsupported/unimplemented/disabled
93e1051a39Sopenharmony_ci} else {
94e1051a39Sopenharmony_ci	$label="256";
95e1051a39Sopenharmony_ci	$SZ=4;
96e1051a39Sopenharmony_ci	$LD="llgf";	# load from memory
97e1051a39Sopenharmony_ci	$ST="st";	# store to memory
98e1051a39Sopenharmony_ci	$ADD="al";	# add with memory operand
99e1051a39Sopenharmony_ci	$ROT="rll";	# rotate left
100e1051a39Sopenharmony_ci	$SHR="srl";	# logical right shift
101e1051a39Sopenharmony_ci	@Sigma0=(10,19,30);
102e1051a39Sopenharmony_ci	@Sigma1=( 7,21,26);
103e1051a39Sopenharmony_ci	@sigma0=(14,25, 3);
104e1051a39Sopenharmony_ci	@sigma1=(13,15,10);
105e1051a39Sopenharmony_ci	$rounds=64;
106e1051a39Sopenharmony_ci	$kimdfunc=2;	# magic function code for kimd instruction
107e1051a39Sopenharmony_ci}
108e1051a39Sopenharmony_ci$Func="sha${label}_block_data_order";
109e1051a39Sopenharmony_ci$Table="K${label}";
110e1051a39Sopenharmony_ci$stdframe=16*$SIZE_T+4*8;
111e1051a39Sopenharmony_ci$frame=$stdframe+16*$SZ;
112e1051a39Sopenharmony_ci
113e1051a39Sopenharmony_cisub BODY_00_15 {
114e1051a39Sopenharmony_cimy ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_;
115e1051a39Sopenharmony_ci
116e1051a39Sopenharmony_ci$code.=<<___ if ($i<16);
117e1051a39Sopenharmony_ci	$LD	$T1,`$i*$SZ`($inp)	### $i
118e1051a39Sopenharmony_ci___
119e1051a39Sopenharmony_ci$code.=<<___;
120e1051a39Sopenharmony_ci	$ROT	$t0,$e,$Sigma1[0]
121e1051a39Sopenharmony_ci	$ROT	$t1,$e,$Sigma1[1]
122e1051a39Sopenharmony_ci	 lgr	$t2,$f
123e1051a39Sopenharmony_ci	xgr	$t0,$t1
124e1051a39Sopenharmony_ci	$ROT	$t1,$t1,`$Sigma1[2]-$Sigma1[1]`
125e1051a39Sopenharmony_ci	 xgr	$t2,$g
126e1051a39Sopenharmony_ci	$ST	$T1,`$stdframe+$SZ*($i%16)`($sp)
127e1051a39Sopenharmony_ci	xgr	$t0,$t1			# Sigma1(e)
128e1051a39Sopenharmony_ci	algr	$T1,$h			# T1+=h
129e1051a39Sopenharmony_ci	 ngr	$t2,$e
130e1051a39Sopenharmony_ci	 lgr	$t1,$a
131e1051a39Sopenharmony_ci	algr	$T1,$t0			# T1+=Sigma1(e)
132e1051a39Sopenharmony_ci	$ROT	$h,$a,$Sigma0[0]
133e1051a39Sopenharmony_ci	 xgr	$t2,$g			# Ch(e,f,g)
134e1051a39Sopenharmony_ci	$ADD	$T1,`$i*$SZ`($len,$tbl)	# T1+=K[i]
135e1051a39Sopenharmony_ci	$ROT	$t0,$a,$Sigma0[1]
136e1051a39Sopenharmony_ci	algr	$T1,$t2			# T1+=Ch(e,f,g)
137e1051a39Sopenharmony_ci	 ogr	$t1,$b
138e1051a39Sopenharmony_ci	xgr	$h,$t0
139e1051a39Sopenharmony_ci	 lgr	$t2,$a
140e1051a39Sopenharmony_ci	 ngr	$t1,$c
141e1051a39Sopenharmony_ci	$ROT	$t0,$t0,`$Sigma0[2]-$Sigma0[1]`
142e1051a39Sopenharmony_ci	xgr	$h,$t0			# h=Sigma0(a)
143e1051a39Sopenharmony_ci	 ngr	$t2,$b
144e1051a39Sopenharmony_ci	algr	$h,$T1			# h+=T1
145e1051a39Sopenharmony_ci	 ogr	$t2,$t1			# Maj(a,b,c)
146e1051a39Sopenharmony_ci	algr	$d,$T1			# d+=T1
147e1051a39Sopenharmony_ci	algr	$h,$t2			# h+=Maj(a,b,c)
148e1051a39Sopenharmony_ci___
149e1051a39Sopenharmony_ci}
150e1051a39Sopenharmony_ci
151e1051a39Sopenharmony_cisub BODY_16_XX {
152e1051a39Sopenharmony_cimy ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_;
153e1051a39Sopenharmony_ci
154e1051a39Sopenharmony_ci$code.=<<___;
155e1051a39Sopenharmony_ci	$LD	$T1,`$stdframe+$SZ*(($i+1)%16)`($sp)	### $i
156e1051a39Sopenharmony_ci	$LD	$t1,`$stdframe+$SZ*(($i+14)%16)`($sp)
157e1051a39Sopenharmony_ci	$ROT	$t0,$T1,$sigma0[0]
158e1051a39Sopenharmony_ci	$SHR	$T1,$sigma0[2]
159e1051a39Sopenharmony_ci	$ROT	$t2,$t0,`$sigma0[1]-$sigma0[0]`
160e1051a39Sopenharmony_ci	xgr	$T1,$t0
161e1051a39Sopenharmony_ci	$ROT	$t0,$t1,$sigma1[0]
162e1051a39Sopenharmony_ci	xgr	$T1,$t2					# sigma0(X[i+1])
163e1051a39Sopenharmony_ci	$SHR	$t1,$sigma1[2]
164e1051a39Sopenharmony_ci	$ADD	$T1,`$stdframe+$SZ*($i%16)`($sp)	# +=X[i]
165e1051a39Sopenharmony_ci	xgr	$t1,$t0
166e1051a39Sopenharmony_ci	$ROT	$t0,$t0,`$sigma1[1]-$sigma1[0]`
167e1051a39Sopenharmony_ci	$ADD	$T1,`$stdframe+$SZ*(($i+9)%16)`($sp)	# +=X[i+9]
168e1051a39Sopenharmony_ci	xgr	$t1,$t0				# sigma1(X[i+14])
169e1051a39Sopenharmony_ci	algr	$T1,$t1				# +=sigma1(X[i+14])
170e1051a39Sopenharmony_ci___
171e1051a39Sopenharmony_ci	&BODY_00_15(@_);
172e1051a39Sopenharmony_ci}
173e1051a39Sopenharmony_ci
174e1051a39Sopenharmony_ci$code.=<<___;
175e1051a39Sopenharmony_ci#include "s390x_arch.h"
176e1051a39Sopenharmony_ci
177e1051a39Sopenharmony_ci.text
178e1051a39Sopenharmony_ci.align	64
179e1051a39Sopenharmony_ci.type	$Table,\@object
180e1051a39Sopenharmony_ci$Table:
181e1051a39Sopenharmony_ci___
182e1051a39Sopenharmony_ci$code.=<<___ if ($SZ==4);
183e1051a39Sopenharmony_ci	.long	0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5
184e1051a39Sopenharmony_ci	.long	0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5
185e1051a39Sopenharmony_ci	.long	0xd807aa98,0x12835b01,0x243185be,0x550c7dc3
186e1051a39Sopenharmony_ci	.long	0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174
187e1051a39Sopenharmony_ci	.long	0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc
188e1051a39Sopenharmony_ci	.long	0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da
189e1051a39Sopenharmony_ci	.long	0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7
190e1051a39Sopenharmony_ci	.long	0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967
191e1051a39Sopenharmony_ci	.long	0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13
192e1051a39Sopenharmony_ci	.long	0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85
193e1051a39Sopenharmony_ci	.long	0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3
194e1051a39Sopenharmony_ci	.long	0xd192e819,0xd6990624,0xf40e3585,0x106aa070
195e1051a39Sopenharmony_ci	.long	0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5
196e1051a39Sopenharmony_ci	.long	0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3
197e1051a39Sopenharmony_ci	.long	0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208
198e1051a39Sopenharmony_ci	.long	0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
199e1051a39Sopenharmony_ci___
200e1051a39Sopenharmony_ci$code.=<<___ if ($SZ==8);
201e1051a39Sopenharmony_ci	.quad	0x428a2f98d728ae22,0x7137449123ef65cd
202e1051a39Sopenharmony_ci	.quad	0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc
203e1051a39Sopenharmony_ci	.quad	0x3956c25bf348b538,0x59f111f1b605d019
204e1051a39Sopenharmony_ci	.quad	0x923f82a4af194f9b,0xab1c5ed5da6d8118
205e1051a39Sopenharmony_ci	.quad	0xd807aa98a3030242,0x12835b0145706fbe
206e1051a39Sopenharmony_ci	.quad	0x243185be4ee4b28c,0x550c7dc3d5ffb4e2
207e1051a39Sopenharmony_ci	.quad	0x72be5d74f27b896f,0x80deb1fe3b1696b1
208e1051a39Sopenharmony_ci	.quad	0x9bdc06a725c71235,0xc19bf174cf692694
209e1051a39Sopenharmony_ci	.quad	0xe49b69c19ef14ad2,0xefbe4786384f25e3
210e1051a39Sopenharmony_ci	.quad	0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65
211e1051a39Sopenharmony_ci	.quad	0x2de92c6f592b0275,0x4a7484aa6ea6e483
212e1051a39Sopenharmony_ci	.quad	0x5cb0a9dcbd41fbd4,0x76f988da831153b5
213e1051a39Sopenharmony_ci	.quad	0x983e5152ee66dfab,0xa831c66d2db43210
214e1051a39Sopenharmony_ci	.quad	0xb00327c898fb213f,0xbf597fc7beef0ee4
215e1051a39Sopenharmony_ci	.quad	0xc6e00bf33da88fc2,0xd5a79147930aa725
216e1051a39Sopenharmony_ci	.quad	0x06ca6351e003826f,0x142929670a0e6e70
217e1051a39Sopenharmony_ci	.quad	0x27b70a8546d22ffc,0x2e1b21385c26c926
218e1051a39Sopenharmony_ci	.quad	0x4d2c6dfc5ac42aed,0x53380d139d95b3df
219e1051a39Sopenharmony_ci	.quad	0x650a73548baf63de,0x766a0abb3c77b2a8
220e1051a39Sopenharmony_ci	.quad	0x81c2c92e47edaee6,0x92722c851482353b
221e1051a39Sopenharmony_ci	.quad	0xa2bfe8a14cf10364,0xa81a664bbc423001
222e1051a39Sopenharmony_ci	.quad	0xc24b8b70d0f89791,0xc76c51a30654be30
223e1051a39Sopenharmony_ci	.quad	0xd192e819d6ef5218,0xd69906245565a910
224e1051a39Sopenharmony_ci	.quad	0xf40e35855771202a,0x106aa07032bbd1b8
225e1051a39Sopenharmony_ci	.quad	0x19a4c116b8d2d0c8,0x1e376c085141ab53
226e1051a39Sopenharmony_ci	.quad	0x2748774cdf8eeb99,0x34b0bcb5e19b48a8
227e1051a39Sopenharmony_ci	.quad	0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb
228e1051a39Sopenharmony_ci	.quad	0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3
229e1051a39Sopenharmony_ci	.quad	0x748f82ee5defb2fc,0x78a5636f43172f60
230e1051a39Sopenharmony_ci	.quad	0x84c87814a1f0ab72,0x8cc702081a6439ec
231e1051a39Sopenharmony_ci	.quad	0x90befffa23631e28,0xa4506cebde82bde9
232e1051a39Sopenharmony_ci	.quad	0xbef9a3f7b2c67915,0xc67178f2e372532b
233e1051a39Sopenharmony_ci	.quad	0xca273eceea26619c,0xd186b8c721c0c207
234e1051a39Sopenharmony_ci	.quad	0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178
235e1051a39Sopenharmony_ci	.quad	0x06f067aa72176fba,0x0a637dc5a2c898a6
236e1051a39Sopenharmony_ci	.quad	0x113f9804bef90dae,0x1b710b35131c471b
237e1051a39Sopenharmony_ci	.quad	0x28db77f523047d84,0x32caab7b40c72493
238e1051a39Sopenharmony_ci	.quad	0x3c9ebe0a15c9bebc,0x431d67c49c100d4c
239e1051a39Sopenharmony_ci	.quad	0x4cc5d4becb3e42b6,0x597f299cfc657e2a
240e1051a39Sopenharmony_ci	.quad	0x5fcb6fab3ad6faec,0x6c44198c4a475817
241e1051a39Sopenharmony_ci___
242e1051a39Sopenharmony_ci$code.=<<___;
243e1051a39Sopenharmony_ci.size	$Table,.-$Table
244e1051a39Sopenharmony_ci.globl	$Func
245e1051a39Sopenharmony_ci.type	$Func,\@function
246e1051a39Sopenharmony_ci$Func:
247e1051a39Sopenharmony_ci	sllg	$len,$len,`log(16*$SZ)/log(2)`
248e1051a39Sopenharmony_ci___
249e1051a39Sopenharmony_ci$code.=<<___ if ($kimdfunc);
250e1051a39Sopenharmony_ci	larl	%r1,OPENSSL_s390xcap_P
251e1051a39Sopenharmony_ci	lg	%r0,S390X_KIMD(%r1)	# check kimd capabilities
252e1051a39Sopenharmony_ci	tmhh	%r0,`0x8000>>$kimdfunc`
253e1051a39Sopenharmony_ci	jz	.Lsoftware
254e1051a39Sopenharmony_ci	lghi	%r0,$kimdfunc
255e1051a39Sopenharmony_ci	lgr	%r1,$ctx
256e1051a39Sopenharmony_ci	lgr	%r2,$inp
257e1051a39Sopenharmony_ci	lgr	%r3,$len
258e1051a39Sopenharmony_ci	.long	0xb93e0002	# kimd %r0,%r2
259e1051a39Sopenharmony_ci	brc	1,.-4		# pay attention to "partial completion"
260e1051a39Sopenharmony_ci	br	%r14
261e1051a39Sopenharmony_ci.align	16
262e1051a39Sopenharmony_ci.Lsoftware:
263e1051a39Sopenharmony_ci___
264e1051a39Sopenharmony_ci$code.=<<___;
265e1051a39Sopenharmony_ci	lghi	%r1,-$frame
266e1051a39Sopenharmony_ci	la	$len,0($len,$inp)
267e1051a39Sopenharmony_ci	stm${g}	$ctx,%r15,`2*$SIZE_T`($sp)
268e1051a39Sopenharmony_ci	lgr	%r0,$sp
269e1051a39Sopenharmony_ci	la	$sp,0(%r1,$sp)
270e1051a39Sopenharmony_ci	st${g}	%r0,0($sp)
271e1051a39Sopenharmony_ci
272e1051a39Sopenharmony_ci	larl	$tbl,$Table
273e1051a39Sopenharmony_ci	$LD	$A,`0*$SZ`($ctx)
274e1051a39Sopenharmony_ci	$LD	$B,`1*$SZ`($ctx)
275e1051a39Sopenharmony_ci	$LD	$C,`2*$SZ`($ctx)
276e1051a39Sopenharmony_ci	$LD	$D,`3*$SZ`($ctx)
277e1051a39Sopenharmony_ci	$LD	$E,`4*$SZ`($ctx)
278e1051a39Sopenharmony_ci	$LD	$F,`5*$SZ`($ctx)
279e1051a39Sopenharmony_ci	$LD	$G,`6*$SZ`($ctx)
280e1051a39Sopenharmony_ci	$LD	$H,`7*$SZ`($ctx)
281e1051a39Sopenharmony_ci
282e1051a39Sopenharmony_ci.Lloop:
283e1051a39Sopenharmony_ci	lghi	$len,0
284e1051a39Sopenharmony_ci___
285e1051a39Sopenharmony_cifor ($i=0;$i<16;$i++)	{ &BODY_00_15($i,@V); unshift(@V,pop(@V)); }
286e1051a39Sopenharmony_ci$code.=".Lrounds_16_xx:\n";
287e1051a39Sopenharmony_cifor (;$i<32;$i++)	{ &BODY_16_XX($i,@V); unshift(@V,pop(@V)); }
288e1051a39Sopenharmony_ci$code.=<<___;
289e1051a39Sopenharmony_ci	aghi	$len,`16*$SZ`
290e1051a39Sopenharmony_ci	lghi	$t0,`($rounds-16)*$SZ`
291e1051a39Sopenharmony_ci	clgr	$len,$t0
292e1051a39Sopenharmony_ci	jne	.Lrounds_16_xx
293e1051a39Sopenharmony_ci
294e1051a39Sopenharmony_ci	l${g}	$ctx,`$frame+2*$SIZE_T`($sp)
295e1051a39Sopenharmony_ci	la	$inp,`16*$SZ`($inp)
296e1051a39Sopenharmony_ci	$ADD	$A,`0*$SZ`($ctx)
297e1051a39Sopenharmony_ci	$ADD	$B,`1*$SZ`($ctx)
298e1051a39Sopenharmony_ci	$ADD	$C,`2*$SZ`($ctx)
299e1051a39Sopenharmony_ci	$ADD	$D,`3*$SZ`($ctx)
300e1051a39Sopenharmony_ci	$ADD	$E,`4*$SZ`($ctx)
301e1051a39Sopenharmony_ci	$ADD	$F,`5*$SZ`($ctx)
302e1051a39Sopenharmony_ci	$ADD	$G,`6*$SZ`($ctx)
303e1051a39Sopenharmony_ci	$ADD	$H,`7*$SZ`($ctx)
304e1051a39Sopenharmony_ci	$ST	$A,`0*$SZ`($ctx)
305e1051a39Sopenharmony_ci	$ST	$B,`1*$SZ`($ctx)
306e1051a39Sopenharmony_ci	$ST	$C,`2*$SZ`($ctx)
307e1051a39Sopenharmony_ci	$ST	$D,`3*$SZ`($ctx)
308e1051a39Sopenharmony_ci	$ST	$E,`4*$SZ`($ctx)
309e1051a39Sopenharmony_ci	$ST	$F,`5*$SZ`($ctx)
310e1051a39Sopenharmony_ci	$ST	$G,`6*$SZ`($ctx)
311e1051a39Sopenharmony_ci	$ST	$H,`7*$SZ`($ctx)
312e1051a39Sopenharmony_ci	cl${g}	$inp,`$frame+4*$SIZE_T`($sp)
313e1051a39Sopenharmony_ci	jne	.Lloop
314e1051a39Sopenharmony_ci
315e1051a39Sopenharmony_ci	lm${g}	%r6,%r15,`$frame+6*$SIZE_T`($sp)
316e1051a39Sopenharmony_ci	br	%r14
317e1051a39Sopenharmony_ci.size	$Func,.-$Func
318e1051a39Sopenharmony_ci.string	"SHA${label} block transform for s390x, CRYPTOGAMS by <appro\@openssl.org>"
319e1051a39Sopenharmony_ci___
320e1051a39Sopenharmony_ci
321e1051a39Sopenharmony_ci$code =~ s/\`([^\`]*)\`/eval $1/gem;
322e1051a39Sopenharmony_ci# unlike 32-bit shift 64-bit one takes three arguments
323e1051a39Sopenharmony_ci$code =~ s/(srlg\s+)(%r[0-9]+),/$1$2,$2,/gm;
324e1051a39Sopenharmony_ci
325e1051a39Sopenharmony_ciprint $code;
326e1051a39Sopenharmony_ciclose STDOUT or die "error closing STDOUT: $!";
327