You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.2 KiB

  1. // +build !go1.9
  2. // +build amd64,!appengine
  3. package bitset
  4. // *** the following functions are defined in popcnt_amd64.s
  5. //go:noescape
  6. func hasAsm() bool
  7. // useAsm is a flag used to select the GO or ASM implementation of the popcnt function
  8. var useAsm = hasAsm()
  9. //go:noescape
  10. func popcntSliceAsm(s []uint64) uint64
  11. //go:noescape
  12. func popcntMaskSliceAsm(s, m []uint64) uint64
  13. //go:noescape
  14. func popcntAndSliceAsm(s, m []uint64) uint64
  15. //go:noescape
  16. func popcntOrSliceAsm(s, m []uint64) uint64
  17. //go:noescape
  18. func popcntXorSliceAsm(s, m []uint64) uint64
  19. func popcntSlice(s []uint64) uint64 {
  20. if useAsm {
  21. return popcntSliceAsm(s)
  22. }
  23. return popcntSliceGo(s)
  24. }
  25. func popcntMaskSlice(s, m []uint64) uint64 {
  26. if useAsm {
  27. return popcntMaskSliceAsm(s, m)
  28. }
  29. return popcntMaskSliceGo(s, m)
  30. }
  31. func popcntAndSlice(s, m []uint64) uint64 {
  32. if useAsm {
  33. return popcntAndSliceAsm(s, m)
  34. }
  35. return popcntAndSliceGo(s, m)
  36. }
  37. func popcntOrSlice(s, m []uint64) uint64 {
  38. if useAsm {
  39. return popcntOrSliceAsm(s, m)
  40. }
  41. return popcntOrSliceGo(s, m)
  42. }
  43. func popcntXorSlice(s, m []uint64) uint64 {
  44. if useAsm {
  45. return popcntXorSliceAsm(s, m)
  46. }
  47. return popcntXorSliceGo(s, m)
  48. }