Skip to content

Commit 1d904b7

Browse files
authored
Merge pull request #186 from andjo403/at_and_t
counters: use AT&T inline asm syntax for older LLVM.
2 parents b4da534 + 7577447 commit 1d904b7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

measureme/src/counters.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,19 +558,24 @@ mod hw {
558558
fn serialize_instruction_execution() {
559559
unsafe {
560560
asm!(
561-
"xor eax, eax",
561+
"xor %eax, %eax", // Intel syntax: "xor eax, eax"
562562
// LLVM sometimes reserves `ebx` for its internal use, so we need to use
563563
// a scratch register for it instead.
564-
"mov {tmp_rbx:r}, rbx",
564+
"mov %rbx, {tmp_rbx:r}", // Intel syntax: "mov {tmp_rbx:r}, rbx"
565565
"cpuid",
566-
"mov rbx, {tmp_rbx:r}",
566+
"mov {tmp_rbx:r}, %rbx", // Intel syntax: "mov rbx, {tmp_rbx:r}"
567567
tmp_rbx = lateout(reg) _,
568568
// `cpuid` clobbers.
569569
lateout("eax") _,
570570
lateout("edx") _,
571571
lateout("ecx") _,
572572

573573
options(nostack),
574+
// Older versions of LLVM do not support modifiers in
575+
// Intel syntax inline asm; whenever Rust minimum LLVM version
576+
// supports Intel syntax inline asm, remove and replace above
577+
// instructions with Intel syntax version (from comments).
578+
options(att_syntax),
574579
);
575580
}
576581
}
@@ -588,7 +593,12 @@ mod hw {
588593
in("ecx") reg_idx,
589594
lateout("eax") lo,
590595
lateout("edx") hi,
591-
options(nostack)
596+
options(nostack),
597+
// Older versions of LLVM do not support modifiers in
598+
// Intel syntax inline asm; whenever Rust minimum LLVM version
599+
// supports Intel syntax inline asm, remove and replace above
600+
// instructions with Intel syntax version (from comments).
601+
options(att_syntax),
592602
);
593603
}
594604
lo as u64 | (hi as u64) << 32

0 commit comments

Comments
 (0)