poly1305/asm/poly1305-x86_64.pl: switch to vpermdd in table expansion.
[openssl.git] / crypto / poly1305 / asm / poly1305-sparcv9.pl
index f0ce259c02cfe5e0a9a4398fd25e5ee15917a659..0bdd04892544a0787d6c58a62451a1792e9f9486 100755 (executable)
@@ -1,4 +1,11 @@
-#!/usr/bin/env perl
+#! /usr/bin/env perl
+# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (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
+
 #
 # ====================================================================
 # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
 #
 #                      IALU(*)         FMA
 #
-# UltraSPARC III       11.9(**)
-# SPARC T3             7.85
-# SPARC T4             1.67(***)       6.55
-# SPARC64 X            5.54            3.64
+# UltraSPARC III       12.3(**)
+# SPARC T3             7.92
+# SPARC T4             1.70(***)       6.55
+# SPARC64 X            5.60            3.64
 #
 # (*)  Comparison to compiler-generated code is really problematic,
 #      because latter's performance varies too much depending on too
@@ -42,6 +49,9 @@ my ($r0,$r1,$r2,$r3,$s1,$s2,$s3,$h4)  = map("%l$_",(0..7));
 my ($h0,$h1,$h2,$h3, $t0,$t1,$t2)      = map("%o$_",(0..5,7));
 my ($d0,$d1,$d2,$d3)                   = map("%g$_",(1..4));
 
+my $output = pop;
+open STDOUT,">$stdout";
+
 $code.=<<___;
 #include "sparc_arch.h"
 
@@ -71,8 +81,8 @@ poly1305_init:
        SPARC_LOAD_ADDRESS(OPENSSL_sparcv9cap_P,%g1)
        ld      [%g1],%g1
 
-       and     %g1,SPARCV9_FMADD|SPARCV9_PREFER_FPU|SPARCV9_VIS3,%g1
-       cmp     %g1,SPARCV9_FMADD|SPARCV9_PREFER_FPU
+       and     %g1,SPARCV9_FMADD|SPARCV9_VIS3,%g1
+       cmp     %g1,SPARCV9_FMADD
        be      .Lpoly1305_init_fma
        nop
 
@@ -129,13 +139,14 @@ poly1305_init:
 .Lno_key:
        ret
        restore %g0,%g0,%o0             ! return 0
+.type  poly1305_init,#function
 .size  poly1305_init,.-poly1305_init
 
 .globl poly1305_blocks
 .align 32
 poly1305_blocks:
        save    %sp,-STACK_FRAME,%sp
-       andn    $len,15,$len
+       srln    $len,4,$len
 
        brz,pn  $len,.Lno_data
        nop
@@ -191,7 +202,7 @@ poly1305_blocks:
        umul    $r1,$h0,$d1
        umul    $r2,$h0,$d2
        umul    $r3,$h0,$d3
-        sub    $len,16,$len
+        sub    $len,1,$len
         add    $inp,16,$inp
 
        umul    $s3,$h1,$t0
@@ -248,8 +259,9 @@ poly1305_blocks:
        addcc   $t0,$d0,$h0
        addccc  %g0,$h1,$h1
        addccc  %g0,$h2,$h2
+       addccc  %g0,$h3,$h3
        brnz,pt $len,.Loop
-       addc    %g0,$h3,$h3
+       addc    %g0,$h4,$h4
 
        st      $h1,[$ctx+0]            ! store hash value
        st      $h0,[$ctx+4]
@@ -260,6 +272,7 @@ poly1305_blocks:
 .Lno_data:
        ret
        restore
+.type  poly1305_blocks,#function
 .size  poly1305_blocks,.-poly1305_blocks
 ___
 ########################################################################
@@ -272,7 +285,7 @@ $code.=<<___;
 .align 32
 poly1305_blocks_vis3:
        save    %sp,-STACK_FRAME,%sp
-       andn    $len,15,$len
+       srln    $len,4,$len
 
        brz,pn  $len,.Lno_data
        nop
@@ -292,6 +305,7 @@ poly1305_blocks_vis3:
        neg     $shr,$shl
 
        srlx    $R1,2,$S1
+       b       .Loop_vis3
        add     $R1,$S1,$S1
 
 .Loop_vis3:
@@ -309,7 +323,7 @@ poly1305_blocks_vis3:
 
 .Linp_aligned_vis3:
        addcc   $D0,$H0,$H0             ! accumulate input
-        sub    $len,16,$len
+        sub    $len,1,$len
        addxccc $D1,$H1,$H1
         add    $inp,16,$inp
 
@@ -339,8 +353,9 @@ poly1305_blocks_vis3:
        add     $T1,$T0,$T0
 
        addcc   $T0,$D0,$H0
+       addxccc %g0,$D1,$H1
        brnz,pt $len,.Loop_vis3
-       addxc   %g0,$D1,$H1
+       addxc   %g0,$H2,$H2
 
        stx     $H0,[$ctx+0]            ! store hash value
        stx     $H1,[$ctx+8]
@@ -348,6 +363,7 @@ poly1305_blocks_vis3:
 
        ret
        restore
+.type  poly1305_blocks_vis3,#function
 .size  poly1305_blocks_vis3,.-poly1305_blocks_vis3
 ___
 }
@@ -420,6 +436,7 @@ poly1305_emit:
 
        ret
        restore
+.type  poly1305_emit,#function
 .size  poly1305_emit,.-poly1305_emit
 ___
 
@@ -585,12 +602,13 @@ poly1305_init_fma:
 .Lno_key_fma:
        ret
        restore %g0,%g0,%o0                     ! return 0
+.type  poly1305_init_fma,#function
 .size  poly1305_init_fma,.-poly1305_init_fma
 
 .align 32
 poly1305_blocks_fma:
        save    %sp,-STACK_FRAME-48,%sp
-       srlx    $len,4,$len
+       srln    $len,4,$len
 
        brz,pn  $len,.Labort
        sub     $len,1,$len
@@ -892,6 +910,7 @@ poly1305_blocks_fma:
 .Labort:
        ret
        restore
+.type  poly1305_blocks_fma,#function
 .size  poly1305_blocks_fma,.-poly1305_blocks_fma
 ___
 {
@@ -998,6 +1017,7 @@ poly1305_emit_fma:
 
        ret
        restore
+.type  poly1305_emit_fma,#function
 .size  poly1305_emit_fma,.-poly1305_emit_fma
 ___
 }