github.com/corona10/go@v0.0.0-20180224231303-7a218942be57/src/internal/cpu/cpu_arm64.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 // +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 hwcap_FP = (1 << 0) 20 hwcap_ASIMD = (1 << 1) 21 hwcap_EVTSTRM = (1 << 2) 22 hwcap_AES = (1 << 3) 23 hwcap_PMULL = (1 << 4) 24 hwcap_SHA1 = (1 << 5) 25 hwcap_SHA2 = (1 << 6) 26 hwcap_CRC32 = (1 << 7) 27 hwcap_ATOMICS = (1 << 8) 28 ) 29 30 func init() { 31 // HWCAP feature bits 32 ARM64.HasFP = isSet(arm64_hwcap, hwcap_FP) 33 ARM64.HasASIMD = isSet(arm64_hwcap, hwcap_ASIMD) 34 ARM64.HasEVTSTRM = isSet(arm64_hwcap, hwcap_EVTSTRM) 35 ARM64.HasAES = isSet(arm64_hwcap, hwcap_AES) 36 ARM64.HasPMULL = isSet(arm64_hwcap, hwcap_PMULL) 37 ARM64.HasSHA1 = isSet(arm64_hwcap, hwcap_SHA1) 38 ARM64.HasSHA2 = isSet(arm64_hwcap, hwcap_SHA2) 39 ARM64.HasCRC32 = isSet(arm64_hwcap, hwcap_CRC32) 40 ARM64.HasATOMICS = isSet(arm64_hwcap, hwcap_ATOMICS) 41 } 42 43 func isSet(hwc uint, value uint) bool { 44 return hwc&value != 0 45 }