1 /* { dg-do assemble { target x86_64-*-* } } */
2 /* { dg-require-effective-target lp64 } */
3 
4 #include "../analyzer-decls.h"
5 
6 typedef unsigned __INT32_TYPE__ u32;
7 typedef unsigned __INT64_TYPE__ u64;
8 
9 extern void check_init_u32 (u32 v);
10 extern void check_init_u64 (u32 v);
11 
12 /* Adapted from linux kernel: arch/x86/include/asm/processor.h (GPL-2.0).  */
13 
native_cpuid(unsigned int * eax,unsigned int * ebx,unsigned int * ecx,unsigned int * edx)14 static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
15 				unsigned int *ecx, unsigned int *edx)
16 {
17 	/* ecx is often an input as well as an output. */
18 	asm volatile("cpuid"
19 	    : "=a" (*eax),
20 	      "=b" (*ebx),
21 	      "=c" (*ecx),
22 	      "=d" (*edx)
23 	    : "0" (*eax), "2" (*ecx)
24 	    : "memory");
25 }
26 
cpuid(unsigned int op,unsigned int * eax,unsigned int * ebx,unsigned int * ecx,unsigned int * edx)27 static inline void cpuid(unsigned int op,
28 			 unsigned int *eax, unsigned int *ebx,
29 			 unsigned int *ecx, unsigned int *edx)
30 {
31 	*eax = op;
32 	*ecx = 0;
33 	native_cpuid(eax, ebx, ecx, edx);
34 }
35 
test_1(void)36 void test_1 (void)
37 {
38   u32 eax, ebx, ecx, edx;
39   cpuid(0x8000001e, &eax, &ebx, &ecx, &edx); /* from "amd_get_topology".  */
40 
41   /* Verify that they are now initialized.  */
42   check_init_u32 (eax);
43   check_init_u32 (ebx);
44   check_init_u32 (ecx);
45   check_init_u32 (edx);
46 }
47