From c34ecd87181a6d325a2b60d023da235bfebb140a Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Fri, 24 Feb 2023 00:37:50 +0100 Subject: [PATCH] Add RCPC ISA detection on win-arm64 (#82527) * Add RCPC ISA detection on win-arm64 * Address feedback --- .../Runtime/windows/PalRedhawkMinWin.cpp | 22 +++++++++++++++++++ src/coreclr/vm/codeman.cpp | 11 +++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/Runtime/windows/PalRedhawkMinWin.cpp b/src/coreclr/nativeaot/Runtime/windows/PalRedhawkMinWin.cpp index 2d53bbf33edbf..1d2b9766b4fdc 100644 --- a/src/coreclr/nativeaot/Runtime/windows/PalRedhawkMinWin.cpp +++ b/src/coreclr/nativeaot/Runtime/windows/PalRedhawkMinWin.cpp @@ -761,6 +761,18 @@ REDHAWK_PALIMPORT void REDHAWK_PALAPI PAL_GetCpuCapabilityFlags(int* flags) { *flags = 0; +// Older version of SDK would return false for these intrinsics +// but make sure we pass the right values to the APIs +#ifndef PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE +#define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34 +#endif +#ifndef PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE +#define PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE 43 +#endif +#ifndef PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE +#define PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE 45 +#endif + // FP and SIMD support are enabled by default *flags |= ARM64IntrinsicConstants_AdvSimd; @@ -780,6 +792,16 @@ REDHAWK_PALIMPORT void REDHAWK_PALAPI PAL_GetCpuCapabilityFlags(int* flags) { *flags |= ARM64IntrinsicConstants_Atomics; } + + if (IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE)) + { + *flags |= ARM64IntrinsicConstants_Dp; + } + + if (IsProcessorFeaturePresent(PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE)) + { + *flags |= ARM64IntrinsicConstants_Rcpc; + } } #endif diff --git a/src/coreclr/vm/codeman.cpp b/src/coreclr/vm/codeman.cpp index 471bd1628d32a..a2eee4ca59898 100644 --- a/src/coreclr/vm/codeman.cpp +++ b/src/coreclr/vm/codeman.cpp @@ -1656,7 +1656,10 @@ void EEJitManager::SetCpuInfo() #define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34 #endif #ifndef PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE -# define PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE 43 +#define PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE 43 +#endif +#ifndef PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE +#define PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE 45 #endif // PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE (34) @@ -1671,6 +1674,12 @@ void EEJitManager::SetCpuInfo() CPUCompileFlags.Set(InstructionSet_Dp); } + // PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE (45) + if (IsProcessorFeaturePresent(PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE)) + { + CPUCompileFlags.Set(InstructionSet_Rcpc); + } + #endif // HOST_64BIT if (GetDataCacheZeroIDReg() == 4) {