cpu_linux_loong64.go 632 B

12345678910111213141516171819202122
  1. // Copyright 2025 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. // HWCAP bits. These are exposed by the Linux kernel.
  6. const (
  7. hwcap_LOONGARCH_LSX = 1 << 4
  8. hwcap_LOONGARCH_LASX = 1 << 5
  9. )
  10. func doinit() {
  11. // TODO: Features that require kernel support like LSX and LASX can
  12. // be detected here once needed in std library or by the compiler.
  13. Loong64.HasLSX = hwcIsSet(hwCap, hwcap_LOONGARCH_LSX)
  14. Loong64.HasLASX = hwcIsSet(hwCap, hwcap_LOONGARCH_LASX)
  15. }
  16. func hwcIsSet(hwc uint, val uint) bool {
  17. return hwc&val != 0
  18. }