[PATCH] D65142: [RISCV] Implement benchmark::cycleclock::Now for riscv64-linux

Roger Ferrer Ibanez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 23 06:56:31 PDT 2019


rogfer01 created this revision.
rogfer01 added reviewers: asb, lenary, luismarques.
Herald added subscribers: llvm-commits, benna, psnobl, lebedev.ri, PkmX, rkruppe, shiva0217, kito-cheng.
Herald added a reviewer: lebedev.ri.
Herald added a project: LLVM.

We have been cross-compiling LLVM using `riscv64-unknown-linux-gnu-gcc` and we found that this function has to be implemented for a successful build.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65142

Files:
  llvm/utils/benchmark/src/cycleclock.h


Index: llvm/utils/benchmark/src/cycleclock.h
===================================================================
--- llvm/utils/benchmark/src/cycleclock.h
+++ llvm/utils/benchmark/src/cycleclock.h
@@ -164,6 +164,10 @@
   uint64_t tsc;
   asm("stck %0" : "=Q" (tsc) : : "cc");
   return tsc;
+#elif defined(__riscv) && __riscv_xlen == 64
+  uint64_t cycle;
+  asm("rdcycle %0" : "=r"(cycle));
+  return cycle;
 #else
 // The soft failover to a generic implementation is automatic only for ARM.
 // For other platforms the developer is expected to make an attempt to create


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65142.211285.patch
Type: text/x-patch
Size: 572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190723/e3078266/attachment.bin>


More information about the llvm-commits mailing list