| 1 |
// Copyright 2023 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 |
//go:build loong64 && linux |
| 6 |
|
| 7 |
package cpu |
| 8 |
|
| 9 |
// This is initialized by archauxv and should not be changed after it is |
| 10 |
// initialized. |
| 11 |
var HWCap uint |
| 12 |
|
| 13 |
// HWCAP bits. These are exposed by the Linux kernel. |
| 14 |
const ( |
| 15 |
hwcap_LOONGARCH_LSX = 1 << 4 |
| 16 |
hwcap_LOONGARCH_LASX = 1 << 5 |
| 17 |
) |
| 18 |
|
| 19 |
func hwcapInit() { |
| 20 |
// TODO: Features that require kernel support like LSX and LASX can |
| 21 |
// be detected here once needed in std library or by the compiler. |
| 22 |
Loong64.HasLSX = hwcIsSet(HWCap, hwcap_LOONGARCH_LSX) |
| 23 |
Loong64.HasLASX = hwcIsSet(HWCap, hwcap_LOONGARCH_LASX) |
| 24 |
} |
| 25 |
|
| 26 |
func hwcIsSet(hwc uint, val uint) bool { |
| 27 |
return hwc&val != 0 |
| 28 |
} |