github.com/saintwish/kv@v1.0.4/swiss/simd/asm.go (about) 1 // From https://github.com/dolthub/swiss 2 // Copyright 2023 Dolthub, Inc. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 //go:build ignore 17 // +build ignore 18 19 package main 20 21 import ( 22 . "github.com/mmcloughlin/avo/build" 23 . "github.com/mmcloughlin/avo/operand" 24 ) 25 26 func main() { 27 ConstraintExpr("amd64") 28 29 TEXT("MatchMetadata", NOSPLIT, "func(metadata *[16]int8, hash int8) uint16") 30 Doc("MatchMetadata performs a 16-way probe of |metadata| using SSE instructions", 31 "nb: |metadata| must be an aligned pointer") 32 m := Mem{Base: Load(Param("metadata"), GP64())} 33 h := Load(Param("hash"), GP32()) 34 mask := GP32() 35 36 x0, x1, x2 := XMM(), XMM(), XMM() 37 MOVD(h, x0) 38 PXOR(x1, x1) 39 PSHUFB(x1, x0) 40 MOVOU(m, x2) 41 PCMPEQB(x2, x0) 42 PMOVMSKB(x0, mask) 43 44 Store(mask.As16(), ReturnIndex(0)) 45 RET() 46 Generate() 47 }