github.com/thepudds/swisstable@v0.0.0-20221011152303-9c77dc657777/match_amd64.s (about) 1 // Code generated by command: go run asm.go -out ../match_amd64.s -stubs ../match_stub.go -pkg swisstable. DO NOT EDIT. 2 3 #include "textflag.h" 4 5 // func MatchByte(c uint8, buffer []byte) (mask uint32, ok bool) 6 // Requires: SSE2, SSSE3 7 TEXT ·MatchByte(SB), NOSPLIT, $0-37 8 // Get our input parameters 9 MOVBLZX c+0(FP), AX 10 MOVQ buffer_base+8(FP), CX 11 MOVQ buffer_len+16(FP), DX 12 13 // Check len of our input slice, which must be at least 16 14 CMPQ DX, $0x10 15 JGE valid 16 17 // Input slice too short. Return 0, false 18 XORL AX, AX 19 MOVL AX, mask+32(FP) 20 MOVB $0x00, ok+36(FP) 21 RET 22 23 valid: 24 // Input slice is a valid length 25 // Move c into an xmm register 26 MOVD AX, X0 27 28 // Shuffle the value of c into every byte of another xmm register 29 PXOR X1, X1 30 PSHUFB X1, X0 31 32 // Do an unaligned move of 16 bytes of input slice data to xmm register 33 // MOVOU is how MOVDQU is spelled in Go asm 34 MOVOU (CX), X1 35 36 // Find matching bytes with result in xmm register 37 PCMPEQB X1, X0 38 39 // Collapse matching bytes result down to an integer bitmask 40 PMOVMSKB X0, AX 41 42 // Return bitmask, true 43 MOVL AX, mask+32(FP) 44 MOVB $0x01, ok+36(FP) 45 RET