Also check for errors in x86_64-xlate.pl.
[openssl.git] / crypto / aes / asm / aesp8-ppc.pl
index 0497953cf5a461c4cb8678465ff41f968b396fed..7bd5e9e3f0b5fd70146f3bc0345b1ec2d4c7865c 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env perl
-# Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
 #
-# Licensed under the OpenSSL license (the "License").  You may not use
+# Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
 # in the file LICENSE in the source distribution or at
 # https://www.openssl.org/source/license.html
 #              CBC en-/decrypt CTR     XTS
 # POWER8[le]   3.96/0.72       0.74    1.1
 # POWER8[be]   3.75/0.65       0.66    1.0
+# POWER9[le]   4.02/0.86       0.84    1.05
+# POWER9[be]   3.99/0.78       0.79    0.97
 
-$flavour = shift;
+# $output is the last argument if it looks like a file (it has an extension)
+# $flavour is the first argument if it doesn't look like a file
+$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
+$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
 
 if ($flavour =~ /64/) {
        $SIZE_T =8;
@@ -68,7 +73,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
 ( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
 die "can't locate ppc-xlate.pl";
 
-open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
+open STDOUT,"| $^X $xlate $flavour \"$output\""
+    or die "can't call $xlate: $!";
 
 $FRAME=8*$SIZE_T;
 $prefix="aes_p8";
@@ -1827,7 +1833,7 @@ Lctr32_enc8x_three:
        stvx_u          $out1,$x10,$out
        stvx_u          $out2,$x20,$out
        addi            $out,$out,0x30
-       b               Lcbc_dec8x_done
+       b               Lctr32_enc8x_done
 
 .align 5
 Lctr32_enc8x_two:
@@ -1839,7 +1845,7 @@ Lctr32_enc8x_two:
        stvx_u          $out0,$x00,$out
        stvx_u          $out1,$x10,$out
        addi            $out,$out,0x20
-       b               Lcbc_dec8x_done
+       b               Lctr32_enc8x_done
 
 .align 5
 Lctr32_enc8x_one:
@@ -3011,7 +3017,7 @@ _aesp8_xts_enc5x:
         vxor           $twk0,$twk0,v31
 
        vcipher         $out0,$out0,v26
-       lvsr            $inpperm,r0,$taillen    # $in5 is no more
+       lvsr            $inpperm,0,$taillen     # $in5 is no more
        vcipher         $out1,$out1,v26
        vcipher         $out2,$out2,v26
        vcipher         $out3,$out3,v26
@@ -3802,4 +3808,4 @@ foreach(split("\n",$code)) {
         print $_,"\n";
 }
 
-close STDOUT;
+close STDOUT or die "error closing STDOUT: $!";