From 366008657484f55182b1b08e1e137ac53e8f3574 Mon Sep 17 00:00:00 2001 From: XieJiSS Date: Wed, 28 Feb 2024 09:52:06 +0800 Subject: [PATCH 1/2] feat: add riscv detection macros in config.hpp --- src/external/cpuid/platform/src/platform/config.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/external/cpuid/platform/src/platform/config.hpp b/src/external/cpuid/platform/src/platform/config.hpp index b50390edc..a196ce53f 100644 --- a/src/external/cpuid/platform/src/platform/config.hpp +++ b/src/external/cpuid/platform/src/platform/config.hpp @@ -55,6 +55,10 @@ #define PLATFORM_MIPS 1 #define PLATFORM_CLANG_MIPS 1 #define PLATFORM_GCC_COMPATIBLE_MIPS 1 +#elif defined(__riscv) +#define PLATFORM_RISCV 1 +#define PLATFORM_CLANG_RISCV 1 +#define PLATFORM_GCC_COMPATIBLE_RISCV 1 #elif defined(__asmjs__) #define PLATFORM_ASMJS 1 #define PLATFORM_CLANG_ASMJS 1 @@ -75,6 +79,10 @@ #define PLATFORM_MIPS 1 #define PLATFORM_GCC_MIPS 1 #define PLATFORM_GCC_COMPATIBLE_MIPS 1 +#elif defined(__riscv) +#define PLATFORM_RISCV 1 +#define PLATFORM_GCC_RISCV 1 +#define PLATFORM_GCC_COMPATIBLE_RISCV 1 #endif #elif defined(_MSC_VER) #define PLATFORM_MSVC 1 From 2780c18d5b8a4e0689ac96e34544a8a4f07c9a8d Mon Sep 17 00:00:00 2001 From: XieJiSS Date: Wed, 28 Feb 2024 10:11:59 +0800 Subject: [PATCH 2/2] feat: add pause support for riscv --- external/atomic_queue/include/atomic_queue/defs.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/external/atomic_queue/include/atomic_queue/defs.h b/external/atomic_queue/include/atomic_queue/defs.h index a279dcf8d..24fb5dfc2 100644 --- a/external/atomic_queue/include/atomic_queue/defs.h +++ b/external/atomic_queue/include/atomic_queue/defs.h @@ -31,6 +31,12 @@ static inline void spin_loop_pause() noexcept { defined(__ARM_ARCH_8A__) || \ defined(__aarch64__)) asm volatile ("yield" ::: "memory"); +#elif defined(__riscv) +#if defined(__riscv_zihintpause) + asm volatile ("pause" ::: "memory"); +#else + /* Encoding of the pause instruction, will be treated as nop if not supported by hardware */ + asm volatile (".4byte 0x100000F"); #else asm volatile ("nop" ::: "memory"); #endif