[llvm] r366868 - [RISCV] Implement benchmark::cycleclock::Now

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 5 01:09:57 PDT 2019


Merged to release_90 in r367810.

On Wed, Jul 24, 2019 at 7:33 AM Roger Ferrer Ibanez via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
> Author: rogfer01
> Date: Tue Jul 23 22:33:46 2019
> New Revision: 366868
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366868&view=rev
> Log:
> [RISCV] Implement benchmark::cycleclock::Now
>
> This is a cherrypick of D64237 onto llvm/utils/benchmark and
> libcxx/utils/google-benchmark.
>
> Differential Revision: https://reviews.llvm.org/D65142
>
> Modified:
>     llvm/trunk/utils/benchmark/README.LLVM
>     llvm/trunk/utils/benchmark/src/cycleclock.h
>
> Modified: llvm/trunk/utils/benchmark/README.LLVM
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/benchmark/README.LLVM?rev=366868&r1=366867&r2=366868&view=diff
> ==============================================================================
> --- llvm/trunk/utils/benchmark/README.LLVM (original)
> +++ llvm/trunk/utils/benchmark/README.LLVM Tue Jul 23 22:33:46 2019
> @@ -23,3 +23,5 @@ Changes:
>    is applied to disable exceptions in Microsoft STL when exceptions are disabled
>  * Disabled CMake get_git_version as it is meaningless for this in-tree build,
>    and hardcoded a null version
> +* https://github.com/google/benchmark/commit/4abdfbb802d1b514703223f5f852ce4a507d32d2
> +  is applied on top of v1.4.1 to add RISC-V timer support.
>
> Modified: llvm/trunk/utils/benchmark/src/cycleclock.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/benchmark/src/cycleclock.h?rev=366868&r1=366867&r2=366868&view=diff
> ==============================================================================
> --- llvm/trunk/utils/benchmark/src/cycleclock.h (original)
> +++ llvm/trunk/utils/benchmark/src/cycleclock.h Tue Jul 23 22:33:46 2019
> @@ -164,6 +164,21 @@ inline BENCHMARK_ALWAYS_INLINE int64_t N
>    uint64_t tsc;
>    asm("stck %0" : "=Q" (tsc) : : "cc");
>    return tsc;
> +#elif defined(__riscv) // RISC-V
> +  // Use RDCYCLE (and RDCYCLEH on riscv32)
> +#if __riscv_xlen == 32
> +  uint64_t cycles_low, cycles_hi0, cycles_hi1;
> +  asm("rdcycleh %0" : "=r"(cycles_hi0));
> +  asm("rdcycle %0" : "=r"(cycles_lo));
> +  asm("rdcycleh %0" : "=r"(cycles_hi1));
> +  // This matches the PowerPC overflow detection, above
> +  cycles_lo &= -static_cast<int64_t>(cycles_hi0 == cycles_hi1);
> +  return (cycles_hi1 << 32) | cycles_lo;
> +#else
> +  uint64_t cycles;
> +  asm("rdcycle %0" : "=r"(cycles));
> +  return cycles;
> +#endif
>  #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
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list