github.com/apache/arrow/go/v14@v14.0.2/parquet/internal/utils/clib_amd64.s (about)

     1  #include "textflag.h"
     2  
     3  // void *memcpy(void *dst, const void *src, size_t n)
     4  // DI = dst, SI = src, DX = size
     5  TEXT clib·_memcpy(SB), $16-0
     6  	PUSHQ R8
     7  	PUSHQ CX
     8  	XORQ  CX, CX // clear register
     9  
    10  MEMCPY_QUAD_LOOP:
    11  	ADDQ $8, CX
    12  	CMPQ CX, DX
    13  	JA   MEMCPY_QUAD_DONE
    14  	MOVQ -8(SI)(CX*1), R8
    15  	MOVQ R8, -8(DI)(CX*1)
    16  	JMP  MEMCPY_QUAD_LOOP
    17  
    18  MEMCPY_QUAD_DONE:
    19  	SUBQ $4, CX
    20  	CMPQ CX, DX
    21  	JA   MEMCPY_LONG_DONE
    22  	MOVL -4(SI)(CX*1), R8
    23  	MOVL R8, -4(DI)(CX*1)
    24  	ADDQ $4, CX
    25  
    26  MEMCPY_LONG_DONE:
    27  	SUBQ $2, CX
    28  	CMPQ CX, DX
    29  	JA   MEMCPY_WORD_DONE
    30  	MOVW -2(SI)(CX*1), R8
    31  	MOVW R8, -2(DI)(CX*1)
    32  	ADDQ $2, CX
    33  
    34  MEMCPY_WORD_DONE:
    35  	SUBQ $1, CX
    36  	CMPQ CX, DX
    37  	JA   MEMCPY_BYTE_DONE
    38  	MOVB -1(SI)(CX*1), R8
    39  	MOVB R8, -1(DI)(CX*1)
    40  
    41  MEMCPY_BYTE_DONE:
    42  	MOVQ DI, AX // set return value
    43  	POPQ CX
    44  	POPQ R8
    45  	RET
    46  
    47  // func _ClibMemcpy(dst, src unsafe.Pointer, n uint) unsafe.Pointer
    48  TEXT ·_ClibMemcpy(SB), NOSPLIT|NOFRAME, $16-24
    49  	MOVQ arg1+0(FP), DI
    50  	MOVQ arg2+8(FP), SI
    51  	MOVQ arg3+16(FP), DX
    52  	CALL clib·_memcpy(SB)
    53  	MOVQ AX, ret+24(FP)
    54  	RET
    55  
    56  // void *memset(void *str, int c, size_t n)
    57  // DI = str, SI = c, DX = size
    58  TEXT clib·_memset(SB), $16-0
    59  	PUSHQ CX
    60      LONG $0x0101f669; WORD $0x0101 // imul esi, 0x1010101
    61      MOVQ SI, CX
    62      ROLQ $32, CX
    63      ORQ CX, SI
    64  	XORQ CX, CX // clear register
    65  
    66  MEMSET_QUAD_LOOP:
    67  	ADDQ $8, CX
    68  	CMPQ CX, DX
    69  	JA   MEMSET_QUAD_DONE
    70  	MOVQ SI, -8(DI)(CX*1)
    71  	JMP  MEMSET_QUAD_LOOP
    72  
    73  MEMSET_QUAD_DONE:
    74  	SUBQ $4, CX
    75  	CMPQ CX, DX
    76  	JA   MEMSET_LONG_DONE
    77  	MOVL SI, -4(DI)(CX*1)
    78  	ADDQ $4, CX
    79  
    80  MEMSET_LONG_DONE:
    81  	SUBQ $2, CX
    82  	CMPQ CX, DX
    83  	JA   MEMSET_WORD_DONE
    84  	MOVW SI, -2(DI)(CX*1)
    85  	ADDQ $2, CX
    86  
    87  MEMSET_WORD_DONE:
    88  	SUBQ $1, CX
    89  	CMPQ CX, DX
    90  	JA   MEMSET_BYTE_DONE
    91  	MOVB SI, -1(DI)(CX*1)
    92  
    93  MEMSET_BYTE_DONE:
    94  	MOVQ DI, AX // set return value
    95  	POPQ CX
    96  	RET
    97  
    98  // func _ClibMemset(dst unsafe.Pointer, c int, n uint) unsafe.Pointer
    99  TEXT ·_ClibMemset(SB), NOSPLIT|NOFRAME, $16-24
   100  	MOVQ arg1+0(FP), DI
   101  	MOVQ arg2+8(FP), SI
   102  	MOVQ arg3+16(FP), DX
   103  	CALL clib·_memset(SB)
   104  	MOVQ AX, ret+24(FP)
   105  	RET