github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/pkg/hash/crc32/crc32_amd64.s (about) 1 // Copyright 2011 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 // func castagnoliSSE42(crc uint32, p []byte) uint32 6 TEXT ·castagnoliSSE42(SB),7,$0 7 MOVL crc+0(FP), AX // CRC value 8 MOVQ p+8(FP), SI // data pointer 9 MOVQ p_len+16(FP), CX // len(p) 10 11 NOTL AX 12 13 /* If there's less than 8 bytes to process, we do it byte-by-byte. */ 14 CMPQ CX, $8 15 JL cleanup 16 17 /* Process individual bytes until the input is 8-byte aligned. */ 18 startup: 19 MOVQ SI, BX 20 ANDQ $7, BX 21 JZ aligned 22 23 CRC32B (SI), AX 24 DECQ CX 25 INCQ SI 26 JMP startup 27 28 aligned: 29 /* The input is now 8-byte aligned and we can process 8-byte chunks. */ 30 CMPQ CX, $8 31 JL cleanup 32 33 CRC32Q (SI), AX 34 ADDQ $8, SI 35 SUBQ $8, CX 36 JMP aligned 37 38 cleanup: 39 /* We may have some bytes left over that we process one at a time. */ 40 CMPQ CX, $0 41 JE done 42 43 CRC32B (SI), AX 44 INCQ SI 45 DECQ CX 46 JMP cleanup 47 48 done: 49 NOTL AX 50 MOVL AX, ret+32(FP) 51 RET 52 53 // func haveSSE42() bool 54 TEXT ·haveSSE42(SB),7,$0 55 XORQ AX, AX 56 INCL AX 57 CPUID 58 SHRQ $20, CX 59 ANDQ $1, CX 60 MOVB CX, ret+0(FP) 61 RET 62