Skip to content

Commit 89f3e89

Browse files
committed
[C++] Patch vendored pcg library to enable msvc arm64 intrinsics
This enables building Arrow C++ for Windows ARM64 with MSVC when setting ARROW_SIMD_LEVEL to NONE (to disable xsimd usage, which does not support msvc arm64 intrinsics, and is non-trivial to fix). This patch is based on imneme/pcg-cpp#99. The upstream pcg library has not been updated in the past 3 years, so this may never get merged.
1 parent ed91f6f commit 89f3e89

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cpp/src/arrow/vendored/pcg/pcg_uint128.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
#define PCG_LITTLE_ENDIAN 1
6868
#elif __BIG_ENDIAN__ || _BIG_ENDIAN
6969
#define PCG_LITTLE_ENDIAN 0
70-
#elif __x86_64 || __x86_64__ || _M_X64 || __i386 || __i386__ || _M_IX86
70+
#elif __x86_64 || __x86_64__ || _M_X64 || __i386 || __i386__ || _M_IX86 || _M_ARM64
7171
#define PCG_LITTLE_ENDIAN 1
7272
#elif __powerpc__ || __POWERPC__ || __ppc__ || __PPC__ \
7373
|| __m68k__ || __mc68000__
@@ -734,7 +734,13 @@ uint_x4<UInt,UIntX2> operator*(const uint_x4<UInt,UIntX2>& a,
734734

735735
#if PCG_64BIT_SPECIALIZATIONS
736736
#if defined(_MSC_VER)
737+
#if defined(_M_X64) || defined(_M_IX86)
737738
#pragma intrinsic(_umul128)
739+
#elif defined(_M_ARM64)
740+
#pragma intrinsic(__umulh)
741+
#else
742+
#error Unsupported architecture
743+
#endif
738744
#endif
739745

740746
#if defined(_MSC_VER) || __SIZEOF_INT128__
@@ -743,8 +749,15 @@ uint_x4<UInt32,uint64_t> operator*(const uint_x4<UInt32,uint64_t>& a,
743749
const uint_x4<UInt32,uint64_t>& b)
744750
{
745751
#if defined(_MSC_VER)
752+
#if defined(_M_X64) || defined(_M_IX86)
746753
uint64_t hi;
747754
uint64_t lo = _umul128(a.d.v01, b.d.v01, &hi);
755+
#elif defined(_M_ARM64)
756+
uint64_t lo = a.d.v01 * b.d.v01;
757+
uint64_t hi = __umulh(a.d.v01, b.d.v01);
758+
#else
759+
#error Unsupported architecture
760+
#endif
748761
#else
749762
__uint128_t r = __uint128_t(a.d.v01) * __uint128_t(b.d.v01);
750763
uint64_t lo = uint64_t(r);

0 commit comments

Comments
 (0)