mirror of
https://github.com/golang/go.git
synced 2025-05-30 11:51:34 +00:00
internal/cpu: add MIPS64x feature detection
Change-Id: Iacdad1758aa15e4703fccef38c08ecb338b95fd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/200579 Run-TryBot: Meng Zhuo <mengzhuo1203@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
618126b989
commit
e48a83f077
@ -134,6 +134,14 @@ type s390x struct {
|
|||||||
_ CacheLinePad
|
_ CacheLinePad
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var MIPS64X mips64x
|
||||||
|
|
||||||
|
type mips64x struct {
|
||||||
|
_ CacheLinePad
|
||||||
|
HasMSA bool // MIPS SIMD architecture
|
||||||
|
_ CacheLinePad
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize examines the processor and sets the relevant variables above.
|
// Initialize examines the processor and sets the relevant variables above.
|
||||||
// This is called by the runtime package early in program initialization,
|
// This is called by the runtime package early in program initialization,
|
||||||
// before normal init functions are run. env is set by runtime if the OS supports
|
// before normal init functions are run. env is set by runtime if the OS supports
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package cpu
|
|
||||||
|
|
||||||
const CacheLinePadSize = 32
|
|
@ -1,7 +0,0 @@
|
|||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package cpu
|
|
||||||
|
|
||||||
const CacheLinePadSize = 32
|
|
32
src/internal/cpu/cpu_mips64x.go
Normal file
32
src/internal/cpu/cpu_mips64x.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build mips64 mips64le
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const CacheLinePadSize = 32
|
||||||
|
|
||||||
|
// These are initialized by archauxv in runtime/os_linux_mips64x.go.
|
||||||
|
// These should not be changed after they are initialized.
|
||||||
|
var HWCap uint
|
||||||
|
|
||||||
|
// HWCAP bits. These are exposed by the Linux kernel 5.4.
|
||||||
|
const (
|
||||||
|
// CPU features
|
||||||
|
hwcap_MIPS_MSA = 1 << 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func doinit() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "msa", Feature: &MIPS64X.HasMSA},
|
||||||
|
}
|
||||||
|
|
||||||
|
// HWCAP feature bits
|
||||||
|
MIPS64X.HasMSA = isSet(HWCap, hwcap_MIPS_MSA)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isSet(hwc uint, value uint) bool {
|
||||||
|
return hwc&value != 0
|
||||||
|
}
|
@ -9,6 +9,8 @@
|
|||||||
// +build !ppc64
|
// +build !ppc64
|
||||||
// +build !ppc64le
|
// +build !ppc64le
|
||||||
// +build !s390x
|
// +build !s390x
|
||||||
|
// +build !mips64
|
||||||
|
// +build !mips64le
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
|
@ -7,7 +7,13 @@
|
|||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
|
import "internal/cpu"
|
||||||
|
|
||||||
func archauxv(tag, val uintptr) {
|
func archauxv(tag, val uintptr) {
|
||||||
|
switch tag {
|
||||||
|
case _AT_HWCAP:
|
||||||
|
cpu.HWCap = uint(val)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func osArchInit() {}
|
func osArchInit() {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user