Exclude unsupported x64 intrinsics from ARM64EC (#1135)

ARM64EC is a Microsoft-designed ARM64 ABI compatible with AMD64
applications on ARM64 Windows 11. The ARM64EC does not support
_umul128 and __rdtsc as x64 intrinsics, though it provides inline
function implementations for them, by emulation. Since the code
already has portable code paths without using the intrinsics,
instead of using the emulated intrinsic implementations, we use
the said portable code paths for ARM64EC.
pull/1137/head
Ben Niu 3 years ago committed by GitHub
parent c33f21f86a
commit 4c015dbb49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      absl/base/internal/unscaledcycleclock.h
  2. 4
      absl/numeric/int128.h

@ -47,7 +47,7 @@
// The following platforms have an implementation of a hardware counter. // The following platforms have an implementation of a hardware counter.
#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \ #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
defined(__powerpc__) || defined(__ppc__) || defined(__riscv) || \ defined(__powerpc__) || defined(__ppc__) || defined(__riscv) || \
defined(_M_IX86) || defined(_M_X64) defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC))
#define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1 #define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1
#else #else
#define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 0 #define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 0

@ -44,7 +44,7 @@
// builtin type. We need to make sure not to define operator wchar_t() // builtin type. We need to make sure not to define operator wchar_t()
// alongside operator unsigned short() in these instances. // alongside operator unsigned short() in these instances.
#define ABSL_INTERNAL_WCHAR_T __wchar_t #define ABSL_INTERNAL_WCHAR_T __wchar_t
#if defined(_M_X64) #if defined(_M_X64) && !defined(_M_ARM64EC)
#include <intrin.h> #include <intrin.h>
#pragma intrinsic(_umul128) #pragma intrinsic(_umul128)
#endif // defined(_M_X64) #endif // defined(_M_X64)
@ -980,7 +980,7 @@ inline uint128 operator*(uint128 lhs, uint128 rhs) {
// can be used for uint128 storage. // can be used for uint128 storage.
return static_cast<unsigned __int128>(lhs) * return static_cast<unsigned __int128>(lhs) *
static_cast<unsigned __int128>(rhs); static_cast<unsigned __int128>(rhs);
#elif defined(_MSC_VER) && defined(_M_X64) #elif defined(_MSC_VER) && defined(_M_X64) && !defined(_M_ARM64EC)
uint64_t carry; uint64_t carry;
uint64_t low = _umul128(Uint128Low64(lhs), Uint128Low64(rhs), &carry); uint64_t low = _umul128(Uint128Low64(lhs), Uint128Low64(rhs), &carry);
return MakeUint128(Uint128Low64(lhs) * Uint128High64(rhs) + return MakeUint128(Uint128Low64(lhs) * Uint128High64(rhs) +

Loading…
Cancel
Save