1 // Copyright 2018 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.
7 #if defined(__i386__) || defined(__x86_64__)
14 #if defined(__i386__) || defined(__x86_64__)
23 struct cpuid_ret
cpuid(uint32_t, uint32_t)
24 __asm__(GOSYM_PREFIX
"internal_cpu.cpuid")
25 __attribute__((no_split_stack
));
27 struct cpuid_ret
cpuid(uint32_t eaxArg
, uint32_t ecxArg
) {
34 __get_cpuid_count(eaxArg
, ecxArg
, &eax
, &ebx
, &ecx
, &edx
);
35 ret
.eax
= (uint32_t)(eax
);
36 ret
.ebx
= (uint32_t)(ebx
);
37 ret
.ecx
= (uint32_t)(ecx
);
38 ret
.edx
= (uint32_t)(edx
);
47 struct xgetbv_ret
xgetbv(void)
48 __asm__(GOSYM_PREFIX
"internal_cpu.xgetbv")
49 __attribute__((no_split_stack
));
51 #pragma GCC push_options
52 #pragma GCC target("xsave")
54 struct xgetbv_ret
xgetbv(void) {
55 struct xgetbv_ret ret
;
57 // At some point, use call to _xgetbv() instead:
59 // long long r = _xgetbv(0);
60 // ret.eax = r & 0xffffffff;
63 unsigned int __eax
, __edx
, __xcr_no
= 0;
64 __asm__ ("xgetbv" : "=a" (__eax
), "=d" (__edx
) : "c" (__xcr_no
));
70 #pragma GCC pop_options
72 #endif /* defined(__i386__) || defined(__x86_64__) */