Skip to content

Commit 5d1f519

Browse files
authored
Add riscv64 support in x9 and rANS (#15669)
- x9.c: add a riscv64 branch to the arch guards, emitting the PAUSE hint (Zihintpause) as a raw .4byte encoding so it assembles regardless of -march and is a NOP on cores without the extension. - rANS defines.h: add riscv64 (64-bit) to the coder-detection guard so the existing scalar Compat/SingleStream coders are selected; no SIMD. Refs #15664
1 parent e4d1882 commit 5d1f519

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

  • Framework/Foundation/3rdparty/x9
  • Utilities/rANS/include/rANS/internal/common

Framework/Foundation/3rdparty/x9/x9.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#if defined(__x86_64__) || defined(__i386__)
3939
#include <immintrin.h> /* _mm_pause */
4040
#elif defined(__aarch64__)
41+
#elif defined(__riscv)
4142
#else
4243
#error Not supported architecture
4344
#endif
@@ -370,6 +371,8 @@ void x9_read_from_inbox_spin(x9_inbox* const inbox,
370371
_mm_pause();
371372
#elif defined(__aarch64__)
372373
__asm__ __volatile__ ("yield");
374+
#elif defined(__riscv)
375+
__asm__ __volatile__ (".4byte 0x0100000F"); /* PAUSE hint (Zihintpause); NOP if unsupported */
373376
#else
374377
#error Not supported architecture
375378
#endif

Utilities/rANS/include/rANS/internal/common/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#error RANS_FMA cannot be directly set
4141
#endif
4242

43-
#if (defined(__x86_64__) || defined(__aarch64__))
43+
#if (defined(__x86_64__) || defined(__aarch64__) || (defined(__riscv) && __riscv_xlen == 64))
4444
#define RANS_COMPAT
4545
#if defined(__SIZEOF_INT128__)
4646
#define RANS_SINGLE_STREAM

0 commit comments

Comments
 (0)