@@ -57,18 +57,18 @@ pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult {
5757 let edx;
5858 #[ cfg( target_arch = "x86" ) ]
5959 {
60- asm ! ( "cpuid"
61- : "={eax}" ( eax) , "={ebx}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
62- : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
63- : : ) ;
60+ llvm_asm ! ( "cpuid"
61+ : "={eax}" ( eax) , "={ebx}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
62+ : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
63+ : : ) ;
6464 }
6565 #[ cfg( target_arch = "x86_64" ) ]
6666 {
6767 // x86-64 uses %rbx as the base register, so preserve it.
68- asm ! ( "cpuid"
69- : "={eax}" ( eax) , "={ebx}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
70- : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
71- : "rbx" : ) ;
68+ llvm_asm ! ( "cpuid"
69+ : "={eax}" ( eax) , "={ebx}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
70+ : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
71+ : "rbx" : ) ;
7272 }
7373 CpuidResult { eax, ebx, ecx, edx }
7474}
@@ -113,29 +113,29 @@ pub fn has_cpuid() -> bool {
113113 // If it is, then `cpuid` is available.
114114 let result: u32 ;
115115 let _temp: u32 ;
116- asm ! ( r#"
117- # Read eflags into $0 and copy it into $1:
118- pushfd
119- pop $0
120- mov $1, $0
121- # Flip 21st bit of $0.
122- xor $0, 0x200000
123- # Set eflags to the value of $0
124- #
125- # Bit 21st can only be modified if cpuid is available
126- push $0
127- popfd # A
128- # Read eflags into $0:
129- pushfd # B
130- pop $0
131- # xor with the original eflags sets the bits that
132- # have been modified:
133- xor $0, $1
134- "#
135- : "=r" ( result) , "=r" ( _temp)
136- :
137- : "cc" , "memory"
138- : "intel" ) ;
116+ llvm_asm ! ( r#"
117+ # Read eflags into $0 and copy it into $1:
118+ pushfd
119+ pop $0
120+ mov $1, $0
121+ # Flip 21st bit of $0.
122+ xor $0, 0x200000
123+ # Set eflags to the value of $0
124+ #
125+ # Bit 21st can only be modified if cpuid is available
126+ push $0
127+ popfd # A
128+ # Read eflags into $0:
129+ pushfd # B
130+ pop $0
131+ # xor with the original eflags sets the bits that
132+ # have been modified:
133+ xor $0, $1
134+ "#
135+ : "=r" ( result) , "=r" ( _temp)
136+ :
137+ : "cc" , "memory"
138+ : "intel" ) ;
139139 // There is a race between popfd (A) and pushfd (B)
140140 // where other bits beyond 21st may have been modified due to
141141 // interrupts, a debugger stepping through the asm, etc.
0 commit comments