github.com/mattn/go@v0.0.0-20171011075504-07f7db3ea99f/src/internal/cpu/cpu.go (about)

     1  // Copyright 2017 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  // Package cpu implements processor feature detection
     6  // used by the Go standard library.
     7  package cpu
     8  
     9  var X86 x86
    10  
    11  // The booleans in x86 contain the correspondingly named cpuid feature bit.
    12  // HasAVX and HasAVX2 are only set if the OS does support XMM and YMM registers
    13  // in addition to the cpuid feature bit being set.
    14  // The struct is padded to avoid false sharing.
    15  type x86 struct {
    16  	_            [CacheLineSize]byte
    17  	HasAES       bool
    18  	HasAVX       bool
    19  	HasAVX2      bool
    20  	HasBMI1      bool
    21  	HasBMI2      bool
    22  	HasERMS      bool
    23  	HasFMA       bool
    24  	HasOSXSAVE   bool
    25  	HasPCLMULQDQ bool
    26  	HasPOPCNT    bool
    27  	HasSSE2      bool
    28  	HasSSE3      bool
    29  	HasSSSE3     bool
    30  	HasSSE41     bool
    31  	HasSSE42     bool
    32  	_            [CacheLineSize]byte
    33  }
    34  
    35  var PPC64 ppc64
    36  
    37  // For ppc64x, it is safe to check only for ISA level starting on ISA v3.00,
    38  // since there are no optional categories. There are some exceptions that also
    39  // require kernel support to work (darn, scv), so there are capability bits for
    40  // those as well. The minimum processor requirement is POWER8 (ISA 2.07), so we
    41  // maintain some of the old capability checks for optional categories for
    42  // safety.
    43  // The struct is padded to avoid false sharing.
    44  type ppc64 struct {
    45  	_          [CacheLineSize]byte
    46  	HasVMX     bool // Vector unit (Altivec)
    47  	HasDFP     bool // Decimal Floating Point unit
    48  	HasVSX     bool // Vector-scalar unit
    49  	HasHTM     bool // Hardware Transactional Memory
    50  	HasISEL    bool // Integer select
    51  	HasVCRYPTO bool // Vector cryptography
    52  	HasHTMNOSC bool // HTM: kernel-aborted transaction in syscalls
    53  	HasDARN    bool // Hardware random number generator (requires kernel enablement)
    54  	HasSCV     bool // Syscall vectored (requires kernel enablement)
    55  	IsPOWER8   bool // ISA v2.07 (POWER8)
    56  	IsPOWER9   bool // ISA v3.00 (POWER9)
    57  	_          [CacheLineSize]byte
    58  }