aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/cycles.h
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-09 14:27:41 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-09 14:27:41 +0100
commit7c403eb8d50a0292c741b25ff967d2a170637258 (patch)
treea43a116a67c83163be18ffb91868e661761d78c5 /test/monniaux/cycles.h
parente16fff7a60904a760f5c11b0bc700abdbdd5d467 (diff)
downloadcompcert-kvx-7c403eb8d50a0292c741b25ff967d2a170637258.tar.gz
compcert-kvx-7c403eb8d50a0292c741b25ff967d2a170637258.zip
cycles for aarch64
Diffstat (limited to 'test/monniaux/cycles.h')
-rw-r--r--test/monniaux/cycles.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/monniaux/cycles.h b/test/monniaux/cycles.h
index 4a87299b..aed9941a 100644
--- a/test/monniaux/cycles.h
+++ b/test/monniaux/cycles.h
@@ -1,5 +1,6 @@
#include <inttypes.h>
#include <stdio.h>
+
typedef unsigned long cycle_t;
#ifdef MAX_MEASURES
@@ -39,12 +40,27 @@ static inline cycle_t get_cycle(void) {
}
#elif defined (__ARM_ARCH) && (__ARM_ARCH >= 6)
+#if (__ARM_ARCH < 8)
+/* need this kernel module
+https://github.com/zertyz/MTL/tree/master/cpp/time/kernel/arm */
static inline cycle_t get_cycle(void) {
cycle_t cycles;
__asm__ volatile ("mrc p15, 0, %0, c9, c13, 0":"=r" (cycles));
return cycles;
}
+#else
+/* need this kernel module:
+https://github.com/jerinjacobk/armv8_pmu_cycle_counter_el0
+on 5+ kernels, remove first argument of access_ok macro */
+
+static inline cycle_t get_cycle(void)
+{
+ uint64_t val;
+ __asm__ volatile("mrs %0, pmccntr_el0" : "=r"(val));
+ return val;
+}
+#endif
#else
static inline cycle_t get_cycle(void) { return 0; }
#endif