Fix PowerPC support (#6292)

This commit is contained in:
Sergey Fedorov 2025-08-16 02:25:32 +08:00 committed by GitHub
parent 9c11f5e05d
commit ece4469869
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 3 deletions

View File

@ -214,6 +214,7 @@ Ryszard Rozak
Samuel Riedel Samuel Riedel
Sean Cross Sean Cross
Sebastien Van Cauwenberghe Sebastien Van Cauwenberghe
Sergey Fedorov
Sergi Granell Sergi Granell
Seth Pellegrino Seth Pellegrino
Shou-Li Hsu Shou-Li Hsu

View File

@ -575,7 +575,9 @@ static inline double VL_ROUND(double n) {
# define VL_CPU_RELAX() asm volatile("nop" ::: "memory") # define VL_CPU_RELAX() asm volatile("nop" ::: "memory")
#elif defined(__mips64el__) || defined(__mips__) || defined(__mips64__) || defined(__mips64) #elif defined(__mips64el__) || defined(__mips__) || defined(__mips64__) || defined(__mips64)
# define VL_CPU_RELAX() asm volatile("pause" ::: "memory") # define VL_CPU_RELAX() asm volatile("pause" ::: "memory")
#elif defined(__powerpc64__) #elif defined(__POWERPC__) && defined(__APPLE__) // First check for a special case of macOS
# define VL_CPU_RELAX() asm volatile("or r1, r1, r1; or r2, r2, r2;" ::: "memory")
#elif defined(__powerpc64__) || defined(__powerpc__) // Generic powerpc
# define VL_CPU_RELAX() asm volatile("or 1, 1, 1; or 2, 2, 2;" ::: "memory") # define VL_CPU_RELAX() asm volatile("or 1, 1, 1; or 2, 2, 2;" ::: "memory")
#elif defined(__riscv) // RiscV does not currently have yield/pause, but one is proposed #elif defined(__riscv) // RiscV does not currently have yield/pause, but one is proposed
# define VL_CPU_RELAX() asm volatile("nop" ::: "memory") # define VL_CPU_RELAX() asm volatile("nop" ::: "memory")

View File

@ -38,7 +38,7 @@
#if defined(__linux) #if defined(__linux)
# include <sched.h> // For sched_getcpu() # include <sched.h> // For sched_getcpu()
#endif #endif
#if defined(__APPLE__) && !defined(__arm64__) #if defined(__APPLE__) && !defined(__arm64__) && !defined(__POWERPC__)
# include <cpuid.h> // For __cpuid_count() # include <cpuid.h> // For __cpuid_count()
#endif #endif
// clang-format on // clang-format on
@ -88,7 +88,7 @@ double DeltaWallTime::gettime() VL_MT_SAFE {
uint16_t getcpu() VL_MT_SAFE { uint16_t getcpu() VL_MT_SAFE {
#if defined(__linux) #if defined(__linux)
return sched_getcpu(); // TODO: this is a system call. Not exactly cheap. return sched_getcpu(); // TODO: this is a system call. Not exactly cheap.
#elif defined(__APPLE__) && !defined(__arm64__) #elif defined(__APPLE__) && !defined(__arm64__) && !defined(__POWERPC__)
uint32_t info[4]; uint32_t info[4];
__cpuid_count(1, 0, info[0], info[1], info[2], info[3]); __cpuid_count(1, 0, info[0], info[1], info[2], info[3]);
// info[1] is EBX, bits 24-31 are APIC ID // info[1] is EBX, bits 24-31 are APIC ID