github.com/icodeface/tls@v0.0.0-20230910023335-34df9250cd12/internal/x/crypto/curve25519/mul_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 mul(dest, a, b *[5]uint64)
    13  TEXT ·mul(SB),0,$16-24
    14  	MOVQ dest+0(FP), DI
    15  	MOVQ a+8(FP), SI
    16  	MOVQ b+16(FP), DX
    17  
    18  	MOVQ DX,CX
    19  	MOVQ 24(SI),DX
    20  	IMUL3Q $19,DX,AX
    21  	MOVQ AX,0(SP)
    22  	MULQ 16(CX)
    23  	MOVQ AX,R8
    24  	MOVQ DX,R9
    25  	MOVQ 32(SI),DX
    26  	IMUL3Q $19,DX,AX
    27  	MOVQ AX,8(SP)
    28  	MULQ 8(CX)
    29  	ADDQ AX,R8
    30  	ADCQ DX,R9
    31  	MOVQ 0(SI),AX
    32  	MULQ 0(CX)
    33  	ADDQ AX,R8
    34  	ADCQ DX,R9
    35  	MOVQ 0(SI),AX
    36  	MULQ 8(CX)
    37  	MOVQ AX,R10
    38  	MOVQ DX,R11
    39  	MOVQ 0(SI),AX
    40  	MULQ 16(CX)
    41  	MOVQ AX,R12
    42  	MOVQ DX,R13
    43  	MOVQ 0(SI),AX
    44  	MULQ 24(CX)
    45  	MOVQ AX,R14
    46  	MOVQ DX,R15
    47  	MOVQ 0(SI),AX
    48  	MULQ 32(CX)
    49  	MOVQ AX,BX
    50  	MOVQ DX,BP
    51  	MOVQ 8(SI),AX
    52  	MULQ 0(CX)
    53  	ADDQ AX,R10
    54  	ADCQ DX,R11
    55  	MOVQ 8(SI),AX
    56  	MULQ 8(CX)
    57  	ADDQ AX,R12
    58  	ADCQ DX,R13
    59  	MOVQ 8(SI),AX
    60  	MULQ 16(CX)
    61  	ADDQ AX,R14
    62  	ADCQ DX,R15
    63  	MOVQ 8(SI),AX
    64  	MULQ 24(CX)
    65  	ADDQ AX,BX
    66  	ADCQ DX,BP
    67  	MOVQ 8(SI),DX
    68  	IMUL3Q $19,DX,AX
    69  	MULQ 32(CX)
    70  	ADDQ AX,R8
    71  	ADCQ DX,R9
    72  	MOVQ 16(SI),AX
    73  	MULQ 0(CX)
    74  	ADDQ AX,R12
    75  	ADCQ DX,R13
    76  	MOVQ 16(SI),AX
    77  	MULQ 8(CX)
    78  	ADDQ AX,R14
    79  	ADCQ DX,R15
    80  	MOVQ 16(SI),AX
    81  	MULQ 16(CX)
    82  	ADDQ AX,BX
    83  	ADCQ DX,BP
    84  	MOVQ 16(SI),DX
    85  	IMUL3Q $19,DX,AX
    86  	MULQ 24(CX)
    87  	ADDQ AX,R8
    88  	ADCQ DX,R9
    89  	MOVQ 16(SI),DX
    90  	IMUL3Q $19,DX,AX
    91  	MULQ 32(CX)
    92  	ADDQ AX,R10
    93  	ADCQ DX,R11
    94  	MOVQ 24(SI),AX
    95  	MULQ 0(CX)
    96  	ADDQ AX,R14
    97  	ADCQ DX,R15
    98  	MOVQ 24(SI),AX
    99  	MULQ 8(CX)
   100  	ADDQ AX,BX
   101  	ADCQ DX,BP
   102  	MOVQ 0(SP),AX
   103  	MULQ 24(CX)
   104  	ADDQ AX,R10
   105  	ADCQ DX,R11
   106  	MOVQ 0(SP),AX
   107  	MULQ 32(CX)
   108  	ADDQ AX,R12
   109  	ADCQ DX,R13
   110  	MOVQ 32(SI),AX
   111  	MULQ 0(CX)
   112  	ADDQ AX,BX
   113  	ADCQ DX,BP
   114  	MOVQ 8(SP),AX
   115  	MULQ 16(CX)
   116  	ADDQ AX,R10
   117  	ADCQ DX,R11
   118  	MOVQ 8(SP),AX
   119  	MULQ 24(CX)
   120  	ADDQ AX,R12
   121  	ADCQ DX,R13
   122  	MOVQ 8(SP),AX
   123  	MULQ 32(CX)
   124  	ADDQ AX,R14
   125  	ADCQ DX,R15
   126  	MOVQ $REDMASK51,SI
   127  	SHLQ $13,R9:R8
   128  	ANDQ SI,R8
   129  	SHLQ $13,R11:R10
   130  	ANDQ SI,R10
   131  	ADDQ R9,R10
   132  	SHLQ $13,R13:R12
   133  	ANDQ SI,R12
   134  	ADDQ R11,R12
   135  	SHLQ $13,R15:R14
   136  	ANDQ SI,R14
   137  	ADDQ R13,R14
   138  	SHLQ $13,BP:BX
   139  	ANDQ SI,BX
   140  	ADDQ R15,BX
   141  	IMUL3Q $19,BP,DX
   142  	ADDQ DX,R8
   143  	MOVQ R8,DX
   144  	SHRQ $51,DX
   145  	ADDQ R10,DX
   146  	MOVQ DX,CX
   147  	SHRQ $51,DX
   148  	ANDQ SI,R8
   149  	ADDQ R12,DX
   150  	MOVQ DX,R9
   151  	SHRQ $51,DX
   152  	ANDQ SI,CX
   153  	ADDQ R14,DX
   154  	MOVQ DX,AX
   155  	SHRQ $51,DX
   156  	ANDQ SI,R9
   157  	ADDQ BX,DX
   158  	MOVQ DX,R10
   159  	SHRQ $51,DX
   160  	ANDQ SI,AX
   161  	IMUL3Q $19,DX,DX
   162  	ADDQ DX,R8
   163  	ANDQ SI,R10
   164  	MOVQ R8,0(DI)
   165  	MOVQ CX,8(DI)
   166  	MOVQ R9,16(DI)
   167  	MOVQ AX,24(DI)
   168  	MOVQ R10,32(DI)
   169  	RET