From bd5fe7b010ea0d6c4b1e5e3740085f5eabf7def6 Mon Sep 17 00:00:00 2001 From: Min-Yih Hsu Date: Mon, 5 Oct 2020 20:24:33 -0700 Subject: [PATCH] [M680x0] Add google/benchmark's CycleTimer support for M68K This is a cherrypick of the upstream fix commit ffe1342 onto `llvm/utils/benchmark` and `libcxx/utils/google-benchmark`. This adds CycleTimer implementation for M680x0, which simply uses `gettimeofday` same as MIPS. Differential Review: https://reviews.llvm.org/D88868 --- libcxx/utils/google-benchmark/AUTHORS | 1 + libcxx/utils/google-benchmark/CONTRIBUTORS | 1 + libcxx/utils/google-benchmark/README.LLVM | 2 ++ libcxx/utils/google-benchmark/src/cycleclock.h | 2 +- llvm/utils/benchmark/AUTHORS | 1 + llvm/utils/benchmark/CONTRIBUTORS | 1 + llvm/utils/benchmark/README.LLVM | 2 ++ llvm/utils/benchmark/src/cycleclock.h | 2 +- 8 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libcxx/utils/google-benchmark/AUTHORS b/libcxx/utils/google-benchmark/AUTHORS index 09e2e0551adf..3593870661ec 100644 --- a/libcxx/utils/google-benchmark/AUTHORS +++ b/libcxx/utils/google-benchmark/AUTHORS @@ -46,3 +46,4 @@ Stripe, Inc. Yixuan Qiu Yusuke Suzuki Zbigniew Skowron +Min-Yih Hsu diff --git a/libcxx/utils/google-benchmark/CONTRIBUTORS b/libcxx/utils/google-benchmark/CONTRIBUTORS index ee74ff886c0c..9e7a39f25881 100644 --- a/libcxx/utils/google-benchmark/CONTRIBUTORS +++ b/libcxx/utils/google-benchmark/CONTRIBUTORS @@ -66,3 +66,4 @@ Tom Madams Yixuan Qiu Yusuke Suzuki Zbigniew Skowron +Min-Yih Hsu diff --git a/libcxx/utils/google-benchmark/README.LLVM b/libcxx/utils/google-benchmark/README.LLVM index ea92eee202ce..7a0c02c420d4 100644 --- a/libcxx/utils/google-benchmark/README.LLVM +++ b/libcxx/utils/google-benchmark/README.LLVM @@ -22,3 +22,5 @@ Changes: to fix timestamp-related inline asm issues and 32-bit RISC-V build failures. The second cherrypicked commit fixes formatting issues introduced by the preceding change. +* https://github.com/google/benchmark/commit/ffe1342eb2faa7d2e7c35b4db2ccf99fab81ec20 + is applied to add the CycleTimer implementation for M680x0 diff --git a/libcxx/utils/google-benchmark/src/cycleclock.h b/libcxx/utils/google-benchmark/src/cycleclock.h index 179c67cd614a..93d579a739c1 100644 --- a/libcxx/utils/google-benchmark/src/cycleclock.h +++ b/libcxx/utils/google-benchmark/src/cycleclock.h @@ -161,7 +161,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { struct timeval tv; gettimeofday(&tv, nullptr); return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; -#elif defined(__mips__) +#elif defined(__mips__) || defined(__m68k__) // mips apparently only allows rdtsc for superusers, so we fall // back to gettimeofday. It's possible clock_gettime would be better. struct timeval tv; diff --git a/llvm/utils/benchmark/AUTHORS b/llvm/utils/benchmark/AUTHORS index 381a8f486afb..052a383f77cd 100644 --- a/llvm/utils/benchmark/AUTHORS +++ b/llvm/utils/benchmark/AUTHORS @@ -44,3 +44,4 @@ Stripe, Inc. Yixuan Qiu Yusuke Suzuki Zbigniew Skowron +Min-Yih Hsu diff --git a/llvm/utils/benchmark/CONTRIBUTORS b/llvm/utils/benchmark/CONTRIBUTORS index 1cf04db17e4e..53e7b6f9f8b4 100644 --- a/llvm/utils/benchmark/CONTRIBUTORS +++ b/llvm/utils/benchmark/CONTRIBUTORS @@ -63,3 +63,4 @@ Tom Madams Yixuan Qiu Yusuke Suzuki Zbigniew Skowron +Min-Yih Hsu diff --git a/llvm/utils/benchmark/README.LLVM b/llvm/utils/benchmark/README.LLVM index b370925b9543..afd70a3dd914 100644 --- a/llvm/utils/benchmark/README.LLVM +++ b/llvm/utils/benchmark/README.LLVM @@ -33,3 +33,5 @@ Changes: are applied on top of the previous cherrypick to fix timestamp-related inline asm issues and 32-bit RISC-V build failures. The second cherrypicked commit fixes formatting issues introduced by the preceding change. +* https://github.com/google/benchmark/commit/ffe1342eb2faa7d2e7c35b4db2ccf99fab81ec20 + is applied to add the CycleTimer implementation for M680x0 diff --git a/llvm/utils/benchmark/src/cycleclock.h b/llvm/utils/benchmark/src/cycleclock.h index 1b0f09359c9b..88b7805faafa 100644 --- a/llvm/utils/benchmark/src/cycleclock.h +++ b/llvm/utils/benchmark/src/cycleclock.h @@ -161,7 +161,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { struct timeval tv; gettimeofday(&tv, nullptr); return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; -#elif defined(__mips__) +#elif defined(__mips__) || defined(__m68k__) // mips apparently only allows rdtsc for superusers, so we fall // back to gettimeofday. It's possible clock_gettime would be better. struct timeval tv;