Debian Codegraph @

cpu/cpu_linux_loong64.go

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