github.com/hlts2/go@v0.0.0-20170904000733-812b34efaed8/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  	HasOSXSAVE   bool
    24  	HasPCLMULQDQ bool
    25  	HasPOPCNT    bool
    26  	HasSSE2      bool
    27  	HasSSE3      bool
    28  	HasSSSE3     bool
    29  	HasSSE41     bool
    30  	HasSSE42     bool
    31  	_            [CacheLineSize]byte
    32  }
    33  
    34  var PPC64 ppc64
    35  
    36  // For ppc64x, it is safe to check only for ISA level starting on ISA v3.00,
    37  // since there are no optional categories. There are some exceptions that also
    38  // require kernel support to work (darn, scv), so there are capability bits for
    39  // those as well. The minimum processor requirement is POWER8 (ISA 2.07), so we
    40  // maintain some of the old capability checks for optional categories for
    41  // safety.
    42  // The struct is padded to avoid false sharing.
    43  type ppc64 struct {
    44  	_          [CacheLineSize]byte
    45  	HasVMX     bool // Vector unit (Altivec)
    46  	HasDFP     bool // Decimal Floating Point unit
    47  	HasVSX     bool // Vector-scalar unit
    48  	HasHTM     bool // Hardware Transactional Memory
    49  	HasISEL    bool // Integer select
    50  	HasVCRYPTO bool // Vector cryptography
    51  	HasHTMNOSC bool // HTM: kernel-aborted transaction in syscalls
    52  	HasDARN    bool // Hardware random number generator (requires kernel enablement)
    53  	HasSCV     bool // Syscall vectored (requires kernel enablement)
    54  	IsPOWER8   bool // ISA v2.07 (POWER8)
    55  	IsPOWER9   bool // ISA v3.00 (POWER9)
    56  	_          [CacheLineSize]byte
    57  }