本站源代码
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.1KB

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