summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/sys/cpu/cpu_linux_loong64.go
blob: 4f34114329eae0065c3204c42f07f29b33b6b838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package cpu

// HWCAP bits. These are exposed by the Linux kernel.
const (
	hwcap_LOONGARCH_LSX  = 1 << 4
	hwcap_LOONGARCH_LASX = 1 << 5
)

func doinit() {
	// TODO: Features that require kernel support like LSX and LASX can
	// be detected here once needed in std library or by the compiler.
	Loong64.HasLSX = hwcIsSet(hwCap, hwcap_LOONGARCH_LSX)
	Loong64.HasLASX = hwcIsSet(hwCap, hwcap_LOONGARCH_LASX)
}

func hwcIsSet(hwc uint, val uint) bool {
	return hwc&val != 0
}