1// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file.
2
3//+build 386,!gccgo,!noasm,!appengine amd64,!gccgo,!noasm,!appengine
4
5package cpuid
6
7func asmCpuid(op uint32) (eax, ebx, ecx, edx uint32)
8func asmCpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32)
9func asmXgetbv(index uint32) (eax, edx uint32)
10func asmRdtscpAsm() (eax, ebx, ecx, edx uint32)
11func asmDarwinHasAVX512() bool
12
13func initCPU() {
14	cpuid = asmCpuid
15	cpuidex = asmCpuidex
16	xgetbv = asmXgetbv
17	rdtscpAsm = asmRdtscpAsm
18	darwinHasAVX512 = asmDarwinHasAVX512
19}
20
21func addInfo(c *CPUInfo, safe bool) {
22	c.maxFunc = maxFunctionID()
23	c.maxExFunc = maxExtendedFunction()
24	c.BrandName = brandName()
25	c.CacheLine = cacheLine()
26	c.Family, c.Model = familyModel()
27	c.featureSet = support()
28	c.SGX = hasSGX(c.featureSet.inSet(SGX), c.featureSet.inSet(SGXLC))
29	c.ThreadsPerCore = threadsPerCore()
30	c.LogicalCores = logicalCores()
31	c.PhysicalCores = physicalCores()
32	c.VendorID, c.VendorString = vendorID()
33	c.cacheSize()
34	c.frequencies()
35}
36