-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add Sm4 and SVE Sm4 APIs #130039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
a74nh
wants to merge
13
commits into
dotnet:main
Choose a base branch
from
a74nh:sm4_github
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Sm4 and SVE Sm4 APIs #130039
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
adc5df4
Add Sm4 and SVE Sm4 APIs
a74nh e8a14fd
fix IsSupported
a74nh ffcce4e
fix System.Runtime.Intrinsics.cs
a74nh 6a3bdb2
fix variable names
a74nh 0a59711
merge main
a74nh e065953
fix variable names
a74nh 69ac7b6
Do the mov inside emit
a74nh 348c2e9
Move helpers into subclass
a74nh 3d973e0
remove bogus assert
a74nh 5f637ab
merge main
a74nh 64ea152
fix hwintrinsic entries
a74nh 77006d9
fix IsSupported
a74nh 2deac95
remove AES changes
a74nh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sm4.PlatformNotSupported.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace System.Runtime.Intrinsics.Arm | ||
| { | ||
| /// <summary>Provides access to the ARM Sm4 hardware instructions via intrinsics.</summary> | ||
| [CLSCompliant(false)] | ||
| public abstract class Sm4 : ArmBase | ||
| { | ||
| internal Sm4() { } | ||
|
|
||
| /// <summary>Gets a value that indicates whether the APIs in this class are supported.</summary> | ||
| /// <value><see langword="true" /> if the APIs are supported; otherwise, <see langword="false" />.</value> | ||
| /// <remarks>A value of <see langword="false" /> indicates that the APIs will throw <see cref="PlatformNotSupportedException" />.</remarks> | ||
| public static new bool IsSupported { [Intrinsic] get => false; } | ||
|
|
||
| /// <summary>Provides access to the ARM Sm4 hardware instructions, that are only available to 64-bit processes, via intrinsics.</summary> | ||
| public new abstract class Arm64 : ArmBase.Arm64 | ||
| { | ||
| internal Arm64() { } | ||
|
|
||
| /// <summary>Gets a value that indicates whether the APIs in this class are supported.</summary> | ||
| /// <value><see langword="true" /> if the APIs are supported; otherwise, <see langword="false" />.</value> | ||
| /// <remarks>A value of <see langword="false" /> indicates that the APIs will throw <see cref="PlatformNotSupportedException" />.</remarks> | ||
| public static new bool IsSupported { [Intrinsic] get { return false; } } | ||
| } | ||
|
|
||
|
|
||
| // SM4 encryption and decryption | ||
|
|
||
| /// <summary> | ||
| /// uint32x4_t vsm4eq_u32(uint32x4_t a, uint32x4_t b) | ||
| /// SM4E Vd.4S,Vn.4S | ||
| /// </summary> | ||
| public static unsafe Vector128<uint> Encode(Vector128<uint> value, Vector128<uint> roundKeys) { throw new PlatformNotSupportedException(); } | ||
|
|
||
| // SM4 key updates | ||
|
|
||
| /// <summary> | ||
| /// uint32x4_t vsm4ekeyq_u32(uint32x4_t a, uint32x4_t b) | ||
| /// SM4EKEY Vd.4S,Vn.4S,Vm.4S | ||
| /// </summary> | ||
| public static unsafe Vector128<uint> KeyUpdate(Vector128<uint> value, Vector128<uint> constant) { throw new PlatformNotSupportedException(); } | ||
|
|
||
| } | ||
| } |
51 changes: 51 additions & 0 deletions
51
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sm4.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace System.Runtime.Intrinsics.Arm | ||
| { | ||
| /// <summary>Provides access to the ARM Sm4 hardware instructions via intrinsics.</summary> | ||
| [Intrinsic] | ||
| [CLSCompliant(false)] | ||
| public abstract class Sm4 : ArmBase | ||
| { | ||
| internal Sm4() { } | ||
|
|
||
| /// <summary>Gets a value that indicates whether the APIs in this class are supported.</summary> | ||
| /// <value><see langword="true" /> if the APIs are supported; otherwise, <see langword="false" />.</value> | ||
| /// <remarks>A value of <see langword="false" /> indicates that the APIs will throw <see cref="PlatformNotSupportedException" />.</remarks> | ||
| public static new bool IsSupported { get => IsSupported; } | ||
|
|
||
| /// <summary>Provides access to the ARM Sm4 hardware instructions, that are only available to 64-bit processes, via intrinsics.</summary> | ||
| [Intrinsic] | ||
| public new abstract class Arm64 : ArmBase.Arm64 | ||
| { | ||
| internal Arm64() { } | ||
|
|
||
| /// <summary>Gets a value that indicates whether the APIs in this class are supported.</summary> | ||
| /// <value><see langword="true" /> if the APIs are supported; otherwise, <see langword="false" />.</value> | ||
| /// <remarks>A value of <see langword="false" /> indicates that the APIs will throw <see cref="PlatformNotSupportedException" />.</remarks> | ||
| public static new bool IsSupported { get => IsSupported; } | ||
| } | ||
|
|
||
|
|
||
| // SM4 encryption and decryption | ||
|
|
||
| /// <summary> | ||
| /// uint32x4_t vsm4eq_u32(uint32x4_t a, uint32x4_t b) | ||
| /// SM4E Vd.4S,Vn.4S | ||
| /// </summary> | ||
| public static unsafe Vector128<uint> Encode(Vector128<uint> value, Vector128<uint> roundKeys) => Encode(value, roundKeys); | ||
|
|
||
| // SM4 key updates | ||
|
|
||
| /// <summary> | ||
| /// uint32x4_t vsm4ekeyq_u32(uint32x4_t a, uint32x4_t b) | ||
| /// SM4EKEY Vd.4S,Vn.4S,Vm.4S | ||
| /// </summary> | ||
| public static unsafe Vector128<uint> KeyUpdate(Vector128<uint> value, Vector128<uint> constant) => KeyUpdate(value, constant); | ||
|
|
||
| } | ||
| } | ||
52 changes: 52 additions & 0 deletions
52
...s/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/SveSm4.PlatformNotSupported.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Numerics; | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace System.Runtime.Intrinsics.Arm | ||
| { | ||
| /// <summary>Provides access to the ARM SveSm4 hardware instructions via intrinsics.</summary> | ||
| [CLSCompliant(false)] | ||
| [Experimental(Experimentals.ArmSveDiagId, UrlFormat = Experimentals.SharedUrlFormat)] | ||
| public abstract class SveSm4 : ArmBase | ||
| { | ||
| internal SveSm4() { } | ||
|
|
||
| /// <summary>Gets a value that indicates whether the APIs in this class are supported.</summary> | ||
| /// <value><see langword="true" /> if the APIs are supported; otherwise, <see langword="false" />.</value> | ||
| /// <remarks>A value of <see langword="false" /> indicates that the APIs will throw <see cref="PlatformNotSupportedException" />.</remarks> | ||
| public static new bool IsSupported { [Intrinsic] get => false; } | ||
|
|
||
| /// <summary>Provides access to the ARM SveSm4 hardware instructions, that are only available to 64-bit processes, via intrinsics.</summary> | ||
| public new abstract class Arm64 : ArmBase.Arm64 | ||
| { | ||
| internal Arm64() { } | ||
|
|
||
| /// <summary>Gets a value that indicates whether the APIs in this class are supported.</summary> | ||
| /// <value><see langword="true" /> if the APIs are supported; otherwise, <see langword="false" />.</value> | ||
| /// <remarks>A value of <see langword="false" /> indicates that the APIs will throw <see cref="PlatformNotSupportedException" />.</remarks> | ||
| public static new bool IsSupported { [Intrinsic] get { return false; } } | ||
| } | ||
|
|
||
|
|
||
| // SM4 encryption and decryption | ||
|
|
||
| /// <summary> | ||
| /// svuint32_t svsm4e[_u32](svuint32_t op1, svuint32_t op2) | ||
| /// SM4E Ztied1.S, Ztied1.S, Zop2.S | ||
| /// </summary> | ||
| public static unsafe Vector<uint> Encode(Vector<uint> value, Vector<uint> roundKeys) { throw new PlatformNotSupportedException(); } | ||
|
|
||
|
|
||
| // SM4 key updates | ||
|
|
||
| /// <summary> | ||
| /// svuint32_t svsm4ekey[_u32](svuint32_t op1, svuint32_t op2) | ||
| /// SM4EKEY Zresult.S, Zop1.S, Zop2.S | ||
| /// </summary> | ||
| public static unsafe Vector<uint> KeyUpdate(Vector<uint> value, Vector<uint> constant) { throw new PlatformNotSupportedException(); } | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect
unsafeis not needed for these, as it wasn't needed for SHA3 et al