summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.s
blob: 4465fbe9e905b9d623acab011a2a52285083ec56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// +build !appengine
// +build gc
// +build !noasm

#include "textflag.h"
#include "funcdata.h"
#include "go_asm.h"

TEXT ·x86extensions(SB), NOSPLIT, $0
	// 1. determine max EAX value
	XORQ AX, AX
	CPUID

	CMPQ AX, $7
	JB   unsupported

	// 2. EAX = 7, ECX = 0 --- see Table 3-8 "Information Returned by CPUID Instruction"
	MOVQ $7, AX
	MOVQ $0, CX
	CPUID

	BTQ   $3, BX // bit 3 = BMI1
	SETCS AL

	BTQ   $8, BX // bit 8 = BMI2
	SETCS AH

	MOVB AL, bmi1+0(FP)
	MOVB AH, bmi2+1(FP)
	RET

unsupported:
	XORQ AX, AX
	MOVB AL, bmi1+0(FP)
	MOVB AL, bmi2+1(FP)
	RET