Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Add ComputeCrc32, ComputeCrc32C (#27421)
Browse files Browse the repository at this point in the history
  • Loading branch information
echesakov authored Oct 30, 2019
1 parent a9ab3ca commit 74ec37a
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1346,13 +1346,15 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\AdvSimd.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Aes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\ArmBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Crc32.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha256.cs" />
</ItemGroup>
<ItemGroup Condition="'$(FeatureHardwareIntrinsics)' != 'true' OR '$(Platform)' != 'arm64'">
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\AdvSimd.PlatformNotSupported.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Aes.PlatformNotSupported.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\ArmBase.PlatformNotSupported.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Crc32.PlatformNotSupported.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha1.PlatformNotSupported.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha256.PlatformNotSupported.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// This class provides access to the ARM Crc32 hardware instructions via intrinsics
/// </summary>
[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; } }

/// <summary>
/// uint32_t __crc32d (uint32_t a, uint64_t b)
/// A64: CRC32X Wd, Wn, Xm
/// </summary>
public static uint ComputeCrc32(uint crc, ulong data) { throw new PlatformNotSupportedException(); }

/// <summary>
/// uint32_t __crc32cd (uint32_t a, uint64_t b)
/// A64: CRC32CX Wd, Wn, Xm
/// </summary>
public static uint ComputeCrc32C(uint crc, ulong data) { throw new PlatformNotSupportedException(); }
}

/// <summary>
/// uint32_t __crc32b (uint32_t a, uint8_t b)
/// A32: CRC32B Rd, Rn, Rm
/// A64: CRC32B Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32(uint crc, byte data) { throw new PlatformNotSupportedException(); }

/// <summary>
/// uint32_t __crc32h (uint32_t a, uint16_t b)
/// A32: CRC32H Rd, Rn, Rm
/// A64: CRC32H Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32(uint crc, ushort data) { throw new PlatformNotSupportedException(); }

/// <summary>
/// uint32_t __crc32w (uint32_t a, uint32_t b)
/// A32: CRC32W Rd, Rn, Rm
/// A64: CRC32W Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32(uint crc, uint data) { throw new PlatformNotSupportedException(); }

/// <summary>
/// uint32_t __crc32cb (uint32_t a, uint8_t b)
/// A32: CRC32CB Rd, Rn, Rm
/// A64: CRC32CB Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32C(uint crc, byte data) { throw new PlatformNotSupportedException(); }

/// <summary>
/// uint32_t __crc32ch (uint32_t a, uint16_t b)
/// A32: CRC32CH Rd, Rn, Rm
/// A64: CRC32CH Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32C(uint crc, ushort data) { throw new PlatformNotSupportedException(); }

/// <summary>
/// uint32_t __crc32cw (uint32_t a, uint32_t b)
/// A32: CRC32CW Rd, Rn, Rm
/// A64: CRC32CW Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32C(uint crc, uint data) { throw new PlatformNotSupportedException(); }
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// This class provides access to the ARM Crc32 hardware instructions via intrinsics
/// </summary>
[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; }

/// <summary>
/// uint32_t __crc32d (uint32_t a, uint64_t b)
/// A64: CRC32X Wd, Wn, Xm
/// </summary>
public static uint ComputeCrc32(uint crc, ulong data) => ComputeCrc32(crc, data);

/// <summary>
/// uint32_t __crc32cd (uint32_t a, uint64_t b)
/// A64: CRC32CX Wd, Wn, Xm
/// </summary>
public static uint ComputeCrc32C(uint crc, ulong data) => ComputeCrc32C(crc, data);
}

/// <summary>
/// uint32_t __crc32b (uint32_t a, uint8_t b)
/// A32: CRC32B Rd, Rn, Rm
/// A64: CRC32B Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32(uint crc, byte data) => ComputeCrc32(crc, data);

/// <summary>
/// uint32_t __crc32h (uint32_t a, uint16_t b)
/// A32: CRC32H Rd, Rn, Rm
/// A64: CRC32H Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32(uint crc, ushort data) => ComputeCrc32(crc, data);

/// <summary>
/// uint32_t __crc32w (uint32_t a, uint32_t b)
/// A32: CRC32W Rd, Rn, Rm
/// A64: CRC32W Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32(uint crc, uint data) => ComputeCrc32(crc, data);

/// <summary>
/// uint32_t __crc32cb (uint32_t a, uint8_t b)
/// A32: CRC32CB Rd, Rn, Rm
/// A64: CRC32CB Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32C(uint crc, byte data) => ComputeCrc32C(crc, data);

/// <summary>
/// uint32_t __crc32ch (uint32_t a, uint16_t b)
/// A32: CRC32CH Rd, Rn, Rm
/// A64: CRC32CH Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32C(uint crc, ushort data) => ComputeCrc32C(crc, data);

/// <summary>
/// uint32_t __crc32cw (uint32_t a, uint32_t b)
/// A32: CRC32CW Rd, Rn, Rm
/// A64: CRC32CW Wd, Wn, Wm
/// </summary>
public static uint ComputeCrc32C(uint crc, uint data) => ComputeCrc32C(crc, data);
}
}

0 comments on commit 74ec37a

Please sign in to comment.