diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-06-18 21:20:03 +0200 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-06-18 21:20:03 +0200 |
commit | cde2827856693a98f89d21e11dca258ef6c08ce2 (patch) | |
tree | 1ecd5afd401a72dc25ca315456ffa4991e48c373 /test/monniaux/cycles.h | |
parent | 82db72dbd06eced8f72ca4a41e08892b908b5036 (diff) | |
download | compcert-kvx-cde2827856693a98f89d21e11dca258ef6c08ce2.tar.gz compcert-kvx-cde2827856693a98f89d21e11dca258ef6c08ce2.zip |
for RiscV
Diffstat (limited to 'test/monniaux/cycles.h')
-rw-r--r-- | test/monniaux/cycles.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/monniaux/cycles.h b/test/monniaux/cycles.h index e4f098cd..4231a34e 100644 --- a/test/monniaux/cycles.h +++ b/test/monniaux/cycles.h @@ -23,6 +23,14 @@ static inline void cycle_count_config(void) { } #ifdef __x86_64__ #include <x86intrin.h> static inline cycle_t get_cycle(void) { return __rdtsc(); } + +#elif __riscv +static inline cycle_t get_cycle(void) { + cycle_t cycles; + asm volatile ("rdcycle %0" : "=r" (cycles)); + return cycles; +} + #else static inline cycle_t get_cycle(void) { return 0; } #endif |