cpu_linux_arm64.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package cpu
  5. const cacheLineSize = 64
  6. // HWCAP/HWCAP2 bits. These are exposed by Linux.
  7. const (
  8. hwcap_FP = 1 << 0
  9. hwcap_ASIMD = 1 << 1
  10. hwcap_EVTSTRM = 1 << 2
  11. hwcap_AES = 1 << 3
  12. hwcap_PMULL = 1 << 4
  13. hwcap_SHA1 = 1 << 5
  14. hwcap_SHA2 = 1 << 6
  15. hwcap_CRC32 = 1 << 7
  16. hwcap_ATOMICS = 1 << 8
  17. hwcap_FPHP = 1 << 9
  18. hwcap_ASIMDHP = 1 << 10
  19. hwcap_CPUID = 1 << 11
  20. hwcap_ASIMDRDM = 1 << 12
  21. hwcap_JSCVT = 1 << 13
  22. hwcap_FCMA = 1 << 14
  23. hwcap_LRCPC = 1 << 15
  24. hwcap_DCPOP = 1 << 16
  25. hwcap_SHA3 = 1 << 17
  26. hwcap_SM3 = 1 << 18
  27. hwcap_SM4 = 1 << 19
  28. hwcap_ASIMDDP = 1 << 20
  29. hwcap_SHA512 = 1 << 21
  30. hwcap_SVE = 1 << 22
  31. hwcap_ASIMDFHM = 1 << 23
  32. )
  33. func doinit() {
  34. // HWCAP feature bits
  35. ARM64.HasFP = isSet(hwCap, hwcap_FP)
  36. ARM64.HasASIMD = isSet(hwCap, hwcap_ASIMD)
  37. ARM64.HasEVTSTRM = isSet(hwCap, hwcap_EVTSTRM)
  38. ARM64.HasAES = isSet(hwCap, hwcap_AES)
  39. ARM64.HasPMULL = isSet(hwCap, hwcap_PMULL)
  40. ARM64.HasSHA1 = isSet(hwCap, hwcap_SHA1)
  41. ARM64.HasSHA2 = isSet(hwCap, hwcap_SHA2)
  42. ARM64.HasCRC32 = isSet(hwCap, hwcap_CRC32)
  43. ARM64.HasATOMICS = isSet(hwCap, hwcap_ATOMICS)
  44. ARM64.HasFPHP = isSet(hwCap, hwcap_FPHP)
  45. ARM64.HasASIMDHP = isSet(hwCap, hwcap_ASIMDHP)
  46. ARM64.HasCPUID = isSet(hwCap, hwcap_CPUID)
  47. ARM64.HasASIMDRDM = isSet(hwCap, hwcap_ASIMDRDM)
  48. ARM64.HasJSCVT = isSet(hwCap, hwcap_JSCVT)
  49. ARM64.HasFCMA = isSet(hwCap, hwcap_FCMA)
  50. ARM64.HasLRCPC = isSet(hwCap, hwcap_LRCPC)
  51. ARM64.HasDCPOP = isSet(hwCap, hwcap_DCPOP)
  52. ARM64.HasSHA3 = isSet(hwCap, hwcap_SHA3)
  53. ARM64.HasSM3 = isSet(hwCap, hwcap_SM3)
  54. ARM64.HasSM4 = isSet(hwCap, hwcap_SM4)
  55. ARM64.HasASIMDDP = isSet(hwCap, hwcap_ASIMDDP)
  56. ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512)
  57. ARM64.HasSVE = isSet(hwCap, hwcap_SVE)
  58. ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM)
  59. }
  60. func isSet(hwc uint, value uint) bool {
  61. return hwc&value != 0
  62. }