Retro68/gcc/libgo/go/internal/cpu/cpu_ppc64x.go

45 lines
1.2 KiB
Go
Raw Normal View History

2018-12-28 15:30:48 +00:00
// 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.
// +build ppc64 ppc64le
package cpu
// ppc64x doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
2019-06-02 15:48:37 +00:00
// These are initialized by archauxv in runtime/os_linux_ppc64x.go.
// These should not be changed after they are initialized.
// On aix/ppc64, these values are initialized early in the runtime in runtime/os_aix.go.
var HWCap uint
var HWCap2 uint
2018-12-28 15:30:48 +00:00
// HWCAP/HWCAP2 bits. These are exposed by the kernel.
const (
// ISA Level
2019-06-02 15:48:37 +00:00
PPC_FEATURE2_ARCH_2_07 = 0x80000000
PPC_FEATURE2_ARCH_3_00 = 0x00800000
2018-12-28 15:30:48 +00:00
// CPU features
2019-06-02 15:48:37 +00:00
PPC_FEATURE2_DARN = 0x00200000
PPC_FEATURE2_SCV = 0x00100000
2018-12-28 15:30:48 +00:00
)
2019-06-02 15:48:37 +00:00
func doinit() {
options = []option{
{Name: "darn", Feature: &PPC64.HasDARN},
{Name: "scv", Feature: &PPC64.HasSCV},
{Name: "power9", Feature: &PPC64.IsPOWER9},
{Name: "power8", Feature: &PPC64.IsPOWER8},
}
2018-12-28 15:30:48 +00:00
// HWCAP2 feature bits
2019-06-02 15:48:37 +00:00
PPC64.IsPOWER8 = isSet(HWCap2, PPC_FEATURE2_ARCH_2_07)
PPC64.IsPOWER9 = isSet(HWCap2, PPC_FEATURE2_ARCH_3_00)
PPC64.HasDARN = isSet(HWCap2, PPC_FEATURE2_DARN)
PPC64.HasSCV = isSet(HWCap2, PPC_FEATURE2_SCV)
2018-12-28 15:30:48 +00:00
}
func isSet(hwc uint, value uint) bool {
return hwc&value != 0
}