cpuinfo_amd64.s 562 B

123456789101112131415161718192021222324252627282930313233343536
  1. // +build !appengine
  2. // +build gc
  3. // +build !noasm
  4. #include "textflag.h"
  5. #include "funcdata.h"
  6. #include "go_asm.h"
  7. TEXT ·x86extensions(SB), NOSPLIT, $0
  8. // 1. determine max EAX value
  9. XORQ AX, AX
  10. CPUID
  11. CMPQ AX, $7
  12. JB unsupported
  13. // 2. EAX = 7, ECX = 0 --- see Table 3-8 "Information Returned by CPUID Instruction"
  14. MOVQ $7, AX
  15. MOVQ $0, CX
  16. CPUID
  17. BTQ $3, BX // bit 3 = BMI1
  18. SETCS AL
  19. BTQ $8, BX // bit 8 = BMI2
  20. SETCS AH
  21. MOVB AL, bmi1+0(FP)
  22. MOVB AH, bmi2+1(FP)
  23. RET
  24. unsupported:
  25. XORQ AX, AX
  26. MOVB AL, bmi1+0(FP)
  27. MOVB AL, bmi2+1(FP)
  28. RET