Skip to content

Commit 7758090

Browse files
mhr3gopherbot
authored andcommitted
cpu: add support for sve2 detection
Fixes golang/go#66952 Change-Id: Idaf2ce3b09baf33cf29079677a83a51ea9c4b255 GitHub-Last-Rev: eac0088 GitHub-Pull-Request: #193 Reviewed-on: https://go-review.googlesource.com/c/sys/+/580655 Reviewed-by: Ian Lance Taylor <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Tobias Klauser <[email protected]>
1 parent 9a28524 commit 7758090

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

cpu/cpu.go

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ var ARM64 struct {
103103
HasASIMDDP bool // Advanced SIMD double precision instruction set
104104
HasSHA512 bool // SHA512 hardware implementation
105105
HasSVE bool // Scalable Vector Extensions
106+
HasSVE2 bool // Scalable Vector Extensions 2
106107
HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32
107108
_ CacheLinePad
108109
}

cpu/cpu_arm64.go

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func initOptions() {
2828
{Name: "sm3", Feature: &ARM64.HasSM3},
2929
{Name: "sm4", Feature: &ARM64.HasSM4},
3030
{Name: "sve", Feature: &ARM64.HasSVE},
31+
{Name: "sve2", Feature: &ARM64.HasSVE2},
3132
{Name: "crc32", Feature: &ARM64.HasCRC32},
3233
{Name: "atomics", Feature: &ARM64.HasATOMICS},
3334
{Name: "asimdhp", Feature: &ARM64.HasASIMDHP},
@@ -164,6 +165,15 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) {
164165
switch extractBits(pfr0, 32, 35) {
165166
case 1:
166167
ARM64.HasSVE = true
168+
169+
parseARM64SVERegister(getzfr0())
170+
}
171+
}
172+
173+
func parseARM64SVERegister(zfr0 uint64) {
174+
switch extractBits(zfr0, 0, 3) {
175+
case 1:
176+
ARM64.HasSVE2 = true
167177
}
168178
}
169179

cpu/cpu_arm64.s

+8
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@ TEXT ·getpfr0(SB),NOSPLIT,$0-8
2929
WORD $0xd5380400
3030
MOVD R0, ret+0(FP)
3131
RET
32+
33+
// func getzfr0() uint64
34+
TEXT ·getzfr0(SB),NOSPLIT,$0-8
35+
// get SVE Feature Register 0 into x0
36+
// mrs x0, ID_AA64ZFR0_EL1 = d5380480
37+
WORD $0xd5380480
38+
MOVD R0, ret+0(FP)
39+
RET

cpu/cpu_gc_arm64.go

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ package cpu
99
func getisar0() uint64
1010
func getisar1() uint64
1111
func getpfr0() uint64
12+
func getzfr0() uint64

cpu/cpu_linux_arm64.go

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const (
3535
hwcap_SHA512 = 1 << 21
3636
hwcap_SVE = 1 << 22
3737
hwcap_ASIMDFHM = 1 << 23
38+
39+
hwcap2_SVE2 = 1 << 1
3840
)
3941

4042
// linuxKernelCanEmulateCPUID reports whether we're running
@@ -104,6 +106,9 @@ func doinit() {
104106
ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512)
105107
ARM64.HasSVE = isSet(hwCap, hwcap_SVE)
106108
ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM)
109+
110+
// HWCAP2 feature bits
111+
ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2)
107112
}
108113

109114
func isSet(hwc uint, value uint) bool {

0 commit comments

Comments
 (0)