summaryrefslogtreecommitdiffstats
path: root/contrib/go/_std_1.24/src/internal/cpu/cpu_loong64_hwcap.go
blob: 58397adae82c10d92a643883a68a579a6b36eb48 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright 2023 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.

//go:build loong64 && linux

package cpu

// This is initialized by archauxv and should not be changed after it is
// initialized.
var HWCap uint

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

func hwcapInit() {
	// 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)
}

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