github.com/MangoDowner/go-gm@v0.0.0-20180818020936-8baa2bd4408c/src/hash/crc32/crc32_arm64.s (about)

     1  // Copyright 2017 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  #include "textflag.h"
     6  
     7  // castagnoliUpdate updates the non-inverted crc with the given data.
     8  
     9  // func castagnoliUpdate(crc uint32, p []byte) uint32
    10  TEXT ·castagnoliUpdate(SB),NOSPLIT,$0-36
    11  	MOVWU	crc+0(FP), R9  // CRC value
    12  	MOVD	p+8(FP), R13  // data pointer
    13  	MOVD	p_len+16(FP), R11  // len(p)
    14  
    15  	CMP	$8, R11
    16  	BLT	less_than_8
    17  
    18  update:
    19  	MOVD.P	8(R13), R10
    20  	CRC32CX	R10, R9
    21  	SUB	$8, R11
    22  
    23  	CMP	$8, R11
    24  	BLT	less_than_8
    25  
    26  	JMP	update
    27  
    28  less_than_8:
    29  	TBZ	$2, R11, less_than_4
    30  
    31  	MOVWU.P	4(R13), R10
    32  	CRC32CW	R10, R9
    33  
    34  less_than_4:
    35  	TBZ	$1, R11, less_than_2
    36  
    37  	MOVHU.P	2(R13), R10
    38  	CRC32CH	R10, R9
    39  
    40  less_than_2:
    41  	TBZ	$0, R11, done
    42  
    43  	MOVBU	(R13), R10
    44  	CRC32CB	R10, R9
    45  
    46  done:
    47  	MOVWU	R9, ret+32(FP)
    48  	RET
    49  
    50  // ieeeUpdate updates the non-inverted crc with the given data.
    51  
    52  // func ieeeUpdate(crc uint32, p []byte) uint32
    53  TEXT ·ieeeUpdate(SB),NOSPLIT,$0-36
    54  	MOVWU	crc+0(FP), R9  // CRC value
    55  	MOVD	p+8(FP), R13  // data pointer
    56  	MOVD	p_len+16(FP), R11  // len(p)
    57  
    58  	CMP	$8, R11
    59  	BLT	less_than_8
    60  
    61  update:
    62  	MOVD.P	8(R13), R10
    63  	CRC32X	R10, R9
    64  	SUB	$8, R11
    65  
    66  	CMP	$8, R11
    67  	BLT	less_than_8
    68  
    69  	JMP	update
    70  
    71  less_than_8:
    72  	TBZ	$2, R11, less_than_4
    73  
    74  	MOVWU.P	4(R13), R10
    75  	CRC32W	R10, R9
    76  
    77  less_than_4:
    78  	TBZ	$1, R11, less_than_2
    79  
    80  	MOVHU.P	2(R13), R10
    81  	CRC32H	R10, R9
    82  
    83  less_than_2:
    84  	TBZ	$0, R11, done
    85  
    86  	MOVBU	(R13), R10
    87  	CRC32B	R10, R9
    88  
    89  done:
    90  	MOVWU	R9, ret+32(FP)
    91  	RET
    92  
    93  // func supportsCRC32() bool
    94  TEXT ·supportsCRC32(SB),NOSPLIT,$0-1
    95  	MOVB	runtime·supportCRC32(SB), R0
    96  	MOVB	R0, ret+0(FP)
    97  	RET