Skip to content

Commit

Permalink
Add support for Sve.ReverseElementX() (#102991)
Browse files Browse the repository at this point in the history
* Add support for Sve.ReverseElementX()

* Make ReverseElement8/16/32 as low masked operation
  • Loading branch information
SwapnilGaikwad committed Jun 3, 2024
1 parent 2bf492b commit a7386e0
Show file tree
Hide file tree
Showing 6 changed files with 343 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/coreclr/jit/hwintrinsiccodegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,11 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
break;
}

case NI_Sve_ReverseElement:
// Use non-predicated version explicitly
GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op1Reg, opt, INS_SCALABLE_OPTS_UNPREDICATED);
break;

case NI_Sve_StoreNarrowing:
opt = emitter::optGetSveInsOpt(emitTypeSize(intrin.baseType));
GetEmitter()->emitIns_R_R_R_I(ins, emitSize, op3Reg, op1Reg, op2Reg, 0, opt);
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 @@ -140,6 +140,10 @@ HARDWARE_INTRINSIC(Sve, Negate,
HARDWARE_INTRINSIC(Sve, Or, -1, -1, false, {INS_sve_orr, INS_sve_orr, INS_sve_orr, INS_sve_orr, INS_sve_orr, INS_sve_orr, INS_sve_orr, INS_sve_orr, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_OptionalEmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, OrAcross, -1, -1, false, {INS_sve_orv, INS_sve_orv, INS_sve_orv, INS_sve_orv, INS_sve_orv, INS_sve_orv, INS_sve_orv, INS_sve_orv, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, PopCount, -1, -1, false, {INS_sve_cnt, INS_sve_cnt, INS_sve_cnt, INS_sve_cnt, INS_sve_cnt, INS_sve_cnt, INS_sve_cnt, INS_sve_cnt, INS_sve_cnt, INS_sve_cnt}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_BaseTypeFromFirstArg|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, ReverseElement, -1, 1, true, {INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_SpecialCodeGen)
HARDWARE_INTRINSIC(Sve, ReverseElement16, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_revh, INS_sve_revh, INS_sve_revh, INS_sve_revh, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, ReverseElement32, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_revw, INS_sve_revw, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, ReverseElement8, -1, -1, false, {INS_invalid, INS_invalid, INS_sve_revb, INS_sve_revb, INS_sve_revb, INS_sve_revb, INS_sve_revb, INS_sve_revb, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, SaturatingDecrementBy16BitElementCount, -1, 3, true, {INS_invalid, INS_invalid, INS_sve_sqdech, INS_sve_uqdech, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_HasEnumOperand|HW_Flag_SpecialCodeGen|HW_Flag_HasScalarInputVariant|HW_Flag_SpecialImport|HW_Flag_HasRMWSemantics)
HARDWARE_INTRINSIC(Sve, SaturatingDecrementBy32BitElementCount, -1, 3, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_sqdecw, INS_sve_uqdecw, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_HasEnumOperand|HW_Flag_SpecialCodeGen|HW_Flag_HasScalarInputVariant|HW_Flag_SpecialImport|HW_Flag_HasRMWSemantics)
HARDWARE_INTRINSIC(Sve, SaturatingDecrementBy64BitElementCount, -1, 3, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_sqdecd, INS_sve_uqdecd, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_HasEnumOperand|HW_Flag_SpecialCodeGen|HW_Flag_HasScalarInputVariant|HW_Flag_SpecialImport|HW_Flag_HasRMWSemantics)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3093,6 +3093,150 @@ internal Arm64() { }
public static unsafe Vector<ulong> PopCount(Vector<ulong> value) { throw new PlatformNotSupportedException(); }


/// Reverse all elements

/// <summary>
/// svuint8_t svrev[_u8](svuint8_t op)
/// REV Zresult.B, Zop.B
/// </summary>
public static unsafe Vector<byte> ReverseElement(Vector<byte> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat64_t svrev[_f64](svfloat64_t op)
/// REV Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<double> ReverseElement(Vector<double> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svint16_t svrev[_s16](svint16_t op)
/// REV Zresult.H, Zop.H
/// </summary>
public static unsafe Vector<short> ReverseElement(Vector<short> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svint32_t svrev[_s32](svint32_t op)
/// REV Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<int> ReverseElement(Vector<int> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svint64_t svrev[_s64](svint64_t op)
/// REV Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<long> ReverseElement(Vector<long> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svint8_t svrev[_s8](svint8_t op)
/// REV Zresult.B, Zop.B
/// </summary>
public static unsafe Vector<sbyte> ReverseElement(Vector<sbyte> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svrev[_f32](svfloat32_t op)
/// REV Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<float> ReverseElement(Vector<float> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svuint16_t svrev[_u16](svuint16_t op)
/// REV Zresult.H, Zop.H
/// </summary>
public static unsafe Vector<ushort> ReverseElement(Vector<ushort> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svuint32_t svrev[_u32](svuint32_t op)
/// REV Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<uint> ReverseElement(Vector<uint> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svuint64_t svrev[_u64](svuint64_t op)
/// REV Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<ulong> ReverseElement(Vector<ulong> value) { throw new PlatformNotSupportedException(); }


/// Reverse halfwords within elements

/// <summary>
/// svint32_t svrevh[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op)
/// REVH Ztied.S, Pg/M, Zop.S
/// </summary>
public static unsafe Vector<int> ReverseElement16(Vector<int> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svint64_t svrevh[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
/// REVH Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<long> ReverseElement16(Vector<long> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svuint32_t svrevh[_u32]_m(svuint32_t inactive, svbool_t pg, svuint32_t op)
/// REVH Ztied.S, Pg/M, Zop.S
/// </summary>
public static unsafe Vector<uint> ReverseElement16(Vector<uint> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svuint64_t svrevh[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
/// REVH Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<ulong> ReverseElement16(Vector<ulong> value) { throw new PlatformNotSupportedException(); }


/// Reverse words within elements

/// <summary>
/// svint64_t svrevw[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
/// REVW Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<long> ReverseElement32(Vector<long> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svuint64_t svrevw[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
/// REVW Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<ulong> ReverseElement32(Vector<ulong> value) { throw new PlatformNotSupportedException(); }


/// Reverse bytes within elements

/// <summary>
/// svint16_t svrevb[_s16]_m(svint16_t inactive, svbool_t pg, svint16_t op)
/// REVB Ztied.H, Pg/M, Zop.H
/// </summary>
public static unsafe Vector<short> ReverseElement8(Vector<short> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svint32_t svrevb[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op)
/// REVB Ztied.S, Pg/M, Zop.S
/// </summary>
public static unsafe Vector<int> ReverseElement8(Vector<int> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svint64_t svrevb[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
/// REVB Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<long> ReverseElement8(Vector<long> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svuint16_t svrevb[_u16]_m(svuint16_t inactive, svbool_t pg, svuint16_t op)
/// REVB Ztied.H, Pg/M, Zop.H
/// </summary>
public static unsafe Vector<ushort> ReverseElement8(Vector<ushort> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svuint32_t svrevb[_u32]_m(svuint32_t inactive, svbool_t pg, svuint32_t op)
/// REVB Ztied.S, Pg/M, Zop.S
/// </summary>
public static unsafe Vector<uint> ReverseElement8(Vector<uint> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svuint64_t svrevb[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
/// REVB Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<ulong> ReverseElement8(Vector<ulong> value) { throw new PlatformNotSupportedException(); }


/// Saturating decrement by number of halfword elements

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3149,6 +3149,150 @@ internal Arm64() { }
public static unsafe Vector<ulong> PopCount(Vector<ulong> value) => PopCount(value);


/// Reverse all elements

/// <summary>
/// svuint8_t svrev[_u8](svuint8_t op)
/// REV Zresult.B, Zop.B
/// </summary>
public static unsafe Vector<byte> ReverseElement(Vector<byte> value) => ReverseElement(value);

/// <summary>
/// svfloat64_t svrev[_f64](svfloat64_t op)
/// REV Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<double> ReverseElement(Vector<double> value) => ReverseElement(value);

/// <summary>
/// svint16_t svrev[_s16](svint16_t op)
/// REV Zresult.H, Zop.H
/// </summary>
public static unsafe Vector<short> ReverseElement(Vector<short> value) => ReverseElement(value);

/// <summary>
/// svint32_t svrev[_s32](svint32_t op)
/// REV Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<int> ReverseElement(Vector<int> value) => ReverseElement(value);

/// <summary>
/// svint64_t svrev[_s64](svint64_t op)
/// REV Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<long> ReverseElement(Vector<long> value) => ReverseElement(value);

/// <summary>
/// svint8_t svrev[_s8](svint8_t op)
/// REV Zresult.B, Zop.B
/// </summary>
public static unsafe Vector<sbyte> ReverseElement(Vector<sbyte> value) => ReverseElement(value);

/// <summary>
/// svfloat32_t svrev[_f32](svfloat32_t op)
/// REV Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<float> ReverseElement(Vector<float> value) => ReverseElement(value);

/// <summary>
/// svuint16_t svrev[_u16](svuint16_t op)
/// REV Zresult.H, Zop.H
/// </summary>
public static unsafe Vector<ushort> ReverseElement(Vector<ushort> value) => ReverseElement(value);

/// <summary>
/// svuint32_t svrev[_u32](svuint32_t op)
/// REV Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<uint> ReverseElement(Vector<uint> value) => ReverseElement(value);

/// <summary>
/// svuint64_t svrev[_u64](svuint64_t op)
/// REV Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<ulong> ReverseElement(Vector<ulong> value) => ReverseElement(value);


/// Reverse halfwords within elements

/// <summary>
/// svint32_t svrevh[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op)
/// REVH Ztied.S, Pg/M, Zop.S
/// </summary>
public static unsafe Vector<int> ReverseElement16(Vector<int> value) => ReverseElement16(value);

/// <summary>
/// svint64_t svrevh[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
/// REVH Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<long> ReverseElement16(Vector<long> value) => ReverseElement16(value);

/// <summary>
/// svuint32_t svrevh[_u32]_m(svuint32_t inactive, svbool_t pg, svuint32_t op)
/// REVH Ztied.S, Pg/M, Zop.S
/// </summary>
public static unsafe Vector<uint> ReverseElement16(Vector<uint> value) => ReverseElement16(value);

/// <summary>
/// svuint64_t svrevh[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
/// REVH Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<ulong> ReverseElement16(Vector<ulong> value) => ReverseElement16(value);


/// Reverse words within elements

/// <summary>
/// svint64_t svrevw[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
/// REVW Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<long> ReverseElement32(Vector<long> value) => ReverseElement32(value);

/// <summary>
/// svuint64_t svrevw[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
/// REVW Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<ulong> ReverseElement32(Vector<ulong> value) => ReverseElement32(value);


/// Reverse bytes within elements

/// <summary>
/// svint16_t svrevb[_s16]_m(svint16_t inactive, svbool_t pg, svint16_t op)
/// REVB Ztied.H, Pg/M, Zop.H
/// </summary>
public static unsafe Vector<short> ReverseElement8(Vector<short> value) => ReverseElement8(value);

/// <summary>
/// svint32_t svrevb[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op)
/// REVB Ztied.S, Pg/M, Zop.S
/// </summary>
public static unsafe Vector<int> ReverseElement8(Vector<int> value) => ReverseElement8(value);

/// <summary>
/// svint64_t svrevb[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
/// REVB Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<long> ReverseElement8(Vector<long> value) => ReverseElement8(value);

/// <summary>
/// svuint16_t svrevb[_u16]_m(svuint16_t inactive, svbool_t pg, svuint16_t op)
/// REVB Ztied.H, Pg/M, Zop.H
/// </summary>
public static unsafe Vector<ushort> ReverseElement8(Vector<ushort> value) => ReverseElement8(value);

/// <summary>
/// svuint32_t svrevb[_u32]_m(svuint32_t inactive, svbool_t pg, svuint32_t op)
/// REVB Ztied.S, Pg/M, Zop.S
/// </summary>
public static unsafe Vector<uint> ReverseElement8(Vector<uint> value) => ReverseElement8(value);

/// <summary>
/// svuint64_t svrevb[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
/// REVB Ztied.D, Pg/M, Zop.D
/// </summary>
public static unsafe Vector<ulong> ReverseElement8(Vector<ulong> value) => ReverseElement8(value);


/// Saturating decrement by number of halfword elements

/// <summary>
Expand Down
Loading

0 comments on commit a7386e0

Please sign in to comment.