github.com/parquet-go/parquet-go@v0.20.0/hashprobe/aeshash/aeshash_amd64.s (about)

     1  //go:build !purego
     2  
     3  #include "textflag.h"
     4  
     5  // func Hash32(value uint32, seed uintptr) uintptr
     6  TEXT ·Hash32(SB), NOSPLIT, $0-24
     7      MOVL value+0(FP), AX
     8      MOVQ seed+8(FP), BX
     9  
    10      MOVOU runtime·aeskeysched+0(SB), X1
    11      MOVOU runtime·aeskeysched+16(SB), X2
    12      MOVOU runtime·aeskeysched+32(SB), X3
    13  
    14      MOVQ BX, X0
    15      PINSRD $2, AX, X0
    16  
    17      AESENC X1, X0
    18      AESENC X2, X0
    19      AESENC X3, X0
    20  
    21      MOVQ X0, ret+16(FP)
    22      RET
    23  
    24  // func Hash64(value uint64, seed uintptr) uintptr
    25  TEXT ·Hash64(SB), NOSPLIT, $0-24
    26      MOVQ value+0(FP), AX
    27      MOVQ seed+8(FP), BX
    28  
    29      MOVOU runtime·aeskeysched+0(SB), X1
    30      MOVOU runtime·aeskeysched+16(SB), X2
    31      MOVOU runtime·aeskeysched+32(SB), X3
    32  
    33      MOVQ BX, X0
    34      PINSRQ $1, AX, X0
    35  
    36      AESENC X1, X0
    37      AESENC X2, X0
    38      AESENC X3, X0
    39  
    40      MOVQ X0, ret+16(FP)
    41      RET
    42  
    43  // func Hash128(value [16]byte, seed uintptr) uintptr
    44  TEXT ·Hash128(SB), NOSPLIT, $0-32
    45      LEAQ value+0(FP), AX
    46      MOVQ seed+16(FP), BX
    47      MOVQ $16, CX
    48  
    49      MOVQ BX, X0                      // 64 bits of per-table hash seed
    50      PINSRW $4, CX, X0                // 16 bits of length
    51      PSHUFHW $0, X0, X0               // repeat length 4 times total
    52      PXOR runtime·aeskeysched(SB), X0 // xor in per-process seed
    53      AESENC X0, X0                    // scramble seed
    54  
    55      MOVOU (AX), X1
    56      PXOR X0, X1
    57      AESENC X1, X1
    58      AESENC X1, X1
    59      AESENC X1, X1
    60  
    61      MOVQ X1, ret+24(FP)
    62      RET
    63  
    64  // func MultiHashUint32Array(hashes []uintptr, values sparse.Uint32Array, seed uintptr)
    65  TEXT ·MultiHashUint32Array(SB), NOSPLIT, $0-56
    66      MOVQ hashes_base+0(FP), AX
    67      MOVQ values_array_ptr+24(FP), BX
    68      MOVQ values_array_len+32(FP), CX
    69      MOVQ values_array_off+40(FP), R8
    70      MOVQ seed+48(FP), DX
    71  
    72      MOVOU runtime·aeskeysched+0(SB), X1
    73      MOVOU runtime·aeskeysched+16(SB), X2
    74      MOVOU runtime·aeskeysched+32(SB), X3
    75  
    76      XORQ SI, SI
    77      JMP test
    78  loop:
    79      MOVQ DX, X0
    80      PINSRD $2, (BX), X0
    81  
    82      AESENC X1, X0
    83      AESENC X2, X0
    84      AESENC X3, X0
    85  
    86      MOVQ X0, (AX)(SI*8)
    87      INCQ SI
    88      ADDQ R8, BX
    89  test:
    90      CMPQ SI, CX
    91      JNE loop
    92      RET
    93  
    94  // func MultiHashUint64Array(hashes []uintptr, values sparse.Uint64Array, seed uintptr)
    95  TEXT ·MultiHashUint64Array(SB), NOSPLIT, $0-56
    96      MOVQ hashes_base+0(FP), AX
    97      MOVQ values_array_ptr+24(FP), BX
    98      MOVQ values_array_len+32(FP), CX
    99      MOVQ values_array_off+40(FP), R8
   100      MOVQ seed+48(FP), DX
   101  
   102      MOVOU runtime·aeskeysched+0(SB), X1
   103      MOVOU runtime·aeskeysched+16(SB), X2
   104      MOVOU runtime·aeskeysched+32(SB), X3
   105  
   106      XORQ SI, SI
   107      JMP test
   108  loop:
   109      MOVQ DX, X0
   110      PINSRQ $1, (BX), X0
   111  
   112      AESENC X1, X0
   113      AESENC X2, X0
   114      AESENC X3, X0
   115  
   116      MOVQ X0, (AX)(SI*8)
   117      INCQ SI
   118      ADDQ R8, BX
   119  test:
   120      CMPQ SI, CX
   121      JNE loop
   122      RET
   123  
   124  // func MultiHashUint128Array(hashes []uintptr, values sparse.Uint128Array, seed uintptr)
   125  TEXT ·MultiHashUint128Array(SB), NOSPLIT, $0-56
   126      MOVQ hashes_base+0(FP), AX
   127      MOVQ values_array_ptr+24(FP), BX
   128      MOVQ values_array_len+32(FP), CX
   129      MOVQ values_array_off+40(FP), R8
   130      MOVQ seed+48(FP), DX
   131      MOVQ $16, DI
   132  
   133      MOVQ DX, X0
   134      PINSRW $4, DI, X0
   135      PSHUFHW $0, X0, X0
   136      PXOR runtime·aeskeysched(SB), X0
   137      AESENC X0, X0
   138  
   139      XORQ SI, SI
   140      JMP test
   141  loop:
   142      MOVOU (BX), X1
   143  
   144      PXOR X0, X1
   145      AESENC X1, X1
   146      AESENC X1, X1
   147      AESENC X1, X1
   148  
   149      MOVQ X1, (AX)(SI*8)
   150      INCQ SI
   151      ADDQ R8, BX
   152  test:
   153      CMPQ SI, CX
   154      JNE loop
   155      RET