1
0
mirror of https://github.com/golang/go synced 2024-11-23 14:50:07 -07:00

internal/cpu: update arm64 cpu features

Follow the Linux Kernel 4.15
Add Arm64 minimalFeatures test

Change-Id: I1c092521ba59b1e4096c27786fa0464f9ef7d311
Reviewed-on: https://go-review.googlesource.com/103636
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Meng Zhuo 2018-03-31 10:07:03 +08:00 committed by Brad Fitzpatrick
parent 55732ad839
commit 8a525b8e7f
3 changed files with 76 additions and 20 deletions

View File

@ -73,6 +73,21 @@ type arm64 struct {
HasSHA2 bool
HasCRC32 bool
HasATOMICS bool
HasFPHP bool
HasASIMDHP bool
HasCPUID bool
HasASIMDRDM bool
HasJSCVT bool
HasFCMA bool
HasLRCPC bool
HasDCPOP bool
HasSHA3 bool
HasSM3 bool
HasSM4 bool
HasASIMDDP bool
HasSHA512 bool
HasSVE bool
HasASIMDFHM bool
_ [CacheLineSize]byte
}

View File

@ -25,6 +25,21 @@ const (
hwcap_SHA2 = (1 << 6)
hwcap_CRC32 = (1 << 7)
hwcap_ATOMICS = (1 << 8)
hwcap_FPHP = (1 << 9)
hwcap_ASIMDHP = (1 << 10)
hwcap_CPUID = (1 << 11)
hwcap_ASIMDRDM = (1 << 12)
hwcap_JSCVT = (1 << 13)
hwcap_FCMA = (1 << 14)
hwcap_LRCPC = (1 << 15)
hwcap_DCPOP = (1 << 16)
hwcap_SHA3 = (1 << 17)
hwcap_SM3 = (1 << 18)
hwcap_SM4 = (1 << 19)
hwcap_ASIMDDP = (1 << 20)
hwcap_SHA512 = (1 << 21)
hwcap_SVE = (1 << 22)
hwcap_ASIMDFHM = (1 << 23)
)
func init() {
@ -38,6 +53,21 @@ func init() {
ARM64.HasSHA2 = isSet(arm64_hwcap, hwcap_SHA2)
ARM64.HasCRC32 = isSet(arm64_hwcap, hwcap_CRC32)
ARM64.HasATOMICS = isSet(arm64_hwcap, hwcap_ATOMICS)
ARM64.HasFPHP = isSet(arm64_hwcap, hwcap_FPHP)
ARM64.HasASIMDHP = isSet(arm64_hwcap, hwcap_ASIMDHP)
ARM64.HasCPUID = isSet(arm64_hwcap, hwcap_CPUID)
ARM64.HasASIMDRDM = isSet(arm64_hwcap, hwcap_ASIMDRDM)
ARM64.HasJSCVT = isSet(arm64_hwcap, hwcap_JSCVT)
ARM64.HasFCMA = isSet(arm64_hwcap, hwcap_FCMA)
ARM64.HasLRCPC = isSet(arm64_hwcap, hwcap_LRCPC)
ARM64.HasDCPOP = isSet(arm64_hwcap, hwcap_DCPOP)
ARM64.HasSHA3 = isSet(arm64_hwcap, hwcap_SHA3)
ARM64.HasSM3 = isSet(arm64_hwcap, hwcap_SM3)
ARM64.HasSM4 = isSet(arm64_hwcap, hwcap_SM4)
ARM64.HasASIMDDP = isSet(arm64_hwcap, hwcap_ASIMDDP)
ARM64.HasSHA512 = isSet(arm64_hwcap, hwcap_SHA512)
ARM64.HasSVE = isSet(arm64_hwcap, hwcap_SVE)
ARM64.HasASIMDFHM = isSet(arm64_hwcap, hwcap_ASIMDFHM)
}
func isSet(hwc uint, value uint) bool {

View File

@ -48,3 +48,14 @@ func TestPPC64minimalFeatures(t *testing.T) {
}
}
}
func TestARM64minimalFeatures(t *testing.T) {
if runtime.GOARCH == "arm64" {
if !cpu.ARM64.HasASIMD {
t.Fatalf("HasASIMD expected true, got false")
}
if !cpu.ARM64.HasFP {
t.Fatalf("HasFP expected true, got false")
}
}
}