package main

import (
	. "github.com/mmcloughlin/avo/build"
	"github.com/mmcloughlin/avo/operand"
)

const MM_CMPINT_NLT = operand.U8(5)

//go:generate go run gen.go -pkg main -out ../ge_amd64.s -stubs ../ge_amd64.go
func main() {
	TEXT("ge", NOSPLIT, "func(a,b []uint64, r *uint8)")
	Doc("r_bits[i] = a[i] >= b[i], a,b must have 8 elements")

	aPtr := operand.Mem{Base: Load(Param("a").Base(), GP64())}
	bPtr := operand.Mem{Base: Load(Param("b").Base(), GP64())}
	rPtr := operand.Mem{Base: Load(Param("r"), GP64())}

	k := K()
	zmm := ZMM()
	VMOVDQU64(bPtr, zmm)
	VPCMPUQ(MM_CMPINT_NLT, aPtr, zmm, k)
	KMOVB(k, rPtr)
	RET()

	Generate()
}
