github.com/panjjo/go@v0.0.0-20161104043856-d62b31386338/src/runtime/os_linux_ppc64x.go (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build ppc64 ppc64le 6 7 package runtime 8 9 import ( 10 "runtime/internal/sys" 11 ) 12 13 const ( 14 // ISA level 15 // Go currently requires POWER5 as a minimum for ppc64, so we need 16 // to check for ISA 2.03 and beyond. 17 _PPC_FEATURE_POWER5_PLUS = 0x00020000 // ISA 2.03 (POWER5+) 18 _PPC_FEATURE_ARCH_2_05 = 0x00001000 // ISA 2.05 (POWER6) 19 _PPC_FEATURE_POWER6_EXT = 0x00000200 // mffgpr/mftgpr extension (POWER6x) 20 _PPC_FEATURE_ARCH_2_06 = 0x00000100 // ISA 2.06 (POWER7) 21 _PPC_FEATURE2_ARCH_2_07 = 0x80000000 // ISA 2.07 (POWER8) 22 23 // Standalone capabilities 24 _PPC_FEATURE_HAS_ALTIVEC = 0x10000000 // SIMD/Vector unit 25 _PPC_FEATURE_HAS_VSX = 0x00000080 // Vector scalar unit 26 ) 27 28 type facilities struct { 29 _ [sys.CacheLineSize]byte 30 isPOWER5x bool // ISA 2.03 31 isPOWER6 bool // ISA 2.05 32 isPOWER6x bool // ISA 2.05 + mffgpr/mftgpr extension 33 isPOWER7 bool // ISA 2.06 34 isPOWER8 bool // ISA 2.07 35 hasVMX bool // Vector unit 36 hasVSX bool // Vector scalar unit 37 _ [sys.CacheLineSize]byte 38 } 39 40 // cpu can be tested at runtime in go assembler code to check for 41 // a certain ISA level or hardware capability, for example: 42 // ·cpu+facilities_hasVSX(SB) for checking the availability of VSX 43 // or 44 // ·cpu+facilities_isPOWER7(SB) for checking if the processor implements 45 // ISA 2.06 instructions. 46 var cpu facilities 47 48 func archauxv(tag, val uintptr) { 49 switch tag { 50 case _AT_HWCAP: 51 cpu.isPOWER5x = val&_PPC_FEATURE_POWER5_PLUS != 0 52 cpu.isPOWER6 = val&_PPC_FEATURE_ARCH_2_05 != 0 53 cpu.isPOWER6x = val&_PPC_FEATURE_POWER6_EXT != 0 54 cpu.isPOWER7 = val&_PPC_FEATURE_ARCH_2_06 != 0 55 cpu.hasVMX = val&_PPC_FEATURE_HAS_ALTIVEC != 0 56 cpu.hasVSX = val&_PPC_FEATURE_HAS_VSX != 0 57 case _AT_HWCAP2: 58 cpu.isPOWER8 = val&_PPC_FEATURE2_ARCH_2_07 != 0 59 } 60 }