github.com/coyove/sdss@v0.0.0-20231129015646-c2ec58cca6a2/contrib/roaring/popcnt_asm.go (about) 1 //go:build amd64 && !appengine && !go1.9 2 // +build amd64,!appengine,!go1.9 3 4 package roaring 5 6 // *** the following functions are defined in popcnt_amd64.s 7 8 //go:noescape 9 10 func hasAsm() bool 11 12 // useAsm is a flag used to select the GO or ASM implementation of the popcnt function 13 var useAsm = hasAsm() 14 15 //go:noescape 16 17 func popcntSliceAsm(s []uint64) uint64 18 19 //go:noescape 20 21 func popcntMaskSliceAsm(s, m []uint64) uint64 22 23 //go:noescape 24 25 func popcntAndSliceAsm(s, m []uint64) uint64 26 27 //go:noescape 28 29 func popcntOrSliceAsm(s, m []uint64) uint64 30 31 //go:noescape 32 33 func popcntXorSliceAsm(s, m []uint64) uint64 34 35 func popcntSlice(s []uint64) uint64 { 36 if useAsm { 37 return popcntSliceAsm(s) 38 } 39 return popcntSliceGo(s) 40 } 41 42 func popcntMaskSlice(s, m []uint64) uint64 { 43 if useAsm { 44 return popcntMaskSliceAsm(s, m) 45 } 46 return popcntMaskSliceGo(s, m) 47 } 48 49 func popcntAndSlice(s, m []uint64) uint64 { 50 if useAsm { 51 return popcntAndSliceAsm(s, m) 52 } 53 return popcntAndSliceGo(s, m) 54 } 55 56 func popcntOrSlice(s, m []uint64) uint64 { 57 if useAsm { 58 return popcntOrSliceAsm(s, m) 59 } 60 return popcntOrSliceGo(s, m) 61 } 62 63 func popcntXorSlice(s, m []uint64) uint64 { 64 if useAsm { 65 return popcntXorSliceAsm(s, m) 66 } 67 return popcntXorSliceGo(s, m) 68 }