github.com/icodeface/tls@v0.0.0-20230910023335-34df9250cd12/internal/x/crypto/curve25519/freeze_amd64.s (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // This code was translated into a form compatible with 6a from the public
     6  // domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html
     7  
     8  // +build amd64,!gccgo,!appengine
     9  
    10  #include "const_amd64.h"
    11  
    12  // func freeze(inout *[5]uint64)
    13  TEXT ·freeze(SB),7,$0-8
    14  	MOVQ inout+0(FP), DI
    15  
    16  	MOVQ 0(DI),SI
    17  	MOVQ 8(DI),DX
    18  	MOVQ 16(DI),CX
    19  	MOVQ 24(DI),R8
    20  	MOVQ 32(DI),R9
    21  	MOVQ $REDMASK51,AX
    22  	MOVQ AX,R10
    23  	SUBQ $18,R10
    24  	MOVQ $3,R11
    25  REDUCELOOP:
    26  	MOVQ SI,R12
    27  	SHRQ $51,R12
    28  	ANDQ AX,SI
    29  	ADDQ R12,DX
    30  	MOVQ DX,R12
    31  	SHRQ $51,R12
    32  	ANDQ AX,DX
    33  	ADDQ R12,CX
    34  	MOVQ CX,R12
    35  	SHRQ $51,R12
    36  	ANDQ AX,CX
    37  	ADDQ R12,R8
    38  	MOVQ R8,R12
    39  	SHRQ $51,R12
    40  	ANDQ AX,R8
    41  	ADDQ R12,R9
    42  	MOVQ R9,R12
    43  	SHRQ $51,R12
    44  	ANDQ AX,R9
    45  	IMUL3Q $19,R12,R12
    46  	ADDQ R12,SI
    47  	SUBQ $1,R11
    48  	JA REDUCELOOP
    49  	MOVQ $1,R12
    50  	CMPQ R10,SI
    51  	CMOVQLT R11,R12
    52  	CMPQ AX,DX
    53  	CMOVQNE R11,R12
    54  	CMPQ AX,CX
    55  	CMOVQNE R11,R12
    56  	CMPQ AX,R8
    57  	CMOVQNE R11,R12
    58  	CMPQ AX,R9
    59  	CMOVQNE R11,R12
    60  	NEGQ R12
    61  	ANDQ R12,AX
    62  	ANDQ R12,R10
    63  	SUBQ R10,SI
    64  	SUBQ AX,DX
    65  	SUBQ AX,CX
    66  	SUBQ AX,R8
    67  	SUBQ AX,R9
    68  	MOVQ SI,0(DI)
    69  	MOVQ DX,8(DI)
    70  	MOVQ CX,16(DI)
    71  	MOVQ R8,24(DI)
    72  	MOVQ R9,32(DI)
    73  	RET