Skip to content

[API Proposal]: Arm64: FEAT_SVE_SM4 #94426

Closed

Description

@a74nh

FEAT_SVE_SM4 provides SVE variants of the SM4 instructions provided in FEAT_SM4. See #98696

namespace System.Runtime.Intrinsics.Arm

/// VectorT Summary
public abstract class SveSm4 : AdvSimd /// Feature: FEAT_SVE_SM4
{

  public static unsafe Vector<uint> Sm4Encode(Vector<uint> left, Vector<uint> right); // SM4E

  public static unsafe Vector<uint> Sm4KeyUpdate(Vector<uint> left, Vector<uint> right); // SM4EKEY

  /// total method signatures: 2

}

The SM4E instruction reads 16 bytes of input data from each 128-bit segment of the first source vector, together with four iterations of 32-bit round keys from the corresponding 128-bit segments of the second source vector. Each block of data is encrypted by four rounds in accordance with the SM4 standard, and destructively placed in the corresponding segments of the first source vector. This instruction is unpredicated.

The SM4EKEY instruction reads four rounds of 32-bit input key values from each 128-bit segment of the first source vector, along with four rounds of 32-bit constants from the corresponding 128-bit segment of the second source vector. The four rounds of output key values are derived in accordance with the SM4 standard, and placed in the corresponding segments of the destination vector. This instruction is unpredicated.

/// Full API
public abstract class SveSm4 : AdvSimd /// Feature: FEAT_SVE_SM4
{
    /// Sm4EncryptionAndDecryption : SM4 encryption and decryption

    /// svuint32_t svsm4e[_u32](svuint32_t op1, svuint32_t op2) : "SM4E Ztied1.S, Ztied1.S, Zop2.S"
  public static unsafe Vector<uint> Sm4EncryptionAndDecryption(Vector<uint> left, Vector<uint> right);


    /// Sm4KeyUpdates : SM4 key updates

    /// svuint32_t svsm4ekey[_u32](svuint32_t op1, svuint32_t op2) : "SM4EKEY Zresult.S, Zop1.S, Zop2.S"
  public static unsafe Vector<uint> Sm4KeyUpdates(Vector<uint> left, Vector<uint> right);


  /// total method signatures: 2
  /// total method names:      2
}


  /// Total ACLE covered across API:      2

Activity

  1. ghost added
    untriaged
    on Nov 6, 2023
  2. a74nh commented on Nov 6, 2023

    @a74nh
    ContributorAuthor

    This contributes to #93095

    It covers all of the instructions in FEAT_SVE_SM4.
    This list was auto generated from the C ACLE for SVE, and is in three parts:

    The methods list reduced down to Vector versions. All possible varaints of T are given above the method.
    The complete list of all methods. The corresponding ACLE methods and SVE instructions are given above the method.
    All rejected ACLE methods. These are methods we have agreed that do not need including in C#.
    Where possible, existing C# naming conventions have been matched.

    Many of the C functions include predicate argument(s), of type svbool_t as the first argument. These are missing from the C# method. It is expected that the Jit will create predicates where required, or combine with uses of conditionalSelect(). For more discussion see #88140 comment.

  3. added
    api-ready-for-review
    on Feb 7, 2024
  4. added this to the Future milestone on May 1, 2024
  5. removed
    untriaged
    on May 3, 2024
  6. added
    api-suggestion
    and removed
    api-ready-for-review
    on Aug 20, 2024
  7. added
    arm-sve
    api-ready-for-review
    and removed
    api-suggestion
    on Nov 28, 2025
  8. modified the milestones: Future, 11.0.0 on Nov 28, 2025
  9. bartonjs commented on Jan 13, 2026

    @bartonjs
    Member
    • Gave the parameters better names than left/right.
    • Removed the "Sm4" method prefixes since it's in the ISA classname. That's consistent with x86.Aes.Decrypt and friends.
    namespace System.Runtime.Intrinsics.Arm;
    
    public abstract class SveSm4 : AdvSimd /// Feature: FEAT_SVE_SM4
    {
      public static unsafe Vector<uint> Encode(Vector<uint> value, Vector<uint> roundKeys); // SM4E
    
      public static unsafe Vector<uint> KeyUpdate(Vector<uint> value, Vector<uint> constant); // SM4EKEY
    }
  10. added
    api-approved
    and removed
    api-ready-for-review
    on Jan 13, 2026
  11. added a commit that references this issue on Feb 17, 2026
  12. added
    in-pr
    on Jun 30, 2026
  13. added a commit that references this issue on Jul 15, 2026
    afe04eb
  14. locked and limited conversation to collaborators on Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedarch-arm64area-System.Runtime.Intrinsicsarm-svein-pr

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions