diff --git a/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems b/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems index 7cd55aa5987c..382c641a064f 100644 --- a/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems +++ b/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems @@ -1343,6 +1343,7 @@ + @@ -1350,6 +1351,7 @@ + diff --git a/src/Common/src/CoreLib/System/Runtime/Intrinsics/Arm/Crc32.PlatformNotSupported.cs b/src/Common/src/CoreLib/System/Runtime/Intrinsics/Arm/Crc32.PlatformNotSupported.cs new file mode 100644 index 000000000000..36aa42e81605 --- /dev/null +++ b/src/Common/src/CoreLib/System/Runtime/Intrinsics/Arm/Crc32.PlatformNotSupported.cs @@ -0,0 +1,82 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.CompilerServices; + +namespace System.Runtime.Intrinsics.Arm +{ + /// + /// This class provides access to the ARM Crc32 hardware instructions via intrinsics + /// + [Intrinsic] + [CLSCompliant(false)] + public abstract class Crc32 : ArmBase + { + internal Crc32() { } + + public static new bool IsSupported { [Intrinsic] get { return false; } } + + [Intrinsic] + public new abstract class Arm64 : ArmBase.Arm64 + { + internal Arm64() { } + + public static new bool IsSupported { [Intrinsic] get { return false; } } + + /// + /// uint32_t __crc32d (uint32_t a, uint64_t b) + /// A64: CRC32X Wd, Wn, Xm + /// + public static uint ComputeCrc32(uint crc, ulong data) { throw new PlatformNotSupportedException(); } + + /// + /// uint32_t __crc32cd (uint32_t a, uint64_t b) + /// A64: CRC32CX Wd, Wn, Xm + /// + public static uint ComputeCrc32C(uint crc, ulong data) { throw new PlatformNotSupportedException(); } + } + + /// + /// uint32_t __crc32b (uint32_t a, uint8_t b) + /// A32: CRC32B Rd, Rn, Rm + /// A64: CRC32B Wd, Wn, Wm + /// + public static uint ComputeCrc32(uint crc, byte data) { throw new PlatformNotSupportedException(); } + + /// + /// uint32_t __crc32h (uint32_t a, uint16_t b) + /// A32: CRC32H Rd, Rn, Rm + /// A64: CRC32H Wd, Wn, Wm + /// + public static uint ComputeCrc32(uint crc, ushort data) { throw new PlatformNotSupportedException(); } + + /// + /// uint32_t __crc32w (uint32_t a, uint32_t b) + /// A32: CRC32W Rd, Rn, Rm + /// A64: CRC32W Wd, Wn, Wm + /// + public static uint ComputeCrc32(uint crc, uint data) { throw new PlatformNotSupportedException(); } + + /// + /// uint32_t __crc32cb (uint32_t a, uint8_t b) + /// A32: CRC32CB Rd, Rn, Rm + /// A64: CRC32CB Wd, Wn, Wm + /// + public static uint ComputeCrc32C(uint crc, byte data) { throw new PlatformNotSupportedException(); } + + /// + /// uint32_t __crc32ch (uint32_t a, uint16_t b) + /// A32: CRC32CH Rd, Rn, Rm + /// A64: CRC32CH Wd, Wn, Wm + /// + public static uint ComputeCrc32C(uint crc, ushort data) { throw new PlatformNotSupportedException(); } + + /// + /// uint32_t __crc32cw (uint32_t a, uint32_t b) + /// A32: CRC32CW Rd, Rn, Rm + /// A64: CRC32CW Wd, Wn, Wm + /// + public static uint ComputeCrc32C(uint crc, uint data) { throw new PlatformNotSupportedException(); } + } +} diff --git a/src/Common/src/CoreLib/System/Runtime/Intrinsics/Arm/Crc32.cs b/src/Common/src/CoreLib/System/Runtime/Intrinsics/Arm/Crc32.cs new file mode 100644 index 000000000000..8d5684c08cf3 --- /dev/null +++ b/src/Common/src/CoreLib/System/Runtime/Intrinsics/Arm/Crc32.cs @@ -0,0 +1,82 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.CompilerServices; + +namespace System.Runtime.Intrinsics.Arm +{ + /// + /// This class provides access to the ARM Crc32 hardware instructions via intrinsics + /// + [Intrinsic] + [CLSCompliant(false)] + public abstract class Crc32 : ArmBase + { + internal Crc32() { } + + public static new bool IsSupported { get => IsSupported; } + + [Intrinsic] + public new abstract class Arm64 : ArmBase.Arm64 + { + internal Arm64() { } + + public static new bool IsSupported { get => IsSupported; } + + /// + /// uint32_t __crc32d (uint32_t a, uint64_t b) + /// A64: CRC32X Wd, Wn, Xm + /// + public static uint ComputeCrc32(uint crc, ulong data) => ComputeCrc32(crc, data); + + /// + /// uint32_t __crc32cd (uint32_t a, uint64_t b) + /// A64: CRC32CX Wd, Wn, Xm + /// + public static uint ComputeCrc32C(uint crc, ulong data) => ComputeCrc32C(crc, data); + } + + /// + /// uint32_t __crc32b (uint32_t a, uint8_t b) + /// A32: CRC32B Rd, Rn, Rm + /// A64: CRC32B Wd, Wn, Wm + /// + public static uint ComputeCrc32(uint crc, byte data) => ComputeCrc32(crc, data); + + /// + /// uint32_t __crc32h (uint32_t a, uint16_t b) + /// A32: CRC32H Rd, Rn, Rm + /// A64: CRC32H Wd, Wn, Wm + /// + public static uint ComputeCrc32(uint crc, ushort data) => ComputeCrc32(crc, data); + + /// + /// uint32_t __crc32w (uint32_t a, uint32_t b) + /// A32: CRC32W Rd, Rn, Rm + /// A64: CRC32W Wd, Wn, Wm + /// + public static uint ComputeCrc32(uint crc, uint data) => ComputeCrc32(crc, data); + + /// + /// uint32_t __crc32cb (uint32_t a, uint8_t b) + /// A32: CRC32CB Rd, Rn, Rm + /// A64: CRC32CB Wd, Wn, Wm + /// + public static uint ComputeCrc32C(uint crc, byte data) => ComputeCrc32C(crc, data); + + /// + /// uint32_t __crc32ch (uint32_t a, uint16_t b) + /// A32: CRC32CH Rd, Rn, Rm + /// A64: CRC32CH Wd, Wn, Wm + /// + public static uint ComputeCrc32C(uint crc, ushort data) => ComputeCrc32C(crc, data); + + /// + /// uint32_t __crc32cw (uint32_t a, uint32_t b) + /// A32: CRC32CW Rd, Rn, Rm + /// A64: CRC32CW Wd, Wn, Wm + /// + public static uint ComputeCrc32C(uint crc, uint data) => ComputeCrc32C(crc, data); + } +}