...
Run Format

Source file src/internal/cpu/cpu_arm64.go

Documentation: internal/cpu

     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  // +build arm64
     6  
     7  package cpu
     8  
     9  const CacheLineSize = 64
    10  
    11  // arm64 doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
    12  // These are linknamed in runtime/os_linux_arm64.go and are initialized by
    13  // archauxv().
    14  var arm64_hwcap uint
    15  var arm64_hwcap2 uint
    16  
    17  // HWCAP/HWCAP2 bits. These are exposed by Linux.
    18  const (
    19  	_ARM64_FEATURE_HAS_FP      = (1 << 0)
    20  	_ARM64_FEATURE_HAS_ASIMD   = (1 << 1)
    21  	_ARM64_FEATURE_HAS_EVTSTRM = (1 << 2)
    22  	_ARM64_FEATURE_HAS_AES     = (1 << 3)
    23  	_ARM64_FEATURE_HAS_PMULL   = (1 << 4)
    24  	_ARM64_FEATURE_HAS_SHA1    = (1 << 5)
    25  	_ARM64_FEATURE_HAS_SHA2    = (1 << 6)
    26  	_ARM64_FEATURE_HAS_CRC32   = (1 << 7)
    27  	_ARM64_FEATURE_HAS_ATOMICS = (1 << 8)
    28  )
    29  
    30  func init() {
    31  	// HWCAP feature bits
    32  	ARM64.HasFP = isSet(arm64_hwcap, _ARM64_FEATURE_HAS_FP)
    33  	ARM64.HasASIMD = isSet(arm64_hwcap, _ARM64_FEATURE_HAS_ASIMD)
    34  	ARM64.HasEVTSTRM = isSet(arm64_hwcap, _ARM64_FEATURE_HAS_EVTSTRM)
    35  	ARM64.HasAES = isSet(arm64_hwcap, _ARM64_FEATURE_HAS_AES)
    36  	ARM64.HasPMULL = isSet(arm64_hwcap, _ARM64_FEATURE_HAS_PMULL)
    37  	ARM64.HasSHA1 = isSet(arm64_hwcap, _ARM64_FEATURE_HAS_SHA1)
    38  	ARM64.HasSHA2 = isSet(arm64_hwcap, _ARM64_FEATURE_HAS_SHA2)
    39  	ARM64.HasCRC32 = isSet(arm64_hwcap, _ARM64_FEATURE_HAS_CRC32)
    40  	ARM64.HasATOMICS = isSet(arm64_hwcap, _ARM64_FEATURE_HAS_ATOMICS)
    41  }
    42  
    43  func isSet(hwc uint, value uint) bool {
    44  	return hwc&value != 0
    45  }
    46  

View as plain text