Skip to content

Commit

Permalink
JIT: Added four SVE CreateBreak* APIs (#104184)
Browse files Browse the repository at this point in the history
* Added four SVE CreateBreak* APIs

* Fix comments

* Added break

* Formatting

* Update Sve.PlatformNotSupported.cs
  • Loading branch information
TIHan authored Jul 2, 2024
1 parent b59816c commit 7294674
Show file tree
Hide file tree
Showing 9 changed files with 620 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/coreclr/jit/hwintrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,10 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,

switch (intrinsic)
{
case NI_Sve_CreateBreakAfterMask:
case NI_Sve_CreateBreakAfterPropagateMask:
case NI_Sve_CreateBreakBeforeMask:
case NI_Sve_CreateBreakBeforePropagateMask:
case NI_Sve_CreateMaskForFirstActiveElement:
case NI_Sve_CreateMaskForNextActiveElement:
case NI_Sve_GetActiveElementCount:
Expand All @@ -1933,6 +1937,26 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,
break;
}

switch (intrinsic)
{
case NI_Sve_CreateBreakAfterPropagateMask:
case NI_Sve_CreateBreakBeforePropagateMask:
{
GenTree* op3 = retNode->AsHWIntrinsic()->Op(3);

// HWInstrinsic requires a mask for op3
if (!varTypeIsMask(op3))
{
retNode->AsHWIntrinsic()->Op(3) =
gtNewSimdCvtVectorToMaskNode(TYP_MASK, op3, simdBaseJitType, simdSize);
}
break;
}

default:
break;
}

if (!varTypeIsMask(op1))
{
// Op1 input is a vector. HWInstrinsic requires a mask.
Expand Down
14 changes: 14 additions & 0 deletions src/coreclr/jit/hwintrinsiccodegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,20 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
break;
}

case NI_Sve_CreateBreakAfterMask:
case NI_Sve_CreateBreakBeforeMask:
{
GetEmitter()->emitInsSve_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, INS_OPTS_SCALABLE_B);
break;
}

case NI_Sve_CreateBreakAfterPropagateMask:
case NI_Sve_CreateBreakBeforePropagateMask:
{
GetEmitter()->emitInsSve_R_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, op3Reg, INS_OPTS_SCALABLE_B);
break;
}

case NI_Sve_CreateMaskForFirstActiveElement:
{
assert(isRMW);
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/jit/hwintrinsiclistarm64sve.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ HARDWARE_INTRINSIC(Sve, Count16BitElements,
HARDWARE_INTRINSIC(Sve, Count32BitElements, 0, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_cntw, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_Scalable|HW_Flag_HasEnumOperand|HW_Flag_SpecialCodeGen|HW_Flag_NoFloatingPointUsed)
HARDWARE_INTRINSIC(Sve, Count64BitElements, 0, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_cntd, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_Scalable|HW_Flag_HasEnumOperand|HW_Flag_SpecialCodeGen|HW_Flag_NoFloatingPointUsed)
HARDWARE_INTRINSIC(Sve, Count8BitElements, 0, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_cntb, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_Scalable|HW_Flag_HasEnumOperand|HW_Flag_SpecialCodeGen|HW_Flag_NoFloatingPointUsed)
HARDWARE_INTRINSIC(Sve, CreateBreakAfterMask, -1, 2, true, {INS_sve_brka, INS_sve_brka, INS_sve_brka, INS_sve_brka, INS_sve_brka, INS_sve_brka, INS_sve_brka, INS_sve_brka, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_ReturnsPerElementMask|HW_Flag_SpecialCodeGen)
HARDWARE_INTRINSIC(Sve, CreateBreakAfterPropagateMask, -1, 3, true, {INS_sve_brkpa, INS_sve_brkpa, INS_sve_brkpa, INS_sve_brkpa, INS_sve_brkpa, INS_sve_brkpa, INS_sve_brkpa, INS_sve_brkpa, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_ReturnsPerElementMask|HW_Flag_SpecialCodeGen)
HARDWARE_INTRINSIC(Sve, CreateBreakBeforeMask, -1, 2, true, {INS_sve_brkb, INS_sve_brkb, INS_sve_brkb, INS_sve_brkb, INS_sve_brkb, INS_sve_brkb, INS_sve_brkb, INS_sve_brkb, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_ReturnsPerElementMask|HW_Flag_SpecialCodeGen)
HARDWARE_INTRINSIC(Sve, CreateBreakBeforePropagateMask, -1, 3, true, {INS_sve_brkpb, INS_sve_brkpb, INS_sve_brkpb, INS_sve_brkpb, INS_sve_brkpb, INS_sve_brkpb, INS_sve_brkpb, INS_sve_brkpb, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_ReturnsPerElementMask|HW_Flag_SpecialCodeGen)
HARDWARE_INTRINSIC(Sve, CreateFalseMaskByte, -1, 0, false, {INS_invalid, INS_sve_pfalse, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ReturnsPerElementMask)
HARDWARE_INTRINSIC(Sve, CreateFalseMaskDouble, -1, 0, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_pfalse}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ReturnsPerElementMask)
HARDWARE_INTRINSIC(Sve, CreateFalseMaskInt16, -1, 0, false, {INS_invalid, INS_invalid, INS_sve_pfalse, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ReturnsPerElementMask)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,199 @@ internal Arm64() { }
public static unsafe ulong Count8BitElements([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw new PlatformNotSupportedException(); }


/// <summary>
/// svbool_t svbrka[_b]_z(svbool_t pg, svbool_t op)
/// BRKA Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<byte> CreateBreakAfterMask(Vector<byte> mask, Vector<byte> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrka[_b]_z(svbool_t pg, svbool_t op)
/// BRKA Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<short> CreateBreakAfterMask(Vector<short> mask, Vector<short> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrka[_b]_z(svbool_t pg, svbool_t op)
/// BRKA Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<int> CreateBreakAfterMask(Vector<int> mask, Vector<int> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrka[_b]_z(svbool_t pg, svbool_t op)
/// BRKA Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<long> CreateBreakAfterMask(Vector<long> mask, Vector<long> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrka[_b]_z(svbool_t pg, svbool_t op)
/// BRKA Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<sbyte> CreateBreakAfterMask(Vector<sbyte> mask, Vector<sbyte> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrka[_b]_z(svbool_t pg, svbool_t op)
/// BRKA Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<ushort> CreateBreakAfterMask(Vector<ushort> mask, Vector<ushort> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrka[_b]_z(svbool_t pg, svbool_t op)
/// BRKA Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<uint> CreateBreakAfterMask(Vector<uint> mask, Vector<uint> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrka[_b]_z(svbool_t pg, svbool_t op)
/// BRKA Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<ulong> CreateBreakAfterMask(Vector<ulong> mask, Vector<ulong> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpa[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPA Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<byte> CreateBreakAfterPropagateMask(Vector<byte> mask, Vector<byte> left, Vector<byte> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpa[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPA Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<short> CreateBreakAfterPropagateMask(Vector<short> mask, Vector<short> left, Vector<short> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpa[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPA Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<int> CreateBreakAfterPropagateMask(Vector<int> mask, Vector<int> left, Vector<int> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpa[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPA Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<long> CreateBreakAfterPropagateMask(Vector<long> mask, Vector<long> left, Vector<long> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpa[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPA Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<sbyte> CreateBreakAfterPropagateMask(Vector<sbyte> mask, Vector<sbyte> left, Vector<sbyte> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpa[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPA Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<ushort> CreateBreakAfterPropagateMask(Vector<ushort> mask, Vector<ushort> left, Vector<ushort> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpa[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPA Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<uint> CreateBreakAfterPropagateMask(Vector<uint> mask, Vector<uint> left, Vector<uint> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpa[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPA Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<ulong> CreateBreakAfterPropagateMask(Vector<ulong> mask, Vector<ulong> left, Vector<ulong> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkb[_b]_z(svbool_t pg, svbool_t op)
/// BRKB Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<byte> CreateBreakBeforeMask(Vector<byte> mask, Vector<byte> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkb[_b]_z(svbool_t pg, svbool_t op)
/// BRKB Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<short> CreateBreakBeforeMask(Vector<short> mask, Vector<short> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkb[_b]_z(svbool_t pg, svbool_t op)
/// BRKB Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<int> CreateBreakBeforeMask(Vector<int> mask, Vector<int> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkb[_b]_z(svbool_t pg, svbool_t op)
/// BRKB Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<long> CreateBreakBeforeMask(Vector<long> mask, Vector<long> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkb[_b]_z(svbool_t pg, svbool_t op)
/// BRKB Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<sbyte> CreateBreakBeforeMask(Vector<sbyte> mask, Vector<sbyte> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkb[_b]_z(svbool_t pg, svbool_t op)
/// BRKB Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<ushort> CreateBreakBeforeMask(Vector<ushort> mask, Vector<ushort> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkb[_b]_z(svbool_t pg, svbool_t op)
/// BRKB Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<uint> CreateBreakBeforeMask(Vector<uint> mask, Vector<uint> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkb[_b]_z(svbool_t pg, svbool_t op)
/// BRKB Presult.B, Pg/Z, Pop.B
/// </summary>
public static unsafe Vector<ulong> CreateBreakBeforeMask(Vector<ulong> mask, Vector<ulong> srcMask) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpb[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPB Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<byte> CreateBreakBeforePropagateMask(Vector<byte> mask, Vector<byte> left, Vector<byte> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpb[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPB Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<short> CreateBreakBeforePropagateMask(Vector<short> mask, Vector<short> left, Vector<short> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpb[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPB Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<int> CreateBreakBeforePropagateMask(Vector<int> mask, Vector<int> left, Vector<int> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpb[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPB Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<long> CreateBreakBeforePropagateMask(Vector<long> mask, Vector<long> left, Vector<long> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpb[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPB Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<sbyte> CreateBreakBeforePropagateMask(Vector<sbyte> mask, Vector<sbyte> left, Vector<sbyte> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpb[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPB Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<ushort> CreateBreakBeforePropagateMask(Vector<ushort> mask, Vector<ushort> left, Vector<ushort> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpb[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPB Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<uint> CreateBreakBeforePropagateMask(Vector<uint> mask, Vector<uint> left, Vector<uint> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svbool_t svbrkpb[_b]_z(svbool_t pg, svbool_t op1, svbool_t op2)
/// BRKPB Presult.B, Pg/Z, Pop1.B, Pop2.B
/// </summary>
public static unsafe Vector<ulong> CreateBreakBeforePropagateMask(Vector<ulong> mask, Vector<ulong> left, Vector<ulong> right) { throw new PlatformNotSupportedException(); }


/// Set all predicate elements to false

/// <summary>
Expand Down
Loading

0 comments on commit 7294674

Please sign in to comment.