Text file src/hash/crc32/crc32_arm64.s

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

View as plain text