From 45e950adb5d5e0b0e26dda3cb83fd6b9f564ff69 Mon Sep 17 00:00:00 2001 From: Johnnie Birch <45402135+jlb6740@users.noreply.github.com> Date: Fri, 24 Jul 2020 17:57:57 -0700 Subject: [PATCH] Update to use the now legacy format by using llvm_asm https://github.com/rust-lang/rfcs/blob/master/text/2843-llvm-asm.md https://github.com/rust-lang/rfcs/pull/2873 --- src/cpucounter.c | 8 ++++++-- src/cpucounter.rs | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cpucounter.c b/src/cpucounter.c index fce42e2..23fd47c 100644 --- a/src/cpucounter.c +++ b/src/cpucounter.c @@ -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 \ No newline at end of file diff --git a/src/cpucounter.rs b/src/cpucounter.rs index cc0997e..5e4ed27 100644 --- a/src/cpucounter.rs +++ b/src/cpucounter.rs @@ -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 {}, cntvct_el0", out(reg) vtm); vtm }