Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/crypto/sha/asm/keccak1600-s390x.pl

raw
1 #!/usr/bin/env perl
2 # Copyright 2017-2026 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the Apache License 2.0 (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
8 #
9 # ====================================================================
10 # Written by Andy Polyakov, @dot-asm, initially for use in the OpenSSL
11 # project. The module is, however, dual licensed under OpenSSL and
12 # CRYPTOGAMS licenses depending on where you obtain it. For further
13 # details see https://github.com/dot-asm/cryptogams/.
14 # ====================================================================
15 #
16 # Keccak-1600 for s390x.
17 #
18 # June 2017.
19 #
20 # Below code is [lane complementing] KECCAK_2X implementation (see
21 # sha/keccak1600.c) with C[5] and D[5] held in register bank. Though
22 # instead of actually unrolling the loop pair-wise I simply flip
23 # pointers to T[][] and A[][] at the end of round. Since number of
24 # rounds is even, last round writes to A[][] and everything works out.
25 # In the nutshell it's transliteration of x86_64 module, because both
26 # architectures have similar capabilities/limitations. Performance
27 # measurement is problematic as I don't have access to an idle system.
28 # It looks like z13 processes one byte [out of long message] in ~14
29 # cycles. At least the result is consistent with estimate based on
30 # amount of instruction and assumed instruction issue rate. It's ~2.5x
31 # faster than compiler-generated code.
32
33 # $output is the last argument if it looks like a file (it has an extension)
34 # $flavour is the first argument if it doesn't look like a file
35 $output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
36 $flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
37
38 if ($flavour =~ /3[12]/) {
39 $SIZE_T=4;
40 $g="";
41 } else {
42 $SIZE_T=8;
43 $g="g";
44 }
45
46 $output and open STDOUT,">$output";
47
48 my @A = map([ 8*$_, 8*($_+1), 8*($_+2), 8*($_+3), 8*($_+4) ], (0,5,10,15,20));
49
50 my @C = map("%r$_",(0,1,5..7));
51 my @D = map("%r$_",(8..12));
52 my @T = map("%r$_",(13..14));
53 my ($src,$dst,$iotas) = map("%r$_",(2..4));
54 my $sp = "%r15";
55
56 $stdframe=16*$SIZE_T+4*8;
57 $frame=$stdframe+25*8;
58
59 my @rhotates = ([ 0, 1, 62, 28, 27 ],
60 [ 36, 44, 6, 55, 20 ],
61 [ 3, 10, 43, 25, 39 ],
62 [ 41, 45, 15, 21, 8 ],
63 [ 18, 2, 61, 56, 14 ]);
64
65 { my @C = @C; # copy, because we mess them up...
66 my @D = @D;
67
68 $code.=<<___;
69 .text
70 .machine "z10"
71
72 .type __KeccakF1600,\@function
73 .align 32
74 __KeccakF1600:
75 st${g} %r14,$SIZE_T*14($sp)
76 lg @C[0],$A[4][0]($src)
77 lg @C[1],$A[4][1]($src)
78 lg @C[2],$A[4][2]($src)
79 lg @C[3],$A[4][3]($src)
80 lg @C[4],$A[4][4]($src)
81 larl $iotas,iotas
82 j .Loop
83
84 .align 16
85 .Loop:
86 lg @D[0],$A[0][0]($src)
87 lg @D[1],$A[1][1]($src)
88 lg @D[2],$A[2][2]($src)
89 lg @D[3],$A[3][3]($src)
90
91 xgr @C[0],@D[0]
92 xg @C[1],$A[0][1]($src)
93 xg @C[2],$A[0][2]($src)
94 xg @C[3],$A[0][3]($src)
95 lgr @D[4],@C[4]
96 xg @C[4],$A[0][4]($src)
97
98 xg @C[0],$A[1][0]($src)
99 xgr @C[1],@D[1]
100 xg @C[2],$A[1][2]($src)
101 xg @C[3],$A[1][3]($src)
102 xg @C[4],$A[1][4]($src)
103
104 xg @C[0],$A[2][0]($src)
105 xg @C[1],$A[2][1]($src)
106 xgr @C[2],@D[2]
107 xg @C[3],$A[2][3]($src)
108 xg @C[4],$A[2][4]($src)
109
110 xg @C[0],$A[3][0]($src)
111 xg @C[1],$A[3][1]($src)
112 xg @C[2],$A[3][2]($src)
113 xgr @C[3],@D[3]
114 xg @C[4],$A[3][4]($src)
115
116 lgr @T[0],@C[2]
117 rllg @C[2],@C[2],1
118 xgr @C[2],@C[0] # D[1] = ROL64(C[2], 1) ^ C[0]
119
120 rllg @C[0],@C[0],1
121 xgr @C[0],@C[3] # D[4] = ROL64(C[0], 1) ^ C[3]
122
123 rllg @C[3],@C[3],1
124 xgr @C[3],@C[1] # D[2] = ROL64(C[3], 1) ^ C[1]
125
126 rllg @C[1],@C[1],1
127 xgr @C[1],@C[4] # D[0] = ROL64(C[1], 1) ^ C[4]
128
129 rllg @C[4],@C[4],1
130 xgr @C[4],@T[0] # D[3] = ROL64(C[4], 1) ^ C[2]
131 ___
132 (@D[0..4], @C) = (@C[1..4,0], @D);
133 $code.=<<___;
134 xgr @C[1],@D[1]
135 xgr @C[2],@D[2]
136 xgr @C[3],@D[3]
137 rllg @C[1],@C[1],$rhotates[1][1]
138 xgr @C[4],@D[4]
139 rllg @C[2],@C[2],$rhotates[2][2]
140 xgr @C[0],@D[0]
141
142 lgr @T[0],@C[1]
143 ogr @C[1],@C[2]
144 rllg @C[3],@C[3],$rhotates[3][3]
145 xgr @C[1],@C[0] # C[0] ^ ( C[1] | C[2])
146 rllg @C[4],@C[4],$rhotates[4][4]
147 xg @C[1],0($iotas)
148 la $iotas,8($iotas)
149 stg @C[1],$A[0][0]($dst) # R[0][0] = C[0] ^ ( C[1] | C[2]) ^ iotas[i]
150
151 lgr @T[1],@C[4]
152 ngr @C[4],@C[3]
153 lghi @C[1],-1 # no 'not' instruction :-(
154 xgr @C[4],@C[2] # C[2] ^ ( C[4] & C[3])
155 xgr @C[2],@C[1] # not @C[2]
156 stg @C[4],$A[0][2]($dst) # R[0][2] = C[2] ^ ( C[4] & C[3])
157 ogr @C[2],@C[3]
158 xgr @C[2],@T[0] # C[1] ^ (~C[2] | C[3])
159
160 ngr @T[0],@C[0]
161 stg @C[2],$A[0][1]($dst) # R[0][1] = C[1] ^ (~C[2] | C[3])
162 xgr @T[0],@T[1] # C[4] ^ ( C[1] & C[0])
163 ogr @T[1],@C[0]
164 stg @T[0],$A[0][4]($dst) # R[0][4] = C[4] ^ ( C[1] & C[0])
165 xgr @T[1],@C[3] # C[3] ^ ( C[4] | C[0])
166 stg @T[1],$A[0][3]($dst) # R[0][3] = C[3] ^ ( C[4] | C[0])
167
168
169 lg @C[0],$A[0][3]($src)
170 lg @C[4],$A[4][2]($src)
171 lg @C[3],$A[3][1]($src)
172 lg @C[1],$A[1][4]($src)
173 lg @C[2],$A[2][0]($src)
174
175 xgr @C[0],@D[3]
176 xgr @C[4],@D[2]
177 rllg @C[0],@C[0],$rhotates[0][3]
178 xgr @C[3],@D[1]
179 rllg @C[4],@C[4],$rhotates[4][2]
180 xgr @C[1],@D[4]
181 rllg @C[3],@C[3],$rhotates[3][1]
182 xgr @C[2],@D[0]
183
184 lgr @T[0],@C[0]
185 ogr @C[0],@C[4]
186 rllg @C[1],@C[1],$rhotates[1][4]
187 xgr @C[0],@C[3] # C[3] ^ (C[0] | C[4])
188 rllg @C[2],@C[2],$rhotates[2][0]
189 stg @C[0],$A[1][3]($dst) # R[1][3] = C[3] ^ (C[0] | C[4])
190
191 lgr @T[1],@C[1]
192 ngr @C[1],@T[0]
193 lghi @C[0],-1 # no 'not' instruction :-(
194 xgr @C[1],@C[4] # C[4] ^ (C[1] & C[0])
195 xgr @C[4],@C[0] # not @C[4]
196 stg @C[1],$A[1][4]($dst) # R[1][4] = C[4] ^ (C[1] & C[0])
197
198 ogr @C[4],@C[3]
199 xgr @C[4],@C[2] # C[2] ^ (~C[4] | C[3])
200
201 ngr @C[3],@C[2]
202 stg @C[4],$A[1][2]($dst) # R[1][2] = C[2] ^ (~C[4] | C[3])
203 xgr @C[3],@T[1] # C[1] ^ (C[3] & C[2])
204 ogr @T[1],@C[2]
205 stg @C[3],$A[1][1]($dst) # R[1][1] = C[1] ^ (C[3] & C[2])
206 xgr @T[1],@T[0] # C[0] ^ (C[1] | C[2])
207 stg @T[1],$A[1][0]($dst) # R[1][0] = C[0] ^ (C[1] | C[2])
208
209
210 lg @C[2],$A[2][3]($src)
211 lg @C[3],$A[3][4]($src)
212 lg @C[1],$A[1][2]($src)
213 lg @C[4],$A[4][0]($src)
214 lg @C[0],$A[0][1]($src)
215
216 xgr @C[2],@D[3]
217 xgr @C[3],@D[4]
218 rllg @C[2],@C[2],$rhotates[2][3]
219 xgr @C[1],@D[2]
220 rllg @C[3],@C[3],$rhotates[3][4]
221 xgr @C[4],@D[0]
222 rllg @C[1],@C[1],$rhotates[1][2]
223 xgr @C[0],@D[1]
224
225 lgr @T[0],@C[2]
226 ngr @C[2],@C[3]
227 rllg @C[4],@C[4],$rhotates[4][0]
228 xgr @C[2],@C[1] # C[1] ^ ( C[2] & C[3])
229 lghi @T[1],-1 # no 'not' instruction :-(
230 stg @C[2],$A[2][1]($dst) # R[2][1] = C[1] ^ ( C[2] & C[3])
231
232 xgr @C[3],@T[1] # not @C[3]
233 lgr @T[1],@C[4]
234 ngr @C[4],@C[3]
235 rllg @C[0],@C[0],$rhotates[0][1]
236 xgr @C[4],@T[0] # C[2] ^ ( C[4] & ~C[3])
237 ogr @T[0],@C[1]
238 stg @C[4],$A[2][2]($dst) # R[2][2] = C[2] ^ ( C[4] & ~C[3])
239 xgr @T[0],@C[0] # C[0] ^ ( C[2] | C[1])
240
241 ngr @C[1],@C[0]
242 stg @T[0],$A[2][0]($dst) # R[2][0] = C[0] ^ ( C[2] | C[1])
243 xgr @C[1],@T[1] # C[4] ^ ( C[1] & C[0])
244 ogr @C[0],@T[1]
245 stg @C[1],$A[2][4]($dst) # R[2][4] = C[4] ^ ( C[1] & C[0])
246 xgr @C[0],@C[3] # ~C[3] ^ ( C[0] | C[4])
247 stg @C[0],$A[2][3]($dst) # R[2][3] = ~C[3] ^ ( C[0] | C[4])
248
249
250 lg @C[2],$A[2][1]($src)
251 lg @C[3],$A[3][2]($src)
252 lg @C[1],$A[1][0]($src)
253 lg @C[4],$A[4][3]($src)
254 lg @C[0],$A[0][4]($src)
255
256 xgr @C[2],@D[1]
257 xgr @C[3],@D[2]
258 rllg @C[2],@C[2],$rhotates[2][1]
259 xgr @C[1],@D[0]
260 rllg @C[3],@C[3],$rhotates[3][2]
261 xgr @C[4],@D[3]
262 rllg @C[1],@C[1],$rhotates[1][0]
263 xgr @C[0],@D[4]
264 rllg @C[4],@C[4],$rhotates[4][3]
265
266 lgr @T[0],@C[2]
267 ogr @C[2],@C[3]
268 lghi @T[1],-1 # no 'not' instruction :-(
269 xgr @C[2],@C[1] # C[1] ^ ( C[2] | C[3])
270 xgr @C[3],@T[1] # not @C[3]
271 stg @C[2],$A[3][1]($dst) # R[3][1] = C[1] ^ ( C[2] | C[3])
272
273 lgr @T[1],@C[4]
274 ogr @C[4],@C[3]
275 rllg @C[0],@C[0],$rhotates[0][4]
276 xgr @C[4],@T[0] # C[2] ^ ( C[4] | ~C[3])
277 ngr @T[0],@C[1]
278 stg @C[4],$A[3][2]($dst) # R[3][2] = C[2] ^ ( C[4] | ~C[3])
279 xgr @T[0],@C[0] # C[0] ^ ( C[2] & C[1])
280
281 ogr @C[1],@C[0]
282 stg @T[0],$A[3][0]($dst) # R[3][0] = C[0] ^ ( C[2] & C[1])
283 xgr @C[1],@T[1] # C[4] ^ ( C[1] | C[0])
284 ngr @C[0],@T[1]
285 stg @C[1],$A[3][4]($dst) # R[3][4] = C[4] ^ ( C[1] | C[0])
286 xgr @C[0],@C[3] # ~C[3] ^ ( C[0] & C[4])
287 stg @C[0],$A[3][3]($dst) # R[3][3] = ~C[3] ^ ( C[0] & C[4])
288
289
290 xg @D[2],$A[0][2]($src)
291 xg @D[3],$A[1][3]($src)
292 xg @D[1],$A[4][1]($src)
293 xg @D[4],$A[2][4]($src)
294 xgr $dst,$src # xchg $dst,$src
295 rllg @D[2],@D[2],$rhotates[0][2]
296 xg @D[0],$A[3][0]($src)
297 rllg @D[3],@D[3],$rhotates[1][3]
298 xgr $src,$dst
299 rllg @D[1],@D[1],$rhotates[4][1]
300 xgr $dst,$src
301 rllg @D[4],@D[4],$rhotates[2][4]
302 ___
303 @C = @D[2..4,0,1];
304 $code.=<<___;
305 lgr @T[0],@C[0]
306 ngr @C[0],@C[1]
307 lghi @T[1],-1 # no 'not' instruction :-(
308 xgr @C[0],@C[4] # C[4] ^ ( C[0] & C[1])
309 xgr @C[1],@T[1] # not @C[1]
310 stg @C[0],$A[4][4]($src) # R[4][4] = C[4] ^ ( C[0] & C[1])
311
312 lgr @T[1],@C[2]
313 ngr @C[2],@C[1]
314 rllg @D[0],@D[0],$rhotates[3][0]
315 xgr @C[2],@T[0] # C[0] ^ ( C[2] & ~C[1])
316 ogr @T[0],@C[4]
317 stg @C[2],$A[4][0]($src) # R[4][0] = C[0] ^ ( C[2] & ~C[1])
318 xgr @T[0],@C[3] # C[3] ^ ( C[0] | C[4])
319
320 ngr @C[4],@C[3]
321 stg @T[0],$A[4][3]($src) # R[4][3] = C[3] ^ ( C[0] | C[4])
322 xgr @C[4],@T[1] # C[2] ^ ( C[4] & C[3])
323 ogr @C[3],@T[1]
324 stg @C[4],$A[4][2]($src) # R[4][2] = C[2] ^ ( C[4] & C[3])
325 xgr @C[3],@C[1] # ~C[1] ^ ( C[2] | C[3])
326
327 lgr @C[1],@C[0] # harmonize with the loop top
328 lgr @C[0],@T[0]
329 stg @C[3],$A[4][1]($src) # R[4][1] = ~C[1] ^ ( C[2] | C[3])
330
331 tmll $iotas,255
332 jnz .Loop
333
334 l${g} %r14,$SIZE_T*14($sp)
335 br %r14
336 .size __KeccakF1600,.-__KeccakF1600
337 ___
338 }
339 {
340 $code.=<<___;
341 .type KeccakF1600,\@function
342 .align 32
343 KeccakF1600:
344 .LKeccakF1600:
345 lghi %r1,-$frame
346 stm${g} %r6,%r15,$SIZE_T*6($sp)
347 lgr %r0,$sp
348 la $sp,0(%r1,$sp)
349 st${g} %r0,0($sp)
350
351 lghi @D[0],-1 # no 'not' instruction :-(
352 lghi @D[1],-1
353 lghi @D[2],-1
354 lghi @D[3],-1
355 lghi @D[4],-1
356 lghi @T[0],-1
357 xg @D[0],$A[0][1]($src)
358 xg @D[1],$A[0][2]($src)
359 xg @D[2],$A[1][3]($src)
360 xg @D[3],$A[2][2]($src)
361 xg @D[4],$A[3][2]($src)
362 xg @T[0],$A[4][0]($src)
363 stmg @D[0],@D[1],$A[0][1]($src)
364 stg @D[2],$A[1][3]($src)
365 stg @D[3],$A[2][2]($src)
366 stg @D[4],$A[3][2]($src)
367 stg @T[0],$A[4][0]($src)
368
369 la $dst,$stdframe($sp)
370
371 bras %r14,__KeccakF1600
372
373 lghi @D[0],-1 # no 'not' instruction :-(
374 lghi @D[1],-1
375 lghi @D[2],-1
376 lghi @D[3],-1
377 lghi @D[4],-1
378 lghi @T[0],-1
379 xg @D[0],$A[0][1]($src)
380 xg @D[1],$A[0][2]($src)
381 xg @D[2],$A[1][3]($src)
382 xg @D[3],$A[2][2]($src)
383 xg @D[4],$A[3][2]($src)
384 xg @T[0],$A[4][0]($src)
385 stmg @D[0],@D[1],$A[0][1]($src)
386 stg @D[2],$A[1][3]($src)
387 stg @D[3],$A[2][2]($src)
388 stg @D[4],$A[3][2]($src)
389 stg @T[0],$A[4][0]($src)
390
391 lm${g} %r6,%r15,$frame+6*$SIZE_T($sp)
392 br %r14
393 .size KeccakF1600,.-KeccakF1600
394 ___
395 }
396 { my ($A_flat,$inp,$len,$bsz) = map("%r$_",(2..5));
397
398 $code.=<<___;
399 .globl SHA3_absorb
400 .type SHA3_absorb,\@function
401 .align 32
402 SHA3_absorb:
403 lghi %r1,-$frame
404 stm${g} %r5,%r15,$SIZE_T*5($sp)
405 lgr %r0,$sp
406 la $sp,0(%r1,$sp)
407 st${g} %r0,0($sp)
408
409 lghi @D[0],-1 # no 'not' instruction :-(
410 lghi @D[1],-1
411 lghi @D[2],-1
412 lghi @D[3],-1
413 lghi @D[4],-1
414 lghi @T[0],-1
415 xg @D[0],$A[0][1]($src)
416 xg @D[1],$A[0][2]($src)
417 xg @D[2],$A[1][3]($src)
418 xg @D[3],$A[2][2]($src)
419 xg @D[4],$A[3][2]($src)
420 xg @T[0],$A[4][0]($src)
421 stmg @D[0],@D[1],$A[0][1]($src)
422 stg @D[2],$A[1][3]($src)
423 stg @D[3],$A[2][2]($src)
424 stg @D[4],$A[3][2]($src)
425 stg @T[0],$A[4][0]($src)
426
427 .Loop_absorb:
428 cl${g}r $len,$bsz
429 jl .Ldone_absorb
430
431 srl${g} $bsz,3
432 la %r1,0($A_flat)
433
434 .Lblock_absorb:
435 lrvg %r0,0($inp)
436 la $inp,8($inp)
437 xg %r0,0(%r1)
438 a${g}hi $len,-8
439 stg %r0,0(%r1)
440 la %r1,8(%r1)
441 brct $bsz,.Lblock_absorb
442
443 stm${g} $inp,$len,$frame+3*$SIZE_T($sp)
444 la $dst,$stdframe($sp)
445 bras %r14,__KeccakF1600
446 lm${g} $inp,$bsz,$frame+3*$SIZE_T($sp)
447 j .Loop_absorb
448
449 .align 16
450 .Ldone_absorb:
451 lghi @D[0],-1 # no 'not' instruction :-(
452 lghi @D[1],-1
453 lghi @D[2],-1
454 lghi @D[3],-1
455 lghi @D[4],-1
456 lghi @T[0],-1
457 xg @D[0],$A[0][1]($src)
458 xg @D[1],$A[0][2]($src)
459 xg @D[2],$A[1][3]($src)
460 xg @D[3],$A[2][2]($src)
461 xg @D[4],$A[3][2]($src)
462 xg @T[0],$A[4][0]($src)
463 stmg @D[0],@D[1],$A[0][1]($src)
464 stg @D[2],$A[1][3]($src)
465 stg @D[3],$A[2][2]($src)
466 stg @D[4],$A[3][2]($src)
467 stg @T[0],$A[4][0]($src)
468
469 lgr %r2,$len # return value
470
471 lm${g} %r6,%r15,$frame+6*$SIZE_T($sp)
472 br %r14
473 .size SHA3_absorb,.-SHA3_absorb
474 ___
475 }
476 { my ($A_flat,$out,$len,$bsz,$next) = map("%r$_",(2..6));
477
478 $code.=<<___;
479 .globl SHA3_squeeze
480 .type SHA3_squeeze,\@function
481 .align 32
482 SHA3_squeeze:
483 srl${g} $bsz,3
484 st${g} %r14,2*$SIZE_T($sp)
485 lghi %r14,8
486 st${g} $bsz,5*$SIZE_T($sp)
487 la %r1,0($A_flat)
488 cijne $next,0,.Lnext_block
489
490 j .Loop_squeeze
491
492 .align 16
493 .Loop_squeeze:
494 cl${g}r $len,%r14
495 jl .Ltail_squeeze
496
497 lrvg %r0,0(%r1)
498 la %r1,8(%r1)
499 stg %r0,0($out)
500 la $out,8($out)
501 a${g}hi $len,-8 # len -= 8
502 jz .Ldone_squeeze
503
504 brct $bsz,.Loop_squeeze # bsz--
505
506 .Lnext_block:
507 stm${g} $out,$len,3*$SIZE_T($sp)
508 bras %r14,.LKeccakF1600
509 lm${g} $out,$bsz,3*$SIZE_T($sp)
510 lghi %r14,8
511 la %r1,0($A_flat)
512 j .Loop_squeeze
513
514 .Ltail_squeeze:
515 lg %r0,0(%r1)
516 .Loop_tail_squeeze:
517 stc %r0,0($out)
518 la $out,1($out)
519 srlg %r0,8
520 brct $len,.Loop_tail_squeeze
521
522 .Ldone_squeeze:
523 l${g} %r14,2*$SIZE_T($sp)
524 br %r14
525 .size SHA3_squeeze,.-SHA3_squeeze
526 ___
527 }
528 $code.=<<___;
529 .align 256
530 .quad 0,0,0,0,0,0,0,0
531 .type iotas,\@object
532 iotas:
533 .quad 0x0000000000000001
534 .quad 0x0000000000008082
535 .quad 0x800000000000808a
536 .quad 0x8000000080008000
537 .quad 0x000000000000808b
538 .quad 0x0000000080000001
539 .quad 0x8000000080008081
540 .quad 0x8000000000008009
541 .quad 0x000000000000008a
542 .quad 0x0000000000000088
543 .quad 0x0000000080008009
544 .quad 0x000000008000000a
545 .quad 0x000000008000808b
546 .quad 0x800000000000008b
547 .quad 0x8000000000008089
548 .quad 0x8000000000008003
549 .quad 0x8000000000008002
550 .quad 0x8000000000000080
551 .quad 0x000000000000800a
552 .quad 0x800000008000000a
553 .quad 0x8000000080008081
554 .quad 0x8000000000008080
555 .quad 0x0000000080000001
556 .quad 0x8000000080008008
557 .size iotas,.-iotas
558 .asciz "Keccak-1600 absorb and squeeze for s390x, CRYPTOGAMS by <https://github.com/dot-asm>"
559 ___
560
561 # unlike 32-bit shift 64-bit one takes three arguments
562 $code =~ s/(srlg\s+)(%r[0-9]+),/$1$2,$2,/gm;
563
564 print $code;
565 close STDOUT or die "error closing STDOUT: $!";