Closed
Description
None of the "a" -- "d" constraints (to use the eax
-- edx
registers) works as expected.
#![feature(asm)]
fn main() {
let x: u32;
unsafe {
asm!( "xor $0, $0" : "=r"(x) );
// asm!( "xor $0, $0" : "=a"(x) );
};
println!("{}", x);
}
If I enable the commented-out line, I get:
error: couldn't allocate output register for constraint 'a' at line 20
But Clang/LLVM 3.0 (Ubuntu 12.04 package) understands them:
int main(void) {
int x;
__asm__ __volatile__ ( "xor %0, %0" : "=a"(x) );
__asm__ __volatile__ ( "xor %0, %0" : "=b"(x) );
__asm__ __volatile__ ( "xor %0, %0" : "=c"(x) );
__asm__ __volatile__ ( "xor %0, %0" : "=d"(x) );
return 0;
}
00000000004004c0 <main>:
4004c0: 53 push %rbx
4004c1: 31 c0 xor %eax,%eax
4004c3: 31 db xor %ebx,%ebx
4004c5: 31 c9 xor %ecx,%ecx
4004c7: 31 d2 xor %edx,%edx
4004c9: 31 c0 xor %eax,%eax
4004cb: 5b pop %rbx
4004cc: c3 retq
4004cd: 90 nop
4004ce: 90 nop
4004cf: 90 nop