From ff239dba9a9358b818ab0d37d6271fcfe7619c81 Mon Sep 17 00:00:00 2001 From: Helge Date: Fri, 20 Dec 2024 16:40:55 +0000 Subject: [PATCH 1/2] Cmake: Allow build on HP PA-RISC host machine Fix this configure stage error: -- LLVM host triple: hppa1.1-unknown-linux-gnu CMake Error at cmake/config-ix.cmake:516 (message): Unknown architecture hppa1.1 --- llvm/cmake/config-ix.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index 64878d28d9e1e..1dbb468a46044 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -512,6 +512,10 @@ elseif (LLVM_NATIVE_ARCH STREQUAL "m68k") set(LLVM_NATIVE_ARCH M68k) elseif (LLVM_NATIVE_ARCH MATCHES "loongarch") set(LLVM_NATIVE_ARCH LoongArch) +elseif (LLVM_NATIVE_ARCH MATCHES "hppa1.1") + set(LLVM_NATIVE_ARCH HPPA) +elseif (LLVM_NATIVE_ARCH MATCHES "hppa64") + set(LLVM_NATIVE_ARCH HPPA) else () message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}") endif () From 4c2413dfe3abeb34e285f3504ac8e0d2937dac78 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Fri, 20 Dec 2024 21:42:05 +0000 Subject: [PATCH 2/2] Add clock counter for hppa architecture Add support for time measurements on hppa, otherwise build breaks with this compiler error: You need to define CycleTimer for your OS and CPU --- third-party/benchmark/src/cycleclock.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/third-party/benchmark/src/cycleclock.h b/third-party/benchmark/src/cycleclock.h index d4f1330b671db..723a3bd17094d 100644 --- a/third-party/benchmark/src/cycleclock.h +++ b/third-party/benchmark/src/cycleclock.h @@ -228,6 +228,16 @@ 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(__hppa__) + // HP PA-RISC provides a user-readable clock counter (cr16), but + // it's not syncronized across CPUs and only 32-bit wide when programs + // are built as 32-bit binaries. + // Use clock_gettime(CLOCK_MONOTONIC, ...) instead of gettimeofday + // because is provides nanosecond resolution. + // Initialize to always return 0 if clock_gettime fails. + struct timespec ts = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &ts); + return static_cast(ts.tv_sec) * 1000000000 + ts.tv_nsec; #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