diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 8b6d515d1b559b..2b9ec27eb8228c 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -26706,7 +26706,14 @@ bool GenTreeHWIntrinsic::OperIsMemoryStore(GenTree** pAddr) const case NI_SSE2_MaskMove: addr = Op(3); break; -#endif // TARGET_XARCH +#elif defined(TARGET_ARM64) + case NI_Sve_StoreAndZip: + case NI_Sve_StoreAndZipx2: + case NI_Sve_StoreAndZipx3: + case NI_Sve_StoreAndZipx4: + addr = Op(2); + break; +#endif // TARGET_ARM64 default: addr = Op(1); diff --git a/src/coreclr/jit/hwintrinsicarm64.cpp b/src/coreclr/jit/hwintrinsicarm64.cpp index 5a2154c9d1cf67..5a30c54fe78f55 100644 --- a/src/coreclr/jit/hwintrinsicarm64.cpp +++ b/src/coreclr/jit/hwintrinsicarm64.cpp @@ -2426,6 +2426,59 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, break; } + case NI_Sve_StoreAndZip: + { + assert(sig->numArgs == 3); + assert(retType == TYP_VOID); + + CORINFO_ARG_LIST_HANDLE arg1 = sig->args; + CORINFO_ARG_LIST_HANDLE arg2 = info.compCompHnd->getArgNext(arg1); + CORINFO_ARG_LIST_HANDLE arg3 = info.compCompHnd->getArgNext(arg2); + var_types argType = TYP_UNKNOWN; + CORINFO_CLASS_HANDLE argClass = NO_CLASS_HANDLE; + argType = JITtype2varType(strip(info.compCompHnd->getArgType(sig, arg3, &argClass))); + op3 = impPopStack().val; + unsigned fieldCount = info.compCompHnd->getClassNumInstanceFields(argClass); + + if (op3->TypeGet() == TYP_STRUCT) + { + info.compNeedsConsecutiveRegisters = true; + switch (fieldCount) + { + case 2: + intrinsic = NI_Sve_StoreAndZipx2; + break; + + case 3: + intrinsic = NI_Sve_StoreAndZipx3; + break; + + case 4: + intrinsic = NI_Sve_StoreAndZipx4; + break; + + default: + assert("unsupported"); + } + + if (!op3->OperIs(GT_LCL_VAR)) + { + unsigned tmp = lvaGrabTemp(true DEBUGARG("SveStoreN")); + + impStoreToTemp(tmp, op3, CHECK_SPILL_NONE); + op3 = gtNewLclvNode(tmp, argType); + } + op3 = gtConvertTableOpToFieldList(op3, fieldCount); + } + + argType = JITtype2varType(strip(info.compCompHnd->getArgType(sig, arg2, &argClass))); + op2 = getArgForHWIntrinsic(argType, argClass); + argType = JITtype2varType(strip(info.compCompHnd->getArgType(sig, arg1, &argClass))); + op1 = getArgForHWIntrinsic(argType, argClass); + retNode = gtNewSimdHWIntrinsicNode(retType, op1, op2, op3, intrinsic, simdBaseJitType, simdSize); + break; + } + default: { return nullptr; diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index c0dcd95b5b1b9e..5a4c5abdb76015 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -1348,6 +1348,67 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) } break; + case NI_Sve_StoreAndZipx2: + case NI_Sve_StoreAndZipx3: + case NI_Sve_StoreAndZipx4: + { + assert(intrin.op3->OperIsFieldList()); + GenTreeFieldList* fieldList = intrin.op3->AsFieldList(); + GenTree* firstField = fieldList->Uses().GetHead()->GetNode(); + op3Reg = firstField->GetRegNum(); + +#ifdef DEBUG + unsigned regCount = 0; + regNumber argReg = op3Reg; + for (GenTreeFieldList::Use& use : fieldList->Uses()) + { + regCount++; + + GenTree* argNode = use.GetNode(); + assert(argReg == argNode->GetRegNum()); + argReg = getNextSIMDRegWithWraparound(argReg); + } + + switch (ins) + { + case INS_sve_st2b: + case INS_sve_st2d: + case INS_sve_st2h: + case INS_sve_st2w: + case INS_sve_st2q: + assert(regCount == 2); + break; + + case INS_sve_st3b: + case INS_sve_st3d: + case INS_sve_st3h: + case INS_sve_st3w: + case INS_sve_st3q: + assert(regCount == 3); + break; + + case INS_sve_st4b: + case INS_sve_st4d: + case INS_sve_st4h: + case INS_sve_st4w: + case INS_sve_st4q: + assert(regCount == 4); + break; + + default: + unreached(); + } +#endif + GetEmitter()->emitIns_R_R_R_I(ins, emitSize, op3Reg, op1Reg, op2Reg, 0, opt); + break; + } + + case NI_Sve_StoreAndZip: + { + GetEmitter()->emitIns_R_R_R_I(ins, emitSize, op3Reg, op1Reg, op2Reg, 0, opt); + break; + } + case NI_Vector64_ToVector128: GetEmitter()->emitIns_Mov(ins, emitSize, targetReg, op1Reg, /* canSkip */ false); break; diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index 00b0739604b3cf..b8750fd90ad76b 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -114,6 +114,7 @@ HARDWARE_INTRINSIC(Sve, SignExtend32, HARDWARE_INTRINSIC(Sve, SignExtend8, -1, -1, false, {INS_invalid, INS_invalid, INS_sve_sxtb, INS_invalid, INS_sve_sxtb, INS_invalid, INS_sve_sxtb, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation) HARDWARE_INTRINSIC(Sve, SignExtendWideningLower, -1, 1, true, {INS_sve_sunpklo, INS_invalid, INS_sve_sunpklo, INS_invalid, INS_sve_sunpklo, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Sve, SignExtendWideningUpper, -1, 1, true, {INS_sve_sunpkhi, INS_invalid, INS_sve_sunpkhi, INS_invalid, INS_sve_sunpkhi, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(Sve, StoreAndZip, -1, 3, true, {INS_sve_st1b, INS_sve_st1b, INS_sve_st1h, INS_sve_st1h, INS_sve_st1w, INS_sve_st1w, INS_sve_st1d, INS_sve_st1d, INS_sve_st1w, INS_sve_st1d}, HW_Category_MemoryStore, HW_Flag_Scalable|HW_Flag_BaseTypeFromFirstArg|HW_Flag_ExplicitMaskedOperation|HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_LowMaskedOperation) HARDWARE_INTRINSIC(Sve, Subtract, -1, 2, true, {INS_sve_sub, INS_sve_sub, INS_sve_sub, INS_sve_sub, INS_sve_sub, INS_sve_sub, INS_sve_sub, INS_sve_sub, INS_sve_fsub, INS_sve_fsub}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_OptionalEmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation) HARDWARE_INTRINSIC(Sve, SubtractSaturate, -1, 2, true, {INS_sve_sqsub, INS_sve_uqsub, INS_sve_sqsub, INS_sve_uqsub, INS_sve_sqsub, INS_sve_uqsub, INS_sve_sqsub, INS_sve_uqsub, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_OptionalEmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation) HARDWARE_INTRINSIC(Sve, UnzipEven, -1, 2, true, {INS_sve_uzp1, INS_sve_uzp1, INS_sve_uzp1, INS_sve_uzp1, INS_sve_uzp1, INS_sve_uzp1, INS_sve_uzp1, INS_sve_uzp1, INS_sve_uzp1, INS_sve_uzp1}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_SpecialCodeGen) @@ -138,6 +139,9 @@ HARDWARE_INTRINSIC(Sve, ZipLow, HARDWARE_INTRINSIC(Sve, ConvertMaskToVector, -1, 1, true, {INS_sve_mov, INS_sve_mov, INS_sve_mov, INS_sve_mov, INS_sve_mov, INS_sve_mov, INS_sve_mov, INS_sve_mov, INS_sve_mov, INS_sve_mov}, HW_Category_Helper, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation) HARDWARE_INTRINSIC(Sve, ConvertVectorToMask, -1, 2, true, {INS_sve_cmpne, INS_sve_cmpne, INS_sve_cmpne, INS_sve_cmpne, INS_sve_cmpne, INS_sve_cmpne, INS_sve_cmpne, INS_sve_cmpne, INS_sve_cmpne, INS_sve_cmpne}, HW_Category_Helper, HW_Flag_Scalable|HW_Flag_ReturnsPerElementMask|HW_Flag_LowMaskedOperation) HARDWARE_INTRINSIC(Sve, CreateTrueMaskAll, -1, -1, false, {INS_sve_ptrue, INS_sve_ptrue, INS_sve_ptrue, INS_sve_ptrue, INS_sve_ptrue, INS_sve_ptrue, INS_sve_ptrue, INS_sve_ptrue, INS_sve_ptrue, INS_sve_ptrue}, HW_Category_Helper, HW_Flag_Scalable|HW_Flag_ReturnsPerElementMask) +HARDWARE_INTRINSIC(Sve, StoreAndZipx2, -1, 3, true, {INS_sve_st2b, INS_sve_st2b, INS_sve_st2h, INS_sve_st2h, INS_sve_st2w, INS_sve_st2w, INS_sve_st2d, INS_sve_st2d, INS_sve_st2w, INS_sve_st2d}, HW_Category_MemoryStore, HW_Flag_Scalable|HW_Flag_SpecialCodeGen|HW_Flag_ExplicitMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_NeedsConsecutiveRegisters) +HARDWARE_INTRINSIC(Sve, StoreAndZipx3, -1, 3, true, {INS_sve_st3b, INS_sve_st3b, INS_sve_st3h, INS_sve_st3h, INS_sve_st3w, INS_sve_st3w, INS_sve_st3d, INS_sve_st3d, INS_sve_st3w, INS_sve_st3d}, HW_Category_MemoryStore, HW_Flag_Scalable|HW_Flag_SpecialCodeGen|HW_Flag_ExplicitMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_NeedsConsecutiveRegisters) +HARDWARE_INTRINSIC(Sve, StoreAndZipx4, -1, 3, true, {INS_sve_st4b, INS_sve_st4b, INS_sve_st4h, INS_sve_st4h, INS_sve_st4w, INS_sve_st4w, INS_sve_st4d, INS_sve_st4d, INS_sve_st4w, INS_sve_st4d}, HW_Category_MemoryStore, HW_Flag_Scalable|HW_Flag_SpecialCodeGen|HW_Flag_ExplicitMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_NeedsConsecutiveRegisters) #endif // FEATURE_HW_INTRINSIC diff --git a/src/coreclr/jit/lsraarm64.cpp b/src/coreclr/jit/lsraarm64.cpp index c133a4a6917762..cc3e6fae655c3e 100644 --- a/src/coreclr/jit/lsraarm64.cpp +++ b/src/coreclr/jit/lsraarm64.cpp @@ -1758,6 +1758,20 @@ int LinearScan::BuildHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree, int* pDstCou break; } + case NI_Sve_StoreAndZipx2: + case NI_Sve_StoreAndZipx3: + case NI_Sve_StoreAndZipx4: + { + assert(intrin.op2 != nullptr); + assert(intrin.op3 != nullptr); + srcCount += BuildAddrUses(intrin.op2); + srcCount += BuildConsecutiveRegistersForUse(intrin.op3); + assert(dstCount == 0); + buildInternalRegisterUses(); + *pDstCount = 0; + break; + } + default: noway_assert(!"Not a supported as multiple consecutive register intrinsic"); } @@ -1894,6 +1908,10 @@ int LinearScan::BuildHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree, int* pDstCou (argNum == lowVectorOperandNum) ? lowVectorCandidates : RBM_NONE); } } + else if (intrin.id == NI_Sve_StoreAndZip) + { + srcCount += BuildAddrUses(intrin.op2); + } else { regMaskTP candidates = lowVectorOperandNum == 2 ? lowVectorCandidates : RBM_NONE; diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs index 346b2c1de1f00b..9be0014bd9ecb7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs @@ -2570,6 +2570,250 @@ internal Arm64() { } /// public static unsafe Vector SignExtend8(Vector value) { throw new PlatformNotSupportedException(); } + + /// Non-truncating store + + /// + /// void svst1[_u8](svbool_t pg, uint8_t *base, svuint8_t data) + /// ST1B Zdata.B, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, byte* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_u8](svbool_t pg, uint8_t *base, svuint8x2_t data) + /// ST2B {Zdata0.B, Zdata1.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, byte* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_u8](svbool_t pg, uint8_t *base, svuint8x3_t data) + /// ST3B {Zdata0.B - Zdata2.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, byte* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_u8](svbool_t pg, uint8_t *base, svuint8x4_t data) + /// ST4B {Zdata0.B - Zdata3.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, byte* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst1[_f64](svbool_t pg, float64_t *base, svfloat64_t data) + /// ST1D Zdata.D, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, double* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_f64](svbool_t pg, float64_t *base, svfloat64x2_t data) + /// ST2D {Zdata0.D, Zdata1.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, double* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_f64](svbool_t pg, float64_t *base, svfloat64x3_t data) + /// ST3D {Zdata0.D - Zdata2.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, double* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_f64](svbool_t pg, float64_t *base, svfloat64x4_t data) + /// ST4D {Zdata0.D - Zdata3.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, double* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst1[_s16](svbool_t pg, int16_t *base, svint16_t data) + /// ST1H Zdata.H, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, short* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_s16](svbool_t pg, int16_t *base, svint16x2_t data) + /// ST2H {Zdata0.H, Zdata1.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, short* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_s16](svbool_t pg, int16_t *base, svint16x3_t data) + /// ST3H {Zdata0.H - Zdata2.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, short* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_s16](svbool_t pg, int16_t *base, svint16x4_t data) + /// ST4H {Zdata0.H - Zdata3.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, short* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst1[_s32](svbool_t pg, int32_t *base, svint32_t data) + /// ST1W Zdata.S, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, int* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_s32](svbool_t pg, int32_t *base, svint32x2_t data) + /// ST2W {Zdata0.S, Zdata1.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, int* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_s32](svbool_t pg, int32_t *base, svint32x3_t data) + /// ST3W {Zdata0.S - Zdata2.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, int* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_s32](svbool_t pg, int32_t *base, svint32x4_t data) + /// ST4W {Zdata0.S - Zdata3.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, int* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst1[_s64](svbool_t pg, int64_t *base, svint64_t data) + /// ST1D Zdata.D, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, long* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_s64](svbool_t pg, int64_t *base, svint64x2_t data) + /// ST2D {Zdata0.D, Zdata1.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, long* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_s64](svbool_t pg, int64_t *base, svint64x3_t data) + /// ST3D {Zdata0.D - Zdata2.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, long* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_s64](svbool_t pg, int64_t *base, svint64x4_t data) + /// ST4D {Zdata0.D - Zdata3.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, long* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst1[_s8](svbool_t pg, int8_t *base, svint8_t data) + /// ST1B Zdata.B, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, sbyte* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_s8](svbool_t pg, int8_t *base, svint8x2_t data) + /// ST2B {Zdata0.B, Zdata1.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, sbyte* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_s8](svbool_t pg, int8_t *base, svint8x3_t data) + /// ST3B {Zdata0.B - Zdata2.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, sbyte* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_s8](svbool_t pg, int8_t *base, svint8x4_t data) + /// ST4B {Zdata0.B - Zdata3.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, sbyte* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst1[_f32](svbool_t pg, float32_t *base, svfloat32_t data) + /// ST1W Zdata.S, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, float* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_f32](svbool_t pg, float32_t *base, svfloat32x2_t data) + /// ST2W {Zdata0.S, Zdata1.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, float* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_f32](svbool_t pg, float32_t *base, svfloat32x3_t data) + /// ST3W {Zdata0.S - Zdata2.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, float* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_f32](svbool_t pg, float32_t *base, svfloat32x4_t data) + /// ST4W {Zdata0.S - Zdata3.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, float* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst1[_u16](svbool_t pg, uint16_t *base, svuint16_t data) + /// ST1H Zdata.H, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ushort* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_u16](svbool_t pg, uint16_t *base, svuint16x2_t data) + /// ST2H {Zdata0.H, Zdata1.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ushort* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_u16](svbool_t pg, uint16_t *base, svuint16x3_t data) + /// ST3H {Zdata0.H - Zdata2.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ushort* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_u16](svbool_t pg, uint16_t *base, svuint16x4_t data) + /// ST4H {Zdata0.H - Zdata3.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ushort* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst1[_u32](svbool_t pg, uint32_t *base, svuint32_t data) + /// ST1W Zdata.S, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, uint* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_u32](svbool_t pg, uint32_t *base, svuint32x2_t data) + /// ST2W {Zdata0.S, Zdata1.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, uint* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_u32](svbool_t pg, uint32_t *base, svuint32x3_t data) + /// ST3W {Zdata0.S - Zdata2.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, uint* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_u32](svbool_t pg, uint32_t *base, svuint32x4_t data) + /// ST4W {Zdata0.S - Zdata3.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, uint* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst1[_u64](svbool_t pg, uint64_t *base, svuint64_t data) + /// ST1D Zdata.D, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ulong* address, Vector data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst2[_u64](svbool_t pg, uint64_t *base, svuint64x2_t data) + /// ST2D {Zdata0.D, Zdata1.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ulong* address, (Vector Value1, Vector Value2) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst3[_u64](svbool_t pg, uint64_t *base, svuint64x3_t data) + /// ST3D {Zdata0.D - Zdata2.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ulong* address, (Vector Value1, Vector Value2, Vector Value3) data) { throw new PlatformNotSupportedException(); } + + /// + /// void svst4[_u64](svbool_t pg, uint64_t *base, svuint64x4_t data) + /// ST4D {Zdata0.D - Zdata3.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ulong* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) { throw new PlatformNotSupportedException(); } + + /// Subtract : Subtract /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs index b6c4be424c0563..120dcd1177531e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs @@ -2666,6 +2666,250 @@ internal Arm64() { } /// public static unsafe Vector SignExtendWideningUpper(Vector value) => SignExtendWideningUpper(value); + + /// Non-truncating store + + /// + /// void svst1[_u8](svbool_t pg, uint8_t *base, svuint8_t data) + /// ST1B Zdata.B, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, byte* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_u8](svbool_t pg, uint8_t *base, svuint8x2_t data) + /// ST2B {Zdata0.B, Zdata1.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, byte* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_u8](svbool_t pg, uint8_t *base, svuint8x3_t data) + /// ST3B {Zdata0.B - Zdata2.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, byte* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_u8](svbool_t pg, uint8_t *base, svuint8x4_t data) + /// ST4B {Zdata0.B - Zdata3.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, byte* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// + /// void svst1[_f64](svbool_t pg, float64_t *base, svfloat64_t data) + /// ST1D Zdata.D, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, double* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_f64](svbool_t pg, float64_t *base, svfloat64x2_t data) + /// ST2D {Zdata0.D, Zdata1.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, double* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_f64](svbool_t pg, float64_t *base, svfloat64x3_t data) + /// ST3D {Zdata0.D - Zdata2.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, double* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_f64](svbool_t pg, float64_t *base, svfloat64x4_t data) + /// ST4D {Zdata0.D - Zdata3.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, double* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// + /// void svst1[_s16](svbool_t pg, int16_t *base, svint16_t data) + /// ST1H Zdata.H, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, short* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_s16](svbool_t pg, int16_t *base, svint16x2_t data) + /// ST2H {Zdata0.H, Zdata1.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, short* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_s16](svbool_t pg, int16_t *base, svint16x3_t data) + /// ST3H {Zdata0.H - Zdata2.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, short* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_s16](svbool_t pg, int16_t *base, svint16x4_t data) + /// ST4H {Zdata0.H - Zdata3.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, short* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// + /// void svst1[_s32](svbool_t pg, int32_t *base, svint32_t data) + /// ST1W Zdata.S, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, int* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_s32](svbool_t pg, int32_t *base, svint32x2_t data) + /// ST2W {Zdata0.S, Zdata1.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, int* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_s32](svbool_t pg, int32_t *base, svint32x3_t data) + /// ST3W {Zdata0.S - Zdata2.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, int* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_s32](svbool_t pg, int32_t *base, svint32x4_t data) + /// ST4W {Zdata0.S - Zdata3.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, int* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// + /// void svst1[_s64](svbool_t pg, int64_t *base, svint64_t data) + /// ST1D Zdata.D, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, long* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_s64](svbool_t pg, int64_t *base, svint64x2_t data) + /// ST2D {Zdata0.D, Zdata1.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, long* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_s64](svbool_t pg, int64_t *base, svint64x3_t data) + /// ST3D {Zdata0.D - Zdata2.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, long* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_s64](svbool_t pg, int64_t *base, svint64x4_t data) + /// ST4D {Zdata0.D - Zdata3.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, long* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// + /// void svst1[_s8](svbool_t pg, int8_t *base, svint8_t data) + /// ST1B Zdata.B, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, sbyte* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_s8](svbool_t pg, int8_t *base, svint8x2_t data) + /// ST2B {Zdata0.B, Zdata1.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, sbyte* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_s8](svbool_t pg, int8_t *base, svint8x3_t data) + /// ST3B {Zdata0.B - Zdata2.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, sbyte* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_s8](svbool_t pg, int8_t *base, svint8x4_t data) + /// ST4B {Zdata0.B - Zdata3.B}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, sbyte* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// + /// void svst1[_f32](svbool_t pg, float32_t *base, svfloat32_t data) + /// ST1W Zdata.S, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, float* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_f32](svbool_t pg, float32_t *base, svfloat32x2_t data) + /// ST2W {Zdata0.S, Zdata1.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, float* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_f32](svbool_t pg, float32_t *base, svfloat32x3_t data) + /// ST3W {Zdata0.S - Zdata2.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, float* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_f32](svbool_t pg, float32_t *base, svfloat32x4_t data) + /// ST4W {Zdata0.S - Zdata3.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, float* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// + /// void svst1[_u16](svbool_t pg, uint16_t *base, svuint16_t data) + /// ST1H Zdata.H, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ushort* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_u16](svbool_t pg, uint16_t *base, svuint16x2_t data) + /// ST2H {Zdata0.H, Zdata1.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ushort* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_u16](svbool_t pg, uint16_t *base, svuint16x3_t data) + /// ST3H {Zdata0.H - Zdata2.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ushort* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_u16](svbool_t pg, uint16_t *base, svuint16x4_t data) + /// ST4H {Zdata0.H - Zdata3.H}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ushort* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// + /// void svst1[_u32](svbool_t pg, uint32_t *base, svuint32_t data) + /// ST1W Zdata.S, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, uint* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_u32](svbool_t pg, uint32_t *base, svuint32x2_t data) + /// ST2W {Zdata0.S, Zdata1.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, uint* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_u32](svbool_t pg, uint32_t *base, svuint32x3_t data) + /// ST3W {Zdata0.S - Zdata2.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, uint* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_u32](svbool_t pg, uint32_t *base, svuint32x4_t data) + /// ST4W {Zdata0.S - Zdata3.S}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, uint* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// + /// void svst1[_u64](svbool_t pg, uint64_t *base, svuint64_t data) + /// ST1D Zdata.D, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ulong* address, Vector data) => StoreAndZip(mask, address, data); + + /// + /// void svst2[_u64](svbool_t pg, uint64_t *base, svuint64x2_t data) + /// ST2D {Zdata0.D, Zdata1.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ulong* address, (Vector Value1, Vector Value2) data) => StoreAndZip(mask, address, data); + + /// + /// void svst3[_u64](svbool_t pg, uint64_t *base, svuint64x3_t data) + /// ST3D {Zdata0.D - Zdata2.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ulong* address, (Vector Value1, Vector Value2, Vector Value3) data) => StoreAndZip(mask, address, data); + + /// + /// void svst4[_u64](svbool_t pg, uint64_t *base, svuint64x4_t data) + /// ST4D {Zdata0.D - Zdata3.D}, Pg, [Xbase, #0, MUL VL] + /// + public static unsafe void StoreAndZip(Vector mask, ulong* address, (Vector Value1, Vector Value2, Vector Value3, Vector Value4) data) => StoreAndZip(mask, address, data); + + /// Subtract : Subtract /// diff --git a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs index 665f5d41ee98d1..418ba79428bf9f 100644 --- a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs +++ b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs @@ -4521,7 +4521,48 @@ internal Arm64() { } public static System.Numerics.Vector SignExtendWideningLower(System.Numerics.Vector value) { throw null; } public static System.Numerics.Vector SignExtendWideningUpper(System.Numerics.Vector value) { throw null; } public static System.Numerics.Vector SignExtendWideningUpper(System.Numerics.Vector value) { throw null; } - public static System.Numerics.Vector SignExtendWideningUpper(System.Numerics.Vector value) { throw null; } + public static System.Numerics.Vector SignExtendWideningUpper(System.Numerics.Vector value) { throw null; } + + public static unsafe void StoreAndZip(System.Numerics.Vector mask, byte* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, byte* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, byte* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, byte* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, double* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, double* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, double* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, double* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, short* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, short* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, short* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, short* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, int* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, int* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, int* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, int* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, long* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, long* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, long* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, long* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, sbyte* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, sbyte* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, sbyte* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, sbyte* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, float* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, float* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, float* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, float* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, ushort* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, ushort* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, ushort* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, ushort* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, uint* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, uint* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, uint* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, uint* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, ulong* address, System.Numerics.Vector data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, ulong* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, ulong* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3) data) { throw null; } + public static unsafe void StoreAndZip(System.Numerics.Vector mask, ulong* address, (System.Numerics.Vector Value1, System.Numerics.Vector Value2, System.Numerics.Vector Value3, System.Numerics.Vector Value4) data) { throw null; } public static System.Numerics.Vector Subtract(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector Subtract(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index b37ec3a274b171..e9cce1a4564469 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -3363,6 +3363,47 @@ ("SveVecPairBinOpTest.template", new Dictionary { ["TestName"] = "SveZipLow_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ZipLow", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateEntry"] = "result[i] != left[index] || result[i + 1] != right[index]"}), ("SveVecPairBinOpTest.template", new Dictionary { ["TestName"] = "SveZipLow_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ZipLow", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateEntry"] = "result[i] != left[index] || result[i + 1] != right[index]"}), ("SveVecPairBinOpTest.template", new Dictionary { ["TestName"] = "SveZipLow_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ZipLow", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateEntry"] = "result[i] != left[index] || result[i + 1] != right[index]"}), + + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTest.template", new Dictionary { ["TestName"] = "SveStoreAndZip_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateEntry"] = "(maskArray[i] == 0 && result[i] != 0) || (maskArray[i] == 1 && result[i] != first[i])"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx2.template", new Dictionary { ["TestName"] = "SveStoreAndZipx2_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx3.template", new Dictionary { ["TestName"] = "SveStoreAndZipx3_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), + ("SveStoreAndZipTestx4.template", new Dictionary { ["TestName"] = "SveStoreAndZipx4_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "StoreAndZip", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateEntry"] = "(maskArray[i] == 0 && (result[index] != 0 || result[index + 1] != 0 || result[index + 2] != 0 || result[index + 3] != 0)) || (maskArray[i] == 1 && (result[index] != first[i] || result[index + 1] != second[i] || result[index + 2] != third[i] || result[index + 3] != fourth[i]))"}), }; diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTest.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTest.template new file mode 100644 index 00000000000000..d8294856452ac2 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTest.template @@ -0,0 +1,336 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\Arm\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Numerics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.Arm; +using Xunit; + +namespace JIT.HardwareIntrinsics.Arm +{ + public static partial class Program + { + [Fact] + public static void {TestName}() + { + var test = new StoreTest__{TestName}(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sve.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class StoreTest__{TestName} + { + private struct DataTable + { + private byte[] inArray1; + private byte[] outArray; + private byte[] maskArray; + + private GCHandle inHandle1; + private GCHandle outHandle; + private GCHandle maskHandle; + + private ulong alignment; + + public DataTable({Op1BaseType}[] inArray1, {RetBaseType}[] outArray, {Op1BaseType}[] maskArray, int alignment) + { + int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); + int sizeOfmaskArray = maskArray.Length * Unsafe.SizeOf<{Op1BaseType}>(); + + if ((alignment != 64 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray || (alignment * 2) < sizeOfmaskArray) + { + throw new ArgumentException("Invalid value of alignment"); + } + + this.inArray1 = new byte[alignment * 2]; + this.outArray = new byte[alignment * 2]; + this.maskArray = new byte[alignment * 2]; + + this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); + this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); + this.maskHandle = GCHandle.Alloc(this.maskArray, GCHandleType.Pinned); + + this.alignment = (ulong)alignment; + + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray1Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), (uint)sizeOfinArray1); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(maskArrayPtr), ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), (uint)sizeOfmaskArray); + } + + public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); + public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); + public void* maskArrayPtr => Align((byte*)(maskHandle.AddrOfPinnedObject().ToPointer()), alignment); + + public void Dispose() + { + inHandle1.Free(); + outHandle.Free(); + maskHandle.Free(); + } + + public static unsafe void* Align(byte* buffer, ulong expectedAlignment) + { + return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); + } + } + + + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op1VectorType}<{Op1BaseType}> _storeMask; + private GCHandle _outHandle; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var rnd = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < MaskElementCount; i++) { _maskData[i] = ({Op1BaseType})1; } + for (var i = 0; i < MaskElementCount / 2; i++) { _maskData[rnd.Next(MaskElementCount)] = ({Op1BaseType})0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._storeMask), ref Unsafe.As<{Op1BaseType}, byte>(ref _maskData[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + ulong alignment = (ulong)LargestVectorSize; + byte[] _outArray = new byte[alignment * 2]; + testStruct._outHandle = GCHandle.Alloc(_outArray, GCHandleType.Pinned); + + return testStruct; + } + + public void* _outArrayPtr => DataTable.Align((byte*)(_outHandle.AddrOfPinnedObject().ToPointer()), (ulong)LargestVectorSize); + + public void Dispose() + { + _outHandle.Free(); + } + + public void RunStructFldScenario(StoreTest__{TestName} testClass) + { + Sve.{Method}(_storeMask, ({Op1BaseType}*) _outArrayPtr, _fld1); + + testClass.ValidateResult(_fld1, _outArrayPtr, _storeMask); + } + } + + private static readonly int LargestVectorSize = {LargestVectorSize}; + + private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); + private static readonly int MaskElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + + private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; + private static {Op1BaseType}[] _maskData = new {Op1BaseType}[MaskElementCount]; + + private DataTable _dataTable; + + public StoreTest__{TestName}() + { + Succeeded = true; + var rnd = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + for (var i = 0; i < MaskElementCount; i++) { _maskData[i] = ({Op1BaseType})1; } + for (var i = 0; i < MaskElementCount / 2; i++) { _maskData[rnd.Next(MaskElementCount)] = ({Op1BaseType})0; } + + _dataTable = new DataTable(_data1, new {RetBaseType}[RetElementCount], _maskData, LargestVectorSize); + } + + public bool IsSupported => Sve.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); + + Sve.{Method}(Unsafe.Read>(_dataTable.maskArrayPtr), ({Op1BaseType} *)_dataTable.outArrayPtr, Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr)); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunBasicScenario_Load() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); + {Op1VectorType}<{Op1BaseType}> loadMask = Sve.CreateTrueMask{Op1BaseType}(SveMaskPattern.All); + + Sve.{Method}(Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.maskArrayPtr)), ({Op1BaseType} *)_dataTable.outArrayPtr, Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray1Ptr))); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); + + typeof(Sve).GetMethod(nameof(Sve.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op1BaseType} *), typeof({Op1VectorType}<{Op1BaseType}>) }) + .Invoke(null, new object[] { Unsafe.Read>(_dataTable.maskArrayPtr), + Pointer.Box(_dataTable.outArrayPtr, typeof({Op1BaseType}*)), Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr) + }); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); + + {Op1VectorType}<{Op1BaseType}> op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + {Op1VectorType}<{Op1BaseType}> storeMask = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.maskArrayPtr); + + Sve.{Method}(storeMask, ({Op1BaseType} *)_dataTable.outArrayPtr, op1); + + ValidateResult(op1, _dataTable.outArrayPtr, storeMask); + } + + public void RunClassFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); + + {Op1VectorType}<{Op1BaseType}> op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + {Op1VectorType}<{Op1BaseType}> storeMask = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.maskArrayPtr); + + Sve.{Method}(storeMask, ({Op1BaseType} *)_dataTable.outArrayPtr, op1); + + ValidateResult(op1, _dataTable.outArrayPtr, storeMask); + } + + public void RunStructLclFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); + + var test = TestStruct.Create(); + Sve.{Method}(test._storeMask, ({Op1BaseType} *)test._outArrayPtr, test._fld1); + + ValidateResult(test._fld1, test._outArrayPtr, test._storeMask); + } + + public void RunStructFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); + + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); + + bool succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + succeeded = true; + } + + if (!succeeded) + { + Succeeded = false; + } + } + + private void ValidateResult({Op1VectorType}<{Op1BaseType}> op1, void* result, {Op1VectorType}<{Op1BaseType}> storeMask, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + {Op1BaseType}[] maskArray = new {Op1BaseType}[MaskElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), op1); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), storeMask); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + + ValidateResult(inArray1, outArray, maskArray, method); + } + + private void ValidateResult(void* op1, void* result, void* mask, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + {Op1BaseType}[] maskArray = new {Op1BaseType}[MaskElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), ref Unsafe.AsRef(op1), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), ref Unsafe.AsRef(mask), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + ValidateResult(inArray1, outArray, maskArray, method); + } + + private void ValidateResult({Op1BaseType}[] first, {RetBaseType}[] result, {Op1BaseType}[] maskArray, [CallerMemberName] string method = "") + { + bool succeeded = true; + + for (var i = 0; i < Op1ElementCount; i++) + { + if ({ValidateEntry}) + { + succeeded = false; + break; + } + } + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{nameof(Sve)}.{nameof(Sve.{Method})}<{Op1BaseType}>({Op1VectorType}<{Op1BaseType}>, {Op1BaseType}*, {Op1VectorType}<{Op1BaseType}>): {method} failed:"); + TestLibrary.TestFramework.LogInformation($" first: ({string.Join(", ", first)})"); + TestLibrary.TestFramework.LogInformation($" mask: ({string.Join(", ", maskArray)})"); + TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + Succeeded = false; + } + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTestx2.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTestx2.template new file mode 100644 index 00000000000000..992d253246492b --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTestx2.template @@ -0,0 +1,366 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\Arm\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Numerics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.Arm; +using Xunit; + +namespace JIT.HardwareIntrinsics.Arm +{ + public static partial class Program + { + [Fact] + public static void {TestName}() + { + var test = new Storex2Test__{TestName}(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sve.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class Storex2Test__{TestName} + { + private struct DataTable + { + private byte[] inArray1; + private byte[] inArray2; + private byte[] outArray; + private byte[] maskArray; + + private GCHandle inHandle1; + private GCHandle inHandle2; + private GCHandle outHandle; + private GCHandle maskHandle; + + private ulong alignment; + + public DataTable({Op1BaseType}[] inArray1, {Op1BaseType}[] inArray2, {RetBaseType}[] outArray, {Op1BaseType}[] maskArray, int alignment) + { + int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); + int sizeOfmaskArray = maskArray.Length * Unsafe.SizeOf<{Op1BaseType}>(); + + if ((alignment != 64 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 4) < sizeOfoutArray || (alignment * 2) < sizeOfmaskArray) + { + throw new ArgumentException("Invalid value of alignment"); + } + + this.inArray1 = new byte[alignment * 2]; + this.inArray2 = new byte[alignment * 2]; + this.outArray = new byte[alignment * 4]; + this.maskArray = new byte[alignment * 2]; + + this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); + this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); + this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); + this.maskHandle = GCHandle.Alloc(this.maskArray, GCHandleType.Pinned); + + this.alignment = (ulong)alignment; + + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray1Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), (uint)sizeOfinArray1); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray2Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray2[0]), (uint)sizeOfinArray2); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(maskArrayPtr), ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), (uint)sizeOfmaskArray); + } + + public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); + public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); + public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); + public void* maskArrayPtr => Align((byte*)(maskHandle.AddrOfPinnedObject().ToPointer()), alignment); + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + maskHandle.Free(); + } + + public static unsafe void* Align(byte* buffer, ulong expectedAlignment) + { + return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); + } + } + + + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op1VectorType}<{Op1BaseType}> _fld2; + public {Op1VectorType}<{Op1BaseType}> _storeMask; + private GCHandle _outHandle; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var rnd = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op1BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < MaskElementCount; i++) { _maskData[i] = ({Op1BaseType})1; } + for (var i = 0; i < MaskElementCount / 2; i++) { _maskData[rnd.Next(MaskElementCount)] = ({Op1BaseType})0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._storeMask), ref Unsafe.As<{Op1BaseType}, byte>(ref _maskData[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + ulong alignment = (ulong)LargestVectorSize; + byte[] _outArray = new byte[alignment * 4]; + testStruct._outHandle = GCHandle.Alloc(_outArray, GCHandleType.Pinned); + + return testStruct; + } + + public void* _outArrayPtr => DataTable.Align((byte*)(_outHandle.AddrOfPinnedObject().ToPointer()), (ulong)LargestVectorSize); + + public void Dispose() + { + _outHandle.Free(); + } + + public void RunStructFldScenario(Storex2Test__{TestName} testClass) + { + Sve.{Method}(_storeMask, ({Op1BaseType}*) _outArrayPtr, (_fld1, _fld2)); + + testClass.ValidateResult(_fld1, _fld2, _outArrayPtr, _storeMask); + } + } + + private static readonly int LargestVectorSize = {LargestVectorSize}; + + private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int Op2ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}) * 2; + private static readonly int MaskElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + + private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; + private static {Op1BaseType}[] _data2 = new {Op1BaseType}[Op2ElementCount]; + private static {Op1BaseType}[] _maskData = new {Op1BaseType}[MaskElementCount]; + + private DataTable _dataTable; + + public Storex2Test__{TestName}() + { + Succeeded = true; + var rnd = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp1}; } + for (var i = 0; i < MaskElementCount; i++) { _maskData[i] = ({Op1BaseType})1; } + for (var i = 0; i < MaskElementCount / 2; i++) { _maskData[rnd.Next(MaskElementCount)] = ({Op1BaseType})0; } + + _dataTable = new DataTable(_data1, _data2, new {RetBaseType}[RetElementCount], _maskData, LargestVectorSize); + } + + public bool IsSupported => Sve.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); + + Sve.{Method}(Unsafe.Read>(_dataTable.maskArrayPtr), ({Op1BaseType} *)_dataTable.outArrayPtr, + (Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr)) + ); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunBasicScenario_Load() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); + {Op1VectorType}<{Op1BaseType}> loadMask = Sve.CreateTrueMask{Op1BaseType}(SveMaskPattern.All); + + Sve.{Method}(Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.maskArrayPtr)), ({Op1BaseType} *)_dataTable.outArrayPtr, + (Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray1Ptr)), + Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray2Ptr))) + ); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); + + typeof(Sve).GetMethod(nameof(Sve.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op1BaseType} *), typeof(({Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>)) }) + .Invoke(null, new object[] { Unsafe.Read>(_dataTable.maskArrayPtr), + Pointer.Box(_dataTable.outArrayPtr, typeof({Op1BaseType}*)), + (Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr)) + }); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); + + {Op1VectorType}<{Op1BaseType}> op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + {Op1VectorType}<{Op1BaseType}> op2 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr); + {Op1VectorType}<{Op1BaseType}> storeMask = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.maskArrayPtr); + + Sve.{Method}(storeMask, ({Op1BaseType} *)_dataTable.outArrayPtr, (op1, op2)); + + ValidateResult(op1, op2, _dataTable.outArrayPtr, storeMask); + } + + public void RunClassFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); + + {Op1VectorType}<{Op1BaseType}> op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + {Op1VectorType}<{Op1BaseType}> op2 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr); + {Op1VectorType}<{Op1BaseType}> storeMask = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.maskArrayPtr); + + Sve.{Method}(storeMask, ({Op1BaseType} *)_dataTable.outArrayPtr, (op1, op2)); + + ValidateResult(op1, op2, _dataTable.outArrayPtr, storeMask); + } + + public void RunStructLclFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); + + var test = TestStruct.Create(); + Sve.{Method}(test._storeMask, ({Op1BaseType} *)test._outArrayPtr, (test._fld1, test._fld2)); + + ValidateResult(test._fld1, test._fld2, test._outArrayPtr, test._storeMask); + } + + public void RunStructFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); + + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); + + bool succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + succeeded = true; + } + + if (!succeeded) + { + Succeeded = false; + } + } + + private void ValidateResult({Op1VectorType}<{Op1BaseType}> op1, {Op1VectorType}<{Op1BaseType}> op2, void* result, {Op1VectorType}<{Op1BaseType}> storeMask, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] inArray2 = new {Op1BaseType}[Op2ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + {Op1BaseType}[] maskArray = new {Op1BaseType}[MaskElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), op1); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray2[0]), op2); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), storeMask); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() * 2); + + ValidateResult(inArray1, inArray2, outArray, maskArray, method); + } + + private void ValidateResult(void* op1, void* op2, void* result, void* mask, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] inArray2 = new {Op1BaseType}[Op2ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + {Op1BaseType}[] maskArray = new {Op1BaseType}[MaskElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), ref Unsafe.AsRef(op1), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray2[0]), ref Unsafe.AsRef(op2), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() * 2); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), ref Unsafe.AsRef(mask), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + ValidateResult(inArray1, inArray2, outArray, maskArray, method); + } + + private void ValidateResult({Op1BaseType}[] first, {Op1BaseType}[] second, {RetBaseType}[] result, {Op1BaseType}[] maskArray, [CallerMemberName] string method = "") + { + bool succeeded = true; + + int index = 0; + for (var i = 0; i < Op1ElementCount; i++, index+=2) + { + if ({ValidateEntry}) + { + succeeded = false; + break; + } + } + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{nameof(Sve)}.{nameof(Sve.{Method})}<{Op1BaseType}>({Op1VectorType}<{Op1BaseType}>, {Op1BaseType}*, ({Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>)): {method} failed:"); + TestLibrary.TestFramework.LogInformation($" first: ({string.Join(", ", first)})"); + TestLibrary.TestFramework.LogInformation($" second: ({string.Join(", ", second)})"); + TestLibrary.TestFramework.LogInformation($" mask: ({string.Join(", ", maskArray)})"); + TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + Succeeded = false; + } + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTestx3.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTestx3.template new file mode 100644 index 00000000000000..cac8a3a542c29d --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTestx3.template @@ -0,0 +1,390 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\Arm\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Numerics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.Arm; +using Xunit; + +namespace JIT.HardwareIntrinsics.Arm +{ + public static partial class Program + { + [Fact] + public static void {TestName}() + { + var test = new Storex3Test__{TestName}(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sve.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class Storex3Test__{TestName} + { + private struct DataTable + { + private byte[] inArray1; + private byte[] inArray2; + private byte[] inArray3; + private byte[] outArray; + private byte[] maskArray; + + private GCHandle inHandle1; + private GCHandle inHandle2; + private GCHandle inHandle3; + private GCHandle outHandle; + private GCHandle maskHandle; + + private ulong alignment; + + public DataTable({Op1BaseType}[] inArray1, {Op1BaseType}[] inArray2, {Op1BaseType}[] inArray3, {RetBaseType}[] outArray, {Op1BaseType}[] maskArray, int alignment) + { + int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); + int sizeOfmaskArray = maskArray.Length * Unsafe.SizeOf<{Op1BaseType}>(); + + if ((alignment != 64 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 6) < sizeOfoutArray || (alignment * 2) < sizeOfmaskArray) + { + throw new ArgumentException("Invalid value of alignment"); + } + + this.inArray1 = new byte[alignment * 2]; + this.inArray2 = new byte[alignment * 2]; + this.inArray3 = new byte[alignment * 2]; + this.outArray = new byte[alignment * 6]; + this.maskArray = new byte[alignment * 2]; + + this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); + this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); + this.inHandle3 = GCHandle.Alloc(this.inArray3, GCHandleType.Pinned); + this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); + this.maskHandle = GCHandle.Alloc(this.maskArray, GCHandleType.Pinned); + + this.alignment = (ulong)alignment; + + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray1Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), (uint)sizeOfinArray1); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray2Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray2[0]), (uint)sizeOfinArray2); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray3Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray3[0]), (uint)sizeOfinArray3); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(maskArrayPtr), ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), (uint)sizeOfmaskArray); + } + + public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); + public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); + public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment); + public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); + public void* maskArrayPtr => Align((byte*)(maskHandle.AddrOfPinnedObject().ToPointer()), alignment); + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + inHandle3.Free(); + outHandle.Free(); + maskHandle.Free(); + } + + public static unsafe void* Align(byte* buffer, ulong expectedAlignment) + { + return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); + } + } + + + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op1VectorType}<{Op1BaseType}> _fld2; + public {Op1VectorType}<{Op1BaseType}> _fld3; + public {Op1VectorType}<{Op1BaseType}> _storeMask; + private GCHandle _outHandle; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var rnd = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op1BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld3), ref Unsafe.As<{Op1BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < MaskElementCount; i++) { _maskData[i] = ({Op1BaseType})1; } + for (var i = 0; i < MaskElementCount / 2; i++) { _maskData[rnd.Next(MaskElementCount)] = ({Op1BaseType})0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._storeMask), ref Unsafe.As<{Op1BaseType}, byte>(ref _maskData[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + ulong alignment = (ulong)LargestVectorSize; + byte[] _outArray = new byte[alignment * 6]; + testStruct._outHandle = GCHandle.Alloc(_outArray, GCHandleType.Pinned); + + return testStruct; + } + + public void* _outArrayPtr => DataTable.Align((byte*)(_outHandle.AddrOfPinnedObject().ToPointer()), (ulong)LargestVectorSize); + + public void Dispose() + { + _outHandle.Free(); + } + + public void RunStructFldScenario(Storex3Test__{TestName} testClass) + { + Sve.{Method}(_storeMask, ({Op1BaseType}*)_outArrayPtr, (_fld1, _fld2, _fld3)); + + testClass.ValidateResult(_fld1, _fld2, _fld3, _outArrayPtr, _storeMask); + } + } + + private static readonly int LargestVectorSize = {LargestVectorSize}; + + private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int Op2ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int Op3ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}) * 3; + private static readonly int MaskElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + + private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; + private static {Op1BaseType}[] _data2 = new {Op1BaseType}[Op2ElementCount]; + private static {Op1BaseType}[] _data3 = new {Op1BaseType}[Op3ElementCount]; + private static {Op1BaseType}[] _maskData = new {Op1BaseType}[MaskElementCount]; + + private DataTable _dataTable; + + public Storex3Test__{TestName}() + { + Succeeded = true; + var rnd = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp1}; } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp1}; } + for (var i = 0; i < MaskElementCount; i++) { _maskData[i] = ({Op1BaseType})1; } + for (var i = 0; i < MaskElementCount / 2; i++) { _maskData[rnd.Next(MaskElementCount)] = ({Op1BaseType})0; } + + _dataTable = new DataTable(_data1, _data2, _data3, new {RetBaseType}[RetElementCount], _maskData, LargestVectorSize); + } + + public bool IsSupported => Sve.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); + + Sve.{Method}(Unsafe.Read>(_dataTable.maskArrayPtr), ({Op1BaseType} *)_dataTable.outArrayPtr, + (Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray3Ptr)) + ); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunBasicScenario_Load() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); + {Op1VectorType}<{Op1BaseType}> loadMask = Sve.CreateTrueMask{Op1BaseType}(SveMaskPattern.All); + + Sve.{Method}(Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.maskArrayPtr)), ({Op1BaseType} *)_dataTable.outArrayPtr, + (Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray1Ptr)), + Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray2Ptr)), + Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray3Ptr))) + ); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); + + typeof(Sve).GetMethod(nameof(Sve.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op1BaseType} *), typeof(({Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>)) }) + .Invoke(null, new object[] { Unsafe.Read>(_dataTable.maskArrayPtr), + Pointer.Box(_dataTable.outArrayPtr, typeof({Op1BaseType}*)), + (Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray3Ptr)) + }); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); + + {Op1VectorType}<{Op1BaseType}> op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + {Op1VectorType}<{Op1BaseType}> op2 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr); + {Op1VectorType}<{Op1BaseType}> op3 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray3Ptr); + {Op1VectorType}<{Op1BaseType}> storeMask = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.maskArrayPtr); + + Sve.{Method}(storeMask, ({Op1BaseType} *)_dataTable.outArrayPtr, (op1, op2, op3)); + + ValidateResult(op1, op2, op3, _dataTable.outArrayPtr, storeMask); + } + + public void RunClassFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); + + {Op1VectorType}<{Op1BaseType}> op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + {Op1VectorType}<{Op1BaseType}> op2 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr); + {Op1VectorType}<{Op1BaseType}> op3 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray3Ptr); + {Op1VectorType}<{Op1BaseType}> storeMask = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.maskArrayPtr); + + Sve.{Method}(storeMask, ({Op1BaseType} *)_dataTable.outArrayPtr, (op1, op2, op3)); + + ValidateResult(op1, op2, op3, _dataTable.outArrayPtr, storeMask); + } + + public void RunStructLclFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); + + var test = TestStruct.Create(); + Sve.{Method}(test._storeMask, ({Op1BaseType} *)test._outArrayPtr, (test._fld1, test._fld2, test._fld3)); + + ValidateResult(test._fld1, test._fld2, test._fld3, test._outArrayPtr, test._storeMask); + } + + public void RunStructFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); + + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); + + bool succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + succeeded = true; + } + + if (!succeeded) + { + Succeeded = false; + } + } + + private void ValidateResult({Op1VectorType}<{Op1BaseType}> op1, {Op1VectorType}<{Op1BaseType}> op2, {Op1VectorType}<{Op1BaseType}> op3, void* result, {Op1VectorType}<{Op1BaseType}> storeMask, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] inArray2 = new {Op1BaseType}[Op2ElementCount]; + {Op1BaseType}[] inArray3 = new {Op1BaseType}[Op3ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + {Op1BaseType}[] maskArray = new {Op1BaseType}[MaskElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), op1); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray2[0]), op2); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray3[0]), op3); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), storeMask); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() * 3); + + ValidateResult(inArray1, inArray2, inArray3, outArray, maskArray, method); + } + + private void ValidateResult(void* op1, void* op2, void* op3, void* result, void* mask, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] inArray2 = new {Op1BaseType}[Op2ElementCount]; + {Op1BaseType}[] inArray3 = new {Op1BaseType}[Op3ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + {Op1BaseType}[] maskArray = new {Op1BaseType}[MaskElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), ref Unsafe.AsRef(op1), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray2[0]), ref Unsafe.AsRef(op2), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray3[0]), ref Unsafe.AsRef(op3), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() * 3); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), ref Unsafe.AsRef(mask), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + ValidateResult(inArray1, inArray2, inArray3, outArray, maskArray, method); + } + + private void ValidateResult({Op1BaseType}[] first, {Op1BaseType}[] second, {Op1BaseType}[] third, {RetBaseType}[] result, {Op1BaseType}[] maskArray, [CallerMemberName] string method = "") + { + bool succeeded = true; + + int index = 0; + for (var i = 0; i < Op1ElementCount; i++, index+=3) + { + if ({ValidateEntry}) + { + succeeded = false; + break; + } + } + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{nameof(Sve)}.{nameof(Sve.{Method})}<{Op1BaseType}>({Op1VectorType}<{Op1BaseType}>, {Op1BaseType}*, ({Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>)): {method} failed:"); + TestLibrary.TestFramework.LogInformation($" first: ({string.Join(", ", first)})"); + TestLibrary.TestFramework.LogInformation($" second: ({string.Join(", ", second)})"); + TestLibrary.TestFramework.LogInformation($" third: ({string.Join(", ", third)})"); + TestLibrary.TestFramework.LogInformation($" mask: ({string.Join(", ", maskArray)})"); + TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + Succeeded = false; + } + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTestx4.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTestx4.template new file mode 100644 index 00000000000000..81b13f0a5e3ab5 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveStoreAndZipTestx4.template @@ -0,0 +1,414 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\Arm\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Numerics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.Arm; +using Xunit; + +namespace JIT.HardwareIntrinsics.Arm +{ + public static partial class Program + { + [Fact] + public static void {TestName}() + { + var test = new Storex4Test__{TestName}(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sve.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class Storex4Test__{TestName} + { + private struct DataTable + { + private byte[] inArray1; + private byte[] inArray2; + private byte[] inArray3; + private byte[] inArray4; + private byte[] outArray; + private byte[] maskArray; + + private GCHandle inHandle1; + private GCHandle inHandle2; + private GCHandle inHandle3; + private GCHandle inHandle4; + private GCHandle outHandle; + private GCHandle maskHandle; + + private ulong alignment; + + public DataTable({Op1BaseType}[] inArray1, {Op1BaseType}[] inArray2, {Op1BaseType}[] inArray3, {Op1BaseType}[] inArray4, {RetBaseType}[] outArray, {Op1BaseType}[] maskArray, int alignment) + { + int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfinArray4 = inArray4.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); + int sizeOfmaskArray = maskArray.Length * Unsafe.SizeOf<{Op1BaseType}>(); + + if ((alignment != 64 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfinArray4 || (alignment * 8) < sizeOfoutArray || (alignment * 2) < sizeOfmaskArray) + { + throw new ArgumentException("Invalid value of alignment"); + } + + this.inArray1 = new byte[alignment * 2]; + this.inArray2 = new byte[alignment * 2]; + this.inArray3 = new byte[alignment * 2]; + this.inArray4 = new byte[alignment * 2]; + this.outArray = new byte[alignment * 8]; + this.maskArray = new byte[alignment * 2]; + + this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); + this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); + this.inHandle3 = GCHandle.Alloc(this.inArray3, GCHandleType.Pinned); + this.inHandle4 = GCHandle.Alloc(this.inArray4, GCHandleType.Pinned); + this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); + this.maskHandle = GCHandle.Alloc(this.maskArray, GCHandleType.Pinned); + + this.alignment = (ulong)alignment; + + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray1Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), (uint)sizeOfinArray1); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray2Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray2[0]), (uint)sizeOfinArray2); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray3Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray3[0]), (uint)sizeOfinArray3); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray4Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray4[0]), (uint)sizeOfinArray4); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(maskArrayPtr), ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), (uint)sizeOfmaskArray); + } + + public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); + public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); + public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment); + public void* inArray4Ptr => Align((byte*)(inHandle4.AddrOfPinnedObject().ToPointer()), alignment); + public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); + public void* maskArrayPtr => Align((byte*)(maskHandle.AddrOfPinnedObject().ToPointer()), alignment); + + public void Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + inHandle3.Free(); + inHandle4.Free(); + outHandle.Free(); + maskHandle.Free(); + } + + public static unsafe void* Align(byte* buffer, ulong expectedAlignment) + { + return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); + } + } + + + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op1VectorType}<{Op1BaseType}> _fld2; + public {Op1VectorType}<{Op1BaseType}> _fld3; + public {Op1VectorType}<{Op1BaseType}> _fld4; + public {Op1VectorType}<{Op1BaseType}> _storeMask; + private GCHandle _outHandle; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var rnd = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op1BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld3), ref Unsafe.As<{Op1BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op4ElementCount; i++) { _data4[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld4), ref Unsafe.As<{Op1BaseType}, byte>(ref _data4[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < MaskElementCount; i++) { _maskData[i] = ({Op1BaseType})1; } + for (var i = 0; i < MaskElementCount / 2; i++) { _maskData[rnd.Next(MaskElementCount)] = ({Op1BaseType})0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._storeMask), ref Unsafe.As<{Op1BaseType}, byte>(ref _maskData[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + ulong alignment = (ulong)LargestVectorSize; + byte[] _outArray = new byte[alignment * 8]; + testStruct._outHandle = GCHandle.Alloc(_outArray, GCHandleType.Pinned); + + return testStruct; + } + + public void* _outArrayPtr => DataTable.Align((byte*)(_outHandle.AddrOfPinnedObject().ToPointer()), (ulong)LargestVectorSize); + + public void Dispose() + { + _outHandle.Free(); + } + + public void RunStructFldScenario(Storex4Test__{TestName} testClass) + { + Sve.{Method}(_storeMask, ({Op1BaseType}*)_outArrayPtr, (_fld1, _fld2, _fld3, _fld4)); + + testClass.ValidateResult(_fld1, _fld2, _fld3, _fld4, _outArrayPtr, _storeMask); + } + } + + private static readonly int LargestVectorSize = {LargestVectorSize}; + + private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int Op2ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int Op3ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int Op4ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}) * 4; + private static readonly int MaskElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + + private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; + private static {Op1BaseType}[] _data2 = new {Op1BaseType}[Op2ElementCount]; + private static {Op1BaseType}[] _data3 = new {Op1BaseType}[Op3ElementCount]; + private static {Op1BaseType}[] _data4 = new {Op1BaseType}[Op4ElementCount]; + private static {Op1BaseType}[] _maskData = new {Op1BaseType}[MaskElementCount]; + + private DataTable _dataTable; + + public Storex4Test__{TestName}() + { + Succeeded = true; + var rnd = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp1}; } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp1}; } + for (var i = 0; i < Op4ElementCount; i++) { _data4[i] = {NextValueOp1}; } + for (var i = 0; i < MaskElementCount; i++) { _maskData[i] = ({Op1BaseType})1; } + for (var i = 0; i < MaskElementCount / 2; i++) { _maskData[rnd.Next(MaskElementCount)] = ({Op1BaseType})0; } + + _dataTable = new DataTable(_data1, _data2, _data3, _data4, new {RetBaseType}[RetElementCount], _maskData, LargestVectorSize); + } + + public bool IsSupported => Sve.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); + + Sve.{Method}(Unsafe.Read>(_dataTable.maskArrayPtr), ({Op1BaseType} *)_dataTable.outArrayPtr, + (Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray3Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray4Ptr)) + ); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.inArray4Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunBasicScenario_Load() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); + {Op1VectorType}<{Op1BaseType}> loadMask = Sve.CreateTrueMask{Op1BaseType}(SveMaskPattern.All); + + Sve.{Method}(Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.maskArrayPtr)), ({Op1BaseType} *)_dataTable.outArrayPtr, + (Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray1Ptr)), + Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray2Ptr)), + Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray3Ptr)), + Sve.LoadVector(loadMask, ({Op1BaseType}*)(_dataTable.inArray4Ptr))) + ); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.inArray4Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); + + typeof(Sve).GetMethod(nameof(Sve.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op1BaseType} *), typeof(({Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>)) }) + .Invoke(null, new object[] { Unsafe.Read>(_dataTable.maskArrayPtr), + Pointer.Box(_dataTable.outArrayPtr, typeof({Op1BaseType}*)), + (Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray3Ptr), + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray4Ptr)) + }); + + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.inArray4Ptr, _dataTable.outArrayPtr, _dataTable.maskArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); + + {Op1VectorType}<{Op1BaseType}> op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + {Op1VectorType}<{Op1BaseType}> op2 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr); + {Op1VectorType}<{Op1BaseType}> op3 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray3Ptr); + {Op1VectorType}<{Op1BaseType}> op4 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray4Ptr); + {Op1VectorType}<{Op1BaseType}> storeMask = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.maskArrayPtr); + + Sve.{Method}(storeMask, ({Op1BaseType} *)_dataTable.outArrayPtr, (op1, op2, op3, op4)); + + ValidateResult(op1, op2, op3, op4, _dataTable.outArrayPtr, storeMask); + } + + public void RunClassFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); + + {Op1VectorType}<{Op1BaseType}> op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + {Op1VectorType}<{Op1BaseType}> op2 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr); + {Op1VectorType}<{Op1BaseType}> op3 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray3Ptr); + {Op1VectorType}<{Op1BaseType}> op4 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray4Ptr); + {Op1VectorType}<{Op1BaseType}> storeMask = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.maskArrayPtr); + + Sve.{Method}(storeMask, ({Op1BaseType} *)_dataTable.outArrayPtr, (op1, op2, op3, op4)); + + ValidateResult(op1, op2, op3, op4, _dataTable.outArrayPtr, storeMask); + } + + public void RunStructLclFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); + + var test = TestStruct.Create(); + Sve.{Method}(test._storeMask, ({Op1BaseType} *)test._outArrayPtr, (test._fld1, test._fld2, test._fld3, test._fld4)); + + ValidateResult(test._fld1, test._fld2, test._fld3, test._fld4, test._outArrayPtr, test._storeMask); + } + + public void RunStructFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); + + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); + + bool succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + succeeded = true; + } + + if (!succeeded) + { + Succeeded = false; + } + } + + private void ValidateResult({Op1VectorType}<{Op1BaseType}> op1, {Op1VectorType}<{Op1BaseType}> op2, {Op1VectorType}<{Op1BaseType}> op3, {Op1VectorType}<{Op1BaseType}> op4, void* result, {Op1VectorType}<{Op1BaseType}> storeMask, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] inArray2 = new {Op1BaseType}[Op2ElementCount]; + {Op1BaseType}[] inArray3 = new {Op1BaseType}[Op3ElementCount]; + {Op1BaseType}[] inArray4 = new {Op1BaseType}[Op4ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + {Op1BaseType}[] maskArray = new {Op1BaseType}[MaskElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), op1); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray2[0]), op2); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray3[0]), op3); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray4[0]), op4); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), storeMask); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() * 4); + + ValidateResult(inArray1, inArray2, inArray3, inArray4, outArray, maskArray, method); + } + + private void ValidateResult(void* op1, void* op2, void* op3, void* op4, void* result, void* mask, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] inArray2 = new {Op1BaseType}[Op2ElementCount]; + {Op1BaseType}[] inArray3 = new {Op1BaseType}[Op3ElementCount]; + {Op1BaseType}[] inArray4 = new {Op1BaseType}[Op4ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + {Op1BaseType}[] maskArray = new {Op1BaseType}[MaskElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), ref Unsafe.AsRef(op1), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray2[0]), ref Unsafe.AsRef(op2), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray3[0]), ref Unsafe.AsRef(op3), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray4[0]), ref Unsafe.AsRef(op4), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() * 4); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref maskArray[0]), ref Unsafe.AsRef(mask), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + ValidateResult(inArray1, inArray2, inArray3, inArray4, outArray, maskArray, method); + } + + private void ValidateResult({Op1BaseType}[] first, {Op1BaseType}[] second, {Op1BaseType}[] third, {Op1BaseType}[] fourth, {RetBaseType}[] result, {Op1BaseType}[] maskArray, [CallerMemberName] string method = "") + { + bool succeeded = true; + + int index = 0; + for (var i = 0; i < Op1ElementCount; i++, index+=4) + { + if ({ValidateEntry}) + { + succeeded = false; + break; + } + } + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{nameof(Sve)}.{nameof(Sve.{Method})}<{Op1BaseType}>({Op1VectorType}<{Op1BaseType}>, {Op1BaseType}*, ({Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>)): {method} failed:"); + TestLibrary.TestFramework.LogInformation($" first: ({string.Join(", ", first)})"); + TestLibrary.TestFramework.LogInformation($" second: ({string.Join(", ", second)})"); + TestLibrary.TestFramework.LogInformation($" third: ({string.Join(", ", third)})"); + TestLibrary.TestFramework.LogInformation($" fourth: ({string.Join(", ", fourth)})"); + TestLibrary.TestFramework.LogInformation($" mask: ({string.Join(", ", maskArray)})"); + TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + Succeeded = false; + } + } + } +}