Skip to content

Commit a7386e0

Browse files
Add support for Sve.ReverseElementX() (dotnet#102991)
* Add support for Sve.ReverseElementX() * Make ReverseElement8/16/32 as low masked operation
1 parent 2bf492b commit a7386e0

File tree

6 files changed

+343
-0
lines changed

6 files changed

+343
-0
lines changed

src/coreclr/jit/hwintrinsiccodegenarm64.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,11 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
18381838
break;
18391839
}
18401840

1841+
case NI_Sve_ReverseElement:
1842+
// Use non-predicated version explicitly
1843+
GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op1Reg, opt, INS_SCALABLE_OPTS_UNPREDICATED);
1844+
break;
1845+
18411846
case NI_Sve_StoreNarrowing:
18421847
opt = emitter::optGetSveInsOpt(emitTypeSize(intrin.baseType));
18431848
GetEmitter()->emitIns_R_R_R_I(ins, emitSize, op3Reg, op1Reg, op2Reg, 0, opt);

src/coreclr/jit/hwintrinsiclistarm64sve.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ HARDWARE_INTRINSIC(Sve, Negate,
140140
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)
141141
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)
142142
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)
143+
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)
144+
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)
145+
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)
146+
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)
143147
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)
144148
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)
145149
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)

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,6 +3093,150 @@ internal Arm64() { }
30933093
public static unsafe Vector<ulong> PopCount(Vector<ulong> value) { throw new PlatformNotSupportedException(); }
30943094

30953095

3096+
/// Reverse all elements
3097+
3098+
/// <summary>
3099+
/// svuint8_t svrev[_u8](svuint8_t op)
3100+
/// REV Zresult.B, Zop.B
3101+
/// </summary>
3102+
public static unsafe Vector<byte> ReverseElement(Vector<byte> value) { throw new PlatformNotSupportedException(); }
3103+
3104+
/// <summary>
3105+
/// svfloat64_t svrev[_f64](svfloat64_t op)
3106+
/// REV Zresult.D, Zop.D
3107+
/// </summary>
3108+
public static unsafe Vector<double> ReverseElement(Vector<double> value) { throw new PlatformNotSupportedException(); }
3109+
3110+
/// <summary>
3111+
/// svint16_t svrev[_s16](svint16_t op)
3112+
/// REV Zresult.H, Zop.H
3113+
/// </summary>
3114+
public static unsafe Vector<short> ReverseElement(Vector<short> value) { throw new PlatformNotSupportedException(); }
3115+
3116+
/// <summary>
3117+
/// svint32_t svrev[_s32](svint32_t op)
3118+
/// REV Zresult.S, Zop.S
3119+
/// </summary>
3120+
public static unsafe Vector<int> ReverseElement(Vector<int> value) { throw new PlatformNotSupportedException(); }
3121+
3122+
/// <summary>
3123+
/// svint64_t svrev[_s64](svint64_t op)
3124+
/// REV Zresult.D, Zop.D
3125+
/// </summary>
3126+
public static unsafe Vector<long> ReverseElement(Vector<long> value) { throw new PlatformNotSupportedException(); }
3127+
3128+
/// <summary>
3129+
/// svint8_t svrev[_s8](svint8_t op)
3130+
/// REV Zresult.B, Zop.B
3131+
/// </summary>
3132+
public static unsafe Vector<sbyte> ReverseElement(Vector<sbyte> value) { throw new PlatformNotSupportedException(); }
3133+
3134+
/// <summary>
3135+
/// svfloat32_t svrev[_f32](svfloat32_t op)
3136+
/// REV Zresult.S, Zop.S
3137+
/// </summary>
3138+
public static unsafe Vector<float> ReverseElement(Vector<float> value) { throw new PlatformNotSupportedException(); }
3139+
3140+
/// <summary>
3141+
/// svuint16_t svrev[_u16](svuint16_t op)
3142+
/// REV Zresult.H, Zop.H
3143+
/// </summary>
3144+
public static unsafe Vector<ushort> ReverseElement(Vector<ushort> value) { throw new PlatformNotSupportedException(); }
3145+
3146+
/// <summary>
3147+
/// svuint32_t svrev[_u32](svuint32_t op)
3148+
/// REV Zresult.S, Zop.S
3149+
/// </summary>
3150+
public static unsafe Vector<uint> ReverseElement(Vector<uint> value) { throw new PlatformNotSupportedException(); }
3151+
3152+
/// <summary>
3153+
/// svuint64_t svrev[_u64](svuint64_t op)
3154+
/// REV Zresult.D, Zop.D
3155+
/// </summary>
3156+
public static unsafe Vector<ulong> ReverseElement(Vector<ulong> value) { throw new PlatformNotSupportedException(); }
3157+
3158+
3159+
/// Reverse halfwords within elements
3160+
3161+
/// <summary>
3162+
/// svint32_t svrevh[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op)
3163+
/// REVH Ztied.S, Pg/M, Zop.S
3164+
/// </summary>
3165+
public static unsafe Vector<int> ReverseElement16(Vector<int> value) { throw new PlatformNotSupportedException(); }
3166+
3167+
/// <summary>
3168+
/// svint64_t svrevh[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
3169+
/// REVH Ztied.D, Pg/M, Zop.D
3170+
/// </summary>
3171+
public static unsafe Vector<long> ReverseElement16(Vector<long> value) { throw new PlatformNotSupportedException(); }
3172+
3173+
/// <summary>
3174+
/// svuint32_t svrevh[_u32]_m(svuint32_t inactive, svbool_t pg, svuint32_t op)
3175+
/// REVH Ztied.S, Pg/M, Zop.S
3176+
/// </summary>
3177+
public static unsafe Vector<uint> ReverseElement16(Vector<uint> value) { throw new PlatformNotSupportedException(); }
3178+
3179+
/// <summary>
3180+
/// svuint64_t svrevh[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
3181+
/// REVH Ztied.D, Pg/M, Zop.D
3182+
/// </summary>
3183+
public static unsafe Vector<ulong> ReverseElement16(Vector<ulong> value) { throw new PlatformNotSupportedException(); }
3184+
3185+
3186+
/// Reverse words within elements
3187+
3188+
/// <summary>
3189+
/// svint64_t svrevw[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
3190+
/// REVW Ztied.D, Pg/M, Zop.D
3191+
/// </summary>
3192+
public static unsafe Vector<long> ReverseElement32(Vector<long> value) { throw new PlatformNotSupportedException(); }
3193+
3194+
/// <summary>
3195+
/// svuint64_t svrevw[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
3196+
/// REVW Ztied.D, Pg/M, Zop.D
3197+
/// </summary>
3198+
public static unsafe Vector<ulong> ReverseElement32(Vector<ulong> value) { throw new PlatformNotSupportedException(); }
3199+
3200+
3201+
/// Reverse bytes within elements
3202+
3203+
/// <summary>
3204+
/// svint16_t svrevb[_s16]_m(svint16_t inactive, svbool_t pg, svint16_t op)
3205+
/// REVB Ztied.H, Pg/M, Zop.H
3206+
/// </summary>
3207+
public static unsafe Vector<short> ReverseElement8(Vector<short> value) { throw new PlatformNotSupportedException(); }
3208+
3209+
/// <summary>
3210+
/// svint32_t svrevb[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op)
3211+
/// REVB Ztied.S, Pg/M, Zop.S
3212+
/// </summary>
3213+
public static unsafe Vector<int> ReverseElement8(Vector<int> value) { throw new PlatformNotSupportedException(); }
3214+
3215+
/// <summary>
3216+
/// svint64_t svrevb[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
3217+
/// REVB Ztied.D, Pg/M, Zop.D
3218+
/// </summary>
3219+
public static unsafe Vector<long> ReverseElement8(Vector<long> value) { throw new PlatformNotSupportedException(); }
3220+
3221+
/// <summary>
3222+
/// svuint16_t svrevb[_u16]_m(svuint16_t inactive, svbool_t pg, svuint16_t op)
3223+
/// REVB Ztied.H, Pg/M, Zop.H
3224+
/// </summary>
3225+
public static unsafe Vector<ushort> ReverseElement8(Vector<ushort> value) { throw new PlatformNotSupportedException(); }
3226+
3227+
/// <summary>
3228+
/// svuint32_t svrevb[_u32]_m(svuint32_t inactive, svbool_t pg, svuint32_t op)
3229+
/// REVB Ztied.S, Pg/M, Zop.S
3230+
/// </summary>
3231+
public static unsafe Vector<uint> ReverseElement8(Vector<uint> value) { throw new PlatformNotSupportedException(); }
3232+
3233+
/// <summary>
3234+
/// svuint64_t svrevb[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
3235+
/// REVB Ztied.D, Pg/M, Zop.D
3236+
/// </summary>
3237+
public static unsafe Vector<ulong> ReverseElement8(Vector<ulong> value) { throw new PlatformNotSupportedException(); }
3238+
3239+
30963240
/// Saturating decrement by number of halfword elements
30973241

30983242
/// <summary>

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,6 +3149,150 @@ internal Arm64() { }
31493149
public static unsafe Vector<ulong> PopCount(Vector<ulong> value) => PopCount(value);
31503150

31513151

3152+
/// Reverse all elements
3153+
3154+
/// <summary>
3155+
/// svuint8_t svrev[_u8](svuint8_t op)
3156+
/// REV Zresult.B, Zop.B
3157+
/// </summary>
3158+
public static unsafe Vector<byte> ReverseElement(Vector<byte> value) => ReverseElement(value);
3159+
3160+
/// <summary>
3161+
/// svfloat64_t svrev[_f64](svfloat64_t op)
3162+
/// REV Zresult.D, Zop.D
3163+
/// </summary>
3164+
public static unsafe Vector<double> ReverseElement(Vector<double> value) => ReverseElement(value);
3165+
3166+
/// <summary>
3167+
/// svint16_t svrev[_s16](svint16_t op)
3168+
/// REV Zresult.H, Zop.H
3169+
/// </summary>
3170+
public static unsafe Vector<short> ReverseElement(Vector<short> value) => ReverseElement(value);
3171+
3172+
/// <summary>
3173+
/// svint32_t svrev[_s32](svint32_t op)
3174+
/// REV Zresult.S, Zop.S
3175+
/// </summary>
3176+
public static unsafe Vector<int> ReverseElement(Vector<int> value) => ReverseElement(value);
3177+
3178+
/// <summary>
3179+
/// svint64_t svrev[_s64](svint64_t op)
3180+
/// REV Zresult.D, Zop.D
3181+
/// </summary>
3182+
public static unsafe Vector<long> ReverseElement(Vector<long> value) => ReverseElement(value);
3183+
3184+
/// <summary>
3185+
/// svint8_t svrev[_s8](svint8_t op)
3186+
/// REV Zresult.B, Zop.B
3187+
/// </summary>
3188+
public static unsafe Vector<sbyte> ReverseElement(Vector<sbyte> value) => ReverseElement(value);
3189+
3190+
/// <summary>
3191+
/// svfloat32_t svrev[_f32](svfloat32_t op)
3192+
/// REV Zresult.S, Zop.S
3193+
/// </summary>
3194+
public static unsafe Vector<float> ReverseElement(Vector<float> value) => ReverseElement(value);
3195+
3196+
/// <summary>
3197+
/// svuint16_t svrev[_u16](svuint16_t op)
3198+
/// REV Zresult.H, Zop.H
3199+
/// </summary>
3200+
public static unsafe Vector<ushort> ReverseElement(Vector<ushort> value) => ReverseElement(value);
3201+
3202+
/// <summary>
3203+
/// svuint32_t svrev[_u32](svuint32_t op)
3204+
/// REV Zresult.S, Zop.S
3205+
/// </summary>
3206+
public static unsafe Vector<uint> ReverseElement(Vector<uint> value) => ReverseElement(value);
3207+
3208+
/// <summary>
3209+
/// svuint64_t svrev[_u64](svuint64_t op)
3210+
/// REV Zresult.D, Zop.D
3211+
/// </summary>
3212+
public static unsafe Vector<ulong> ReverseElement(Vector<ulong> value) => ReverseElement(value);
3213+
3214+
3215+
/// Reverse halfwords within elements
3216+
3217+
/// <summary>
3218+
/// svint32_t svrevh[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op)
3219+
/// REVH Ztied.S, Pg/M, Zop.S
3220+
/// </summary>
3221+
public static unsafe Vector<int> ReverseElement16(Vector<int> value) => ReverseElement16(value);
3222+
3223+
/// <summary>
3224+
/// svint64_t svrevh[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
3225+
/// REVH Ztied.D, Pg/M, Zop.D
3226+
/// </summary>
3227+
public static unsafe Vector<long> ReverseElement16(Vector<long> value) => ReverseElement16(value);
3228+
3229+
/// <summary>
3230+
/// svuint32_t svrevh[_u32]_m(svuint32_t inactive, svbool_t pg, svuint32_t op)
3231+
/// REVH Ztied.S, Pg/M, Zop.S
3232+
/// </summary>
3233+
public static unsafe Vector<uint> ReverseElement16(Vector<uint> value) => ReverseElement16(value);
3234+
3235+
/// <summary>
3236+
/// svuint64_t svrevh[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
3237+
/// REVH Ztied.D, Pg/M, Zop.D
3238+
/// </summary>
3239+
public static unsafe Vector<ulong> ReverseElement16(Vector<ulong> value) => ReverseElement16(value);
3240+
3241+
3242+
/// Reverse words within elements
3243+
3244+
/// <summary>
3245+
/// svint64_t svrevw[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
3246+
/// REVW Ztied.D, Pg/M, Zop.D
3247+
/// </summary>
3248+
public static unsafe Vector<long> ReverseElement32(Vector<long> value) => ReverseElement32(value);
3249+
3250+
/// <summary>
3251+
/// svuint64_t svrevw[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
3252+
/// REVW Ztied.D, Pg/M, Zop.D
3253+
/// </summary>
3254+
public static unsafe Vector<ulong> ReverseElement32(Vector<ulong> value) => ReverseElement32(value);
3255+
3256+
3257+
/// Reverse bytes within elements
3258+
3259+
/// <summary>
3260+
/// svint16_t svrevb[_s16]_m(svint16_t inactive, svbool_t pg, svint16_t op)
3261+
/// REVB Ztied.H, Pg/M, Zop.H
3262+
/// </summary>
3263+
public static unsafe Vector<short> ReverseElement8(Vector<short> value) => ReverseElement8(value);
3264+
3265+
/// <summary>
3266+
/// svint32_t svrevb[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op)
3267+
/// REVB Ztied.S, Pg/M, Zop.S
3268+
/// </summary>
3269+
public static unsafe Vector<int> ReverseElement8(Vector<int> value) => ReverseElement8(value);
3270+
3271+
/// <summary>
3272+
/// svint64_t svrevb[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op)
3273+
/// REVB Ztied.D, Pg/M, Zop.D
3274+
/// </summary>
3275+
public static unsafe Vector<long> ReverseElement8(Vector<long> value) => ReverseElement8(value);
3276+
3277+
/// <summary>
3278+
/// svuint16_t svrevb[_u16]_m(svuint16_t inactive, svbool_t pg, svuint16_t op)
3279+
/// REVB Ztied.H, Pg/M, Zop.H
3280+
/// </summary>
3281+
public static unsafe Vector<ushort> ReverseElement8(Vector<ushort> value) => ReverseElement8(value);
3282+
3283+
/// <summary>
3284+
/// svuint32_t svrevb[_u32]_m(svuint32_t inactive, svbool_t pg, svuint32_t op)
3285+
/// REVB Ztied.S, Pg/M, Zop.S
3286+
/// </summary>
3287+
public static unsafe Vector<uint> ReverseElement8(Vector<uint> value) => ReverseElement8(value);
3288+
3289+
/// <summary>
3290+
/// svuint64_t svrevb[_u64]_m(svuint64_t inactive, svbool_t pg, svuint64_t op)
3291+
/// REVB Ztied.D, Pg/M, Zop.D
3292+
/// </summary>
3293+
public static unsafe Vector<ulong> ReverseElement8(Vector<ulong> value) => ReverseElement8(value);
3294+
3295+
31523296
/// Saturating decrement by number of halfword elements
31533297

31543298
/// <summary>

0 commit comments

Comments
 (0)