Skip to content

Commit

Permalink
Update to use the now legacy format by using llvm_asm
Browse files Browse the repository at this point in the history
  • Loading branch information
jlb6740 committed Jul 25, 2020
1 parent 7564a33 commit eac5ac4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/cpucounter.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
uint64_t cpucounter(void)
{
uint64_t low, high;
__asm__ __volatile__ ("rdtscp" : "=a" (low), "=d" (high) : : "%ecx");
__asm__ __volatile__("rdtscp"
: "=a"(low), "=d"(high)
:
: "%ecx");
return (high << 32) | low;
}
#elif defined(__aarch64__)
uint64_t cpucounter(void)
{
uint64_t virtual_timer_value;
__asm__ __volatile__ ("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
__asm__ __volatile__("mrs %0, cntvct_el0"
: "=r"(virtual_timer_value));
return virtual_timer_value;
}
#endif
5 changes: 3 additions & 2 deletions src/cpucounter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ unsafe fn cpucounter() -> u64 {
(high << 32) | low
}


// https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h#L116
#[cfg(asm)]
#[inline]
#[cfg(any(target_arch = "aarch64"))]
unsafe fn cpucounter() -> u64 {
let (vtm): (u64);
asm!("mrs %0, cntvct_el0" : "=r"(vtm));
//asm!("mrs %0, cntvct_el0" : "=r"(vtm));
//asm!("mrs %0, cntvct_el0", out(reg) vtm);
asm!("mov {}, 5", out(reg) vtm);
vtm
}

Expand Down

0 comments on commit eac5ac4

Please sign in to comment.