Skip to content

Commit

Permalink
Merge pull request #186 from andjo403/at_and_t
Browse files Browse the repository at this point in the history
counters: use AT&T inline asm syntax for older LLVM.
  • Loading branch information
eddyb committed Oct 6, 2021
2 parents b4da534 + 7577447 commit 1d904b7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions measureme/src/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,19 +558,24 @@ mod hw {
fn serialize_instruction_execution() {
unsafe {
asm!(
"xor eax, eax",
"xor %eax, %eax", // Intel syntax: "xor eax, eax"
// LLVM sometimes reserves `ebx` for its internal use, so we need to use
// a scratch register for it instead.
"mov {tmp_rbx:r}, rbx",
"mov %rbx, {tmp_rbx:r}", // Intel syntax: "mov {tmp_rbx:r}, rbx"
"cpuid",
"mov rbx, {tmp_rbx:r}",
"mov {tmp_rbx:r}, %rbx", // Intel syntax: "mov rbx, {tmp_rbx:r}"
tmp_rbx = lateout(reg) _,
// `cpuid` clobbers.
lateout("eax") _,
lateout("edx") _,
lateout("ecx") _,

options(nostack),
// Older versions of LLVM do not support modifiers in
// Intel syntax inline asm; whenever Rust minimum LLVM version
// supports Intel syntax inline asm, remove and replace above
// instructions with Intel syntax version (from comments).
options(att_syntax),
);
}
}
Expand All @@ -588,7 +593,12 @@ mod hw {
in("ecx") reg_idx,
lateout("eax") lo,
lateout("edx") hi,
options(nostack)
options(nostack),
// Older versions of LLVM do not support modifiers in
// Intel syntax inline asm; whenever Rust minimum LLVM version
// supports Intel syntax inline asm, remove and replace above
// instructions with Intel syntax version (from comments).
options(att_syntax),
);
}
lo as u64 | (hi as u64) << 32
Expand Down

0 comments on commit 1d904b7

Please sign in to comment.