// +build ignore package main import ( . "github.com/mmcloughlin/avo/build" . "github.com/mmcloughlin/avo/operand" . "github.com/mmcloughlin/avo/reg" . "github.com/segmentio/asm/build/internal/x86" ) func init() { ConstraintExpr("!purego") } func main() { TEXT("ContainsByte", NOSPLIT, "func(haystack []byte, needle byte) bool") haystack := Load(Param("haystack").Base(), GP64()) length := Load(Param("haystack").Len(), GP64()) // Broadcast the needle byte to each 8 bytes in a GP64. needle := GP64() XORQ(needle, needle) Load(Param("needle"), needle.As8()) tmp := GP64() for i := 3; i <= 5; i++ { MOVQ(needle, tmp) SHLQ(U8(1< 1 { ops = append(ops[2:], op(ops[0], ops[1])) } return ops[0] } func binary(ins func(Op, Op)) func(Op, Op) Op { return func(src Op, dst Op) Op { ins(src, dst) return dst } } func vex(ins func(Op, Op, Op)) func(Op, Op) Op { return func(src Op, dst Op) Op { ins(src, dst, dst) return dst } }