2016-05-21 12:23:39 +00:00
|
|
|
|
#! /usr/bin/env perl
|
|
|
|
|
# Copyright 2005-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
|
|
|
|
|
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
# ====================================================================
|
2017-10-10 21:55:09 +00:00
|
|
|
|
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
|
2006-11-28 07:24:26 +00:00
|
|
|
|
# project. The module is, however, dual licensed under OpenSSL and
|
|
|
|
|
# CRYPTOGAMS licenses depending on where you obtain it. For further
|
|
|
|
|
# details see http://www.openssl.org/~appro/cryptogams/.
|
2005-10-19 07:12:06 +00:00
|
|
|
|
# ====================================================================
|
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
# October 2005
|
|
|
|
|
#
|
2005-10-19 07:12:06 +00:00
|
|
|
|
# "Teaser" Montgomery multiplication module for UltraSPARC. Why FPU?
|
|
|
|
|
# Because unlike integer multiplier, which simply stalls whole CPU,
|
|
|
|
|
# FPU is fully pipelined and can effectively emit 48 bit partial
|
|
|
|
|
# product every cycle. Why not blended SPARC v9? One can argue that
|
|
|
|
|
# making this module dependent on UltraSPARC VIS extension limits its
|
2005-10-25 15:39:47 +00:00
|
|
|
|
# binary compatibility. Well yes, it does exclude SPARC64 prior-V(!)
|
|
|
|
|
# implementations from compatibility matrix. But the rest, whole Sun
|
|
|
|
|
# UltraSPARC family and brand new Fujitsu's SPARC64 V, all support
|
|
|
|
|
# VIS extension instructions used in this module. This is considered
|
2006-11-28 11:07:36 +00:00
|
|
|
|
# good enough to not care about HAL SPARC64 users [if any] who have
|
|
|
|
|
# integer-only pure SPARCv9 module to "fall down" to.
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
# USI&II cores currently exhibit uniform 2x improvement [over pre-
|
|
|
|
|
# bn_mul_mont codebase] for all key lengths and benchmarks. On USIII
|
|
|
|
|
# performance improves few percents for shorter keys and worsens few
|
2005-10-22 18:16:09 +00:00
|
|
|
|
# percents for longer keys. This is because USIII integer multiplier
|
2005-10-19 07:12:06 +00:00
|
|
|
|
# is >3x faster than USI&II one, which is harder to match [but see
|
|
|
|
|
# TODO list below]. It should also be noted that SPARC64 V features
|
|
|
|
|
# out-of-order execution, which *might* mean that integer multiplier
|
2005-10-25 15:39:47 +00:00
|
|
|
|
# is pipelined, which in turn *might* be impossible to match... On
|
|
|
|
|
# additional note, SPARC64 V implements FP Multiply-Add instruction,
|
|
|
|
|
# which is perfectly usable in this context... In other words, as far
|
2006-11-28 11:07:36 +00:00
|
|
|
|
# as Fujitsu SPARC64 V goes, talk to the author:-)
|
2005-10-22 18:16:09 +00:00
|
|
|
|
|
2005-12-16 17:39:57 +00:00
|
|
|
|
# The implementation implies following "non-natural" limitations on
|
|
|
|
|
# input arguments:
|
2005-10-22 18:16:09 +00:00
|
|
|
|
# - num may not be less than 4;
|
|
|
|
|
# - num has to be even;
|
|
|
|
|
# Failure to meet either condition has no fatal effects, simply
|
|
|
|
|
# doesn't give any performance gain.
|
|
|
|
|
|
2005-10-19 07:12:06 +00:00
|
|
|
|
# TODO:
|
|
|
|
|
# - modulo-schedule inner loop for better performance (on in-order
|
|
|
|
|
# execution core such as UltraSPARC this shall result in further
|
|
|
|
|
# noticeable(!) improvement);
|
|
|
|
|
# - dedicated squaring procedure[?];
|
|
|
|
|
|
2006-11-28 07:24:26 +00:00
|
|
|
|
######################################################################
|
|
|
|
|
# November 2006
|
|
|
|
|
#
|
|
|
|
|
# Modulo-scheduled inner loops allow to interleave floating point and
|
|
|
|
|
# integer instructions and minimize Read-After-Write penalties. This
|
2016-08-05 17:56:58 +00:00
|
|
|
|
# results in *further* 20-50% performance improvement [depending on
|
2006-11-28 07:24:26 +00:00
|
|
|
|
# key length, more for longer keys] on USI&II cores and 30-80% - on
|
|
|
|
|
# USIII&IV.
|
|
|
|
|
|
2016-03-07 14:41:33 +00:00
|
|
|
|
$output = pop;
|
|
|
|
|
open STDOUT,">$output";
|
|
|
|
|
|
2005-12-16 17:39:57 +00:00
|
|
|
|
$fname="bn_mul_mont_fpu";
|
2016-03-08 08:46:19 +00:00
|
|
|
|
|
|
|
|
|
$frame="STACK_FRAME";
|
|
|
|
|
$bias="STACK_BIAS";
|
2005-10-19 07:12:06 +00:00
|
|
|
|
$locals=64;
|
|
|
|
|
|
|
|
|
|
# In order to provide for 32-/64-bit ABI duality, I keep integers wider
|
|
|
|
|
# than 32 bit in %g1-%g4 and %o0-%o5. %l0-%l7 and %i0-%i5 are used
|
|
|
|
|
# exclusively for pointers, indexes and other small values...
|
|
|
|
|
# int bn_mul_mont(
|
|
|
|
|
$rp="%i0"; # BN_ULONG *rp,
|
|
|
|
|
$ap="%i1"; # const BN_ULONG *ap,
|
|
|
|
|
$bp="%i2"; # const BN_ULONG *bp,
|
|
|
|
|
$np="%i3"; # const BN_ULONG *np,
|
2005-10-22 17:57:18 +00:00
|
|
|
|
$n0="%i4"; # const BN_ULONG *n0,
|
2005-10-19 07:12:06 +00:00
|
|
|
|
$num="%i5"; # int num);
|
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
$tp="%l0"; # t[num]
|
2005-10-19 07:12:06 +00:00
|
|
|
|
$ap_l="%l1"; # a[num],n[num] are smashed to 32-bit words and saved
|
|
|
|
|
$ap_h="%l2"; # to these four vectors as double-precision FP values.
|
|
|
|
|
$np_l="%l3"; # This way a bunch of fxtods are eliminated in second
|
|
|
|
|
$np_h="%l4"; # loop and L1-cache aliasing is minimized...
|
|
|
|
|
$i="%l5";
|
|
|
|
|
$j="%l6";
|
|
|
|
|
$mask="%l7"; # 16-bit mask, 0xffff
|
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
$n0="%g4"; # reassigned(!) to "64-bit" register
|
|
|
|
|
$carry="%i4"; # %i4 reused(!) for a carry bit
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
# FP register naming chart
|
|
|
|
|
#
|
|
|
|
|
# ..HILO
|
|
|
|
|
# dcba
|
|
|
|
|
# --------
|
|
|
|
|
# LOa
|
|
|
|
|
# LOb
|
|
|
|
|
# LOc
|
|
|
|
|
# LOd
|
|
|
|
|
# HIa
|
|
|
|
|
# HIb
|
|
|
|
|
# HIc
|
|
|
|
|
# HId
|
|
|
|
|
# ..a
|
|
|
|
|
# ..b
|
|
|
|
|
$ba="%f0"; $bb="%f2"; $bc="%f4"; $bd="%f6";
|
|
|
|
|
$na="%f8"; $nb="%f10"; $nc="%f12"; $nd="%f14";
|
|
|
|
|
$alo="%f16"; $alo_="%f17"; $ahi="%f18"; $ahi_="%f19";
|
|
|
|
|
$nlo="%f20"; $nlo_="%f21"; $nhi="%f22"; $nhi_="%f23";
|
|
|
|
|
|
|
|
|
|
$dota="%f24"; $dotb="%f26";
|
|
|
|
|
|
|
|
|
|
$aloa="%f32"; $alob="%f34"; $aloc="%f36"; $alod="%f38";
|
|
|
|
|
$ahia="%f40"; $ahib="%f42"; $ahic="%f44"; $ahid="%f46";
|
|
|
|
|
$nloa="%f48"; $nlob="%f50"; $nloc="%f52"; $nlod="%f54";
|
|
|
|
|
$nhia="%f56"; $nhib="%f58"; $nhic="%f60"; $nhid="%f62";
|
|
|
|
|
|
|
|
|
|
$ASI_FL16_P=0xD2; # magic ASI value to engage 16-bit FP load
|
|
|
|
|
|
|
|
|
|
$code=<<___;
|
2016-03-08 08:46:19 +00:00
|
|
|
|
#include "sparc_arch.h"
|
|
|
|
|
|
2005-10-19 07:12:06 +00:00
|
|
|
|
.section ".text",#alloc,#execinstr
|
|
|
|
|
|
|
|
|
|
.global $fname
|
|
|
|
|
.align 32
|
|
|
|
|
$fname:
|
2005-10-22 18:16:09 +00:00
|
|
|
|
save %sp,-$frame-$locals,%sp
|
2005-12-15 22:40:58 +00:00
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
cmp $num,4
|
|
|
|
|
bl,a,pn %icc,.Lret
|
|
|
|
|
clr %i0
|
|
|
|
|
andcc $num,1,%g0 ! $num has to be even...
|
|
|
|
|
bnz,a,pn %icc,.Lret
|
|
|
|
|
clr %i0 ! signal "unsupported input value"
|
2007-03-20 08:54:51 +00:00
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
srl $num,1,$num
|
2007-03-20 08:54:51 +00:00
|
|
|
|
sethi %hi(0xffff),$mask
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ld [%i4+0],$n0 ! $n0 reassigned, remember?
|
2007-03-20 08:54:51 +00:00
|
|
|
|
or $mask,%lo(0xffff),$mask
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ld [%i4+4],%o0
|
|
|
|
|
sllx %o0,32,%o0
|
|
|
|
|
or %o0,$n0,$n0 ! $n0=n0[1].n0[0]
|
2005-12-15 22:40:58 +00:00
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
sll $num,3,$num ! num*=8
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
add %sp,$bias,%o0 ! real top of stack
|
|
|
|
|
sll $num,2,%o1
|
|
|
|
|
add %o1,$num,%o1 ! %o1=num*5
|
|
|
|
|
sub %o0,%o1,%o0
|
|
|
|
|
and %o0,-2048,%o0 ! optimize TLB utilization
|
2005-10-22 18:16:09 +00:00
|
|
|
|
sub %o0,$bias,%sp ! alloca(5*num*8)
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
rd %asi,%o7 ! save %asi
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add %sp,$bias+$frame+$locals,$tp
|
|
|
|
|
add $tp,$num,$ap_l
|
2005-10-22 18:16:09 +00:00
|
|
|
|
add $ap_l,$num,$ap_l ! [an]p_[lh] point at the vectors' ends !
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add $ap_l,$num,$ap_h
|
|
|
|
|
add $ap_h,$num,$np_l
|
|
|
|
|
add $np_l,$num,$np_h
|
|
|
|
|
|
|
|
|
|
wr %g0,$ASI_FL16_P,%asi ! setup %asi for 16-bit FP loads
|
|
|
|
|
|
|
|
|
|
add $rp,$num,$rp ! readjust input pointers to point
|
|
|
|
|
add $ap,$num,$ap ! at the ends too...
|
|
|
|
|
add $bp,$num,$bp
|
|
|
|
|
add $np,$num,$np
|
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
stx %o7,[%sp+$bias+$frame+48] ! save %asi
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
2005-12-15 22:40:58 +00:00
|
|
|
|
sub %g0,$num,$i ! i=-num
|
|
|
|
|
sub %g0,$num,$j ! j=-num
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
add $ap,$j,%o3
|
|
|
|
|
add $bp,$i,%o4
|
2005-12-15 22:40:58 +00:00
|
|
|
|
|
2006-12-08 15:18:41 +00:00
|
|
|
|
ld [%o3+4],%g1 ! bp[0]
|
|
|
|
|
ld [%o3+0],%o0
|
|
|
|
|
ld [%o4+4],%g5 ! ap[0]
|
|
|
|
|
sllx %g1,32,%g1
|
|
|
|
|
ld [%o4+0],%o1
|
|
|
|
|
sllx %g5,32,%g5
|
2005-12-15 22:40:58 +00:00
|
|
|
|
or %g1,%o0,%o0
|
|
|
|
|
or %g5,%o1,%o1
|
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
add $np,$j,%o5
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
mulx %o1,%o0,%o0 ! ap[0]*bp[0]
|
|
|
|
|
mulx $n0,%o0,%o0 ! ap[0]*bp[0]*n0
|
2005-10-22 18:16:09 +00:00
|
|
|
|
stx %o0,[%sp+$bias+$frame+0]
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
2005-12-15 22:40:58 +00:00
|
|
|
|
ld [%o3+0],$alo_ ! load a[j] as pair of 32-bit words
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fzeros $alo
|
2005-12-15 22:40:58 +00:00
|
|
|
|
ld [%o3+4],$ahi_
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fzeros $ahi
|
2005-12-15 22:40:58 +00:00
|
|
|
|
ld [%o5+0],$nlo_ ! load n[j] as pair of 32-bit words
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fzeros $nlo
|
2005-12-15 22:40:58 +00:00
|
|
|
|
ld [%o5+4],$nhi_
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fzeros $nhi
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
! transfer b[i] to FPU as 4x16-bit values
|
2005-12-15 22:40:58 +00:00
|
|
|
|
ldda [%o4+2]%asi,$ba
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $alo,$alo
|
2005-12-15 22:40:58 +00:00
|
|
|
|
ldda [%o4+0]%asi,$bb
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $ahi,$ahi
|
2005-12-15 22:40:58 +00:00
|
|
|
|
ldda [%o4+6]%asi,$bc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $nlo,$nlo
|
2005-12-15 22:40:58 +00:00
|
|
|
|
ldda [%o4+4]%asi,$bd
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $nhi,$nhi
|
|
|
|
|
|
|
|
|
|
! transfer ap[0]*b[0]*n0 to FPU as 4x16-bit values
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ldda [%sp+$bias+$frame+6]%asi,$na
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $ba,$ba
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ldda [%sp+$bias+$frame+4]%asi,$nb
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $bb,$bb
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ldda [%sp+$bias+$frame+2]%asi,$nc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $bc,$bc
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ldda [%sp+$bias+$frame+0]%asi,$nd
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $bd,$bd
|
|
|
|
|
|
|
|
|
|
std $alo,[$ap_l+$j] ! save smashed ap[j] in double format
|
|
|
|
|
fxtod $na,$na
|
|
|
|
|
std $ahi,[$ap_h+$j]
|
|
|
|
|
fxtod $nb,$nb
|
|
|
|
|
std $nlo,[$np_l+$j] ! save smashed np[j] in double format
|
|
|
|
|
fxtod $nc,$nc
|
|
|
|
|
std $nhi,[$np_h+$j]
|
|
|
|
|
fxtod $nd,$nd
|
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $alo,$ba,$aloa
|
|
|
|
|
fmuld $nlo,$na,$nloa
|
|
|
|
|
fmuld $alo,$bb,$alob
|
|
|
|
|
fmuld $nlo,$nb,$nlob
|
|
|
|
|
fmuld $alo,$bc,$aloc
|
|
|
|
|
faddd $aloa,$nloa,$nloa
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nlo,$nc,$nloc
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $alo,$bd,$alod
|
|
|
|
|
faddd $alob,$nlob,$nlob
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nlo,$nd,$nlod
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$ba,$ahia
|
|
|
|
|
faddd $aloc,$nloc,$nloc
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$na,$nhia
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$bb,$ahib
|
|
|
|
|
faddd $alod,$nlod,$nlod
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$nb,$nhib
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$bc,$ahic
|
|
|
|
|
faddd $ahia,$nhia,$nhia
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$nc,$nhic
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$bd,$ahid
|
2005-12-15 22:40:58 +00:00
|
|
|
|
faddd $ahib,$nhib,$nhib
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $nhi,$nd,$nhid
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
faddd $ahic,$nhic,$dota ! $nhic
|
|
|
|
|
faddd $ahid,$nhid,$dotb ! $nhid
|
|
|
|
|
|
|
|
|
|
faddd $nloc,$nhia,$nloc
|
|
|
|
|
faddd $nlod,$nhib,$nlod
|
|
|
|
|
|
|
|
|
|
fdtox $nloa,$nloa
|
|
|
|
|
fdtox $nlob,$nlob
|
|
|
|
|
fdtox $nloc,$nloc
|
|
|
|
|
fdtox $nlod,$nlod
|
|
|
|
|
|
|
|
|
|
std $nloa,[%sp+$bias+$frame+0]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add $j,8,$j
|
2005-10-19 07:12:06 +00:00
|
|
|
|
std $nlob,[%sp+$bias+$frame+8]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add $ap,$j,%o4
|
2005-10-19 07:12:06 +00:00
|
|
|
|
std $nloc,[%sp+$bias+$frame+16]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add $np,$j,%o5
|
2005-10-19 07:12:06 +00:00
|
|
|
|
std $nlod,[%sp+$bias+$frame+24]
|
|
|
|
|
|
2006-11-28 07:20:36 +00:00
|
|
|
|
ld [%o4+0],$alo_ ! load a[j] as pair of 32-bit words
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fzeros $alo
|
2006-11-28 07:20:36 +00:00
|
|
|
|
ld [%o4+4],$ahi_
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fzeros $ahi
|
2006-11-28 07:20:36 +00:00
|
|
|
|
ld [%o5+0],$nlo_ ! load n[j] as pair of 32-bit words
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fzeros $nlo
|
2006-11-28 07:20:36 +00:00
|
|
|
|
ld [%o5+4],$nhi_
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fzeros $nhi
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
fxtod $alo,$alo
|
|
|
|
|
fxtod $ahi,$ahi
|
|
|
|
|
fxtod $nlo,$nlo
|
|
|
|
|
fxtod $nhi,$nhi
|
|
|
|
|
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+0],%o0
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $alo,$ba,$aloa
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+8],%o1
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $nlo,$na,$nloa
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+16],%o2
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $alo,$bb,$alob
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+24],%o3
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $nlo,$nb,$nlob
|
2006-11-28 07:24:26 +00:00
|
|
|
|
|
|
|
|
|
srlx %o0,16,%o7
|
|
|
|
|
std $alo,[$ap_l+$j] ! save smashed ap[j] in double format
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $alo,$bc,$aloc
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add %o7,%o1,%o1
|
|
|
|
|
std $ahi,[$ap_h+$j]
|
|
|
|
|
faddd $aloa,$nloa,$nloa
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nlo,$nc,$nloc
|
2006-11-28 07:24:26 +00:00
|
|
|
|
srlx %o1,16,%o7
|
|
|
|
|
std $nlo,[$np_l+$j] ! save smashed np[j] in double format
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $alo,$bd,$alod
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add %o7,%o2,%o2
|
|
|
|
|
std $nhi,[$np_h+$j]
|
|
|
|
|
faddd $alob,$nlob,$nlob
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nlo,$nd,$nlod
|
2006-11-28 07:24:26 +00:00
|
|
|
|
srlx %o2,16,%o7
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$ba,$ahia
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add %o7,%o3,%o3 ! %o3.%o2[0..15].%o1[0..15].%o0[0..15]
|
|
|
|
|
faddd $aloc,$nloc,$nloc
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$na,$nhia
|
2006-11-28 07:24:26 +00:00
|
|
|
|
!and %o0,$mask,%o0
|
|
|
|
|
!and %o1,$mask,%o1
|
|
|
|
|
!and %o2,$mask,%o2
|
|
|
|
|
!sllx %o1,16,%o1
|
|
|
|
|
!sllx %o2,32,%o2
|
|
|
|
|
!sllx %o3,48,%o7
|
|
|
|
|
!or %o1,%o0,%o0
|
|
|
|
|
!or %o2,%o0,%o0
|
|
|
|
|
!or %o7,%o0,%o0 ! 64-bit result
|
|
|
|
|
srlx %o3,16,%g1 ! 34-bit carry
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$bb,$ahib
|
2006-11-28 07:24:26 +00:00
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
faddd $alod,$nlod,$nlod
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$nb,$nhib
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$bc,$ahic
|
|
|
|
|
faddd $ahia,$nhia,$nhia
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$nc,$nhic
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$bd,$ahid
|
|
|
|
|
faddd $ahib,$nhib,$nhib
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$nd,$nhid
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
faddd $dota,$nloa,$nloa
|
|
|
|
|
faddd $dotb,$nlob,$nlob
|
|
|
|
|
faddd $ahic,$nhic,$dota ! $nhic
|
|
|
|
|
faddd $ahid,$nhid,$dotb ! $nhid
|
|
|
|
|
|
|
|
|
|
faddd $nloc,$nhia,$nloc
|
|
|
|
|
faddd $nlod,$nhib,$nlod
|
|
|
|
|
|
|
|
|
|
fdtox $nloa,$nloa
|
|
|
|
|
fdtox $nlob,$nlob
|
|
|
|
|
fdtox $nloc,$nloc
|
|
|
|
|
fdtox $nlod,$nlod
|
|
|
|
|
|
|
|
|
|
std $nloa,[%sp+$bias+$frame+0]
|
|
|
|
|
std $nlob,[%sp+$bias+$frame+8]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
addcc $j,8,$j
|
2005-10-19 07:12:06 +00:00
|
|
|
|
std $nloc,[%sp+$bias+$frame+16]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
bz,pn %icc,.L1stskip
|
2005-10-19 07:12:06 +00:00
|
|
|
|
std $nlod,[%sp+$bias+$frame+24]
|
2006-11-28 07:20:36 +00:00
|
|
|
|
|
2007-06-20 12:24:22 +00:00
|
|
|
|
.align 32 ! incidentally already aligned !
|
2006-11-28 07:20:36 +00:00
|
|
|
|
.L1st:
|
|
|
|
|
add $ap,$j,%o4
|
|
|
|
|
add $np,$j,%o5
|
|
|
|
|
ld [%o4+0],$alo_ ! load a[j] as pair of 32-bit words
|
|
|
|
|
fzeros $alo
|
|
|
|
|
ld [%o4+4],$ahi_
|
|
|
|
|
fzeros $ahi
|
|
|
|
|
ld [%o5+0],$nlo_ ! load n[j] as pair of 32-bit words
|
|
|
|
|
fzeros $nlo
|
|
|
|
|
ld [%o5+4],$nhi_
|
|
|
|
|
fzeros $nhi
|
|
|
|
|
|
|
|
|
|
fxtod $alo,$alo
|
|
|
|
|
fxtod $ahi,$ahi
|
|
|
|
|
fxtod $nlo,$nlo
|
|
|
|
|
fxtod $nhi,$nhi
|
|
|
|
|
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+0],%o0
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $alo,$ba,$aloa
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+8],%o1
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $nlo,$na,$nloa
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+16],%o2
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $alo,$bb,$alob
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+24],%o3
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $nlo,$nb,$nlob
|
2006-11-28 07:24:26 +00:00
|
|
|
|
|
|
|
|
|
srlx %o0,16,%o7
|
|
|
|
|
std $alo,[$ap_l+$j] ! save smashed ap[j] in double format
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $alo,$bc,$aloc
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add %o7,%o1,%o1
|
|
|
|
|
std $ahi,[$ap_h+$j]
|
|
|
|
|
faddd $aloa,$nloa,$nloa
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $nlo,$nc,$nloc
|
2006-11-28 07:24:26 +00:00
|
|
|
|
srlx %o1,16,%o7
|
|
|
|
|
std $nlo,[$np_l+$j] ! save smashed np[j] in double format
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $alo,$bd,$alod
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add %o7,%o2,%o2
|
|
|
|
|
std $nhi,[$np_h+$j]
|
|
|
|
|
faddd $alob,$nlob,$nlob
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $nlo,$nd,$nlod
|
2006-11-28 07:24:26 +00:00
|
|
|
|
srlx %o2,16,%o7
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $ahi,$ba,$ahia
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add %o7,%o3,%o3 ! %o3.%o2[0..15].%o1[0..15].%o0[0..15]
|
|
|
|
|
and %o0,$mask,%o0
|
|
|
|
|
faddd $aloc,$nloc,$nloc
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $nhi,$na,$nhia
|
2006-11-28 07:24:26 +00:00
|
|
|
|
and %o1,$mask,%o1
|
|
|
|
|
and %o2,$mask,%o2
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $ahi,$bb,$ahib
|
2006-11-28 07:24:26 +00:00
|
|
|
|
sllx %o1,16,%o1
|
|
|
|
|
faddd $alod,$nlod,$nlod
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $nhi,$nb,$nhib
|
2006-11-28 07:24:26 +00:00
|
|
|
|
sllx %o2,32,%o2
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $ahi,$bc,$ahic
|
2006-11-28 07:24:26 +00:00
|
|
|
|
sllx %o3,48,%o7
|
|
|
|
|
or %o1,%o0,%o0
|
|
|
|
|
faddd $ahia,$nhia,$nhia
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $nhi,$nc,$nhic
|
2006-11-28 07:24:26 +00:00
|
|
|
|
or %o2,%o0,%o0
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $ahi,$bd,$ahid
|
2006-11-28 07:24:26 +00:00
|
|
|
|
or %o7,%o0,%o0 ! 64-bit result
|
|
|
|
|
faddd $ahib,$nhib,$nhib
|
2006-11-28 07:20:36 +00:00
|
|
|
|
fmuld $nhi,$nd,$nhid
|
2006-11-28 07:24:26 +00:00
|
|
|
|
addcc %g1,%o0,%o0
|
|
|
|
|
faddd $dota,$nloa,$nloa
|
|
|
|
|
srlx %o3,16,%g1 ! 34-bit carry
|
|
|
|
|
faddd $dotb,$nlob,$nlob
|
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add %g1,1,%g1
|
|
|
|
|
|
|
|
|
|
stx %o0,[$tp] ! tp[j-1]=
|
2006-11-28 07:20:36 +00:00
|
|
|
|
|
|
|
|
|
faddd $ahic,$nhic,$dota ! $nhic
|
|
|
|
|
faddd $ahid,$nhid,$dotb ! $nhid
|
|
|
|
|
|
|
|
|
|
faddd $nloc,$nhia,$nloc
|
|
|
|
|
faddd $nlod,$nhib,$nlod
|
|
|
|
|
|
|
|
|
|
fdtox $nloa,$nloa
|
|
|
|
|
fdtox $nlob,$nlob
|
|
|
|
|
fdtox $nloc,$nloc
|
|
|
|
|
fdtox $nlod,$nlod
|
|
|
|
|
|
|
|
|
|
std $nloa,[%sp+$bias+$frame+0]
|
|
|
|
|
std $nlob,[%sp+$bias+$frame+8]
|
|
|
|
|
std $nloc,[%sp+$bias+$frame+16]
|
|
|
|
|
std $nlod,[%sp+$bias+$frame+24]
|
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
addcc $j,8,$j
|
|
|
|
|
bnz,pt %icc,.L1st
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add $tp,8,$tp
|
2006-11-28 07:20:36 +00:00
|
|
|
|
|
|
|
|
|
.L1stskip:
|
2006-11-28 10:34:51 +00:00
|
|
|
|
fdtox $dota,$dota
|
|
|
|
|
fdtox $dotb,$dotb
|
|
|
|
|
|
2006-11-28 07:20:36 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+0],%o0
|
|
|
|
|
ldx [%sp+$bias+$frame+8],%o1
|
|
|
|
|
ldx [%sp+$bias+$frame+16],%o2
|
|
|
|
|
ldx [%sp+$bias+$frame+24],%o3
|
|
|
|
|
|
|
|
|
|
srlx %o0,16,%o7
|
2006-11-28 10:34:51 +00:00
|
|
|
|
std $dota,[%sp+$bias+$frame+32]
|
2006-11-28 07:20:36 +00:00
|
|
|
|
add %o7,%o1,%o1
|
2006-11-28 10:34:51 +00:00
|
|
|
|
std $dotb,[%sp+$bias+$frame+40]
|
2006-11-28 07:20:36 +00:00
|
|
|
|
srlx %o1,16,%o7
|
|
|
|
|
add %o7,%o2,%o2
|
|
|
|
|
srlx %o2,16,%o7
|
|
|
|
|
add %o7,%o3,%o3 ! %o3.%o2[0..15].%o1[0..15].%o0[0..15]
|
|
|
|
|
and %o0,$mask,%o0
|
|
|
|
|
and %o1,$mask,%o1
|
|
|
|
|
and %o2,$mask,%o2
|
|
|
|
|
sllx %o1,16,%o1
|
|
|
|
|
sllx %o2,32,%o2
|
|
|
|
|
sllx %o3,48,%o7
|
|
|
|
|
or %o1,%o0,%o0
|
|
|
|
|
or %o2,%o0,%o0
|
|
|
|
|
or %o7,%o0,%o0 ! 64-bit result
|
2006-11-28 10:34:51 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+32],%o4
|
2006-11-28 07:20:36 +00:00
|
|
|
|
addcc %g1,%o0,%o0
|
2006-11-28 10:34:51 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+40],%o5
|
2006-11-28 07:20:36 +00:00
|
|
|
|
srlx %o3,16,%g1 ! 34-bit carry
|
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add %g1,1,%g1
|
|
|
|
|
|
|
|
|
|
stx %o0,[$tp] ! tp[j-1]=
|
|
|
|
|
add $tp,8,$tp
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
2006-11-28 10:34:51 +00:00
|
|
|
|
srlx %o4,16,%o7
|
|
|
|
|
add %o7,%o5,%o5
|
|
|
|
|
and %o4,$mask,%o4
|
|
|
|
|
sllx %o5,16,%o7
|
|
|
|
|
or %o7,%o4,%o4
|
|
|
|
|
addcc %g1,%o4,%o4
|
|
|
|
|
srlx %o5,48,%g1
|
2005-10-19 07:12:06 +00:00
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add %g1,1,%g1
|
|
|
|
|
|
|
|
|
|
mov %g1,$carry
|
2006-11-28 10:34:51 +00:00
|
|
|
|
stx %o4,[$tp] ! tp[num-1]=
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
ba .Louter
|
|
|
|
|
add $i,8,$i
|
|
|
|
|
.align 32
|
|
|
|
|
.Louter:
|
2005-12-15 22:40:58 +00:00
|
|
|
|
sub %g0,$num,$j ! j=-num
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add %sp,$bias+$frame+$locals,$tp
|
|
|
|
|
|
2006-12-08 15:18:41 +00:00
|
|
|
|
add $ap,$j,%o3
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add $bp,$i,%o4
|
2005-12-15 22:40:58 +00:00
|
|
|
|
|
2006-12-08 15:18:41 +00:00
|
|
|
|
ld [%o3+4],%g1 ! bp[i]
|
|
|
|
|
ld [%o3+0],%o0
|
|
|
|
|
ld [%o4+4],%g5 ! ap[0]
|
|
|
|
|
sllx %g1,32,%g1
|
|
|
|
|
ld [%o4+0],%o1
|
|
|
|
|
sllx %g5,32,%g5
|
2005-12-15 22:40:58 +00:00
|
|
|
|
or %g1,%o0,%o0
|
|
|
|
|
or %g5,%o1,%o1
|
|
|
|
|
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ldx [$tp],%o2 ! tp[0]
|
|
|
|
|
mulx %o1,%o0,%o0
|
|
|
|
|
addcc %o2,%o0,%o0
|
|
|
|
|
mulx $n0,%o0,%o0 ! (ap[0]*bp[i]+t[0])*n0
|
2005-10-22 18:16:09 +00:00
|
|
|
|
stx %o0,[%sp+$bias+$frame+0]
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
! transfer b[i] to FPU as 4x16-bit values
|
2005-12-15 22:40:58 +00:00
|
|
|
|
ldda [%o4+2]%asi,$ba
|
|
|
|
|
ldda [%o4+0]%asi,$bb
|
|
|
|
|
ldda [%o4+6]%asi,$bc
|
|
|
|
|
ldda [%o4+4]%asi,$bd
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
! transfer (ap[0]*b[i]+t[0])*n0 to FPU as 4x16-bit values
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ldda [%sp+$bias+$frame+6]%asi,$na
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $ba,$ba
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ldda [%sp+$bias+$frame+4]%asi,$nb
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $bb,$bb
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ldda [%sp+$bias+$frame+2]%asi,$nc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $bc,$bc
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ldda [%sp+$bias+$frame+0]%asi,$nd
|
2005-10-19 07:12:06 +00:00
|
|
|
|
fxtod $bd,$bd
|
|
|
|
|
ldd [$ap_l+$j],$alo ! load a[j] in double format
|
|
|
|
|
fxtod $na,$na
|
|
|
|
|
ldd [$ap_h+$j],$ahi
|
|
|
|
|
fxtod $nb,$nb
|
|
|
|
|
ldd [$np_l+$j],$nlo ! load n[j] in double format
|
|
|
|
|
fxtod $nc,$nc
|
|
|
|
|
ldd [$np_h+$j],$nhi
|
|
|
|
|
fxtod $nd,$nd
|
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $alo,$ba,$aloa
|
|
|
|
|
fmuld $nlo,$na,$nloa
|
|
|
|
|
fmuld $alo,$bb,$alob
|
|
|
|
|
fmuld $nlo,$nb,$nlob
|
|
|
|
|
fmuld $alo,$bc,$aloc
|
|
|
|
|
faddd $aloa,$nloa,$nloa
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nlo,$nc,$nloc
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $alo,$bd,$alod
|
|
|
|
|
faddd $alob,$nlob,$nlob
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nlo,$nd,$nlod
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$ba,$ahia
|
|
|
|
|
faddd $aloc,$nloc,$nloc
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$na,$nhia
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$bb,$ahib
|
|
|
|
|
faddd $alod,$nlod,$nlod
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$nb,$nhib
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$bc,$ahic
|
|
|
|
|
faddd $ahia,$nhia,$nhia
|
2005-12-15 22:40:58 +00:00
|
|
|
|
fmuld $nhi,$nc,$nhic
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $ahi,$bd,$ahid
|
2005-12-15 22:40:58 +00:00
|
|
|
|
faddd $ahib,$nhib,$nhib
|
2005-10-22 18:16:09 +00:00
|
|
|
|
fmuld $nhi,$nd,$nhid
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
faddd $ahic,$nhic,$dota ! $nhic
|
|
|
|
|
faddd $ahid,$nhid,$dotb ! $nhid
|
|
|
|
|
|
|
|
|
|
faddd $nloc,$nhia,$nloc
|
|
|
|
|
faddd $nlod,$nhib,$nlod
|
|
|
|
|
|
|
|
|
|
fdtox $nloa,$nloa
|
|
|
|
|
fdtox $nlob,$nlob
|
|
|
|
|
fdtox $nloc,$nloc
|
|
|
|
|
fdtox $nlod,$nlod
|
|
|
|
|
|
|
|
|
|
std $nloa,[%sp+$bias+$frame+0]
|
|
|
|
|
std $nlob,[%sp+$bias+$frame+8]
|
|
|
|
|
std $nloc,[%sp+$bias+$frame+16]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
add $j,8,$j
|
2005-10-19 07:12:06 +00:00
|
|
|
|
std $nlod,[%sp+$bias+$frame+24]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
|
|
|
|
|
ldd [$ap_l+$j],$alo ! load a[j] in double format
|
|
|
|
|
ldd [$ap_h+$j],$ahi
|
|
|
|
|
ldd [$np_l+$j],$nlo ! load n[j] in double format
|
|
|
|
|
ldd [$np_h+$j],$nhi
|
|
|
|
|
|
|
|
|
|
fmuld $alo,$ba,$aloa
|
|
|
|
|
fmuld $nlo,$na,$nloa
|
|
|
|
|
fmuld $alo,$bb,$alob
|
|
|
|
|
fmuld $nlo,$nb,$nlob
|
|
|
|
|
fmuld $alo,$bc,$aloc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+0],%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $aloa,$nloa,$nloa
|
|
|
|
|
fmuld $nlo,$nc,$nloc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+8],%o1
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $alo,$bd,$alod
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+16],%o2
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $alob,$nlob,$nlob
|
|
|
|
|
fmuld $nlo,$nd,$nlod
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+24],%o3
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $ahi,$ba,$ahia
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
srlx %o0,16,%o7
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $aloc,$nloc,$nloc
|
|
|
|
|
fmuld $nhi,$na,$nhia
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add %o7,%o1,%o1
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $ahi,$bb,$ahib
|
2005-10-19 07:12:06 +00:00
|
|
|
|
srlx %o1,16,%o7
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $alod,$nlod,$nlod
|
|
|
|
|
fmuld $nhi,$nb,$nhib
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add %o7,%o2,%o2
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $ahi,$bc,$ahic
|
2005-10-19 07:12:06 +00:00
|
|
|
|
srlx %o2,16,%o7
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $ahia,$nhia,$nhia
|
|
|
|
|
fmuld $nhi,$nc,$nhic
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add %o7,%o3,%o3 ! %o3.%o2[0..15].%o1[0..15].%o0[0..15]
|
|
|
|
|
! why?
|
|
|
|
|
and %o0,$mask,%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $ahi,$bd,$ahid
|
2005-10-19 07:12:06 +00:00
|
|
|
|
and %o1,$mask,%o1
|
|
|
|
|
and %o2,$mask,%o2
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $ahib,$nhib,$nhib
|
|
|
|
|
fmuld $nhi,$nd,$nhid
|
2005-10-19 07:12:06 +00:00
|
|
|
|
sllx %o1,16,%o1
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $dota,$nloa,$nloa
|
2005-10-19 07:12:06 +00:00
|
|
|
|
sllx %o2,32,%o2
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $dotb,$nlob,$nlob
|
2005-10-19 07:12:06 +00:00
|
|
|
|
sllx %o3,48,%o7
|
|
|
|
|
or %o1,%o0,%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $ahic,$nhic,$dota ! $nhic
|
2005-10-19 07:12:06 +00:00
|
|
|
|
or %o2,%o0,%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $ahid,$nhid,$dotb ! $nhid
|
2005-10-19 07:12:06 +00:00
|
|
|
|
or %o7,%o0,%o0 ! 64-bit result
|
|
|
|
|
ldx [$tp],%o7
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $nloc,$nhia,$nloc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
addcc %o7,%o0,%o0
|
|
|
|
|
! end-of-why?
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $nlod,$nhib,$nlod
|
2005-10-19 07:12:06 +00:00
|
|
|
|
srlx %o3,16,%g1 ! 34-bit carry
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fdtox $nloa,$nloa
|
2005-10-19 07:12:06 +00:00
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add %g1,1,%g1
|
|
|
|
|
|
|
|
|
|
fdtox $nlob,$nlob
|
|
|
|
|
fdtox $nloc,$nloc
|
|
|
|
|
fdtox $nlod,$nlod
|
|
|
|
|
|
|
|
|
|
std $nloa,[%sp+$bias+$frame+0]
|
|
|
|
|
std $nlob,[%sp+$bias+$frame+8]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
addcc $j,8,$j
|
2005-10-19 07:12:06 +00:00
|
|
|
|
std $nloc,[%sp+$bias+$frame+16]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
bz,pn %icc,.Linnerskip
|
2005-10-19 07:12:06 +00:00
|
|
|
|
std $nlod,[%sp+$bias+$frame+24]
|
2006-11-28 07:20:36 +00:00
|
|
|
|
|
2006-11-28 10:34:51 +00:00
|
|
|
|
ba .Linner
|
|
|
|
|
nop
|
|
|
|
|
.align 32
|
2006-11-28 07:20:36 +00:00
|
|
|
|
.Linner:
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldd [$ap_l+$j],$alo ! load a[j] in double format
|
|
|
|
|
ldd [$ap_h+$j],$ahi
|
|
|
|
|
ldd [$np_l+$j],$nlo ! load n[j] in double format
|
|
|
|
|
ldd [$np_h+$j],$nhi
|
|
|
|
|
|
|
|
|
|
fmuld $alo,$ba,$aloa
|
|
|
|
|
fmuld $nlo,$na,$nloa
|
|
|
|
|
fmuld $alo,$bb,$alob
|
|
|
|
|
fmuld $nlo,$nb,$nlob
|
|
|
|
|
fmuld $alo,$bc,$aloc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+0],%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $aloa,$nloa,$nloa
|
|
|
|
|
fmuld $nlo,$nc,$nloc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+8],%o1
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $alo,$bd,$alod
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+16],%o2
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $alob,$nlob,$nlob
|
|
|
|
|
fmuld $nlo,$nd,$nlod
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+24],%o3
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $ahi,$ba,$ahia
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
srlx %o0,16,%o7
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $aloc,$nloc,$nloc
|
|
|
|
|
fmuld $nhi,$na,$nhia
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add %o7,%o1,%o1
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $ahi,$bb,$ahib
|
2005-10-19 07:12:06 +00:00
|
|
|
|
srlx %o1,16,%o7
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $alod,$nlod,$nlod
|
|
|
|
|
fmuld $nhi,$nb,$nhib
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add %o7,%o2,%o2
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $ahi,$bc,$ahic
|
2005-10-19 07:12:06 +00:00
|
|
|
|
srlx %o2,16,%o7
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $ahia,$nhia,$nhia
|
|
|
|
|
fmuld $nhi,$nc,$nhic
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add %o7,%o3,%o3 ! %o3.%o2[0..15].%o1[0..15].%o0[0..15]
|
|
|
|
|
and %o0,$mask,%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fmuld $ahi,$bd,$ahid
|
2005-10-19 07:12:06 +00:00
|
|
|
|
and %o1,$mask,%o1
|
|
|
|
|
and %o2,$mask,%o2
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $ahib,$nhib,$nhib
|
|
|
|
|
fmuld $nhi,$nd,$nhid
|
2005-10-19 07:12:06 +00:00
|
|
|
|
sllx %o1,16,%o1
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $dota,$nloa,$nloa
|
2005-10-19 07:12:06 +00:00
|
|
|
|
sllx %o2,32,%o2
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $dotb,$nlob,$nlob
|
2005-10-19 07:12:06 +00:00
|
|
|
|
sllx %o3,48,%o7
|
|
|
|
|
or %o1,%o0,%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $ahic,$nhic,$dota ! $nhic
|
2005-10-19 07:12:06 +00:00
|
|
|
|
or %o2,%o0,%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $ahid,$nhid,$dotb ! $nhid
|
2005-10-19 07:12:06 +00:00
|
|
|
|
or %o7,%o0,%o0 ! 64-bit result
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $nloc,$nhia,$nloc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
addcc %g1,%o0,%o0
|
2006-11-28 10:34:51 +00:00
|
|
|
|
ldx [$tp+8],%o7 ! tp[j]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
faddd $nlod,$nhib,$nlod
|
2005-10-19 07:12:06 +00:00
|
|
|
|
srlx %o3,16,%g1 ! 34-bit carry
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fdtox $nloa,$nloa
|
2005-10-19 07:12:06 +00:00
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add %g1,1,%g1
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fdtox $nlob,$nlob
|
2005-10-19 07:12:06 +00:00
|
|
|
|
addcc %o7,%o0,%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fdtox $nloc,$nloc
|
2005-10-19 07:12:06 +00:00
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add %g1,1,%g1
|
|
|
|
|
|
|
|
|
|
stx %o0,[$tp] ! tp[j-1]
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fdtox $nlod,$nlod
|
2006-11-28 07:20:36 +00:00
|
|
|
|
|
|
|
|
|
std $nloa,[%sp+$bias+$frame+0]
|
|
|
|
|
std $nlob,[%sp+$bias+$frame+8]
|
|
|
|
|
std $nloc,[%sp+$bias+$frame+16]
|
2005-10-22 18:16:09 +00:00
|
|
|
|
addcc $j,8,$j
|
2006-11-28 07:24:26 +00:00
|
|
|
|
std $nlod,[%sp+$bias+$frame+24]
|
2005-10-22 18:16:09 +00:00
|
|
|
|
bnz,pt %icc,.Linner
|
2005-10-19 07:12:06 +00:00
|
|
|
|
add $tp,8,$tp
|
2006-11-28 07:20:36 +00:00
|
|
|
|
|
|
|
|
|
.Linnerskip:
|
2006-11-28 07:24:26 +00:00
|
|
|
|
fdtox $dota,$dota
|
|
|
|
|
fdtox $dotb,$dotb
|
|
|
|
|
|
2006-11-28 07:20:36 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+0],%o0
|
|
|
|
|
ldx [%sp+$bias+$frame+8],%o1
|
|
|
|
|
ldx [%sp+$bias+$frame+16],%o2
|
|
|
|
|
ldx [%sp+$bias+$frame+24],%o3
|
|
|
|
|
|
|
|
|
|
srlx %o0,16,%o7
|
2006-11-28 07:24:26 +00:00
|
|
|
|
std $dota,[%sp+$bias+$frame+32]
|
2006-11-28 07:20:36 +00:00
|
|
|
|
add %o7,%o1,%o1
|
2006-11-28 07:24:26 +00:00
|
|
|
|
std $dotb,[%sp+$bias+$frame+40]
|
2006-11-28 07:20:36 +00:00
|
|
|
|
srlx %o1,16,%o7
|
|
|
|
|
add %o7,%o2,%o2
|
|
|
|
|
srlx %o2,16,%o7
|
|
|
|
|
add %o7,%o3,%o3 ! %o3.%o2[0..15].%o1[0..15].%o0[0..15]
|
|
|
|
|
and %o0,$mask,%o0
|
|
|
|
|
and %o1,$mask,%o1
|
|
|
|
|
and %o2,$mask,%o2
|
|
|
|
|
sllx %o1,16,%o1
|
|
|
|
|
sllx %o2,32,%o2
|
|
|
|
|
sllx %o3,48,%o7
|
|
|
|
|
or %o1,%o0,%o0
|
|
|
|
|
or %o2,%o0,%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+32],%o4
|
2006-11-28 07:20:36 +00:00
|
|
|
|
or %o7,%o0,%o0 ! 64-bit result
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [%sp+$bias+$frame+40],%o5
|
2006-11-28 07:20:36 +00:00
|
|
|
|
addcc %g1,%o0,%o0
|
2006-11-28 07:24:26 +00:00
|
|
|
|
ldx [$tp+8],%o7 ! tp[j]
|
2006-11-28 07:20:36 +00:00
|
|
|
|
srlx %o3,16,%g1 ! 34-bit carry
|
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add %g1,1,%g1
|
|
|
|
|
|
|
|
|
|
addcc %o7,%o0,%o0
|
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add %g1,1,%g1
|
|
|
|
|
|
|
|
|
|
stx %o0,[$tp] ! tp[j-1]
|
|
|
|
|
add $tp,8,$tp
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
2006-11-28 07:24:26 +00:00
|
|
|
|
srlx %o4,16,%o7
|
|
|
|
|
add %o7,%o5,%o5
|
|
|
|
|
and %o4,$mask,%o4
|
|
|
|
|
sllx %o5,16,%o7
|
|
|
|
|
or %o7,%o4,%o4
|
|
|
|
|
addcc %g1,%o4,%o4
|
|
|
|
|
srlx %o5,48,%g1
|
2005-10-19 07:12:06 +00:00
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add %g1,1,%g1
|
|
|
|
|
|
2006-11-28 07:24:26 +00:00
|
|
|
|
addcc $carry,%o4,%o4
|
|
|
|
|
stx %o4,[$tp] ! tp[num-1]
|
2005-10-19 07:12:06 +00:00
|
|
|
|
mov %g1,$carry
|
|
|
|
|
bcs,a %xcc,.+8
|
|
|
|
|
add $carry,1,$carry
|
|
|
|
|
|
2005-10-22 18:16:09 +00:00
|
|
|
|
addcc $i,8,$i
|
|
|
|
|
bnz %icc,.Louter
|
2005-10-19 07:12:06 +00:00
|
|
|
|
nop
|
|
|
|
|
|
2007-06-17 17:10:03 +00:00
|
|
|
|
add $tp,8,$tp ! adjust tp to point at the end
|
|
|
|
|
orn %g0,%g0,%g4
|
|
|
|
|
sub %g0,$num,%o7 ! n=-num
|
2007-06-20 12:24:22 +00:00
|
|
|
|
ba .Lsub
|
2007-06-29 13:10:19 +00:00
|
|
|
|
subcc %g0,%g0,%g0 ! clear %icc.c
|
2007-06-20 12:24:22 +00:00
|
|
|
|
|
|
|
|
|
.align 32
|
2005-10-19 07:12:06 +00:00
|
|
|
|
.Lsub:
|
2006-12-08 15:18:41 +00:00
|
|
|
|
ldx [$tp+%o7],%o0
|
|
|
|
|
add $np,%o7,%g1
|
|
|
|
|
ld [%g1+0],%o2
|
|
|
|
|
ld [%g1+4],%o3
|
|
|
|
|
srlx %o0,32,%o1
|
|
|
|
|
subccc %o0,%o2,%o2
|
|
|
|
|
add $rp,%o7,%g1
|
|
|
|
|
subccc %o1,%o3,%o3
|
|
|
|
|
st %o2,[%g1+0]
|
2005-10-22 18:16:09 +00:00
|
|
|
|
add %o7,8,%o7
|
|
|
|
|
brnz,pt %o7,.Lsub
|
2006-12-08 15:18:41 +00:00
|
|
|
|
st %o3,[%g1+4]
|
2007-06-17 17:10:03 +00:00
|
|
|
|
subc $carry,0,%g4
|
2005-12-15 22:40:58 +00:00
|
|
|
|
sub %g0,$num,%o7 ! n=-num
|
2007-06-20 12:24:22 +00:00
|
|
|
|
ba .Lcopy
|
|
|
|
|
nop
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
2007-06-20 12:24:22 +00:00
|
|
|
|
.align 32
|
2005-10-19 07:12:06 +00:00
|
|
|
|
.Lcopy:
|
2005-10-22 18:16:09 +00:00
|
|
|
|
ldx [$tp+%o7],%o0
|
2006-12-08 15:18:41 +00:00
|
|
|
|
add $rp,%o7,%g1
|
2007-06-17 17:10:03 +00:00
|
|
|
|
ld [%g1+0],%o2
|
|
|
|
|
ld [%g1+4],%o3
|
|
|
|
|
stx %g0,[$tp+%o7]
|
|
|
|
|
and %o0,%g4,%o0
|
|
|
|
|
srlx %o0,32,%o1
|
|
|
|
|
andn %o2,%g4,%o2
|
|
|
|
|
andn %o3,%g4,%o3
|
|
|
|
|
or %o2,%o0,%o0
|
|
|
|
|
or %o3,%o1,%o1
|
2006-12-08 15:18:41 +00:00
|
|
|
|
st %o0,[%g1+0]
|
2005-10-22 18:16:09 +00:00
|
|
|
|
add %o7,8,%o7
|
|
|
|
|
brnz,pt %o7,.Lcopy
|
2006-12-08 15:18:41 +00:00
|
|
|
|
st %o1,[%g1+4]
|
2005-12-15 22:40:58 +00:00
|
|
|
|
sub %g0,$num,%o7 ! n=-num
|
2005-10-19 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
.Lzap:
|
2005-10-22 18:16:09 +00:00
|
|
|
|
stx %g0,[$ap_l+%o7]
|
|
|
|
|
stx %g0,[$ap_h+%o7]
|
|
|
|
|
stx %g0,[$np_l+%o7]
|
|
|
|
|
stx %g0,[$np_h+%o7]
|
|
|
|
|
add %o7,8,%o7
|
|
|
|
|
brnz,pt %o7,.Lzap
|
2005-10-19 07:12:06 +00:00
|
|
|
|
nop
|
|
|
|
|
|
|
|
|
|
ldx [%sp+$bias+$frame+48],%o7
|
|
|
|
|
wr %g0,%o7,%asi ! restore %asi
|
|
|
|
|
|
|
|
|
|
mov 1,%i0
|
2005-10-22 18:16:09 +00:00
|
|
|
|
.Lret:
|
2005-10-19 07:12:06 +00:00
|
|
|
|
ret
|
|
|
|
|
restore
|
|
|
|
|
.type $fname,#function
|
|
|
|
|
.size $fname,(.-$fname)
|
2017-11-12 00:03:10 +00:00
|
|
|
|
.asciz "Montgomery Multiplication for UltraSPARC, CRYPTOGAMS by <appro\@openssl.org>"
|
2007-06-20 12:24:22 +00:00
|
|
|
|
.align 32
|
2005-10-19 07:12:06 +00:00
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
$code =~ s/\`([^\`]*)\`/eval($1)/gem;
|
2005-12-19 09:10:06 +00:00
|
|
|
|
|
|
|
|
|
# Below substitution makes it possible to compile without demanding
|
2013-06-12 23:22:32 +00:00
|
|
|
|
# VIS extensions on command line, e.g. -xarch=v9 vs. -xarch=v9a. I
|
2005-12-19 09:10:06 +00:00
|
|
|
|
# dare to do this, because VIS capability is detected at run-time now
|
|
|
|
|
# and this routine is not called on CPU not capable to execute it. Do
|
|
|
|
|
# note that fzeros is not the only VIS dependency! Another dependency
|
|
|
|
|
# is implicit and is just _a_ numerical value loaded to %asi register,
|
|
|
|
|
# which assembler can't recognize as VIS specific...
|
|
|
|
|
$code =~ s/fzeros\s+%f([0-9]+)/
|
|
|
|
|
sprintf(".word\t0x%x\t! fzeros %%f%d",0x81b00c20|($1<<25),$1)
|
|
|
|
|
/gem;
|
|
|
|
|
|
2005-10-19 07:12:06 +00:00
|
|
|
|
print $code;
|
2005-12-19 09:10:06 +00:00
|
|
|
|
# flush
|
2005-10-19 07:12:06 +00:00
|
|
|
|
close STDOUT;
|