// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build 386 amd64 amd64p32

package cpu

const cacheLineSize = 64

func init() {
	Initialized = true

	, , ,  := cpuid(0, 0)

	if  < 1 {
		return
	}

	, , ,  := cpuid(1, 0)
	X86.HasSSE2 = isSet(26, )

	X86.HasSSE3 = isSet(0, )
	X86.HasPCLMULQDQ = isSet(1, )
	X86.HasSSSE3 = isSet(9, )
	X86.HasFMA = isSet(12, )
	X86.HasSSE41 = isSet(19, )
	X86.HasSSE42 = isSet(20, )
	X86.HasPOPCNT = isSet(23, )
	X86.HasAES = isSet(25, )
	X86.HasOSXSAVE = isSet(27, )
	X86.HasRDRAND = isSet(30, )

	 := false
	// For XGETBV, OSXSAVE bit is required and sufficient.
	if X86.HasOSXSAVE {
		,  := xgetbv()
		// Check if XMM and YMM registers have OS support.
		 = isSet(1, ) && isSet(2, )
	}

	X86.HasAVX = isSet(28, ) && 

	if  < 7 {
		return
	}

	, , ,  := cpuid(7, 0)
	X86.HasBMI1 = isSet(3, )
	X86.HasAVX2 = isSet(5, ) && 
	X86.HasBMI2 = isSet(8, )
	X86.HasERMS = isSet(9, )
	X86.HasRDSEED = isSet(18, )
	X86.HasADX = isSet(19, )
}

func isSet( uint,  uint32) bool {
	return &(1<<) != 0
}