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
5package cpu
6
7// HWCAP bits. These are exposed by the Linux kernel.
8const (
9 hwcap_LOONGARCH_LSX = 1 << 4
10 hwcap_LOONGARCH_LASX = 1 << 5
11)
12
13func 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
20func hwcIsSet(hwc uint, val uint) bool {
21 return hwc&val != 0
22}