github.com/dolthub/swiss@v0.2.2-0.20240312182618-f4b2babd2bc1/simd/asm.go (about)

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