mirror of https://github.com/golang/go.git
runtime: move s390x HWCap CPU feature detection to internal/cpu
Change-Id: I7d9e31c3b342731ddd7329962426fdfc80e9ed87 Reviewed-on: https://go-review.googlesource.com/c/go/+/263803 Trust: Martin Möhrmann <moehrmann@google.com> Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
parent
91b7619310
commit
f8aecbbff5
|
|
@ -6,6 +6,8 @@ package cpu
|
||||||
|
|
||||||
const CacheLinePadSize = 256
|
const CacheLinePadSize = 256
|
||||||
|
|
||||||
|
var HWCap uint
|
||||||
|
|
||||||
// bitIsSet reports whether the bit at index is set. The bit index
|
// bitIsSet reports whether the bit at index is set. The bit index
|
||||||
// is in big endian order, so bit index 0 is the leftmost bit.
|
// is in big endian order, so bit index 0 is the leftmost bit.
|
||||||
func bitIsSet(bits []uint64, index uint) bool {
|
func bitIsSet(bits []uint64, index uint) bool {
|
||||||
|
|
@ -95,8 +97,10 @@ const (
|
||||||
// vector facilities
|
// vector facilities
|
||||||
vxe facility = 135 // vector-enhancements 1
|
vxe facility = 135 // vector-enhancements 1
|
||||||
|
|
||||||
// Note: vx and highgprs are excluded because they require
|
// Note: vx requires kernel support
|
||||||
// kernel support and so must be fetched from HWCAP.
|
// and so must be fetched from HWCAP.
|
||||||
|
|
||||||
|
hwcap_VX = 1 << 11 // vector facility
|
||||||
)
|
)
|
||||||
|
|
||||||
// facilityList contains the result of an STFLE call.
|
// facilityList contains the result of an STFLE call.
|
||||||
|
|
@ -188,7 +192,14 @@ func doinit() {
|
||||||
S390X.HasEDDSA = kdsa.Has(eddsaVerifyEd25519, eddsaSignEd25519, eddsaVerifyEd448, eddsaSignEd448)
|
S390X.HasEDDSA = kdsa.Has(eddsaVerifyEd25519, eddsaSignEd25519, eddsaVerifyEd448, eddsaSignEd448)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
S390X.HasVX = isSet(HWCap, hwcap_VX)
|
||||||
|
|
||||||
if S390X.HasVX {
|
if S390X.HasVX {
|
||||||
S390X.HasVXE = facilities.Has(vxe)
|
S390X.HasVXE = facilities.Has(vxe)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isSet(hwc uint, value uint) bool {
|
||||||
|
return hwc&value != 0
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,10 @@ package runtime
|
||||||
|
|
||||||
import "internal/cpu"
|
import "internal/cpu"
|
||||||
|
|
||||||
const (
|
|
||||||
// bit masks taken from bits/hwcap.h
|
|
||||||
_HWCAP_S390_VX = 2048 // vector facility
|
|
||||||
)
|
|
||||||
|
|
||||||
func archauxv(tag, val uintptr) {
|
func archauxv(tag, val uintptr) {
|
||||||
switch tag {
|
switch tag {
|
||||||
case _AT_HWCAP: // CPU capability bit flags
|
case _AT_HWCAP:
|
||||||
cpu.S390X.HasVX = val&_HWCAP_S390_VX != 0
|
cpu.HWCap = uint(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue