From 0d437e362fe3db00e76ea871f816fe5fff8f6eaa Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Mon, 11 Mar 2024 16:23:54 +0000 Subject: [PATCH 01/47] JIT ARM64-SVE: Add Sve.Abs() and Sve.Add() Change-Id: Ie8cfe828595da9a87adbc0857c0c44c0ce12f5b2 --- src/coreclr/jit/compiler.h | 1 + src/coreclr/jit/hwintrinsic.cpp | 70 +++- src/coreclr/jit/hwintrinsic.h | 11 +- src/coreclr/jit/hwintrinsicarm64.cpp | 17 +- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 81 +++-- src/coreclr/jit/hwintrinsiclistarm64sve.h | 4 + .../Arm/Sve.PlatformNotSupported.cs | 119 +++++++ .../src/System/Runtime/Intrinsics/Arm/Sve.cs | 118 +++++++ .../ref/System.Runtime.Intrinsics.cs | 17 + .../GenerateHWIntrinsicTests_Arm.cs | 66 ++-- .../Shared/_SveBinaryOpTestTemplate.template | 328 ++++++++++++++++++ .../Shared/_SveUnaryOpTestTemplate.template | 302 ++++++++++++++++ 12 files changed, 1070 insertions(+), 64 deletions(-) create mode 100644 src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template create mode 100644 src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 2937d477a31b13..2d98a2210ae513 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -3467,6 +3467,7 @@ class Compiler #if defined(TARGET_ARM64) GenTree* gtNewSimdConvertVectorToMaskNode(var_types type, GenTree* node, CorInfoType simdBaseJitType, unsigned simdSize); GenTree* gtNewSimdConvertMaskToVectorNode(GenTreeHWIntrinsic* node, var_types type); + GenTree* gtNewSimdEmbeddedMaskNode(CorInfoType simdBaseJitType, unsigned simdSize); #endif //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index e8b60b07909d95..8ad4004fc5650f 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1396,6 +1396,60 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, GenTree* op3 = nullptr; GenTree* op4 = nullptr; + switch (numArgs) + { + case 4: + op4 = getArgForHWIntrinsic(sigReader.GetOp4Type(), sigReader.op4ClsHnd); + op4 = addRangeCheckIfNeeded(intrinsic, op4, mustExpand, immLowerBound, immUpperBound); + op3 = getArgForHWIntrinsic(sigReader.GetOp3Type(), sigReader.op3ClsHnd); + op2 = getArgForHWIntrinsic(sigReader.GetOp2Type(), sigReader.op2ClsHnd); + op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); + break; + + case 3: + op3 = getArgForHWIntrinsic(sigReader.GetOp3Type(), sigReader.op3ClsHnd); + op2 = getArgForHWIntrinsic(sigReader.GetOp2Type(), sigReader.op2ClsHnd); + op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); + break; + + case 2: + op2 = getArgForHWIntrinsic(sigReader.GetOp2Type(), sigReader.op2ClsHnd); + op2 = addRangeCheckIfNeeded(intrinsic, op2, mustExpand, immLowerBound, immUpperBound); + op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); + break; + + case 1: + op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); + break; + + default: + break; + } + +#if defined(TARGET_ARM64) + // Embedded masks need inserting as op1. + if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsic)) + { + numArgs++; + assert(numArgs <= 4); + switch (numArgs) + { + case 4: + op4 = op3; + FALLTHROUGH; + case 3: + op3 = op2; + FALLTHROUGH; + case 2: + op2 = op1; + FALLTHROUGH; + default: + break; + } + op1 = gtNewSimdEmbeddedMaskNode(simdBaseJitType, simdSize); + } +#endif + switch (numArgs) { case 0: @@ -1407,8 +1461,6 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, case 1: { - op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); - if ((category == HW_Category_MemoryLoad) && op1->OperIs(GT_CAST)) { // Although the API specifies a pointer, if what we have is a BYREF, that's what @@ -1467,10 +1519,6 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, case 2: { - op2 = getArgForHWIntrinsic(sigReader.GetOp2Type(), sigReader.op2ClsHnd); - op2 = addRangeCheckIfNeeded(intrinsic, op2, mustExpand, immLowerBound, immUpperBound); - op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); - retNode = isScalar ? gtNewScalarHWIntrinsicNode(nodeRetType, op1, op2, intrinsic) : gtNewSimdHWIntrinsicNode(nodeRetType, op1, op2, intrinsic, simdBaseJitType, simdSize); @@ -1524,10 +1572,6 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, case 3: { - op3 = getArgForHWIntrinsic(sigReader.GetOp3Type(), sigReader.op3ClsHnd); - op2 = getArgForHWIntrinsic(sigReader.GetOp2Type(), sigReader.op2ClsHnd); - op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); - #ifdef TARGET_ARM64 if (intrinsic == NI_AdvSimd_LoadAndInsertScalar) { @@ -1569,12 +1613,6 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, case 4: { - op4 = getArgForHWIntrinsic(sigReader.GetOp4Type(), sigReader.op4ClsHnd); - op4 = addRangeCheckIfNeeded(intrinsic, op4, mustExpand, immLowerBound, immUpperBound); - op3 = getArgForHWIntrinsic(sigReader.GetOp3Type(), sigReader.op3ClsHnd); - op2 = getArgForHWIntrinsic(sigReader.GetOp2Type(), sigReader.op2ClsHnd); - op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); - assert(!isScalar); retNode = gtNewSimdHWIntrinsicNode(nodeRetType, op1, op2, op3, op4, intrinsic, simdBaseJitType, simdSize); diff --git a/src/coreclr/jit/hwintrinsic.h b/src/coreclr/jit/hwintrinsic.h index cac041eb83ea6d..2aab0c0a18c787 100644 --- a/src/coreclr/jit/hwintrinsic.h +++ b/src/coreclr/jit/hwintrinsic.h @@ -191,6 +191,9 @@ enum HWIntrinsicFlag : unsigned int // The intrinsic uses a mask in arg1 to select elements present in the result, and must use a low register. HW_Flag_LowMaskedOperation = 0x40000, + // The intrinsic uses a mask in arg1 to select elements present in the result, which is not present in the API call + HW_Flag_EmbeddedMaskedOperation = 0x80000, + #else #error Unsupported platform #endif @@ -872,7 +875,7 @@ struct HWIntrinsicInfo static bool IsMaskedOperation(NamedIntrinsic id) { const HWIntrinsicFlag flags = lookupFlags(id); - return ((flags & HW_Flag_MaskedOperation) != 0) || IsLowMaskedOperation(id); + return ((flags & HW_Flag_MaskedOperation) != 0) || IsLowMaskedOperation(id) || IsEmbeddedMaskedOperation(id); } static bool IsLowMaskedOperation(NamedIntrinsic id) @@ -881,6 +884,12 @@ struct HWIntrinsicInfo return (flags & HW_Flag_LowMaskedOperation) != 0; } + static bool IsEmbeddedMaskedOperation(NamedIntrinsic id) + { + const HWIntrinsicFlag flags = lookupFlags(id); + return (flags & HW_Flag_EmbeddedMaskedOperation) != 0; + } + #endif // TARGET_ARM64 static bool HasSpecialSideEffect(NamedIntrinsic id) diff --git a/src/coreclr/jit/hwintrinsicarm64.cpp b/src/coreclr/jit/hwintrinsicarm64.cpp index 385dfe4bc82bf7..faa123281fdb07 100644 --- a/src/coreclr/jit/hwintrinsicarm64.cpp +++ b/src/coreclr/jit/hwintrinsicarm64.cpp @@ -2222,7 +2222,7 @@ GenTree* Compiler::gtNewSimdConvertVectorToMaskNode(var_types type, assert(varTypeIsSIMD(node)); // ConvertVectorToMask uses cmpne which requires an embedded mask. - GenTree* embeddedMask = gtNewSimdHWIntrinsicNode(TYP_MASK, NI_Sve_CreateTrueMaskAll, simdBaseJitType, simdSize); + GenTree* embeddedMask = gtNewSimdEmbeddedMaskNode(simdBaseJitType, simdSize); return gtNewSimdHWIntrinsicNode(TYP_MASK, embeddedMask, node, NI_Sve_ConvertVectorToMask, simdBaseJitType, simdSize); } @@ -2246,4 +2246,19 @@ GenTree* Compiler::gtNewSimdConvertMaskToVectorNode(GenTreeHWIntrinsic* node, va node->GetSimdSize()); } +//------------------------------------------------------------------------ +// gtNewSimdEmbeddedMaskNode: Create an embedded mask +// +// Arguments: +// simdBaseJitType -- the base jit type of the nodes being masked +// simdSize -- the simd size of the nodes being masked +// +// Return Value: +// The mask +// +GenTree* Compiler::gtNewSimdEmbeddedMaskNode(CorInfoType simdBaseJitType, unsigned simdSize) +{ + return gtNewSimdHWIntrinsicNode(TYP_MASK, NI_Sve_CreateTrueMaskAll, simdBaseJitType, simdSize); +} + #endif // FEATURE_HW_INTRINSICS diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 6418b72a8f3075..7822529354a2d3 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -398,6 +398,64 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) unreached(); } } + else if (isRMW) + { + assert(!hasImmediateOperand); + assert(!HWIntrinsicInfo::SupportsContainment(intrin.id)); + + // Move the RMW register out of the way and do not pass it to the emit. + + if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrin.id)) + { + // op1Reg contains a mask, op2Reg contains the RMW register. + + if (targetReg != op2Reg) + { + assert(targetReg != op3Reg); + GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op2Reg, /* canSkip */ true); + } + + switch (intrin.numOperands) + { + case 2: + GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op1Reg, opt); + break; + + case 3: + assert(targetReg != op3Reg); + GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op3Reg, opt); + break; + + default: + unreached(); + } + } + else + { + // op1Reg contains the RMW register. + + if (targetReg != op1Reg) + { + assert(targetReg != op2Reg); + assert(targetReg != op3Reg); + GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); + } + + switch (intrin.numOperands) + { + case 2: + GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op2Reg, opt); + break; + + case 3: + GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); + break; + + default: + unreached(); + } + } + } else { assert(!hasImmediateOperand); @@ -416,35 +474,12 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) { GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op1Reg, opt); } - else if (isRMW) - { - if (targetReg != op1Reg) - { - assert(targetReg != op2Reg); - - GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, - /* canSkip */ true); - } - GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op2Reg, opt); - } else { GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, opt); } break; - case 3: - assert(isRMW); - if (targetReg != op1Reg) - { - assert(targetReg != op2Reg); - assert(targetReg != op3Reg); - - GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); - } - GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); - break; - default: unreached(); } diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index ac110c2a0e1b5b..7281cb7bb36d0d 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -17,6 +17,10 @@ // SVE Intrinsics // Sve +HARDWARE_INTRINSIC(Sve, Abs, -1, -1, false, {INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_fabs, INS_sve_fabs}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation) + +HARDWARE_INTRINSIC(Sve, Add, -1, -1, false, {INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_fadd, INS_sve_fadd}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation) + HARDWARE_INTRINSIC(Sve, CreateTrueMaskByte, -1, 1, false, {INS_invalid, INS_sve_ptrue, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) HARDWARE_INTRINSIC(Sve, CreateTrueMaskDouble, -1, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_ptrue}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) HARDWARE_INTRINSIC(Sve, CreateTrueMaskInt16, -1, 1, false, {INS_invalid, INS_invalid, INS_sve_ptrue, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) 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 fbd5ee65ca748f..cc6ca7131b5414 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 @@ -31,6 +31,125 @@ internal Arm64() { } public static new bool IsSupported { [Intrinsic] get { return false; } } } + + /// Abs : Absolute value + + /// + /// svint8_t svabs[_s8]_m(svint8_t inactive, svbool_t pg, svint8_t op) + /// svint8_t svabs[_s8]_x(svbool_t pg, svint8_t op) + /// svint8_t svabs[_s8]_z(svbool_t pg, svint8_t op) + /// + public static unsafe Vector Abs(Vector value) { throw new PlatformNotSupportedException(); } + + /// + /// svint16_t svabs[_s16]_m(svint16_t inactive, svbool_t pg, svint16_t op) + /// svint16_t svabs[_s16]_x(svbool_t pg, svint16_t op) + /// svint16_t svabs[_s16]_z(svbool_t pg, svint16_t op) + /// + public static unsafe Vector Abs(Vector value) { throw new PlatformNotSupportedException(); } + + /// + /// svint32_t svabs[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op) + /// svint32_t svabs[_s32]_x(svbool_t pg, svint32_t op) + /// svint32_t svabs[_s32]_z(svbool_t pg, svint32_t op) + /// + public static unsafe Vector Abs(Vector value) { throw new PlatformNotSupportedException(); } + + /// + /// svint64_t svabs[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op) + /// svint64_t svabs[_s64]_x(svbool_t pg, svint64_t op) + /// svint64_t svabs[_s64]_z(svbool_t pg, svint64_t op) + /// + public static unsafe Vector Abs(Vector value) { throw new PlatformNotSupportedException(); } + + /// + /// svfloat32_t svabs[_f32]_m(svfloat32_t inactive, svbool_t pg, svfloat32_t op) + /// svfloat32_t svabs[_f32]_x(svbool_t pg, svfloat32_t op) + /// svfloat32_t svabs[_f32]_z(svbool_t pg, svfloat32_t op) + /// + public static unsafe Vector Abs(Vector value) { throw new PlatformNotSupportedException(); } + + /// + /// svfloat64_t svabs[_f64]_m(svfloat64_t inactive, svbool_t pg, svfloat64_t op) + /// svfloat64_t svabs[_f64]_x(svbool_t pg, svfloat64_t op) + /// svfloat64_t svabs[_f64]_z(svbool_t pg, svfloat64_t op) + /// + public static unsafe Vector Abs(Vector value) { throw new PlatformNotSupportedException(); } + + + /// Add : Add + + /// + /// svint8_t svadd[_s8]_m(svbool_t pg, svint8_t op1, svint8_t op2) + /// svint8_t svadd[_s8]_x(svbool_t pg, svint8_t op1, svint8_t op2) + /// svint8_t svadd[_s8]_z(svbool_t pg, svint8_t op1, svint8_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svint16_t svadd[_s16]_m(svbool_t pg, svint16_t op1, svint16_t op2) + /// svint16_t svadd[_s16]_x(svbool_t pg, svint16_t op1, svint16_t op2) + /// svint16_t svadd[_s16]_z(svbool_t pg, svint16_t op1, svint16_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svint32_t svadd[_s32]_m(svbool_t pg, svint32_t op1, svint32_t op2) + /// svint32_t svadd[_s32]_x(svbool_t pg, svint32_t op1, svint32_t op2) + /// svint32_t svadd[_s32]_z(svbool_t pg, svint32_t op1, svint32_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svint64_t svadd[_s64]_m(svbool_t pg, svint64_t op1, svint64_t op2) + /// svint64_t svadd[_s64]_x(svbool_t pg, svint64_t op1, svint64_t op2) + /// svint64_t svadd[_s64]_z(svbool_t pg, svint64_t op1, svint64_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svuint8_t svadd[_u8]_m(svbool_t pg, svuint8_t op1, svuint8_t op2) + /// svuint8_t svadd[_u8]_x(svbool_t pg, svuint8_t op1, svuint8_t op2) + /// svuint8_t svadd[_u8]_z(svbool_t pg, svuint8_t op1, svuint8_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svuint16_t svadd[_u16]_m(svbool_t pg, svuint16_t op1, svuint16_t op2) + /// svuint16_t svadd[_u16]_x(svbool_t pg, svuint16_t op1, svuint16_t op2) + /// svuint16_t svadd[_u16]_z(svbool_t pg, svuint16_t op1, svuint16_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svuint32_t svadd[_u32]_m(svbool_t pg, svuint32_t op1, svuint32_t op2) + /// svuint32_t svadd[_u32]_x(svbool_t pg, svuint32_t op1, svuint32_t op2) + /// svuint32_t svadd[_u32]_z(svbool_t pg, svuint32_t op1, svuint32_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svuint64_t svadd[_u64]_m(svbool_t pg, svuint64_t op1, svuint64_t op2) + /// svuint64_t svadd[_u64]_x(svbool_t pg, svuint64_t op1, svuint64_t op2) + /// svuint64_t svadd[_u64]_z(svbool_t pg, svuint64_t op1, svuint64_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svfloat32_t svadd[_f32]_m(svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// svfloat32_t svadd[_f32]_x(svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// svfloat32_t svadd[_f32]_z(svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svfloat64_t svadd[_f64]_m(svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// svfloat64_t svadd[_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// svfloat64_t svadd[_f64]_z(svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// CreateTrueMaskByte : Set predicate elements to true /// 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 6ba2a2c67bc8a7..9c310a53324f76 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 @@ -29,6 +29,124 @@ internal Arm64() { } } + /// Abs : Absolute value + + /// + /// svint8_t svabs[_s8]_m(svint8_t inactive, svbool_t pg, svint8_t op) + /// svint8_t svabs[_s8]_x(svbool_t pg, svint8_t op) + /// svint8_t svabs[_s8]_z(svbool_t pg, svint8_t op) + /// + public static unsafe Vector Abs(Vector value) => Abs(value); + + /// + /// svint16_t svabs[_s16]_m(svint16_t inactive, svbool_t pg, svint16_t op) + /// svint16_t svabs[_s16]_x(svbool_t pg, svint16_t op) + /// svint16_t svabs[_s16]_z(svbool_t pg, svint16_t op) + /// + public static unsafe Vector Abs(Vector value) => Abs(value); + + /// + /// svint32_t svabs[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op) + /// svint32_t svabs[_s32]_x(svbool_t pg, svint32_t op) + /// svint32_t svabs[_s32]_z(svbool_t pg, svint32_t op) + /// + public static unsafe Vector Abs(Vector value) => Abs(value); + + /// + /// svint64_t svabs[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op) + /// svint64_t svabs[_s64]_x(svbool_t pg, svint64_t op) + /// svint64_t svabs[_s64]_z(svbool_t pg, svint64_t op) + /// + public static unsafe Vector Abs(Vector value) => Abs(value); + + /// + /// svfloat32_t svabs[_f32]_m(svfloat32_t inactive, svbool_t pg, svfloat32_t op) + /// svfloat32_t svabs[_f32]_x(svbool_t pg, svfloat32_t op) + /// svfloat32_t svabs[_f32]_z(svbool_t pg, svfloat32_t op) + /// + public static unsafe Vector Abs(Vector value) => Abs(value); + + /// + /// svfloat64_t svabs[_f64]_m(svfloat64_t inactive, svbool_t pg, svfloat64_t op) + /// svfloat64_t svabs[_f64]_x(svbool_t pg, svfloat64_t op) + /// svfloat64_t svabs[_f64]_z(svbool_t pg, svfloat64_t op) + /// + public static unsafe Vector Abs(Vector value) => Abs(value); + + + /// Add : Add + + /// + /// svint8_t svadd[_s8]_m(svbool_t pg, svint8_t op1, svint8_t op2) + /// svint8_t svadd[_s8]_x(svbool_t pg, svint8_t op1, svint8_t op2) + /// svint8_t svadd[_s8]_z(svbool_t pg, svint8_t op1, svint8_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// + /// svint16_t svadd[_s16]_m(svbool_t pg, svint16_t op1, svint16_t op2) + /// svint16_t svadd[_s16]_x(svbool_t pg, svint16_t op1, svint16_t op2) + /// svint16_t svadd[_s16]_z(svbool_t pg, svint16_t op1, svint16_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// + /// svint32_t svadd[_s32]_m(svbool_t pg, svint32_t op1, svint32_t op2) + /// svint32_t svadd[_s32]_x(svbool_t pg, svint32_t op1, svint32_t op2) + /// svint32_t svadd[_s32]_z(svbool_t pg, svint32_t op1, svint32_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// + /// svint64_t svadd[_s64]_m(svbool_t pg, svint64_t op1, svint64_t op2) + /// svint64_t svadd[_s64]_x(svbool_t pg, svint64_t op1, svint64_t op2) + /// svint64_t svadd[_s64]_z(svbool_t pg, svint64_t op1, svint64_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// + /// svuint8_t svadd[_u8]_m(svbool_t pg, svuint8_t op1, svuint8_t op2) + /// svuint8_t svadd[_u8]_x(svbool_t pg, svuint8_t op1, svuint8_t op2) + /// svuint8_t svadd[_u8]_z(svbool_t pg, svuint8_t op1, svuint8_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// + /// svuint16_t svadd[_u16]_m(svbool_t pg, svuint16_t op1, svuint16_t op2) + /// svuint16_t svadd[_u16]_x(svbool_t pg, svuint16_t op1, svuint16_t op2) + /// svuint16_t svadd[_u16]_z(svbool_t pg, svuint16_t op1, svuint16_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// + /// svuint32_t svadd[_u32]_m(svbool_t pg, svuint32_t op1, svuint32_t op2) + /// svuint32_t svadd[_u32]_x(svbool_t pg, svuint32_t op1, svuint32_t op2) + /// svuint32_t svadd[_u32]_z(svbool_t pg, svuint32_t op1, svuint32_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// + /// svuint64_t svadd[_u64]_m(svbool_t pg, svuint64_t op1, svuint64_t op2) + /// svuint64_t svadd[_u64]_x(svbool_t pg, svuint64_t op1, svuint64_t op2) + /// svuint64_t svadd[_u64]_z(svbool_t pg, svuint64_t op1, svuint64_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// + /// svfloat32_t svadd[_f32]_m(svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// svfloat32_t svadd[_f32]_x(svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// svfloat32_t svadd[_f32]_z(svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// + /// svfloat64_t svadd[_f64]_m(svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// svfloat64_t svadd[_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// svfloat64_t svadd[_f64]_z(svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// + public static unsafe Vector Add(Vector left, Vector right) => Add(left, right); + + /// CreateTrueMaskByte : Set predicate elements to true /// 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 77fe06ddc5c02c..06b5a52eb9e7d2 100644 --- a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs +++ b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs @@ -4138,6 +4138,23 @@ internal Sve() { } internal Arm64() { } public static new bool IsSupported { get { throw null; } } } + public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } + public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } + public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } + public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } + public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } + public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } + + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector CreateTrueMaskByte([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } public static System.Numerics.Vector CreateTrueMaskDouble([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index 5ee032e2842d61..2c7ace892d389d 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -107,7 +107,9 @@ ("_TernaryOpTestTemplate.template", "SimpleTernOpTest.template", new Dictionary { ["TemplateName"] = "Simple", ["TemplateValidationLogic"] = SimpleOpTest_ValidationLogic }), ("_UnaryOpTestTemplate.template", "SecureHashUnOpTest.template", new Dictionary { ["TemplateName"] = "SecureHash", ["TemplateValidationLogic"] = SecureHashOpTest_ValidationLogic }), ("_BinaryOpTestTemplate.template", "SecureHashBinOpTest.template", new Dictionary { ["TemplateName"] = "SecureHash", ["TemplateValidationLogic"] = SecureHashOpTest_ValidationLogic }), - ("_TernaryOpTestTemplate.template", "SecureHashTernOpTest.template", new Dictionary { ["TemplateName"] = "SecureHash", ["TemplateValidationLogic"] = SecureHashOpTest_ValidationLogic }) + ("_TernaryOpTestTemplate.template", "SecureHashTernOpTest.template", new Dictionary { ["TemplateName"] = "SecureHash", ["TemplateValidationLogic"] = SecureHashOpTest_ValidationLogic }), + ("_SveUnaryOpTestTemplate.template", "SveSimpleVecOpTest.template", new Dictionary { ["TemplateName"] = "Simple", ["TemplateValidationLogic"] = SimpleVecOpTest_ValidationLogic }), + ("_SveBinaryOpTestTemplate.template", "SveVecBinOpTest.template", new Dictionary { ["TemplateName"] = "Simple", ["TemplateValidationLogic"] = SimpleVecOpTest_ValidationLogic }), }; (string templateFileName, Dictionary templateData)[] AdvSimdInputs = new [] @@ -2887,16 +2889,34 @@ (string templateFileName, Dictionary templateData)[] SveInputs = new [] { - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_sbyte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_short", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_int", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_long", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_byte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ushort", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_uint", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ulong", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(sbyte)-TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)-TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + // ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + + // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(sbyte)TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(byte)TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_sbyte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_short", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_int", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_long", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_byte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ushort", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_uint", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ulong", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), }; @@ -2905,18 +2925,18 @@ string outputDirectory = args[2]; string testListFileName = args[3]; -ProcessInputs("AdvSimd", AdvSimdInputs); -ProcessInputs("AdvSimd.Arm64", AdvSimd_Arm64Inputs); -ProcessInputs("Aes", AesInputs); -ProcessInputs("ArmBase", ArmBaseInputs); -ProcessInputs("ArmBase.Arm64", ArmBase_Arm64Inputs); -ProcessInputs("Crc32", Crc32Inputs); -ProcessInputs("Crc32.Arm64", Crc32_Arm64Inputs); -ProcessInputs("Dp", DpInputs); -ProcessInputs("Rdm", RdmInputs); -ProcessInputs("Rdm.Arm64", Rdm_Arm64Inputs); -ProcessInputs("Sha1", Sha1Inputs); -ProcessInputs("Sha256", Sha256Inputs); +// ProcessInputs("AdvSimd", AdvSimdInputs); +// ProcessInputs("AdvSimd.Arm64", AdvSimd_Arm64Inputs); +// ProcessInputs("Aes", AesInputs); +// ProcessInputs("ArmBase", ArmBaseInputs); +// ProcessInputs("ArmBase.Arm64", ArmBase_Arm64Inputs); +// ProcessInputs("Crc32", Crc32Inputs); +// ProcessInputs("Crc32.Arm64", Crc32_Arm64Inputs); +// ProcessInputs("Dp", DpInputs); +// ProcessInputs("Rdm", RdmInputs); +// ProcessInputs("Rdm.Arm64", Rdm_Arm64Inputs); +// ProcessInputs("Sha1", Sha1Inputs); +// ProcessInputs("Sha256", Sha256Inputs); ProcessInputs("Sve", SveInputs); void ProcessInputs(string groupName, (string templateFileName, Dictionary templateData)[] inputs) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template new file mode 100644 index 00000000000000..48b124734ef946 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template @@ -0,0 +1,328 @@ +// 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.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 {TemplateName}BinaryOpTest__{TestName}(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if ({LoadIsa}.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 {TemplateName}BinaryOpTest__{TestName} + { + private struct DataTable + { + private byte[] inArray1; + private byte[] inArray2; + private byte[] outArray; + + private GCHandle inHandle1; + private GCHandle inHandle2; + private GCHandle outHandle; + + private ulong alignment; + + public DataTable({Op1BaseType}[] inArray1, {Op2BaseType}[] inArray2, {RetBaseType}[] outArray, int alignment) + { + int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<{Op2BaseType}>(); + int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); + if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) + { + throw new ArgumentException("Invalid value of alignment"); + } + + this.inArray1 = new byte[alignment * 2]; + this.inArray2 = new byte[alignment * 2]; + this.outArray = 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.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<{Op2BaseType}, byte>(ref inArray2[0]), (uint)sizeOfinArray2); + } + + 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 Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + outHandle.Free(); + } + + private static unsafe void* Align(byte* buffer, ulong expectedAlignment) + { + return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); + } + } + + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + + 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] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario({TemplateName}BinaryOpTest__{TestName} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = {LargestVectorSize}; + + private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int Op2ElementCount = Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>() / sizeof({Op2BaseType}); + private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); + + private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; + private static {Op2BaseType}[] _data2 = new {Op2BaseType}[Op2ElementCount]; + + private {Op1VectorType}<{Op1BaseType}> _fld1; + private {Op2VectorType}<{Op2BaseType}> _fld2; + + private DataTable _dataTable; + + public {TemplateName}BinaryOpTest__{TestName}() + { + Succeeded = true; + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref _fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + _dataTable = new DataTable(_data1, _data2, new {RetBaseType}[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => {Isa}.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); + + var result = {Isa}.{Method}( + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op2VectorType}<{Op2BaseType}>>(_dataTable.inArray2Ptr) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); + + {Op1VectorType}<{Op1BaseType}> loadMask = Sve.CreateTrueMask{RetBaseType}(SveMaskPattern.All); + + var result = {Isa}.{Method}( + {LoadIsa}.Load{Op1VectorType}(loadMask, ({Op1BaseType}*)(_dataTable.inArray1Ptr)), + {LoadIsa}.Load{Op2VectorType}(loadMask, ({Op2BaseType}*)(_dataTable.inArray2Ptr)) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); + + var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2VectorType}<{Op2BaseType}>) }) + .Invoke(null, new object[] { + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op2VectorType}<{Op2BaseType}>>(_dataTable.inArray2Ptr) + }); + + Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); + + var op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + var op2 = Unsafe.Read<{Op2VectorType}<{Op2BaseType}>>(_dataTable.inArray2Ptr); + var result = {Isa}.{Method}(op1, op2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(op1, op2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); + + var result = {Isa}.{Method}(_fld1, _fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); + + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + 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, {Op2VectorType}<{Op2BaseType}> op2, void* result, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op2BaseType}[] inArray2 = new {Op2BaseType}[Op2ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), op1); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op2BaseType}, byte>(ref inArray2[0]), op2); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op2BaseType}[] inArray2 = new {Op2BaseType}[Op2ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), ref Unsafe.AsRef(op1), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2BaseType}, byte>(ref inArray2[0]), ref Unsafe.AsRef(op2), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult({Op1BaseType}[] left, {Op2BaseType}[] right, {RetBaseType}[] result, [CallerMemberName] string method = "") + { + bool succeeded = true; + + {TemplateValidationLogic} + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>, {Op2VectorType}<{Op2BaseType}>): {method} failed:"); + TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); + TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); + TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + Succeeded = false; + } + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template new file mode 100644 index 00000000000000..eb3dd48b9dfcf4 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template @@ -0,0 +1,302 @@ +// 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.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 {TemplateName}UnaryOpTest__{TestName}(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if ({LoadIsa}.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 {TemplateName}UnaryOpTest__{TestName} + { + private struct DataTable + { + private byte[] inArray1; + private byte[] outArray; + + private GCHandle inHandle1; + private GCHandle outHandle; + + private ulong alignment; + + public DataTable({Op1BaseType}[] inArray1, {RetBaseType}[] outArray, int alignment) + { + int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); + if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray) + { + throw new ArgumentException("Invalid value of alignment"); + } + + this.inArray1 = new byte[alignment * 2]; + this.outArray = new byte[alignment * 2]; + + this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); + this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); + + this.alignment = (ulong)alignment; + + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray1Ptr), ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), (uint)sizeOfinArray1); + } + + public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); + public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); + + public void Dispose() + { + inHandle1.Free(); + outHandle.Free(); + } + + private static unsafe void* Align(byte* buffer, ulong expectedAlignment) + { + return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); + } + } + + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + + 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}>>()); + + return testStruct; + } + + public void RunStructFldScenario({TemplateName}UnaryOpTest__{TestName} testClass) + { + var result = {Isa}.{Method}(_fld1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr); + } + } + + 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 {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; + + private {Op1VectorType}<{Op1BaseType}> _fld1; + + private DataTable _dataTable; + + public {TemplateName}UnaryOpTest__{TestName}() + { + Succeeded = true; + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + _dataTable = new DataTable(_data1, new {RetBaseType}[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => {Isa}.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); + + var result = {Isa}.{Method}( + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); + + {Op1VectorType}<{Op1BaseType}> loadMask = Sve.CreateTrueMask{RetBaseType}(SveMaskPattern.All); + + var result = {Isa}.{Method}( + {LoadIsa}.Load{Op1VectorType}(loadMask, ({Op1BaseType}*)(_dataTable.inArray1Ptr)) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); + + var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>) }) + .Invoke(null, new object[] { + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr) + }); + + Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); + + var op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + var result = {Isa}.{Method}(op1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(op1, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); + + var result = {Isa}.{Method}(_fld1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); + + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, _dataTable.outArrayPtr); + } + + 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, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), op1); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + + ValidateResult(inArray1, outArray, method); + } + + private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + + 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}>>()); + + ValidateResult(inArray1, outArray, method); + } + + private void ValidateResult({Op1BaseType}[] firstOp, {RetBaseType}[] result, [CallerMemberName] string method = "") + { + bool succeeded = true; + + {TemplateValidationLogic} + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>): {method} failed:"); + TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); + TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + Succeeded = false; + } + } + } +} From e9fa735738e900bed3c92848aa9ca5ac1f84fbde Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Fri, 22 Mar 2024 13:30:12 +0000 Subject: [PATCH 02/47] Fix sve scaling in enitIns_R_S/S_R --- src/coreclr/jit/emitarm64.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index 28faef7419e9db..8b285df7b2c9e9 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -9839,11 +9839,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va scale = NaturalScale_helper(EA_16BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate - if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) - { - imm >>= scale; // The immediate is scaled by the size of the ld/st - } - else + if (((imm & mask) != 0) || (!isValidSimm<9>(imm >> scale))) { useRegForImm = true; regNumber rsvdReg = codeGen->rsGetRsvdReg(); @@ -9867,11 +9863,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va scale = NaturalScale_helper(EA_2BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate - if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) - { - imm >>= scale; // The immediate is scaled by the size of the ld/st - } - else + if (((imm & mask) != 0) || (!isValidSimm<9>(imm >> scale))) { useRegForImm = true; regNumber rsvdReg = codeGen->rsGetRsvdReg(); @@ -10118,11 +10110,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va scale = NaturalScale_helper(EA_16BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate - if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) - { - imm >>= scale; // The immediate is scaled by the size of the ld/st - } - else + if (((imm & mask) != 0) || (!isValidSimm<9>(imm >> scale))) { useRegForImm = true; regNumber rsvdReg = codeGen->rsGetRsvdReg(); @@ -10146,11 +10134,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va scale = NaturalScale_helper(EA_2BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate - if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) - { - imm >>= scale; // The immediate is scaled by the size of the ld/st - } - else + if (((imm & mask) != 0) || (!isValidSimm<9>(imm >> scale))) { useRegForImm = true; regNumber rsvdReg = codeGen->rsGetRsvdReg(); From 5acc1226bb6e17a7215730b2dc88286e176a79f7 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Sat, 23 Mar 2024 13:21:28 +0000 Subject: [PATCH 03/47] Revert "Fix sve scaling in enitIns_R_S/S_R" This reverts commit e9fa735738e900bed3c92848aa9ca5ac1f84fbde. --- src/coreclr/jit/emitarm64.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index 8b285df7b2c9e9..28faef7419e9db 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -9839,7 +9839,11 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va scale = NaturalScale_helper(EA_16BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate - if (((imm & mask) != 0) || (!isValidSimm<9>(imm >> scale))) + if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) + { + imm >>= scale; // The immediate is scaled by the size of the ld/st + } + else { useRegForImm = true; regNumber rsvdReg = codeGen->rsGetRsvdReg(); @@ -9863,7 +9867,11 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va scale = NaturalScale_helper(EA_2BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate - if (((imm & mask) != 0) || (!isValidSimm<9>(imm >> scale))) + if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) + { + imm >>= scale; // The immediate is scaled by the size of the ld/st + } + else { useRegForImm = true; regNumber rsvdReg = codeGen->rsGetRsvdReg(); @@ -10110,7 +10118,11 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va scale = NaturalScale_helper(EA_16BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate - if (((imm & mask) != 0) || (!isValidSimm<9>(imm >> scale))) + if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) + { + imm >>= scale; // The immediate is scaled by the size of the ld/st + } + else { useRegForImm = true; regNumber rsvdReg = codeGen->rsGetRsvdReg(); @@ -10134,7 +10146,11 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va scale = NaturalScale_helper(EA_2BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate - if (((imm & mask) != 0) || (!isValidSimm<9>(imm >> scale))) + if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) + { + imm >>= scale; // The immediate is scaled by the size of the ld/st + } + else { useRegForImm = true; regNumber rsvdReg = codeGen->rsGetRsvdReg(); From 15e893d29155a45726a744be35a8189b7713680f Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Sat, 23 Mar 2024 15:19:23 +0000 Subject: [PATCH 04/47] Fix sve scaling in enitIns_R_S/S_R --- src/coreclr/jit/emitarm64.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index 28faef7419e9db..3f701b9761b122 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -9836,7 +9836,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va fmt = IF_SVE_IE_2A; // TODO-SVE: Don't assume 128bit vectors - scale = NaturalScale_helper(EA_16BYTE); + scale = 4; ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) @@ -9864,7 +9864,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va // TODO-SVE: Don't assume 128bit vectors // Predicate size is vector length / 8 - scale = NaturalScale_helper(EA_2BYTE); + scale = 2; ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) @@ -10115,7 +10115,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va fmt = IF_SVE_JH_2A; // TODO-SVE: Don't assume 128bit vectors - scale = NaturalScale_helper(EA_16BYTE); + scale = 4; ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) @@ -10143,7 +10143,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va // TODO-SVE: Don't assume 128bit vectors // Predicate size is vector length / 8 - scale = NaturalScale_helper(EA_2BYTE); + scale = 2; ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) From c22f45802f07df02951f85d10970651c670cf122 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Sun, 24 Mar 2024 11:27:10 +0000 Subject: [PATCH 05/47] Restore testing --- .../GenerateHWIntrinsicTests_Arm.cs | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index 2c7ace892d389d..74e074923e267b 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -2891,32 +2891,32 @@ { ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(sbyte)-TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)-TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(sbyte)-TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)-TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - // ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(long)Helpers.Abs(firstOp[i]) != (long)result[i]"}), - // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(sbyte)TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(byte)TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - // ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(sbyte)TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(byte)TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_sbyte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_short", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_int", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_long", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_byte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ushort", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_uint", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - // ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ulong", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_sbyte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_short", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_int", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_long", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_byte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ushort", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_uint", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ulong", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), }; @@ -2925,18 +2925,18 @@ string outputDirectory = args[2]; string testListFileName = args[3]; -// ProcessInputs("AdvSimd", AdvSimdInputs); -// ProcessInputs("AdvSimd.Arm64", AdvSimd_Arm64Inputs); -// ProcessInputs("Aes", AesInputs); -// ProcessInputs("ArmBase", ArmBaseInputs); -// ProcessInputs("ArmBase.Arm64", ArmBase_Arm64Inputs); -// ProcessInputs("Crc32", Crc32Inputs); -// ProcessInputs("Crc32.Arm64", Crc32_Arm64Inputs); -// ProcessInputs("Dp", DpInputs); -// ProcessInputs("Rdm", RdmInputs); -// ProcessInputs("Rdm.Arm64", Rdm_Arm64Inputs); -// ProcessInputs("Sha1", Sha1Inputs); -// ProcessInputs("Sha256", Sha256Inputs); +ProcessInputs("AdvSimd", AdvSimdInputs); +ProcessInputs("AdvSimd.Arm64", AdvSimd_Arm64Inputs); +ProcessInputs("Aes", AesInputs); +ProcessInputs("ArmBase", ArmBaseInputs); +ProcessInputs("ArmBase.Arm64", ArmBase_Arm64Inputs); +ProcessInputs("Crc32", Crc32Inputs); +ProcessInputs("Crc32.Arm64", Crc32_Arm64Inputs); +ProcessInputs("Dp", DpInputs); +ProcessInputs("Rdm", RdmInputs); +ProcessInputs("Rdm.Arm64", Rdm_Arm64Inputs); +ProcessInputs("Sha1", Sha1Inputs); +ProcessInputs("Sha256", Sha256Inputs); ProcessInputs("Sve", SveInputs); void ProcessInputs(string groupName, (string templateFileName, Dictionary templateData)[] inputs) From 508a52a23245d1b49bb65882d1a6e43341c16a42 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Mon, 25 Mar 2024 18:10:08 +0000 Subject: [PATCH 06/47] Use NaturalScale_helper for vector load/stores --- src/coreclr/jit/emitarm64.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index 3f701b9761b122..aa20688af344e2 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -9836,7 +9836,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va fmt = IF_SVE_IE_2A; // TODO-SVE: Don't assume 128bit vectors - scale = 4; + scale = NaturalScale_helper(EA_16BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) @@ -10115,7 +10115,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va fmt = IF_SVE_JH_2A; // TODO-SVE: Don't assume 128bit vectors - scale = 4; + scale = NaturalScale_helper(EA_16BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) From d4f3c8629743a6fd3089fd8ba8dc54788f8f946c Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Wed, 3 Apr 2024 14:35:45 -0700 Subject: [PATCH 07/47] wip --- src/coreclr/jit/compiler.h | 2 +- src/coreclr/jit/hwintrinsic.cpp | 47 ++++++++++--------- src/coreclr/jit/hwintrinsicarm64.cpp | 6 +-- src/coreclr/jit/lowerarmarch.cpp | 7 +++ .../src/System/Runtime/Intrinsics/Arm/Sve.cs | 30 ++++++++++++ .../ref/System.Runtime.Intrinsics.cs | 4 -- 6 files changed, 65 insertions(+), 31 deletions(-) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 09d1ced890c0f7..0feb405640d258 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -3470,7 +3470,7 @@ class Compiler #if defined(TARGET_ARM64) GenTree* gtNewSimdConvertVectorToMaskNode(var_types type, GenTree* node, CorInfoType simdBaseJitType, unsigned simdSize); GenTree* gtNewSimdConvertMaskToVectorNode(GenTreeHWIntrinsic* node, var_types type); - GenTree* gtNewSimdEmbeddedMaskNode(CorInfoType simdBaseJitType, unsigned simdSize); + GenTree* gtNewSimdAllTrueMaskNode(CorInfoType simdBaseJitType, unsigned simdSize); #endif //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index 8ad4004fc5650f..e76f25ed69081f 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1407,6 +1407,7 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, break; case 3: + assert(addRangeCheckIfNeeded(intrinsic, op3, mustExpand, immLowerBound, immUpperBound) == op3); op3 = getArgForHWIntrinsic(sigReader.GetOp3Type(), sigReader.op3ClsHnd); op2 = getArgForHWIntrinsic(sigReader.GetOp2Type(), sigReader.op2ClsHnd); op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); @@ -1426,29 +1427,29 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, break; } -#if defined(TARGET_ARM64) - // Embedded masks need inserting as op1. - if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsic)) - { - numArgs++; - assert(numArgs <= 4); - switch (numArgs) - { - case 4: - op4 = op3; - FALLTHROUGH; - case 3: - op3 = op2; - FALLTHROUGH; - case 2: - op2 = op1; - FALLTHROUGH; - default: - break; - } - op1 = gtNewSimdEmbeddedMaskNode(simdBaseJitType, simdSize); - } -#endif +//#if defined(TARGET_ARM64) +// // Embedded masks need inserting as op1. +// if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsic)) +// { +// numArgs++; +// assert(numArgs <= 4); +// switch (numArgs) +// { +// case 4: +// op4 = op3; +// FALLTHROUGH; +// case 3: +// op3 = op2; +// FALLTHROUGH; +// case 2: +// op2 = op1; +// FALLTHROUGH; +// default: +// break; +// } +// op1 = gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); +// } +//#endif switch (numArgs) { diff --git a/src/coreclr/jit/hwintrinsicarm64.cpp b/src/coreclr/jit/hwintrinsicarm64.cpp index faa123281fdb07..33e8e0826e9c91 100644 --- a/src/coreclr/jit/hwintrinsicarm64.cpp +++ b/src/coreclr/jit/hwintrinsicarm64.cpp @@ -2222,8 +2222,8 @@ GenTree* Compiler::gtNewSimdConvertVectorToMaskNode(var_types type, assert(varTypeIsSIMD(node)); // ConvertVectorToMask uses cmpne which requires an embedded mask. - GenTree* embeddedMask = gtNewSimdEmbeddedMaskNode(simdBaseJitType, simdSize); - return gtNewSimdHWIntrinsicNode(TYP_MASK, embeddedMask, node, NI_Sve_ConvertVectorToMask, simdBaseJitType, + GenTree* trueMask = gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); + return gtNewSimdHWIntrinsicNode(TYP_MASK, trueMask, node, NI_Sve_ConvertVectorToMask, simdBaseJitType, simdSize); } @@ -2256,7 +2256,7 @@ GenTree* Compiler::gtNewSimdConvertMaskToVectorNode(GenTreeHWIntrinsic* node, va // Return Value: // The mask // -GenTree* Compiler::gtNewSimdEmbeddedMaskNode(CorInfoType simdBaseJitType, unsigned simdSize) +GenTree* Compiler::gtNewSimdAllTrueMaskNode(CorInfoType simdBaseJitType, unsigned simdSize) { return gtNewSimdHWIntrinsicNode(TYP_MASK, NI_Sve_CreateTrueMaskAll, simdBaseJitType, simdSize); } diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 9d28135c92a1a0..9bed4fb0b15a7f 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1206,6 +1206,13 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) LowerHWIntrinsicFusedMultiplyAddScalar(node); break; + case NI_Sve_Abs: + { + GenTree* op1 = node->Op(1); + + break; + } + default: break; } 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 9c310a53324f76..9c551cc64300e3 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 @@ -33,43 +33,73 @@ internal Arm64() { } /// /// svint8_t svabs[_s8]_m(svint8_t inactive, svbool_t pg, svint8_t op) + /// ABS Ztied.B, Pg/M, Zop.B + /// MOVPRFX Zresult, Zinactive; ABS Zresult.B, Pg/M, Zop.B /// svint8_t svabs[_s8]_x(svbool_t pg, svint8_t op) + /// ABS Ztied.B, Pg/M, Ztied.B + /// MOVPRFX Zresult, Zop; ABS Zresult.B, Pg/M, Zop.B /// svint8_t svabs[_s8]_z(svbool_t pg, svint8_t op) + /// MOVPRFX Zresult.B, Pg/Z, Zop.B; ABS Zresult.B, Pg/M, Zop.B /// public static unsafe Vector Abs(Vector value) => Abs(value); /// /// svint16_t svabs[_s16]_m(svint16_t inactive, svbool_t pg, svint16_t op) + /// ABS Ztied.H, Pg/M, Zop.H + /// MOVPRFX Zresult, Zinactive; ABS Zresult.H, Pg/M, Zop.H /// svint16_t svabs[_s16]_x(svbool_t pg, svint16_t op) + /// ABS Ztied.H, Pg/M, Ztied.H + /// MOVPRFX Zresult, Zop; ABS Zresult.H, Pg/M, Zop.H /// svint16_t svabs[_s16]_z(svbool_t pg, svint16_t op) + /// MOVPRFX Zresult.H, Pg/Z, Zop.H; ABS Zresult.H, Pg/M, Zop.H /// public static unsafe Vector Abs(Vector value) => Abs(value); /// /// svint32_t svabs[_s32]_m(svint32_t inactive, svbool_t pg, svint32_t op) + /// ABS Ztied.S, Pg/M, Zop.S + /// MOVPRFX Zresult, Zinactive; ABS Zresult.S, Pg/M, Zop.S /// svint32_t svabs[_s32]_x(svbool_t pg, svint32_t op) + /// ABS Ztied.S, Pg/M, Ztied.S + /// MOVPRFX Zresult, Zop; ABS Zresult.S, Pg/M, Zop.S /// svint32_t svabs[_s32]_z(svbool_t pg, svint32_t op) + /// MOVPRFX Zresult.S, Pg/Z, Zop.S; ABS Zresult.S, Pg/M, Zop.S /// public static unsafe Vector Abs(Vector value) => Abs(value); /// /// svint64_t svabs[_s64]_m(svint64_t inactive, svbool_t pg, svint64_t op) + /// ABS Ztied.D, Pg/M, Zop.D + /// MOVPRFX Zresult, Zinactive; ABS Zresult.D, Pg/M, Zop.D /// svint64_t svabs[_s64]_x(svbool_t pg, svint64_t op) + /// ABS Ztied.D, Pg/M, Ztied.D + /// MOVPRFX Zresult, Zop; ABS Zresult.D, Pg/M, Zop.D /// svint64_t svabs[_s64]_z(svbool_t pg, svint64_t op) + /// MOVPRFX Zresult.D, Pg/Z, Zop.D; ABS Zresult.D, Pg/M, Zop.D /// public static unsafe Vector Abs(Vector value) => Abs(value); /// /// svfloat32_t svabs[_f32]_m(svfloat32_t inactive, svbool_t pg, svfloat32_t op) + /// FABS Ztied.S, Pg/M, Zop.S + /// MOVPRFX Zresult, Zinactive; FABS Zresult.S, Pg/M, Zop.S /// svfloat32_t svabs[_f32]_x(svbool_t pg, svfloat32_t op) + /// FABS Ztied.S, Pg/M, Ztied.S + /// MOVPRFX Zresult, Zop; FABS Zresult.S, Pg/M, Zop.S /// svfloat32_t svabs[_f32]_z(svbool_t pg, svfloat32_t op) + /// MOVPRFX Zresult.S, Pg/Z, Zop.S; FABS Zresult.S, Pg/M, Zop.S /// public static unsafe Vector Abs(Vector value) => Abs(value); /// /// svfloat64_t svabs[_f64]_m(svfloat64_t inactive, svbool_t pg, svfloat64_t op) + /// FABS Ztied.D, Pg/M, Zop.D + /// MOVPRFX Zresult, Zinactive; FABS Zresult.D, Pg/M, Zop.D /// svfloat64_t svabs[_f64]_x(svbool_t pg, svfloat64_t op) + /// FABS Ztied.D, Pg/M, Ztied.D + /// MOVPRFX Zresult, Zop; FABS Zresult.D, Pg/M, Zop.D /// svfloat64_t svabs[_f64]_z(svbool_t pg, svfloat64_t op) + /// MOVPRFX Zresult.D, Pg/Z, Zop.D; FABS Zresult.D, Pg/M, Zop.D /// public static unsafe Vector Abs(Vector value) => Abs(value); 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 06b5a52eb9e7d2..b5b27243019ef4 100644 --- a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs +++ b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs @@ -4144,7 +4144,6 @@ internal Arm64() { } public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } - public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } @@ -4155,7 +4154,6 @@ internal Arm64() { } public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector Add(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } - public static System.Numerics.Vector CreateTrueMaskByte([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } public static System.Numerics.Vector CreateTrueMaskDouble([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } public static System.Numerics.Vector CreateTrueMaskInt16([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } @@ -4166,7 +4164,6 @@ internal Arm64() { } public static System.Numerics.Vector CreateTrueMaskUInt16([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } public static System.Numerics.Vector CreateTrueMaskUInt32([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } public static System.Numerics.Vector CreateTrueMaskUInt64([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } - public static unsafe System.Numerics.Vector LoadVector(System.Numerics.Vector mask, sbyte* address) { throw null; } public static unsafe System.Numerics.Vector LoadVector(System.Numerics.Vector mask, short* address) { throw null; } public static unsafe System.Numerics.Vector LoadVector(System.Numerics.Vector mask, int* address) { throw null; } @@ -4177,7 +4174,6 @@ internal Arm64() { } public static unsafe System.Numerics.Vector LoadVector(System.Numerics.Vector mask, ulong* address) { throw null; } public static unsafe System.Numerics.Vector LoadVector(System.Numerics.Vector mask, float* address) { throw null; } public static unsafe System.Numerics.Vector LoadVector(System.Numerics.Vector mask, double* address) { throw null; } - } public enum SveMaskPattern : byte From 20defbdb6d53c28cb51e5a15206f6925dbc8f03b Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 4 Apr 2024 01:28:57 -0700 Subject: [PATCH 08/47] Add ConditionalSelect() APIs --- .../Arm/Sve.PlatformNotSupported.cs | 58 +++++++++++++ .../src/System/Runtime/Intrinsics/Arm/Sve.cs | 86 +++++++++++++++++++ .../ref/System.Runtime.Intrinsics.cs | 11 ++- 3 files changed, 154 insertions(+), 1 deletion(-) 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 fbd5ee65ca748f..c40e08cb87e643 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 @@ -120,7 +120,65 @@ internal Arm64() { } /// public static unsafe Vector CreateTrueMaskUInt64([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw new PlatformNotSupportedException(); } + /// ConditionalSelect : Conditionally select elements + /// + /// svint8_t svsel[_s8](svbool_t pg, svint8_t op1, svint8_t op2) + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svint16_t svsel[_s16](svbool_t pg, svint16_t op1, svint16_t op2) + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svint32_t svsel[_s32](svbool_t pg, svint32_t op1, svint32_t op2) + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svint64_t svsel[_s64](svbool_t pg, svint64_t op1, svint64_t op2) + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svuint8_t svsel[_u8](svbool_t pg, svuint8_t op1, svuint8_t op2) + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svuint16_t svsel[_u16](svbool_t pg, svuint16_t op1, svuint16_t op2) + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svuint32_t svsel[_u32](svbool_t pg, svuint32_t op1, svuint32_t op2) + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svuint64_t svsel[_u64](svbool_t pg, svuint64_t op1, svuint64_t op2) + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svfloat32_t svsel[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svfloat64_t svsel[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) { throw new PlatformNotSupportedException(); } /// LoadVector : Unextended load 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 6ba2a2c67bc8a7..5fa7e9b65206ef 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 @@ -118,7 +118,93 @@ internal Arm64() { } /// public static unsafe Vector CreateTrueMaskUInt64([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) => CreateTrueMaskUInt64(pattern); + /// ConditionalSelect : Conditionally select elements + /// + /// svint8_t svsel[_s8](svbool_t pg, svint8_t op1, svint8_t op2) + /// SEL Zresult.B, Pg, Zop1.B, Zop2.B + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// SEL Presult.B, Pg, Pop1.B, Pop2.B + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); + + /// + /// svint16_t svsel[_s16](svbool_t pg, svint16_t op1, svint16_t op2) + /// SEL Zresult.H, Pg, Zop1.H, Zop2.H + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// SEL Presult.B, Pg, Pop1.B, Pop2.B + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); + + /// + /// svint32_t svsel[_s32](svbool_t pg, svint32_t op1, svint32_t op2) + /// SEL Zresult.S, Pg, Zop1.S, Zop2.S + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// SEL Presult.B, Pg, Pop1.B, Pop2.B + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); + + /// + /// svint64_t svsel[_s64](svbool_t pg, svint64_t op1, svint64_t op2) + /// SEL Zresult.D, Pg, Zop1.D, Zop2.D + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// SEL Presult.B, Pg, Pop1.B, Pop2.B + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); + + /// + /// svuint8_t svsel[_u8](svbool_t pg, svuint8_t op1, svuint8_t op2) + /// SEL Zresult.B, Pg, Zop1.B, Zop2.B + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// SEL Presult.B, Pg, Pop1.B, Pop2.B + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); + + /// + /// svuint16_t svsel[_u16](svbool_t pg, svuint16_t op1, svuint16_t op2) + /// SEL Zresult.H, Pg, Zop1.H, Zop2.H + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// SEL Presult.B, Pg, Pop1.B, Pop2.B + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); + + /// + /// svuint32_t svsel[_u32](svbool_t pg, svuint32_t op1, svuint32_t op2) + /// SEL Zresult.S, Pg, Zop1.S, Zop2.S + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// SEL Presult.B, Pg, Pop1.B, Pop2.B + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); + + /// + /// svuint64_t svsel[_u64](svbool_t pg, svuint64_t op1, svuint64_t op2) + /// SEL Zresult.D, Pg, Zop1.D, Zop2.D + /// svbool_t svsel[_b](svbool_t pg, svbool_t op1, svbool_t op2) + /// SEL Presult.B, Pg, Pop1.B, Pop2.B + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); + + /// + /// svfloat32_t svsel[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// SEL Zresult.S, Pg, Zop1.S, Zop2.S + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); + + /// + /// svfloat64_t svsel[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// SEL Zresult.D, Pg, Zop1.D, Zop2.D + /// + /// + public static unsafe Vector ConditionalSelect(Vector mask, Vector left, Vector right) => ConditionalSelect(mask, left, right); /// LoadVector : Unextended load 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 77fe06ddc5c02c..bbe960b00b8207 100644 --- a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs +++ b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs @@ -4149,7 +4149,16 @@ internal Arm64() { } public static System.Numerics.Vector CreateTrueMaskUInt16([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } public static System.Numerics.Vector CreateTrueMaskUInt32([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } public static System.Numerics.Vector CreateTrueMaskUInt64([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; } - + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector ConditionalSelect(System.Numerics.Vector mask, System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static unsafe System.Numerics.Vector LoadVector(System.Numerics.Vector mask, sbyte* address) { throw null; } public static unsafe System.Numerics.Vector LoadVector(System.Numerics.Vector mask, short* address) { throw null; } public static unsafe System.Numerics.Vector LoadVector(System.Numerics.Vector mask, int* address) { throw null; } From c70367f410e184f95de5e8fe1ba44b138e482981 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 4 Apr 2024 01:29:25 -0700 Subject: [PATCH 09/47] Handle ConditionalSelect in JIT --- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 20 ++++++++++++++------ src/coreclr/jit/hwintrinsiclistarm64sve.h | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 6418b72a8f3075..93559c76458ee9 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -434,15 +434,23 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) break; case 3: - assert(isRMW); - if (targetReg != op1Reg) + if (isRMW) { - assert(targetReg != op2Reg); - assert(targetReg != op3Reg); + if (targetReg != op1Reg) + { + assert(targetReg != op2Reg); + assert(targetReg != op3Reg); - GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); + GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, + /* canSkip */ true); + } + GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); + } + else + { + GetEmitter()->emitIns_R_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, op3Reg, + opt, INS_SCALABLE_OPTS_UNPREDICATED); } - GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); break; default: diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index ac110c2a0e1b5b..40403e795bc37d 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -38,10 +38,11 @@ HARDWARE_INTRINSIC(Sve, LoadVector, // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** // Special intrinsics that are generated during importing or lowering +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, ConditionalSelect, -1, 3, true, {INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_MaskedOperation) 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_MaskedOperation) 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) #endif // FEATURE_HW_INTRINSIC From 1896b212fc2ae893c1249c1bfba4e9a4ccb737a5 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 4 Apr 2024 01:30:57 -0700 Subject: [PATCH 10/47] Add test coverage --- .../GenerateHWIntrinsicTests_Arm.cs | 10 + .../Arm/Shared/SveConditionalSelect.template | 362 ++++++++++++++++++ 2 files changed, 372 insertions(+) create mode 100644 src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveConditionalSelect.template diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index 5ee032e2842d61..d20d4e36a27010 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -2887,6 +2887,16 @@ (string templateFileName, Dictionary templateData)[] SveInputs = new [] { + // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "false",}), + // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "false",}), + // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "false",}), + // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "false",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "false",}), + // ("VecTernOpTest.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "false",}), + // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "false",}), + // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "false",}), + // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "false",}), + // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "false",}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_sbyte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveConditionalSelect.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveConditionalSelect.template new file mode 100644 index 00000000000000..6a4ccfe3aa6064 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveConditionalSelect.template @@ -0,0 +1,362 @@ +// 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.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.Arm; +using System.Numerics; +using Xunit; + +namespace JIT.HardwareIntrinsics.Arm +{ + public static partial class Program + { + [Fact] + public static void {TestName}() + { + var test = new TernaryOpTest__{TestName}(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if ({LoadIsa}.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 TernaryOpTest__{TestName} + { + private struct DataTable + { + private byte[] inArray1; + private byte[] inArray2; + private byte[] inArray3; + private byte[] outArray; + + private GCHandle inHandle1; + private GCHandle inHandle2; + private GCHandle inHandle3; + private GCHandle outHandle; + + private ulong alignment; + + public DataTable({Op1BaseType}[] inArray1, {Op2BaseType}[] inArray2, {Op3BaseType}[] inArray3, {RetBaseType}[] outArray, int alignment) + { + int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); + int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<{Op2BaseType}>(); + int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<{Op3BaseType}>(); + int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); + if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray) + { + 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 * 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.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<{Op2BaseType}, byte>(ref inArray2[0]), (uint)sizeOfinArray2); + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArray3Ptr), ref Unsafe.As<{Op3BaseType}, byte>(ref inArray3[0]), (uint)sizeOfinArray3); + } + + 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 Dispose() + { + inHandle1.Free(); + inHandle2.Free(); + inHandle3.Free(); + outHandle.Free(); + } + + private static unsafe void* Align(byte* buffer, ulong expectedAlignment) + { + return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); + } + } + + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + public {Op3VectorType}<{Op3BaseType}> _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + + 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] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref testStruct._fld3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(TernaryOpTest__{TestName} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = {LargestVectorSize}; + + private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + private static readonly int Op2ElementCount = Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>() / sizeof({Op2BaseType}); + private static readonly int Op3ElementCount = Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>() / sizeof({Op3BaseType}); + private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); + + private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; + private static {Op2BaseType}[] _data2 = new {Op2BaseType}[Op2ElementCount]; + private static {Op3BaseType}[] _data3 = new {Op3BaseType}[Op3ElementCount]; + + private {Op1VectorType}<{Op1BaseType}> _fld1; + private {Op2VectorType}<{Op2BaseType}> _fld2; + private {Op3VectorType}<{Op3BaseType}> _fld3; + + private DataTable _dataTable; + + public TernaryOpTest__{TestName}() + { + Succeeded = true; + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref _fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref _fld3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } + _dataTable = new DataTable(_data1, _data2, _data3, new {RetBaseType}[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => {Isa}.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); + + var result = {Isa}.{Method}( + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op2VectorType}<{Op2BaseType}>>(_dataTable.inArray2Ptr), + Unsafe.Read<{Op3VectorType}<{Op3BaseType}>>(_dataTable.inArray3Ptr) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); + + //TODO-SVE: Once register allocation exists for predicates, move loadMask into DataTable + {Op1VectorType}<{Op1BaseType}> loadMask = Sve.CreateTrueMask{RetBaseType}(SveMaskPattern.All); + + var result = {Isa}.{Method}( + {LoadIsa}.Load{Op1VectorType}(loadMask, ({Op1BaseType}*)(_dataTable.inArray1Ptr)), + {LoadIsa}.Load{Op2VectorType}(loadMask, ({Op2BaseType}*)(_dataTable.inArray2Ptr)), + {LoadIsa}.Load{Op3VectorType}(loadMask, ({Op3BaseType}*)(_dataTable.inArray3Ptr)) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); + + var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2VectorType}<{Op2BaseType}>), typeof({Op3VectorType}<{Op3BaseType}>) }) + .Invoke(null, new object[] { + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), + Unsafe.Read<{Op2VectorType}<{Op2BaseType}>>(_dataTable.inArray2Ptr), + Unsafe.Read<{Op3VectorType}<{Op3BaseType}>>(_dataTable.inArray3Ptr) + }); + + Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); + + var op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); + var op2 = Unsafe.Read<{Op2VectorType}<{Op2BaseType}>>(_dataTable.inArray2Ptr); + var op3 = Unsafe.Read<{Op3VectorType}<{Op3BaseType}>>(_dataTable.inArray3Ptr); + var result = {Isa}.{Method}(op1, op2, op3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(op1, op2, op3, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); + + var result = {Isa}.{Method}(_fld1, _fld2, _fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); + + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + 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, {Op2VectorType}<{Op2BaseType}> op2, {Op3VectorType}<{Op3BaseType}> op3, void* result, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op2BaseType}[] inArray2 = new {Op2BaseType}[Op2ElementCount]; + {Op3BaseType}[] inArray3 = new {Op3BaseType}[Op3ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), op1); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op2BaseType}, byte>(ref inArray2[0]), op2); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op3BaseType}, byte>(ref inArray3[0]), op3); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + + ValidateResult(inArray1, inArray2, inArray3, outArray, method); + } + + private void ValidateResult(void* op1, void* op2, void* op3, void* result, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; + {Op2BaseType}[] inArray2 = new {Op2BaseType}[Op2ElementCount]; + {Op3BaseType}[] inArray3 = new {Op3BaseType}[Op3ElementCount]; + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), ref Unsafe.AsRef(op1), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2BaseType}, byte>(ref inArray2[0]), ref Unsafe.AsRef(op2), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3BaseType}, byte>(ref inArray3[0]), ref Unsafe.AsRef(op3), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + + ValidateResult(inArray1, inArray2, inArray3, outArray, method); + } + + private void ValidateResult({Op1BaseType}[] firstOp, {Op2BaseType}[] secondOp, {Op3BaseType}[] thirdOp, {RetBaseType}[] result, [CallerMemberName] string method = "") + { + bool succeeded = true; + + for (var i = 0; i < RetElementCount; i++) + { + if ({ValidateIterResult}) + { + succeeded = false; + break; + } + } + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>, {Op2VectorType}<{Op2BaseType}>, {Op3VectorType}<{Op3BaseType}>): {method} failed:"); + TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); + TestLibrary.TestFramework.LogInformation($"secondOp: ({string.Join(", ", secondOp)})"); + TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); + TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + Succeeded = false; + } + } + } +} From 2e0d022ed12c515b965113410e5fb8f46973c976 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Fri, 5 Apr 2024 17:29:18 -0700 Subject: [PATCH 11/47] Update the test cases --- .../GenerateHWIntrinsicTests_Arm.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index d20d4e36a27010..f1234adb00ef2b 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -2887,16 +2887,16 @@ (string templateFileName, Dictionary templateData)[] SveInputs = new [] { - // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "false",}), - // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "false",}), - // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "false",}), - // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "false",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "false",}), - // ("VecTernOpTest.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "false",}), - // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "false",}), - // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "false",}), - // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "false",}), - // ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "false",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_sbyte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), From 185fcfa63a7e90f78c8f0664177c4c2541b0f0e7 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Fri, 5 Apr 2024 22:33:10 -0700 Subject: [PATCH 12/47] jit format --- src/coreclr/jit/_typeinfo.h | 15 +- src/coreclr/jit/abi.h | 8 +- src/coreclr/jit/alloc.h | 18 +- src/coreclr/jit/assertionprop.cpp | 20 +- src/coreclr/jit/bitset.h | 4 +- src/coreclr/jit/bitsetasshortlong.h | 50 +- src/coreclr/jit/bitsetasuint64.h | 4 +- src/coreclr/jit/bitsetasuint64inclass.h | 8 +- src/coreclr/jit/block.cpp | 55 +- src/coreclr/jit/block.h | 128 ++-- src/coreclr/jit/codegen.h | 131 ++-- src/coreclr/jit/codegenarm.cpp | 10 +- src/coreclr/jit/codegenarm64.cpp | 16 +- src/coreclr/jit/codegenarm64test.cpp | 8 +- src/coreclr/jit/codegenarmarch.cpp | 83 ++- src/coreclr/jit/codegencommon.cpp | 38 +- src/coreclr/jit/codegeninterface.h | 9 +- src/coreclr/jit/codegenlinear.cpp | 15 +- src/coreclr/jit/codegenloongarch64.cpp | 46 +- src/coreclr/jit/codegenriscv64.cpp | 46 +- src/coreclr/jit/codegenxarch.cpp | 68 ++- src/coreclr/jit/compiler.cpp | 270 ++++----- src/coreclr/jit/compiler.h | 340 +++++------ src/coreclr/jit/compiler.hpp | 90 +-- src/coreclr/jit/copyprop.cpp | 6 +- src/coreclr/jit/dataflow.h | 10 +- src/coreclr/jit/debuginfo.h | 16 +- src/coreclr/jit/decomposelongs.h | 6 +- src/coreclr/jit/disasm.cpp | 37 +- src/coreclr/jit/ee_il_dll.cpp | 8 +- src/coreclr/jit/ee_il_dll.hpp | 4 +- src/coreclr/jit/eeinterface.cpp | 97 +-- src/coreclr/jit/emit.cpp | 179 +++--- src/coreclr/jit/emit.h | 191 +++--- src/coreclr/jit/emitarm.cpp | 38 +- src/coreclr/jit/emitarm.h | 4 +- src/coreclr/jit/emitarm64.cpp | 124 ++-- src/coreclr/jit/emitarm64.h | 146 ++--- src/coreclr/jit/emitarm64sve.cpp | 358 +++++------ src/coreclr/jit/emitloongarch64.cpp | 34 +- src/coreclr/jit/emitloongarch64.h | 18 +- src/coreclr/jit/emitpub.h | 36 +- src/coreclr/jit/emitriscv64.cpp | 31 +- src/coreclr/jit/emitriscv64.h | 26 +- src/coreclr/jit/emitxarch.cpp | 296 ++++----- src/coreclr/jit/emitxarch.h | 58 +- src/coreclr/jit/error.cpp | 4 +- src/coreclr/jit/fgbasic.cpp | 22 +- src/coreclr/jit/fgdiagnostic.cpp | 92 ++- src/coreclr/jit/fgehopt.cpp | 8 +- src/coreclr/jit/fginline.cpp | 11 +- src/coreclr/jit/fgopt.cpp | 79 +-- src/coreclr/jit/fgprofile.cpp | 85 +-- src/coreclr/jit/fgprofilesynthesis.cpp | 92 +-- src/coreclr/jit/fgprofilesynthesis.h | 4 +- src/coreclr/jit/flowgraph.cpp | 301 ++++++---- src/coreclr/jit/forwardsub.cpp | 4 +- src/coreclr/jit/gcencode.cpp | 29 +- src/coreclr/jit/gentree.cpp | 198 +++--- src/coreclr/jit/gentree.h | 433 +++++-------- src/coreclr/jit/gschecks.cpp | 4 +- src/coreclr/jit/hashbv.cpp | 108 ++-- src/coreclr/jit/hashbv.h | 27 +- src/coreclr/jit/helperexpansion.cpp | 12 +- src/coreclr/jit/host.h | 6 +- src/coreclr/jit/hostallocator.h | 6 +- src/coreclr/jit/hwintrinsic.cpp | 2 +- src/coreclr/jit/hwintrinsic.h | 12 +- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 7 +- src/coreclr/jit/hwintrinsiccodegenxarch.cpp | 35 +- src/coreclr/jit/hwintrinsicxarch.cpp | 14 +- src/coreclr/jit/importer.cpp | 88 +-- src/coreclr/jit/importercalls.cpp | 634 ++++++++++---------- src/coreclr/jit/importervectorization.cpp | 10 +- src/coreclr/jit/indirectcalltransformer.cpp | 10 +- src/coreclr/jit/inductionvariableopts.cpp | 200 +++--- src/coreclr/jit/inline.cpp | 2 +- src/coreclr/jit/inline.h | 28 +- src/coreclr/jit/inlinepolicy.cpp | 10 +- src/coreclr/jit/inlinepolicy.h | 2 +- src/coreclr/jit/instr.cpp | 12 +- src/coreclr/jit/instrsarm.h | 2 +- src/coreclr/jit/instrsarm64.h | 2 +- src/coreclr/jit/instrsloongarch64.h | 2 +- src/coreclr/jit/instrsxarch.h | 2 +- src/coreclr/jit/jit.h | 29 +- src/coreclr/jit/jitconfig.cpp | 23 +- src/coreclr/jit/jitconfig.h | 12 +- src/coreclr/jit/jiteh.cpp | 20 +- src/coreclr/jit/jiteh.h | 7 +- src/coreclr/jit/jitexpandarray.h | 4 +- src/coreclr/jit/jitgcinfo.h | 17 +- src/coreclr/jit/jithashtable.h | 32 +- src/coreclr/jit/layout.cpp | 7 +- src/coreclr/jit/layout.h | 5 +- src/coreclr/jit/lclmorph.cpp | 12 +- src/coreclr/jit/lclvars.cpp | 104 ++-- src/coreclr/jit/likelyclass.cpp | 5 +- src/coreclr/jit/lir.cpp | 76 ++- src/coreclr/jit/lir.h | 26 +- src/coreclr/jit/liveness.cpp | 104 ++-- src/coreclr/jit/loopcloning.cpp | 48 +- src/coreclr/jit/loopcloning.h | 51 +- src/coreclr/jit/lower.cpp | 60 +- src/coreclr/jit/lower.h | 132 ++-- src/coreclr/jit/lowerarmarch.cpp | 5 +- src/coreclr/jit/lowerxarch.cpp | 54 +- src/coreclr/jit/lsra.cpp | 129 ++-- src/coreclr/jit/lsra.h | 256 ++++---- src/coreclr/jit/lsraarmarch.cpp | 34 +- src/coreclr/jit/lsrabuild.cpp | 200 +++--- src/coreclr/jit/lsraxarch.cpp | 38 +- src/coreclr/jit/morph.cpp | 127 ++-- src/coreclr/jit/morphblock.cpp | 18 +- src/coreclr/jit/objectalloc.cpp | 4 +- src/coreclr/jit/objectalloc.h | 30 +- src/coreclr/jit/optcse.cpp | 14 +- src/coreclr/jit/optcse.h | 30 +- src/coreclr/jit/optimizebools.cpp | 11 +- src/coreclr/jit/optimizer.cpp | 147 ++--- src/coreclr/jit/patchpoint.cpp | 4 +- src/coreclr/jit/phase.h | 6 +- src/coreclr/jit/promotion.cpp | 71 +-- src/coreclr/jit/promotion.h | 68 +-- src/coreclr/jit/promotiondecomposition.cpp | 4 +- src/coreclr/jit/promotionliveness.cpp | 22 +- src/coreclr/jit/rangecheck.cpp | 6 +- src/coreclr/jit/rangecheck.h | 16 +- src/coreclr/jit/rationalize.h | 4 +- src/coreclr/jit/redundantbranchopts.cpp | 47 +- src/coreclr/jit/regset.cpp | 10 +- src/coreclr/jit/regset.h | 10 +- src/coreclr/jit/scev.cpp | 18 +- src/coreclr/jit/scev.h | 26 +- src/coreclr/jit/scopeinfo.cpp | 19 +- src/coreclr/jit/sideeffects.cpp | 38 +- src/coreclr/jit/sideeffects.h | 3 +- src/coreclr/jit/simd.h | 18 +- src/coreclr/jit/simdashwintrinsic.cpp | 6 +- src/coreclr/jit/sm.cpp | 4 +- src/coreclr/jit/smallhash.h | 16 +- src/coreclr/jit/smopenum.h | 3 +- src/coreclr/jit/ssabuilder.cpp | 408 +++++++------ src/coreclr/jit/ssabuilder.h | 2 +- src/coreclr/jit/ssarenamestate.h | 4 +- src/coreclr/jit/stacklevelsetter.h | 4 +- src/coreclr/jit/target.h | 6 +- src/coreclr/jit/targetarm.cpp | 4 +- src/coreclr/jit/treelifeupdater.cpp | 2 +- src/coreclr/jit/unwind.cpp | 2 +- src/coreclr/jit/unwind.h | 89 +-- src/coreclr/jit/unwindamd64.cpp | 2 +- src/coreclr/jit/unwindarm64.cpp | 6 +- src/coreclr/jit/unwindarmarch.cpp | 37 +- src/coreclr/jit/unwindloongarch64.cpp | 12 +- src/coreclr/jit/unwindriscv64.cpp | 2 +- src/coreclr/jit/unwindx86.cpp | 32 +- src/coreclr/jit/utils.cpp | 38 +- src/coreclr/jit/utils.h | 28 +- src/coreclr/jit/valuenum.cpp | 80 +-- src/coreclr/jit/valuenum.h | 99 ++- src/coreclr/jit/valuenumtype.h | 4 +- src/coreclr/jit/varset.h | 2 +- src/coreclr/jit/vartype.h | 12 +- 164 files changed, 4328 insertions(+), 4639 deletions(-) diff --git a/src/coreclr/jit/_typeinfo.h b/src/coreclr/jit/_typeinfo.h index 42526eeb8de4bd..a4848bd3c63a52 100644 --- a/src/coreclr/jit/_typeinfo.h +++ b/src/coreclr/jit/_typeinfo.h @@ -41,23 +41,18 @@ class typeInfo private: var_types m_type; - union { + union + { CORINFO_CLASS_HANDLE m_cls; // Valid, but not always available, for TYP_REFs. methodPointerInfo* m_methodPointerInfo; // Valid only for function pointers. }; public: - typeInfo() : m_type(TYP_UNDEF), m_cls(NO_CLASS_HANDLE) - { - } + typeInfo() : m_type(TYP_UNDEF), m_cls(NO_CLASS_HANDLE) {} - typeInfo(var_types type) : m_type(type), m_cls(NO_CLASS_HANDLE) - { - } + typeInfo(var_types type) : m_type(type), m_cls(NO_CLASS_HANDLE) {} - typeInfo(CORINFO_CLASS_HANDLE cls) : m_type(TYP_REF), m_cls(cls) - { - } + typeInfo(CORINFO_CLASS_HANDLE cls) : m_type(TYP_REF), m_cls(cls) {} typeInfo(methodPointerInfo* methodPointerInfo) : m_type(TYP_I_IMPL), m_methodPointerInfo(methodPointerInfo) { diff --git a/src/coreclr/jit/abi.h b/src/coreclr/jit/abi.h index 27e53c27efc7e3..88470265c6e576 100644 --- a/src/coreclr/jit/abi.h +++ b/src/coreclr/jit/abi.h @@ -63,9 +63,7 @@ class RegisterQueue unsigned int m_index = 0; public: - RegisterQueue(const regNumber* regs, unsigned int numRegs) : m_regs(regs), m_numRegs(numRegs) - { - } + RegisterQueue(const regNumber* regs, unsigned int numRegs) : m_regs(regs), m_numRegs(numRegs) {} unsigned Count() { @@ -187,9 +185,7 @@ class SwiftABIClassifier PlatformClassifier m_classifier; public: - SwiftABIClassifier(const ClassifierInfo& info) : m_classifier(info) - { - } + SwiftABIClassifier(const ClassifierInfo& info) : m_classifier(info) {} ABIPassingInformation Classify(Compiler* comp, var_types type, diff --git a/src/coreclr/jit/alloc.h b/src/coreclr/jit/alloc.h index cb3da79232f8bb..1bb4679ce71afe 100644 --- a/src/coreclr/jit/alloc.h +++ b/src/coreclr/jit/alloc.h @@ -22,9 +22,9 @@ enum CompMemKind class ArenaAllocator { private: - ArenaAllocator(const ArenaAllocator& other) = delete; + ArenaAllocator(const ArenaAllocator& other) = delete; ArenaAllocator& operator=(const ArenaAllocator& other) = delete; - ArenaAllocator& operator=(ArenaAllocator&& other) = delete; + ArenaAllocator& operator=(ArenaAllocator&& other) = delete; struct PageDescriptor { @@ -52,7 +52,7 @@ class ArenaAllocator void* allocateNewPage(size_t size); static void* allocateHostMemory(size_t size, size_t* pActualSize); - static void freeHostMemory(void* block, size_t size); + static void freeHostMemory(void* block, size_t size); #if MEASURE_MEM_ALLOC struct MemStats @@ -125,8 +125,8 @@ class ArenaAllocator public: MemStatsAllocator* getMemStatsAllocator(CompMemKind kind); - void finishMemStats(); - void dumpMemStats(FILE* file); + void finishMemStats(); + void dumpMemStats(FILE* file); static void dumpMaxMemStats(FILE* file); static void dumpAggregateMemStats(FILE* file); @@ -249,9 +249,7 @@ class CompAllocator // Deallocate a block of memory previously allocated by `allocate`. // The arena allocator does not release memory so this doesn't do anything. - void deallocate(void* p) - { - } + void deallocate(void* p) {} }; // Global operator new overloads that work with CompAllocator @@ -276,9 +274,7 @@ class CompIAllocator : public IAllocator char m_zeroLenAllocTarg; public: - CompIAllocator(CompAllocator alloc) : m_alloc(alloc) - { - } + CompIAllocator(CompAllocator alloc) : m_alloc(alloc) {} // Allocates a block of memory at least `sz` in size. virtual void* Alloc(size_t sz) override diff --git a/src/coreclr/jit/assertionprop.cpp b/src/coreclr/jit/assertionprop.cpp index 459d816181e502..d8fd2f7b6a6326 100644 --- a/src/coreclr/jit/assertionprop.cpp +++ b/src/coreclr/jit/assertionprop.cpp @@ -1524,9 +1524,8 @@ AssertionIndex Compiler::optCreateAssertion(GenTree* op1, assertion.op1.lcl.ssaNum = op1->AsLclVarCommon()->GetSsaNum(); assert((assertion.op1.lcl.ssaNum == SsaConfig::RESERVED_SSA_NUM) || - (assertion.op1.vn == - vnStore->VNConservativeNormalValue( - lvaGetDesc(lclNum)->GetPerSsaData(assertion.op1.lcl.ssaNum)->m_vnPair))); + (assertion.op1.vn == vnStore->VNConservativeNormalValue( + lvaGetDesc(lclNum)->GetPerSsaData(assertion.op1.lcl.ssaNum)->m_vnPair))); ssize_t cnsValue = 0; GenTreeFlags iconFlags = GTF_EMPTY; @@ -2770,7 +2769,7 @@ GenTree* Compiler::optVNBasedFoldExpr(BasicBlock* block, GenTree* parent, GenTre case GT_CALL: return optVNBasedFoldExpr_Call(block, parent, tree->AsCall()); - // We can add more VN-based foldings here. + // We can add more VN-based foldings here. default: break; @@ -3325,7 +3324,7 @@ bool Compiler::optIsProfitableToSubstitute(GenTree* dest, BasicBlock* destBlock, // GenTree* Compiler::optConstantAssertionProp(AssertionDsc* curAssertion, GenTreeLclVarCommon* tree, - Statement* stmt DEBUGARG(AssertionIndex index)) + Statement* stmt DEBUGARG(AssertionIndex index)) { const unsigned lclNum = tree->GetLclNum(); @@ -3580,7 +3579,7 @@ bool Compiler::optAssertionProp_LclVarTypeCheck(GenTree* tree, LclVarDsc* lclVar // GenTree* Compiler::optCopyAssertionProp(AssertionDsc* curAssertion, GenTreeLclVarCommon* tree, - Statement* stmt DEBUGARG(AssertionIndex index)) + Statement* stmt DEBUGARG(AssertionIndex index)) { const AssertionDsc::AssertionDscOp1& op1 = curAssertion->op1; const AssertionDsc::AssertionDscOp2& op2 = curAssertion->op2; @@ -4529,8 +4528,9 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, Gen { printf("\nVN relop based copy assertion prop in " FMT_BB ":\n", compCurBB->bbNum); printf("Assertion index=#%02u: V%02d.%02d %s V%02d.%02d\n", index, op1->AsLclVar()->GetLclNum(), - op1->AsLclVar()->GetSsaNum(), (curAssertion->assertionKind == OAK_EQUAL) ? "==" : "!=", - op2->AsLclVar()->GetLclNum(), op2->AsLclVar()->GetSsaNum()); + op1->AsLclVar()->GetSsaNum(), + (curAssertion->assertionKind == OAK_EQUAL) ? "==" : "!=", op2->AsLclVar()->GetLclNum(), + op2->AsLclVar()->GetSsaNum()); gtDispTree(tree, nullptr, nullptr, true); } #endif @@ -4824,7 +4824,7 @@ GenTree* Compiler::optAssertionProp_Ind(ASSERT_VALARG_TP assertions, GenTree* tr // If both VN and assertion table yield a matching assertion, "pVnBased" // is only set and the return value is "NO_ASSERTION_INDEX." // -bool Compiler::optAssertionIsNonNull(GenTree* op, +bool Compiler::optAssertionIsNonNull(GenTree* op, ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased) DEBUGARG(AssertionIndex* pIndex)) { @@ -4871,7 +4871,7 @@ bool Compiler::optAssertionIsNonNull(GenTree* op, // Return Value: // index of assertion, or NO_ASSERTION_INDEX // -AssertionIndex Compiler::optAssertionIsNonNullInternal(GenTree* op, +AssertionIndex Compiler::optAssertionIsNonNullInternal(GenTree* op, ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased)) { diff --git a/src/coreclr/jit/bitset.h b/src/coreclr/jit/bitset.h index b34d1f04b85f1f..aefa0e380a7d5f 100644 --- a/src/coreclr/jit/bitset.h +++ b/src/coreclr/jit/bitset.h @@ -435,9 +435,7 @@ class BitSetOpsWithCounter Env m_env; public: - Iter(Env env, BitSetValueArgType bs) : m_iter(env, bs), m_env(env) - { - } + Iter(Env env, BitSetValueArgType bs) : m_iter(env, bs), m_env(env) {} bool NextElem(unsigned* pElem) { diff --git a/src/coreclr/jit/bitsetasshortlong.h b/src/coreclr/jit/bitsetasshortlong.h index 2ef293820fd264..7ace234e8a0868 100644 --- a/src/coreclr/jit/bitsetasshortlong.h +++ b/src/coreclr/jit/bitsetasshortlong.h @@ -32,36 +32,36 @@ class BitSetOps m_bs; public: - BitSetUint64ValueRetType(const BitSetUint64& bs) : m_bs(bs) - { - } + BitSetUint64ValueRetType(const BitSetUint64& bs) : m_bs(bs) {} }; template @@ -451,9 +449,7 @@ class BitSetOps, unsigned m_bitNum; public: - Iter(Env env, const BitSetUint64& bs) : m_bits(bs.m_bits), m_bitNum(0) - { - } + Iter(Env env, const BitSetUint64& bs) : m_bits(bs.m_bits), m_bitNum(0) {} bool NextElem(unsigned* pElem) { diff --git a/src/coreclr/jit/block.cpp b/src/coreclr/jit/block.cpp index 6eea265871c04c..01031cd8b7f58d 100644 --- a/src/coreclr/jit/block.cpp +++ b/src/coreclr/jit/block.cpp @@ -34,7 +34,7 @@ unsigned BasicBlock::s_nMaxTrees; FlowEdge* ShuffleHelper(unsigned hash, FlowEdge* res) { FlowEdge* head = res; - for (FlowEdge *prev = nullptr; res != nullptr; prev = res, res = res->getNextPredEdge()) + for (FlowEdge* prev = nullptr; res != nullptr; prev = res, res = res->getNextPredEdge()) { unsigned blkHash = (hash ^ (res->getSourceBlock()->bbNum << 16) ^ res->getSourceBlock()->bbNum); if (((blkHash % 1879) & 1) && prev != nullptr) @@ -143,26 +143,30 @@ void FlowEdge::addLikelihood(weight_t addedLikelihood) AllSuccessorEnumerator::AllSuccessorEnumerator(Compiler* comp, BasicBlock* block) : m_block(block) { m_numSuccs = 0; - block->VisitAllSuccs(comp, [this](BasicBlock* succ) { - if (m_numSuccs < ArrLen(m_successors)) - { - m_successors[m_numSuccs] = succ; - } - - m_numSuccs++; - return BasicBlockVisit::Continue; - }); + block->VisitAllSuccs(comp, + [this](BasicBlock* succ) + { + if (m_numSuccs < ArrLen(m_successors)) + { + m_successors[m_numSuccs] = succ; + } + + m_numSuccs++; + return BasicBlockVisit::Continue; + }); if (m_numSuccs > ArrLen(m_successors)) { m_pSuccessors = new (comp, CMK_BasicBlock) BasicBlock*[m_numSuccs]; unsigned numSuccs = 0; - block->VisitAllSuccs(comp, [this, &numSuccs](BasicBlock* succ) { - assert(numSuccs < m_numSuccs); - m_pSuccessors[numSuccs++] = succ; - return BasicBlockVisit::Continue; - }); + block->VisitAllSuccs(comp, + [this, &numSuccs](BasicBlock* succ) + { + assert(numSuccs < m_numSuccs); + m_pSuccessors[numSuccs++] = succ; + return BasicBlockVisit::Continue; + }); assert(numSuccs == m_numSuccs); } @@ -231,9 +235,12 @@ FlowEdge* Compiler::BlockPredsWithEH(BasicBlock* blk) { res = new (this, CMK_FlowEdge) FlowEdge(filterBlk, blk, res); - assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, [blk](BasicBlock* succ) { - return succ == blk ? BasicBlockVisit::Abort : BasicBlockVisit::Continue; - }) == BasicBlockVisit::Abort); + assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, + [blk](BasicBlock* succ) { + return succ == blk + ? BasicBlockVisit::Abort + : BasicBlockVisit::Continue; + }) == BasicBlockVisit::Abort); } } @@ -306,9 +313,12 @@ FlowEdge* Compiler::BlockDominancePreds(BasicBlock* blk) { res = new (this, CMK_FlowEdge) FlowEdge(filterBlk, blk, res); - assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, [blk](BasicBlock* succ) { - return succ == blk ? BasicBlockVisit::Abort : BasicBlockVisit::Continue; - }) == BasicBlockVisit::Abort); + assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, + [blk](BasicBlock* succ) { + return succ == blk + ? BasicBlockVisit::Abort + : BasicBlockVisit::Continue; + }) == BasicBlockVisit::Abort); } } @@ -690,7 +700,8 @@ void BasicBlock::dspSuccs(Compiler* compiler) // things strictly. void BasicBlock::dspKind() const { - auto dspBlockNum = [](const FlowEdge* e) -> const char* { + auto dspBlockNum = [](const FlowEdge* e) -> const char* + { static char buffers[3][64]; // static array of 3 to allow 3 concurrent calls in one printf() static int nextBufferIndex = 0; diff --git a/src/coreclr/jit/block.h b/src/coreclr/jit/block.h index 68f41e3610173a..5c0de29449c460 100644 --- a/src/coreclr/jit/block.h +++ b/src/coreclr/jit/block.h @@ -162,9 +162,7 @@ class MemoryKindIterator int value; public: - explicit inline MemoryKindIterator(int val) : value(val) - { - } + explicit inline MemoryKindIterator(int val) : value(val) {} inline MemoryKindIterator& operator++() { ++value; @@ -191,9 +189,7 @@ class MemoryKindIterator // Empty struct that allows enumerating memory kinds via `for(MemoryKind kind : allMemoryKinds())` struct allMemoryKinds { - inline allMemoryKinds() - { - } + inline allMemoryKinds() {} inline MemoryKindIterator begin() { return MemoryKindIterator(0); @@ -244,9 +240,7 @@ class PredEdgeList }; public: - PredEdgeList(FlowEdge* pred) : m_begin(pred) - { - } + PredEdgeList(FlowEdge* pred) : m_begin(pred) {} iterator begin() const { @@ -297,9 +291,7 @@ class PredBlockList }; public: - PredBlockList(FlowEdge* pred) : m_begin(pred) - { - } + PredBlockList(FlowEdge* pred) : m_begin(pred) {} iterator begin() const { @@ -322,9 +314,7 @@ class BBArrayIterator FlowEdge* const* m_edgeEntry; public: - BBArrayIterator(FlowEdge* const* edgeEntry) : m_edgeEntry(edgeEntry) - { - } + BBArrayIterator(FlowEdge* const* edgeEntry) : m_edgeEntry(edgeEntry) {} BasicBlock* operator*() const; @@ -351,9 +341,7 @@ class FlowEdgeArrayIterator FlowEdge* const* m_edgeEntry; public: - FlowEdgeArrayIterator(FlowEdge* const* edgeEntry) : m_edgeEntry(edgeEntry) - { - } + FlowEdgeArrayIterator(FlowEdge* const* edgeEntry) : m_edgeEntry(edgeEntry) {} FlowEdge* operator*() const { @@ -727,7 +715,8 @@ struct BasicBlock : private LIR::Range BBKinds bbKind; // jump (if any) at the end of this block /* The following union describes the jump target(s) of this block */ - union { + union + { unsigned bbTargetOffs; // PC offset (temporary only) FlowEdge* bbTargetEdge; // successor edge for block kinds with only one successor (BBJ_ALWAYS, etc) FlowEdge* bbTrueEdge; // BBJ_COND successor edge when its condition is true (alias for bbTargetEdge) @@ -1165,11 +1154,11 @@ struct BasicBlock : private LIR::Range } #ifdef DEBUG - void dspFlags() const; // Print the flags - unsigned dspPreds() const; // Print the predecessors (bbPreds) - void dspSuccs(Compiler* compiler); // Print the successors. The 'compiler' argument determines whether EH - // regions are printed: see NumSucc() for details. - void dspKind() const; // Print the block jump kind (e.g., BBJ_ALWAYS, BBJ_COND, etc.). + void dspFlags() const; // Print the flags + unsigned dspPreds() const; // Print the predecessors (bbPreds) + void dspSuccs(Compiler* compiler); // Print the successors. The 'compiler' argument determines whether EH + // regions are printed: see NumSucc() for details. + void dspKind() const; // Print the block jump kind (e.g., BBJ_ALWAYS, BBJ_COND, etc.). // Print a simple basic block header for various output, including a list of predecessors and successors. void dspBlockHeader(Compiler* compiler, bool showKind = true, bool showFlags = false, bool showPreds = true); @@ -1402,12 +1391,14 @@ struct BasicBlock : private LIR::Range #define NO_BASE_TMP UINT_MAX // base# to use when we have none - union { + union + { unsigned bbStkTempsIn; // base# for input stack temps int bbCountSchemaIndex; // schema index for count instrumentation }; - union { + union + { unsigned bbStkTempsOut; // base# for output stack temps int bbHistogramSchemaIndex; // schema index for histogram instrumentation }; @@ -1574,7 +1565,8 @@ struct BasicBlock : private LIR::Range void ensurePredListOrder(Compiler* compiler); void reorderPredList(Compiler* compiler); - union { + union + { BasicBlock* bbIDom; // Represent the closest dominator to this block (called the Immediate // Dominator) used to compute the dominance tree. FlowEdge* bbLastPred; // Used early on by fgLinkBasicBlock/fgAddRefPred @@ -1623,9 +1615,7 @@ struct BasicBlock : private LIR::Range return m_ssaNum; } - MemoryPhiArg(unsigned ssaNum, MemoryPhiArg* nextArg = nullptr) : m_ssaNum(ssaNum), m_nextArg(nextArg) - { - } + MemoryPhiArg(unsigned ssaNum, MemoryPhiArg* nextArg = nullptr) : m_ssaNum(ssaNum), m_nextArg(nextArg) {} void* operator new(size_t sz, class Compiler* comp); }; @@ -1649,18 +1639,21 @@ struct BasicBlock : private LIR::Range * thus we can union them since the two operations are completely disjunct. */ - union { + union + { EXPSET_TP bbCseGen; // CSEs computed by block ASSERT_TP bbAssertionGen; // assertions created by block (global prop) ASSERT_TP bbAssertionOutIfTrue; // assertions available on exit along true/jump edge (BBJ_COND, local prop) }; - union { + union + { EXPSET_TP bbCseIn; // CSEs available on entry ASSERT_TP bbAssertionIn; // assertions available on entry (global prop) }; - union { + union + { EXPSET_TP bbCseOut; // CSEs available on exit ASSERT_TP bbAssertionOut; // assertions available on exit (global prop, local prop & !BBJ_COND) ASSERT_TP bbAssertionOutIfFalse; // assertions available on exit along false/next edge (BBJ_COND, local prop) @@ -1668,7 +1661,7 @@ struct BasicBlock : private LIR::Range void* bbEmitCookie; -//------------------------------------------------------------------------- + //------------------------------------------------------------------------- #if MEASURE_BLOCK_SIZE static size_t s_Size; @@ -1703,8 +1696,8 @@ struct BasicBlock : private LIR::Range unsigned bbID; #endif // DEBUG - unsigned bbStackDepthOnEntry() const; - void bbSetStack(StackEntry* stack); + unsigned bbStackDepthOnEntry() const; + void bbSetStack(StackEntry* stack); StackEntry* bbStackOnEntry() const; // "bbNum" is one-based (for unknown reasons); it is sometimes useful to have the corresponding @@ -1754,9 +1747,7 @@ struct BasicBlock : private LIR::Range Statement* FirstNonPhiDef() const; Statement* FirstNonPhiDefOrCatchArgStore() const; - BasicBlock() : bbStmtList(nullptr), bbLiveIn(VarSetOps::UninitVal()), bbLiveOut(VarSetOps::UninitVal()) - { - } + BasicBlock() : bbStmtList(nullptr), bbLiveIn(VarSetOps::UninitVal()), bbLiveOut(VarSetOps::UninitVal()) {} // Iteratable collection of successors of a block. template @@ -1766,9 +1757,7 @@ struct BasicBlock : private LIR::Range BasicBlock* m_block; public: - Successors(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block) - { - } + Successors(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block) {} class iterator { @@ -1777,13 +1766,9 @@ struct BasicBlock : private LIR::Range TPosition m_pos; public: - iterator(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block), m_pos(comp, block) - { - } + iterator(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block), m_pos(comp, block) {} - iterator() : m_pos() - { - } + iterator() : m_pos() {} void operator++(void) { @@ -1854,9 +1839,7 @@ struct BasicBlock : private LIR::Range class BBSuccList : private SuccList { public: - BBSuccList(const BasicBlock* block) : SuccList(block) - { - } + BBSuccList(const BasicBlock* block) : SuccList(block) {} BBArrayIterator begin() const { @@ -1876,9 +1859,7 @@ struct BasicBlock : private LIR::Range class BBSuccEdgeList : private SuccList { public: - BBSuccEdgeList(const BasicBlock* block) : SuccList(block) - { - } + BBSuccEdgeList(const BasicBlock* block) : SuccList(block) {} FlowEdgeArrayIterator begin() const { @@ -1937,9 +1918,7 @@ struct BasicBlock : private LIR::Range }; public: - BBCompilerSuccList(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block) - { - } + BBCompilerSuccList(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block) {} iterator begin() const { @@ -1998,9 +1977,7 @@ struct BasicBlock : private LIR::Range }; public: - BBCompilerSuccEdgeList(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block) - { - } + BBCompilerSuccEdgeList(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block) {} iterator begin() const { @@ -2108,9 +2085,7 @@ class BasicBlockIterator BasicBlock* m_block; public: - BasicBlockIterator(BasicBlock* block) : m_block(block) - { - } + BasicBlockIterator(BasicBlock* block) : m_block(block) {} BasicBlock* operator*() const { @@ -2144,9 +2119,7 @@ class BasicBlockSimpleList BasicBlock* m_begin; public: - BasicBlockSimpleList(BasicBlock* begin) : m_begin(begin) - { - } + BasicBlockSimpleList(BasicBlock* begin) : m_begin(begin) {} BasicBlockIterator begin() const { @@ -2214,9 +2187,7 @@ struct BBswtDesc bool bbsHasDefault; // true if last switch case is a default case bool bbsHasDominantCase; // true if switch has a dominant case - BBswtDesc() : bbsHasDefault(true), bbsHasDominantCase(false) - { - } + BBswtDesc() : bbsHasDefault(true), bbsHasDominantCase(false) {} BBswtDesc(const BBswtDesc* other); @@ -2264,9 +2235,7 @@ struct BBehfDesc FlowEdge** bbeSuccs; // array of `FlowEdge*` pointing to BBJ_EHFINALLYRET block successors unsigned bbeCount; // size of `bbeSuccs` array - BBehfDesc() : bbeSuccs(nullptr), bbeCount(0) - { - } + BBehfDesc() : bbeSuccs(nullptr), bbeCount(0) {} BBehfDesc(Compiler* comp, const BBehfDesc* other); }; @@ -2373,13 +2342,9 @@ struct BasicBlockList BasicBlockList* next; // The next BasicBlock in the list, nullptr for end of list. BasicBlock* block; // The BasicBlock of interest. - BasicBlockList() : next(nullptr), block(nullptr) - { - } + BasicBlockList() : next(nullptr), block(nullptr) {} - BasicBlockList(BasicBlock* blk, BasicBlockList* rest) : next(rest), block(blk) - { - } + BasicBlockList(BasicBlock* blk, BasicBlockList* rest) : next(rest), block(blk) {} }; // FlowEdge implementations (that are required to be defined after the declaration of BasicBlock) @@ -2435,13 +2400,13 @@ inline PredBlockList::iterator::iterator(FlowEdge* pred) : m_pred(pr } } -template +template inline BasicBlock* PredBlockList::iterator::operator*() const { return m_pred->getSourceBlock(); } -template +template inline typename PredBlockList::iterator& PredBlockList::iterator::operator++() { if (allowEdits) @@ -2480,7 +2445,8 @@ void* emitCodeGetCookie(const BasicBlock* block); class AllSuccessorEnumerator { BasicBlock* m_block; - union { + union + { // We store up to 4 successors inline in the enumerator. For ASP.NET // and libraries.pmi this is enough in 99.7% of cases. BasicBlock* m_successors[4]; diff --git a/src/coreclr/jit/codegen.h b/src/coreclr/jit/codegen.h index d63e0809b62693..faec6fd1bb5a27 100644 --- a/src/coreclr/jit/codegen.h +++ b/src/coreclr/jit/codegen.h @@ -101,7 +101,7 @@ class CodeGen final : public CodeGenInterface } } - static GenTreeIndir indirForm(var_types type, GenTree* base); + static GenTreeIndir indirForm(var_types type, GenTree* base); static GenTreeStoreInd storeIndirForm(var_types type, GenTree* base, GenTree* data); GenTreeIntCon intForm(var_types type, ssize_t value); @@ -177,8 +177,8 @@ class CodeGen final : public CodeGenInterface #ifdef JIT32_GCENCODER void* genCreateAndStoreGCInfo(unsigned codeSize, unsigned prologSize, unsigned epilogSize DEBUGARG(void* codePtr)); - void* genCreateAndStoreGCInfoJIT32(unsigned codeSize, - unsigned prologSize, + void* genCreateAndStoreGCInfoJIT32(unsigned codeSize, + unsigned prologSize, unsigned epilogSize DEBUGARG(void* codePtr)); #else // !JIT32_GCENCODER void genCreateAndStoreGCInfo(unsigned codeSize, unsigned prologSize, unsigned epilogSize DEBUGARG(void* codePtr)); @@ -206,7 +206,7 @@ class CodeGen final : public CodeGenInterface unsigned genCurDispOffset; static const char* genInsName(instruction ins); - const char* genInsDisplayName(emitter::instrDesc* id); + const char* genInsDisplayName(emitter::instrDesc* id); static const char* genSizeStr(emitAttr size); @@ -317,9 +317,7 @@ class CodeGen final : public CodeGenInterface regNumber reg2; bool useSaveNextPair; - RegPair(regNumber reg1) : reg1(reg1), reg2(REG_NA), useSaveNextPair(false) - { - } + RegPair(regNumber reg1) : reg1(reg1), reg2(REG_NA), useSaveNextPair(false) {} RegPair(regNumber reg1, regNumber reg2) : reg1(reg1), reg2(reg2), useSaveNextPair(false) { @@ -364,8 +362,8 @@ class CodeGen final : public CodeGenInterface bool genStackPointerAdjustment(ssize_t spAdjustment, regNumber tmpReg); - void genPushFltRegs(regMaskTP regMask); - void genPopFltRegs(regMaskTP regMask); + void genPushFltRegs(regMaskTP regMask); + void genPopFltRegs(regMaskTP regMask); regMaskTP genStackAllocRegisterMask(unsigned frameSize, regMaskTP maskCalleeSavedFloat); regMaskTP genJmpCallArgMask(); @@ -679,17 +677,17 @@ class CodeGen final : public CodeGenInterface void genSinglePush(); void genSinglePop(); regMaskTP genPushRegs(regMaskTP regs, regMaskTP* byrefRegs, regMaskTP* noRefRegs); - void genPopRegs(regMaskTP regs, regMaskTP byrefRegs, regMaskTP noRefRegs); - -/* -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XX XX -XX Debugging Support XX -XX XX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -*/ + void genPopRegs(regMaskTP regs, regMaskTP byrefRegs, regMaskTP noRefRegs); + + /* + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + XX XX + XX Debugging Support XX + XX XX + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + */ #ifdef DEBUG void genIPmappingDisp(unsigned mappingNum, const IPmappingDsc* ipMapping); @@ -939,7 +937,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX void genCompareFloat(GenTree* treeNode); void genCompareInt(GenTree* treeNode); #ifdef TARGET_XARCH - bool genCanAvoidEmittingCompareAgainstZero(GenTree* tree, var_types opType); + bool genCanAvoidEmittingCompareAgainstZero(GenTree* tree, var_types opType); GenTree* genTryFindFlagsConsumer(GenTree* flagsProducer, GenCondition** condition); #endif @@ -1112,12 +1110,12 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX void genSpillLocal(unsigned varNum, var_types type, GenTreeLclVar* lclNode, regNumber regNum); void genUnspillLocal( unsigned varNum, var_types type, GenTreeLclVar* lclNode, regNumber regNum, bool reSpill, bool isLastUse); - void genUnspillRegIfNeeded(GenTree* tree); - void genUnspillRegIfNeeded(GenTree* tree, unsigned multiRegIndex); + void genUnspillRegIfNeeded(GenTree* tree); + void genUnspillRegIfNeeded(GenTree* tree, unsigned multiRegIndex); regNumber genConsumeReg(GenTree* tree); regNumber genConsumeReg(GenTree* tree, unsigned multiRegIndex); - void genCopyRegIfNeeded(GenTree* tree, regNumber needReg); - void genConsumeRegAndCopy(GenTree* tree, regNumber needReg); + void genCopyRegIfNeeded(GenTree* tree, regNumber needReg); + void genConsumeRegAndCopy(GenTree* tree, regNumber needReg); void genConsumeIfReg(GenTree* tree) { @@ -1127,15 +1125,15 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX } } - void genRegCopy(GenTree* tree); + void genRegCopy(GenTree* tree); regNumber genRegCopy(GenTree* tree, unsigned multiRegIndex); - void genTransferRegGCState(regNumber dst, regNumber src); - void genConsumeAddress(GenTree* addr); - void genConsumeAddrMode(GenTreeAddrMode* mode); - void genSetBlockSize(GenTreeBlk* blkNode, regNumber sizeReg); - void genConsumeBlockSrc(GenTreeBlk* blkNode); - void genSetBlockSrc(GenTreeBlk* blkNode, regNumber srcReg); - void genConsumeBlockOp(GenTreeBlk* blkNode, regNumber dstReg, regNumber srcReg, regNumber sizeReg); + void genTransferRegGCState(regNumber dst, regNumber src); + void genConsumeAddress(GenTree* addr); + void genConsumeAddrMode(GenTreeAddrMode* mode); + void genSetBlockSize(GenTreeBlk* blkNode, regNumber sizeReg); + void genConsumeBlockSrc(GenTreeBlk* blkNode); + void genSetBlockSrc(GenTreeBlk* blkNode, regNumber srcReg); + void genConsumeBlockOp(GenTreeBlk* blkNode, regNumber dstReg, regNumber srcReg, regNumber sizeReg); #ifdef FEATURE_PUT_STRUCT_ARG_STK void genConsumePutStructArgStk(GenTreePutArgStk* putArgStkNode, @@ -1243,10 +1241,10 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX unsigned genMove4IfNeeded(unsigned size, regNumber tmpReg, GenTree* src, unsigned offset); unsigned genMove2IfNeeded(unsigned size, regNumber tmpReg, GenTree* src, unsigned offset); unsigned genMove1IfNeeded(unsigned size, regNumber tmpReg, GenTree* src, unsigned offset); - void genCodeForLoadOffset(instruction ins, emitAttr size, regNumber dst, GenTree* base, unsigned offset); - void genStoreRegToStackArg(var_types type, regNumber reg, int offset); - void genStructPutArgRepMovs(GenTreePutArgStk* putArgStkNode); - void genStructPutArgUnroll(GenTreePutArgStk* putArgStkNode); + void genCodeForLoadOffset(instruction ins, emitAttr size, regNumber dst, GenTree* base, unsigned offset); + void genStoreRegToStackArg(var_types type, regNumber reg, int offset); + void genStructPutArgRepMovs(GenTreePutArgStk* putArgStkNode); + void genStructPutArgUnroll(GenTreePutArgStk* putArgStkNode); #ifdef TARGET_X86 void genStructPutArgPush(GenTreePutArgStk* putArgStkNode); #else @@ -1254,13 +1252,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #endif #endif // FEATURE_PUT_STRUCT_ARG_STK - void genCodeForStoreBlk(GenTreeBlk* storeBlkNode); - void genCodeForInitBlkLoop(GenTreeBlk* initBlkNode); - void genCodeForInitBlkRepStos(GenTreeBlk* initBlkNode); - void genCodeForInitBlkUnroll(GenTreeBlk* initBlkNode); + void genCodeForStoreBlk(GenTreeBlk* storeBlkNode); + void genCodeForInitBlkLoop(GenTreeBlk* initBlkNode); + void genCodeForInitBlkRepStos(GenTreeBlk* initBlkNode); + void genCodeForInitBlkUnroll(GenTreeBlk* initBlkNode); unsigned genEmitJumpTable(GenTree* treeNode, bool relativeAddr); - void genJumpTable(GenTree* tree); - void genTableBasedSwitch(GenTree* tree); + void genJumpTable(GenTree* tree); + void genTableBasedSwitch(GenTree* tree); #if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) instruction genGetInsForOper(GenTree* treeNode); #else @@ -1270,13 +1268,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX regNumber targetReg, GenTreeIndir* indir, bool* needsBarrier); - bool genEmitOptimizedGCWriteBarrier(GCInfo::WriteBarrierForm writeBarrierForm, GenTree* addr, GenTree* data); - GenTree* getCallTarget(const GenTreeCall* call, CORINFO_METHOD_HANDLE* methHnd); - regNumber getCallIndirectionCellReg(GenTreeCall* call); - void genCall(GenTreeCall* call); - void genCallInstruction(GenTreeCall* call X86_ARG(target_ssize_t stackArgBytes)); - void genDefinePendingCallLabel(GenTreeCall* call); - void genJmpMethod(GenTree* jmp); + bool genEmitOptimizedGCWriteBarrier(GCInfo::WriteBarrierForm writeBarrierForm, GenTree* addr, GenTree* data); + GenTree* getCallTarget(const GenTreeCall* call, CORINFO_METHOD_HANDLE* methHnd); + regNumber getCallIndirectionCellReg(GenTreeCall* call); + void genCall(GenTreeCall* call); + void genCallInstruction(GenTreeCall* call X86_ARG(target_ssize_t stackArgBytes)); + void genDefinePendingCallLabel(GenTreeCall* call); + void genJmpMethod(GenTree* jmp); BasicBlock* genCallFinally(BasicBlock* block); #if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) // TODO: refactor for LA. @@ -1318,13 +1316,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX void genReturn(GenTree* treeNode); #ifdef TARGET_XARCH - void genStackPointerConstantAdjustment(ssize_t spDelta, bool trackSpAdjustments); - void genStackPointerConstantAdjustmentWithProbe(ssize_t spDelta, bool trackSpAdjustments); + void genStackPointerConstantAdjustment(ssize_t spDelta, bool trackSpAdjustments); + void genStackPointerConstantAdjustmentWithProbe(ssize_t spDelta, bool trackSpAdjustments); target_ssize_t genStackPointerConstantAdjustmentLoopWithProbe(ssize_t spDelta, bool trackSpAdjustments); - void genStackPointerDynamicAdjustmentWithProbe(regNumber regSpDelta); + void genStackPointerDynamicAdjustmentWithProbe(regNumber regSpDelta); #else // !TARGET_XARCH - void genStackPointerConstantAdjustment(ssize_t spDelta, regNumber regTmp); - void genStackPointerConstantAdjustmentWithProbe(ssize_t spDelta, regNumber regTmp); + void genStackPointerConstantAdjustment(ssize_t spDelta, regNumber regTmp); + void genStackPointerConstantAdjustmentWithProbe(ssize_t spDelta, regNumber regTmp); target_ssize_t genStackPointerConstantAdjustmentLoopWithProbe(ssize_t spDelta, regNumber regTmp); #endif // !TARGET_XARCH @@ -1358,12 +1356,10 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #ifdef DEBUG GenTree* lastConsumedNode; - void genNumberOperandUse(GenTree* const operand, int& useNum) const; - void genCheckConsumeNode(GenTree* const node); + void genNumberOperandUse(GenTree* const operand, int& useNum) const; + void genCheckConsumeNode(GenTree* const node); #else // !DEBUG - inline void genCheckConsumeNode(GenTree* treeNode) - { - } + inline void genCheckConsumeNode(GenTree* treeNode) {} #endif // DEBUG /* @@ -1448,7 +1444,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX class OperandDesc { OperandKind m_kind; - union { + union + { struct { CORINFO_FIELD_HANDLE m_fieldHnd; @@ -1476,13 +1473,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }; public: - OperandDesc(CORINFO_FIELD_HANDLE fieldHnd) : m_kind(OperandKind::ClsVar), m_fieldHnd(fieldHnd) - { - } + OperandDesc(CORINFO_FIELD_HANDLE fieldHnd) : m_kind(OperandKind::ClsVar), m_fieldHnd(fieldHnd) {} - OperandDesc(int varNum, uint16_t offset) : m_kind(OperandKind::Local), m_varNum(varNum), m_offset(offset) - { - } + OperandDesc(int varNum, uint16_t offset) : m_kind(OperandKind::Local), m_varNum(varNum), m_offset(offset) {} OperandDesc(GenTreeIndir* indir) : m_kind(OperandKind::Indir), m_addr(indir->Addr()), m_indir(indir), m_indirType(indir->TypeGet()) @@ -1499,9 +1492,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX { } - OperandDesc(regNumber reg) : m_kind(OperandKind::Reg), m_reg(reg) - { - } + OperandDesc(regNumber reg) : m_kind(OperandKind::Reg), m_reg(reg) {} OperandKind GetKind() const { diff --git a/src/coreclr/jit/codegenarm.cpp b/src/coreclr/jit/codegenarm.cpp index 8cf3ac32b3a329..65ba1bf5913c69 100644 --- a/src/coreclr/jit/codegenarm.cpp +++ b/src/coreclr/jit/codegenarm.cpp @@ -173,9 +173,9 @@ void CodeGen::genEHCatchRet(BasicBlock* block) //------------------------------------------------------------------------ // instGen_Set_Reg_To_Imm: Move an immediate value into an integer register. // -void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, - regNumber reg, - ssize_t imm, +void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, + regNumber reg, + ssize_t imm, insFlags flags DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { // reg cannot be a FP register @@ -1651,7 +1651,7 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, callTargetReg, // ireg REG_NA, 0, 0, // xreg, xmul, disp false // isJump - ); + ); } else { @@ -1660,7 +1660,7 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur, DebugInfo(), REG_NA, REG_NA, 0, 0, /* ilOffset, ireg, xreg, xmul, disp */ false /* isJump */ - ); + ); } regSet.verifyRegistersUsed(RBM_CALLEE_TRASH); diff --git a/src/coreclr/jit/codegenarm64.cpp b/src/coreclr/jit/codegenarm64.cpp index 81370e6413835f..5447fc34724c21 100644 --- a/src/coreclr/jit/codegenarm64.cpp +++ b/src/coreclr/jit/codegenarm64.cpp @@ -1884,8 +1884,8 @@ void CodeGen::genCaptureFuncletPrologEpilogInfo() if (compiler->lvaPSPSym != BAD_VAR_NUM) { - if (CallerSP_to_PSP_slot_delta != - compiler->lvaGetCallerSPRelativeOffset(compiler->lvaPSPSym)) // for debugging + if (CallerSP_to_PSP_slot_delta != compiler->lvaGetCallerSPRelativeOffset(compiler->lvaPSPSym)) // for + // debugging { printf("lvaGetCallerSPRelativeOffset(lvaPSPSym): %d\n", compiler->lvaGetCallerSPRelativeOffset(compiler->lvaPSPSym)); @@ -2216,9 +2216,9 @@ void CodeGen::genEHCatchRet(BasicBlock* block) // move an immediate value into an integer register -void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, - regNumber reg, - ssize_t imm, +void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, + regNumber reg, + ssize_t imm, insFlags flags DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { // reg cannot be a FP register @@ -5130,7 +5130,7 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, gcInfo.gcRegByrefSetCur, DebugInfo(), callTarget, /* ireg */ REG_NA, 0, 0, /* xreg, xmul, disp */ false /* isJump */ - ); + ); regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper); regSet.verifyRegistersUsed(killMask); @@ -5739,8 +5739,8 @@ void CodeGen::genCodeForBfiz(GenTreeOp* tree) GenTree* castOp = cast->CastOp(); genConsumeRegs(castOp); - unsigned srcBits = varTypeIsSmall(cast->CastToType()) ? genTypeSize(cast->CastToType()) * BITS_PER_BYTE - : genTypeSize(castOp) * BITS_PER_BYTE; + unsigned srcBits = varTypeIsSmall(cast->CastToType()) ? genTypeSize(cast->CastToType()) * BITS_PER_BYTE + : genTypeSize(castOp) * BITS_PER_BYTE; const bool isUnsigned = cast->IsUnsigned() || varTypeIsUnsigned(cast->CastToType()); GetEmitter()->emitIns_R_R_I_I(isUnsigned ? INS_ubfiz : INS_sbfiz, size, tree->GetRegNum(), castOp->GetRegNum(), (int)shiftByImm, (int)srcBits); diff --git a/src/coreclr/jit/codegenarm64test.cpp b/src/coreclr/jit/codegenarm64test.cpp index 750daa569613ff..52633ed6733e6a 100644 --- a/src/coreclr/jit/codegenarm64test.cpp +++ b/src/coreclr/jit/codegenarm64test.cpp @@ -4932,16 +4932,16 @@ void CodeGen::genArm64EmitterUnitTestsSve() INS_OPTS_SCALABLE_B); /* SEL .B, , .B, .B */ // IF_SVE_CZ_4A_A - theEmitter->emitIns_R_R(INS_sve_movs, EA_SCALABLE, REG_P0, REG_P15, - INS_OPTS_SCALABLE_B); /* MOVS .B, .B */ + theEmitter->emitIns_R_R(INS_sve_movs, EA_SCALABLE, REG_P0, REG_P15, INS_OPTS_SCALABLE_B); /* MOVS .B, .B + */ // IF_SVE_CZ_4A_K theEmitter->emitIns_R_R_R(INS_sve_mov, EA_SCALABLE, REG_P0, REG_P8, REG_P15, INS_OPTS_SCALABLE_B, INS_SCALABLE_OPTS_PREDICATE_MERGE); /* MOV .B, /M, .B */ // IF_SVE_CZ_4A_L - theEmitter->emitIns_R_R(INS_sve_mov, EA_SCALABLE, REG_P0, REG_P15, - INS_OPTS_SCALABLE_B); /* MOV .B, .B */ + theEmitter->emitIns_R_R(INS_sve_mov, EA_SCALABLE, REG_P0, REG_P15, INS_OPTS_SCALABLE_B); /* MOV .B, .B + */ // IF_SVE_DA_4A theEmitter->emitIns_R_R_R_R(INS_sve_brkpa, EA_SCALABLE, REG_P0, REG_P1, REG_P10, REG_P15, diff --git a/src/coreclr/jit/codegenarmarch.cpp b/src/coreclr/jit/codegenarmarch.cpp index 1f550660b77984..160addef1b9656 100644 --- a/src/coreclr/jit/codegenarmarch.cpp +++ b/src/coreclr/jit/codegenarmarch.cpp @@ -727,8 +727,8 @@ void CodeGen::genIntrinsic(GenTreeIntrinsic* treeNode) break; #if defined(FEATURE_SIMD) - // The handling is a bit more complex so genSimdUpperSave/Restore - // handles genConsumeOperands and genProduceReg + // The handling is a bit more complex so genSimdUpperSave/Restore + // handles genConsumeOperands and genProduceReg case NI_SIMD_UpperRestore: { @@ -861,7 +861,7 @@ void CodeGen::genPutArgStk(GenTreePutArgStk* treeNode) emit->emitIns_S_R(storeIns, storeAttr, REG_ZR, varNumOut, argOffsetOut); #else // !TARGET_ARM64 - // There is no zero register on ARM32 + // There is no zero register on ARM32 unreached(); #endif // !TARGET_ARM64 } @@ -1018,9 +1018,9 @@ void CodeGen::genPutArgStk(GenTreePutArgStk* treeNode) nextIndex += 2; } #else // TARGET_ARM - // For a >= 4 byte sizes we will generate a ldr and str instruction each loop - // ldr r2, [r0] - // str r2, [sp, #16] + // For a >= 4 byte sizes we will generate a ldr and str instruction each loop + // ldr r2, [r0] + // str r2, [sp, #16] while (remainingSize >= TARGET_POINTER_SIZE) { var_types type = layout->GetGCPtrType(nextIndex); @@ -1812,7 +1812,7 @@ instruction CodeGen::genGetVolatileLdStIns(instruction currentIns, assert(!addrIsInReg); switch (currentIns) { - // Loads + // Loads case INS_ldrb: return INS_ldapurb; @@ -1823,7 +1823,7 @@ instruction CodeGen::genGetVolatileLdStIns(instruction currentIns, case INS_ldr: return INS_ldapur; - // Stores + // Stores case INS_strb: return INS_stlurb; @@ -1855,7 +1855,7 @@ instruction CodeGen::genGetVolatileLdStIns(instruction currentIns, const bool hasRcpc1 = compiler->compOpportunisticallyDependsOn(InstructionSet_Rcpc); switch (currentIns) { - // Loads + // Loads case INS_ldrb: return hasRcpc1 ? INS_ldaprb : INS_ldarb; @@ -1866,7 +1866,7 @@ instruction CodeGen::genGetVolatileLdStIns(instruction currentIns, case INS_ldr: return hasRcpc1 ? INS_ldapr : INS_ldar; - // Stores + // Stores case INS_strb: return INS_stlrb; @@ -2244,9 +2244,7 @@ class BlockUnrollHelper class InitBlockUnrollHelper { public: - InitBlockUnrollHelper(int dstOffset, unsigned byteCount) : dstStartOffset(dstOffset), byteCount(byteCount) - { - } + InitBlockUnrollHelper(int dstOffset, unsigned byteCount) : dstStartOffset(dstOffset), byteCount(byteCount) {} int GetDstOffset() const { @@ -3090,7 +3088,8 @@ void CodeGen::genCodeForMemmove(GenTreeBlk* tree) regNumber src = genConsumeReg(srcIndir->Addr()); unsigned size = tree->Size(); - auto emitLoadStore = [&](bool load, unsigned regSize, regNumber tempReg, unsigned offset) { + auto emitLoadStore = [&](bool load, unsigned regSize, regNumber tempReg, unsigned offset) + { var_types memType; switch (regSize) { @@ -3139,7 +3138,8 @@ void CodeGen::genCodeForMemmove(GenTreeBlk* tree) tempRegs[i] = tree->ExtractTempReg(RBM_ALLFLOAT); } - auto emitSimdLoadStore = [&](bool load) { + auto emitSimdLoadStore = [&](bool load) + { unsigned offset = 0; int regIndex = 0; do @@ -3432,13 +3432,13 @@ void CodeGen::genCall(GenTreeCall* call) else #endif // TARGET_ARM if (varTypeUsesFloatArgReg(returnType)) - { - returnReg = REG_FLOATRET; - } - else - { - returnReg = REG_INTRET; - } + { + returnReg = REG_FLOATRET; + } + else + { + returnReg = REG_INTRET; + } if (call->GetRegNum() != returnReg) { @@ -3694,19 +3694,19 @@ void CodeGen::genCallInstruction(GenTreeCall* call) else #endif // FEATURE_READYTORUN if (call->gtCallType == CT_HELPER) - { - CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd); - noway_assert(helperNum != CORINFO_HELP_UNDEF); + { + CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd); + noway_assert(helperNum != CORINFO_HELP_UNDEF); - void* pAddr = nullptr; - addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr); - assert(pAddr == nullptr); - } - else - { - // Direct call to a non-virtual user function. - addr = call->gtDirectCallAddress; - } + void* pAddr = nullptr; + addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr); + assert(pAddr == nullptr); + } + else + { + // Direct call to a non-virtual user function. + addr = call->gtDirectCallAddress; + } assert(addr != nullptr); @@ -4372,8 +4372,8 @@ void CodeGen::genFloatToFloatCast(GenTree* treeNode) //------------------------------------------------------------------------ // genCreateAndStoreGCInfo: Create and record GC Info for the function. // -void CodeGen::genCreateAndStoreGCInfo(unsigned codeSize, - unsigned prologSize, +void CodeGen::genCreateAndStoreGCInfo(unsigned codeSize, + unsigned prologSize, unsigned epilogSize DEBUGARG(void* codePtr)) { IAllocator* allowZeroAlloc = new (compiler, CMK_GC) CompIAllocator(compiler->getAllocatorGC()); @@ -5529,9 +5529,8 @@ void CodeGen::genFnEpilog(BasicBlock* block) compiler->unwindSetFrameReg(REG_SAVED_LOCALLOC_SP, 0); } - if (jmpEpilog || - genStackAllocRegisterMask(compiler->compLclFrameSize, regSet.rsGetModifiedRegsMask() & RBM_FLT_CALLEE_SAVED) == - RBM_NONE) + if (jmpEpilog || genStackAllocRegisterMask(compiler->compLclFrameSize, + regSet.rsGetModifiedRegsMask() & RBM_FLT_CALLEE_SAVED) == RBM_NONE) { genFreeLclFrame(compiler->compLclFrameSize, &unwindStarted); } @@ -5603,9 +5602,9 @@ void CodeGen::genFnEpilog(BasicBlock* block) #if !FEATURE_FASTTAILCALL noway_assert(jmpNode->gtOper == GT_JMP); #else // FEATURE_FASTTAILCALL - // armarch - // If jmpNode is GT_JMP then gtNext must be null. - // If jmpNode is a fast tail call, gtNext need not be null since it could have embedded stmts. + // armarch + // If jmpNode is GT_JMP then gtNext must be null. + // If jmpNode is a fast tail call, gtNext need not be null since it could have embedded stmts. noway_assert((jmpNode->gtOper != GT_JMP) || (jmpNode->gtNext == nullptr)); // Could either be a "jmp method" or "fast tail call" implemented as epilog+jmp diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index a62bcde9e556d0..30fcd2532436ad 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -1873,7 +1873,7 @@ void CodeGen::genGenerateMachineCode() (compiler->compCodeOpt() != Compiler::SMALL_CODE) && !compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT) #endif - ); + ); /* Now generate code for the function */ genCodeForBBlist(); @@ -3199,9 +3199,9 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere #ifdef TARGET_X86 noway_assert(varDsc->lvType == TYP_STRUCT); #else // !TARGET_X86 - // For LSRA, it may not be in regArgMaskLive if it has a zero - // refcnt. This is in contrast with the non-LSRA case in which all - // non-tracked args are assumed live on entry. + // For LSRA, it may not be in regArgMaskLive if it has a zero + // refcnt. This is in contrast with the non-LSRA case in which all + // non-tracked args are assumed live on entry. noway_assert((varDsc->lvRefCnt() == 0) || (varDsc->lvType == TYP_STRUCT) || (varDsc->IsAddressExposed() && compiler->info.compIsVarArgs) || (varDsc->IsAddressExposed() && compiler->opts.compUseSoftFP)); @@ -4131,8 +4131,8 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere int nextArgNum = argNum + i; LclVarDsc* fieldVarDsc = compiler->lvaGetDesc(varDsc->lvFieldLclStart + i); regNumber nextRegNum = genMapRegArgNumToRegNum(nextArgNum, regArgTab[nextArgNum].type, - compiler->info.compCallConv); - destRegNum = fieldVarDsc->GetRegNum(); + compiler->info.compCallConv); + destRegNum = fieldVarDsc->GetRegNum(); noway_assert(regArgTab[nextArgNum].varNum == varNum); noway_assert(genIsValidFloatReg(nextRegNum)); noway_assert(genIsValidFloatReg(destRegNum)); @@ -4215,7 +4215,7 @@ void CodeGen::genEnregisterIncomingStackArgs() regNumber tmp_reg = REG_NA; #endif - for (LclVarDsc *varDsc = compiler->lvaTable; varNum < compiler->lvaCount; varNum++, varDsc++) + for (LclVarDsc* varDsc = compiler->lvaTable; varNum < compiler->lvaCount; varNum++, varDsc++) { /* Is this variable a parameter? */ @@ -4289,7 +4289,7 @@ void CodeGen::genEnregisterIncomingStackArgs() } } } -#else // !TARGET_LOONGARCH64 +#else // !TARGET_LOONGARCH64 GetEmitter()->emitIns_R_S(ins_Load(regType), emitTypeSize(regType), regNum, varNum, 0); #endif // !TARGET_LOONGARCH64 @@ -5342,7 +5342,7 @@ void CodeGen::genFinalizeFrame() } noway_assert((regSet.rsGetModifiedRegsMask() & ~okRegs) == 0); #else // !TARGET_AMD64 && !TARGET_ARM64 - // On x86 we save all callee saved regs so the saved reg area size is consistent + // On x86 we save all callee saved regs so the saved reg area size is consistent regSet.rsSetRegsModified(RBM_INT_CALLEE_SAVED & ~RBM_FPBASE); #endif // !TARGET_AMD64 && !TARGET_ARM64 } @@ -6071,7 +6071,7 @@ void CodeGen::genFnProlog() } #endif // TARGET_AMD64 -//------------------------------------------------------------------------- + //------------------------------------------------------------------------- #ifdef TARGET_ARM if (compiler->compLocallocUsed) @@ -6097,11 +6097,11 @@ void CodeGen::genFnProlog() #endif // TARGET_AMD64 compiler->unwindEndProlog(); -//------------------------------------------------------------------------- -// -// This is the end of the OS-reported prolog for purposes of unwinding -// -//------------------------------------------------------------------------- + //------------------------------------------------------------------------- + // + // This is the end of the OS-reported prolog for purposes of unwinding + // + //------------------------------------------------------------------------- #ifdef TARGET_ARM if (needToEstablishFP) @@ -6251,7 +6251,8 @@ void CodeGen::genFnProlog() genFnPrologCalleeRegArgs(); } #else - auto assignIncomingRegisterArgs = [this, initReg, &initRegZeroed](RegState* regState) { + auto assignIncomingRegisterArgs = [this, initReg, &initRegZeroed](RegState* regState) + { if (regState->rsCalleeRegArgMaskLiveIn) { // If we need an extra register to shuffle around the incoming registers @@ -7325,7 +7326,8 @@ void CodeGen::genReportRichDebugInfoInlineTreeToFile(FILE* file, InlineContext* fprintf(file, "\"ILOffset\":%u,", context->GetLocation().GetOffset()); fprintf(file, "\"LocationFlags\":%u,", (uint32_t)context->GetLocation().EncodeSourceTypes()); fprintf(file, "\"ExactILOffset\":%u,", context->GetActualCallOffset()); - auto append = [&]() { + auto append = [&]() + { char buffer[256]; const char* methodName = compiler->eeGetMethodName(context->GetCallee(), buffer, sizeof(buffer)); fprintf(file, "\"MethodName\":\"%s\",", methodName); @@ -8488,7 +8490,7 @@ void CodeGen::genPoisonFrame(regMaskTP regLiveIn) bool fpBased; int addr = compiler->lvaFrameAddress((int)varNum, &fpBased); #else - int addr = 0; + int addr = 0; #endif int end = addr + (int)size; for (int offs = addr; offs < end;) diff --git a/src/coreclr/jit/codegeninterface.h b/src/coreclr/jit/codegeninterface.h index 63954adc6ffbb3..5a228a73eca160 100644 --- a/src/coreclr/jit/codegeninterface.h +++ b/src/coreclr/jit/codegeninterface.h @@ -165,8 +165,8 @@ class CodeGenInterface TreeLifeUpdater* treeLifeUpdater; public: - bool genUseOptimizedWriteBarriers(GCInfo::WriteBarrierForm wbf); - bool genUseOptimizedWriteBarriers(GenTreeStoreInd* store); + bool genUseOptimizedWriteBarriers(GCInfo::WriteBarrierForm wbf); + bool genUseOptimizedWriteBarriers(GenTreeStoreInd* store); CorInfoHelpFunc genWriteBarrierHelperForWriteBarrierForm(GCInfo::WriteBarrierForm wbf); #ifdef DEBUG @@ -442,7 +442,8 @@ class CodeGenInterface { siVarLocType vlType; - union { + union + { // VLT_REG/VLT_REG_FP -- Any pointer-sized enregistered value (TYP_INT, TYP_REF, etc) // eg. EAX // VLT_REG_BYREF -- the specified register contains the address of the variable @@ -756,7 +757,7 @@ class CodeGenInterface LiveRangeList* getLiveRangesForVarForBody(unsigned int varNum) const; LiveRangeList* getLiveRangesForVarForProlog(unsigned int varNum) const; - size_t getLiveRangesCount() const; + size_t getLiveRangesCount() const; // For parameters locations on prolog void psiStartVariableLiveRange(CodeGenInterface::siVarLoc varLocation, unsigned int varNum); diff --git a/src/coreclr/jit/codegenlinear.cpp b/src/coreclr/jit/codegenlinear.cpp index 5e05f1b0819829..3176808d02c7ae 100644 --- a/src/coreclr/jit/codegenlinear.cpp +++ b/src/coreclr/jit/codegenlinear.cpp @@ -156,8 +156,8 @@ void CodeGen::genCodeForBBlist() genMarkLabelsForCodegen(); - assert(!compiler->fgFirstBBScratch || - compiler->fgFirstBB == compiler->fgFirstBBScratch); // compiler->fgFirstBBScratch has to be first. + assert(!compiler->fgFirstBBScratch || compiler->fgFirstBB == compiler->fgFirstBBScratch); // compiler->fgFirstBBScratch + // has to be first. /* Initialize structures used in the block list iteration */ genInitialize(); @@ -622,7 +622,7 @@ void CodeGen::genCodeForBBlist() case BBJ_THROW: case BBJ_CALLFINALLY: case BBJ_EHCATCHRET: - // We're going to generate more code below anyway, so no need for the NOP. + // We're going to generate more code below anyway, so no need for the NOP. case BBJ_RETURN: case BBJ_EHFINALLYRET: @@ -633,7 +633,7 @@ void CodeGen::genCodeForBBlist() case BBJ_COND: case BBJ_SWITCH: - // These can't have a call as the last instruction! + // These can't have a call as the last instruction! default: noway_assert(!"Unexpected bbKind"); @@ -644,7 +644,8 @@ void CodeGen::genCodeForBBlist() #endif // TARGET_AMD64 #if FEATURE_LOOP_ALIGN - auto SetLoopAlignBackEdge = [=](const BasicBlock* block, const BasicBlock* target) { + auto SetLoopAlignBackEdge = [=](const BasicBlock* block, const BasicBlock* target) + { // This is the last place where we operate on blocks and after this, we operate // on IG. Hence, if we know that the destination of "block" is the first block // of a loop and that loop needs alignment (it has BBF_LOOP_ALIGN), then "block" @@ -1868,8 +1869,8 @@ void CodeGen::genPutArgStkFieldList(GenTreePutArgStk* putArgStk, unsigned outArg var_types type = use.GetType(); unsigned thisFieldOffset = argOffset + use.GetOffset(); -// Emit store instructions to store the registers produced by the GT_FIELD_LIST into the outgoing -// argument area. + // Emit store instructions to store the registers produced by the GT_FIELD_LIST into the outgoing + // argument area. #if defined(FEATURE_SIMD) if (type == TYP_SIMD12) diff --git a/src/coreclr/jit/codegenloongarch64.cpp b/src/coreclr/jit/codegenloongarch64.cpp index a99199aedc634c..ec27d2ff8ab4da 100644 --- a/src/coreclr/jit/codegenloongarch64.cpp +++ b/src/coreclr/jit/codegenloongarch64.cpp @@ -1225,9 +1225,9 @@ void CodeGen::genFnEpilog(BasicBlock* block) #if !FEATURE_FASTTAILCALL noway_assert(jmpNode->gtOper == GT_JMP); #else // FEATURE_FASTTAILCALL - // armarch - // If jmpNode is GT_JMP then gtNext must be null. - // If jmpNode is a fast tail call, gtNext need not be null since it could have embedded stmts. + // armarch + // If jmpNode is GT_JMP then gtNext must be null. + // If jmpNode is a fast tail call, gtNext need not be null since it could have embedded stmts. noway_assert((jmpNode->gtOper != GT_JMP) || (jmpNode->gtNext == nullptr)); // Could either be a "jmp method" or "fast tail call" implemented as epilog+jmp @@ -1573,9 +1573,9 @@ void CodeGen::genEHCatchRet(BasicBlock* block) } // move an immediate value into an integer register -void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, - regNumber reg, - ssize_t imm, +void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, + regNumber reg, + ssize_t imm, insFlags flags DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { emitter* emit = GetEmitter(); @@ -3334,7 +3334,7 @@ void CodeGen::genCodeForReturnTrap(GenTreeOp* tree) callTarget, /* ireg */ REG_NA, 0, 0, /* xreg, xmul, disp */ false /* isJump */ - ); + ); regMaskTP killMask = compiler->compHelperCallKillSet(CORINFO_HELP_STOP_FOR_GC); regSet.verifyRegistersUsed(killMask); @@ -4398,7 +4398,7 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, callTarget, /* ireg */ REG_NA, 0, 0, /* xreg, xmul, disp */ false /* isJump */ - ); + ); regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper); regSet.verifyRegistersUsed(killMask); @@ -6648,19 +6648,19 @@ void CodeGen::genCallInstruction(GenTreeCall* call) else #endif // FEATURE_READYTORUN if (call->gtCallType == CT_HELPER) - { - CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd); - noway_assert(helperNum != CORINFO_HELP_UNDEF); + { + CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd); + noway_assert(helperNum != CORINFO_HELP_UNDEF); - void* pAddr = nullptr; - addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr); - assert(pAddr == nullptr); - } - else - { - // Direct call to a non-virtual user function. - addr = call->gtDirectCallAddress; - } + void* pAddr = nullptr; + addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr); + assert(pAddr == nullptr); + } + else + { + // Direct call to a non-virtual user function. + addr = call->gtDirectCallAddress; + } assert(addr != nullptr); @@ -7093,8 +7093,8 @@ void CodeGen::genFloatToFloatCast(GenTree* treeNode) //------------------------------------------------------------------------ // genCreateAndStoreGCInfo: Create and record GC Info for the function. // -void CodeGen::genCreateAndStoreGCInfo(unsigned codeSize, - unsigned prologSize, +void CodeGen::genCreateAndStoreGCInfo(unsigned codeSize, + unsigned prologSize, unsigned epilogSize DEBUGARG(void* codePtr)) { IAllocator* allowZeroAlloc = new (compiler, CMK_GC) CompIAllocator(compiler->getAllocatorGC()); @@ -7615,7 +7615,7 @@ inline void CodeGen::genJumpToThrowHlpBlk_la( callTarget, /* ireg */ REG_NA, 0, 0, /* xreg, xmul, disp */ false /* isJump */ - ); + ); regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)(compiler->acdHelper(codeKind))); regSet.verifyRegistersUsed(killMask); diff --git a/src/coreclr/jit/codegenriscv64.cpp b/src/coreclr/jit/codegenriscv64.cpp index 87745fabe3e04b..1d48582c6c316e 100644 --- a/src/coreclr/jit/codegenriscv64.cpp +++ b/src/coreclr/jit/codegenriscv64.cpp @@ -1212,9 +1212,9 @@ void CodeGen::genFnEpilog(BasicBlock* block) #if !FEATURE_FASTTAILCALL noway_assert(jmpNode->gtOper == GT_JMP); #else // FEATURE_FASTTAILCALL - // armarch - // If jmpNode is GT_JMP then gtNext must be null. - // If jmpNode is a fast tail call, gtNext need not be null since it could have embedded stmts. + // armarch + // If jmpNode is GT_JMP then gtNext must be null. + // If jmpNode is a fast tail call, gtNext need not be null since it could have embedded stmts. noway_assert((jmpNode->gtOper != GT_JMP) || (jmpNode->gtNext == nullptr)); // Could either be a "jmp method" or "fast tail call" implemented as epilog+jmp @@ -1534,9 +1534,9 @@ void CodeGen::genEHCatchRet(BasicBlock* block) } // move an immediate value into an integer register -void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, - regNumber reg, - ssize_t imm, +void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, + regNumber reg, + ssize_t imm, insFlags flags DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { emitter* emit = GetEmitter(); @@ -3338,7 +3338,7 @@ void CodeGen::genCodeForReturnTrap(GenTreeOp* tree) callTarget, /* ireg */ REG_NA, 0, 0, /* xreg, xmul, disp */ false /* isJump */ - ); + ); regMaskTP killMask = compiler->compHelperCallKillSet(CORINFO_HELP_STOP_FOR_GC); regSet.verifyRegistersUsed(killMask); @@ -4359,7 +4359,7 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, callTarget, /* ireg */ REG_NA, 0, 0, /* xreg, xmul, disp */ false /* isJump */ - ); + ); regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper); regSet.verifyRegistersUsed(killMask); @@ -6724,19 +6724,19 @@ void CodeGen::genCallInstruction(GenTreeCall* call) else #endif // FEATURE_READYTORUN if (call->gtCallType == CT_HELPER) - { - CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd); - noway_assert(helperNum != CORINFO_HELP_UNDEF); + { + CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd); + noway_assert(helperNum != CORINFO_HELP_UNDEF); - void* pAddr = nullptr; - addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr); - assert(pAddr == nullptr); - } - else - { - // Direct call to a non-virtual user function. - addr = call->gtDirectCallAddress; - } + void* pAddr = nullptr; + addr = compiler->compGetHelperFtn(helperNum, (void**)&pAddr); + assert(pAddr == nullptr); + } + else + { + // Direct call to a non-virtual user function. + addr = call->gtDirectCallAddress; + } assert(addr != nullptr); @@ -7163,8 +7163,8 @@ void CodeGen::genFloatToFloatCast(GenTree* treeNode) //------------------------------------------------------------------------ // genCreateAndStoreGCInfo: Create and record GC Info for the function. // -void CodeGen::genCreateAndStoreGCInfo(unsigned codeSize, - unsigned prologSize, +void CodeGen::genCreateAndStoreGCInfo(unsigned codeSize, + unsigned prologSize, unsigned epilogSize DEBUGARG(void* codePtr)) { IAllocator* allowZeroAlloc = new (compiler, CMK_GC) CompIAllocator(compiler->getAllocatorGC()); @@ -7683,7 +7683,7 @@ void CodeGen::genJumpToThrowHlpBlk_la( callTarget, /* ireg */ REG_NA, 0, 0, /* xreg, xmul, disp */ false /* isJump */ - ); + ); regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)(compiler->acdHelper(codeKind))); regSet.verifyRegistersUsed(killMask); diff --git a/src/coreclr/jit/codegenxarch.cpp b/src/coreclr/jit/codegenxarch.cpp index 314346300b0056..e282c7df4f4812 100644 --- a/src/coreclr/jit/codegenxarch.cpp +++ b/src/coreclr/jit/codegenxarch.cpp @@ -156,9 +156,9 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg) regGSCheck = REG_EAX; regMaskGSCheck = RBM_EAX; #else // !TARGET_X86 - // Jmp calls: specify method handle using which JIT queries VM for its entry point - // address and hence it can neither be a VSD call nor PInvoke calli with cookie - // parameter. Therefore, in case of jmp calls it is safe to use R11. + // Jmp calls: specify method handle using which JIT queries VM for its entry point + // address and hence it can neither be a VSD call nor PInvoke calli with cookie + // parameter. Therefore, in case of jmp calls it is safe to use R11. regGSCheck = REG_R11; #endif // !TARGET_X86 } @@ -387,9 +387,9 @@ void CodeGen::genEHFinallyOrFilterRet(BasicBlock* block) // Move an immediate value into an integer register -void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, - regNumber reg, - ssize_t imm, +void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, + regNumber reg, + ssize_t imm, insFlags flags DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { // reg cannot be a FP register @@ -2158,8 +2158,8 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode) // The last slot is reserved for ICodeManager::FixContext(ppEndRegion) unsigned filterEndOffsetSlotOffs; - PREFIX_ASSUME(compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) > - TARGET_POINTER_SIZE); // below doesn't underflow. + PREFIX_ASSUME(compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) > TARGET_POINTER_SIZE); // below doesn't + // underflow. filterEndOffsetSlotOffs = (unsigned)(compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) - TARGET_POINTER_SIZE); @@ -2677,7 +2677,8 @@ void CodeGen::genCodeForMemmove(GenTreeBlk* tree) tempRegs[i] = tree->ExtractTempReg(RBM_ALLFLOAT); } - auto emitSimdLoadStore = [&](bool load) { + auto emitSimdLoadStore = [&](bool load) + { unsigned offset = 0; int regIndex = 0; instruction simdMov = simdUnalignedMovIns(); @@ -2723,7 +2724,8 @@ void CodeGen::genCodeForMemmove(GenTreeBlk* tree) // Here we work with size 1..15 (x64) assert((size > 0) && (size < XMM_REGSIZE_BYTES)); - auto emitScalarLoadStore = [&](bool load, int size, regNumber tempReg, int offset) { + auto emitScalarLoadStore = [&](bool load, int size, regNumber tempReg, int offset) + { var_types memType; switch (size) { @@ -3233,7 +3235,8 @@ void CodeGen::genCodeForInitBlkUnroll(GenTreeBlk* node) instruction simdMov = simdUnalignedMovIns(); unsigned bytesWritten = 0; - auto emitSimdMovs = [&]() { + auto emitSimdMovs = [&]() + { if (dstLclNum != BAD_VAR_NUM) { emit->emitIns_S_R(simdMov, EA_ATTR(regSize), srcXmmReg, dstLclNum, dstOffset); @@ -3524,7 +3527,8 @@ void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* node) instruction simdMov = simdUnalignedMovIns(); - auto emitSimdMovs = [&]() { + auto emitSimdMovs = [&]() + { if (srcLclNum != BAD_VAR_NUM) { emit->emitIns_R_S(simdMov, EA_ATTR(regSize), tempReg, srcLclNum, srcOffset); @@ -6093,13 +6097,13 @@ void CodeGen::genCall(GenTreeCall* call) else #endif // TARGET_X86 if (varTypeIsFloating(returnType)) - { - returnReg = REG_FLOATRET; - } - else - { - returnReg = REG_INTRET; - } + { + returnReg = REG_FLOATRET; + } + else + { + returnReg = REG_INTRET; + } inst_Mov(returnType, call->GetRegNum(), returnReg, /* canSkip */ true); } @@ -8040,8 +8044,8 @@ void CodeGen::genIntrinsic(GenTreeIntrinsic* treeNode) } #if defined(FEATURE_SIMD) - // The handling is a bit more complex so genSimdUpperSave/Restore - // handles genConsumeOperands and genProduceReg + // The handling is a bit more complex so genSimdUpperSave/Restore + // handles genConsumeOperands and genProduceReg case NI_SIMD_UpperRestore: { @@ -8111,7 +8115,7 @@ unsigned CodeGen::getBaseVarForPutArgStk(GenTree* treeNode) #ifdef UNIX_AMD64_ABI assert(!varDsc->lvIsRegArg && varDsc->GetArgReg() == REG_STK); #else // !UNIX_AMD64_ABI - // On Windows this assert is always true. The first argument will always be in REG_ARG_0 or REG_FLTARG_0. + // On Windows this assert is always true. The first argument will always be in REG_ARG_0 or REG_FLTARG_0. assert(varDsc->lvIsRegArg && (varDsc->GetArgReg() == REG_ARG_0 || varDsc->GetArgReg() == REG_FLTARG_0)); #endif // !UNIX_AMD64_ABI #endif // !DEBUG @@ -8584,7 +8588,7 @@ void CodeGen::genPutArgStk(GenTreePutArgStk* putArgStk) unsigned argOffset = putArgStk->getArgOffset(); #ifdef DEBUG - CallArg* callArg = putArgStk->gtCall->gtArgs.FindByNode(putArgStk); + CallArg* callArg = putArgStk->gtCall->gtArgs.FindByNode(putArgStk); assert(callArg != nullptr); assert(argOffset == callArg->AbiInfo.ByteOffset); #endif @@ -8837,8 +8841,8 @@ CodeGen::genCreateAndStoreGCInfo(unsigned codeSize, unsigned prologSize, unsigne } #ifdef JIT32_GCENCODER -void* CodeGen::genCreateAndStoreGCInfoJIT32(unsigned codeSize, - unsigned prologSize, +void* CodeGen::genCreateAndStoreGCInfoJIT32(unsigned codeSize, + unsigned prologSize, unsigned epilogSize DEBUGARG(void* codePtr)) { BYTE headerBuf[64]; @@ -9240,8 +9244,8 @@ void CodeGen::genProfilingEnterCallback(regNumber initReg, bool* pInitRegZeroed) unsigned saveStackLvl2 = genStackLevel; -// Important note: when you change enter probe layout, you must also update SKIP_ENTER_PROF_CALLBACK() -// for x86 stack unwinding + // Important note: when you change enter probe layout, you must also update SKIP_ENTER_PROF_CALLBACK() + // for x86 stack unwinding #if defined(UNIX_X86_ABI) // Manually align the stack to be 16-byte aligned. This is similar to CodeGen::genAlignStackBeforeCall() @@ -10203,7 +10207,7 @@ void CodeGen::genFnEpilog(BasicBlock* block) // do an LEA to "pop off" the frame allocation. needLea = true; #else // !TARGET_AMD64 - // We will just generate "mov esp, ebp" and be done with it. + // We will just generate "mov esp, ebp" and be done with it. needMovEspEbp = true; #endif // !TARGET_AMD64 } @@ -10949,8 +10953,8 @@ void CodeGen::genZeroInitFrameUsingBlockInit(int untrLclHi, int untrLclLo, regNu assert(i == alignmentLoBlkSize); } #else // !defined(TARGET_AMD64) - // While we aren't aligning the start, we still want to - // zero anything that is not in a 16 byte chunk at end + // While we aren't aligning the start, we still want to + // zero anything that is not in a 16 byte chunk at end int alignmentBlkSize = blkSize & -XMM_REGSIZE_BYTES; int alignmentHiBlkSize = blkSize - alignmentBlkSize; int alignedLclHi = untrLclLo + alignmentBlkSize; @@ -11129,8 +11133,8 @@ void CodeGen::genPreserveCalleeSavedFltRegs(unsigned lclFrameSize) assert((offset % 16) == 0); instruction copyIns = ins_Copy(TYP_FLOAT); #else // !TARGET_AMD64 - unsigned offset = lclFrameSize - XMM_REGSIZE_BYTES; - instruction copyIns = INS_movupd; + unsigned offset = lclFrameSize - XMM_REGSIZE_BYTES; + instruction copyIns = INS_movupd; #endif // !TARGET_AMD64 for (regNumber reg = REG_FLT_CALLEE_SAVED_FIRST; regMask != RBM_NONE; reg = REG_NEXT(reg)) diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 0e75f2073dc5e0..676135b10b6246 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -645,11 +645,11 @@ var_types Compiler::getArgTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, // have a struct that is larger than that. // if (structSize <= MAX_PASS_SINGLEREG_BYTES) - { - // We set the "primitive" useType based upon the structSize - // and also examine the clsHnd to see if it is an HFA of count one - useType = getPrimitiveTypeForStruct(structSize, clsHnd, isVarArg); - } + { + // We set the "primitive" useType based upon the structSize + // and also examine the clsHnd to see if it is an HFA of count one + useType = getPrimitiveTypeForStruct(structSize, clsHnd, isVarArg); + } #else if (isTrivialPointerSizedStruct(clsHnd)) { @@ -1157,9 +1157,7 @@ struct FileLine unsigned m_line; char* m_condStr; - FileLine() : m_file(nullptr), m_line(0), m_condStr(nullptr) - { - } + FileLine() : m_file(nullptr), m_line(0), m_condStr(nullptr) {} FileLine(const char* file, unsigned line, const char* condStr) : m_line(line) { @@ -1200,7 +1198,7 @@ struct FileLine }; typedef JitHashTable FileLineToCountMap; -FileLineToCountMap* NowayAssertMap; +FileLineToCountMap* NowayAssertMap; void Compiler::RecordNowayAssert(const char* filename, unsigned line, const char* condStr) { @@ -1233,9 +1231,7 @@ struct NowayAssertCountMap size_t count; FileLine fl; - NowayAssertCountMap() : count(0) - { - } + NowayAssertCountMap() : count(0) {} struct compare { @@ -1459,10 +1455,12 @@ void Compiler::compShutdown() opers[op] = {GenTree::s_gtNodeCounts[op], GenTree::s_gtTrueSizes[op], static_cast(op)}; } - jitstd::sort(opers, opers + ArrLen(opers), [](const OperInfo& l, const OperInfo& r) { - // We'll be sorting in descending order. - return l.Count >= r.Count; - }); + jitstd::sort(opers, opers + ArrLen(opers), + [](const OperInfo& l, const OperInfo& r) + { + // We'll be sorting in descending order. + return l.Count >= r.Count; + }); unsigned remainingCount = totalCount; unsigned remainingCountLarge = 0; @@ -2026,8 +2024,8 @@ void Compiler::compDone() #endif // LATE_DISASM } -void* Compiler::compGetHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ - void** ppIndirection) /* OUT */ +void* Compiler::compGetHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ + void** ppIndirection) /* OUT */ { void* addr; @@ -3406,11 +3404,10 @@ void Compiler::compInitOptions(JitFlags* jitFlags) printf("OPTIONS: OSR variant with entry point 0x%x\n", info.compILEntry); } - printf("OPTIONS: compCodeOpt = %s\n", - (opts.compCodeOpt == BLENDED_CODE) - ? "BLENDED_CODE" - : (opts.compCodeOpt == SMALL_CODE) ? "SMALL_CODE" - : (opts.compCodeOpt == FAST_CODE) ? "FAST_CODE" : "UNKNOWN_CODE"); + printf("OPTIONS: compCodeOpt = %s\n", (opts.compCodeOpt == BLENDED_CODE) ? "BLENDED_CODE" + : (opts.compCodeOpt == SMALL_CODE) ? "SMALL_CODE" + : (opts.compCodeOpt == FAST_CODE) ? "FAST_CODE" + : "UNKNOWN_CODE"); printf("OPTIONS: compDbgCode = %s\n", dspBool(opts.compDbgCode)); printf("OPTIONS: compDbgInfo = %s\n", dspBool(opts.compDbgInfo)); @@ -4011,8 +4008,9 @@ void Compiler::compSetOptimizationLevel() } if (theMinOptsValue == true) { - JITLOG((LL_INFO10000, "IL Code Size,Instr %4d,%4d, Basic Block count %3d, Local Variable Num,Ref count " - "%3d,%3d for method %s\n", + JITLOG((LL_INFO10000, + "IL Code Size,Instr %4d,%4d, Basic Block count %3d, Local Variable Num,Ref count " + "%3d,%3d for method %s\n", info.compILCodeSize, opts.instrCount, fgBBcount, lvaCount, opts.lvRefCount, info.compFullName)); if (JitConfig.JitBreakOnMinOpts() != 0) { @@ -4568,7 +4566,8 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl // Prepare for importation // - auto preImportPhase = [this]() { + auto preImportPhase = [this]() + { if (compIsForInlining()) { // Notify root instance that an inline attempt is about to import IL @@ -4863,8 +4862,8 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl unsigned const preMorphBBCount = fgBBcount; DoPhase(this, PHASE_MORPH_GLOBAL, &Compiler::fgMorphBlocks); - auto postMorphPhase = [this]() { - + auto postMorphPhase = [this]() + { // Fix any LclVar annotations on discarded struct promotion temps for implicit by-ref args fgMarkDemotedImplicitByRefArgs(); lvaRefCountState = RCS_INVALID; @@ -5421,17 +5420,19 @@ bool Compiler::shouldAlignLoop(FlowGraphNaturalLoop* loop, BasicBlock* top) return false; } - bool hasCall = loop->VisitLoopBlocks([](BasicBlock* block) { - for (GenTree* tree : LIR::AsRange(block)) - { - if (tree->IsCall()) - { - return BasicBlockVisit::Abort; - } - } + bool hasCall = loop->VisitLoopBlocks( + [](BasicBlock* block) + { + for (GenTree* tree : LIR::AsRange(block)) + { + if (tree->IsCall()) + { + return BasicBlockVisit::Abort; + } + } - return BasicBlockVisit::Continue; - }) == BasicBlockVisit::Abort; + return BasicBlockVisit::Continue; + }) == BasicBlockVisit::Abort; if (hasCall) { @@ -5994,9 +5995,7 @@ void Compiler::RecomputeFlowGraphAnnotations() } /*****************************************************************************/ -void Compiler::ProcessShutdownWork(ICorStaticInfo* statInfo) -{ -} +void Compiler::ProcessShutdownWork(ICorStaticInfo* statInfo) {} /*****************************************************************************/ @@ -6171,12 +6170,12 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr, // We need to assume, by default, that all flags coming from the VM are invalid. instructionSetFlags.Reset(); -// We then add each available instruction set for the target architecture provided -// that the corresponding JitConfig switch hasn't explicitly asked for it to be -// disabled. This allows us to default to "everything" supported for altjit scenarios -// while also still allowing instruction set opt-out providing users with the ability -// to, for example, see and debug ARM64 codegen for any desired CPU configuration without -// needing to have the hardware in question. + // We then add each available instruction set for the target architecture provided + // that the corresponding JitConfig switch hasn't explicitly asked for it to be + // disabled. This allows us to default to "everything" supported for altjit scenarios + // while also still allowing instruction set opt-out providing users with the ability + // to, for example, see and debug ARM64 codegen for any desired CPU configuration without + // needing to have the hardware in question. #if defined(TARGET_ARM64) if (JitConfig.EnableHWIntrinsic() != 0) @@ -7949,112 +7948,105 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd, #endif param.result = result; - setErrorTrap(compHnd, Param*, pParamOuter, ¶m) - { - setErrorTrap(nullptr, Param*, pParam, pParamOuter) - { - if (pParam->inlineInfo) - { - // Lazily create the inlinee compiler object - if (pParam->inlineInfo->InlinerCompiler->InlineeCompiler == nullptr) - { - pParam->inlineInfo->InlinerCompiler->InlineeCompiler = - (Compiler*)pParam->pAlloc->allocateMemory(roundUp(sizeof(*pParam->pComp))); - } + setErrorTrap(compHnd, Param*, pParamOuter, ¶m){setErrorTrap(nullptr, Param*, pParam, pParamOuter){ + if (pParam->inlineInfo){// Lazily create the inlinee compiler object + if (pParam->inlineInfo->InlinerCompiler->InlineeCompiler == nullptr){ + pParam->inlineInfo->InlinerCompiler->InlineeCompiler = + (Compiler*)pParam->pAlloc->allocateMemory(roundUp(sizeof(*pParam->pComp))); +} - // Use the inlinee compiler object - pParam->pComp = pParam->inlineInfo->InlinerCompiler->InlineeCompiler; +// Use the inlinee compiler object +pParam->pComp = pParam->inlineInfo->InlinerCompiler->InlineeCompiler; #ifdef DEBUG // memset(pParam->pComp, 0xEE, sizeof(Compiler)); #endif - } - else - { - // Allocate create the inliner compiler object - pParam->pComp = (Compiler*)pParam->pAlloc->allocateMemory(roundUp(sizeof(*pParam->pComp))); - } +} +else +{ + // Allocate create the inliner compiler object + pParam->pComp = (Compiler*)pParam->pAlloc->allocateMemory(roundUp(sizeof(*pParam->pComp))); +} #if MEASURE_CLRAPI_CALLS - pParam->wrapCLR = WrapICorJitInfo::makeOne(pParam->pAlloc, pParam->pComp, pParam->compHnd); +pParam->wrapCLR = WrapICorJitInfo::makeOne(pParam->pAlloc, pParam->pComp, pParam->compHnd); #endif - // push this compiler on the stack (TLS) - pParam->pComp->prevCompiler = JitTls::GetCompiler(); - JitTls::SetCompiler(pParam->pComp); +// push this compiler on the stack (TLS) +pParam->pComp->prevCompiler = JitTls::GetCompiler(); +JitTls::SetCompiler(pParam->pComp); // PREFIX_ASSUME gets turned into ASSERT_CHECK and we cannot have it here #if defined(_PREFAST_) || defined(_PREFIX_) - PREFIX_ASSUME(pParam->pComp != NULL); +PREFIX_ASSUME(pParam->pComp != NULL); #else - assert(pParam->pComp != nullptr); +assert(pParam->pComp != nullptr); #endif - pParam->pComp->compInit(pParam->pAlloc, pParam->methodHnd, pParam->compHnd, pParam->methodInfo, - pParam->inlineInfo); +pParam->pComp->compInit(pParam->pAlloc, pParam->methodHnd, pParam->compHnd, pParam->methodInfo, pParam->inlineInfo); #ifdef DEBUG - pParam->pComp->jitFallbackCompile = pParam->jitFallbackCompile; +pParam->pComp->jitFallbackCompile = pParam->jitFallbackCompile; #endif - // Now generate the code - pParam->result = pParam->pComp->compCompile(pParam->classPtr, pParam->methodCodePtr, pParam->methodCodeSize, - pParam->compileFlags); - } - finallyErrorTrap() - { - Compiler* pCompiler = pParamOuter->pComp; +// Now generate the code +pParam->result = + pParam->pComp->compCompile(pParam->classPtr, pParam->methodCodePtr, pParam->methodCodeSize, pParam->compileFlags); +} +finallyErrorTrap() +{ + Compiler* pCompiler = pParamOuter->pComp; - // If OOM is thrown when allocating memory for a pComp, we will end up here. - // For this case, pComp and also pCompiler will be a nullptr - // - if (pCompiler != nullptr) - { - pCompiler->info.compCode = nullptr; + // If OOM is thrown when allocating memory for a pComp, we will end up here. + // For this case, pComp and also pCompiler will be a nullptr + // + if (pCompiler != nullptr) + { + pCompiler->info.compCode = nullptr; - // pop the compiler off the TLS stack only if it was linked above - assert(JitTls::GetCompiler() == pCompiler); - JitTls::SetCompiler(pCompiler->prevCompiler); - } + // pop the compiler off the TLS stack only if it was linked above + assert(JitTls::GetCompiler() == pCompiler); + JitTls::SetCompiler(pCompiler->prevCompiler); + } - if (pParamOuter->inlineInfo == nullptr) - { - // Free up the allocator we were using - pParamOuter->pAlloc->destroy(); - } - } - endErrorTrap() + if (pParamOuter->inlineInfo == nullptr) + { + // Free up the allocator we were using + pParamOuter->pAlloc->destroy(); } - impJitErrorTrap() +} +endErrorTrap() +} +impJitErrorTrap() +{ + // If we were looking at an inlinee.... + if (inlineInfo != nullptr) { - // If we were looking at an inlinee.... - if (inlineInfo != nullptr) - { - // Note that we failed to compile the inlinee, and that - // there's no point trying to inline it again anywhere else. - inlineInfo->inlineResult->NoteFatal(InlineObservation::CALLEE_COMPILATION_ERROR); - } - param.result = __errc; + // Note that we failed to compile the inlinee, and that + // there's no point trying to inline it again anywhere else. + inlineInfo->inlineResult->NoteFatal(InlineObservation::CALLEE_COMPILATION_ERROR); } - endErrorTrap() + param.result = __errc; +} +endErrorTrap() - result = param.result; + result = param.result; - if (!inlineInfo && - (result == CORJIT_INTERNALERROR || result == CORJIT_RECOVERABLEERROR || result == CORJIT_IMPLLIMITATION) && - !jitFallbackCompile) - { - // If we failed the JIT, reattempt with debuggable code. - jitFallbackCompile = true; +if (!inlineInfo && + (result == CORJIT_INTERNALERROR || result == CORJIT_RECOVERABLEERROR || result == CORJIT_IMPLLIMITATION) && + !jitFallbackCompile) +{ + // If we failed the JIT, reattempt with debuggable code. + jitFallbackCompile = true; - // Update the flags for 'safer' code generation. - compileFlags->Set(JitFlags::JIT_FLAG_MIN_OPT); - compileFlags->Clear(JitFlags::JIT_FLAG_SIZE_OPT); - compileFlags->Clear(JitFlags::JIT_FLAG_SPEED_OPT); + // Update the flags for 'safer' code generation. + compileFlags->Set(JitFlags::JIT_FLAG_MIN_OPT); + compileFlags->Clear(JitFlags::JIT_FLAG_SIZE_OPT); + compileFlags->Clear(JitFlags::JIT_FLAG_SPEED_OPT); - goto START; - } + goto START; +} - return result; +return result; } #if defined(UNIX_AMD64_ABI) @@ -8332,9 +8324,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ /*****************************************************************************/ -void codeGeneratorCodeSizeBeg() -{ -} +void codeGeneratorCodeSizeBeg() {} /***************************************************************************** * @@ -8342,9 +8332,7 @@ void codeGeneratorCodeSizeBeg() */ /*****************************************************************************/ -void codeGeneratorCodeSizeEnd() -{ -} +void codeGeneratorCodeSizeEnd() {} /***************************************************************************** * * Gather statistics - mainly used for the standalone @@ -8805,8 +8793,9 @@ void CompTimeSummaryInfo::Print(FILE* f) double pslop_pct = 100.0 * m_total.m_parentPhaseEndSlop * 1000.0 / countsPerSec / totTime_ms; if (pslop_pct >= 1.0) { - fprintf(f, "\n 'End phase slop' should be very small (if not, there's unattributed time): %9.3f Mcycles = " - "%3.1f%% of total.\n\n", + fprintf(f, + "\n 'End phase slop' should be very small (if not, there's unattributed time): %9.3f Mcycles = " + "%3.1f%% of total.\n\n", m_total.m_parentPhaseEndSlop / 1000000.0, pslop_pct); } } @@ -8846,8 +8835,9 @@ void CompTimeSummaryInfo::Print(FILE* f) double fslop_ms = m_filtered.m_parentPhaseEndSlop * 1000.0 / countsPerSec; if (fslop_ms > 1.0) { - fprintf(f, "\n 'End phase slop' should be very small (if not, there's unattributed time): %9.3f Mcycles = " - "%3.1f%% of total.\n\n", + fprintf(f, + "\n 'End phase slop' should be very small (if not, there's unattributed time): %9.3f Mcycles = " + "%3.1f%% of total.\n\n", m_filtered.m_parentPhaseEndSlop / 1000000.0, fslop_ms); } } @@ -9197,7 +9187,7 @@ void JitTimer::PrintCsvMethodStats(Compiler* comp) // for a DEBUG build (presumably not for the time info), just re-use it. const char* methName = comp->info.compFullName; #else - const char* methName = comp->eeGetMethodFullName(comp->info.compMethodHnd); + const char* methName = comp->eeGetMethodFullName(comp->info.compMethodHnd); #endif // Try and access the SPMI index to report in the data set. @@ -10499,10 +10489,12 @@ JITDBGAPI GenTree* __cdecl dFindTreeInTree(GenTree* tree, unsigned id) } GenTree* child = nullptr; - tree->VisitOperands([&child, id](GenTree* operand) -> GenTree::VisitResult { - child = dFindTreeInTree(child, id); - return (child != nullptr) ? GenTree::VisitResult::Abort : GenTree::VisitResult::Continue; - }); + tree->VisitOperands( + [&child, id](GenTree* operand) -> GenTree::VisitResult + { + child = dFindTreeInTree(child, id); + return (child != nullptr) ? GenTree::VisitResult::Abort : GenTree::VisitResult::Continue; + }); return child; } diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index ee89502ce9b62d..af59c4bcb59d4f 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -230,13 +230,9 @@ class LclSsaVarDsc bool m_hasGlobalUse = false; public: - LclSsaVarDsc() - { - } + LclSsaVarDsc() {} - LclSsaVarDsc(BasicBlock* block) : m_block(block) - { - } + LclSsaVarDsc(BasicBlock* block) : m_block(block) {} LclSsaVarDsc(BasicBlock* block, GenTreeLclVarCommon* defNode) : m_block(block) { @@ -363,9 +359,7 @@ class SsaDefArray public: // Construct an empty SsaDefArray. - SsaDefArray() : m_array(nullptr), m_arraySize(0), m_count(0) - { - } + SsaDefArray() : m_array(nullptr), m_arraySize(0), m_count(0) {} // Reset the array (used only if the SSA form is reconstructed). void Reset() @@ -669,7 +663,8 @@ class LclVarDsc unsigned char lvIsSpan : 1; // The local is a Span public: - union { + union + { unsigned lvFieldLclStart; // The index of the local var representing the first field in the promoted struct // local. For implicit byref parameters, this gets hijacked between // fgRetypeImplicitByRefArgs and fgMarkDemotedImplicitByRefArgs to point to the @@ -889,7 +884,7 @@ class LclVarDsc assert(_lvRegNum == reg); } -///////////////////// + ///////////////////// #if defined(TARGET_64BIT) @@ -1075,13 +1070,13 @@ class LclVarDsc public: unsigned short lvRefCnt(RefCountState state = RCS_NORMAL) const; - void incLvRefCnt(unsigned short delta, RefCountState state = RCS_NORMAL); - void setLvRefCnt(unsigned short newValue, RefCountState state = RCS_NORMAL); - void incLvRefCntSaturating(unsigned short delta, RefCountState state = RCS_NORMAL); + void incLvRefCnt(unsigned short delta, RefCountState state = RCS_NORMAL); + void setLvRefCnt(unsigned short newValue, RefCountState state = RCS_NORMAL); + void incLvRefCntSaturating(unsigned short delta, RefCountState state = RCS_NORMAL); weight_t lvRefCntWtd(RefCountState state = RCS_NORMAL) const; - void incLvRefCntWtd(weight_t delta, RefCountState state = RCS_NORMAL); - void setLvRefCntWtd(weight_t newValue, RefCountState state = RCS_NORMAL); + void incLvRefCntWtd(weight_t delta, RefCountState state = RCS_NORMAL); + void setLvRefCntWtd(weight_t newValue, RefCountState state = RCS_NORMAL); private: int lvStkOffs; // stack offset of home in bytes. @@ -1366,7 +1361,7 @@ class IntegralRange return (m_lowerBound == other.m_lowerBound) && (m_upperBound == other.m_upperBound); } - static int64_t SymbolicToRealValue(SymbolicIntegerValue value); + static int64_t SymbolicToRealValue(SymbolicIntegerValue value); static SymbolicIntegerValue LowerBoundForType(var_types type); static SymbolicIntegerValue UpperBoundForType(var_types type); @@ -1486,9 +1481,9 @@ enum class PhaseStatus : unsigned class LinearScanInterface { public: - virtual PhaseStatus doLinearScan() = 0; - virtual void recordVarLocationsAtStartOfBB(BasicBlock* bb) = 0; - virtual bool willEnregisterLocalVars() const = 0; + virtual PhaseStatus doLinearScan() = 0; + virtual void recordVarLocationsAtStartOfBB(BasicBlock* bb) = 0; + virtual bool willEnregisterLocalVars() const = 0; #if TRACK_LSRA_STATS virtual void dumpLsraStatsCsv(FILE* file) = 0; virtual void dumpLsraStatsSummary(FILE* file) = 0; @@ -7436,23 +7431,23 @@ class Compiler typedef JitHashTable, GenTree*> LocalNumberToNullCheckTreeMap; - GenTree* getArrayLengthFromAllocation(GenTree* tree DEBUGARG(BasicBlock* block)); - GenTree* optPropGetValueRec(unsigned lclNum, unsigned ssaNum, optPropKind valueKind, int walkDepth); - GenTree* optPropGetValue(unsigned lclNum, unsigned ssaNum, optPropKind valueKind); - GenTree* optEarlyPropRewriteTree(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); - bool optDoEarlyPropForBlock(BasicBlock* block); + GenTree* getArrayLengthFromAllocation(GenTree* tree DEBUGARG(BasicBlock* block)); + GenTree* optPropGetValueRec(unsigned lclNum, unsigned ssaNum, optPropKind valueKind, int walkDepth); + GenTree* optPropGetValue(unsigned lclNum, unsigned ssaNum, optPropKind valueKind); + GenTree* optEarlyPropRewriteTree(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); + bool optDoEarlyPropForBlock(BasicBlock* block); bool optDoEarlyPropForFunc(); PhaseStatus optEarlyProp(); - bool optFoldNullCheck(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); - GenTree* optFindNullCheckToFold(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); - bool optIsNullCheckFoldingLegal(GenTree* tree, - GenTree* nullCheckTree, - GenTree** nullCheckParent, - Statement** nullCheckStmt); - bool optCanMoveNullCheckPastTree(GenTree* tree, - unsigned nullCheckLclNum, - bool isInsideTry, - bool checkSideEffectSummary); + bool optFoldNullCheck(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); + GenTree* optFindNullCheckToFold(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); + bool optIsNullCheckFoldingLegal(GenTree* tree, + GenTree* nullCheckTree, + GenTree** nullCheckParent, + Statement** nullCheckStmt); + bool optCanMoveNullCheckPastTree(GenTree* tree, + unsigned nullCheckLclNum, + bool isInsideTry, + bool checkSideEffectSummary); #if DEBUG void optCheckFlagsAreSet(unsigned methodFlag, const char* methodFlagStr, @@ -7463,30 +7458,30 @@ class Compiler #endif PhaseStatus optInductionVariables(); - bool optCanSinkWidenedIV(unsigned lclNum, FlowGraphNaturalLoop* loop); - bool optIsIVWideningProfitable(unsigned lclNum, - BasicBlock* initBlock, - bool initedToConstant, - FlowGraphNaturalLoop* loop, - ArrayStack& ivUses); - void optBestEffortReplaceNarrowIVUses( - unsigned lclNum, unsigned ssaNum, unsigned newLclNum, BasicBlock* block, Statement* firstStmt); + bool optCanSinkWidenedIV(unsigned lclNum, FlowGraphNaturalLoop* loop); + bool optIsIVWideningProfitable(unsigned lclNum, + BasicBlock* initBlock, + bool initedToConstant, + FlowGraphNaturalLoop* loop, + ArrayStack& ivUses); + void optBestEffortReplaceNarrowIVUses( + unsigned lclNum, unsigned ssaNum, unsigned newLclNum, BasicBlock* block, Statement* firstStmt); void optReplaceWidenedIV(unsigned lclNum, unsigned ssaNum, unsigned newLclNum, Statement* stmt); void optSinkWidenedIV(unsigned lclNum, unsigned newLclNum, FlowGraphNaturalLoop* loop); // Redundant branch opts // - PhaseStatus optRedundantBranches(); - bool optRedundantRelop(BasicBlock* const block); - bool optRedundantBranch(BasicBlock* const block); - bool optJumpThreadDom(BasicBlock* const block, BasicBlock* const domBlock, bool domIsSameRelop); - bool optJumpThreadPhi(BasicBlock* const block, GenTree* tree, ValueNum treeNormVN); - bool optJumpThreadCheck(BasicBlock* const block, BasicBlock* const domBlock); - bool optJumpThreadCore(JumpThreadInfo& jti); - bool optReachable(BasicBlock* const fromBlock, BasicBlock* const toBlock, BasicBlock* const excludedBlock); + PhaseStatus optRedundantBranches(); + bool optRedundantRelop(BasicBlock* const block); + bool optRedundantBranch(BasicBlock* const block); + bool optJumpThreadDom(BasicBlock* const block, BasicBlock* const domBlock, bool domIsSameRelop); + bool optJumpThreadPhi(BasicBlock* const block, GenTree* tree, ValueNum treeNormVN); + bool optJumpThreadCheck(BasicBlock* const block, BasicBlock* const domBlock); + bool optJumpThreadCore(JumpThreadInfo& jti); + bool optReachable(BasicBlock* const fromBlock, BasicBlock* const toBlock, BasicBlock* const excludedBlock); BitVecTraits* optReachableBitVecTraits; BitVec optReachableBitVec; - void optRelopImpliesRelop(RelopImplicationInfo* rii); + void optRelopImpliesRelop(RelopImplicationInfo* rii); /************************************************************************** * Value/Assertion propagation @@ -7553,7 +7548,8 @@ class Compiler { optOp1Kind kind; // a normal LclVar, or Exact-type or Subtype ValueNum vn; - union { + union + { SsaVar lcl; ArrBnd bnd; }; @@ -7573,7 +7569,8 @@ class Compiler #endif FieldSeq* fieldSeq; }; - union { + union + { SsaVar lcl; IntVal u1; __int64 lconVal; @@ -7790,49 +7787,49 @@ class Compiler bool optCanPropSubRange; public: - void optVnNonNullPropCurStmt(BasicBlock* block, Statement* stmt, GenTree* tree); + void optVnNonNullPropCurStmt(BasicBlock* block, Statement* stmt, GenTree* tree); fgWalkResult optVNBasedFoldCurStmt(BasicBlock* block, Statement* stmt, GenTree* parent, GenTree* tree); - GenTree* optVNConstantPropOnJTrue(BasicBlock* block, GenTree* test); - GenTree* optVNBasedFoldConstExpr(BasicBlock* block, GenTree* parent, GenTree* tree); - GenTree* optVNBasedFoldExpr(BasicBlock* block, GenTree* parent, GenTree* tree); - GenTree* optVNBasedFoldExpr_Call(BasicBlock* block, GenTree* parent, GenTreeCall* call); - GenTree* optExtractSideEffListFromConst(GenTree* tree); + GenTree* optVNConstantPropOnJTrue(BasicBlock* block, GenTree* test); + GenTree* optVNBasedFoldConstExpr(BasicBlock* block, GenTree* parent, GenTree* tree); + GenTree* optVNBasedFoldExpr(BasicBlock* block, GenTree* parent, GenTree* tree); + GenTree* optVNBasedFoldExpr_Call(BasicBlock* block, GenTree* parent, GenTreeCall* call); + GenTree* optExtractSideEffListFromConst(GenTree* tree); AssertionIndex GetAssertionCount() { return optAssertionCount; } - ASSERT_TP* bbJtrueAssertionOut; + ASSERT_TP* bbJtrueAssertionOut; typedef JitHashTable, ASSERT_TP> ValueNumToAssertsMap; - ValueNumToAssertsMap* optValueNumToAsserts; + ValueNumToAssertsMap* optValueNumToAsserts; // Assertion prop helpers. - ASSERT_TP& GetAssertionDep(unsigned lclNum); + ASSERT_TP& GetAssertionDep(unsigned lclNum); AssertionDsc* optGetAssertion(AssertionIndex assertIndex); - void optAssertionInit(bool isLocalProp); - void optAssertionTraitsInit(AssertionIndex assertionCount); - void optAssertionReset(AssertionIndex limit); - void optAssertionRemove(AssertionIndex index); + void optAssertionInit(bool isLocalProp); + void optAssertionTraitsInit(AssertionIndex assertionCount); + void optAssertionReset(AssertionIndex limit); + void optAssertionRemove(AssertionIndex index); // Assertion prop data flow functions. PhaseStatus optAssertionPropMain(); - Statement* optVNAssertionPropCurStmt(BasicBlock* block, Statement* stmt); - bool optIsTreeKnownIntValue(bool vnBased, GenTree* tree, ssize_t* pConstant, GenTreeFlags* pIconFlags); - ASSERT_TP* optInitAssertionDataflowFlags(); - ASSERT_TP* optComputeAssertionGen(); + Statement* optVNAssertionPropCurStmt(BasicBlock* block, Statement* stmt); + bool optIsTreeKnownIntValue(bool vnBased, GenTree* tree, ssize_t* pConstant, GenTreeFlags* pIconFlags); + ASSERT_TP* optInitAssertionDataflowFlags(); + ASSERT_TP* optComputeAssertionGen(); // Assertion Gen functions. - void optAssertionGen(GenTree* tree); + void optAssertionGen(GenTree* tree); AssertionIndex optAssertionGenCast(GenTreeCast* cast); AssertionIndex optAssertionGenPhiDefn(GenTree* tree); - AssertionInfo optCreateJTrueBoundsAssertion(GenTree* tree); - AssertionInfo optAssertionGenJtrue(GenTree* tree); + AssertionInfo optCreateJTrueBoundsAssertion(GenTree* tree); + AssertionInfo optAssertionGenJtrue(GenTree* tree); AssertionIndex optCreateJtrueAssertions(GenTree* op1, GenTree* op2, Compiler::optAssertionKind assertionKind, bool helperCallArgs = false); AssertionIndex optFindComplementary(AssertionIndex assertionIndex); - void optMapComplementary(AssertionIndex assertionIndex, AssertionIndex index); + void optMapComplementary(AssertionIndex assertionIndex, AssertionIndex index); ValueNum optConservativeNormalVN(GenTree* tree); @@ -7853,9 +7850,9 @@ class Compiler GenTree* op2, bool helperCallArgs = false); - bool optAssertionVnInvolvesNan(AssertionDsc* assertion); + bool optAssertionVnInvolvesNan(AssertionDsc* assertion); AssertionIndex optAddAssertion(AssertionDsc* assertion); - void optAddVnAssertionMapping(ValueNum vn, AssertionIndex index); + void optAddVnAssertionMapping(ValueNum vn, AssertionIndex index); #ifdef DEBUG void optPrintVnAssertionMapping(); #endif @@ -7865,8 +7862,8 @@ class Compiler AssertionIndex optAssertionIsSubrange(GenTree* tree, IntegralRange range, ASSERT_VALARG_TP assertions); AssertionIndex optAssertionIsSubtype(GenTree* tree, GenTree* methodTableArg, ASSERT_VALARG_TP assertions); AssertionIndex optAssertionIsNonNullInternal(GenTree* op, ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased)); - bool optAssertionIsNonNull(GenTree* op, - ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased) DEBUGARG(AssertionIndex* pIndex)); + bool optAssertionIsNonNull(GenTree* op, + ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased) DEBUGARG(AssertionIndex* pIndex)); AssertionIndex optGlobalAssertionIsEqualOrNotEqual(ASSERT_VALARG_TP assertions, GenTree* op1, GenTree* op2); AssertionIndex optGlobalAssertionIsEqualOrNotEqualZero(ASSERT_VALARG_TP assertions, GenTree* op1); @@ -7874,15 +7871,15 @@ class Compiler optOp1Kind op1Kind, unsigned lclNum, optOp2Kind op2Kind, ssize_t cnsVal, ASSERT_VALARG_TP assertions); // Assertion prop for lcl var functions. - bool optAssertionProp_LclVarTypeCheck(GenTree* tree, LclVarDsc* lclVarDsc, LclVarDsc* copyVarDsc); + bool optAssertionProp_LclVarTypeCheck(GenTree* tree, LclVarDsc* lclVarDsc, LclVarDsc* copyVarDsc); GenTree* optCopyAssertionProp(AssertionDsc* curAssertion, GenTreeLclVarCommon* tree, - Statement* stmt DEBUGARG(AssertionIndex index)); + Statement* stmt DEBUGARG(AssertionIndex index)); GenTree* optConstantAssertionProp(AssertionDsc* curAssertion, GenTreeLclVarCommon* tree, - Statement* stmt DEBUGARG(AssertionIndex index)); - bool optIsProfitableToSubstitute(GenTree* dest, BasicBlock* destBlock, GenTree* destParent, GenTree* value); - bool optZeroObjAssertionProp(GenTree* tree, ASSERT_VALARG_TP assertions); + Statement* stmt DEBUGARG(AssertionIndex index)); + bool optIsProfitableToSubstitute(GenTree* dest, BasicBlock* destBlock, GenTree* destParent, GenTree* value); + bool optZeroObjAssertionProp(GenTree* tree, ASSERT_VALARG_TP assertions); // Assertion propagation functions. GenTree* optAssertionProp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt, BasicBlock* block); @@ -7902,8 +7899,8 @@ class Compiler GenTree* optAssertionPropLocal_RelOp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionProp_Update(GenTree* newTree, GenTree* tree, Statement* stmt); GenTree* optNonNullAssertionProp_Call(ASSERT_VALARG_TP assertions, GenTreeCall* call); - bool optNonNullAssertionProp_Ind(ASSERT_VALARG_TP assertions, GenTree* indir); - bool optWriteBarrierAssertionProp_StoreInd(ASSERT_VALARG_TP assertions, GenTreeStoreInd* indir); + bool optNonNullAssertionProp_Ind(ASSERT_VALARG_TP assertions, GenTree* indir); + bool optWriteBarrierAssertionProp_StoreInd(ASSERT_VALARG_TP assertions, GenTreeStoreInd* indir); void optAssertionProp_RangeProperties(ASSERT_VALARG_TP assertions, GenTree* tree, @@ -7959,11 +7956,11 @@ class Compiler bool optReconstructArrIndex(GenTree* tree, ArrIndex* result); bool optIdentifyLoopOptInfo(FlowGraphNaturalLoop* loop, LoopCloneContext* context); static fgWalkPreFn optCanOptimizeByLoopCloningVisitor; - fgWalkResult optCanOptimizeByLoopCloning(GenTree* tree, LoopCloneVisitorInfo* info); - bool optObtainLoopCloningOpts(LoopCloneContext* context); - bool optIsLoopClonable(FlowGraphNaturalLoop* loop, LoopCloneContext* context); - bool optCheckLoopCloningGDVTestProfitable(GenTreeOp* guard, LoopCloneVisitorInfo* info); - bool optIsHandleOrIndirOfHandle(GenTree* tree, GenTreeFlags handleType); + fgWalkResult optCanOptimizeByLoopCloning(GenTree* tree, LoopCloneVisitorInfo* info); + bool optObtainLoopCloningOpts(LoopCloneContext* context); + bool optIsLoopClonable(FlowGraphNaturalLoop* loop, LoopCloneContext* context); + bool optCheckLoopCloningGDVTestProfitable(GenTreeOp* guard, LoopCloneVisitorInfo* info); + bool optIsHandleOrIndirOfHandle(GenTree* tree, GenTreeFlags handleType); static bool optLoopCloningEnabled(); @@ -8125,7 +8122,7 @@ class Compiler const char* eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer = nullptr, size_t bufferSize = 0); - void eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle); + void eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle); const char* eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd); #if defined(DEBUG) @@ -8134,12 +8131,12 @@ class Compiler unsigned compMethodHash(CORINFO_METHOD_HANDLE methodHandle); - var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig); - var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig, bool* isPinned); + var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig); + var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig, bool* isPinned); CORINFO_CLASS_HANDLE eeGetArgClass(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_HANDLE list); CORINFO_CLASS_HANDLE eeGetClassFromContext(CORINFO_CONTEXT_HANDLE context); - unsigned eeGetArgSize(CorInfoType corInfoType, CORINFO_CLASS_HANDLE typeHnd); - static unsigned eeGetArgSizeAlignment(var_types type, bool isFloatHfa); + unsigned eeGetArgSize(CorInfoType corInfoType, CORINFO_CLASS_HANDLE typeHnd); + static unsigned eeGetArgSizeAlignment(var_types type, bool isFloatHfa); // VOM info, method sigs @@ -8267,7 +8264,7 @@ class Compiler unsigned eeBoundariesCount; ICorDebugInfo::OffsetMapping* eeBoundaries; // Boundaries to report to the EE - void eeSetLIcount(unsigned count); + void eeSetLIcount(unsigned count); void eeSetLIinfo(unsigned which, UNATIVE_OFFSET offs, IPmappingDscKind kind, const ILLocation& loc); void eeSetLIdone(); @@ -8275,7 +8272,7 @@ class Compiler static void eeDispILOffs(IL_OFFSET offs); static void eeDispSourceMappingOffs(uint32_t offs); static void eeDispLineInfo(const ICorDebugInfo::OffsetMapping* line); - void eeDispLineInfos(); + void eeDispLineInfos(); #endif // DEBUG // Debugging support - Local var info @@ -8290,7 +8287,7 @@ class Compiler UNATIVE_OFFSET endOffset; DWORD varNumber; CodeGenInterface::siVarLoc loc; - } * eeVars; + }* eeVars; void eeSetLVcount(unsigned count); void eeSetLVinfo(unsigned which, UNATIVE_OFFSET startOffs, @@ -8324,7 +8321,7 @@ class Compiler WORD eeGetRelocTypeHint(void* target); -// ICorStaticInfo wrapper functions + // ICorStaticInfo wrapper functions #if defined(UNIX_AMD64_ABI) #ifdef DEBUG @@ -8361,7 +8358,7 @@ class Compiler // Utility functions static CORINFO_METHOD_HANDLE eeFindHelper(unsigned helper); - static CorInfoHelpFunc eeGetHelperNum(CORINFO_METHOD_HANDLE method); + static CorInfoHelpFunc eeGetHelperNum(CORINFO_METHOD_HANDLE method); enum StaticHelperReturnValue { @@ -8412,7 +8409,7 @@ class Compiler // structure and IL offset is needed only when generating debuggable code. Therefore // it is desirable to avoid memory size penalty in retail scenarios. typedef JitHashTable, DebugInfo> CallSiteDebugInfoTable; - CallSiteDebugInfoTable* genCallSite2DebugInfoMap; + CallSiteDebugInfoTable* genCallSite2DebugInfoMap; unsigned genReturnLocal; // Local number for the return value when applicable. BasicBlock* genReturnBB; // jumped to when not optimizing for speed. @@ -8446,11 +8443,11 @@ class Compiler return codeGen->doDoubleAlign(); } DWORD getCanDoubleAlign(); - bool shouldDoubleAlign(unsigned refCntStk, - unsigned refCntReg, - weight_t refCntWtdReg, - unsigned refCntStkParam, - weight_t refCntWtdStkDbl); + bool shouldDoubleAlign(unsigned refCntStk, + unsigned refCntReg, + weight_t refCntWtdReg, + unsigned refCntStkParam, + weight_t refCntWtdStkDbl); #endif // DOUBLE_ALIGN bool IsFullPtrRegMapRequired() @@ -8462,7 +8459,7 @@ class Compiler codeGen->SetFullPtrRegMapRequired(value); } -// Things that MAY belong either in CodeGen or CodeGenContext + // Things that MAY belong either in CodeGen or CodeGenContext #if defined(FEATURE_EH_FUNCLETS) FuncInfoDsc* compFuncInfos; @@ -8495,7 +8492,7 @@ class Compiler #endif // !FEATURE_EH_FUNCLETS FuncInfoDsc* funCurrentFunc(); - void funSetCurrentFunc(unsigned funcIdx); + void funSetCurrentFunc(unsigned funcIdx); FuncInfoDsc* funGetFunc(unsigned funcIdx); unsigned int funGetFuncIdx(BasicBlock* block); @@ -8518,15 +8515,15 @@ class Compiler // not all JIT Helper calls follow the standard ABI on the target architecture. regMaskTP compHelperCallKillSet(CorInfoHelpFunc helper); -/* -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XX XX -XX UnwindInfo XX -XX XX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -*/ + /* + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + XX XX + XX UnwindInfo XX + XX XX + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + */ #if !defined(__GNUC__) #pragma region Unwind information @@ -8640,13 +8637,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #if defined(FEATURE_CFI_SUPPORT) short mapRegNumToDwarfReg(regNumber reg); - void createCfiCode(FuncInfoDsc* func, UNATIVE_OFFSET codeOffset, UCHAR opcode, short dwarfReg, INT offset = 0); - void unwindPushPopCFI(regNumber reg); - void unwindBegPrologCFI(); - void unwindPushPopMaskCFI(regMaskTP regMask, bool isFloat); - void unwindAllocStackCFI(unsigned size); - void unwindSetFrameRegCFI(regNumber reg, unsigned offset); - void unwindEmitFuncCFI(FuncInfoDsc* func, void* pHotCode, void* pColdCode); + void createCfiCode(FuncInfoDsc* func, UNATIVE_OFFSET codeOffset, UCHAR opcode, short dwarfReg, INT offset = 0); + void unwindPushPopCFI(regNumber reg); + void unwindBegPrologCFI(); + void unwindPushPopMaskCFI(regMaskTP regMask, bool isFloat); + void unwindAllocStackCFI(unsigned size); + void unwindSetFrameRegCFI(regNumber reg, unsigned offset); + void unwindEmitFuncCFI(FuncInfoDsc* func, void* pHotCode, void* pColdCode); #ifdef DEBUG void DumpCfiInfo(bool isHotCode, UNATIVE_OFFSET startOffset, @@ -8895,11 +8892,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX GenTree* impSIMDPopStack(); - void setLclRelatedToSIMDIntrinsic(GenTree* tree); - bool areFieldsContiguous(GenTreeIndir* op1, GenTreeIndir* op2); - bool areLocalFieldsContiguous(GenTreeLclFld* first, GenTreeLclFld* second); - bool areArrayElementsContiguous(GenTree* op1, GenTree* op2); - bool areArgumentsContiguous(GenTree* op1, GenTree* op2); + void setLclRelatedToSIMDIntrinsic(GenTree* tree); + bool areFieldsContiguous(GenTreeIndir* op1, GenTreeIndir* op2); + bool areLocalFieldsContiguous(GenTreeLclFld* first, GenTreeLclFld* second); + bool areArrayElementsContiguous(GenTree* op1, GenTree* op2); + bool areArgumentsContiguous(GenTree* op1, GenTree* op2); GenTree* CreateAddressNodeForSimdHWIntrinsicCreate(GenTree* tree, var_types simdBaseType, unsigned simdSize); // Get the size of the SIMD type in bytes @@ -9553,8 +9550,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX bool compSwitchedToMinOpts; // Codegen initially was Tier1/FullOpts but jit switched to MinOpts bool compSuppressedZeroInit; // There are vars with lvSuppressedZeroInit set -// NOTE: These values are only reliable after -// the importing is completely finished. + // NOTE: These values are only reliable after + // the importing is completely finished. #ifdef DEBUG // State information - which phases have completed? @@ -9642,7 +9639,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX uint32_t preferredVectorByteLength; #endif // TARGET_XARCH -// optimize maximally and/or favor speed over size? + // optimize maximally and/or favor speed over size? #define DEFAULT_MIN_OPTS_CODE_SIZE 60000 #define DEFAULT_MIN_OPTS_INSTR_COUNT 20000 @@ -10067,7 +10064,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #endif // DEBUG -// clang-format off + // clang-format off #define STRESS_MODES \ \ STRESS_MODE(NONE) \ @@ -10137,7 +10134,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX STRESS_MODES #undef STRESS_MODE }; -// clang-format on + // clang-format on #ifdef DEBUG static const LPCWSTR s_compStressModeNamesW[STRESS_COUNT + 1]; @@ -10147,8 +10144,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #define MAX_STRESS_WEIGHT 100 - bool compStressCompile(compStressArea stressArea, unsigned weightPercentage); - bool compStressCompileHelper(compStressArea stressArea, unsigned weightPercentage); + bool compStressCompile(compStressArea stressArea, unsigned weightPercentage); + bool compStressCompileHelper(compStressArea stressArea, unsigned weightPercentage); static unsigned compStressAreaHash(compStressArea area); #ifdef DEBUG @@ -10376,7 +10373,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX } } #endif // TARGET_ARM64 - // 4. x86 unmanaged calling conventions require the address of RetBuff to be returned in eax. + // 4. x86 unmanaged calling conventions require the address of RetBuff to be returned in eax. CLANG_FORMAT_COMMENT_ANCHOR; #if defined(TARGET_X86) if (info.compCallConv != CorInfoCallConvExtension::Managed) @@ -10465,7 +10462,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX var_types TypeHandleToVarType(CORINFO_CLASS_HANDLE handle, ClassLayout** pLayout = nullptr); var_types TypeHandleToVarType(CorInfoType jitType, CORINFO_CLASS_HANDLE handle, ClassLayout** pLayout = nullptr); -//-------------------------- Global Compiler Data ------------------------------------ + //-------------------------- Global Compiler Data ------------------------------------ #ifdef DEBUG private: @@ -10573,8 +10570,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX //------------ Some utility functions -------------- - void* compGetHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ - void** ppIndirection); /* OUT */ + void* compGetHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ + void** ppIndirection); /* OUT */ // Several JIT/EE interface functions return a CorInfoType, and also return a // class handle as an out parameter if the type is a value class. Returns the @@ -10589,17 +10586,17 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX void compDoComponentUnitTestsOnce(); #endif // DEBUG - int compCompile(CORINFO_MODULE_HANDLE classPtr, - void** methodCodePtr, - uint32_t* methodCodeSize, - JitFlags* compileFlags); + int compCompile(CORINFO_MODULE_HANDLE classPtr, + void** methodCodePtr, + uint32_t* methodCodeSize, + JitFlags* compileFlags); void compCompileFinish(); - int compCompileHelper(CORINFO_MODULE_HANDLE classPtr, - COMP_HANDLE compHnd, - CORINFO_METHOD_INFO* methodInfo, - void** methodCodePtr, - uint32_t* methodCodeSize, - JitFlags* compileFlag); + int compCompileHelper(CORINFO_MODULE_HANDLE classPtr, + COMP_HANDLE compHnd, + CORINFO_METHOD_INFO* methodInfo, + void** methodCodePtr, + uint32_t* methodCodeSize, + JitFlags* compileFlag); ArenaAllocator* compGetArenaAllocator(); @@ -10690,10 +10687,10 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX static unsigned char compGetJitDefaultFill(Compiler* comp); const char* compLocalVarName(unsigned varNum, unsigned offs); - VarName compVarName(regNumber reg, bool isFloatReg = false); + VarName compVarName(regNumber reg, bool isFloatReg = false); const char* compFPregVarName(unsigned fpReg, bool displayVar = false); - void compDspSrcLinesByNativeIP(UNATIVE_OFFSET curIP); - void compDspSrcLinesByLineNum(unsigned line, bool seek = false); + void compDspSrcLinesByNativeIP(UNATIVE_OFFSET curIP); + void compDspSrcLinesByLineNum(unsigned line, bool seek = false); #endif // DEBUG const char* compRegNameForSize(regNumber reg, size_t size); const char* compRegVarName(regNumber reg, bool displayVar = false, bool isFloatReg = false); @@ -10865,8 +10862,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX void verInitCurrentState(); void verResetCurrentState(BasicBlock* block, EntryState* currentState); - void verConvertBBToThrowVerificationException(BasicBlock* block DEBUGARG(bool logMsg)); - void verHandleVerificationFailure(BasicBlock* block DEBUGARG(bool logMsg)); + void verConvertBBToThrowVerificationException(BasicBlock* block DEBUGARG(bool logMsg)); + void verHandleVerificationFailure(BasicBlock* block DEBUGARG(bool logMsg)); typeInfo verMakeTypeInfoForLocal(unsigned lclNum); typeInfo verMakeTypeInfo(CORINFO_CLASS_HANDLE clsHnd); // converts from jit type representation to typeInfo typeInfo verMakeTypeInfo(CorInfoType ciType, @@ -10963,8 +10960,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX static fgWalkPreFn gsMarkPtrsAndAssignGroups; // Shadow param analysis tree-walk static fgWalkPreFn gsReplaceShadowParams; // Shadow param replacement tree-walk -#define DEFAULT_MAX_INLINE_SIZE 100 // Methods with > DEFAULT_MAX_INLINE_SIZE IL bytes will never be inlined. - // This can be overwritten by setting DOTNET_JITInlineSize env variable. +#define DEFAULT_MAX_INLINE_SIZE \ + 100 // Methods with > DEFAULT_MAX_INLINE_SIZE IL bytes will never be inlined. + // This can be overwritten by setting DOTNET_JITInlineSize env variable. #define DEFAULT_MAX_INLINE_DEPTH 20 // Methods at more than this level deep will not be inlined @@ -11148,7 +11146,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #endif // defined(UNIX_AMD64_ABI) - void fgMorphMultiregStructArgs(GenTreeCall* call); + void fgMorphMultiregStructArgs(GenTreeCall* call); GenTree* fgMorphMultiregStructArg(CallArg* arg); bool killGCRefs(GenTree* tree); @@ -11726,25 +11724,15 @@ class DomTreeVisitor protected: Compiler* m_compiler; - DomTreeVisitor(Compiler* compiler) : m_compiler(compiler) - { - } + DomTreeVisitor(Compiler* compiler) : m_compiler(compiler) {} - void Begin() - { - } + void Begin() {} - void PreOrderVisit(BasicBlock* block) - { - } + void PreOrderVisit(BasicBlock* block) {} - void PostOrderVisit(BasicBlock* block) - { - } + void PostOrderVisit(BasicBlock* block) {} - void End() - { - } + void End() {} private: void WalkTree(const DomTreeNode* tree) @@ -11815,9 +11803,7 @@ class EHClauses EHblkDsc* m_ehDsc; public: - iterator(EHblkDsc* ehDsc) : m_ehDsc(ehDsc) - { - } + iterator(EHblkDsc* ehDsc) : m_ehDsc(ehDsc) {} EHblkDsc* operator*() const { diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index daccf6027efd10..4e2c52f5cc0666 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -78,9 +78,9 @@ inline T genFindLowestBit(T value) } /***************************************************************************** -* -* Return true if the given value has exactly zero or one bits set. -*/ + * + * Return true if the given value has exactly zero or one bits set. + */ template inline bool genMaxOneBit(T value) @@ -89,9 +89,9 @@ inline bool genMaxOneBit(T value) } /***************************************************************************** -* -* Return true if the given value has exactly one bit set. -*/ + * + * Return true if the given value has exactly one bit set. + */ template inline bool genExactlyOneBit(T value) @@ -280,9 +280,7 @@ class Counter : public Dumpable public: int64_t Value; - Counter(int64_t initialValue = 0) : Value(initialValue) - { - } + Counter(int64_t initialValue = 0) : Value(initialValue) {} void dump(FILE* output); }; @@ -332,9 +330,7 @@ class Histogram : public Dumpable class NodeCounts : public Dumpable { public: - NodeCounts() : m_counts() - { - } + NodeCounts() : m_counts() {} void dump(FILE* output); void record(genTreeOps oper); @@ -544,7 +540,7 @@ BasicBlockVisit BasicBlock::VisitEHEnclosedHandlerSecondPassSuccs(Compiler* comp // 3. As part of two pass EH, control may bypass filters and flow directly to // filter-handlers // -template +template static BasicBlockVisit VisitEHSuccs(Compiler* comp, BasicBlock* block, TFunc func) { if (!block->HasPotentialEHSuccs(comp)) @@ -1273,8 +1269,8 @@ inline Statement* Compiler::gtNewStmt(GenTree* expr, const DebugInfo& di) inline GenTree* Compiler::gtNewOperNode(genTreeOps oper, var_types type, GenTree* op1) { assert((GenTree::OperKind(oper) & (GTK_UNOP | GTK_BINOP)) != 0); - assert((GenTree::OperKind(oper) & GTK_EXOP) == - 0); // Can't use this to construct any types that extend unary/binary operator. + assert((GenTree::OperKind(oper) & GTK_EXOP) == 0); // Can't use this to construct any types that extend unary/binary + // operator. assert(op1 != nullptr || oper == GT_RETFILT || (oper == GT_RETURN && type == TYP_VOID)); GenTree* node = new (this, oper) GenTreeOp(oper, type, op1, nullptr); @@ -1320,7 +1316,7 @@ inline GenTreeIntCon* Compiler::gtNewIconHandleNode(size_t value, GenTreeFlags f node = new (this, LargeOpOpcode()) GenTreeIntCon(gtGetTypeForIconFlags(flags), value, fields DEBUGARG(/*largeNode*/ true)); #else - node = new (this, GT_CNS_INT) GenTreeIntCon(gtGetTypeForIconFlags(flags), value, fields); + node = new (this, GT_CNS_INT) GenTreeIntCon(gtGetTypeForIconFlags(flags), value, fields); #endif node->gtFlags |= flags; return node; @@ -2520,8 +2516,8 @@ inline assert(varDsc->lvIsParam); #endif // UNIX_AMD64_ABI #else // !TARGET_AMD64 - // For other targets, a stack parameter that is enregistered or prespilled - // for profiling on ARM will have a stack location. + // For other targets, a stack parameter that is enregistered or prespilled + // for profiling on ARM will have a stack location. assert((varDsc->lvIsParam && !varDsc->lvIsRegArg) || isPrespilledArg); #endif // !TARGET_AMD64 } @@ -2608,7 +2604,7 @@ inline #ifdef TARGET_ARM varOffset = codeGen->genCallerSPtoInitialSPdelta() - codeGen->genCallerSPtoFPdelta(); #else - varOffset = -(codeGen->genTotalFrameSize()); + varOffset = -(codeGen->genTotalFrameSize()); #endif } } @@ -2662,7 +2658,7 @@ inline *pBaseReg = REG_SPBASE; } #else - *pFPbased = FPbased; + *pFPbased = FPbased; #endif return varOffset; @@ -4780,8 +4776,8 @@ unsigned Compiler::fgRunDfs(VisitPreorder visitPreorder, VisitPostorder visitPos ArrayStack blocks(getAllocator(CMK_DepthFirstSearch)); - auto dfsFrom = [&](BasicBlock* firstBB) { - + auto dfsFrom = [&](BasicBlock* firstBB) + { BitVecOps::AddElemD(&traits, visited, firstBB->bbNum); blocks.Emplace(this, firstBB); visitPreorder(firstBB, preOrderIndex++); @@ -4807,7 +4803,6 @@ unsigned Compiler::fgRunDfs(VisitPreorder visitPreorder, VisitPostorder visitPos visitPostorder(block, postOrderIndex++); } } - }; dfsFrom(fgFirstBB); @@ -4852,15 +4847,17 @@ template BasicBlockVisit FlowGraphNaturalLoop::VisitLoopBlocksReversePostOrder(TFunc func) { BitVecTraits traits(m_blocksSize, m_dfsTree->GetCompiler()); - bool result = BitVecOps::VisitBits(&traits, m_blocks, [=](unsigned index) { - // head block rpo index = PostOrderCount - 1 - headPreOrderIndex - // loop block rpo index = head block rpoIndex + index - // loop block po index = PostOrderCount - 1 - loop block rpo index - // = headPreOrderIndex - index - unsigned poIndex = m_header->bbPostorderNum - index; - assert(poIndex < m_dfsTree->GetPostOrderCount()); - return func(m_dfsTree->GetPostOrder(poIndex)) == BasicBlockVisit::Continue; - }); + bool result = BitVecOps::VisitBits(&traits, m_blocks, + [=](unsigned index) + { + // head block rpo index = PostOrderCount - 1 - headPreOrderIndex + // loop block rpo index = head block rpoIndex + index + // loop block po index = PostOrderCount - 1 - loop block rpo index + // = headPreOrderIndex - index + unsigned poIndex = m_header->bbPostorderNum - index; + assert(poIndex < m_dfsTree->GetPostOrderCount()); + return func(m_dfsTree->GetPostOrder(poIndex)) == BasicBlockVisit::Continue; + }); return result ? BasicBlockVisit::Continue : BasicBlockVisit::Abort; } @@ -4884,11 +4881,14 @@ template BasicBlockVisit FlowGraphNaturalLoop::VisitLoopBlocksPostOrder(TFunc func) { BitVecTraits traits(m_blocksSize, m_dfsTree->GetCompiler()); - bool result = BitVecOps::VisitBitsReverse(&traits, m_blocks, [=](unsigned index) { - unsigned poIndex = m_header->bbPostorderNum - index; - assert(poIndex < m_dfsTree->GetPostOrderCount()); - return func(m_dfsTree->GetPostOrder(poIndex)) == BasicBlockVisit::Continue; - }); + bool result = + BitVecOps::VisitBitsReverse(&traits, m_blocks, + [=](unsigned index) + { + unsigned poIndex = m_header->bbPostorderNum - index; + assert(poIndex < m_dfsTree->GetPostOrderCount()); + return func(m_dfsTree->GetPostOrder(poIndex)) == BasicBlockVisit::Continue; + }); return result ? BasicBlockVisit::Continue : BasicBlockVisit::Abort; } @@ -4933,15 +4933,17 @@ BasicBlockVisit FlowGraphNaturalLoop::VisitLoopBlocksLexical(TFunc func) { BasicBlock* top = m_header; unsigned numLoopBlocks = 0; - VisitLoopBlocks([&](BasicBlock* block) { - if (block->bbNum < top->bbNum) + VisitLoopBlocks( + [&](BasicBlock* block) { - top = block; - } + if (block->bbNum < top->bbNum) + { + top = block; + } - numLoopBlocks++; - return BasicBlockVisit::Continue; - }); + numLoopBlocks++; + return BasicBlockVisit::Continue; + }); INDEBUG(BasicBlock* prev = nullptr); BasicBlock* cur = top; diff --git a/src/coreclr/jit/copyprop.cpp b/src/coreclr/jit/copyprop.cpp index 90a593ef65b2fe..58cd770453f7f7 100644 --- a/src/coreclr/jit/copyprop.cpp +++ b/src/coreclr/jit/copyprop.cpp @@ -30,7 +30,8 @@ // void Compiler::optBlockCopyPropPopStacks(BasicBlock* block, LclNumToLiveDefsMap* curSsaName) { - auto popDef = [=](unsigned defLclNum, unsigned defSsaNum) { + auto popDef = [=](unsigned defLclNum, unsigned defSsaNum) + { CopyPropSsaDefStack* stack = nullptr; if ((defSsaNum != SsaConfig::RESERVED_SSA_NUM) && curSsaName->Lookup(defLclNum, &stack)) { @@ -300,7 +301,8 @@ void Compiler::optCopyPropPushDef(GenTree* defNode, GenTreeLclVarCommon* lclNode return; } - auto pushDef = [=](unsigned defLclNum, unsigned defSsaNum) { + auto pushDef = [=](unsigned defLclNum, unsigned defSsaNum) + { // The default is "not available". LclSsaVarDsc* ssaDef = nullptr; diff --git a/src/coreclr/jit/dataflow.h b/src/coreclr/jit/dataflow.h index 6f27c6a998d771..d29769d0aa7a6c 100644 --- a/src/coreclr/jit/dataflow.h +++ b/src/coreclr/jit/dataflow.h @@ -78,10 +78,12 @@ void DataFlow::ForwardAnalysis(TCallback& callback) // block dominates all other blocks in the 'try'. That will happen // as part of processing handlers below. // - block->VisitRegularSuccs(m_pCompiler, [&worklist](BasicBlock* succ) { - worklist.insert(worklist.end(), succ); - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(m_pCompiler, + [&worklist](BasicBlock* succ) + { + worklist.insert(worklist.end(), succ); + return BasicBlockVisit::Continue; + }); } if (m_pCompiler->bbIsTryBeg(block)) diff --git a/src/coreclr/jit/debuginfo.h b/src/coreclr/jit/debuginfo.h index 3f628840765dc7..53cadbeaddd030 100644 --- a/src/coreclr/jit/debuginfo.h +++ b/src/coreclr/jit/debuginfo.h @@ -12,9 +12,7 @@ class InlineContext; class ILLocation { public: - ILLocation() : m_offset(BAD_IL_OFFSET), m_isStackEmpty(false), m_isCall(false) - { - } + ILLocation() : m_offset(BAD_IL_OFFSET), m_isStackEmpty(false), m_isCall(false) {} ILLocation(IL_OFFSET offset, bool isStackEmpty, bool isCall) : m_offset(offset), m_isStackEmpty(isStackEmpty), m_isCall(isCall) @@ -72,13 +70,9 @@ class ILLocation class DebugInfo { public: - DebugInfo() : m_inlineContext(nullptr) - { - } + DebugInfo() : m_inlineContext(nullptr) {} - DebugInfo(InlineContext* inlineContext, ILLocation loc) : m_inlineContext(inlineContext), m_location(loc) - { - } + DebugInfo(InlineContext* inlineContext, ILLocation loc) : m_inlineContext(inlineContext), m_location(loc) {} InlineContext* GetInlineContext() const { @@ -103,9 +97,7 @@ class DebugInfo #ifdef DEBUG void Validate() const; #else - void Validate() const - { - } + void Validate() const {} #endif #ifdef DEBUG diff --git a/src/coreclr/jit/decomposelongs.h b/src/coreclr/jit/decomposelongs.h index b8ddc621079925..597c4d6b5e3789 100644 --- a/src/coreclr/jit/decomposelongs.h +++ b/src/coreclr/jit/decomposelongs.h @@ -18,9 +18,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX class DecomposeLongs { public: - DecomposeLongs(Compiler* compiler) : m_compiler(compiler) - { - } + DecomposeLongs(Compiler* compiler) : m_compiler(compiler) {} void PrepareForDecomposition(); void DecomposeBlock(BasicBlock* block); @@ -72,7 +70,7 @@ class DecomposeLongs GenTree* RepresentOpAsLocalVar(GenTree* op, GenTree* user, GenTree** edge); GenTree* EnsureIntSized(GenTree* node, bool signExtend); - GenTree* StoreNodeToVar(LIR::Use& use); + GenTree* StoreNodeToVar(LIR::Use& use); static genTreeOps GetHiOper(genTreeOps oper); static genTreeOps GetLoOper(genTreeOps oper); diff --git a/src/coreclr/jit/disasm.cpp b/src/coreclr/jit/disasm.cpp index 2a49f9d8cb55c5..02dfc3cadd977a 100644 --- a/src/coreclr/jit/disasm.cpp +++ b/src/coreclr/jit/disasm.cpp @@ -1,12 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*********************************************************************** -* -* File: disasm.cpp -* -* This file handles disassembly for the "late disassembler". -* -***********************************************************************/ + * + * File: disasm.cpp + * + * This file handles disassembly for the "late disassembler". + * + ***********************************************************************/ #include "jitpch.h" #ifdef _MSC_VER @@ -23,7 +23,7 @@ FILE* g_disAsmFileCorDisTools; #endif // USE_COREDISTOOLS // Define DISASM_DEBUG to get verbose output of late disassembler inner workings. -//#define DISASM_DEBUG +// #define DISASM_DEBUG #ifdef DISASM_DEBUG #ifdef DEBUG #define DISASM_DUMP(...) \ @@ -96,12 +96,12 @@ typedef struct codeFix { codeFix* cfNext; unsigned cfFixup; -} * codeFixPtr; +}* codeFixPtr; typedef struct codeBlk { codeFix* cbFixupLst; -} * codeBlkPtr; +}* codeBlkPtr; #ifdef USE_MSVCDIS @@ -139,7 +139,7 @@ size_t DisAssembler::disCchAddrMember( switch (terminationType) { - // int disCallSize; + // int disCallSize; case DISX86::trmtaJmpShort: case DISX86::trmtaJmpCcShort: @@ -228,7 +228,7 @@ size_t DisAssembler::disCchAddrMember( switch (terminationType) { - // int disCallSize; + // int disCallSize; case DISARM64::TRMTA::trmtaBra: case DISARM64::TRMTA::trmtaBraCase: @@ -620,7 +620,7 @@ size_t DisAssembler::disCchRegRelMember( case DISX86::trmtaFallThrough: - /* some instructions like division have a TRAP termination type - ignore it */ + /* some instructions like division have a TRAP termination type - ignore it */ case DISX86::trmtaTrap: case DISX86::trmtaTrapCc: @@ -715,7 +715,7 @@ size_t DisAssembler::disCchRegRelMember( case DISARM64::TRMTA::trmtaFallThrough: - /* some instructions like division have a TRAP termination type - ignore it */ + /* some instructions like division have a TRAP termination type - ignore it */ case DISARM64::TRMTA::trmtaTrap: case DISARM64::TRMTA::trmtaTrapCc: @@ -1261,7 +1261,7 @@ void DisAssembler::DisasmBuffer(FILE* pfile, bool printit) #elif defined(TARGET_AMD64) pdis = DIS::PdisNew(DIS::distX8664); #elif defined(TARGET_ARM64) - pdis = DIS::PdisNew(DIS::distArm64); + pdis = DIS::PdisNew(DIS::distArm64); #else // TARGET* #error Unsupported or unset target architecture #endif @@ -1340,7 +1340,7 @@ void DisAssembler::DisasmBuffer(FILE* pfile, bool printit) #else false // Display code bytes? #endif - ); + ); ibCur += (unsigned)cb; } @@ -1680,7 +1680,7 @@ bool DisAssembler::InitCoredistoolsLibrary() s_disCoreDisToolsLibraryLoadSuccessful = true; // We made it! -// done initializing + // done initializing FinishedInitializing: InterlockedExchange(&s_disCoreDisToolsLibraryInitializing, 0); // unlock initialization @@ -1703,7 +1703,7 @@ bool DisAssembler::InitCoredistoolsDisasm() #if defined(TARGET_ARM64) coreDisTargetArchitecture = Target_Arm64; #elif defined(TARGET_ARM) - coreDisTargetArchitecture = Target_Thumb; + coreDisTargetArchitecture = Target_Thumb; #elif defined(TARGET_X86) coreDisTargetArchitecture = Target_X86; #elif defined(TARGET_AMD64) @@ -1737,7 +1737,8 @@ void DisAssembler::DisasmBuffer(FILE* pfile, bool printit) unsigned errorCount = 0; static const unsigned maxErrorCount = 50; - auto disasmRegion = [&](size_t executionAddress, size_t blockAddress, size_t blockSize) { + auto disasmRegion = [&](size_t executionAddress, size_t blockAddress, size_t blockSize) + { uint8_t* address = (uint8_t*)executionAddress; uint8_t* codeBytes = (uint8_t*)blockAddress; size_t codeSizeBytes = blockSize; diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index cfe50b492bb321..8d7f8f4f9baf79 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -239,13 +239,9 @@ void JitTls::SetCompiler(Compiler* compiler) #else // !defined(DEBUG) -JitTls::JitTls(ICorJitInfo* jitInfo) -{ -} +JitTls::JitTls(ICorJitInfo* jitInfo) {} -JitTls::~JitTls() -{ -} +JitTls::~JitTls() {} Compiler* JitTls::GetCompiler() { diff --git a/src/coreclr/jit/ee_il_dll.hpp b/src/coreclr/jit/ee_il_dll.hpp index c3801d88292f5f..d676ba8caa479a 100644 --- a/src/coreclr/jit/ee_il_dll.hpp +++ b/src/coreclr/jit/ee_il_dll.hpp @@ -10,12 +10,12 @@ class CILJit : public ICorJitCompiler unsigned flags, /* IN */ uint8_t** nativeEntry, /* OUT */ uint32_t* nativeSizeOfCode /* OUT */ - ); + ); void ProcessShutdownWork(ICorStaticInfo* statInfo); void getVersionIdentifier(GUID* versionIdentifier /* OUT */ - ); + ); void setTargetOS(CORINFO_OS os); }; diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 0578dee4109ef1..6536eac8650c45 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -156,9 +156,8 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, return; } - eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { - return info.compCompHnd->printClassName(clsHnd, buffer, bufferSize, requiredBufferSize); - }); + eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) + { return info.compCompHnd->printClassName(clsHnd, buffer, bufferSize, requiredBufferSize); }); if (!includeInstantiation) { @@ -255,9 +254,8 @@ void Compiler::eePrintMethod(StringPrinter* printer, printer->Append(':'); } - eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { - return info.compCompHnd->printMethodName(methHnd, buffer, bufferSize, requiredBufferSize); - }); + eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) + { return info.compCompHnd->printMethodName(methHnd, buffer, bufferSize, requiredBufferSize); }); if (includeMethodInstantiation && (sig->sigInst.methInstCount > 0)) { @@ -364,9 +362,8 @@ void Compiler::eePrintField(StringPrinter* printer, CORINFO_FIELD_HANDLE fld, bo printer->Append(':'); } - eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { - return info.compCompHnd->printFieldName(fld, buffer, bufferSize, requiredBufferSize); - }); + eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) + { return info.compCompHnd->printFieldName(fld, buffer, bufferSize, requiredBufferSize); }); } //------------------------------------------------------------------------ @@ -398,16 +395,17 @@ const char* Compiler::eeGetMethodFullName( StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); CORINFO_CLASS_HANDLE clsHnd = NO_CLASS_HANDLE; - bool success = eeRunFunctorWithSPMIErrorTrap([&]() { - clsHnd = info.compCompHnd->getMethodClass(hnd); - CORINFO_SIG_INFO sig; - eeGetMethodSig(hnd, &sig); - eePrintMethod(&p, clsHnd, hnd, &sig, - /* includeClassInstantiation */ true, - /* includeMethodInstantiation */ true, - /* includeSignature */ true, includeReturnType, includeThisSpecifier); - - }); + bool success = eeRunFunctorWithSPMIErrorTrap( + [&]() + { + clsHnd = info.compCompHnd->getMethodClass(hnd); + CORINFO_SIG_INFO sig; + eeGetMethodSig(hnd, &sig); + eePrintMethod(&p, clsHnd, hnd, &sig, + /* includeClassInstantiation */ true, + /* includeMethodInstantiation */ true, + /* includeSignature */ true, includeReturnType, includeThisSpecifier); + }); if (success) { @@ -417,15 +415,17 @@ const char* Compiler::eeGetMethodFullName( // Try without signature p.Truncate(0); - success = eeRunFunctorWithSPMIErrorTrap([&]() { - eePrintMethod(&p, clsHnd, hnd, - /* sig */ nullptr, - /* includeClassInstantiation */ false, - /* includeMethodInstantiation */ false, - /* includeSignature */ false, - /* includeReturnType */ false, - /* includeThisSpecifier */ false); - }); + success = eeRunFunctorWithSPMIErrorTrap( + [&]() + { + eePrintMethod(&p, clsHnd, hnd, + /* sig */ nullptr, + /* includeClassInstantiation */ false, + /* includeMethodInstantiation */ false, + /* includeSignature */ false, + /* includeReturnType */ false, + /* includeThisSpecifier */ false); + }); if (success) { @@ -435,15 +435,17 @@ const char* Compiler::eeGetMethodFullName( // Try with bare minimum p.Truncate(0); - success = eeRunFunctorWithSPMIErrorTrap([&]() { - eePrintMethod(&p, nullptr, hnd, - /* sig */ nullptr, - /* includeClassInstantiation */ false, - /* includeMethodInstantiation */ false, - /* includeSignature */ false, - /* includeReturnType */ false, - /* includeThisSpecifier */ false); - }); + success = eeRunFunctorWithSPMIErrorTrap( + [&]() + { + eePrintMethod(&p, nullptr, hnd, + /* sig */ nullptr, + /* includeClassInstantiation */ false, + /* includeMethodInstantiation */ false, + /* includeSignature */ false, + /* includeReturnType */ false, + /* includeThisSpecifier */ false); + }); if (success) { @@ -473,16 +475,17 @@ const char* Compiler::eeGetMethodFullName( const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffer, size_t bufferSize) { StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); - bool success = eeRunFunctorWithSPMIErrorTrap([&]() { - eePrintMethod(&p, NO_CLASS_HANDLE, methHnd, - /* sig */ nullptr, - /* includeClassInstantiation */ false, - /* includeMethodInstantiation */ false, - /* includeSignature */ false, - /* includeReturnType */ false, - /* includeThisSpecifier */ false); - - }); + bool success = eeRunFunctorWithSPMIErrorTrap( + [&]() + { + eePrintMethod(&p, NO_CLASS_HANDLE, methHnd, + /* sig */ nullptr, + /* includeClassInstantiation */ false, + /* includeMethodInstantiation */ false, + /* includeSignature */ false, + /* includeReturnType */ false, + /* includeThisSpecifier */ false); + }); if (!success) { diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index 778caa9b57e75e..a2a6cb15adc6e5 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -613,18 +613,14 @@ const unsigned short emitTypeActSz[] = { * Initialize the emitter - called once, at DLL load time. */ -void emitter::emitInit() -{ -} +void emitter::emitInit() {} /***************************************************************************** * * Shut down the emitter - called once, at DLL exit time. */ -void emitter::emitDone() -{ -} +void emitter::emitDone() {} /***************************************************************************** * @@ -759,9 +755,7 @@ void emitter::emitBegCG(Compiler* comp, COMP_HANDLE cmpHandle) #endif // TARGET_XARCH } -void emitter::emitEndCG() -{ -} +void emitter::emitEndCG() {} /***************************************************************************** * @@ -787,7 +781,7 @@ void emitter::emitGenIG(insGroup* ig) IMPL_LIMITATION("Too many arguments pushed on stack"); } -// printf("Start IG #%02u [stk=%02u]\n", ig->igNum, emitCurStackLvl); + // printf("Start IG #%02u [stk=%02u]\n", ig->igNum, emitCurStackLvl); #endif @@ -1205,7 +1199,7 @@ void emitter::emitBegFN(bool hasFramePtr , bool chkAlign #endif - ) +) { insGroup* ig; @@ -1369,9 +1363,7 @@ int emitter::emitNextRandomNop() * Done generating code to be scheduled; called once per method. */ -void emitter::emitEndFN() -{ -} +void emitter::emitEndFN() {} // member function iiaIsJitDataOffset for idAddrUnion, defers to Compiler::eeIsJitDataOffs bool emitter::instrDesc::idAddrUnion::iiaIsJitDataOffset() const @@ -1612,7 +1604,7 @@ void* emitter::emitAllocAnyInstr(size_t sz, emitAttr opsz) #if defined(FEATURE_EH_FUNCLETS) && !emitIGisInFuncletProlog(emitCurIG) && !emitIGisInFuncletEpilog(emitCurIG) #endif // FEATURE_EH_FUNCLETS - ) + ) { emitNxtIG(true); } @@ -1627,7 +1619,7 @@ void* emitter::emitAllocAnyInstr(size_t sz, emitAttr opsz) !emitIGisInProlog(emitCurIG) && // don't do this in prolog or epilog !emitIGisInEpilog(emitCurIG) && emitRandomNops // sometimes we turn off where exact codegen is needed (pinvoke inline) - ) + ) { if (emitNextNop == 0) { @@ -1761,7 +1753,7 @@ void* emitter::emitAllocAnyInstr(size_t sz, emitAttr opsz) #ifndef TARGET_AMD64 && emitComp->opts.compReloc #endif // TARGET_AMD64 - ) + ) { /* Mark idInfo()->idDspReloc to remember that the */ /* address mode has a displacement that is relocatable */ @@ -2074,7 +2066,7 @@ void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType, #if defined(FEATURE_EH_FUNCLETS) || igType == IGPT_FUNCLET_EPILOG #endif // FEATURE_EH_FUNCLETS - ) + ) { #ifdef TARGET_AMD64 emitOutputPreEpilogNOP(); @@ -2202,7 +2194,7 @@ void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType, #if defined(FEATURE_EH_FUNCLETS) || igType == IGPT_FUNCLET_EPILOG #endif // FEATURE_EH_FUNCLETS - ) + ) { // If this was an epilog, then assume this is the end of any currently in progress // no-GC region. If a block after the epilog needs to be no-GC, it needs to call @@ -2509,11 +2501,11 @@ void emitter::emitEndFnEpilog() // because the only instruction is the last one and thus a slight // underestimation of the epilog size is harmless (since the EIP // can not be between instructions). - assert(emitEpilogCnt == 1 || - (emitExitSeqSize - newSize) <= 5 // delta between size of various forms of jmp (size is either 6 or 5), - // and various forms of ret (size is either 1 or 3). The combination can - // be anything between 1 and 5. - ); + assert(emitEpilogCnt == 1 || (emitExitSeqSize - newSize) <= 5 // delta between size of various forms of jmp + // (size is either 6 or 5), and various forms of + // ret (size is either 1 or 3). The combination + // can be anything between 1 and 5. + ); emitExitSeqSize = newSize; } #endif // JIT32_GCENCODER @@ -2697,9 +2689,7 @@ void emitter::emitSetFrameRangeGCRs(int offsLo, int offsHi) * method. */ -void emitter::emitSetFrameRangeLcls(int offsLo, int offsHi) -{ -} +void emitter::emitSetFrameRangeLcls(int offsLo, int offsHi) {} /***************************************************************************** * @@ -2707,9 +2697,7 @@ void emitter::emitSetFrameRangeLcls(int offsLo, int offsHi) * method. */ -void emitter::emitSetFrameRangeArgs(int offsLo, int offsHi) -{ -} +void emitter::emitSetFrameRangeArgs(int offsLo, int offsHi) {} /***************************************************************************** * @@ -2825,11 +2813,11 @@ bool emitter::emitNoGChelper(CorInfoHelpFunc helpFunc) case CORINFO_HELP_LRSH: case CORINFO_HELP_LRSZ: -// case CORINFO_HELP_LMUL: -// case CORINFO_HELP_LDIV: -// case CORINFO_HELP_LMOD: -// case CORINFO_HELP_ULDIV: -// case CORINFO_HELP_ULMOD: + // case CORINFO_HELP_LMUL: + // case CORINFO_HELP_LDIV: + // case CORINFO_HELP_LMOD: + // case CORINFO_HELP_ULDIV: + // case CORINFO_HELP_ULMOD: #ifdef TARGET_X86 case CORINFO_HELP_ASSIGN_REF_EAX: @@ -2890,8 +2878,8 @@ bool emitter::emitNoGChelper(CORINFO_METHOD_HANDLE methHnd) * Mark the current spot as having a label. */ -void* emitter::emitAddLabel(VARSET_VALARG_TP GCvars, - regMaskTP gcrefRegs, +void* emitter::emitAddLabel(VARSET_VALARG_TP GCvars, + regMaskTP gcrefRegs, regMaskTP byrefRegs DEBUG_ARG(BasicBlock* block)) { /* Create a new IG if the current one is non-empty */ @@ -3048,7 +3036,8 @@ void emitter::emitSplit(emitLocation* startLoc, UNATIVE_OFFSET curSize; UNATIVE_OFFSET candidateSize; - auto splitIfNecessary = [&]() { + auto splitIfNecessary = [&]() + { if (curSize < maxSplitSize) { return; @@ -3088,7 +3077,7 @@ void emitter::emitSplit(emitLocation* startLoc, return; } -// Report it! + // Report it! #ifdef DEBUG if (EMITVERBOSE) @@ -3605,7 +3594,7 @@ emitter::instrDesc* emitter::emitNewInstrCallInd(int argCnt, VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, regMaskTP byrefRegs, - emitAttr retSizeIn + emitAttr retSizeIn MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize)) { emitAttr retSize = (retSizeIn != EA_UNKNOWN) ? retSizeIn : EA_PTRSIZE; @@ -3688,7 +3677,7 @@ emitter::instrDesc* emitter::emitNewInstrCallDir(int argCnt, VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, regMaskTP byrefRegs, - emitAttr retSizeIn + emitAttr retSizeIn MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize)) { emitAttr retSize = (retSizeIn != EA_UNKNOWN) ? retSizeIn : EA_PTRSIZE; @@ -3912,8 +3901,8 @@ void emitter::emitDispRegPtrListDelta() // Dump any deltas in regPtrDsc's for outgoing args; these aren't captured in the other sets. if (debugPrevRegPtrDsc != codeGen->gcInfo.gcRegPtrLast) { - for (regPtrDsc* dsc = (debugPrevRegPtrDsc == nullptr) ? codeGen->gcInfo.gcRegPtrList - : debugPrevRegPtrDsc->rpdNext; + for (regPtrDsc* dsc = (debugPrevRegPtrDsc == nullptr) ? codeGen->gcInfo.gcRegPtrList + : debugPrevRegPtrDsc->rpdNext; dsc != nullptr; dsc = dsc->rpdNext) { // The non-arg regPtrDscs are reflected in the register sets debugPrevGCrefRegs/emitThisGCrefRegs @@ -4397,7 +4386,7 @@ size_t emitter::emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp) ig->igPerfScore += insPerfScore; #endif // defined(DEBUG) || defined(LATE_DISASM) -// printf("[S=%02u]\n", emitCurStackLvl); + // printf("[S=%02u]\n", emitCurStackLvl); #if EMIT_TRACK_STACK_DEPTH @@ -4559,7 +4548,7 @@ void emitter::emitDispCommentForHandle(size_t handle, size_t cookie, GenTreeFlag #ifdef DEBUG emitComp->eePrintObjectDescription(commentPrefix, (CORINFO_OBJECT_HANDLE)handle); #else - str = "frozen object handle"; + str = "frozen object handle"; #endif } else if (flag == GTF_ICON_CLASS_HDL) @@ -4870,9 +4859,9 @@ void emitter::emitJumpDistBind() int jmp_iteration = 1; -/*****************************************************************************/ -/* If we iterate to look for more jumps to shorten, we start again here. */ -/*****************************************************************************/ + /*****************************************************************************/ + /* If we iterate to look for more jumps to shorten, we start again here. */ + /*****************************************************************************/ AGAIN: @@ -4880,10 +4869,10 @@ void emitter::emitJumpDistBind() emitCheckIGList(); #endif -/* - In the following loop we convert all jump targets from "BasicBlock *" - to "insGroup *" values. We also estimate which jumps will be short. - */ + /* + In the following loop we convert all jump targets from "BasicBlock *" + to "insGroup *" values. We also estimate which jumps will be short. + */ #ifdef DEBUG insGroup* lastIG = nullptr; @@ -5023,7 +5012,7 @@ void emitter::emitJumpDistBind() } #endif // TARGET_ARM64 -/* Make sure the jumps are properly ordered */ + /* Make sure the jumps are properly ordered */ #ifdef DEBUG assert(lastLJ == nullptr || lastIG != jmp->idjIG || lastLJ->idjOffs < jmp->idjOffs); @@ -5427,9 +5416,9 @@ void emitter::emitJumpDistBind() continue; - /*****************************************************************************/ - /* Handle conversion to short jump */ - /*****************************************************************************/ + /*****************************************************************************/ + /* Handle conversion to short jump */ + /*****************************************************************************/ SHORT_JMP: @@ -5469,9 +5458,9 @@ void emitter::emitJumpDistBind() #if defined(TARGET_ARM) - /*****************************************************************************/ - /* Handle conversion to medium jump */ - /*****************************************************************************/ + /*****************************************************************************/ + /* Handle conversion to medium jump */ + /*****************************************************************************/ MEDIUM_JMP: @@ -5496,7 +5485,7 @@ void emitter::emitJumpDistBind() #endif // TARGET_ARM - /*****************************************************************************/ + /*****************************************************************************/ NEXT_JMP: @@ -5572,7 +5561,7 @@ void emitter::emitJumpDistBind() #if defined(TARGET_ARM) || (minMediumExtra <= adjIG) #endif // TARGET_ARM - ) + ) { jmp_iteration++; @@ -5827,8 +5816,8 @@ bool emitter::emitEndsWithAlignInstr() // Returns: size of a loop in bytes. // unsigned emitter::getLoopSize(insGroup* igLoopHeader, - unsigned maxLoopSize // - DEBUG_ARG(bool isAlignAdjusted) // + unsigned maxLoopSize // + DEBUG_ARG(bool isAlignAdjusted) // DEBUG_ARG(UNATIVE_OFFSET containingIGNum) // DEBUG_ARG(UNATIVE_OFFSET loopHeadPredIGNum)) { @@ -6236,7 +6225,7 @@ void emitter::emitLoopAlignAdjustments() } #endif // TARGET_XARCH & TARGET_ARM64 #endif // DEBUG - // Adjust the padding amount in all align instructions in this IG + // Adjust the padding amount in all align instructions in this IG instrDescAlign *alignInstrToAdj = alignInstr, *prevAlignInstr = nullptr; for (; alignInstrToAdj != nullptr && alignInstrToAdj->idaIG == alignInstr->idaIG; alignInstrToAdj = alignInstrToAdj->idaNext) @@ -6332,7 +6321,7 @@ void emitter::emitLoopAlignAdjustments() // 3b. If the loop already fits in minimum alignmentBoundary blocks, then return 0. // already best aligned // 3c. return paddingNeeded. // -unsigned emitter::emitCalculatePaddingForLoopAlignment(insGroup* loopHeadIG, +unsigned emitter::emitCalculatePaddingForLoopAlignment(insGroup* loopHeadIG, size_t offset DEBUG_ARG(bool isAlignAdjusted) DEBUG_ARG(UNATIVE_OFFSET containingIGNum) DEBUG_ARG(UNATIVE_OFFSET loopHeadPredIGNum)) @@ -6673,18 +6662,18 @@ void emitter::emitComputeCodeSizes() // Returns: // size of the method code, in bytes // -unsigned emitter::emitEndCodeGen(Compiler* comp, - bool contTrkPtrLcls, - bool fullyInt, - bool fullPtrMap, - unsigned xcptnsCount, - unsigned* prologSize, - unsigned* epilogSize, - void** codeAddr, - void** codeAddrRW, - void** coldCodeAddr, - void** coldCodeAddrRW, - void** consAddr, +unsigned emitter::emitEndCodeGen(Compiler* comp, + bool contTrkPtrLcls, + bool fullyInt, + bool fullPtrMap, + unsigned xcptnsCount, + unsigned* prologSize, + unsigned* epilogSize, + void** codeAddr, + void** codeAddrRW, + void** coldCodeAddr, + void** coldCodeAddrRW, + void** consAddr, void** consAddrRW DEBUGARG(unsigned* instrCount)) { #ifdef DEBUG @@ -7116,7 +7105,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, assert(indx < emitComp->lvaTrackedCount); -// printf("Variable #%2u/%2u is at stack offset %d\n", num, indx, offs); + // printf("Variable #%2u/%2u is at stack offset %d\n", num, indx, offs); #ifdef JIT32_GCENCODER #ifndef FEATURE_EH_FUNCLETS @@ -8445,7 +8434,7 @@ void emitter::emitDispDataSec(dataSecDsc* section, BYTE* dst) printf("\tdd\t%08Xh", (uint32_t)(size_t)emitOffsetToPtr(ig->igOffs)); } #else // TARGET_64BIT - // We have a 64-BIT target + // We have a 64-BIT target if (emitComp->opts.disDiffable) { printf("\tdq\t%s\n", blockLabel); @@ -9042,7 +9031,7 @@ void emitter::emitGCregDeadSet(GCtype gcType, regMaskTP regMask, BYTE* addr) unsigned char emitter::emitOutputByte(BYTE* dst, ssize_t val) { - BYTE* dstRW = dst + writeableOffset; + BYTE* dstRW = dst + writeableOffset; *castto(dstRW, unsigned char*) = (unsigned char)val; #ifdef DEBUG @@ -9808,13 +9797,13 @@ cnsval_ssize_t emitter::emitGetInsSC(const instrDesc* id) const else #endif // TARGET_ARM if (id->idIsLargeCns()) - { - return ((instrDescCns*)id)->idcCnsVal; - } - else - { - return id->idSmallCns(); - } + { + return ((instrDescCns*)id)->idcCnsVal; + } + else + { + return id->idSmallCns(); + } } #ifdef TARGET_ARM @@ -9925,7 +9914,7 @@ void emitter::emitStackPop(BYTE* addr, bool isCall, unsigned char callInstrSize, #ifndef JIT32_GCENCODER || (emitComp->IsFullPtrRegMapRequired() && !emitComp->GetInterruptible() && isCall) #endif // JIT32_GCENCODER - ) + ) { emitStackPopLargeStk(addr, isCall, callInstrSize, 0); } @@ -10202,17 +10191,17 @@ void emitter::emitStackKillArgs(BYTE* addr, unsigned count, unsigned char callIn #ifdef DEBUG -void emitter::emitRecordRelocationHelp(void* location, /* IN */ - void* target, /* IN */ - uint16_t fRelocType, /* IN */ - const char* relocTypeName, /* IN */ +void emitter::emitRecordRelocationHelp(void* location, /* IN */ + void* target, /* IN */ + uint16_t fRelocType, /* IN */ + const char* relocTypeName, /* IN */ int32_t addlDelta /* = 0 */) /* IN */ #else // !DEBUG -void emitter::emitRecordRelocation(void* location, /* IN */ - void* target, /* IN */ - uint16_t fRelocType, /* IN */ +void emitter::emitRecordRelocation(void* location, /* IN */ + void* target, /* IN */ + uint16_t fRelocType, /* IN */ int32_t addlDelta /* = 0 */) /* IN */ #endif // !DEBUG diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index 48f5edeef728b3..fa7c53b21572af 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -118,7 +118,7 @@ inline const char* GCtypeStr(GCtype gcType) #if DEBUG_EMIT #define INTERESTING_JUMP_NUM -1 // set to 0 to see all jump info -//#define INTERESTING_JUMP_NUM 0 +// #define INTERESTING_JUMP_NUM 0 #endif /***************************************************************************** @@ -129,13 +129,9 @@ inline const char* GCtypeStr(GCtype gcType) class emitLocation { public: - emitLocation() : ig(nullptr), codePos(0) - { - } + emitLocation() : ig(nullptr), codePos(0) {} - emitLocation(insGroup* _ig) : ig(_ig), codePos(0) - { - } + emitLocation(insGroup* _ig) : ig(_ig), codePos(0) {} emitLocation(insGroup* _ig, unsigned _codePos) { @@ -147,9 +143,7 @@ class emitLocation CaptureLocation(emit); } - emitLocation(void* emitCookie) : ig((insGroup*)emitCookie), codePos(0) - { - } + emitLocation(void* emitCookie) : ig((insGroup*)emitCookie), codePos(0) {} // A constructor for code that needs to call it explicitly. void Init() @@ -294,12 +288,15 @@ struct insGroup #define IGF_NOGCINTERRUPT 0x0020 // this IG is in a no-interrupt region (prolog, epilog, etc.) #define IGF_UPD_ISZ 0x0040 // some instruction sizes updated #define IGF_PLACEHOLDER 0x0080 // this is a placeholder group, to be filled in later -#define IGF_EXTEND 0x0100 // this block is conceptually an extension of the previous block - // and the emitter should continue to track GC info as if there was no new block. -#define IGF_HAS_ALIGN 0x0200 // this group contains an alignment instruction(s) at the end to align either the next - // IG, or, if this IG contains with an unconditional branch, some subsequent IG. -#define IGF_REMOVED_ALIGN 0x0400 // IG was marked as having an alignment instruction(s), but was later unmarked - // without updating the IG's size/offsets. +#define IGF_EXTEND \ + 0x0100 // this block is conceptually an extension of the previous block + // and the emitter should continue to track GC info as if there was no new block. +#define IGF_HAS_ALIGN \ + 0x0200 // this group contains an alignment instruction(s) at the end to align either the next + // IG, or, if this IG contains with an unconditional branch, some subsequent IG. +#define IGF_REMOVED_ALIGN \ + 0x0400 // IG was marked as having an alignment instruction(s), but was later unmarked + // without updating the IG's size/offsets. #define IGF_HAS_REMOVABLE_JMP 0x0800 // this group ends with an unconditional jump which is a candidate for removal #ifdef TARGET_ARM64 #define IGF_HAS_REMOVED_INSTR 0x1000 // this group has an instruction that was removed. @@ -325,7 +322,8 @@ struct insGroup regMaskSmall igGCregs; // set of registers with live GC refs #endif // !(REGMASK_BITS <= 32) - union { + union + { BYTE* igData; // addr of instruction descriptors insPlaceholderGroupData* igPhData; // when igFlags & IGF_PLACEHOLDER }; @@ -513,7 +511,7 @@ class emitter #ifdef TARGET_AMD64 OPSZP = OPSZ8, #else - OPSZP = OPSZ4, + OPSZP = OPSZ4, #endif }; @@ -522,7 +520,7 @@ class emitter static const emitAttr emitSizeDecode[]; static emitter::opSize emitEncodeSize(emitAttr size); - static emitAttr emitDecodeSize(emitter::opSize ensz); + static emitAttr emitDecodeSize(emitter::opSize ensz); // Currently, we only allow one IG for the prolog bool emitIGisInProlog(const insGroup* ig) @@ -643,9 +641,9 @@ class emitter static_assert_no_msg(IF_COUNT <= 128); insFormat _idInsFmt : 7; #elif defined(TARGET_LOONGARCH64) - unsigned _idCodeSize : 5; // the instruction(s) size of this instrDesc described. + unsigned _idCodeSize : 5; // the instruction(s) size of this instrDesc described. #elif defined(TARGET_RISCV64) - unsigned _idCodeSize : 6; // the instruction(s) size of this instrDesc described. + unsigned _idCodeSize : 6; // the instruction(s) size of this instrDesc described. #elif defined(TARGET_ARM64) static_assert_no_msg(IF_COUNT <= 1024); insFormat _idInsFmt : 10; @@ -681,11 +679,9 @@ class emitter { // not used for LOONGARCH64. return (insFormat)0; } - void idInsFmt(insFormat insFmt) - { - } + void idInsFmt(insFormat insFmt) {} #elif defined(TARGET_RISCV64) - insFormat idInsFmt() const + insFormat idInsFmt() const { NYI_RISCV64("idInsFmt-----unimplemented on RISCV64 yet----"); return (insFormat)0; @@ -695,7 +691,7 @@ class emitter NYI_RISCV64("idInsFmt-----unimplemented on RISCV64 yet----"); } #else - insFormat idInsFmt() const + insFormat idInsFmt() const { return _idInsFmt; } @@ -730,7 +726,7 @@ class emitter #elif defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) /* _idOpSize defined below. */ #else - opSize _idOpSize : 2; // operand size: 0=1 , 1=2 , 2=4 , 3=8 + opSize _idOpSize : 2; // operand size: 0=1 , 1=2 , 2=4 , 3=8 #endif // TARGET_ARM64 || TARGET_LOONGARCH64 || TARGET_RISCV64 // On Amd64, this is where the second DWORD begins @@ -803,7 +799,7 @@ class emitter #endif #ifdef TARGET_LOONGARCH64 - // TODO-LoongArch64: maybe delete on future. + // TODO-LoongArch64: maybe delete on future. opSize _idOpSize : 3; // operand size: 0=1 , 1=2 , 2=4 , 3=8, 4=16 insOpts _idInsOpt : 6; // loongarch options for special: placeholders. e.g emitIns_R_C, also identifying the // accessing a local on stack. @@ -892,7 +888,7 @@ class emitter #define ID_EXTRA_BITS (ID_EXTRA_RELOC_BITS + ID_EXTRA_BITFIELD_BITS + ID_EXTRA_PREV_OFFSET_BITS) -/* Use whatever bits are left over for small constants */ + /* Use whatever bits are left over for small constants */ #define ID_BIT_SMALL_CNS (32 - ID_EXTRA_BITS) C_ASSERT(ID_BIT_SMALL_CNS > 0); @@ -951,9 +947,10 @@ class emitter void checkSizes(); - union idAddrUnion { -// TODO-Cleanup: We should really add a DEBUG-only tag to this union so we can add asserts -// about reading what we think is here, to avoid unexpected corruption issues. + union idAddrUnion + { + // TODO-Cleanup: We should really add a DEBUG-only tag to this union so we can add asserts + // about reading what we think is here, to avoid unexpected corruption issues. #if !defined(TARGET_ARM64) && !defined(TARGET_LOONGARCH64) emitLclVarAddr iiaLclVar; @@ -2020,7 +2017,8 @@ class emitter instrDescJmp* idjNext; // next jump in the group/method insGroup* idjIG; // containing group - union { + union + { BYTE* idjAddr; // address of jump ins (for patching) } idjTemp; @@ -2210,7 +2208,7 @@ class emitter #endif // TARGET_ARM insUpdateModes emitInsUpdateMode(instruction ins); - insFormat emitInsModeFormat(instruction ins, insFormat base); + insFormat emitInsModeFormat(instruction ins, insFormat base); static const BYTE emitInsModeFmtTab[]; #ifdef DEBUG @@ -2225,7 +2223,7 @@ class emitter ssize_t emitGetInsDsp(instrDesc* id); ssize_t emitGetInsAmd(instrDesc* id); - ssize_t emitGetInsCIdisp(instrDesc* id); + ssize_t emitGetInsCIdisp(instrDesc* id); unsigned emitGetInsCIargs(instrDesc* id); inline emitAttr emitGetMemOpSize(instrDesc* id) const; @@ -2238,7 +2236,7 @@ class emitter #endif // TARGET_XARCH cnsval_ssize_t emitGetInsSC(const instrDesc* id) const; - unsigned emitInsCount; + unsigned emitInsCount; /************************************************************************/ /* A few routines used for debug display purposes */ @@ -2264,11 +2262,11 @@ class emitter regMaskTP debugPrevGCrefRegs; regMaskTP debugPrevByrefRegs; void emitDispInsIndent(); - void emitDispGCDeltaTitle(const char* title); - void emitDispGCRegDelta(const char* title, regMaskTP prevRegs, regMaskTP curRegs); - void emitDispGCVarDelta(); - void emitDispRegPtrListDelta(); - void emitDispGCInfoDelta(); + void emitDispGCDeltaTitle(const char* title); + void emitDispGCRegDelta(const char* title, regMaskTP prevRegs, regMaskTP curRegs); + void emitDispGCVarDelta(); + void emitDispRegPtrListDelta(); + void emitDispGCInfoDelta(); void emitDispIGflags(unsigned flags); void emitDispIG(insGroup* ig, @@ -2325,9 +2323,7 @@ class emitter EpilogList* elNext; emitLocation elLoc; - EpilogList() : elNext(nullptr), elLoc() - { - } + EpilogList() : elNext(nullptr), elLoc() {} }; EpilogList* emitEpilogList; // per method epilog list - head @@ -2362,12 +2358,12 @@ class emitter /* Methods to record a code position and later convert to offset */ /************************************************************************/ - unsigned emitFindInsNum(const insGroup* ig, const instrDesc* id) const; + unsigned emitFindInsNum(const insGroup* ig, const instrDesc* id) const; UNATIVE_OFFSET emitFindOffset(const insGroup* ig, unsigned insNum) const; -/************************************************************************/ -/* Members and methods used to issue (encode) instructions. */ -/************************************************************************/ + /************************************************************************/ + /* Members and methods used to issue (encode) instructions. */ + /************************************************************************/ #ifdef DEBUG // If we have started issuing instructions from the list of instrDesc, this is set @@ -2458,9 +2454,9 @@ class emitter #endif // TARGET_LOONGARCH64 || TARGET_RISCV64 instrDesc* emitFirstInstrDesc(BYTE* idData) const; - void emitAdvanceInstrDesc(instrDesc** id, size_t idSize) const; - size_t emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp); - size_t emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp); + void emitAdvanceInstrDesc(instrDesc** id, size_t idSize) const; + size_t emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp); + size_t emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp); bool emitHasFramePtr; @@ -2511,13 +2507,13 @@ class emitter #endif // FEATURE_SIMD regNumber emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, GenTree* src); regNumber emitInsTernary(instruction ins, emitAttr attr, GenTree* dst, GenTree* src1, GenTree* src2); - void emitInsLoadInd(instruction ins, emitAttr attr, regNumber dstReg, GenTreeIndir* mem); - void emitInsStoreInd(instruction ins, emitAttr attr, GenTreeStoreInd* mem); - void emitInsStoreLcl(instruction ins, emitAttr attr, GenTreeLclVarCommon* varNode); + void emitInsLoadInd(instruction ins, emitAttr attr, regNumber dstReg, GenTreeIndir* mem); + void emitInsStoreInd(instruction ins, emitAttr attr, GenTreeStoreInd* mem); + void emitInsStoreLcl(instruction ins, emitAttr attr, GenTreeLclVarCommon* varNode); insFormat emitMapFmtForIns(insFormat fmt, instruction ins); insFormat emitMapFmtAtoM(insFormat fmt); - void emitHandleMemOp(GenTreeIndir* indir, instrDesc* id, insFormat fmt, instruction ins); - void spillIntArgRegsToShadowSlots(); + void emitHandleMemOp(GenTreeIndir* indir, instrDesc* id, insFormat fmt, instruction ins); + void spillIntArgRegsToShadowSlots(); #ifdef TARGET_XARCH bool emitIsInstrWritingToReg(instrDesc* id, regNumber reg); @@ -2604,22 +2600,22 @@ class emitter // non-adaptive alignment on xarch, this points to the first align instruction of the series of align instructions. instrDescAlign* emitAlignLastGroup; - unsigned getLoopSize(insGroup* igLoopHeader, + unsigned getLoopSize(insGroup* igLoopHeader, unsigned maxLoopSize DEBUG_ARG(bool isAlignAdjusted) DEBUG_ARG(UNATIVE_OFFSET containingIGNum) DEBUG_ARG(UNATIVE_OFFSET loopHeadPredIGNum)); // Get the smallest loop size - void emitLoopAlignment(DEBUG_ARG1(bool isPlacedBehindJmp)); - bool emitEndsWithAlignInstr(); // Validate if newLabel is appropriate - bool emitSetLoopBackEdge(const BasicBlock* loopTopBlock); + void emitLoopAlignment(DEBUG_ARG1(bool isPlacedBehindJmp)); + bool emitEndsWithAlignInstr(); // Validate if newLabel is appropriate + bool emitSetLoopBackEdge(const BasicBlock* loopTopBlock); void emitLoopAlignAdjustments(); // Predict if loop alignment is needed and make appropriate adjustments - unsigned emitCalculatePaddingForLoopAlignment(insGroup* ig, + unsigned emitCalculatePaddingForLoopAlignment(insGroup* ig, size_t offset DEBUG_ARG(bool isAlignAdjusted) DEBUG_ARG(UNATIVE_OFFSET containingIGNum) DEBUG_ARG(UNATIVE_OFFSET loopHeadPredIGNum)); - void emitLoopAlign(unsigned paddingBytes, bool isFirstAlign DEBUG_ARG(bool isPlacedBehindJmp)); - void emitLongLoopAlign(unsigned alignmentBoundary DEBUG_ARG(bool isPlacedBehindJmp)); + void emitLoopAlign(unsigned paddingBytes, bool isFirstAlign DEBUG_ARG(bool isPlacedBehindJmp)); + void emitLongLoopAlign(unsigned alignmentBoundary DEBUG_ARG(bool isPlacedBehindJmp)); instrDescAlign* emitAlignInNextIG(instrDescAlign* alignInstr); - void emitConnectAlignInstrWithCurIG(); + void emitConnectAlignInstrWithCurIG(); #endif @@ -2692,7 +2688,7 @@ class emitter void emitSetSecondRetRegGCType(instrDescCGCA* id, emitAttr secondRetSize); #endif // MULTIREG_HAS_SECOND_GC_RET - static void emitEncodeCallGCregs(regMaskTP regs, instrDesc* id); + static void emitEncodeCallGCregs(regMaskTP regs, instrDesc* id); static unsigned emitDecodeCallGCregs(instrDesc* id); unsigned emitNxtIGnum; @@ -2716,8 +2712,8 @@ class emitter insGroup* emitAllocAndLinkIG(); insGroup* emitAllocIG(); - void emitInitIG(insGroup* ig); - void emitInsertIGAfter(insGroup* insertAfterIG, insGroup* ig); + void emitInitIG(insGroup* ig); + void emitInsertIGAfter(insGroup* insertAfterIG, insGroup* ig); void emitNewIG(); @@ -2732,9 +2728,9 @@ class emitter static bool emitJmpInstHasNoCode(instrDesc* id); #endif - void emitGenIG(insGroup* ig); + void emitGenIG(insGroup* ig); insGroup* emitSavIG(bool emitAdd = false); - void emitNxtIG(bool extend = false); + void emitNxtIG(bool extend = false); #ifdef TARGET_ARM64 void emitRemoveLastInstruction(); @@ -2864,8 +2860,8 @@ class emitter // Mark this instruction group as having a label; return the new instruction group. // Sets the emitter's record of the currently live GC variables // and registers. - void* emitAddLabel(VARSET_VALARG_TP GCvars, - regMaskTP gcrefRegs, + void* emitAddLabel(VARSET_VALARG_TP GCvars, + regMaskTP gcrefRegs, regMaskTP byrefRegs DEBUG_ARG(BasicBlock* block = nullptr)); // Same as above, except the label is added and is conceptually "inline" in @@ -2873,7 +2869,7 @@ class emitter // continues to track GC info as if there was no label. void* emitAddInlineLabel(); - void emitPrintLabel(const insGroup* ig) const; + void emitPrintLabel(const insGroup* ig) const; const char* emitLabelString(const insGroup* ig) const; #if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) @@ -3096,7 +3092,7 @@ class emitter return (offs >= emitGCrFrameOffsMin) && (offs < emitGCrFrameOffsMax); } - static instruction emitJumpKindToIns(emitJumpKind jumpKind); + static instruction emitJumpKindToIns(emitJumpKind jumpKind); static emitJumpKind emitInsToJumpKind(instruction ins); static emitJumpKind emitReverseJumpKind(emitJumpKind jumpKind); @@ -3161,7 +3157,8 @@ class emitter bool emitSimpleStkUsed; // using the "simple" stack table? - union { + union + { struct // if emitSimpleStkUsed==true { @@ -3209,8 +3206,8 @@ class emitter #ifdef DEBUG const char* emitGetFrameReg(); - void emitDispRegSet(regMaskTP regs); - void emitDispVarSet(); + void emitDispRegSet(regMaskTP regs); + void emitDispVarSet(); #endif void emitGCregLiveUpd(GCtype gcType, regNumber reg, BYTE* addr); @@ -3275,9 +3272,7 @@ class emitter UNATIVE_OFFSET dsdOffs; UNATIVE_OFFSET alignment; // in bytes, defaults to 4 - dataSecDsc() : dsdList(nullptr), dsdLast(nullptr), dsdOffs(0), alignment(4) - { - } + dataSecDsc() : dsdList(nullptr), dsdLast(nullptr), dsdOffs(0), alignment(4) {} }; dataSecDsc emitConsDsc; @@ -3293,9 +3288,9 @@ class emitter COMP_HANDLE emitCmpHandle; -/************************************************************************/ -/* Helpers for interface to EE */ -/************************************************************************/ + /************************************************************************/ + /* Helpers for interface to EE */ + /************************************************************************/ #ifdef DEBUG @@ -3305,25 +3300,25 @@ class emitter #define emitRecordRelocationWithAddlDelta(location, target, fRelocType, addlDelta) \ emitRecordRelocationHelp(location, target, fRelocType, #fRelocType, addlDelta) - void emitRecordRelocationHelp(void* location, /* IN */ - void* target, /* IN */ - uint16_t fRelocType, /* IN */ - const char* relocTypeName, /* IN */ - int32_t addlDelta = 0); /* IN */ + void emitRecordRelocationHelp(void* location, /* IN */ + void* target, /* IN */ + uint16_t fRelocType, /* IN */ + const char* relocTypeName, /* IN */ + int32_t addlDelta = 0); /* IN */ #else // !DEBUG void emitRecordRelocationWithAddlDelta(void* location, /* IN */ void* target, /* IN */ uint16_t fRelocType, /* IN */ - int32_t addlDelta) /* IN */ + int32_t addlDelta) /* IN */ { emitRecordRelocation(location, target, fRelocType, addlDelta); } - void emitRecordRelocation(void* location, /* IN */ - void* target, /* IN */ - uint16_t fRelocType, /* IN */ + void emitRecordRelocation(void* location, /* IN */ + void* target, /* IN */ + uint16_t fRelocType, /* IN */ int32_t addlDelta = 0); /* IN */ #endif // !DEBUG @@ -3343,9 +3338,9 @@ class emitter CORINFO_SIG_INFO* emitScratchSigInfo; #endif // DEBUG -/************************************************************************/ -/* Logic to collect and display statistics */ -/************************************************************************/ + /************************************************************************/ + /* Logic to collect and display statistics */ + /************************************************************************/ #if EMITTER_STATS @@ -3482,10 +3477,10 @@ class emitter } #endif // EMITTER_STATS -/************************************************************************* - * - * Define any target-dependent emitter members. - */ + /************************************************************************* + * + * Define any target-dependent emitter members. + */ #include "emitdef.h" diff --git a/src/coreclr/jit/emitarm.cpp b/src/coreclr/jit/emitarm.cpp index 3fa92b60d0e5b5..52453dca5657ad 100644 --- a/src/coreclr/jit/emitarm.cpp +++ b/src/coreclr/jit/emitarm.cpp @@ -1708,10 +1708,10 @@ void emitter::emitIns_R(instruction ins, emitAttr attr, regNumber reg) * Add an instruction referencing a register and a constant. */ -void emitter::emitIns_R_I(instruction ins, - emitAttr attr, - regNumber reg, - target_ssize_t imm, +void emitter::emitIns_R_I(instruction ins, + emitAttr attr, + regNumber reg, + target_ssize_t imm, insFlags flags /* = INS_FLAGS_DONT_CARE */ DEBUGARG(GenTreeFlags gtFlags)) { @@ -1738,7 +1738,7 @@ void emitter::emitIns_R_I(instruction ins, ins = INS_sub; else // ins == INS_sub ins = INS_add; - imm = -imm; + imm = -imm; } fmt = IF_T1_J0; sf = INS_FLAGS_SET; @@ -2607,7 +2607,7 @@ void emitter::emitIns_R_R_I(instruction ins, ins = INS_sub; else ins = INS_add; - imm = -imm; + imm = -imm; } fmt = IF_T1_G; sf = INS_FLAGS_SET; @@ -2621,7 +2621,7 @@ void emitter::emitIns_R_R_I(instruction ins, ins = INS_sub; else ins = INS_add; - imm = -imm; + imm = -imm; } // Use Thumb-1 encoding emitIns_R_I(ins, attr, reg1, imm, flags); @@ -2982,9 +2982,9 @@ void emitter::emitIns_R_R_I(instruction ins, } } } - // - // If we did not find a thumb-1 encoding above - // + // + // If we did not find a thumb-1 encoding above + // COMMON_THUMB2_LDST: assert(fmt == IF_NONE); @@ -3185,8 +3185,8 @@ void emitter::emitIns_R_R_R(instruction ins, case INS_mul: if (insMustSetFlags(flags)) { - assert(reg1 != - REG_PC); // VM debugging single stepper doesn't support PC register with this instruction. + assert(reg1 != REG_PC); // VM debugging single stepper doesn't support PC register with this + // instruction. assert(reg2 != REG_PC); assert(reg3 != REG_PC); @@ -4836,7 +4836,7 @@ void emitter::emitIns_Call(EmitCallType callType, if (m_debugInfoSize > 0) { INDEBUG(id->idDebugOnlyInfo()->idCallSig = sigInfo); - id->idDebugOnlyInfo()->idMemCookie = (size_t)methHnd; // method token + id->idDebugOnlyInfo()->idMemCookie = (size_t)methHnd; // method token } #ifdef LATE_DISASM @@ -5236,7 +5236,7 @@ unsigned emitter::emitOutput_Thumb1Instr(BYTE* dst, code_t code) unsigned emitter::emitOutput_Thumb2Instr(BYTE* dst, code_t code) { unsigned short word1 = (code >> 16) & 0xffff; - unsigned short word2 = (code)&0xffff; + unsigned short word2 = (code) & 0xffff; assert((code_t)((word1 << 16) | word2) == code); #ifdef DEBUG @@ -5342,7 +5342,7 @@ BYTE* emitter::emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* i) if (dstOffs <= srcOffs) { -/* This is a backward jump - distance is known at this point */ + /* This is a backward jump - distance is known at this point */ #if DEBUG_EMIT if (id->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0) @@ -5731,7 +5731,7 @@ BYTE* emitter::emitOutputIT(BYTE* dst, instruction ins, insFormat fmt, code_t co #endif // FEATURE_ITINSTRUCTION /***************************************************************************** -* + * * Append the machine code corresponding to the given instruction descriptor * to the code block at '*dp'; the base of the code block is 'bp', and 'ig' * is the instruction group that contains the instruction. Updates '*dp' to @@ -6561,9 +6561,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) break; - /********************************************************************/ - /* oops */ - /********************************************************************/ + /********************************************************************/ + /* oops */ + /********************************************************************/ default: diff --git a/src/coreclr/jit/emitarm.h b/src/coreclr/jit/emitarm.h index 245196bfa18346..6ae0c57dea6d26 100644 --- a/src/coreclr/jit/emitarm.h +++ b/src/coreclr/jit/emitarm.h @@ -81,7 +81,7 @@ bool emitInsIsStore(instruction ins); bool emitInsIsLoadOrStore(instruction ins); emitter::insFormat emitInsFormat(instruction ins); -emitter::code_t emitInsCode(instruction ins, insFormat fmt); +emitter::code_t emitInsCode(instruction ins, insFormat fmt); // Generate code for a load or store operation and handle the case // of contained GT_LEA op1 with [base + index<idInsOpt())) { - assert((emitGetInsSC(id) > 0) || - (id->idReg2() == REG_ZR)); // REG_ZR encodes SP and we allow a shift of zero + assert((emitGetInsSC(id) > 0) || (id->idReg2() == REG_ZR)); // REG_ZR encodes SP and we allow a shift of + // zero } break; @@ -967,7 +967,7 @@ bool emitter::emitInsMayWriteToGCReg(instrDesc* id) switch (fmt) { - // These are the formats with "destination" registers: + // These are the formats with "destination" registers: case IF_DI_1B: // DI_1B X........hwiiiii iiiiiiiiiiiddddd Rd imm(i16,hw) case IF_DI_1D: // DI_1D X........Nrrrrrr ssssss.....ddddd Rd imm(N,r,s) @@ -1031,7 +1031,7 @@ bool emitter::emitInsMayWriteToGCReg(instrDesc* id) // Tracked GC pointers cannot be placed into the SIMD registers. return false; - // These are the load/store formats with "target" registers: + // These are the load/store formats with "target" registers: case IF_LS_1A: // LS_1A XX...V..iiiiiiii iiiiiiiiiiittttt Rt PC imm(1MB) case IF_LS_2A: // LS_2A .X.......X...... ......nnnnnttttt Rt Rn @@ -1733,8 +1733,8 @@ emitter::code_t emitter::emitInsCode(instruction ins, insFormat fmt) }; // clang-format on - const static insFormat formatEncode9[9] = {IF_DR_2E, IF_DR_2G, IF_DI_1B, IF_DI_1D, IF_DV_3C, - IF_DV_2B, IF_DV_2C, IF_DV_2E, IF_DV_2F}; + const static insFormat formatEncode9[9] = {IF_DR_2E, IF_DR_2G, IF_DI_1B, IF_DI_1D, IF_DV_3C, + IF_DV_2B, IF_DV_2C, IF_DV_2E, IF_DV_2F}; const static insFormat formatEncode6A[6] = {IF_DR_3A, IF_DR_3B, IF_DR_3C, IF_DI_2A, IF_DV_3A, IF_DV_3E}; const static insFormat formatEncode6B[6] = {IF_LS_2D, IF_LS_3F, IF_LS_2E, IF_LS_2F, IF_LS_3G, IF_LS_2G}; const static insFormat formatEncode5A[5] = {IF_LS_2A, IF_LS_2B, IF_LS_2C, IF_LS_3A, IF_LS_1A}; @@ -3748,13 +3748,13 @@ void emitter::emitIns_R(instruction ins, emitAttr attr, regNumber reg, insOpts o * Add an instruction referencing a register and a constant. */ -void emitter::emitIns_R_I(instruction ins, - emitAttr attr, - regNumber reg, - ssize_t imm, - insOpts opt, /* = INS_OPTS_NONE */ +void emitter::emitIns_R_I(instruction ins, + emitAttr attr, + regNumber reg, + ssize_t imm, + insOpts opt, /* = INS_OPTS_NONE */ insScalableOpts sopt /* = INS_SCALABLE_OPTS_NONE */ - DEBUGARG(size_t targetHandle /* = 0 */) DEBUGARG(GenTreeFlags gtFlags /* = GTF_EMPTY */)) + DEBUGARG(size_t targetHandle /* = 0 */) DEBUGARG(GenTreeFlags gtFlags /* = GTF_EMPTY */)) { emitAttr size = EA_SIZE(attr); emitAttr elemsize = EA_UNKNOWN; @@ -3940,8 +3940,8 @@ void emitter::emitIns_R_I(instruction ins, // First try the standard 'byteShifted immediate' imm(i8,bySh) bsi.immBSVal = 0; canEncode = canEncodeByteShiftedImm(imm, elemsize, - (ins == INS_mvni), // mvni supports the ones shifting variant (aka MSL) - &bsi); + (ins == INS_mvni), // mvni supports the ones shifting variant (aka MSL) + &bsi); if (canEncode) { imm = bsi.immBSVal; @@ -4955,8 +4955,8 @@ void emitter::emitIns_R_I_I(instruction ins, regNumber reg, ssize_t imm1, ssize_t imm2, - insOpts opt /* = INS_OPTS_NONE */ - DEBUGARG(size_t targetHandle /* = 0 */) DEBUGARG(GenTreeFlags gtFlags /* = 0 */)) + insOpts opt /* = INS_OPTS_NONE */ + DEBUGARG(size_t targetHandle /* = 0 */) DEBUGARG(GenTreeFlags gtFlags /* = 0 */)) { emitAttr size = EA_SIZE(attr); insFormat fmt = IF_NONE; @@ -5792,15 +5792,15 @@ void emitter::emitIns_R_R_F( } /***************************************************************************** -* -* Add an instruction referencing two registers and a constant. -* Also checks for a large immediate that needs a second instruction -* and will load it in reg1 -* -* - Supports instructions: add, adds, sub, subs, and, ands, eor and orr -* - Requires that reg1 is a general register and not SP or ZR -* - Requires that reg1 != reg2 -*/ + * + * Add an instruction referencing two registers and a constant. + * Also checks for a large immediate that needs a second instruction + * and will load it in reg1 + * + * - Supports instructions: add, adds, sub, subs, and, ands, eor and orr + * - Requires that reg1 is a general register and not SP or ZR + * - Requires that reg1 != reg2 + */ void emitter::emitIns_R_R_Imm(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, ssize_t imm) { assert(isGeneralRegister(reg1)); @@ -6554,7 +6554,7 @@ void emitter::emitIns_R_R_R_I_LdStPair(instruction ins, int varx1, int varx2, int offs1, - int offs2 DEBUG_ARG(unsigned var1RefsOffs) DEBUG_ARG(unsigned var2RefsOffs)) + int offs2 DEBUG_ARG(unsigned var1RefsOffs) DEBUG_ARG(unsigned var2RefsOffs)) { assert((ins == INS_stp) || (ins == INS_ldp)); emitAttr size = EA_SIZE(attr); @@ -7147,7 +7147,7 @@ void emitter::emitIns_R_R_R_Ext(instruction ins, regNumber reg1, regNumber reg2, regNumber reg3, - insOpts opt, /* = INS_OPTS_NONE */ + insOpts opt, /* = INS_OPTS_NONE */ int shiftAmount) /* = -1 -- unset */ { emitAttr size = EA_SIZE(attr); @@ -8482,9 +8482,9 @@ void emitter::emitIns_R_AR(instruction ins, emitAttr attr, regNumber ireg, regNu } // This generates code to populate the access for TLS on linux -void emitter::emitIns_Adrp_Ldr_Add(emitAttr attr, - regNumber reg1, - regNumber reg2, +void emitter::emitIns_Adrp_Ldr_Add(emitAttr attr, + regNumber reg1, + regNumber reg2, ssize_t addr DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { assert(emitComp->IsTargetAbi(CORINFO_NATIVEAOT_ABI)); @@ -8537,9 +8537,9 @@ void emitter::emitIns_Adrp_Ldr_Add(emitAttr attr, } // This computes address from the immediate which is relocatable. -void emitter::emitIns_R_AI(instruction ins, - emitAttr attr, - regNumber ireg, +void emitter::emitIns_R_AI(instruction ins, + emitAttr attr, + regNumber ireg, ssize_t addr DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { assert(EA_IS_RELOC(attr)); @@ -9108,7 +9108,7 @@ void emitter::emitIns_Call(EmitCallType callType, if (m_debugInfoSize > 0) { INDEBUG(id->idDebugOnlyInfo()->idCallSig = sigInfo); - id->idDebugOnlyInfo()->idMemCookie = (size_t)methHnd; // method token + id->idDebugOnlyInfo()->idMemCookie = (size_t)methHnd; // method token } #ifdef LATE_DISASM @@ -10438,9 +10438,9 @@ BYTE* emitter::emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* i) } /***************************************************************************** -* -* Output a short branch instruction. -*/ + * + * Output a short branch instruction. + */ BYTE* emitter::emitOutputShortBranch(BYTE* dst, instruction ins, insFormat fmt, ssize_t distVal, instrDescJmp* id) { code_t code = emitInsCode(ins, fmt); @@ -10503,9 +10503,9 @@ BYTE* emitter::emitOutputShortBranch(BYTE* dst, instruction ins, insFormat fmt, } /***************************************************************************** -* -* Output a short address instruction. -*/ + * + * Output a short address instruction. + */ BYTE* emitter::emitOutputShortAddress(BYTE* dst, instruction ins, insFormat fmt, ssize_t distVal, regNumber reg) { ssize_t loBits = (distVal & 3); @@ -10533,9 +10533,9 @@ BYTE* emitter::emitOutputShortAddress(BYTE* dst, instruction ins, insFormat fmt, } /***************************************************************************** -* -* Output a short constant instruction. -*/ + * + * Output a short constant instruction. + */ BYTE* emitter::emitOutputShortConstant( BYTE* dst, instruction ins, insFormat fmt, ssize_t imm, regNumber reg, emitAttr opSize) { @@ -10768,7 +10768,7 @@ unsigned emitter::emitOutput_Instr(BYTE* dst, code_t code) } /***************************************************************************** -* + * * Append the machine code corresponding to the given instruction descriptor * to the code block at '*dp'; the base of the code block is 'bp', and 'ig' * is the instruction group that contains the instruction. Updates '*dp' to @@ -11164,8 +11164,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) code = emitInsCode(ins, fmt); code |= insEncodeReg_Rd(id->idReg1()); // ddddd dst += emitOutput_Instr(dst, code); - emitRecordRelocation(odst, id->idAddr()->iiaAddr, id->idIsTlsGD() ? IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 - : IMAGE_REL_ARM64_PAGEBASE_REL21); + emitRecordRelocation(odst, id->idAddr()->iiaAddr, + id->idIsTlsGD() ? IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 + : IMAGE_REL_ARM64_PAGEBASE_REL21); } else { @@ -11208,8 +11209,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) { assert(sz == sizeof(instrDesc)); assert(id->idAddr()->iiaAddr != nullptr); - emitRecordRelocation(odst, id->idAddr()->iiaAddr, id->idIsTlsGD() ? IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 - : IMAGE_REL_ARM64_PAGEOFFSET_12A); + emitRecordRelocation(odst, id->idAddr()->iiaAddr, + id->idIsTlsGD() ? IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 + : IMAGE_REL_ARM64_PAGEOFFSET_12A); } break; @@ -12356,7 +12358,7 @@ void emitter::emitDispCond(insCond cond) { const static char* armCond[16] = {"eq", "ne", "hs", "lo", "mi", "pl", "vs", "vc", "hi", "ls", "ge", "lt", "gt", "le", "AL", "NV"}; // The last two are invalid - unsigned imm = (unsigned)cond; + unsigned imm = (unsigned)cond; assert((0 <= imm) && (imm < ArrLen(armCond))); printf(armCond[imm]); } @@ -12369,7 +12371,7 @@ void emitter::emitDispFlags(insCflags flags) { const static char* armFlags[16] = {"0", "v", "c", "cv", "z", "zv", "zc", "zcv", "n", "nv", "nc", "ncv", "nz", "nzv", "nzc", "nzcv"}; - unsigned imm = (unsigned)flags; + unsigned imm = (unsigned)flags; assert((0 <= imm) && (imm < ArrLen(armFlags))); printf(armFlags[imm]); } @@ -12382,7 +12384,7 @@ void emitter::emitDispBarrier(insBarrier barrier) { const static char* armBarriers[16] = {"#0", "oshld", "oshst", "osh", "#4", "nshld", "nshst", "nsh", "#8", "ishld", "ishst", "ish", "#12", "ld", "st", "sy"}; - unsigned imm = (unsigned)barrier; + unsigned imm = (unsigned)barrier; assert((0 <= imm) && (imm < ArrLen(armBarriers))); printf(armBarriers[imm]); } @@ -14681,9 +14683,9 @@ emitter::insExecutionCharacteristics emitter::getInsExecutionCharacteristics(ins switch (insFmt) { - // - // Branch Instructions - // + // + // Branch Instructions + // case IF_BI_0A: // b, bl_local case IF_BI_0C: // bl, b_tail @@ -14936,9 +14938,9 @@ emitter::insExecutionCharacteristics emitter::getInsExecutionCharacteristics(ins break; } - // - // Load/Store Instructions - // + // + // Load/Store Instructions + // case IF_LS_1A: // ldr, ldrsw (literal, pc relative immediate) result.insThroughput = PERFSCORE_THROUGHPUT_1C; @@ -16617,7 +16619,7 @@ bool emitter::OptimizeLdrStr(instruction ins, insFormat fmt, bool localVar, int varx, - int offs DEBUG_ARG(bool useRsvdReg)) + int offs DEBUG_ARG(bool useRsvdReg)) { assert(ins == INS_ldr || ins == INS_str); diff --git a/src/coreclr/jit/emitarm64.h b/src/coreclr/jit/emitarm64.h index 62624fe50d68ef..2d08ba87880a3b 100644 --- a/src/coreclr/jit/emitarm64.h +++ b/src/coreclr/jit/emitarm64.h @@ -124,21 +124,21 @@ enum RegisterOrder /************************************************************************/ private: -bool emitInsIsCompare(instruction ins); -bool emitInsIsLoad(instruction ins); -bool emitInsIsStore(instruction ins); -bool emitInsIsLoadOrStore(instruction ins); -bool emitInsIsVectorRightShift(instruction ins); -bool emitInsIsVectorLong(instruction ins); -bool emitInsIsVectorNarrow(instruction ins); -bool emitInsIsVectorWide(instruction ins); -bool emitInsDestIsOp2(instruction ins); +bool emitInsIsCompare(instruction ins); +bool emitInsIsLoad(instruction ins); +bool emitInsIsStore(instruction ins); +bool emitInsIsLoadOrStore(instruction ins); +bool emitInsIsVectorRightShift(instruction ins); +bool emitInsIsVectorLong(instruction ins); +bool emitInsIsVectorNarrow(instruction ins); +bool emitInsIsVectorWide(instruction ins); +bool emitInsDestIsOp2(instruction ins); emitAttr emitInsTargetRegSize(instrDesc* id); emitAttr emitInsLoadStoreSize(instrDesc* id); emitter::insFormat emitInsFormat(instruction ins); -emitter::code_t emitInsCode(instruction ins, insFormat fmt); -emitter::code_t emitInsCodeSve(instruction ins, insFormat fmt); +emitter::code_t emitInsCode(instruction ins, insFormat fmt); +emitter::code_t emitInsCodeSve(instruction ins, insFormat fmt); // Generate code for a load or store operation and handle the case of contained GT_LEA op1 with [base + index<(id->idReg1()); // ddddd - code |= insEncodeSimm<9, 5>(imm1); // iiiii - code |= insEncodeSimm<20, 16>(imm2); // iiiii - code |= insEncodeElemsize(optGetSveElemsize(id->idInsOpt())); // xx - dst += emitOutput_Instr(dst, code); - break; - } + { + ssize_t imm1; + ssize_t imm2; + insSveDecodeTwoSimm5(emitGetInsSC(id), &imm1, &imm2); + code = emitInsCodeSve(ins, fmt); + code |= insEncodeReg_V<4, 0>(id->idReg1()); // ddddd + code |= insEncodeSimm<9, 5>(imm1); // iiiii + code |= insEncodeSimm<20, 16>(imm2); // iiiii + code |= insEncodeElemsize(optGetSveElemsize(id->idInsOpt())); // xx + dst += emitOutput_Instr(dst, code); + break; + } case IF_SVE_AY_2A: // ........xx.mmmmm ......iiiiiddddd -- SVE index generation (immediate start, register // increment) @@ -11451,16 +11451,16 @@ BYTE* emitter::emitOutput_InstrSve(BYTE* dst, instrDesc* id) case IF_SVE_HM_2A: // ........xx...... ...ggg....iddddd -- SVE floating-point arithmetic with immediate // (predicated) - { - imm = emitGetInsSC(id); - code = emitInsCodeSve(ins, fmt); - code |= insEncodeReg_V<4, 0>(id->idReg1()); // ddddd - code |= insEncodeReg_P<12, 10>(id->idReg2()); // ggg - code |= insEncodeSveSmallFloatImm(imm); // i - code |= insEncodeSveElemsize(optGetSveElemsize(id->idInsOpt())); // xx - dst += emitOutput_Instr(dst, code); - } - break; + { + imm = emitGetInsSC(id); + code = emitInsCodeSve(ins, fmt); + code |= insEncodeReg_V<4, 0>(id->idReg1()); // ddddd + code |= insEncodeReg_P<12, 10>(id->idReg2()); // ggg + code |= insEncodeSveSmallFloatImm(imm); // i + code |= insEncodeSveElemsize(optGetSveElemsize(id->idInsOpt())); // xx + dst += emitOutput_Instr(dst, code); + } + break; case IF_SVE_HN_2A: // ........xx...iii ......mmmmmddddd -- SVE floating-point trig multiply-add coefficient imm = emitGetInsSC(id); @@ -13443,17 +13443,17 @@ void emitter::emitInsSveSanityCheck(instrDesc* id) case IF_SVE_AX_1A: // ........xx.iiiii ......iiiiiddddd -- SVE index generation (immediate start, immediate // increment) - { - ssize_t imm1; - ssize_t imm2; - insSveDecodeTwoSimm5(emitGetInsSC(id), &imm1, &imm2); - assert(insOptsScalableStandard(id->idInsOpt())); - assert(isVectorRegister(id->idReg1())); // ddddd - assert(isValidSimm<5>(imm1)); // iiiii - assert(isValidSimm<5>(imm2)); // iiiii - assert(isValidVectorElemsize(optGetSveElemsize(id->idInsOpt()))); // xx - break; - } + { + ssize_t imm1; + ssize_t imm2; + insSveDecodeTwoSimm5(emitGetInsSC(id), &imm1, &imm2); + assert(insOptsScalableStandard(id->idInsOpt())); + assert(isVectorRegister(id->idReg1())); // ddddd + assert(isValidSimm<5>(imm1)); // iiiii + assert(isValidSimm<5>(imm2)); // iiiii + assert(isValidVectorElemsize(optGetSveElemsize(id->idInsOpt()))); // xx + break; + } case IF_SVE_AY_2A: // ........xx.mmmmm ......iiiiiddddd -- SVE index generation (immediate start, register // increment) @@ -14579,37 +14579,37 @@ void emitter::emitDispInsSveHelp(instrDesc* id) // ., #, # case IF_SVE_AX_1A: // ........xx.iiiii ......iiiiiddddd -- SVE index generation (immediate start, immediate // increment) - { - ssize_t imm1; - ssize_t imm2; - insSveDecodeTwoSimm5(emitGetInsSC(id), &imm1, &imm2); - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispImm(imm1, true); // iiiii - emitDispImm(imm2, false); // iiiii - break; - } + { + ssize_t imm1; + ssize_t imm2; + insSveDecodeTwoSimm5(emitGetInsSC(id), &imm1, &imm2); + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispImm(imm1, true); // iiiii + emitDispImm(imm2, false); // iiiii + break; + } // ., #, case IF_SVE_AY_2A: // ........xx.mmmmm ......iiiiiddddd -- SVE index generation (immediate start, register // increment) - { - const emitAttr intRegSize = (id->idInsOpt() == INS_OPTS_SCALABLE_D) ? EA_8BYTE : EA_4BYTE; - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispImm(emitGetInsSC(id), true); // iiiii - emitDispReg(id->idReg2(), intRegSize, false); // mmmmm - break; - } + { + const emitAttr intRegSize = (id->idInsOpt() == INS_OPTS_SCALABLE_D) ? EA_8BYTE : EA_4BYTE; + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispImm(emitGetInsSC(id), true); // iiiii + emitDispReg(id->idReg2(), intRegSize, false); // mmmmm + break; + } // ., , # case IF_SVE_AZ_2A: // ........xx.iiiii ......nnnnnddddd -- SVE index generation (register start, immediate // increment) - { - const emitAttr intRegSize = (id->idInsOpt() == INS_OPTS_SCALABLE_D) ? EA_8BYTE : EA_4BYTE; - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispReg(id->idReg2(), intRegSize, true); // mmmmm - emitDispImm(emitGetInsSC(id), false); // iiiii - break; - } + { + const emitAttr intRegSize = (id->idInsOpt() == INS_OPTS_SCALABLE_D) ? EA_8BYTE : EA_4BYTE; + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispReg(id->idReg2(), intRegSize, true); // mmmmm + emitDispImm(emitGetInsSC(id), false); // iiiii + break; + } // .H, .B, .B case IF_SVE_GN_3A: // ...........mmmmm ......nnnnnddddd -- SVE2 FP8 multiply-add long diff --git a/src/coreclr/jit/emitloongarch64.cpp b/src/coreclr/jit/emitloongarch64.cpp index 6aaf00a973c8a7..24b408b4b8db38 100644 --- a/src/coreclr/jit/emitloongarch64.cpp +++ b/src/coreclr/jit/emitloongarch64.cpp @@ -51,9 +51,9 @@ const emitJumpKind emitReverseJumpKinds[] = { } /***************************************************************************** -* Look up the jump kind for an instruction. It better be a conditional -* branch instruction with a jump kind! -*/ + * Look up the jump kind for an instruction. It better be a conditional + * branch instruction with a jump kind! + */ /*static*/ emitJumpKind emitter::emitInsToJumpKind(instruction ins) { @@ -2047,9 +2047,9 @@ void emitter::emitIns_R_AR(instruction ins, emitAttr attr, regNumber ireg, regNu } // This computes address from the immediate which is relocatable. -void emitter::emitIns_R_AI(instruction ins, - emitAttr attr, - regNumber reg, +void emitter::emitIns_R_AI(instruction ins, + emitAttr attr, + regNumber reg, ssize_t addr DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { assert(EA_IS_RELOC(attr)); // EA_PTR_DSP_RELOC @@ -2381,8 +2381,8 @@ void emitter::emitIns_I_la(emitAttr size, regNumber reg, ssize_t imm) void emitter::emitIns_Call(EmitCallType callType, CORINFO_METHOD_HANDLE methHnd, INDEBUG_LDISASM_COMMA(CORINFO_SIG_INFO* sigInfo) // used to report call sites to the EE - void* addr, - ssize_t argSize, + void* addr, + ssize_t argSize, emitAttr retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize), VARSET_VALARG_TP ptrVars, regMaskTP gcrefRegs, @@ -2786,9 +2786,9 @@ void emitter::emitJumpDistBind() B_DIST_SMALL_MAX_POS - emitCounts_INS_OPTS_J * (3 << 2); // the max placeholder sizeof(INS_OPTS_JIRL) - sizeof(INS_OPTS_J). -/*****************************************************************************/ -/* If the default small encoding is not enough, we start again here. */ -/*****************************************************************************/ + /*****************************************************************************/ + /* If the default small encoding is not enough, we start again here. */ + /*****************************************************************************/ AGAIN: @@ -2819,7 +2819,7 @@ void emitter::emitJumpDistBind() UNATIVE_OFFSET dstOffs; NATIVE_OFFSET jmpDist; // the relative jump distance, as it will be encoded -/* Make sure the jumps are properly ordered */ + /* Make sure the jumps are properly ordered */ #ifdef DEBUG assert(lastSJ == nullptr || lastIG != jmp->idjIG || lastSJ->idjOffs < (jmp->idjOffs + adjSJ)); @@ -2997,8 +2997,8 @@ void emitter::emitJumpDistBind() instruction ins = jmp->idIns(); assert((INS_bceqz <= ins) && (ins <= INS_bl)); - if (ins < - INS_beqz) // bceqz/bcnez/beq/bne/blt/bltu/bge/bgeu < beqz < bnez // See instrsloongarch64.h. + if (ins < INS_beqz) // bceqz/bcnez/beq/bne/blt/bltu/bge/bgeu < beqz < bnez // See + // instrsloongarch64.h. { if ((jmpDist + emitCounts_INS_OPTS_J * 4) < 0x8000000) { @@ -3085,8 +3085,8 @@ void emitter::emitJumpDistBind() instruction ins = jmp->idIns(); assert((INS_bceqz <= ins) && (ins <= INS_bl)); - if (ins < - INS_beqz) // bceqz/bcnez/beq/bne/blt/bltu/bge/bgeu < beqz < bnez // See instrsloongarch64.h. + if (ins < INS_beqz) // bceqz/bcnez/beq/bne/blt/bltu/bge/bgeu < beqz < bnez // See + // instrsloongarch64.h. { if ((jmpDist + emitCounts_INS_OPTS_J * 4) < 0x8000000) { @@ -3181,7 +3181,7 @@ void emitter::emitJumpDistBind() } /***************************************************************************** -* + * * Append the machine code corresponding to the given instruction descriptor * to the code block at '*dp'; the base of the code block is 'bp', and 'ig' * is the instruction group that contains the instruction. Updates '*dp' to diff --git a/src/coreclr/jit/emitloongarch64.h b/src/coreclr/jit/emitloongarch64.h index 11a2f9ee90710e..afaca5b2ba04b8 100644 --- a/src/coreclr/jit/emitloongarch64.h +++ b/src/coreclr/jit/emitloongarch64.h @@ -104,10 +104,10 @@ enum insDisasmFmt #endif }; -code_t emitGetInsMask(int ins); +code_t emitGetInsMask(int ins); insDisasmFmt emitGetInsFmt(instruction ins); -void emitDispInst(instruction ins); -void emitDisInsName(code_t code, const BYTE* addr, instrDesc* id); +void emitDispInst(instruction ins); +void emitDisInsName(code_t code, const BYTE* addr, instrDesc* id); #endif // DEBUG void emitIns_J_cond_la(instruction ins, BasicBlock* dst, regNumber reg1 = REG_R0, regNumber reg2 = REG_R0); @@ -316,9 +316,9 @@ void emitIns_J_R(instruction ins, emitAttr attr, BasicBlock* dst, regNumber reg) void emitIns_R_AR(instruction ins, emitAttr attr, regNumber ireg, regNumber reg, int offs); -void emitIns_R_AI(instruction ins, - emitAttr attr, - regNumber reg, +void emitIns_R_AI(instruction ins, + emitAttr attr, + regNumber reg, ssize_t disp DEBUGARG(size_t targetHandle = 0) DEBUGARG(GenTreeFlags gtFlags = GTF_EMPTY)); enum EmitCallType @@ -333,7 +333,7 @@ enum EmitCallType EC_FUNC_TOKEN, // Direct call to a helper/static/nonvirtual/global method // EC_FUNC_TOKEN_INDIR, // Indirect call to a helper/static/nonvirtual/global method - // EC_FUNC_ADDR, // Direct call to an absolute address + // EC_FUNC_ADDR, // Direct call to an absolute address EC_INDIR_R, // Indirect call via register @@ -343,8 +343,8 @@ enum EmitCallType void emitIns_Call(EmitCallType callType, CORINFO_METHOD_HANDLE methHnd, INDEBUG_LDISASM_COMMA(CORINFO_SIG_INFO* sigInfo) // used to report call sites to the EE - void* addr, - ssize_t argSize, + void* addr, + ssize_t argSize, emitAttr retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize), VARSET_VALARG_TP ptrVars, regMaskTP gcrefRegs, diff --git a/src/coreclr/jit/emitpub.h b/src/coreclr/jit/emitpub.h index c31d21153fd970..bf15ba33667cac 100644 --- a/src/coreclr/jit/emitpub.h +++ b/src/coreclr/jit/emitpub.h @@ -16,24 +16,24 @@ void emitBegFN(bool hasFramePtr , bool checkAlign #endif - ); +); void emitEndFN(); void emitComputeCodeSizes(); -unsigned emitEndCodeGen(Compiler* comp, - bool contTrkPtrLcls, - bool fullyInt, - bool fullPtrMap, - unsigned xcptnsCount, - unsigned* prologSize, - unsigned* epilogSize, - void** codeAddr, - void** codeAddrRW, - void** coldCodeAddr, - void** coldCodeAddrRW, - void** consAddr, +unsigned emitEndCodeGen(Compiler* comp, + bool contTrkPtrLcls, + bool fullyInt, + bool fullPtrMap, + unsigned xcptnsCount, + unsigned* prologSize, + unsigned* epilogSize, + void** codeAddr, + void** codeAddrRW, + void** coldCodeAddr, + void** coldCodeAddrRW, + void** consAddr, void** consAddrRW DEBUGARG(unsigned* instrCount)); /************************************************************************/ @@ -102,11 +102,11 @@ UNATIVE_OFFSET emitDataSize(); /************************************************************************/ #ifdef TARGET_XARCH -static bool instrIs3opImul(instruction ins); -static bool instrIsExtendedReg3opImul(instruction ins); -static bool instrHasImplicitRegPairDest(instruction ins); -static void check3opImulValues(); -static regNumber inst3opImulReg(instruction ins); +static bool instrIs3opImul(instruction ins); +static bool instrIsExtendedReg3opImul(instruction ins); +static bool instrHasImplicitRegPairDest(instruction ins); +static void check3opImulValues(); +static regNumber inst3opImulReg(instruction ins); static instruction inst3opImulForReg(regNumber reg); #endif diff --git a/src/coreclr/jit/emitriscv64.cpp b/src/coreclr/jit/emitriscv64.cpp index 1c5be94198f8af..e0aef5af4a954e 100644 --- a/src/coreclr/jit/emitriscv64.cpp +++ b/src/coreclr/jit/emitriscv64.cpp @@ -988,9 +988,9 @@ void emitter::emitIns_R_AR(instruction ins, emitAttr attr, regNumber ireg, regNu } // This computes address from the immediate which is relocatable. -void emitter::emitIns_R_AI(instruction ins, - emitAttr attr, - regNumber reg, +void emitter::emitIns_R_AI(instruction ins, + emitAttr attr, + regNumber reg, ssize_t addr DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { assert(EA_IS_RELOC(attr)); // EA_PTR_DSP_RELOC @@ -1290,8 +1290,8 @@ void emitter::emitLoadImmediate(emitAttr size, regNumber reg, ssize_t imm) void emitter::emitIns_Call(EmitCallType callType, CORINFO_METHOD_HANDLE methHnd, INDEBUG_LDISASM_COMMA(CORINFO_SIG_INFO* sigInfo) // used to report call sites to the EE - void* addr, - ssize_t argSize, + void* addr, + ssize_t argSize, emitAttr retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize), VARSET_VALARG_TP ptrVars, regMaskTP gcrefRegs, @@ -1710,7 +1710,8 @@ void emitter::emitJumpDistBind() #if DEBUG_EMIT auto printJmpInfo = [this](const instrDescJmp* jmp, const insGroup* jmpIG, NATIVE_OFFSET extra, UNATIVE_OFFSET srcInstrOffs, UNATIVE_OFFSET srcEncodingOffs, UNATIVE_OFFSET dstOffs, - NATIVE_OFFSET jmpDist, const char* direction) { + NATIVE_OFFSET jmpDist, const char* direction) + { assert(jmp->idDebugOnlyInfo() != nullptr); if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0) { @@ -1760,9 +1761,9 @@ void emitter::emitJumpDistBind() emitCounts_INS_OPTS_J * (6 << 2); // the max placeholder sizeof(INS_OPTS_JALR) - sizeof(INS_OPTS_J) NATIVE_OFFSET psd = B_DIST_SMALL_MAX_POS - maxPlaceholderSize; -/*****************************************************************************/ -/* If the default small encoding is not enough, we start again here. */ -/*****************************************************************************/ + /*****************************************************************************/ + /* If the default small encoding is not enough, we start again here. */ + /*****************************************************************************/ AGAIN: @@ -1793,7 +1794,7 @@ void emitter::emitJumpDistBind() UNATIVE_OFFSET dstOffs; NATIVE_OFFSET jmpDist; // the relative jump distance, as it will be encoded -/* Make sure the jumps are properly ordered */ + /* Make sure the jumps are properly ordered */ #ifdef DEBUG assert(lastSJ == nullptr || lastIG != jmp->idjIG || lastSJ->idjOffs < (jmp->idjOffs + adjSJ)); @@ -1948,8 +1949,8 @@ void emitter::emitJumpDistBind() instruction ins = jmp->idIns(); assert((INS_jal <= ins) && (ins <= INS_bgeu)); - if (ins > INS_jalr || - (ins < INS_jalr && ins > INS_j)) // jal < beqz < bnez < jalr < beq/bne/blt/bltu/bge/bgeu + if (ins > INS_jalr || (ins < INS_jalr && ins > INS_j)) // jal < beqz < bnez < jalr < + // beq/bne/blt/bltu/bge/bgeu { if (isValidSimm13(jmpDist + maxPlaceholderSize)) { @@ -2022,8 +2023,8 @@ void emitter::emitJumpDistBind() instruction ins = jmp->idIns(); assert((INS_jal <= ins) && (ins <= INS_bgeu)); - if (ins > INS_jalr || - (ins < INS_jalr && ins > INS_j)) // jal < beqz < bnez < jalr < beq/bne/blt/bltu/bge/bgeu + if (ins > INS_jalr || (ins < INS_jalr && ins > INS_j)) // jal < beqz < bnez < jalr < + // beq/bne/blt/bltu/bge/bgeu { if (isValidSimm13(jmpDist + maxPlaceholderSize)) { @@ -2966,7 +2967,7 @@ BYTE* emitter::emitOutputInstr_OptsRcNoReloc(BYTE* dst, instruction* ins, unsign const regNumber rsvdReg = codeGen->rsGetRsvdReg(); const instruction lastIns = (*ins == INS_jal) ? (*ins = INS_addi) : *ins; - const ssize_t high = immediate >> 11; + const ssize_t high = immediate >> 11; dst += emitOutput_UTypeInstr(dst, INS_lui, rsvdReg, UpperNBitsOfWordSignExtend<20>(high)); dst += emitOutput_ITypeInstr(dst, INS_addi, rsvdReg, rsvdReg, LowerNBitsOfWord<12>(high)); diff --git a/src/coreclr/jit/emitriscv64.h b/src/coreclr/jit/emitriscv64.h index aef61a029cb576..262f44c9ac4bbd 100644 --- a/src/coreclr/jit/emitriscv64.h +++ b/src/coreclr/jit/emitriscv64.h @@ -82,17 +82,17 @@ void emitInsLoadStoreOp(instruction ins, emitAttr attr, regNumber dataReg, GenTr unsigned emitOutput_Instr(BYTE* dst, code_t code) const; ssize_t emitOutputInstrJumpDistance(const BYTE* src, const insGroup* ig, instrDescJmp* jmp); -void emitOutputInstrJumpDistanceHelper(const insGroup* ig, - instrDescJmp* jmp, - UNATIVE_OFFSET& dstOffs, - const BYTE*& dstAddr) const; +void emitOutputInstrJumpDistanceHelper(const insGroup* ig, + instrDescJmp* jmp, + UNATIVE_OFFSET& dstOffs, + const BYTE*& dstAddr) const; // Method to do check if mov is redundant with respect to the last instruction. // If yes, the caller of this method can choose to omit current mov instruction. static bool IsMovInstruction(instruction ins); -bool IsRedundantMov(instruction ins, emitAttr size, regNumber dst, regNumber src, bool canSkip); -bool IsRedundantLdStr( - instruction ins, regNumber reg1, regNumber reg2, ssize_t imm, emitAttr size, insFormat fmt); // New functions end. +bool IsRedundantMov(instruction ins, emitAttr size, regNumber dst, regNumber src, bool canSkip); +bool IsRedundantLdStr( + instruction ins, regNumber reg1, regNumber reg2, ssize_t imm, emitAttr size, insFormat fmt); // New functions end. static code_t insEncodeRTypeInstr( unsigned opcode, unsigned rd, unsigned funct3, unsigned rs1, unsigned rs2, unsigned funct7); @@ -293,9 +293,9 @@ void emitIns_J_R(instruction ins, emitAttr attr, BasicBlock* dst, regNumber reg) void emitIns_R_AR(instruction ins, emitAttr attr, regNumber ireg, regNumber reg, int offs); -void emitIns_R_AI(instruction ins, - emitAttr attr, - regNumber reg, +void emitIns_R_AI(instruction ins, + emitAttr attr, + regNumber reg, ssize_t disp DEBUGARG(size_t targetHandle = 0) DEBUGARG(GenTreeFlags gtFlags = GTF_EMPTY)); enum EmitCallType @@ -310,7 +310,7 @@ enum EmitCallType EC_FUNC_TOKEN, // Direct call to a helper/static/nonvirtual/global method // EC_FUNC_TOKEN_INDIR, // Indirect call to a helper/static/nonvirtual/global method - // EC_FUNC_ADDR, // Direct call to an absolute address + // EC_FUNC_ADDR, // Direct call to an absolute address // EC_FUNC_VIRTUAL, // Call to a virtual method (using the vtable) EC_INDIR_R, // Indirect call via register @@ -324,8 +324,8 @@ enum EmitCallType void emitIns_Call(EmitCallType callType, CORINFO_METHOD_HANDLE methHnd, INDEBUG_LDISASM_COMMA(CORINFO_SIG_INFO* sigInfo) // used to report call sites to the EE - void* addr, - ssize_t argSize, + void* addr, + ssize_t argSize, emitAttr retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize), VARSET_VALARG_TP ptrVars, regMaskTP gcrefRegs, diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 1bafb6796d8075..37170e54070550 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -567,50 +567,52 @@ bool emitter::AreUpperBitsZero(regNumber reg, emitAttr size) bool result = false; - emitPeepholeIterateLastInstrs([&](instrDesc* id) { - if (emitIsInstrWritingToReg(id, reg)) + emitPeepholeIterateLastInstrs( + [&](instrDesc* id) { - switch (id->idIns()) + if (emitIsInstrWritingToReg(id, reg)) { - // Conservative. - case INS_call: - return PEEPHOLE_ABORT; - - // These instructions sign-extend. - case INS_cwde: - case INS_cdq: - case INS_movsx: - case INS_movsxd: - return PEEPHOLE_ABORT; + switch (id->idIns()) + { + // Conservative. + case INS_call: + return PEEPHOLE_ABORT; + + // These instructions sign-extend. + case INS_cwde: + case INS_cdq: + case INS_movsx: + case INS_movsxd: + return PEEPHOLE_ABORT; + + case INS_movzx: + if ((size == EA_1BYTE) || (size == EA_2BYTE)) + { + result = (id->idOpSize() <= size); + } + // movzx always zeroes the upper 32 bits. + else if (size == EA_4BYTE) + { + result = true; + } + return PEEPHOLE_ABORT; - case INS_movzx: - if ((size == EA_1BYTE) || (size == EA_2BYTE)) - { - result = (id->idOpSize() <= size); - } - // movzx always zeroes the upper 32 bits. - else if (size == EA_4BYTE) - { - result = true; - } - return PEEPHOLE_ABORT; + default: + break; + } - default: - break; + // otherwise rely on operation size. + if (size == EA_4BYTE) + { + result = (id->idOpSize() == EA_4BYTE); + } + return PEEPHOLE_ABORT; } - - // otherwise rely on operation size. - if (size == EA_4BYTE) + else { - result = (id->idOpSize() == EA_4BYTE); + return PEEPHOLE_CONTINUE; } - return PEEPHOLE_ABORT; - } - else - { - return PEEPHOLE_CONTINUE; - } - }); + }); return result; } @@ -646,39 +648,41 @@ bool emitter::AreUpperBitsSignExtended(regNumber reg, emitAttr size) bool result = false; - emitPeepholeIterateLastInstrs([&](instrDesc* id) { - if (emitIsInstrWritingToReg(id, reg)) + emitPeepholeIterateLastInstrs( + [&](instrDesc* id) { - switch (id->idIns()) + if (emitIsInstrWritingToReg(id, reg)) { - // Conservative. - case INS_call: - return PEEPHOLE_ABORT; + switch (id->idIns()) + { + // Conservative. + case INS_call: + return PEEPHOLE_ABORT; - case INS_movsx: - case INS_movsxd: - if ((size == EA_1BYTE) || (size == EA_2BYTE)) - { - result = (id->idOpSize() <= size); - } - // movsx/movsxd always sign extends to 8 bytes. W-bit is set. - else if (size == EA_4BYTE) - { - result = true; - } - break; + case INS_movsx: + case INS_movsxd: + if ((size == EA_1BYTE) || (size == EA_2BYTE)) + { + result = (id->idOpSize() <= size); + } + // movsx/movsxd always sign extends to 8 bytes. W-bit is set. + else if (size == EA_4BYTE) + { + result = true; + } + break; - default: - break; - } + default: + break; + } - return PEEPHOLE_ABORT; - } - else - { - return PEEPHOLE_CONTINUE; - } - }); + return PEEPHOLE_ABORT; + } + else + { + return PEEPHOLE_CONTINUE; + } + }); return result; } @@ -889,41 +893,43 @@ bool emitter::IsRedundantCmp(emitAttr size, regNumber reg1, regNumber reg2) bool result = false; - emitPeepholeIterateLastInstrs([&](instrDesc* id) { - instruction ins = id->idIns(); - - switch (ins) + emitPeepholeIterateLastInstrs( + [&](instrDesc* id) { - case INS_cmp: - { - // We only care about 'cmp reg, reg'. - if (id->idInsFmt() != IF_RRD_RRD) - return PEEPHOLE_ABORT; + instruction ins = id->idIns(); - if ((id->idReg1() == reg1) && (id->idReg2() == reg2)) + switch (ins) + { + case INS_cmp: { - result = (size == id->idOpSize()); + // We only care about 'cmp reg, reg'. + if (id->idInsFmt() != IF_RRD_RRD) + return PEEPHOLE_ABORT; + + if ((id->idReg1() == reg1) && (id->idReg2() == reg2)) + { + result = (size == id->idOpSize()); + } + + return PEEPHOLE_ABORT; } - return PEEPHOLE_ABORT; + default: + break; } - default: - break; - } - - if (emitDoesInsModifyFlags(ins)) - { - return PEEPHOLE_ABORT; - } + if (emitDoesInsModifyFlags(ins)) + { + return PEEPHOLE_ABORT; + } - if (emitIsInstrWritingToReg(id, reg1) || emitIsInstrWritingToReg(id, reg2)) - { - return PEEPHOLE_ABORT; - } + if (emitIsInstrWritingToReg(id, reg1) || emitIsInstrWritingToReg(id, reg2)) + { + return PEEPHOLE_ABORT; + } - return PEEPHOLE_CONTINUE; - }); + return PEEPHOLE_CONTINUE; + }); return result; } @@ -3597,7 +3603,7 @@ bool emitter::emitVerifyEncodable(instruction ins, emitAttr size, regNumber reg1 #ifdef FEATURE_HW_INTRINSICS && (ins != INS_crc32) #endif - ) + ) { // reg1 must be a byte-able register if ((genRegMask(reg1) & RBM_BYTE_REGS) == 0) @@ -4108,7 +4114,8 @@ UNATIVE_OFFSET emitter::emitInsSizeAM(instrDesc* id, code_t code) assert((attrSize == EA_4BYTE) || (attrSize == EA_PTRSIZE) // Only for x64 || (attrSize == EA_16BYTE) || (attrSize == EA_32BYTE) || (attrSize == EA_64BYTE) // only for x64 - || (ins == INS_movzx) || (ins == INS_movsx) || (ins == INS_cmpxchg) + || (ins == INS_movzx) || (ins == INS_movsx) || + (ins == INS_cmpxchg) // The prefetch instructions are always 3 bytes and have part of their modr/m byte hardcoded || isPrefetch(ins)); @@ -4489,9 +4496,9 @@ emitter::instrDesc* emitter::emitNewInstrAmdCns(emitAttr size, ssize_t dsp, int } /***************************************************************************** -* -* Add a data16 instruction of the 1 byte. -*/ + * + * Add a data16 instruction of the 1 byte. + */ void emitter::emitIns_Data16() { @@ -4539,7 +4546,8 @@ void emitter::emitIns(instruction ins) (ins == INS_cdq || ins == INS_int3 || ins == INS_lock || ins == INS_leave || ins == INS_movsb || ins == INS_movsd || ins == INS_movsp || ins == INS_nop || ins == INS_r_movsb || ins == INS_r_movsd || ins == INS_r_movsp || ins == INS_r_stosb || ins == INS_r_stosd || ins == INS_r_stosp || ins == INS_ret || - ins == INS_sahf || ins == INS_stosb || ins == INS_stosd || ins == INS_stosp + ins == INS_sahf || ins == INS_stosb || ins == INS_stosd || + ins == INS_stosp // These instructions take zero operands || ins == INS_vzeroupper || ins == INS_lfence || ins == INS_mfence || ins == INS_sfence || ins == INS_pause || ins == INS_serialize); @@ -6969,9 +6977,9 @@ void emitter::emitIns_R_R_C(instruction ins, } /***************************************************************************** -* -* Add an instruction with three register operands. -*/ + * + * Add an instruction with three register operands. + */ void emitter::emitIns_R_R_R( instruction ins, emitAttr attr, regNumber targetReg, regNumber reg1, regNumber reg2, insOpts instOptions) @@ -7102,16 +7110,16 @@ void emitter::emitIns_R_R_C_I( } /********************************************************************************** -* emitIns_R_R_R_I: Add an instruction with three register operands and an immediate. -* -* Arguments: -* ins - the instruction to add -* attr - the emitter attribute for instruction -* targetReg - the target (destination) register -* reg1 - the first source register -* reg2 - the second source register -* ival - the immediate value -*/ + * emitIns_R_R_R_I: Add an instruction with three register operands and an immediate. + * + * Arguments: + * ins - the instruction to add + * attr - the emitter attribute for instruction + * targetReg - the target (destination) register + * reg1 - the first source register + * reg2 - the second source register + * ival - the immediate value + */ void emitter::emitIns_R_R_R_I( instruction ins, emitAttr attr, regNumber targetReg, regNumber reg1, regNumber reg2, int ival) @@ -7745,9 +7753,9 @@ void emitter::emitIns_R_AR(instruction ins, emitAttr attr, regNumber reg, regNum emitIns_R_ARX(ins, attr, reg, base, REG_NA, 1, disp); } -void emitter::emitIns_R_AI(instruction ins, - emitAttr attr, - regNumber ireg, +void emitter::emitIns_R_AI(instruction ins, + emitAttr attr, + regNumber ireg, ssize_t disp DEBUGARG(size_t targetHandle) DEBUGARG(GenTreeFlags gtFlags)) { assert((CodeGen::instIsFP(ins) == false) && (EA_SIZE(attr) <= EA_8BYTE) && (ireg != REG_NA)); @@ -9706,7 +9714,7 @@ void emitter::emitIns_Call(EmitCallType callType, if (m_debugInfoSize > 0) { INDEBUG(id->idDebugOnlyInfo()->idCallSig = sigInfo); - id->idDebugOnlyInfo()->idMemCookie = (size_t)methHnd; // method token + id->idDebugOnlyInfo()->idMemCookie = (size_t)methHnd; // method token } #ifdef LATE_DISASM @@ -11698,7 +11706,7 @@ void emitter::emitDispIns( #ifdef TARGET_AMD64 || ins == INS_shrx || ins == INS_shlx || ins == INS_sarx #endif - ) + ) { // BMI bextr,bzhi, shrx, shlx and sarx encode the reg2 in VEX.vvvv and reg3 in modRM, // which is different from most of other instructions @@ -12999,9 +13007,9 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) dst += emitOutputWord(dst, code | 0x0500); } #else // TARGET_AMD64 - // Amd64: addr fits within 32-bits and can be encoded as a displacement relative to zero. - // This addr mode should never be used while generating relocatable ngen code nor if - // the addr can be encoded as pc-relative address. + // Amd64: addr fits within 32-bits and can be encoded as a displacement relative to zero. + // This addr mode should never be used while generating relocatable ngen code nor if + // the addr can be encoded as pc-relative address. noway_assert(!emitComp->opts.compReloc); noway_assert(codeGen->genAddrRelocTypeHint((size_t)dsp) != IMAGE_REL_BASED_REL32); noway_assert((int)dsp == dsp); @@ -13925,7 +13933,7 @@ BYTE* emitter::emitOutputSV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) case IF_SRW_CNS: case IF_SRW_RRD: case IF_SRW_RRW: - // += -= of a byref, no change + // += -= of a byref, no change case IF_SRW: break; @@ -16437,9 +16445,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) break; } - /********************************************************************/ - /* Simple constant, local label, method */ - /********************************************************************/ + /********************************************************************/ + /* Simple constant, local label, method */ + /********************************************************************/ case IF_CNS: { @@ -16557,9 +16565,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) #ifdef TARGET_X86 dst += emitOutputWord(dst, code | 0x0500); #else // TARGET_AMD64 - // Amd64: addr fits within 32-bits and can be encoded as a displacement relative to zero. - // This addr mode should never be used while generating relocatable ngen code nor if - // the addr can be encoded as pc-relative address. + // Amd64: addr fits within 32-bits and can be encoded as a displacement relative to zero. + // This addr mode should never be used while generating relocatable ngen code nor if + // the addr can be encoded as pc-relative address. noway_assert(!emitComp->opts.compReloc); noway_assert(codeGen->genAddrRelocTypeHint((size_t)addr) != IMAGE_REL_BASED_REL32); noway_assert(static_cast(reinterpret_cast(addr)) == (ssize_t)addr); @@ -16712,9 +16720,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) break; } - /********************************************************************/ - /* One register operand */ - /********************************************************************/ + /********************************************************************/ + /* One register operand */ + /********************************************************************/ case IF_RRD: case IF_RWR: @@ -16725,9 +16733,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) break; } - /********************************************************************/ - /* Register and register/constant */ - /********************************************************************/ + /********************************************************************/ + /* Register and register/constant */ + /********************************************************************/ case IF_RRW_SHF: { @@ -16952,9 +16960,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) break; } - /********************************************************************/ - /* Address mode operand */ - /********************************************************************/ + /********************************************************************/ + /* Address mode operand */ + /********************************************************************/ case IF_ARD: case IF_AWR: @@ -17191,9 +17199,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) break; } - /********************************************************************/ - /* Stack-based operand */ - /********************************************************************/ + /********************************************************************/ + /* Stack-based operand */ + /********************************************************************/ case IF_SRD: case IF_SWR: @@ -17455,9 +17463,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) unreached(); } - /********************************************************************/ - /* Direct memory address */ - /********************************************************************/ + /********************************************************************/ + /* Direct memory address */ + /********************************************************************/ case IF_MRD: case IF_MRW: @@ -17757,9 +17765,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) unreached(); } - /********************************************************************/ - /* oops */ - /********************************************************************/ + /********************************************************************/ + /* oops */ + /********************************************************************/ default: @@ -18224,7 +18232,7 @@ emitter::insExecutionCharacteristics emitter::getInsExecutionCharacteristics(ins #ifdef TARGET_AMD64 || ins == INS_movsxd #endif - ) + ) { result.insLatency += PERFSCORE_LATENCY_2C; } diff --git a/src/coreclr/jit/emitxarch.h b/src/coreclr/jit/emitxarch.h index 4554a892201f95..e83efd96dca03b 100644 --- a/src/coreclr/jit/emitxarch.h +++ b/src/coreclr/jit/emitxarch.h @@ -93,7 +93,7 @@ code_t emitExtractEvexPrefix(instruction ins, code_t& code) const; unsigned insEncodeReg012(const instrDesc* id, regNumber reg, emitAttr size, code_t* code); unsigned insEncodeReg345(const instrDesc* id, regNumber reg, emitAttr size, code_t* code); -code_t insEncodeReg3456(const instrDesc* id, regNumber reg, emitAttr size, code_t code); +code_t insEncodeReg3456(const instrDesc* id, regNumber reg, emitAttr size, code_t code); unsigned insEncodeRegSIB(const instrDesc* id, regNumber reg, code_t* code); code_t insEncodeMRreg(const instrDesc* id, code_t code); @@ -116,11 +116,11 @@ static bool IsKInstruction(instruction ins); static regNumber getBmiRegNumber(instruction ins); static regNumber getSseShiftRegNumber(instruction ins); -bool HasVexEncoding(instruction ins) const; -bool HasEvexEncoding(instruction ins) const; -bool IsVexEncodableInstruction(instruction ins) const; -bool IsEvexEncodableInstruction(instruction ins) const; -bool IsVexOrEvexEncodableInstruction(instruction ins) const; +bool HasVexEncoding(instruction ins) const; +bool HasEvexEncoding(instruction ins) const; +bool IsVexEncodableInstruction(instruction ins) const; +bool IsEvexEncodableInstruction(instruction ins) const; +bool IsVexOrEvexEncodableInstruction(instruction ins) const; code_t insEncodeMIreg(const instrDesc* id, regNumber reg, emitAttr size, code_t code); @@ -130,15 +130,15 @@ code_t AddRexXPrefix(const instrDesc* id, code_t code); code_t AddRexBPrefix(const instrDesc* id, code_t code); code_t AddRexPrefix(instruction ins, code_t code); -bool EncodedBySSE38orSSE3A(instruction ins) const; -bool Is4ByteSSEInstruction(instruction ins) const; +bool EncodedBySSE38orSSE3A(instruction ins) const; +bool Is4ByteSSEInstruction(instruction ins) const; code_t AddEvexVPrimePrefix(code_t code); code_t AddEvexRPrimePrefix(code_t code); static bool IsMovInstruction(instruction ins); -bool HasSideEffect(instruction ins, emitAttr size); -bool IsRedundantMov( - instruction ins, insFormat fmt, emitAttr size, regNumber dst, regNumber src, bool canIgnoreSideEffects); +bool HasSideEffect(instruction ins, emitAttr size); +bool IsRedundantMov( + instruction ins, insFormat fmt, emitAttr size, regNumber dst, regNumber src, bool canIgnoreSideEffects); bool EmitMovsxAsCwde(instruction ins, emitAttr size, regNumber dst, regNumber src); bool IsRedundantStackMov(instruction ins, insFormat fmt, emitAttr size, regNumber ireg, int varx, int offs); @@ -478,15 +478,15 @@ void SetContainsCallNeedingVzeroupper(bool value) containsCallNeedingVzeroupper = value; } -bool IsDstDstSrcAVXInstruction(instruction ins) const; -bool IsDstSrcSrcAVXInstruction(instruction ins) const; -bool IsThreeOperandAVXInstruction(instruction ins) const; +bool IsDstDstSrcAVXInstruction(instruction ins) const; +bool IsDstSrcSrcAVXInstruction(instruction ins) const; +bool IsThreeOperandAVXInstruction(instruction ins) const; static bool HasRegularWideForm(instruction ins); static bool HasRegularWideImmediateForm(instruction ins); static bool DoesWriteZeroFlag(instruction ins); static bool DoesWriteSignFlag(instruction ins); static bool DoesResetOverflowAndCarryFlags(instruction ins); -bool IsFlagsAlwaysModified(instrDesc* id); +bool IsFlagsAlwaysModified(instrDesc* id); static bool IsRexW0Instruction(instruction ins); static bool IsRexW1Instruction(instruction ins); static bool IsRexWXInstruction(instruction ins); @@ -528,7 +528,7 @@ const char* emitZMMregName(unsigned reg) const; /************************************************************************/ private: -void emitSetAmdDisp(instrDescAmd* id, ssize_t dsp); +void emitSetAmdDisp(instrDescAmd* id, ssize_t dsp); instrDesc* emitNewInstrAmd(emitAttr attr, ssize_t dsp); instrDesc* emitNewInstrAmdCns(emitAttr attr, ssize_t dsp, int cns); @@ -545,9 +545,9 @@ instrDesc* emitNewInstrCallInd(int argCnt, regMaskTP byrefRegs, emitAttr retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize)); -void emitGetInsCns(const instrDesc* id, CnsVal* cv) const; +void emitGetInsCns(const instrDesc* id, CnsVal* cv) const; ssize_t emitGetInsAmdCns(const instrDesc* id, CnsVal* cv) const; -void emitGetInsDcmCns(const instrDesc* id, CnsVal* cv) const; +void emitGetInsDcmCns(const instrDesc* id, CnsVal* cv) const; ssize_t emitGetInsAmdAny(const instrDesc* id) const; /************************************************************************/ @@ -562,12 +562,8 @@ bool emitVerifyEncodable(instruction ins, emitAttr size, regNumber reg1, regNumb bool emitInsCanOnlyWriteSSE2OrAVXReg(instrDesc* id); #if FEATURE_FIXED_OUT_ARGS -void emitAdjustStackDepthPushPop(instruction ins) -{ -} -void emitAdjustStackDepth(instruction ins, ssize_t val) -{ -} +void emitAdjustStackDepthPushPop(instruction ins) {} +void emitAdjustStackDepth(instruction ins, ssize_t val) {} #else // !FEATURE_FIXED_OUT_ARGS void emitAdjustStackDepthPushPop(instruction ins); void emitAdjustStackDepth(instruction ins, ssize_t val); @@ -580,10 +576,10 @@ size_t emitSizeOfInsDsc_NONE(instrDesc* id) const; size_t emitSizeOfInsDsc_SPEC(instrDesc* id) const; /***************************************************************************** -* -* Convert between an index scale in bytes to a smaller encoding used for -* storage in instruction descriptors. -*/ + * + * Convert between an index scale in bytes to a smaller encoding used for + * storage in instruction descriptors. + */ inline emitter::opSize emitEncodeScale(size_t scale) { @@ -752,9 +748,9 @@ void emitIns_I_AI(instruction ins, emitAttr attr, int val, ssize_t disp); void emitIns_R_AR(instruction ins, emitAttr attr, regNumber reg, regNumber base, int disp); -void emitIns_R_AI(instruction ins, - emitAttr attr, - regNumber ireg, +void emitIns_R_AI(instruction ins, + emitAttr attr, + regNumber ireg, ssize_t disp DEBUGARG(size_t targetHandle = 0) DEBUGARG(GenTreeFlags gtFlags = GTF_EMPTY)); void emitIns_AR_R(instruction ins, emitAttr attr, regNumber reg, regNumber base, cnsval_ssize_t disp); diff --git a/src/coreclr/jit/error.cpp b/src/coreclr/jit/error.cpp index a45ad7c7df0ef0..dd49ad56131ae5 100644 --- a/src/coreclr/jit/error.cpp +++ b/src/coreclr/jit/error.cpp @@ -250,9 +250,7 @@ void debugError(const char* msg, const char* file, unsigned line) } /*****************************************************************************/ -LogEnv::LogEnv(ICorJitInfo* aCompHnd) : compHnd(aCompHnd), compiler(nullptr) -{ -} +LogEnv::LogEnv(ICorJitInfo* aCompHnd) : compHnd(aCompHnd), compiler(nullptr) {} /*****************************************************************************/ extern "C" void __cdecl assertAbort(const char* why, const char* file, unsigned line) diff --git a/src/coreclr/jit/fgbasic.cpp b/src/coreclr/jit/fgbasic.cpp index 5b4fcd33f8e214..b3b8c0bd1ded0b 100644 --- a/src/coreclr/jit/fgbasic.cpp +++ b/src/coreclr/jit/fgbasic.cpp @@ -3122,7 +3122,7 @@ unsigned Compiler::fgMakeBasicBlocks(const BYTE* codeAddr, IL_OFFSET codeSize, F codeAddr += sizeof(__int8); goto DECODE_OPCODE; - /* Check to see if we have a jump/return opcode */ + /* Check to see if we have a jump/return opcode */ case CEE_BRFALSE: case CEE_BRFALSE_S: @@ -3305,7 +3305,7 @@ unsigned Compiler::fgMakeBasicBlocks(const BYTE* codeAddr, IL_OFFSET codeSize, F // statement in the block. // Otherwise, we will assert at the following line in fgMorphCall() // noway_assert(fgMorphStmt->GetNextStmt() == NULL); - ) + ) { // Neither .tailcall prefix, no tailcall stress. So move on. break; @@ -4030,11 +4030,11 @@ void Compiler::fgFindBasicBlocks() #endif } -/* Init ebdHandlerNestingLevel of current clause, and bump up value for all - * enclosed clauses (which have to be before it in the table). - * Innermost try-finally blocks must precede outermost - * try-finally blocks. - */ + /* Init ebdHandlerNestingLevel of current clause, and bump up value for all + * enclosed clauses (which have to be before it in the table). + * Innermost try-finally blocks must precede outermost + * try-finally blocks. + */ #if !defined(FEATURE_EH_FUNCLETS) HBtab->ebdHandlerNestingLevel = 0; @@ -5917,8 +5917,8 @@ BasicBlock* Compiler::fgRelocateEHRange(unsigned regionIndex, FG_RELOCATE_TYPE r } else { - assert(fgFirstFuncletBB != - insertAfterBlk->Next()); // We insert at the end, not at the beginning, of the funclet region. + assert(fgFirstFuncletBB != insertAfterBlk->Next()); // We insert at the end, not at the beginning, of the + // funclet region. } #ifdef DEBUG @@ -6244,8 +6244,8 @@ BasicBlock* Compiler::fgFindInsertPoint(unsigned regionIndex, noway_assert(startBlk != nullptr); noway_assert(startBlk != endBlk); noway_assert((regionIndex == 0 && putInTryRegion) || // Search in the main method - (putInTryRegion && regionIndex > 0 && - startBlk->bbTryIndex == regionIndex) || // Search in the specified try region + (putInTryRegion && regionIndex > 0 && startBlk->bbTryIndex == regionIndex) || // Search in the + // specified try region (!putInTryRegion && regionIndex > 0 && startBlk->bbHndIndex == regionIndex)); // Search in the specified handler region diff --git a/src/coreclr/jit/fgdiagnostic.cpp b/src/coreclr/jit/fgdiagnostic.cpp index f49f863b16dc57..d038a2204a4781 100644 --- a/src/coreclr/jit/fgdiagnostic.cpp +++ b/src/coreclr/jit/fgdiagnostic.cpp @@ -389,7 +389,7 @@ const char* ConvertToUtf8(LPCWSTR wideString, CompAllocator& allocator) return alloc; } -} +} // namespace #endif //------------------------------------------------------------------------ @@ -1758,29 +1758,31 @@ void Compiler::fgDumpFlowGraphLoops(FILE* file) fprintf(m_file, "%*scolor = blue;\n", m_indent, ""); fprintf(m_file, "%*s", m_indent, ""); - loop->VisitLoopBlocksReversePostOrder([=](BasicBlock* block) { - if (BitVecOps::IsMember(&m_traits, m_outputBlocks, block->bbPostorderNum)) + loop->VisitLoopBlocksReversePostOrder( + [=](BasicBlock* block) { - return BasicBlockVisit::Continue; - } - - if (block != loop->GetHeader()) - { - FlowGraphNaturalLoop* childLoop = m_loops->GetLoopByHeader(block); - if (childLoop != nullptr) + if (BitVecOps::IsMember(&m_traits, m_outputBlocks, block->bbPostorderNum)) { - fprintf(m_file, "\n"); - Output(childLoop); - fprintf(m_file, "\n%*s", m_indent, ""); return BasicBlockVisit::Continue; } - } - fprintf(m_file, FMT_BB ";", block->bbNum); - BitVecOps::AddElemD(&m_traits, m_outputBlocks, block->bbPostorderNum); + if (block != loop->GetHeader()) + { + FlowGraphNaturalLoop* childLoop = m_loops->GetLoopByHeader(block); + if (childLoop != nullptr) + { + fprintf(m_file, "\n"); + Output(childLoop); + fprintf(m_file, "\n%*s", m_indent, ""); + return BasicBlockVisit::Continue; + } + } + + fprintf(m_file, FMT_BB ";", block->bbNum); + BitVecOps::AddElemD(&m_traits, m_outputBlocks, block->bbPostorderNum); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); m_indent -= 4; fprintf(m_file, "\n%*s}", m_indent, ""); @@ -1933,7 +1935,8 @@ void Compiler::fgTableDispBasicBlock(const BasicBlock* block, // of the generated string. Note that any computation using `printedBlockWidth` must be done after all // calls to this function. auto dspBlockNum = [printEdgeLikelihoods, terseNext, nextBlock, - &printedBlockWidth](const FlowEdge* e) -> const char* { + &printedBlockWidth](const FlowEdge* e) -> const char* + { static char buffers[3][64]; // static array of 3 to allow 3 concurrent calls in one printf() static int nextBufferIndex = 0; @@ -2642,9 +2645,7 @@ void Compiler::fgStress64RsltMul() class BBPredsChecker { public: - BBPredsChecker(Compiler* compiler) : comp(compiler) - { - } + BBPredsChecker(Compiler* compiler) : comp(compiler) {} unsigned CheckBBPreds(BasicBlock* block, unsigned curTraversalStamp); @@ -3240,7 +3241,7 @@ void Compiler::fgDebugCheckBBlist(bool checkBBNum /* = false */, bool checkBBRef #ifndef JIT32_GCENCODER copiedForGenericsCtxt = ((info.compMethodInfo->options & CORINFO_GENERICS_CTXT_FROM_THIS) != 0); #else // JIT32_GCENCODER - copiedForGenericsCtxt = false; + copiedForGenericsCtxt = false; #endif // JIT32_GCENCODER // This if only in support of the noway_asserts it contains. @@ -3284,9 +3285,7 @@ void Compiler::fgDebugCheckTypes(GenTree* tree) DoPostOrder = true, }; - NodeTypeValidator(Compiler* comp) : GenTreeVisitor(comp) - { - } + NodeTypeValidator(Compiler* comp) : GenTreeVisitor(comp) {} fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) const { @@ -3518,12 +3517,14 @@ void Compiler::fgDebugCheckFlags(GenTree* tree, BasicBlock* block) break; } - tree->VisitOperands([&](GenTree* operand) -> GenTree::VisitResult { - fgDebugCheckFlags(operand, block); - expectedFlags |= (operand->gtFlags & GTF_ALL_EFFECT); + tree->VisitOperands( + [&](GenTree* operand) -> GenTree::VisitResult + { + fgDebugCheckFlags(operand, block); + expectedFlags |= (operand->gtFlags & GTF_ALL_EFFECT); - return GenTree::VisitResult::Continue; - }); + return GenTree::VisitResult::Continue; + }); fgDebugCheckFlagsHelper(tree, actualFlags, expectedFlags); } @@ -3733,9 +3734,7 @@ void Compiler::fgDebugCheckLinkedLocals() UseExecutionOrder = true, }; - DebugLocalSequencer(Compiler* comp) : GenTreeVisitor(comp), m_locals(comp->getAllocator(CMK_DebugOnly)) - { - } + DebugLocalSequencer(Compiler* comp) : GenTreeVisitor(comp), m_locals(comp->getAllocator(CMK_DebugOnly)) {} void Sequence(Statement* stmt) { @@ -4132,13 +4131,9 @@ class SsaCheckVisitor : public GenTreeVisitor unsigned m_ssaNum; public: - SsaKey() : m_lclNum(BAD_VAR_NUM), m_ssaNum(SsaConfig::RESERVED_SSA_NUM) - { - } + SsaKey() : m_lclNum(BAD_VAR_NUM), m_ssaNum(SsaConfig::RESERVED_SSA_NUM) {} - SsaKey(unsigned lclNum, unsigned ssaNum) : m_lclNum(lclNum), m_ssaNum(ssaNum) - { - } + SsaKey(unsigned lclNum, unsigned ssaNum) : m_lclNum(lclNum), m_ssaNum(ssaNum) {} static bool Equals(const SsaKey& x, const SsaKey& y) { @@ -4750,13 +4745,15 @@ void Compiler::fgDebugCheckLoops() assert(loop->EntryEdges().size() == 1); assert(loop->EntryEdge(0)->getSourceBlock()->KindIs(BBJ_ALWAYS)); - loop->VisitRegularExitBlocks([=](BasicBlock* exit) { - for (BasicBlock* pred : exit->PredBlocks()) + loop->VisitRegularExitBlocks( + [=](BasicBlock* exit) { - assert(loop->ContainsBlock(pred)); - } - return BasicBlockVisit::Continue; - }); + for (BasicBlock* pred : exit->PredBlocks()) + { + assert(loop->ContainsBlock(pred)); + } + return BasicBlockVisit::Continue; + }); } } } @@ -4775,7 +4772,8 @@ void Compiler::fgDebugCheckFlowGraphAnnotations() unsigned count = fgRunDfs([](BasicBlock* block, unsigned preorderNum) { assert(block->bbPreorderNum == preorderNum); }, - [=](BasicBlock* block, unsigned postorderNum) { + [=](BasicBlock* block, unsigned postorderNum) + { assert(block->bbPostorderNum == postorderNum); assert(m_dfsTree->GetPostOrder(postorderNum) == block); }, diff --git a/src/coreclr/jit/fgehopt.cpp b/src/coreclr/jit/fgehopt.cpp index a437a3da128d4c..43849d2dad5c39 100644 --- a/src/coreclr/jit/fgehopt.cpp +++ b/src/coreclr/jit/fgehopt.cpp @@ -1867,13 +1867,9 @@ PhaseStatus Compiler::fgTailMergeThrows() BasicBlock* m_block; GenTreeCall* m_call; - ThrowHelper() : m_block(nullptr), m_call(nullptr) - { - } + ThrowHelper() : m_block(nullptr), m_call(nullptr) {} - ThrowHelper(BasicBlock* block, GenTreeCall* call) : m_block(block), m_call(call) - { - } + ThrowHelper(BasicBlock* block, GenTreeCall* call) : m_block(block), m_call(call) {} static bool Equals(const ThrowHelper& x, const ThrowHelper& y) { diff --git a/src/coreclr/jit/fginline.cpp b/src/coreclr/jit/fginline.cpp index 8ea17f2bff05a0..cff786c23922f0 100644 --- a/src/coreclr/jit/fginline.cpp +++ b/src/coreclr/jit/fginline.cpp @@ -214,9 +214,7 @@ class SubstitutePlaceholdersAndDevirtualizeWalker : public GenTreeVisitor( - [](Param* pParam) { + [](Param* pParam) + { // Init the local var info of the inlinee pParam->pThis->impInlineInitVars(pParam->inlineInfo); @@ -1203,12 +1202,12 @@ void Compiler::fgInvokeInlineeCompiler(GenTreeCall* call, InlineResult* inlineRe pParam->inlineInfo->inlineContext = pParam->inlineInfo->InlineRoot->m_inlineStrategy ->NewContext(pParam->inlineInfo->inlineCandidateInfo->inlinersContext, - pParam->inlineInfo->iciStmt, pParam->inlineInfo->iciCall); + pParam->inlineInfo->iciStmt, pParam->inlineInfo->iciCall); pParam->inlineInfo->argCnt = pParam->inlineCandidateInfo->methInfo.args.totalILArgs(); pParam->inlineInfo->tokenLookupContextHandle = pParam->inlineCandidateInfo->exactContextHnd; JITLOG_THIS(pParam->pThis, - (LL_INFO100000, "INLINER: inlineInfo.tokenLookupContextHandle for %s set to 0x%p:\n", + (LL_INFO100000, "INLINER: inlineInfo.tokenLookupContextHandle for %s set to 0x%p:\n", pParam->pThis->eeGetMethodFullName(pParam->fncHandle), pParam->pThis->dspPtr(pParam->inlineInfo->tokenLookupContextHandle))); diff --git a/src/coreclr/jit/fgopt.cpp b/src/coreclr/jit/fgopt.cpp index 0f20dccd2fef35..f2e34c9b6d3561 100644 --- a/src/coreclr/jit/fgopt.cpp +++ b/src/coreclr/jit/fgopt.cpp @@ -230,7 +230,8 @@ bool Compiler::fgRemoveDeadBlocks() // or not. bool hasUnreachableBlock = false; - auto isBlockRemovable = [&](BasicBlock* block) -> bool { + auto isBlockRemovable = [&](BasicBlock* block) -> bool + { const bool isVisited = BlockSetOps::IsMember(this, visitedBlocks, block->bbNum); const bool isRemovable = !isVisited || (block->bbRefs == 0); @@ -729,9 +730,9 @@ PhaseStatus Compiler::fgPostImportationCleanup() // Helper method to add flow // - auto addConditionalFlow = [this, entryStateVar, &entryJumpTarget, &addedBlocks](BasicBlock* fromBlock, - BasicBlock* toBlock) { - + auto addConditionalFlow = + [this, entryStateVar, &entryJumpTarget, &addedBlocks](BasicBlock* fromBlock, BasicBlock* toBlock) + { // We may have previously though this try entry was unreachable, but now we're going to // step through it on the way to the OSR entry. So ensure it has plausible profile weight. // @@ -2600,7 +2601,7 @@ void Compiler::fgRemoveConditionalJump(BasicBlock* block) assert(block->TargetIs(target)); /* Update bbRefs and bbNum - Conditional predecessors to the same - * block are counted twice so we have to remove one of them */ + * block are counted twice so we have to remove one of them */ noway_assert(target->countOfInEdges() > 1); fgRemoveRefPred(block->GetTargetEdge()); @@ -3140,7 +3141,8 @@ bool Compiler::fgExpandRarelyRunBlocks() // Note this is potentially expensive for large flow graphs and blocks // with lots of predecessors. // - auto newRunRarely = [](BasicBlock* block, BasicBlock* bPrev) { + auto newRunRarely = [](BasicBlock* block, BasicBlock* bPrev) + { // Figure out earliest block that might be impacted BasicBlock* bPrevPrev = nullptr; BasicBlock* tmpbb; @@ -3969,8 +3971,8 @@ bool Compiler::fgReorderBlocks(bool useProfile) bNext = bEnd->Next(); bool connected_bDest = false; - if ((backwardBranch && !isRare) || - block->HasFlag(BBF_DONT_REMOVE)) // Don't choose option #1 when block is the start of a try region + if ((backwardBranch && !isRare) || block->HasFlag(BBF_DONT_REMOVE)) // Don't choose option #1 when block is the + // start of a try region { bStart = nullptr; bEnd = nullptr; @@ -4779,11 +4781,11 @@ bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */, bool isPh continue; } - /* We jump to the REPEAT label if we performed a change involving the current block - * This is in case there are other optimizations that can show up - * (e.g. - compact 3 blocks in a row) - * If nothing happens, we then finish the iteration and move to the next block - */ + /* We jump to the REPEAT label if we performed a change involving the current block + * This is in case there are other optimizations that can show up + * (e.g. - compact 3 blocks in a row) + * If nothing happens, we then finish the iteration and move to the next block + */ REPEAT:; @@ -5251,15 +5253,17 @@ PhaseStatus Compiler::fgDfsBlocksAndRemove() while (true) { bool anyCallFinallyPairs = false; - fgRemoveUnreachableBlocks([=, &anyCallFinallyPairs](BasicBlock* block) { - if (!m_dfsTree->Contains(block)) + fgRemoveUnreachableBlocks( + [=, &anyCallFinallyPairs](BasicBlock* block) { - anyCallFinallyPairs |= block->isBBCallFinallyPair(); - return true; - } + if (!m_dfsTree->Contains(block)) + { + anyCallFinallyPairs |= block->isBBCallFinallyPair(); + return true; + } - return false; - }); + return false; + }); if (!anyCallFinallyPairs) { @@ -5364,12 +5368,14 @@ unsigned Compiler::fgMeasureIR() { for (Statement* const stmt : block->Statements()) { - fgWalkTreePre(stmt->GetRootNodePointer(), - [](GenTree** slot, fgWalkData* data) -> Compiler::fgWalkResult { - (*reinterpret_cast(data->pCallbackData))++; - return Compiler::WALK_CONTINUE; - }, - &nodeCount); + fgWalkTreePre( + stmt->GetRootNodePointer(), + [](GenTree** slot, fgWalkData* data) -> Compiler::fgWalkResult + { + (*reinterpret_cast(data->pCallbackData))++; + return Compiler::WALK_CONTINUE; + }, + &nodeCount); } } else @@ -5444,9 +5450,7 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) struct PredInfo { - PredInfo(BasicBlock* block, Statement* stmt) : m_block(block), m_stmt(stmt) - { - } + PredInfo(BasicBlock* block, Statement* stmt) : m_block(block), m_stmt(stmt) {} BasicBlock* m_block; Statement* m_stmt; }; @@ -5459,7 +5463,8 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) // If return value is true, retry. // May also add to retryBlocks. // - auto tailMergePreds = [&](BasicBlock* commSucc) -> bool { + auto tailMergePreds = [&](BasicBlock* commSucc) -> bool + { // Are there enough preds to make it interesting? // if (predInfo.Height() < 2) @@ -5684,7 +5689,8 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) return false; }; - auto tailMerge = [&](BasicBlock* block) -> bool { + auto tailMerge = [&](BasicBlock* block) -> bool + { if (block->countOfInEdges() < 2) { // Nothing to merge here @@ -5749,8 +5755,8 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) return tailMergePreds(block); }; - auto iterateTailMerge = [&](BasicBlock* block) -> void { - + auto iterateTailMerge = [&](BasicBlock* block) -> void + { int numOpts = 0; while (tailMerge(block)) @@ -5836,7 +5842,8 @@ bool Compiler::fgTryOneHeadMerge(BasicBlock* block, bool early) } // Verify that both successors are reached along non-critical edges. - auto getSuccCandidate = [=](BasicBlock* succ, Statement** firstStmt) -> bool { + auto getSuccCandidate = [=](BasicBlock* succ, Statement** firstStmt) -> bool + { if (succ->GetUniquePred(this) != block) { return false; @@ -5968,9 +5975,7 @@ bool Compiler::gtTreeContainsTailCall(GenTree* tree) DoPreOrder = true }; - HasTailCallCandidateVisitor(Compiler* comp) : GenTreeVisitor(comp) - { - } + HasTailCallCandidateVisitor(Compiler* comp) : GenTreeVisitor(comp) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { diff --git a/src/coreclr/jit/fgprofile.cpp b/src/coreclr/jit/fgprofile.cpp index d53abf356150c3..a9b316b46ecd09 100644 --- a/src/coreclr/jit/fgprofile.cpp +++ b/src/coreclr/jit/fgprofile.cpp @@ -309,9 +309,7 @@ class Instrumentor bool m_modifiedFlow; protected: - Instrumentor(Compiler* comp) : m_comp(comp), m_schemaCount(0), m_instrCount(0), m_modifiedFlow(false) - { - } + Instrumentor(Compiler* comp) : m_comp(comp), m_schemaCount(0), m_instrCount(0), m_modifiedFlow(false) {} public: virtual bool ShouldProcess(BasicBlock* block) @@ -322,19 +320,11 @@ class Instrumentor { return ShouldProcess(block); } - virtual void Prepare(bool preImport) - { - } - virtual void BuildSchemaElements(BasicBlock* block, Schema& schema) - { - } - virtual void Instrument(BasicBlock* block, Schema& schema, uint8_t* profileMemory) - { - } - virtual void InstrumentMethodEntry(Schema& schema, uint8_t* profileMemory) - { - } - unsigned SchemaCount() const + virtual void Prepare(bool preImport) {} + virtual void BuildSchemaElements(BasicBlock* block, Schema& schema) {} + virtual void Instrument(BasicBlock* block, Schema& schema, uint8_t* profileMemory) {} + virtual void InstrumentMethodEntry(Schema& schema, uint8_t* profileMemory) {} + unsigned SchemaCount() const { return m_schemaCount; } @@ -360,9 +350,7 @@ class Instrumentor class NonInstrumentor : public Instrumentor { public: - NonInstrumentor(Compiler* comp) : Instrumentor(comp) - { - } + NonInstrumentor(Compiler* comp) : Instrumentor(comp) {} }; //------------------------------------------------------------------------ @@ -376,9 +364,7 @@ class BlockCountInstrumentor : public Instrumentor BasicBlock* m_entryBlock; public: - BlockCountInstrumentor(Compiler* comp) : Instrumentor(comp), m_entryBlock(nullptr) - { - } + BlockCountInstrumentor(Compiler* comp) : Instrumentor(comp), m_entryBlock(nullptr) {} bool ShouldProcess(BasicBlock* block) override { return block->HasFlag(BBF_IMPORTED) && !block->HasFlag(BBF_INTERNAL); @@ -566,8 +552,8 @@ void BlockCountInstrumentor::BuildSchemaElements(BasicBlock* block, Schema& sche schemaElem.InstrumentationKind = m_comp->opts.compCollect64BitCounts ? ICorJitInfo::PgoInstrumentationKind::BasicBlockLongCount : ICorJitInfo::PgoInstrumentationKind::BasicBlockIntCount; - schemaElem.ILOffset = offset; - schemaElem.Offset = 0; + schemaElem.ILOffset = offset; + schemaElem.Offset = 0; schema.push_back(schemaElem); @@ -841,9 +827,9 @@ class SpanningTreeVisitor Duplicate }; - virtual void Badcode() = 0; - virtual void VisitBlock(BasicBlock* block) = 0; - virtual void VisitTreeEdge(BasicBlock* source, BasicBlock* target) = 0; + virtual void Badcode() = 0; + virtual void VisitBlock(BasicBlock* block) = 0; + virtual void VisitTreeEdge(BasicBlock* source, BasicBlock* target) = 0; virtual void VisitNonTreeEdge(BasicBlock* source, BasicBlock* target, EdgeKind kind) = 0; }; @@ -1378,9 +1364,7 @@ class EfficientEdgeCountInstrumentor : public Instrumentor, public SpanningTreeV block->bbSparseProbeList = nullptr; } - void VisitTreeEdge(BasicBlock* source, BasicBlock* target) override - { - } + void VisitTreeEdge(BasicBlock* source, BasicBlock* target) override {} void VisitNonTreeEdge(BasicBlock* source, BasicBlock* target, SpanningTreeVisitor::EdgeKind kind) override { @@ -1753,8 +1737,8 @@ void EfficientEdgeCountInstrumentor::BuildSchemaElements(BasicBlock* block, Sche schemaElem.InstrumentationKind = m_comp->opts.compCollect64BitCounts ? ICorJitInfo::PgoInstrumentationKind::EdgeLongCount : ICorJitInfo::PgoInstrumentationKind::EdgeIntCount; - schemaElem.ILOffset = sourceKey; - schemaElem.Offset = 0; + schemaElem.ILOffset = sourceKey; + schemaElem.Offset = 0; schema.push_back(schemaElem); @@ -2003,8 +1987,8 @@ class BuildHandleHistogramProbeSchemaGen schemaElem.InstrumentationKind = compiler->opts.compCollect64BitCounts ? ICorJitInfo::PgoInstrumentationKind::HandleHistogramLongCount : ICorJitInfo::PgoInstrumentationKind::HandleHistogramIntCount; - schemaElem.ILOffset = (int32_t)call->gtHandleHistogramProfileCandidateInfo->ilOffset; - schemaElem.Offset = 0; + schemaElem.ILOffset = (int32_t)call->gtHandleHistogramProfileCandidateInfo->ilOffset; + schemaElem.Offset = 0; m_schema.push_back(schemaElem); @@ -2013,7 +1997,7 @@ class BuildHandleHistogramProbeSchemaGen // Re-using ILOffset and Other fields from schema item for TypeHandleHistogramCount schemaElem.InstrumentationKind = isTypeHistogram ? ICorJitInfo::PgoInstrumentationKind::HandleHistogramTypes : ICorJitInfo::PgoInstrumentationKind::HandleHistogramMethods; - schemaElem.Count = ICorJitInfo::HandleHistogram32::SIZE; + schemaElem.Count = ICorJitInfo::HandleHistogram32::SIZE; m_schema.push_back(schemaElem); m_schemaCount++; @@ -2036,8 +2020,8 @@ class BuildValueHistogramProbeSchemaGen ICorJitInfo::PgoInstrumentationSchema schemaElem = {}; schemaElem.Count = 1; schemaElem.InstrumentationKind = compiler->opts.compCollect64BitCounts - ? ICorJitInfo::PgoInstrumentationKind::ValueHistogramLongCount - : ICorJitInfo::PgoInstrumentationKind::ValueHistogramIntCount; + ? ICorJitInfo::PgoInstrumentationKind::ValueHistogramLongCount + : ICorJitInfo::PgoInstrumentationKind::ValueHistogramIntCount; schemaElem.ILOffset = (int32_t)call->AsCall()->gtHandleHistogramProfileCandidateInfo->ilOffset; m_schema.push_back(schemaElem); m_schemaCount++; @@ -2332,9 +2316,7 @@ class ValueHistogramProbeInserter class HandleHistogramProbeInstrumentor : public Instrumentor { public: - HandleHistogramProbeInstrumentor(Compiler* comp) : Instrumentor(comp) - { - } + HandleHistogramProbeInstrumentor(Compiler* comp) : Instrumentor(comp) {} bool ShouldProcess(BasicBlock* block) override { return block->HasFlag(BBF_IMPORTED) && !block->HasFlag(BBF_INTERNAL); @@ -2350,9 +2332,7 @@ class HandleHistogramProbeInstrumentor : public Instrumentor class ValueInstrumentor : public Instrumentor { public: - ValueInstrumentor(Compiler* comp) : Instrumentor(comp) - { - } + ValueInstrumentor(Compiler* comp) : Instrumentor(comp) {} bool ShouldProcess(BasicBlock* block) override { return block->HasFlag(BBF_IMPORTED) && !block->HasFlag(BBF_INTERNAL); @@ -2727,7 +2707,7 @@ PhaseStatus Compiler::fgInstrumentMethod() // uint8_t* profileMemory; HRESULT res = info.compCompHnd->allocPgoInstrumentationBySchema(info.compMethodHnd, schema.data(), - (UINT32)schema.size(), &profileMemory); + (UINT32)schema.size(), &profileMemory); // Deal with allocation failures. // @@ -3102,7 +3082,7 @@ class EfficientEdgeCountReconstructor : public SpanningTreeVisitor // Map correlating block keys to blocks. // typedef JitHashTable, BasicBlock*> KeyToBlockMap; - KeyToBlockMap m_keyToBlockMap; + KeyToBlockMap m_keyToBlockMap; // Key for finding an edge based on schema info. // @@ -3111,9 +3091,7 @@ class EfficientEdgeCountReconstructor : public SpanningTreeVisitor int32_t const m_sourceKey; int32_t const m_targetKey; - EdgeKey(int32_t sourceKey, int32_t targetKey) : m_sourceKey(sourceKey), m_targetKey(targetKey) - { - } + EdgeKey(int32_t sourceKey, int32_t targetKey) : m_sourceKey(sourceKey), m_targetKey(targetKey) {} EdgeKey(BasicBlock* sourceBlock, BasicBlock* targetBlock) : m_sourceKey(EfficientEdgeCountBlockToKey(sourceBlock)) @@ -3159,7 +3137,7 @@ class EfficientEdgeCountReconstructor : public SpanningTreeVisitor // Map for correlating EdgeIntCount schema entries with edges // typedef JitHashTable EdgeKeyToEdgeMap; - EdgeKeyToEdgeMap m_edgeKeyToEdgeMap; + EdgeKeyToEdgeMap m_edgeKeyToEdgeMap; // Per block data // @@ -3271,9 +3249,7 @@ class EfficientEdgeCountReconstructor : public SpanningTreeVisitor return !(m_entryWeightZero || m_negativeCount); } - void VisitBlock(BasicBlock*) override - { - } + void VisitBlock(BasicBlock*) override {} void VisitTreeEdge(BasicBlock* source, BasicBlock* target) override { @@ -3519,8 +3495,9 @@ void EfficientEdgeCountReconstructor::Solve() // if (m_badcode || m_mismatch || m_allWeightsZero) { - JITDUMP("... not solving because of the %s\n", - m_badcode ? "badcode" : m_allWeightsZero ? "zero counts" : "mismatch"); + JITDUMP("... not solving because of the %s\n", m_badcode ? "badcode" + : m_allWeightsZero ? "zero counts" + : "mismatch"); return; } diff --git a/src/coreclr/jit/fgprofilesynthesis.cpp b/src/coreclr/jit/fgprofilesynthesis.cpp index 77803454f0cfde..7afbbf070190a5 100644 --- a/src/coreclr/jit/fgprofilesynthesis.cpp +++ b/src/coreclr/jit/fgprofilesynthesis.cpp @@ -672,69 +672,73 @@ void ProfileSynthesis::ComputeCyclicProbabilities(FlowGraphNaturalLoop* loop) { // Initialize // - loop->VisitLoopBlocks([](BasicBlock* loopBlock) { - loopBlock->bbWeight = 0.0; - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks( + [](BasicBlock* loopBlock) + { + loopBlock->bbWeight = 0.0; + return BasicBlockVisit::Continue; + }); // Process loop blocks in RPO. Just takes one pass through the loop blocks // as any cyclic contributions are handled by cyclic probabilities. // - loop->VisitLoopBlocksReversePostOrder([=](BasicBlock* block) { - // Loop head gets external count of 1 - // - if (block == loop->GetHeader()) - { - JITDUMP("ccp: " FMT_BB " :: 1.0\n", block->bbNum); - block->bbWeight = 1.0; - } - else + loop->VisitLoopBlocksReversePostOrder( + [=](BasicBlock* block) { - FlowGraphNaturalLoop* const nestedLoop = m_loops->GetLoopByHeader(block); - - if (nestedLoop != nullptr) + // Loop head gets external count of 1 + // + if (block == loop->GetHeader()) { - // We should have figured this out already. - // - assert(m_cyclicProbabilities[nestedLoop->GetIndex()] != 0); - - // Sum entry edges, multply by Cp - // - weight_t newWeight = 0.0; + JITDUMP("ccp: " FMT_BB " :: 1.0\n", block->bbNum); + block->bbWeight = 1.0; + } + else + { + FlowGraphNaturalLoop* const nestedLoop = m_loops->GetLoopByHeader(block); - for (FlowEdge* const edge : nestedLoop->EntryEdges()) + if (nestedLoop != nullptr) { - if (BasicBlock::sameHndRegion(block, edge->getSourceBlock())) + // We should have figured this out already. + // + assert(m_cyclicProbabilities[nestedLoop->GetIndex()] != 0); + + // Sum entry edges, multply by Cp + // + weight_t newWeight = 0.0; + + for (FlowEdge* const edge : nestedLoop->EntryEdges()) { - newWeight += edge->getLikelyWeight(); + if (BasicBlock::sameHndRegion(block, edge->getSourceBlock())) + { + newWeight += edge->getLikelyWeight(); + } } - } - - newWeight *= m_cyclicProbabilities[nestedLoop->GetIndex()]; - block->bbWeight = newWeight; - JITDUMP("ccp (nested header): " FMT_BB " :: " FMT_WT "\n", block->bbNum, newWeight); - } - else - { - weight_t newWeight = 0.0; + newWeight *= m_cyclicProbabilities[nestedLoop->GetIndex()]; + block->bbWeight = newWeight; - for (FlowEdge* const edge : block->PredEdges()) + JITDUMP("ccp (nested header): " FMT_BB " :: " FMT_WT "\n", block->bbNum, newWeight); + } + else { - if (BasicBlock::sameHndRegion(block, edge->getSourceBlock())) + weight_t newWeight = 0.0; + + for (FlowEdge* const edge : block->PredEdges()) { - newWeight += edge->getLikelyWeight(); + if (BasicBlock::sameHndRegion(block, edge->getSourceBlock())) + { + newWeight += edge->getLikelyWeight(); + } } - } - block->bbWeight = newWeight; + block->bbWeight = newWeight; - JITDUMP("ccp: " FMT_BB " :: " FMT_WT "\n", block->bbNum, newWeight); + JITDUMP("ccp: " FMT_BB " :: " FMT_WT "\n", block->bbNum, newWeight); + } } - } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); // Now look at cyclic flow back to the head block. // diff --git a/src/coreclr/jit/fgprofilesynthesis.h b/src/coreclr/jit/fgprofilesynthesis.h index 216bd58297286a..b293c4597e1617 100644 --- a/src/coreclr/jit/fgprofilesynthesis.h +++ b/src/coreclr/jit/fgprofilesynthesis.h @@ -40,9 +40,7 @@ class ProfileSynthesis static constexpr weight_t epsilon = 0.001; private: - ProfileSynthesis(Compiler* compiler) : m_comp(compiler) - { - } + ProfileSynthesis(Compiler* compiler) : m_comp(compiler) {} static constexpr weight_t exceptionScale = 0.001; static constexpr weight_t blendFactor = 0.99; diff --git a/src/coreclr/jit/flowgraph.cpp b/src/coreclr/jit/flowgraph.cpp index 691fa5ef349f27..788515e325ef43 100644 --- a/src/coreclr/jit/flowgraph.cpp +++ b/src/coreclr/jit/flowgraph.cpp @@ -1063,7 +1063,7 @@ GenTree* Compiler::fgOptimizeDelegateConstructor(GenTreeCall* call, &genericLookup); GenTree* ctxTree = getRuntimeContextTree(pLookup.lookupKind.runtimeLookupKind); call = gtNewHelperCallNode(CORINFO_HELP_READYTORUN_DELEGATE_CTOR, TYP_VOID, thisPointer, - targetObjPointers, ctxTree); + targetObjPointers, ctxTree); call->setEntryPoint(genericLookup); } } @@ -1647,8 +1647,8 @@ void Compiler::fgConvertSyncReturnToLeave(BasicBlock* block) // try/finally, which must be the last EH region. EHblkDsc* ehDsc = ehGetDsc(tryIndex); - assert(ehDsc->ebdEnclosingTryIndex == - EHblkDsc::NO_ENCLOSING_INDEX); // There are no enclosing regions of the BBJ_RETURN block + assert(ehDsc->ebdEnclosingTryIndex == EHblkDsc::NO_ENCLOSING_INDEX); // There are no enclosing regions of the + // BBJ_RETURN block assert(ehDsc->ebdEnclosingHndIndex == EHblkDsc::NO_ENCLOSING_INDEX); // Convert the BBJ_RETURN to BBJ_ALWAYS, jumping to genReturnBB. @@ -2266,7 +2266,7 @@ class MergedReturns return nullptr; } }; -} +} // namespace //------------------------------------------------------------------------ // fgAddInternal: add blocks and trees to express special method semantics @@ -2325,7 +2325,7 @@ PhaseStatus Compiler::fgAddInternal() #ifndef JIT32_GCENCODER lva0CopiedForGenericsCtxt = ((info.compMethodInfo->options & CORINFO_GENERICS_CTXT_FROM_THIS) != 0); #else // JIT32_GCENCODER - lva0CopiedForGenericsCtxt = false; + lva0CopiedForGenericsCtxt = false; #endif // JIT32_GCENCODER noway_assert(lva0CopiedForGenericsCtxt || !lvaTable[info.compThisArg].IsAddressExposed()); noway_assert(!lvaTable[info.compThisArg].lvHasILStoreOp); @@ -3677,7 +3677,8 @@ PhaseStatus Compiler::fgSetBlockOrder() class GCSafePointSuccessorEnumerator { BasicBlock* m_block; - union { + union + { BasicBlock* m_successors[2]; BasicBlock** m_pSuccessors; }; @@ -3691,15 +3692,17 @@ class GCSafePointSuccessorEnumerator GCSafePointSuccessorEnumerator(Compiler* comp, BasicBlock* block) : m_block(block) { m_numSuccs = 0; - block->VisitRegularSuccs(comp, [this](BasicBlock* succ) { - if (m_numSuccs < ArrLen(m_successors)) - { - m_successors[m_numSuccs] = succ; - } - - m_numSuccs++; - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(comp, + [this](BasicBlock* succ) + { + if (m_numSuccs < ArrLen(m_successors)) + { + m_successors[m_numSuccs] = succ; + } + + m_numSuccs++; + return BasicBlockVisit::Continue; + }); if (m_numSuccs == 0) { @@ -3723,11 +3726,13 @@ class GCSafePointSuccessorEnumerator m_pSuccessors = new (comp, CMK_BasicBlock) BasicBlock*[m_numSuccs]; unsigned numSuccs = 0; - block->VisitRegularSuccs(comp, [this, &numSuccs](BasicBlock* succ) { - assert(numSuccs < m_numSuccs); - m_pSuccessors[numSuccs++] = succ; - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(comp, + [this, &numSuccs](BasicBlock* succ) + { + assert(numSuccs < m_numSuccs); + m_pSuccessors[numSuccs++] = succ; + return BasicBlockVisit::Continue; + }); assert(numSuccs == m_numSuccs); } @@ -3996,18 +4001,21 @@ FlowGraphDfsTree* Compiler::fgComputeDfs() BasicBlock** postOrder = new (this, CMK_DepthFirstSearch) BasicBlock*[fgBBcount]; bool hasCycle = false; - auto visitPreorder = [](BasicBlock* block, unsigned preorderNum) { + auto visitPreorder = [](BasicBlock* block, unsigned preorderNum) + { block->bbPreorderNum = preorderNum; block->bbPostorderNum = UINT_MAX; }; - auto visitPostorder = [=](BasicBlock* block, unsigned postorderNum) { + auto visitPostorder = [=](BasicBlock* block, unsigned postorderNum) + { block->bbPostorderNum = postorderNum; assert(postorderNum < fgBBcount); postOrder[postorderNum] = block; }; - auto visitEdge = [&hasCycle](BasicBlock* block, BasicBlock* succ) { + auto visitEdge = [&hasCycle](BasicBlock* block, BasicBlock* succ) + { // Check if block -> succ is a backedge, in which case the flow // graph has a cycle. if ((succ->bbPreorderNum <= block->bbPreorderNum) && (succ->bbPostorderNum == UINT_MAX)) @@ -4393,21 +4401,27 @@ FlowGraphNaturalLoops* FlowGraphNaturalLoops::Find(const FlowGraphDfsTree* dfsTr // Find the exit edges // - loop->VisitLoopBlocksReversePostOrder([=](BasicBlock* loopBlock) { - loopBlock->VisitRegularSuccs(comp, [=](BasicBlock* succBlock) { - if (!loop->ContainsBlock(succBlock)) - { - FlowEdge* const exitEdge = comp->fgGetPredForBlock(succBlock, loopBlock); - JITDUMP(FMT_BB " -> " FMT_BB " is an exit edge\n", loopBlock->bbNum, succBlock->bbNum); - loop->m_exitEdges.push_back(exitEdge); - } + loop->VisitLoopBlocksReversePostOrder( + [=](BasicBlock* loopBlock) + { + loopBlock->VisitRegularSuccs(comp, + [=](BasicBlock* succBlock) + { + if (!loop->ContainsBlock(succBlock)) + { + FlowEdge* const exitEdge = + comp->fgGetPredForBlock(succBlock, loopBlock); + JITDUMP(FMT_BB " -> " FMT_BB " is an exit edge\n", + loopBlock->bbNum, succBlock->bbNum); + loop->m_exitEdges.push_back(exitEdge); + } + + return BasicBlockVisit::Continue; + }); return BasicBlockVisit::Continue; }); - return BasicBlockVisit::Continue; - }); - // Find the entry edges // // Note if fgEntryBB is a loop head we won't have an entry edge. @@ -4448,19 +4462,23 @@ FlowGraphNaturalLoops* FlowGraphNaturalLoops::Find(const FlowGraphDfsTree* dfsTr { // Ancestor loop; should contain all blocks of this loop // - loop->VisitLoopBlocks([otherLoop](BasicBlock* loopBlock) { - assert(otherLoop->ContainsBlock(loopBlock)); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks( + [otherLoop](BasicBlock* loopBlock) + { + assert(otherLoop->ContainsBlock(loopBlock)); + return BasicBlockVisit::Continue; + }); } else { // Non-ancestor loop; should have no blocks in common with current loop // - loop->VisitLoopBlocks([otherLoop](BasicBlock* loopBlock) { - assert(!otherLoop->ContainsBlock(loopBlock)); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks( + [otherLoop](BasicBlock* loopBlock) + { + assert(!otherLoop->ContainsBlock(loopBlock)); + return BasicBlockVisit::Continue; + }); } } #endif @@ -4669,7 +4687,8 @@ void FlowGraphNaturalLoop::Dump(FlowGraphNaturalLoop* loop) BasicBlock* firstInRange = nullptr; BasicBlock* lastInRange = nullptr; first = true; - auto printRange = [&]() { + auto printRange = [&]() + { // Dump current range if there is one; reset firstInRange. if (firstInRange == nullptr) { @@ -4714,11 +4733,13 @@ void FlowGraphNaturalLoop::Dump(FlowGraphNaturalLoop* loop) // not well ordered such that `top` and `bottom` are not first/last in `bbNext` order. // Just dump all the blocks individually using the loop block visitor. first = true; - loop->VisitLoopBlocksReversePostOrder([&first](BasicBlock* block) { - printf("%s" FMT_BB, first ? "" : ";", block->bbNum); - first = false; - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocksReversePostOrder( + [&first](BasicBlock* block) + { + printf("%s" FMT_BB, first ? "" : ";", block->bbNum); + first = false; + return BasicBlockVisit::Continue; + }); // Print out the lexical top and bottom blocks, which will explain why we didn't print ranges. printf("\n Lexical top: " FMT_BB, lexicalTopBlock->bbNum); @@ -4838,9 +4859,7 @@ bool FlowGraphNaturalLoop::VisitDefs(TFunc func) DoPreOrder = true, }; - VisitDefsVisitor(Compiler* comp, TFunc& func) : GenTreeVisitor(comp), m_func(func) - { - } + VisitDefsVisitor(Compiler* comp, TFunc& func) : GenTreeVisitor(comp), m_func(func) {} Compiler::fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -4863,15 +4882,17 @@ bool FlowGraphNaturalLoop::VisitDefs(TFunc func) VisitDefsVisitor visitor(m_dfsTree->GetCompiler(), func); - BasicBlockVisit result = VisitLoopBlocks([&](BasicBlock* loopBlock) { - for (Statement* stmt : loopBlock->Statements()) + BasicBlockVisit result = VisitLoopBlocks( + [&](BasicBlock* loopBlock) { - if (visitor.WalkTree(stmt->GetRootNodePointer(), nullptr) == Compiler::WALK_ABORT) - return BasicBlockVisit::Abort; - } + for (Statement* stmt : loopBlock->Statements()) + { + if (visitor.WalkTree(stmt->GetRootNodePointer(), nullptr) == Compiler::WALK_ABORT) + return BasicBlockVisit::Abort; + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); return result == BasicBlockVisit::Continue; } @@ -4903,15 +4924,17 @@ GenTreeLclVarCommon* FlowGraphNaturalLoop::FindDef(unsigned lclNum) } GenTreeLclVarCommon* result = nullptr; - VisitDefs([&result, lclNum, lclNum2](GenTreeLclVarCommon* def) { - if ((def->GetLclNum() == lclNum) || (def->GetLclNum() == lclNum2)) + VisitDefs( + [&result, lclNum, lclNum2](GenTreeLclVarCommon* def) { - result = def; - return false; - } + if ((def->GetLclNum() == lclNum) || (def->GetLclNum() == lclNum2)) + { + result = def; + return false; + } - return true; - }); + return true; + }); return result; } @@ -5016,13 +5039,15 @@ bool FlowGraphNaturalLoop::AnalyzeIteration(NaturalLoopIterInfo* info) continue; } - bool result = VisitDefs([=](GenTreeLclVarCommon* def) { - if ((def->GetLclNum() != iterVar) || (def == iterTree)) - return true; + bool result = VisitDefs( + [=](GenTreeLclVarCommon* def) + { + if ((def->GetLclNum() != iterVar) || (def == iterTree)) + return true; - JITDUMP(" Loop has extraneous def [%06u]\n", Compiler::dspTreeID(def)); - return false; - }); + JITDUMP(" Loop has extraneous def [%06u]\n", Compiler::dspTreeID(def)); + return false; + }); if (!result) { @@ -5055,13 +5080,15 @@ bool FlowGraphNaturalLoop::AnalyzeIteration(NaturalLoopIterInfo* info) MatchInit(info, initBlock, init); - bool result = VisitDefs([=](GenTreeLclVarCommon* def) { - if ((def->GetLclNum() != info->IterVar) || (def == info->IterTree)) - return true; + bool result = VisitDefs( + [=](GenTreeLclVarCommon* def) + { + if ((def->GetLclNum() != info->IterVar) || (def == info->IterTree)) + return true; - JITDUMP(" Loop has extraneous def [%06u]\n", Compiler::dspTreeID(def)); - return false; - }); + JITDUMP(" Loop has extraneous def [%06u]\n", Compiler::dspTreeID(def)); + return false; + }); if (!result) { @@ -5494,11 +5521,13 @@ bool FlowGraphNaturalLoop::InitBlockEntersLoopOnTrue(BasicBlock* initBlock) BasicBlock* FlowGraphNaturalLoop::GetLexicallyTopMostBlock() { BasicBlock* top = m_header; - VisitLoopBlocks([&top](BasicBlock* loopBlock) { - if (loopBlock->bbNum < top->bbNum) - top = loopBlock; - return BasicBlockVisit::Continue; - }); + VisitLoopBlocks( + [&top](BasicBlock* loopBlock) + { + if (loopBlock->bbNum < top->bbNum) + top = loopBlock; + return BasicBlockVisit::Continue; + }); return top; } @@ -5517,11 +5546,13 @@ BasicBlock* FlowGraphNaturalLoop::GetLexicallyTopMostBlock() BasicBlock* FlowGraphNaturalLoop::GetLexicallyBottomMostBlock() { BasicBlock* bottom = m_header; - VisitLoopBlocks([&bottom](BasicBlock* loopBlock) { - if (loopBlock->bbNum > bottom->bbNum) - bottom = loopBlock; - return BasicBlockVisit::Continue; - }); + VisitLoopBlocks( + [&bottom](BasicBlock* loopBlock) + { + if (loopBlock->bbNum > bottom->bbNum) + bottom = loopBlock; + return BasicBlockVisit::Continue; + }); return bottom; } @@ -5551,14 +5582,16 @@ bool FlowGraphNaturalLoop::HasDef(unsigned lclNum) defLclNum2 = dsc->lvParentLcl; } - bool result = VisitDefs([=](GenTreeLclVarCommon* lcl) { - if ((lcl->GetLclNum() == defLclNum1) || (lcl->GetLclNum() == defLclNum2)) + bool result = VisitDefs( + [=](GenTreeLclVarCommon* lcl) { - return false; - } + if ((lcl->GetLclNum() == defLclNum1) || (lcl->GetLclNum() == defLclNum2)) + { + return false; + } - return true; - }); + return true; + }); // If we stopped early we found a def. return !result; @@ -5587,15 +5620,17 @@ bool FlowGraphNaturalLoop::CanDuplicate(INDEBUG(const char** reason)) #endif Compiler* comp = m_dfsTree->GetCompiler(); - BasicBlockVisit result = VisitLoopBlocks([=](BasicBlock* block) { - if (comp->bbIsTryBeg(block)) + BasicBlockVisit result = VisitLoopBlocks( + [=](BasicBlock* block) { - INDEBUG(*reason = "Loop has a `try` begin"); - return BasicBlockVisit::Abort; - } + if (comp->bbIsTryBeg(block)) + { + INDEBUG(*reason = "Loop has a `try` begin"); + return BasicBlockVisit::Abort; + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); return result != BasicBlockVisit::Abort; } @@ -5616,43 +5651,47 @@ void FlowGraphNaturalLoop::Duplicate(BasicBlock** insertAfter, BlockToBlockMap* BasicBlock* bottom = GetLexicallyBottomMostBlock(); - VisitLoopBlocksLexical([=](BasicBlock* blk) { - // Initialize newBlk as BBJ_ALWAYS without jump target, and fix up jump target later - // with BasicBlock::CopyTarget(). - BasicBlock* newBlk = comp->fgNewBBafter(BBJ_ALWAYS, *insertAfter, /*extendRegion*/ true); - JITDUMP("Adding " FMT_BB " (copy of " FMT_BB ") after " FMT_BB "\n", newBlk->bbNum, blk->bbNum, - (*insertAfter)->bbNum); + VisitLoopBlocksLexical( + [=](BasicBlock* blk) + { + // Initialize newBlk as BBJ_ALWAYS without jump target, and fix up jump target later + // with BasicBlock::CopyTarget(). + BasicBlock* newBlk = comp->fgNewBBafter(BBJ_ALWAYS, *insertAfter, /*extendRegion*/ true); + JITDUMP("Adding " FMT_BB " (copy of " FMT_BB ") after " FMT_BB "\n", newBlk->bbNum, blk->bbNum, + (*insertAfter)->bbNum); - BasicBlock::CloneBlockState(comp, newBlk, blk); + BasicBlock::CloneBlockState(comp, newBlk, blk); - // We're going to create the preds below, which will set the bbRefs properly, - // so clear out the cloned bbRefs field. - newBlk->bbRefs = 0; + // We're going to create the preds below, which will set the bbRefs properly, + // so clear out the cloned bbRefs field. + newBlk->bbRefs = 0; - newBlk->scaleBBWeight(weightScale); + newBlk->scaleBBWeight(weightScale); - *insertAfter = newBlk; - map->Set(blk, newBlk, BlockToBlockMap::Overwrite); + *insertAfter = newBlk; + map->Set(blk, newBlk, BlockToBlockMap::Overwrite); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); // Now go through the new blocks, remapping their jump targets within the loop // and updating the preds lists. - VisitLoopBlocks([=](BasicBlock* blk) { - BasicBlock* newBlk = nullptr; - bool b = map->Lookup(blk, &newBlk); - assert(b && newBlk != nullptr); + VisitLoopBlocks( + [=](BasicBlock* blk) + { + BasicBlock* newBlk = nullptr; + bool b = map->Lookup(blk, &newBlk); + assert(b && newBlk != nullptr); - // Jump target should not be set yet - assert(!newBlk->HasInitializedTarget()); + // Jump target should not be set yet + assert(!newBlk->HasInitializedTarget()); - // Redirect the new block according to "blockMap". - // optSetMappedBlockTargets will set newBlk's successors, and add pred edges for the successors. - comp->optSetMappedBlockTargets(blk, newBlk, map); + // Redirect the new block according to "blockMap". + // optSetMappedBlockTargets will set newBlk's successors, and add pred edges for the successors. + comp->optSetMappedBlockTargets(blk, newBlk, map); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ @@ -6165,10 +6204,12 @@ BlockToNaturalLoopMap* BlockToNaturalLoopMap::Build(FlowGraphNaturalLoops* loops // loops last and thus write their indices into the map last. for (FlowGraphNaturalLoop* loop : loops->InReversePostOrder()) { - loop->VisitLoopBlocks([=](BasicBlock* block) { - indices[block->bbPostorderNum] = loop->GetIndex(); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks( + [=](BasicBlock* block) + { + indices[block->bbPostorderNum] = loop->GetIndex(); + return BasicBlockVisit::Continue; + }); } return new (comp, CMK_Loops) BlockToNaturalLoopMap(loops, indices); diff --git a/src/coreclr/jit/forwardsub.cpp b/src/coreclr/jit/forwardsub.cpp index 8e450d7cbb35e1..b6a1c8534bb1fd 100644 --- a/src/coreclr/jit/forwardsub.cpp +++ b/src/coreclr/jit/forwardsub.cpp @@ -399,9 +399,7 @@ class EffectsVisitor final : public GenTreeVisitor UseExecutionOrder = true }; - EffectsVisitor(Compiler* compiler) : GenTreeVisitor(compiler), m_flags(GTF_EMPTY) - { - } + EffectsVisitor(Compiler* compiler) : GenTreeVisitor(compiler), m_flags(GTF_EMPTY) {} Compiler::fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { diff --git a/src/coreclr/jit/gcencode.cpp b/src/coreclr/jit/gcencode.cpp index d039cb3169379e..68e4c10d7b6a86 100644 --- a/src/coreclr/jit/gcencode.cpp +++ b/src/coreclr/jit/gcencode.cpp @@ -433,12 +433,13 @@ static void regenLog(unsigned encoding, InfoHdr* header, InfoHdr* state) EnterCriticalSection(&logFileLock); - fprintf(logFile, "InfoHdr( %2d, %2d, %1d, %1d, %1d," - " %1d, %1d, %1d, %1d, %1d," - " %1d, %1d, %1d, %1d, %1d, %1d," - " %1d, %1d, %1d," - " %1d, %2d, %2d," - " %2d, %2d, %2d, %2d, %2d, %2d), \n", + fprintf(logFile, + "InfoHdr( %2d, %2d, %1d, %1d, %1d," + " %1d, %1d, %1d, %1d, %1d," + " %1d, %1d, %1d, %1d, %1d, %1d," + " %1d, %1d, %1d," + " %1d, %2d, %2d," + " %2d, %2d, %2d, %2d, %2d, %2d), \n", state->prologSize, state->epilogSize, state->epilogCount, state->epilogAtEnd, state->ediSaved, state->esiSaved, state->ebxSaved, state->ebpSaved, state->ebpFrame, state->interruptible, state->doubleAlign, state->security, state->handlers, state->localloc, state->editNcontinue, state->varargs, @@ -2331,7 +2332,7 @@ size_t GCInfo::gcMakeRegPtrTable(BYTE* dest, int mask, const InfoHdr& header, un unsigned varOffs = compiler->lvaTable[compiler->info.compThisArg].GetStackOffset(); /* For negative stack offsets we must reset the low bits, - * take abs and then set them back */ + * take abs and then set them back */ varOffs = abs(static_cast(varOffs)); varOffs |= this_OFFSET_FLAG; @@ -3285,7 +3286,7 @@ size_t GCInfo::gcMakeRegPtrTable(BYTE* dest, int mask, const InfoHdr& header, un assert(regMask || argMask || callArgCnt || pasStk.pasCurDepth()); -// Emit IPtrMask if needed + // Emit IPtrMask if needed #define CHK_NON_INTRPT_ESP_IPtrMask \ \ @@ -3571,7 +3572,7 @@ size_t GCInfo::gcInfoBlockHdrDump(const BYTE* table, InfoHdr* header, unsigned* #ifdef DEBUG gcDump.gcPrintf = gcDump_logf; // use my printf (which logs to VM) #else - gcDump.gcPrintf = printf; + gcDump.gcPrintf = printf; #endif printf("Method info block:\n"); @@ -3590,7 +3591,7 @@ size_t GCInfo::gcDumpPtrTable(const BYTE* table, const InfoHdr& header, unsigned #ifdef DEBUG gcDump.gcPrintf = gcDump_logf; // use my printf (which logs to VM) #else - gcDump.gcPrintf = printf; + gcDump.gcPrintf = printf; #endif return gcDump.DumpGCTable(table, header, methodSize, verifyGCTables); @@ -3608,7 +3609,7 @@ void GCInfo::gcFindPtrsInFrame(const void* infoBlock, const void* codeBlock, uns #ifdef DEBUG gcDump.gcPrintf = gcDump_logf; // use my printf (which logs to VM) #else - gcDump.gcPrintf = printf; + gcDump.gcPrintf = printf; #endif gcDump.DumpPtrsInFrame((PTR_CBYTE)infoBlock, (const BYTE*)codeBlock, offs, verifyGCTables); @@ -4793,7 +4794,7 @@ void GCInfo::gcInfoRecordGCStackArgLive(GcInfoEncoder* gcInfoEncoder, MakeRegPtr StackSlotIdKey sskey(genStackPtr->rpdPtrArg, false, GcSlotFlags(genStackPtr->rpdGCtypeGet() == GCT_BYREF ? GC_SLOT_INTERIOR : GC_SLOT_BASE)); - GcSlotId varSlotId; + GcSlotId varSlotId; if (mode == MAKE_REG_PTR_MODE_ASSIGN_SLOTS) { if (!m_stackSlotMap->Lookup(sskey, &varSlotId)) @@ -4841,8 +4842,8 @@ void GCInfo::gcInfoRecordGCStackArgsDead(GcInfoEncoder* gcInfoEncoder, StackSlotIdKey sskey(genRegPtrTemp->rpdPtrArg, false, genRegPtrTemp->rpdGCtypeGet() == GCT_BYREF ? GC_SLOT_INTERIOR : GC_SLOT_BASE); - GcSlotId varSlotId; - bool b = m_stackSlotMap->Lookup(sskey, &varSlotId); + GcSlotId varSlotId; + bool b = m_stackSlotMap->Lookup(sskey, &varSlotId); assert(b); // Should have been added in the first pass. // Live until the call. gcInfoEncoderWithLog->SetSlotState(instrOffset, varSlotId, GC_SLOT_DEAD); diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index dd77f8e6e1cece..88aff2c08a1efc 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -21,13 +21,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX /*****************************************************************************/ const unsigned char GenTree::gtOperKindTable[] = { -#define GTNODE(en, st, cm, ivn, ok) ((ok)>K_MASK) + GTK_COMMUTE *cm, +#define GTNODE(en, st, cm, ivn, ok) ((ok) & GTK_MASK) + GTK_COMMUTE *cm, #include "gtlist.h" }; #ifdef DEBUG const GenTreeDebugOperKind GenTree::gtDebugOperKindTable[] = { -#define GTNODE(en, st, cm, ivn, ok) static_cast((ok)&DBK_MASK), +#define GTNODE(en, st, cm, ivn, ok) static_cast((ok) & DBK_MASK), #include "gtlist.h" }; #endif // DEBUG @@ -3199,15 +3199,17 @@ bool GenTree::Compare(GenTree* op1, GenTree* op2, bool swapOK) } bool result = false; - tree->VisitOperands([lclNum, &result](GenTree* operand) -> GenTree::VisitResult { - if (gtHasRef(operand, lclNum)) + tree->VisitOperands( + [lclNum, &result](GenTree* operand) -> GenTree::VisitResult { - result = true; - return GenTree::VisitResult::Abort; - } + if (gtHasRef(operand, lclNum)) + { + result = true; + return GenTree::VisitResult::Abort; + } - return GenTree::VisitResult::Continue; - }); + return GenTree::VisitResult::Continue; + }); return result; } @@ -3233,9 +3235,7 @@ bool Compiler::gtHasLocalsWithAddrOp(GenTree* tree) DoLclVarsOnly = true, }; - LocalsWithAddrOpVisitor(Compiler* comp) : GenTreeVisitor(comp) - { - } + LocalsWithAddrOpVisitor(Compiler* comp) : GenTreeVisitor(comp) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -3274,9 +3274,7 @@ bool Compiler::gtHasAddressExposedLocals(GenTree* tree) DoLclVarsOnly = true, }; - Visitor(Compiler* comp) : GenTreeVisitor(comp) - { - } + Visitor(Compiler* comp) : GenTreeVisitor(comp) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -3363,7 +3361,7 @@ unsigned Compiler::gtHashValue(GenTree* tree) #ifdef HOST_64BIT add = bits; #else // 32-bit host - add = genTreeHashAdd(uhi32(bits), ulo32(bits)); + add = genTreeHashAdd(uhi32(bits), ulo32(bits)); #endif break; case GT_CNS_DBL: @@ -3373,7 +3371,7 @@ unsigned Compiler::gtHashValue(GenTree* tree) #ifdef HOST_64BIT add = bits; #else // 32-bit host - add = genTreeHashAdd(uhi32(bits), ulo32(bits)); + add = genTreeHashAdd(uhi32(bits), ulo32(bits)); #endif break; } @@ -3883,7 +3881,8 @@ bool GenTreeOp::IsValidLongMul() if (gtOverflow()) { - auto getMaxValue = [this](GenTree* op) -> int64_t { + auto getMaxValue = [this](GenTree* op) -> int64_t + { if (op->OperIs(GT_CAST)) { if (op->IsUnsigned()) @@ -3980,7 +3979,8 @@ unsigned Compiler::gtSetCallArgsOrder(CallArgs* args, bool lateArgs, int* callCo unsigned costEx = 0; unsigned costSz = 0; - auto update = [&level, &costEx, &costSz, lateArgs](GenTree* argNode, unsigned argLevel) { + auto update = [&level, &costEx, &costSz, lateArgs](GenTree* argNode, unsigned argLevel) + { if (argLevel > level) { level = argLevel; @@ -6436,9 +6436,7 @@ bool Compiler::gtMayHaveStoreInterference(GenTree* treeWithStores, GenTree* tree DoPreOrder = true, }; - Visitor(Compiler* compiler, GenTree* readTree) : GenTreeVisitor(compiler), m_readTree(readTree) - { - } + Visitor(Compiler* compiler, GenTree* readTree) : GenTreeVisitor(compiler), m_readTree(readTree) {} Compiler::fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -7480,7 +7478,7 @@ GenTree::VtablePtr GenTree::GetVtableForOper(genTreeOps oper) switch (oper) { -// clang-format off + // clang-format off #define GTSTRUCT_0(nm, tag) /*handle explicitly*/ #define GTSTRUCT_1(nm, tag) \ @@ -7542,8 +7540,8 @@ GenTree::VtablePtr GenTree::GetVtableForOper(genTreeOps oper) } break; - // We don't need to handle GTSTRUCT_N for LclVarCommon, since all those allowed opers are specified - // in their proper subtype. Similarly for GenTreeIndir. + // We don't need to handle GTSTRUCT_N for LclVarCommon, since all those allowed opers are specified + // in their proper subtype. Similarly for GenTreeIndir. default: { @@ -9026,7 +9024,7 @@ GenTree* Compiler::gtNewPutArgReg(var_types type, GenTree* arg, regNumber argReg node->AsMultiRegOp()->gtOtherReg = REG_NEXT(argReg); } #else - node = gtNewOperNode(GT_PUTARG_REG, type, arg); + node = gtNewOperNode(GT_PUTARG_REG, type, arg); #endif node->SetRegNum(argReg); @@ -9057,7 +9055,7 @@ GenTree* Compiler::gtNewBitCastNode(var_types type, GenTree* arg) // A BITCAST could be a MultiRegOp on arm since we could move a double register to two int registers. node = new (this, GT_BITCAST) GenTreeMultiRegOp(GT_BITCAST, type, arg, nullptr); #else - node = gtNewOperNode(GT_BITCAST, type, arg); + node = gtNewOperNode(GT_BITCAST, type, arg); #endif return node; @@ -9462,7 +9460,7 @@ GenTree* Compiler::gtCloneExpr(GenTree* tree) tree->AsLclFld()->Data(), tree->AsLclFld()->GetLayout()); break; - /* These nodes sometimes get bashed to "fat" ones */ + /* These nodes sometimes get bashed to "fat" ones */ case GT_MUL: case GT_DIV: @@ -9994,9 +9992,7 @@ void Compiler::gtUpdateStmtSideEffects(Statement* stmt) DoPostOrder = true, }; - UpdateSideEffectsWalker(Compiler* comp) : GenTreeVisitor(comp) - { - } + UpdateSideEffectsWalker(Compiler* comp) : GenTreeVisitor(comp) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -10105,10 +10101,12 @@ void Compiler::gtUpdateNodeOperSideEffects(GenTree* tree) void Compiler::gtUpdateNodeSideEffects(GenTree* tree) { gtUpdateNodeOperSideEffects(tree); - tree->VisitOperands([tree](GenTree* operand) -> GenTree::VisitResult { - tree->gtFlags |= (operand->gtFlags & GTF_ALL_EFFECT); - return GenTree::VisitResult::Continue; - }); + tree->VisitOperands( + [tree](GenTree* operand) -> GenTree::VisitResult + { + tree->gtFlags |= (operand->gtFlags & GTF_ALL_EFFECT); + return GenTree::VisitResult::Continue; + }); } bool GenTree::gtSetFlags() const @@ -10480,7 +10478,7 @@ void GenTreeUseEdgeIterator::AdvanceConditional() // `GTF_REVERSE_OPS` flag. // template -void GenTreeUseEdgeIterator::AdvanceBinOp() +void GenTreeUseEdgeIterator::AdvanceBinOp() { assert(ReverseOperands == ((m_node->gtFlags & GTF_REVERSE_OPS) != 0)); @@ -10603,7 +10601,7 @@ void GenTreeUseEdgeIterator::SetEntryStateForMultiOp() // component operands. // template -void GenTreeUseEdgeIterator::AdvanceCall() +void GenTreeUseEdgeIterator::AdvanceCall() { GenTreeCall* const call = m_node->AsCall(); @@ -10816,10 +10814,12 @@ bool GenTree::HandleKindDataIsInvariant(GenTreeFlags flags) printf("%c", (flags & GTF_EXCEPT) ? 'X' : '-'); printf("%c", (flags & GTF_GLOB_REF) ? 'G' : '-'); printf("%c", (debugFlags & GTF_DEBUG_NODE_MORPHED) ? '+' : // First print '+' if GTF_DEBUG_NODE_MORPHED is set - (flags & GTF_ORDER_SIDEEFF) ? 'O' : '-'); // otherwise print 'O' or '-' + (flags & GTF_ORDER_SIDEEFF) ? 'O' + : '-'); // otherwise print 'O' or '-' printf("%c", (flags & GTF_COLON_COND) ? '?' : '-'); - printf("%c", (flags & GTF_DONT_CSE) ? 'N' : // N is for No cse - (flags & GTF_MAKE_CSE) ? 'H' : '-'); // H is for Hoist this expr + printf("%c", (flags & GTF_DONT_CSE) ? 'N' : // N is for No cse + (flags & GTF_MAKE_CSE) ? 'H' + : '-'); // H is for Hoist this expr printf("%c", (flags & GTF_REVERSE_OPS) ? 'R' : '-'); printf("%c", (flags & GTF_UNSIGNED) ? 'U' : (flags & GTF_BOOLEAN) ? 'B' : '-'); #if FEATURE_SET_FLAGS @@ -11668,8 +11668,8 @@ void Compiler::gtDispRegVal(GenTree* tree) { switch (tree->GetRegTag()) { - // Don't display anything for the GT_REGTAG_NONE case; - // the absence of printed register values will imply this state. + // Don't display anything for the GT_REGTAG_NONE case; + // the absence of printed register values will imply this state. case GenTree::GT_REGTAG_REG: printf(" REG %s", compRegVarName(tree->GetRegNum())); @@ -11934,7 +11934,7 @@ static const char* InsCflagsToString(insCflags flags) { const static char* s_table[16] = {"0", "v", "c", "cv", "z", "zv", "zc", "zcv", "n", "nv", "nc", "ncv", "nz", "nzv", "nzc", "nzcv"}; - unsigned index = (unsigned)flags; + unsigned index = (unsigned)flags; assert((0 <= index) && (index < ArrLen(s_table))); return s_table[index]; } @@ -12345,7 +12345,7 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) break; #endif // !FEATURE_EH_FUNCLETS - // Vanilla leaves. No qualifying information available. So do nothing + // Vanilla leaves. No qualifying information available. So do nothing case GT_NOP: case GT_NO_OP: @@ -12497,8 +12497,8 @@ void Compiler::gtDispLocal(GenTreeLclVarCommon* tree, IndentStack* indentStack) void Compiler::gtDispChild(GenTree* child, IndentStack* indentStack, IndentInfo arcType, - _In_opt_ const char* msg, /* = nullptr */ - bool topOnly) /* = false */ + _In_opt_ const char* msg, /* = nullptr */ + bool topOnly) /* = false */ { indentStack->Push(arcType); gtDispTree(child, indentStack, msg, topOnly); @@ -12507,11 +12507,11 @@ void Compiler::gtDispChild(GenTree* child, /*****************************************************************************/ -void Compiler::gtDispTree(GenTree* tree, - IndentStack* indentStack, /* = nullptr */ - _In_ _In_opt_z_ const char* msg, /* = nullptr */ - bool topOnly, /* = false */ - bool isLIR) /* = false */ +void Compiler::gtDispTree(GenTree* tree, + IndentStack* indentStack, /* = nullptr */ + _In_ _In_opt_z_ const char* msg, /* = nullptr */ + bool topOnly, /* = false */ + bool isLIR) /* = false */ { if (tree == nullptr) { @@ -12697,7 +12697,8 @@ void Compiler::gtDispTree(GenTree* tree, if (tree->OperIs(GT_FIELD_ADDR)) { - auto disp = [&]() { + auto disp = [&]() + { char buffer[256]; printf(" %s", eeGetFieldName(tree->AsFieldAddr()->gtFldHnd, true, buffer, sizeof(buffer))); }; @@ -12938,14 +12939,17 @@ void Compiler::gtDispTree(GenTree* tree, { GenTreeCall* call = tree->AsCall(); GenTree* lastChild = nullptr; - call->VisitOperands([&lastChild](GenTree* operand) -> GenTree::VisitResult { - lastChild = operand; - return GenTree::VisitResult::Continue; - }); + call->VisitOperands( + [&lastChild](GenTree* operand) -> GenTree::VisitResult + { + lastChild = operand; + return GenTree::VisitResult::Continue; + }); if (call->gtCallType != CT_INDIRECT) { - auto disp = [&]() { + auto disp = [&]() + { char buffer[256]; printf(" %s", eeGetMethodFullName(call->gtCallMethHnd, true, true, buffer, sizeof(buffer))); }; @@ -13008,9 +13012,10 @@ void Compiler::gtDispTree(GenTree* tree, case GT_HWINTRINSIC: if (tree->OperIs(GT_HWINTRINSIC)) { - printf(" %s %s", tree->AsHWIntrinsic()->GetSimdBaseType() == TYP_UNKNOWN - ? "" - : varTypeName(tree->AsHWIntrinsic()->GetSimdBaseType()), + printf(" %s %s", + tree->AsHWIntrinsic()->GetSimdBaseType() == TYP_UNKNOWN + ? "" + : varTypeName(tree->AsHWIntrinsic()->GetSimdBaseType()), HWIntrinsicInfo::lookupName(tree->AsHWIntrinsic()->GetHWIntrinsicId())); } @@ -13409,8 +13414,9 @@ void Compiler::gtDispTreeRange(LIR::Range& containingRange, GenTree* tree) // void Compiler::gtDispLIRNode(GenTree* node, const char* prefixMsg /* = nullptr */) { - auto displayOperand = [](GenTree* operand, const char* message, IndentInfo operandArc, IndentStack& indentStack, - size_t prefixIndent) { + auto displayOperand = + [](GenTree* operand, const char* message, IndentInfo operandArc, IndentStack& indentStack, size_t prefixIndent) + { assert(operand != nullptr); assert(message != nullptr); @@ -14273,7 +14279,8 @@ GenTree* Compiler::gtFoldExprSpecial(GenTree* tree) bool opHasSideEffects = (op->gtFlags & GTF_SIDE_EFFECT) != 0; // Helper function that creates a new IntCon node and morphs it, if required - auto NewMorphedIntConNode = [&](int value) -> GenTreeIntCon* { + auto NewMorphedIntConNode = [&](int value) -> GenTreeIntCon* + { GenTreeIntCon* icon = gtNewIconNode(value); if (fgGlobalMorph) { @@ -14282,7 +14289,8 @@ GenTree* Compiler::gtFoldExprSpecial(GenTree* tree) return icon; }; - auto NewZeroExtendNode = [&](var_types type, GenTree* op1, var_types castToType) -> GenTree* { + auto NewZeroExtendNode = [&](var_types type, GenTree* op1, var_types castToType) -> GenTree* + { assert(varTypeIsIntegral(type)); assert(!varTypeIsSmall(type)); assert(!varTypeIsUnsigned(type)); @@ -15564,8 +15572,8 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) switch (switchType) { - // Fold constant REF of BYREF binary operator. - // These can only be comparisons or null pointers. + // Fold constant REF of BYREF binary operator. + // These can only be comparisons or null pointers. case TYP_REF: @@ -15634,7 +15642,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) return tree; - // Fold constant INT binary operator. + // Fold constant INT binary operator. case TYP_INT: @@ -15761,8 +15769,8 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) i1 = (i1 << ((32 - i2) & 0x1f)) | (UINT32(i1) >> (i2 & 0x1f)); break; - // DIV and MOD can throw an exception - if the division is by 0 - // or there is overflow - when dividing MIN by -1. + // DIV and MOD can throw an exception - if the division is by 0 + // or there is overflow - when dividing MIN by -1. case GT_DIV: case GT_MOD: @@ -15831,7 +15839,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) goto DONE; - // Fold constant LONG binary operator. + // Fold constant LONG binary operator. case TYP_LONG: @@ -16054,7 +16062,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) goto DONE; - // Fold constant FLOAT or DOUBLE binary operator + // Fold constant FLOAT or DOUBLE binary operator case TYP_FLOAT: case TYP_DOUBLE: @@ -17092,9 +17100,7 @@ void Compiler::gtExtractSideEffList(GenTree* expr, return m_result; } - SideEffectExtractor(Compiler* compiler, GenTreeFlags flags) : GenTreeVisitor(compiler), m_flags(flags) - { - } + SideEffectExtractor(Compiler* compiler, GenTreeFlags flags) : GenTreeVisitor(compiler), m_flags(flags) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -17373,9 +17379,7 @@ Compiler::FindLinkData Compiler::gtFindLink(Statement* stmt, GenTree* node) DoPreOrder = true, }; - FindLinkWalker(Compiler* comp, GenTree* node) : GenTreeVisitor(comp), m_node(node) - { - } + FindLinkWalker(Compiler* comp, GenTree* node) : GenTreeVisitor(comp), m_node(node) {} FindLinkData GetResult() { @@ -17559,9 +17563,7 @@ bool Compiler::gtTreeContainsOper(GenTree* tree, genTreeOps oper) genTreeOps m_oper; public: - Visitor(Compiler* comp, genTreeOps oper) : GenTreeVisitor(comp), m_oper(oper) - { - } + Visitor(Compiler* comp, genTreeOps oper) : GenTreeVisitor(comp), m_oper(oper) {} enum { @@ -17600,9 +17602,7 @@ ExceptionSetFlags Compiler::gtCollectExceptions(GenTree* tree) ExceptionSetFlags m_preciseExceptions = ExceptionSetFlags::None; public: - ExceptionsWalker(Compiler* comp) : GenTreeVisitor(comp) - { - } + ExceptionsWalker(Compiler* comp) : GenTreeVisitor(comp) {} enum { @@ -17658,9 +17658,7 @@ bool Compiler::gtComplexityExceeds(GenTree* tree, unsigned limit) DoPreOrder = true, }; - ComplexityVisitor(Compiler* comp, unsigned limit) : GenTreeVisitor(comp), m_limit(limit) - { - } + ComplexityVisitor(Compiler* comp, unsigned limit) : GenTreeVisitor(comp), m_limit(limit) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -20631,8 +20629,8 @@ GenTree* Compiler::gtNewSimdBinOpNode( assert(!compIsaSupportedDebugOnly(InstructionSet_AVX512F_VL)); // Vector256 maskedProduct = Avx2.And(widenedProduct, vecCon1).AsInt16() - GenTree* maskedProduct = gtNewSimdBinOpNode(GT_AND, widenedType, widenedProduct, vecCon1, - widenedSimdBaseJitType, widenedSimdSize); + GenTree* maskedProduct = gtNewSimdBinOpNode(GT_AND, widenedType, widenedProduct, vecCon1, + widenedSimdBaseJitType, widenedSimdSize); GenTree* maskedProductDup = fgMakeMultiUse(&maskedProduct); // Vector256 packedProduct = Avx2.PackUnsignedSaturate(maskedProduct, @@ -21629,10 +21627,10 @@ GenTree* Compiler::gtNewSimdCmpOpNode( op1 = gtNewSimdHWIntrinsicNode(type, t, gtNewIconNode(SHUFFLE_WWYY, TYP_INT), NI_SSE2_Shuffle, CORINFO_TYPE_INT, simdSize); - u = gtNewSimdHWIntrinsicNode(type, u, gtNewIconNode(SHUFFLE_WWYY, TYP_INT), NI_SSE2_Shuffle, - CORINFO_TYPE_INT, simdSize); - v = gtNewSimdHWIntrinsicNode(type, v, gtNewIconNode(SHUFFLE_ZZXX, TYP_INT), NI_SSE2_Shuffle, - CORINFO_TYPE_INT, simdSize); + u = gtNewSimdHWIntrinsicNode(type, u, gtNewIconNode(SHUFFLE_WWYY, TYP_INT), NI_SSE2_Shuffle, + CORINFO_TYPE_INT, simdSize); + v = gtNewSimdHWIntrinsicNode(type, v, gtNewIconNode(SHUFFLE_ZZXX, TYP_INT), NI_SSE2_Shuffle, + CORINFO_TYPE_INT, simdSize); // Validate we can't use AVX512F_VL_TernaryLogic here assert(!compIsaSupportedDebugOnly(InstructionSet_AVX512F_VL)); @@ -21884,10 +21882,10 @@ GenTree* Compiler::gtNewSimdCmpOpNode( op1 = gtNewSimdHWIntrinsicNode(type, t, gtNewIconNode(SHUFFLE_WWYY, TYP_INT), NI_SSE2_Shuffle, CORINFO_TYPE_INT, simdSize); - u = gtNewSimdHWIntrinsicNode(type, u, gtNewIconNode(SHUFFLE_WWYY, TYP_INT), NI_SSE2_Shuffle, - CORINFO_TYPE_INT, simdSize); - v = gtNewSimdHWIntrinsicNode(type, v, gtNewIconNode(SHUFFLE_ZZXX, TYP_INT), NI_SSE2_Shuffle, - CORINFO_TYPE_INT, simdSize); + u = gtNewSimdHWIntrinsicNode(type, u, gtNewIconNode(SHUFFLE_WWYY, TYP_INT), NI_SSE2_Shuffle, + CORINFO_TYPE_INT, simdSize); + v = gtNewSimdHWIntrinsicNode(type, v, gtNewIconNode(SHUFFLE_ZZXX, TYP_INT), NI_SSE2_Shuffle, + CORINFO_TYPE_INT, simdSize); // Validate we can't use AVX512F_VL_TernaryLogic here assert(!compIsaSupportedDebugOnly(InstructionSet_AVX512F_VL)); @@ -25033,8 +25031,8 @@ GenTree* Compiler::gtNewSimdSumNode(var_types type, GenTree* op1, CorInfoType si tmp = fgMakeMultiUse(&op1); opShifted = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, gtNewIconNode(shiftVal, TYP_INT), NI_SSE2_ShiftRightLogical128BitLane, simdBaseJitType, simdSize); - op1 = gtNewSimdBinOpNode(GT_ADD, TYP_SIMD16, opShifted, tmp, simdBaseJitType, simdSize); - shiftVal = shiftVal / 2; + op1 = gtNewSimdBinOpNode(GT_ADD, TYP_SIMD16, opShifted, tmp, simdBaseJitType, simdSize); + shiftVal = shiftVal / 2; } return gtNewSimdToScalarNode(type, op1, simdBaseJitType, simdSize); @@ -26787,7 +26785,7 @@ genTreeOps GenTreeHWIntrinsic::HWOperGet() const return GT_AND_NOT; } #endif - // TODO: Handle other cases + // TODO: Handle other cases default: { @@ -26935,7 +26933,7 @@ void ReturnTypeDesc::InitializeStructReturnType(Compiler* comp, #else uint32_t floatFieldFlags = comp->info.compCompHnd->getRISCV64PassStructInRegisterFlags(retClsHnd); #endif - BYTE gcPtrs[2] = {TYPE_GC_NONE, TYPE_GC_NONE}; + BYTE gcPtrs[2] = {TYPE_GC_NONE, TYPE_GC_NONE}; comp->info.compCompHnd->getClassGClayout(retClsHnd, &gcPtrs[0]); if (floatFieldFlags & STRUCT_FLOAT_FIELD_ONLY_TWO) diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index c1fc5b33a7175f..0fc2a67d0ee7bb 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -156,10 +156,10 @@ inline ExceptionSetFlags& operator&=(ExceptionSetFlags& a, ExceptionSetFlags b) #ifdef DEBUG /***************************************************************************** -* -* TargetHandleTypes are used to determine the type of handle present inside GenTreeIntCon node. -* The values are such that they don't overlap with helper's or user function's handle. -*/ + * + * TargetHandleTypes are used to determine the type of handle present inside GenTreeIntCon node. + * The values are such that they don't overlap with helper's or user function's handle. + */ enum TargetHandleType : BYTE { THT_Unknown = 2, @@ -206,13 +206,9 @@ class AssertionInfo } public: - AssertionInfo() : AssertionInfo(false, 0) - { - } + AssertionInfo() : AssertionInfo(false, 0) {} - AssertionInfo(AssertionIndex assertionIndex) : AssertionInfo(false, assertionIndex) - { - } + AssertionInfo(AssertionIndex assertionIndex) : AssertionInfo(false, assertionIndex) {} static AssertionInfo ForNextEdge(AssertionIndex assertionIndex) { @@ -314,9 +310,7 @@ class FieldSeqStore JitHashTable, FieldSeq> m_map; public: - FieldSeqStore(CompAllocator alloc) : m_map(alloc) - { - } + FieldSeqStore(CompAllocator alloc) : m_map(alloc) {} FieldSeq* Create(CORINFO_FIELD_HANDLE fieldHnd, ssize_t offset, FieldSeq::FieldKind fieldKind); @@ -957,7 +951,7 @@ struct GenTree regMaskSmall gtRsvdRegs; // set of fixed trashed registers - unsigned AvailableTempRegCount(regMaskTP mask = (regMaskTP)-1) const; + unsigned AvailableTempRegCount(regMaskTP mask = (regMaskTP)-1) const; regNumber GetSingleTempReg(regMaskTP mask = (regMaskTP)-1); regNumber ExtractTempReg(regMaskTP mask = (regMaskTP)-1); @@ -1509,7 +1503,7 @@ struct GenTree #if !defined(TARGET_64BIT) || (gtOper == GT_ADD_HI) || (gtOper == GT_SUB_HI) #endif - ); + ); } bool OperMayOverflow() const @@ -1754,9 +1748,9 @@ struct GenTree return (DebugOperKind() & DBK_NOTLIR) == 0; } - bool OperSupportsReverseOpEvalOrder(Compiler* comp) const; + bool OperSupportsReverseOpEvalOrder(Compiler* comp) const; static bool RequiresNonNullOp2(genTreeOps oper); - bool IsValidCallArgument(); + bool IsValidCallArgument(); #endif // DEBUG inline bool IsIntegralConst(ssize_t constVal) const; @@ -1857,7 +1851,7 @@ struct GenTree bool OperRequiresCallFlag(Compiler* comp) const; ExceptionSetFlags OperExceptions(Compiler* comp); - bool OperMayThrow(Compiler* comp); + bool OperMayThrow(Compiler* comp); bool OperRequiresGlobRefFlag(Compiler* comp) const; @@ -1894,7 +1888,7 @@ struct GenTree static bool Compare(GenTree* op1, GenTree* op2, bool swapOK = false); -//--------------------------------------------------------------------- + //--------------------------------------------------------------------- #if defined(DEBUG) || CALL_ARG_STATS || COUNT_BASIC_BLOCKS || COUNT_LOOPS || EMITTER_STATS || MEASURE_MEM_ALLOC || \ NODEBASH_STATS || MEASURE_NODE_SIZE || COUNT_AST_OPERS || DUMP_FLOWGRAPHS @@ -1938,8 +1932,8 @@ struct GenTree } template - void BashToConst(T value, var_types type = TYP_UNDEF); - void BashToZeroConst(var_types type); + void BashToConst(T value, var_types type = TYP_UNDEF); + void BashToZeroConst(var_types type); GenTreeLclVar* BashToLclVar(Compiler* comp, unsigned lclNum); #if NODEBASH_STATS @@ -1977,7 +1971,7 @@ struct GenTree unsigned* pSize = nullptr); GenTreeLclVarCommon* IsImplicitByrefParameterValuePreMorph(Compiler* compiler); - GenTreeLclVar* IsImplicitByrefParameterValuePostMorph(Compiler* compiler, GenTree** addr); + GenTreeLclVar* IsImplicitByrefParameterValuePostMorph(Compiler* compiler, GenTree** addr); // Determine whether this is an assignment tree of the form X = X (op) Y, // where Y is an arbitrary tree, and X is a lclVar. @@ -2256,7 +2250,7 @@ struct GenTree bool gtRequestSetFlags(); #ifdef DEBUG - static int gtDispFlags(GenTreeFlags flags, GenTreeDebugFlags debugFlags); + static int gtDispFlags(GenTreeFlags flags, GenTreeDebugFlags debugFlags); static const char* gtGetHandleKindString(GenTreeFlags flags); #endif @@ -2274,9 +2268,7 @@ struct GenTree // we can't synthesize an assignment operator. // TODO-Cleanup: Could change this w/o liveset on tree nodes // (This is also necessary for the VTable trick.) - GenTree() - { - } + GenTree() {} // Returns an iterator that will produce the use edge to each operand of this node. Differs // from the sequence of nodes produced by a loop over `GetChild` in its handling of call, phi, @@ -2368,14 +2360,12 @@ struct GenTree #if DEBUGGABLE_GENTREE // In DEBUG builds, add a dummy virtual method, to give the debugger run-time type information. - virtual void DummyVirt() - { - } + virtual void DummyVirt() {} typedef void* VtablePtr; VtablePtr GetVtableForOper(genTreeOps oper); - void SetVtableForOper(genTreeOps oper); + void SetVtableForOper(genTreeOps oper); static VtablePtr s_vtablesForOpers[GT_COUNT]; static VtablePtr s_vtableForOp; @@ -2447,9 +2437,7 @@ struct GenTreePhi final : public GenTree Use* m_use; public: - UseIterator(Use* use) : m_use(use) - { - } + UseIterator(Use* use) : m_use(use) {} Use& operator*() const { @@ -2483,9 +2471,7 @@ struct GenTreePhi final : public GenTree Use* m_uses; public: - UseList(Use* uses) : m_uses(uses) - { - } + UseList(Use* uses) : m_uses(uses) {} UseIterator begin() const { @@ -2500,9 +2486,7 @@ struct GenTreePhi final : public GenTree Use* gtUses; - GenTreePhi(var_types type) : GenTree(GT_PHI, type), gtUses(nullptr) - { - } + GenTreePhi(var_types type) : GenTree(GT_PHI, type), gtUses(nullptr) {} UseList Uses() { @@ -2549,9 +2533,7 @@ struct GenTreePhi final : public GenTree } #if DEBUGGABLE_GENTREE - GenTreePhi() : GenTree() - { - } + GenTreePhi() : GenTree() {} #endif }; @@ -2628,9 +2610,7 @@ struct GenTreeFieldList : public GenTree Use* use; public: - UseIterator(Use* use) : use(use) - { - } + UseIterator(Use* use) : use(use) {} Use& operator*() { @@ -2664,9 +2644,7 @@ struct GenTreeFieldList : public GenTree Use* m_tail; public: - UseList() : m_head(nullptr), m_tail(nullptr) - { - } + UseList() : m_head(nullptr), m_tail(nullptr) {} Use* GetHead() const { @@ -2848,12 +2826,12 @@ class GenTreeUseEdgeIterator final void AdvanceConditional(); template - void AdvanceBinOp(); - void SetEntryStateForBinOp(); + void AdvanceBinOp(); + void SetEntryStateForBinOp(); // The advance function for call nodes template - void AdvanceCall(); + void AdvanceCall(); #if defined(FEATURE_SIMD) || defined(FEATURE_HW_INTRINSICS) void AdvanceMultiOp(); @@ -2912,14 +2890,10 @@ class GenTreeOperandIterator final GenTreeUseEdgeIterator m_useEdges; - GenTreeOperandIterator(GenTree* node) : m_useEdges(node) - { - } + GenTreeOperandIterator(GenTree* node) : m_useEdges(node) {} public: - GenTreeOperandIterator() : m_useEdges() - { - } + GenTreeOperandIterator() : m_useEdges() {} inline GenTree* operator*() { @@ -2975,9 +2949,7 @@ struct GenTreeUnOp : public GenTree } #if DEBUGGABLE_GENTREE - GenTreeUnOp() : GenTree(), gtOp1(nullptr) - { - } + GenTreeUnOp() : GenTree(), gtOp1(nullptr) {} #endif }; @@ -3027,9 +2999,7 @@ struct GenTreeOp : public GenTreeUnOp #endif #if DEBUGGABLE_GENTREE - GenTreeOp() : GenTreeUnOp(), gtOp2(nullptr) - { - } + GenTreeOp() : GenTreeUnOp(), gtOp2(nullptr) {} #endif }; @@ -3037,24 +3007,20 @@ struct GenTreeVal : public GenTree { size_t gtVal1; - GenTreeVal(genTreeOps oper, var_types type, ssize_t val) : GenTree(oper, type), gtVal1(val) - { - } + GenTreeVal(genTreeOps oper, var_types type, ssize_t val) : GenTree(oper, type), gtVal1(val) {} #if DEBUGGABLE_GENTREE - GenTreeVal() : GenTree() - { - } + GenTreeVal() : GenTree() {} #endif }; struct GenTreeIntConCommon : public GenTree { - inline INT64 LngValue() const; - inline void SetLngValue(INT64 val); + inline INT64 LngValue() const; + inline void SetLngValue(INT64 val); inline ssize_t IconValue() const; - inline void SetIconValue(ssize_t val); - inline INT64 IntegralValue() const; - inline void SetIntegralValue(int64_t value); + inline void SetIconValue(ssize_t val); + inline INT64 IntegralValue() const; + inline void SetIntegralValue(int64_t value); template inline void SetValueTruncating(T value); @@ -3097,9 +3063,7 @@ struct GenTreeIntConCommon : public GenTree #endif #if DEBUGGABLE_GENTREE - GenTreeIntConCommon() : GenTree() - { - } + GenTreeIntConCommon() : GenTree() {} #endif }; @@ -3110,13 +3074,9 @@ struct GenTreePhysReg : public GenTree // GetRegNum() indicates the destination (and can be changed) // whereas reg indicates the source regNumber gtSrcReg; - GenTreePhysReg(regNumber r, var_types type = TYP_I_IMPL) : GenTree(GT_PHYSREG, type), gtSrcReg(r) - { - } + GenTreePhysReg(regNumber r, var_types type = TYP_I_IMPL) : GenTree(GT_PHYSREG, type), gtSrcReg(r) {} #if DEBUGGABLE_GENTREE - GenTreePhysReg() : GenTree() - { - } + GenTreePhysReg() : GenTree() {} #endif }; @@ -3173,9 +3133,7 @@ struct GenTreeIntCon : public GenTreeIntConCommon void FixupInitBlkValue(var_types type); #if DEBUGGABLE_GENTREE - GenTreeIntCon() : GenTreeIntConCommon() - { - } + GenTreeIntCon() : GenTreeIntConCommon() {} #endif }; @@ -3199,9 +3157,7 @@ struct GenTreeLngCon : public GenTreeIntConCommon SetLngValue(val); } #if DEBUGGABLE_GENTREE - GenTreeLngCon() : GenTreeIntConCommon() - { - } + GenTreeLngCon() : GenTreeIntConCommon() {} #endif }; @@ -3336,9 +3292,7 @@ struct GenTreeDblCon : public GenTree SetDconValue(val); } #if DEBUGGABLE_GENTREE - GenTreeDblCon() : GenTree() - { - } + GenTreeDblCon() : GenTree() {} #endif }; @@ -3364,9 +3318,7 @@ struct GenTreeStrCon : public GenTree { } #if DEBUGGABLE_GENTREE - GenTreeStrCon() : GenTree() - { - } + GenTreeStrCon() : GenTree() {} #endif }; @@ -3407,14 +3359,10 @@ class SsaNumInfo final int m_value; - SsaNumInfo(int value) : m_value(value) - { - } + SsaNumInfo(int value) : m_value(value) {} public: - SsaNumInfo() : m_value(SsaConfig::RESERVED_SSA_NUM) - { - } + SsaNumInfo() : m_value(SsaConfig::RESERVED_SSA_NUM) {} bool IsSimple() const { @@ -3545,9 +3493,7 @@ struct GenTreeLclVarCommon : public GenTreeUnOp } #if DEBUGGABLE_GENTREE - GenTreeLclVarCommon() : GenTreeUnOp() - { - } + GenTreeLclVarCommon() : GenTreeUnOp() {} #endif }; @@ -3684,7 +3630,7 @@ struct GenTreeLclVar : public GenTreeLclVarCommon } unsigned int GetFieldCount(Compiler* compiler) const; - var_types GetFieldTypeByIndex(Compiler* compiler, unsigned idx); + var_types GetFieldTypeByIndex(Compiler* compiler, unsigned idx); bool IsNeverNegative(Compiler* comp) const; @@ -3723,8 +3669,8 @@ struct GenTreeLclVar : public GenTreeLclVarCommon } #endif - GenTreeLclVar(genTreeOps oper, - var_types type, + GenTreeLclVar(genTreeOps oper, + var_types type, unsigned lclNum DEBUGARG(IL_OFFSET ilOffs = BAD_IL_OFFSET) DEBUGARG(bool largeNode = false)) : GenTreeLclVarCommon(oper, type, lclNum DEBUGARG(largeNode)) DEBUGARG(gtLclILoffs(ilOffs)) { @@ -3737,9 +3683,7 @@ struct GenTreeLclVar : public GenTreeLclVarCommon } #if DEBUGGABLE_GENTREE - GenTreeLclVar() : GenTreeLclVarCommon() - { - } + GenTreeLclVar() : GenTreeLclVarCommon() {} #endif }; @@ -3795,9 +3739,7 @@ struct GenTreeLclFld : public GenTreeLclVarCommon #endif // TARGET_ARM #if DEBUGGABLE_GENTREE - GenTreeLclFld() : GenTreeLclVarCommon() - { - } + GenTreeLclFld() : GenTreeLclVarCommon() {} #endif }; @@ -3847,9 +3789,7 @@ struct GenTreeCast : public GenTreeOp gtFlags |= fromUnsigned ? GTF_UNSIGNED : GTF_EMPTY; } #if DEBUGGABLE_GENTREE - GenTreeCast() : GenTreeOp() - { - } + GenTreeCast() : GenTreeOp() {} #endif bool IsZeroExtending() @@ -3896,9 +3836,7 @@ struct GenTreeBox : public GenTreeUnOp { } #if DEBUGGABLE_GENTREE - GenTreeBox() : GenTreeUnOp() - { - } + GenTreeBox() : GenTreeUnOp() {} #endif bool WasCloned() @@ -3940,9 +3878,7 @@ struct GenTreeFieldAddr : public GenTreeUnOp } #if DEBUGGABLE_GENTREE - GenTreeFieldAddr() : GenTreeUnOp() - { - } + GenTreeFieldAddr() : GenTreeUnOp() {} #endif // The object this field belongs to. Will be "nullptr" for static fields. @@ -4010,14 +3946,10 @@ struct GenTreeColon : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeColon() : GenTreeOp() - { - } + GenTreeColon() : GenTreeOp() {} #endif - GenTreeColon(var_types typ, GenTree* thenNode, GenTree* elseNode) : GenTreeOp(GT_COLON, typ, elseNode, thenNode) - { - } + GenTreeColon(var_types typ, GenTree* thenNode, GenTree* elseNode) : GenTreeOp(GT_COLON, typ, elseNode, thenNode) {} }; // GenTreeConditional -- Conditionally do an operation @@ -4034,9 +3966,7 @@ struct GenTreeConditional : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeConditional() : GenTreeOp() - { - } + GenTreeConditional() : GenTreeOp() {} #endif }; @@ -4501,7 +4431,7 @@ struct CallArgABIInformation bool IsHfaArg() const; bool IsHfaRegArg() const; var_types GetHfaType() const; - void SetHfaType(var_types type, unsigned hfaSlots); + void SetHfaType(var_types type, unsigned hfaSlots); regNumber GetRegNum() const { @@ -4624,9 +4554,7 @@ struct NewCallArg #ifdef DEBUG void ValidateTypes(); #else - void ValidateTypes() - { - } + void ValidateTypes() {} #endif }; @@ -4684,7 +4612,7 @@ class CallArg m_signatureClsHnd = arg.SignatureClsHnd; } - CallArg(const CallArg&) = delete; + CallArg(const CallArg&) = delete; CallArg& operator=(CallArg&) = delete; // clang-format off @@ -4762,15 +4690,15 @@ class CallArgs bool m_alignmentDone : 1; #endif - void AddedWellKnownArg(WellKnownArg arg); - void RemovedWellKnownArg(WellKnownArg arg); + void AddedWellKnownArg(WellKnownArg arg); + void RemovedWellKnownArg(WellKnownArg arg); regNumber GetCustomRegister(Compiler* comp, CorInfoCallConvExtension cc, WellKnownArg arg); - void SplitArg(CallArg* arg, unsigned numRegs, unsigned numSlots); - void SortArgs(Compiler* comp, GenTreeCall* call, CallArg** sortedArgs); + void SplitArg(CallArg* arg, unsigned numRegs, unsigned numSlots); + void SortArgs(Compiler* comp, GenTreeCall* call, CallArg** sortedArgs); public: CallArgs(); - CallArgs(const CallArgs&) = delete; + CallArgs(const CallArgs&) = delete; CallArgs& operator=(CallArgs&) = delete; CallArg* FindByNode(GenTree* node); @@ -4795,8 +4723,8 @@ class CallArgs CallArg* InsertAfterUnchecked(Compiler* comp, CallArg* after, const NewCallArg& arg); CallArg* InsertInstParam(Compiler* comp, GenTree* node); CallArg* InsertAfterThisOrFirst(Compiler* comp, const NewCallArg& arg); - void PushLateBack(CallArg* arg); - void Remove(CallArg* arg); + void PushLateBack(CallArg* arg); + void Remove(CallArg* arg); template void InternalCopyFrom(Compiler* comp, CallArgs* other, CopyNodeFunc copyFunc); @@ -4817,7 +4745,7 @@ class CallArgs bool IsNonStandard(Compiler* comp, GenTreeCall* call, CallArg* arg); GenTree* MakeTmpArgNode(Compiler* comp, CallArg* arg); - void SetTemp(CallArg* arg, unsigned tmpNum); + void SetTemp(CallArg* arg, unsigned tmpNum); // clang-format off bool HasThisPointer() const { return m_hasThisPointer; } @@ -4855,9 +4783,7 @@ class CallArgs CallArg* m_arg; public: - explicit CallArgIterator(CallArg* arg) : m_arg(arg) - { - } + explicit CallArgIterator(CallArg* arg) : m_arg(arg) {} // clang-format off CallArg& operator*() const { return *m_arg; } @@ -4899,9 +4825,7 @@ class CallArgs } public: - explicit EarlyArgIterator(CallArg* arg) : m_arg(arg) - { - } + explicit EarlyArgIterator(CallArg* arg) : m_arg(arg) {} // clang-format off CallArg& operator*() const { return *m_arg; } @@ -4955,7 +4879,8 @@ struct GenTreeCall final : public GenTree CORINFO_SIG_INFO* callSig; #endif - union { + union + { TailCallSiteInfo* tailCallInfo; // Only used for unmanaged calls, which cannot be tail-called CorInfoCallConvExtension unmgdCallConv; @@ -5216,7 +5141,7 @@ struct GenTreeCall final : public GenTree } bool HasNonStandardAddedArgs(Compiler* compiler) const; - int GetNonStandardAddedArgCount(Compiler* compiler) const; + int GetNonStandardAddedArgCount(Compiler* compiler) const; // Returns true if the ABI dictates that this call should get a ret buf // arg. This may be out of sync with gtArgs.HasRetBuffer during import @@ -5589,13 +5514,15 @@ struct GenTreeCall final : public GenTree uint8_t gtInlineInfoCount; // number of inline candidates for the given call CORINFO_CLASS_HANDLE gtRetClsHnd; // The return type handle of the call if it is a struct; always available - union { + union + { void* gtStubCallStubAddr; // GTF_CALL_VIRT_STUB - these are never inlined CORINFO_CLASS_HANDLE gtInitClsHnd; // Used by static init helpers, represents a class they init IL_OFFSET gtCastHelperILOffset; // Used by cast helpers to save corresponding IL offset }; - union { + union + { // only used for CALLI unmanaged calls (CT_INDIRECT) GenTree* gtCallCookie; @@ -5613,7 +5540,8 @@ struct GenTreeCall final : public GenTree // expression evaluated after args are placed which determines the control target GenTree* gtControlExpr; - union { + union + { CORINFO_METHOD_HANDLE gtCallMethHnd; // CT_USER_FUNC or CT_HELPER GenTree* gtCallAddr; // CT_INDIRECT }; @@ -5666,13 +5594,9 @@ struct GenTreeCall final : public GenTree static bool Equals(GenTreeCall* c1, GenTreeCall* c2); - GenTreeCall(var_types type) : GenTree(GT_CALL, type) - { - } + GenTreeCall(var_types type) : GenTree(GT_CALL, type) {} #if DEBUGGABLE_GENTREE - GenTreeCall() : GenTree() - { - } + GenTreeCall() : GenTree() {} #endif }; @@ -5772,9 +5696,7 @@ struct GenTreeMultiRegOp : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeMultiRegOp() : GenTreeOp() - { - } + GenTreeMultiRegOp() : GenTreeOp() {} #endif }; #endif // !defined(TARGET_64BIT) @@ -5798,9 +5720,7 @@ struct GenTreeFptrVal : public GenTree #endif } #if DEBUGGABLE_GENTREE - GenTreeFptrVal() : GenTree() - { - } + GenTreeFptrVal() : GenTree() {} #endif }; @@ -5846,9 +5766,7 @@ struct GenTreeQmark : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeQmark() : GenTreeOp() - { - } + GenTreeQmark() : GenTreeOp() {} #endif }; @@ -5878,9 +5796,7 @@ struct GenTreeIntrinsic : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeIntrinsic() : GenTreeOp() - { - } + GenTreeIntrinsic() : GenTreeOp() {} #endif }; @@ -5898,9 +5814,7 @@ struct GenTreeMultiOp : public GenTree protected: GenTree** m_use; - Iterator(GenTree** use) : m_use(use) - { - } + Iterator(GenTree** use) : m_use(use) {} public: Iterator& operator++() @@ -5923,9 +5837,7 @@ struct GenTreeMultiOp : public GenTree class OperandsIterator final : public Iterator { public: - OperandsIterator(GenTree** use) : Iterator(use) - { - } + OperandsIterator(GenTree** use) : Iterator(use) {} GenTree* operator*() { @@ -5936,9 +5848,7 @@ struct GenTreeMultiOp : public GenTree class UseEdgesIterator final : public Iterator { public: - UseEdgesIterator(GenTree** use) : Iterator(use) - { - } + UseEdgesIterator(GenTree** use) : Iterator(use) {} GenTree** operator*() { @@ -5983,9 +5893,7 @@ struct GenTreeMultiOp : public GenTree public: #if DEBUGGABLE_GENTREE - GenTreeMultiOp() : GenTree() - { - } + GenTreeMultiOp() : GenTree() {} #endif GenTree*& Op(size_t index) @@ -6280,9 +6188,7 @@ struct GenTreeJitIntrinsic : public GenTreeMultiOp } #if DEBUGGABLE_GENTREE - GenTreeJitIntrinsic() : GenTreeMultiOp() - { - } + GenTreeJitIntrinsic() : GenTreeMultiOp() {} #endif protected: @@ -6341,9 +6247,7 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic } #if DEBUGGABLE_GENTREE - GenTreeHWIntrinsic() : GenTreeJitIntrinsic() - { - } + GenTreeHWIntrinsic() : GenTreeJitIntrinsic() {} #endif bool OperIsMemoryLoad(GenTree** pAddr = nullptr) const; @@ -6383,7 +6287,7 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic bool OperRequiresGlobRefFlag() const; unsigned GetResultOpNumForRmwIntrinsic(GenTree* use, GenTree* op1, GenTree* op2, GenTree* op3); - uint8_t GetTernaryControlByte(GenTreeHWIntrinsic* second) const; + uint8_t GetTernaryControlByte(GenTreeHWIntrinsic* second) const; ClassLayout* GetLayout(Compiler* compiler) const; @@ -6486,7 +6390,8 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic // struct GenTreeVecCon : public GenTree { - union { + union + { simd8_t gtSimd8Val; simd12_t gtSimd12Val; simd16_t gtSimd16Val; @@ -6538,7 +6443,7 @@ struct GenTreeVecCon : public GenTree // These intrinsics are meant to set the same value to every element. if ((argCnt == 1) && HandleArgForHWIntrinsicCreate(node->Op(1), 0, simdVal, simdBaseType)) { -// CreateScalar leaves the upper bits as zero + // CreateScalar leaves the upper bits as zero #if defined(TARGET_XARCH) if ((intrinsic != NI_Vector128_CreateScalar) && (intrinsic != NI_Vector256_CreateScalar) && @@ -6874,9 +6779,7 @@ struct GenTreeVecCon : public GenTree } #if DEBUGGABLE_GENTREE - GenTreeVecCon() : GenTree() - { - } + GenTreeVecCon() : GenTree() {} #endif }; @@ -6931,9 +6834,7 @@ struct GenTreeIndexAddr : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeIndexAddr() : GenTreeOp() - { - } + GenTreeIndexAddr() : GenTreeOp() {} #endif bool IsBoundsChecked() const @@ -6971,9 +6872,7 @@ struct GenTreeArrAddr : GenTreeUnOp } #if DEBUGGABLE_GENTREE - GenTreeArrAddr() : GenTreeUnOp() - { - } + GenTreeArrAddr() : GenTreeUnOp() {} #endif GenTree*& Addr() @@ -7018,14 +6917,10 @@ struct GenTreeArrCommon : public GenTreeUnOp return gtOp1; } - GenTreeArrCommon(genTreeOps oper, var_types type, GenTree* arrRef) : GenTreeUnOp(oper, type, arrRef) - { - } + GenTreeArrCommon(genTreeOps oper, var_types type, GenTree* arrRef) : GenTreeUnOp(oper, type, arrRef) {} #if DEBUGGABLE_GENTREE - GenTreeArrCommon() : GenTreeUnOp() - { - } + GenTreeArrCommon() : GenTreeUnOp() {} #endif }; @@ -7053,9 +6948,7 @@ struct GenTreeArrLen : public GenTreeArrCommon } #if DEBUGGABLE_GENTREE - GenTreeArrLen() : GenTreeArrCommon() - { - } + GenTreeArrLen() : GenTreeArrCommon() {} #endif }; @@ -7086,9 +6979,7 @@ struct GenTreeMDArr : public GenTreeArrCommon } #if DEBUGGABLE_GENTREE - GenTreeMDArr() : GenTreeArrCommon() - { - } + GenTreeMDArr() : GenTreeArrCommon() {} #endif }; @@ -7118,9 +7009,7 @@ struct GenTreeBoundsChk : public GenTreeOp gtFlags |= GTF_EXCEPT; } #if DEBUGGABLE_GENTREE - GenTreeBoundsChk() : GenTreeOp() - { - } + GenTreeBoundsChk() : GenTreeOp() {} #endif // If this check is against GT_ARR_LENGTH or GT_MDARR_LENGTH, returns array reference, else nullptr. @@ -7180,9 +7069,7 @@ struct GenTreeArrElem : public GenTree gtFlags |= GTF_EXCEPT; } #if DEBUGGABLE_GENTREE - GenTreeArrElem() : GenTree() - { - } + GenTreeArrElem() : GenTree() {} #endif }; @@ -7274,9 +7161,7 @@ struct GenTreeAddrMode : public GenTreeOp protected: friend GenTree; // Used only for GenTree::GetVtableForOper() - GenTreeAddrMode() : GenTreeOp() - { - } + GenTreeAddrMode() : GenTreeOp() {} #endif }; @@ -7310,9 +7195,7 @@ struct GenTreeIndir : public GenTreeOp unsigned Size() const; - GenTreeIndir(genTreeOps oper, var_types type, GenTree* addr, GenTree* data) : GenTreeOp(oper, type, addr, data) - { - } + GenTreeIndir(genTreeOps oper, var_types type, GenTree* addr, GenTree* data) : GenTreeOp(oper, type, addr, data) {} // True if this indirection is a volatile memory operation. bool IsVolatile() const @@ -7336,14 +7219,10 @@ struct GenTreeIndir : public GenTreeOp #if DEBUGGABLE_GENTREE // Used only for GenTree::GetVtableForOper() - GenTreeIndir() : GenTreeOp() - { - } + GenTreeIndir() : GenTreeOp() {} #else // Used by XARCH codegen to construct temporary trees to pass to the emitter. - GenTreeIndir() : GenTreeOp(GT_NOP, TYP_UNDEF) - { - } + GenTreeIndir() : GenTreeOp(GT_NOP, TYP_UNDEF) {} #endif }; @@ -7449,9 +7328,7 @@ struct GenTreeBlk : public GenTreeIndir #if DEBUGGABLE_GENTREE protected: friend GenTree; - GenTreeBlk() : GenTreeIndir() - { - } + GenTreeBlk() : GenTreeIndir() {} #endif // DEBUGGABLE_GENTREE }; @@ -7584,9 +7461,7 @@ struct GenTreeCmpXchg : public GenTreeIndir } #if DEBUGGABLE_GENTREE - GenTreeCmpXchg() : GenTreeIndir() - { - } + GenTreeCmpXchg() : GenTreeIndir() {} #endif GenTree*& Comparand() @@ -7612,13 +7487,9 @@ struct GenTreeRetExpr : public GenTree // nullptr for cases where gtSubstExpr is not a tree from the inlinee. BasicBlock* gtSubstBB; - GenTreeRetExpr(var_types type) : GenTree(GT_RET_EXPR, type) - { - } + GenTreeRetExpr(var_types type) : GenTree(GT_RET_EXPR, type) {} #if DEBUGGABLE_GENTREE - GenTreeRetExpr() : GenTree() - { - } + GenTreeRetExpr() : GenTree() {} #endif }; @@ -7640,9 +7511,7 @@ struct GenTreeILOffset : public GenTree } #if DEBUGGABLE_GENTREE - GenTreeILOffset() : GenTree(GT_IL_OFFSET, TYP_VOID) - { - } + GenTreeILOffset() : GenTree(GT_IL_OFFSET, TYP_VOID) {} #endif }; @@ -7662,9 +7531,7 @@ class GenTreeList GenTree* m_tree; public: - explicit iterator(GenTree* tree) : m_tree(tree) - { - } + explicit iterator(GenTree* tree) : m_tree(tree) {} GenTree* operator*() const { @@ -7683,9 +7550,7 @@ class GenTreeList } }; - explicit GenTreeList(GenTree* trees) : m_trees(trees) - { - } + explicit GenTreeList(GenTree* trees) : m_trees(trees) {} iterator begin() const { @@ -7708,9 +7573,7 @@ class LocalsGenTreeList GenTreeLclVarCommon* m_tree; public: - explicit iterator(GenTreeLclVarCommon* tree) : m_tree(tree) - { - } + explicit iterator(GenTreeLclVarCommon* tree) : m_tree(tree) {} GenTreeLclVarCommon* operator*() const { @@ -7737,9 +7600,7 @@ class LocalsGenTreeList } }; - explicit LocalsGenTreeList(Statement* stmt) : m_stmt(stmt) - { - } + explicit LocalsGenTreeList(Statement* stmt) : m_stmt(stmt) {} iterator begin() const; @@ -7937,9 +7798,7 @@ class StatementList Statement* m_stmt; public: - iterator(Statement* stmt) : m_stmt(stmt) - { - } + iterator(Statement* stmt) : m_stmt(stmt) {} Statement* operator*() const { @@ -7959,9 +7818,7 @@ class StatementList }; public: - StatementList(Statement* stmts) : m_stmts(stmts) - { - } + StatementList(Statement* stmts) : m_stmts(stmts) {} iterator begin() const { @@ -7990,9 +7847,7 @@ struct GenTreePhiArg : public GenTreeLclVarCommon } #if DEBUGGABLE_GENTREE - GenTreePhiArg() : GenTreeLclVarCommon() - { - } + GenTreePhiArg() : GenTreeLclVarCommon() {} #endif }; @@ -8161,9 +8016,7 @@ struct GenTreePutArgStk : public GenTreeUnOp #endif // !FEATURE_PUT_STRUCT_ARG_STK #if DEBUGGABLE_GENTREE - GenTreePutArgStk() : GenTreeUnOp() - { - } + GenTreePutArgStk() : GenTreeUnOp() {} #endif }; @@ -8311,9 +8164,7 @@ struct GenTreePutArgSplit : public GenTreePutArgStk } #if DEBUGGABLE_GENTREE - GenTreePutArgSplit() : GenTreePutArgStk() - { - } + GenTreePutArgSplit() : GenTreePutArgStk() {} #endif }; #endif // FEATURE_ARG_SPLIT @@ -8446,9 +8297,7 @@ struct GenTreeCopyOrReload : public GenTreeUnOp } #if DEBUGGABLE_GENTREE - GenTreeCopyOrReload() : GenTreeUnOp() - { - } + GenTreeCopyOrReload() : GenTreeUnOp() {} #endif }; @@ -8476,9 +8325,7 @@ struct GenTreeAllocObj final : public GenTreeUnOp #endif } #if DEBUGGABLE_GENTREE - GenTreeAllocObj() : GenTreeUnOp() - { - } + GenTreeAllocObj() : GenTreeUnOp() {} #endif }; @@ -8495,9 +8342,7 @@ struct GenTreeRuntimeLookup final : public GenTreeUnOp assert(hnd != nullptr); } #if DEBUGGABLE_GENTREE - GenTreeRuntimeLookup() : GenTreeUnOp() - { - } + GenTreeRuntimeLookup() : GenTreeUnOp() {} #endif // Return reference to the actual tree that does the lookup @@ -8659,13 +8504,9 @@ struct GenCondition return names[m_code]; } - GenCondition() : m_code() - { - } + GenCondition() : m_code() {} - GenCondition(Code cond) : m_code(cond) - { - } + GenCondition(Code cond) : m_code(cond) {} static_assert((GT_NE - GT_EQ) == (NE & ~Unsigned), "bad relop"); static_assert((GT_LT - GT_EQ) == SLT, "bad relop"); @@ -8793,9 +8634,7 @@ struct GenTreeCC final : public GenTree } #if DEBUGGABLE_GENTREE - GenTreeCC() : GenTree() - { - } + GenTreeCC() : GenTree() {} #endif // DEBUGGABLE_GENTREE }; @@ -8815,9 +8654,7 @@ struct GenTreeOpCC : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeOpCC() : GenTreeOp() - { - } + GenTreeOpCC() : GenTreeOp() {} #endif // DEBUGGABLE_GENTREE }; @@ -8855,9 +8692,7 @@ struct GenTreeCCMP final : public GenTreeOpCC } #if DEBUGGABLE_GENTREE - GenTreeCCMP() : GenTreeOpCC() - { - } + GenTreeCCMP() : GenTreeOpCC() {} #endif // DEBUGGABLE_GENTREE }; #endif diff --git a/src/coreclr/jit/gschecks.cpp b/src/coreclr/jit/gschecks.cpp index 12c610ceaefa45..0fff29596c2866 100644 --- a/src/coreclr/jit/gschecks.cpp +++ b/src/coreclr/jit/gschecks.cpp @@ -455,9 +455,7 @@ void Compiler::gsParamsToShadows() DoPostOrder = true }; - ReplaceShadowParamsVisitor(Compiler* compiler) : GenTreeVisitor(compiler) - { - } + ReplaceShadowParamsVisitor(Compiler* compiler) : GenTreeVisitor(compiler) {} Compiler::fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { diff --git a/src/coreclr/jit/hashbv.cpp b/src/coreclr/jit/hashbv.cpp index 854215235261db..da9bc5c5eb0d6a 100644 --- a/src/coreclr/jit/hashbv.cpp +++ b/src/coreclr/jit/hashbv.cpp @@ -449,9 +449,7 @@ hashBv* hashBv::CreateFrom(hashBv* other, Compiler* comp) return result; } -void hashBv::MergeLists(hashBvNode** root1, hashBvNode** root2) -{ -} +void hashBv::MergeLists(hashBvNode** root1, hashBvNode** root2) {} bool hashBv::TooSmall() { @@ -617,15 +615,17 @@ void hashBv::dump() // DBEXEC(TRUE, printf("[%d(%d)(nodes:%d)]{ ", hashtable_size(), countBits(), this->numNodes)); printf("{"); - ForEachHbvBitSet(*this, [&](indexType index) { - if (!first) - { - printf(" "); - } - printf("%d", index); - first = false; - return HbvWalk::Continue; - }); + ForEachHbvBitSet(*this, + [&](indexType index) + { + if (!first) + { + printf(" "); + } + printf("%d", index); + first = false; + return HbvWalk::Continue; + }); printf("}\n"); } @@ -636,23 +636,25 @@ void hashBv::dumpFancy() printf("{"); printf("count:%d", this->countBits()); - ForEachHbvBitSet(*this, [&](indexType index) { - if (last_1 != index - 1) - { - if (last_0 + 1 != last_1) - { - printf(" %d-%d", last_0 + 1, last_1); - } - else - { - printf(" %d", last_1); - } - last_0 = index - 1; - } - last_1 = index; - - return HbvWalk::Continue; - }); + ForEachHbvBitSet(*this, + [&](indexType index) + { + if (last_1 != index - 1) + { + if (last_0 + 1 != last_1) + { + printf(" %d-%d", last_0 + 1, last_1); + } + else + { + printf(" %d", last_1); + } + last_0 = index - 1; + } + last_1 = index; + + return HbvWalk::Continue; + }); // Print the last one if (last_0 + 1 != last_1) @@ -934,12 +936,8 @@ bool hashBv::anySet() class AndAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) - { - } - static inline void PostAction(hashBv* lhs, hashBv* rhs) - { - } + static inline void PreAction(hashBv* lhs, hashBv* rhs) {} + static inline void PostAction(hashBv* lhs, hashBv* rhs) {} static inline bool DefaultResult() { return false; @@ -996,12 +994,8 @@ class AndAction class SubtractAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) - { - } - static inline void PostAction(hashBv* lhs, hashBv* rhs) - { - } + static inline void PreAction(hashBv* lhs, hashBv* rhs) {} + static inline void PostAction(hashBv* lhs, hashBv* rhs) {} static inline bool DefaultResult() { return false; @@ -1052,12 +1046,8 @@ class SubtractAction class XorAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) - { - } - static inline void PostAction(hashBv* lhs, hashBv* rhs) - { - } + static inline void PreAction(hashBv* lhs, hashBv* rhs) {} + static inline void PostAction(hashBv* lhs, hashBv* rhs) {} static inline bool DefaultResult() { return false; @@ -1125,9 +1115,7 @@ class OrAction rhs->Resize(rhs->numNodes); } } - static inline void PostAction(hashBv* lhs, hashBv* rhs) - { - } + static inline void PostAction(hashBv* lhs, hashBv* rhs) {} static inline bool DefaultResult() { return false; @@ -1182,12 +1170,8 @@ class OrAction class CompareAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) - { - } - static inline void PostAction(hashBv* lhs, hashBv* rhs) - { - } + static inline void PreAction(hashBv* lhs, hashBv* rhs) {} + static inline void PostAction(hashBv* lhs, hashBv* rhs) {} static inline bool DefaultResult() { return true; @@ -1225,12 +1209,8 @@ class CompareAction class IntersectsAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) - { - } - static inline void PostAction(hashBv* lhs, hashBv* rhs) - { - } + static inline void PreAction(hashBv* lhs, hashBv* rhs) {} + static inline void PostAction(hashBv* lhs, hashBv* rhs) {} static inline bool DefaultResult() { return false; @@ -1948,7 +1928,7 @@ indexType hashBvIterator::nextBit() current_element++; // printf("current element is %d\n", current_element); // reached the end of this node - if (current_element == (indexType) this->currNode->numElements()) + if (current_element == (indexType)this->currNode->numElements()) { // printf("going to next node\n"); this->nextNode(); @@ -1956,7 +1936,7 @@ indexType hashBvIterator::nextBit() } else { - assert(current_element < (indexType) this->currNode->numElements()); + assert(current_element < (indexType)this->currNode->numElements()); // printf("getting more data\n"); current_data = this->currNode->elements[current_element]; current_base = this->currNode->baseIndex + current_element * BITS_PER_ELEMENT; diff --git a/src/coreclr/jit/hashbv.h b/src/coreclr/jit/hashbv.h index 7ad95998add8e4..2cebf3c1f7bfca 100644 --- a/src/coreclr/jit/hashbv.h +++ b/src/coreclr/jit/hashbv.h @@ -13,7 +13,7 @@ #include #include -//#define TESTING 1 +// #define TESTING 1 #define LOG2_BITS_PER_ELEMENT 5 #define LOG2_ELEMENTS_PER_NODE 2 @@ -124,12 +124,10 @@ class hashBvNode public: hashBvNode(indexType base); - hashBvNode() - { - } + hashBvNode() {} static hashBvNode* Create(indexType base, Compiler* comp); - void Reconstruct(indexType base); - int numElements() + void Reconstruct(indexType base); + int numElements() { return ELEMENTS_PER_NODE; } @@ -172,7 +170,8 @@ class hashBv hashBvNode** nodeArr; hashBvNode* initialVector[1]; - union { + union + { Compiler* compiler; // for freelist hashBv* next; @@ -186,9 +185,9 @@ class hashBv public: hashBv(Compiler* comp); static hashBv* Create(Compiler* comp); - static void Init(Compiler* comp); + static void Init(Compiler* comp); static hashBv* CreateFrom(hashBv* other, Compiler* comp); - void hbvFree(); + void hbvFree(); #ifdef DEBUG void dump(); void dumpFancy(); @@ -201,18 +200,18 @@ class hashBv hashBvGlobalData* globalData(); static hashBvNode*& nodeFreeList(hashBvGlobalData* globalData); - static hashBv*& hbvFreeList(hashBvGlobalData* data); + static hashBv*& hbvFreeList(hashBvGlobalData* data); hashBvNode** getInsertionPointForIndex(indexType index); private: hashBvNode* getNodeForIndexHelper(indexType index, bool canAdd); - int getHashForIndex(indexType index, int table_size); - int getRehashForIndex(indexType thisIndex, int thisTableSize, int newTableSize); + int getHashForIndex(indexType index, int table_size); + int getRehashForIndex(indexType thisIndex, int thisTableSize, int newTableSize); // maintain free lists for vectors hashBvNode** getNewVector(int vectorLength); - int getNodeCount(); + int getNodeCount(); public: inline hashBvNode* getOrAddNodeForIndex(indexType index) @@ -221,7 +220,7 @@ class hashBv return temp; } hashBvNode* getNodeForIndex(indexType index); - void removeNodeAtBase(indexType index); + void removeNodeAtBase(indexType index); public: void setBit(indexType index); diff --git a/src/coreclr/jit/helperexpansion.cpp b/src/coreclr/jit/helperexpansion.cpp index 3bf37b93798e93..6c8251eee257f5 100644 --- a/src/coreclr/jit/helperexpansion.cpp +++ b/src/coreclr/jit/helperexpansion.cpp @@ -1945,13 +1945,13 @@ static int PickCandidatesForTypeCheck(Compiler* comp, isCastClass = false; break; - // These are never expanded: - // CORINFO_HELP_ISINSTANCEOF_EXCEPTION - // CORINFO_HELP_CHKCASTCLASS_SPECIAL - // CORINFO_HELP_READYTORUN_ISINSTANCEOF, - // CORINFO_HELP_READYTORUN_CHKCAST, + // These are never expanded: + // CORINFO_HELP_ISINSTANCEOF_EXCEPTION + // CORINFO_HELP_CHKCASTCLASS_SPECIAL + // CORINFO_HELP_READYTORUN_ISINSTANCEOF, + // CORINFO_HELP_READYTORUN_CHKCAST, - // Other helper calls are not cast helpers + // Other helper calls are not cast helpers default: return 0; diff --git a/src/coreclr/jit/host.h b/src/coreclr/jit/host.h index 6667fbb3994a76..d10eb93ca9a122 100644 --- a/src/coreclr/jit/host.h +++ b/src/coreclr/jit/host.h @@ -28,10 +28,10 @@ class LogEnv }; bool vlogf(unsigned level, const char* fmt, va_list args); -int vflogf(FILE* file, const char* fmt, va_list args); +int vflogf(FILE* file, const char* fmt, va_list args); -int logf(const char* fmt, ...); -int flogf(FILE* file, const char* fmt, ...); +int logf(const char* fmt, ...); +int flogf(FILE* file, const char* fmt, ...); void gcDump_logf(const char* fmt, ...); void logf(unsigned level, const char* fmt, ...); diff --git a/src/coreclr/jit/hostallocator.h b/src/coreclr/jit/hostallocator.h index a91f7f1fb4ab9b..fc6d0c80660dcc 100644 --- a/src/coreclr/jit/hostallocator.h +++ b/src/coreclr/jit/hostallocator.h @@ -6,9 +6,7 @@ class HostAllocator final { private: - HostAllocator() - { - } + HostAllocator() {} public: template @@ -37,7 +35,7 @@ class HostAllocator final private: void* allocateHostMemory(size_t size); - void freeHostMemory(void* p); + void freeHostMemory(void* p); }; // Global operator new overloads that work with HostAllocator diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index e8b60b07909d95..53970ef4a7460b 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -832,7 +832,7 @@ GenTree* Compiler::addRangeCheckIfNeeded( #ifdef TARGET_XARCH && !HWIntrinsicInfo::isAVX2GatherIntrinsic(intrinsic) && !HWIntrinsicInfo::HasFullRangeImm(intrinsic) #endif - ) + ) { assert(!immOp->IsCnsIntOrI()); assert(varTypeIsUnsigned(immOp)); diff --git a/src/coreclr/jit/hwintrinsic.h b/src/coreclr/jit/hwintrinsic.h index cac041eb83ea6d..0f7fce0ed1dd38 100644 --- a/src/coreclr/jit/hwintrinsic.h +++ b/src/coreclr/jit/hwintrinsic.h @@ -491,11 +491,11 @@ struct HWIntrinsicInfo static const HWIntrinsicInfo& lookup(NamedIntrinsic id); - static NamedIntrinsic lookupId(Compiler* comp, - CORINFO_SIG_INFO* sig, - const char* className, - const char* methodName, - const char* enclosingClassName); + static NamedIntrinsic lookupId(Compiler* comp, + CORINFO_SIG_INFO* sig, + const char* className, + const char* methodName, + const char* enclosingClassName); static CORINFO_InstructionSet lookupIsa(const char* className, const char* enclosingClassName); static unsigned lookupSimdSize(Compiler* comp, NamedIntrinsic id, CORINFO_SIG_INFO* sig); @@ -514,7 +514,7 @@ struct HWIntrinsicInfo static bool isScalarIsa(CORINFO_InstructionSet isa); #ifdef TARGET_XARCH - static bool isAVX2GatherIntrinsic(NamedIntrinsic id); + static bool isAVX2GatherIntrinsic(NamedIntrinsic id); static FloatComparisonMode lookupFloatComparisonModeForSwappedArgs(FloatComparisonMode comparison); #endif diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 93559c76458ee9..36d139c7d836fb 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -346,7 +346,8 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) { assert(hasImmediateOperand); - auto emitShift = [&](GenTree* op, regNumber reg) { + auto emitShift = [&](GenTree* op, regNumber reg) + { HWIntrinsicImmOpHelper helper(this, op, node); for (helper.EmitBegin(); !helper.Done(); helper.EmitCaseEnd()) @@ -448,8 +449,8 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) } else { - GetEmitter()->emitIns_R_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, op3Reg, - opt, INS_SCALABLE_OPTS_UNPREDICATED); + GetEmitter()->emitIns_R_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, op3Reg, opt, + INS_SCALABLE_OPTS_UNPREDICATED); } break; diff --git a/src/coreclr/jit/hwintrinsiccodegenxarch.cpp b/src/coreclr/jit/hwintrinsiccodegenxarch.cpp index 5e44772e7115ac..d915abcee148e2 100644 --- a/src/coreclr/jit/hwintrinsiccodegenxarch.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenxarch.cpp @@ -317,9 +317,10 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) { case 1: { - regNumber targetReg = node->GetRegNum(); - GenTree* rmOp = node->Op(1); - auto emitSwCase = [&](int8_t i) { + regNumber targetReg = node->GetRegNum(); + GenTree* rmOp = node->Op(1); + auto emitSwCase = [&](int8_t i) + { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_RM(node, ins, simdSize, targetReg, rmOp, newInstOptions); }; @@ -331,7 +332,8 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) } case 2: { - auto emitSwCase = [&](int8_t i) { + auto emitSwCase = [&](int8_t i) + { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_R_RM(node, ins, simdSize, newInstOptions); }; @@ -498,7 +500,8 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) } else if (HWIntrinsicInfo::isImmOp(intrinsicId, op2)) { - auto emitSwCase = [&](int8_t i) { + auto emitSwCase = [&](int8_t i) + { if (HWIntrinsicInfo::CopiesUpperBits(intrinsicId)) { assert(!op1->isContained()); @@ -1208,10 +1211,10 @@ void CodeGen::genHWIntrinsic_R_R_R_RM_I(GenTreeHWIntrinsic* node, instruction in if (op2->isContained()) { -// op2 is never selected by the table so -// we can contain and ignore any register -// allocated to it resulting in better -// non-RMW based codegen. + // op2 is never selected by the table so + // we can contain and ignore any register + // allocated to it resulting in better + // non-RMW based codegen. #if defined(DEBUG) NamedIntrinsic intrinsicId = node->GetHWIntrinsicId(); @@ -1364,8 +1367,9 @@ void CodeGen::genNonTableDrivenHWIntrinsicsJumpTableFallback(GenTreeHWIntrinsic* { // This intrinsic has several overloads, only the ones with floating number inputs should reach this part. assert(varTypeIsFloating(baseType)); - GenTree* rmOp = node->Op(1); - auto emitSwCase = [&](int8_t i) { + GenTree* rmOp = node->Op(1); + auto emitSwCase = [&](int8_t i) + { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_RM(node, ins, attr, targetReg, rmOp, newInstOptions); }; @@ -1386,7 +1390,8 @@ void CodeGen::genNonTableDrivenHWIntrinsicsJumpTableFallback(GenTreeHWIntrinsic* attr = emitTypeSize(targetType); GenTree* rmOp = node->Op(1); - auto emitSwCase = [&](int8_t i) { + auto emitSwCase = [&](int8_t i) + { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_RM(node, ins, attr, targetReg, rmOp, newInstOptions); }; @@ -1400,7 +1405,8 @@ void CodeGen::genNonTableDrivenHWIntrinsicsJumpTableFallback(GenTreeHWIntrinsic* case NI_AVX512F_X64_ConvertScalarToVector128Double: { assert(varTypeIsLong(baseType)); - auto emitSwCase = [&](int8_t i) { + auto emitSwCase = [&](int8_t i) + { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_R_RM(node, ins, EA_8BYTE, newInstOptions); }; @@ -1432,7 +1438,8 @@ void CodeGen::genNonTableDrivenHWIntrinsicsJumpTableFallback(GenTreeHWIntrinsic* regNumber op1Reg = op1->GetRegNum(); regNumber op2Reg = op2->GetRegNum(); - auto emitSwCase = [&](int8_t i) { + auto emitSwCase = [&](int8_t i) + { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_R_R_RM(ins, attr, targetReg, op1Reg, op2Reg, op3, newInstOptions); }; diff --git a/src/coreclr/jit/hwintrinsicxarch.cpp b/src/coreclr/jit/hwintrinsicxarch.cpp index f88cf6ec99ec3c..87332c07f0113f 100644 --- a/src/coreclr/jit/hwintrinsicxarch.cpp +++ b/src/coreclr/jit/hwintrinsicxarch.cpp @@ -371,7 +371,7 @@ FloatComparisonMode HWIntrinsicInfo::lookupFloatComparisonModeForSwappedArgs(Flo { switch (comparison) { - // These comparison modes are the same even if the operands are swapped + // These comparison modes are the same even if the operands are swapped case FloatComparisonMode::OrderedEqualNonSignaling: return FloatComparisonMode::OrderedEqualNonSignaling; @@ -406,7 +406,7 @@ FloatComparisonMode HWIntrinsicInfo::lookupFloatComparisonModeForSwappedArgs(Flo case FloatComparisonMode::UnorderedTrueSignaling: return FloatComparisonMode::UnorderedTrueSignaling; - // These comparison modes need a different mode if the operands are swapped + // These comparison modes need a different mode if the operands are swapped case FloatComparisonMode::OrderedLessThanSignaling: return FloatComparisonMode::OrderedGreaterThanSignaling; @@ -2498,7 +2498,7 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, // TODO-XARCH-CQ: We should support long/ulong multiplication break; } -// else if simdSize == 64 then above assert would check if baseline isa supported + // else if simdSize == 64 then above assert would check if baseline isa supported #if defined(TARGET_X86) // TODO-XARCH-CQ: We need to support 64-bit CreateBroadcast @@ -3274,13 +3274,13 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, int ival = HWIntrinsicInfo::lookupIval(this, intrinsic, simdBaseType); retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, op2, gtNewIconNode(ival), NI_AVX_CompareScalar, - simdBaseJitType, simdSize); + simdBaseJitType, simdSize); } else { GenTree* clonedOp1 = nullptr; op1 = impCloneExpr(op1, &clonedOp1, CHECK_SPILL_ALL, - nullptr DEBUGARG("Clone op1 for Sse.CompareScalarGreaterThan")); + nullptr DEBUGARG("Clone op1 for Sse.CompareScalarGreaterThan")); retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op2, op1, intrinsic, simdBaseJitType, simdSize); retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, clonedOp1, retNode, NI_SSE_MoveScalar, simdBaseJitType, @@ -3333,13 +3333,13 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, int ival = HWIntrinsicInfo::lookupIval(this, intrinsic, simdBaseType); retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, op2, gtNewIconNode(ival), NI_AVX_CompareScalar, - simdBaseJitType, simdSize); + simdBaseJitType, simdSize); } else { GenTree* clonedOp1 = nullptr; op1 = impCloneExpr(op1, &clonedOp1, CHECK_SPILL_ALL, - nullptr DEBUGARG("Clone op1 for Sse2.CompareScalarGreaterThan")); + nullptr DEBUGARG("Clone op1 for Sse2.CompareScalarGreaterThan")); retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op2, op1, intrinsic, simdBaseJitType, simdSize); retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, clonedOp1, retNode, NI_SSE2_MoveScalar, simdBaseJitType, diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 5ed3064fa87502..515a22accdec6c 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -70,16 +70,16 @@ bool Compiler::impILConsumesAddr(const BYTE* codeAddr) switch (opcode) { - // case CEE_LDFLDA: We're taking this one out as if you have a sequence - // like - // - // ldloca.0 - // ldflda whatever - // - // of a primitivelike struct, you end up after morphing with addr of a local - // that's not marked as addrtaken, which is wrong. Also ldflda is usually used - // for structs that contain other structs, which isnt a case we handle very - // well now for other reasons. + // case CEE_LDFLDA: We're taking this one out as if you have a sequence + // like + // + // ldloca.0 + // ldflda whatever + // + // of a primitivelike struct, you end up after morphing with addr of a local + // that's not marked as addrtaken, which is wrong. Also ldflda is usually used + // for structs that contain other structs, which isnt a case we handle very + // well now for other reasons. case CEE_LDFLD: { @@ -670,7 +670,7 @@ void Compiler::impStoreTemp(unsigned lclNum, Statement** pAfterStmt, /* = NULL */ const DebugInfo& di, /* = DebugInfo() */ BasicBlock* block /* = NULL */ - ) +) { GenTree* store = gtNewTempStore(lclNum, val, curLevel, pAfterStmt, di, block); @@ -815,7 +815,7 @@ GenTree* Compiler::impStoreStruct(GenTree* store, Statement** pAfterStmt, /* = nullptr */ const DebugInfo& di, /* = DebugInfo() */ BasicBlock* block /* = nullptr */ - ) +) { assert(varTypeIsStruct(store) && store->OperIsStore()); @@ -1718,7 +1718,7 @@ bool Compiler::impSpillStackEntry(unsigned level, bool bAssertOnRecursion, const char* reason #endif - ) +) { #ifdef DEBUG @@ -2067,9 +2067,9 @@ BasicBlock* Compiler::impPushCatchArgOnStack(BasicBlock* hndBlk, CORINFO_CLASS_H * If the tree has side-effects, it will be spilled to a temp. */ -GenTree* Compiler::impCloneExpr(GenTree* tree, - GenTree** pClone, - unsigned curLevel, +GenTree* Compiler::impCloneExpr(GenTree* tree, + GenTree** pClone, + unsigned curLevel, Statement** pAfterStmt DEBUGARG(const char* reason)) { if (!(tree->gtFlags & GTF_GLOB_EFFECT)) @@ -4260,12 +4260,13 @@ GenTree* Compiler::impFixupStructReturnType(GenTree* op) // In contrast, we can only use multi-reg calls directly if they have the exact same ABI. // Calling convention equality is a conservative approximation for that check. - if (op->IsCall() && (op->AsCall()->GetUnmanagedCallConv() == info.compCallConv) + if (op->IsCall() && + (op->AsCall()->GetUnmanagedCallConv() == info.compCallConv) #if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) // TODO-Review: this seems unnecessary. Return ABI doesn't change under varargs. && !op->AsCall()->IsVarargs() #endif // defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) - ) + ) { return op; } @@ -6172,7 +6173,8 @@ void Compiler::impImportBlockCode(BasicBlock* block) bool ovfl, unordered, callNode; CORINFO_CLASS_HANDLE tokenType; - union { + union + { int intVal; float fltVal; __int64 lngVal; @@ -6919,7 +6921,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) // Create the store node and append it. ClassLayout* layout = (lclTyp == TYP_STRUCT) ? typGetObjLayout(stelemClsHnd) : nullptr; op1 = (lclTyp == TYP_STRUCT) ? gtNewStoreBlkNode(layout, op1, op2)->AsIndir() - : gtNewStoreIndNode(lclTyp, op1, op2); + : gtNewStoreIndNode(lclTyp, op1, op2); if (varTypeIsStruct(op1)) { op1 = impStoreStruct(op1, CHECK_SPILL_ALL); @@ -6977,7 +6979,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) oper = GT_MUL; goto MATH_MAYBE_CALL_OVF; - // Other binary math operations + // Other binary math operations case CEE_DIV: oper = GT_DIV; @@ -7266,7 +7268,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) op1 = gtNewOperNode(oper, TYP_INT, op1, op2); } - // fall through + // fall through COND_JUMP: @@ -7595,7 +7597,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) goto SPILL_APPEND; - /************************** Casting OPCODES ***************************/ + /************************** Casting OPCODES ***************************/ case CEE_CONV_OVF_I1: lclTyp = TYP_BYTE; @@ -7737,12 +7739,13 @@ void Compiler::impImportBlockCode(BasicBlock* block) if (varTypeIsFloating(lclTyp)) { - callNode = varTypeIsLong(impStackTop().val) || uns // uint->dbl gets turned into uint->long->dbl + callNode = varTypeIsLong(impStackTop().val) || + uns // uint->dbl gets turned into uint->long->dbl #ifdef TARGET_64BIT - // TODO-ARM64-Bug?: This was AMD64; I enabled it for ARM64 also. OK? - // TYP_BYREF could be used as TYP_I_IMPL which is long. - // TODO-CQ: remove this when we lower casts long/ulong --> float/double - // and generate SSE2 code instead of going through helper calls. + // TODO-ARM64-Bug?: This was AMD64; I enabled it for ARM64 also. OK? + // TYP_BYREF could be used as TYP_I_IMPL which is long. + // TODO-CQ: remove this when we lower casts long/ulong --> float/double + // and generate SSE2 code instead of going through helper calls. || (impStackTop().val->TypeGet() == TYP_BYREF) #endif ; @@ -8922,7 +8925,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) #if BIGENDIAN op1 = gtNewIconNode(0, lclTyp); #else - op1 = gtNewIconNode(1, lclTyp); + op1 = gtNewIconNode(1, lclTyp); #endif goto FIELD_DONE; } @@ -8937,7 +8940,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) ClassLayout* layout; lclTyp = TypeHandleToVarType(fieldInfo.fieldType, clsHnd, &layout); op1 = (lclTyp == TYP_STRUCT) ? gtNewBlkIndir(layout, op1, indirFlags) - : gtNewIndir(lclTyp, op1, indirFlags); + : gtNewIndir(lclTyp, op1, indirFlags); if ((indirFlags & GTF_IND_INVARIANT) != 0) { // TODO-ASG: delete this zero-diff quirk. @@ -9799,10 +9802,10 @@ void Compiler::impImportBlockCode(BasicBlock* block) } } - assert((helper == CORINFO_HELP_UNBOX && op1->gtType == TYP_BYREF) || // Unbox helper returns a byref. - (helper == CORINFO_HELP_UNBOX_NULLABLE && - varTypeIsStruct(op1)) // UnboxNullable helper returns a struct. - ); + assert((helper == CORINFO_HELP_UNBOX && op1->gtType == TYP_BYREF) || // Unbox helper returns a byref. + (helper == CORINFO_HELP_UNBOX_NULLABLE && varTypeIsStruct(op1)) // UnboxNullable helper returns a + // struct. + ); /* ---------------------------------------------------------------------- @@ -10066,7 +10069,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) // Pop the exception object and create the 'throw' helper call op1 = gtNewHelperCallNode(CORINFO_HELP_THROW, TYP_VOID, impPopStack().val); - // Fall through to clear out the eval stack. + // Fall through to clear out the eval stack. EVAL_APPEND: if (verCurrentState.esStackDepth > 0) @@ -10353,7 +10356,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) } break; - /******************************** NYI *******************************/ + /******************************** NYI *******************************/ case 0xCC: OutputDebugStringA("CLR: Invalid x86 breakpoint in IL stream\n"); @@ -10506,7 +10509,7 @@ void Compiler::impLoadLoc(unsigned ilLclNum, IL_OFFSET offset) // Returns: // Tree with reference to struct local to use as call return value. -GenTree* Compiler::impStoreMultiRegValueToVar(GenTree* op, +GenTree* Compiler::impStoreMultiRegValueToVar(GenTree* op, CORINFO_CLASS_HANDLE hClass DEBUGARG(CorInfoCallConvExtension callConv)) { unsigned tmpNum = lvaGrabTemp(true DEBUGARG("Return value temp for multireg return")); @@ -10913,7 +10916,8 @@ void Compiler::impPoisonImplicitByrefsBeforeReturn() ClassLayout* layout = dsc->GetLayout(); assert(layout != nullptr); - auto poisonBlock = [this, lclNum](unsigned start, unsigned count) { + auto poisonBlock = [this, lclNum](unsigned start, unsigned count) + { if (count <= 0) { return; @@ -11794,7 +11798,7 @@ unsigned Compiler::impGetSpillTmpBase(BasicBlock* block) // Otherwise, choose one, and propagate to all members of the spill clique. // Grab enough temps for the whole stack. - unsigned baseTmp = lvaGrabTemps(verCurrentState.esStackDepth DEBUGARG("IL Stack Entries")); + unsigned baseTmp = lvaGrabTemps(verCurrentState.esStackDepth DEBUGARG("IL Stack Entries")); SetSpillTempsBase callback(baseTmp); // We do *NOT* need to reset the SpillClique*Members because a block can only be the predecessor @@ -12097,7 +12101,7 @@ void Compiler::impFixPredLists() unsigned XTnum = 0; bool added = false; - for (EHblkDsc *HBtab = compHndBBtab; XTnum < compHndBBtabCount; XTnum++, HBtab++) + for (EHblkDsc* HBtab = compHndBBtab; XTnum < compHndBBtabCount; XTnum++, HBtab++) { if (HBtab->HasFinallyHandler()) { @@ -12246,7 +12250,7 @@ void Compiler::impMakeDiscretionaryInlineObservations(InlineInfo* pInlineInfo, I { assert((pInlineInfo != nullptr && compIsForInlining()) || // Perform the actual inlining. (pInlineInfo == nullptr && !compIsForInlining()) // Calculate the static inlining hint for ngen. - ); + ); // If we're really inlining, we should just have one result in play. assert((pInlineInfo == nullptr) || (inlineResult == pInlineInfo->inlineResult)); @@ -13291,7 +13295,7 @@ GenTree* Compiler::impInlineFetchArg(InlArgInfo& argInfo, const InlLclVarInfo& l assert(!argInfo.argIsUsed); /* Reserve a temp for the expression. - * Use a large size node as we may change it later */ + * Use a large size node as we may change it later */ const unsigned tmpNum = lvaGrabTemp(true DEBUGARG("Inlining Arg")); diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 53f33c45a98c76..c10f7aea175bcf 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -2203,8 +2203,9 @@ void Compiler::impPopArgsForSwiftCall(GenTreeCall* call, CORINFO_SIG_INFO* sig, } else { - unsigned relOffset = 0; - auto addSegment = [=, &loweredNode, &relOffset](var_types type) { + unsigned relOffset = 0; + auto addSegment = [=, &loweredNode, &relOffset](var_types type) + { GenTree* val = gtNewLclFldNode(structVal->GetLclNum(), type, structVal->GetLclOffs() + offset + relOffset); @@ -3286,7 +3287,7 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, GenTree* op1 = impPopStack().val; GenTree* addr = gtNewIndexAddr(op1, op2, TYP_USHORT, NO_CLASS_HANDLE, OFFSETOF__CORINFO_String__chars, OFFSETOF__CORINFO_String__stringLen); - retNode = gtNewIndexIndir(addr->AsIndexAddr()); + retNode = gtNewIndexIndir(addr->AsIndexAddr()); break; } @@ -3633,8 +3634,8 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, typeHandleHelper = CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL; } assert(op1->AsCall()->gtArgs.CountArgs() == 1); - op1 = gtNewHelperCallNode(typeHandleHelper, TYP_REF, - op1->AsCall()->gtArgs.GetArgByIndex(0)->GetEarlyNode()); + op1 = gtNewHelperCallNode(typeHandleHelper, TYP_REF, + op1->AsCall()->gtArgs.GetArgByIndex(0)->GetEarlyNode()); op1->gtType = TYP_REF; retNode = op1; } @@ -6115,9 +6116,7 @@ void Compiler::impCheckForPInvokeCall( class SpillRetExprHelper { public: - SpillRetExprHelper(Compiler* comp) : comp(comp) - { - } + SpillRetExprHelper(Compiler* comp) : comp(comp) {} void StoreRetExprResultsInArgs(GenTreeCall* call) { @@ -6783,7 +6782,9 @@ void Compiler::considerGuardedDevirtualization(GenTreeCall* call, #ifdef DEBUG char buffer[256]; JITDUMP("%s call would invoke method %s\n", - isInterface ? "interface" : call->IsDelegateInvoke() ? "delegate" : "virtual", + isInterface ? "interface" + : call->IsDelegateInvoke() ? "delegate" + : "virtual", eeGetMethodFullName(likelyMethod, true, true, buffer, sizeof(buffer))); #endif @@ -7278,8 +7279,8 @@ bool Compiler::IsTargetIntrinsic(NamedIntrinsic intrinsicName) #if defined(TARGET_XARCH) switch (intrinsicName) { - // AMD64/x86 has SSE2 instructions to directly compute sqrt/abs and SSE4.1 - // instructions to directly compute round/ceiling/floor/truncate. + // AMD64/x86 has SSE2 instructions to directly compute sqrt/abs and SSE4.1 + // instructions to directly compute round/ceiling/floor/truncate. case NI_System_Math_Abs: case NI_System_Math_Sqrt: @@ -7482,8 +7483,8 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call, // Optionally, print info on devirtualization Compiler* const rootCompiler = impInlineRoot(); const bool doPrint = JitConfig.JitPrintDevirtualizedMethods().contains(rootCompiler->info.compMethodHnd, - rootCompiler->info.compClassHnd, - &rootCompiler->info.compMethodInfo->args); + rootCompiler->info.compClassHnd, + &rootCompiler->info.compMethodInfo->args); #endif // DEBUG // Fetch information about the virtual method we're calling. @@ -8431,8 +8432,8 @@ void Compiler::impCheckCanInline(GenTreeCall* call, param.ppInlineCandidateInfo = ppInlineCandidateInfo; bool success = eeRunWithErrorTrap( - [](Param* pParam) { - + [](Param* pParam) + { // Cache some frequently accessed state. // Compiler* const compiler = pParam->pThis; @@ -8462,8 +8463,9 @@ void Compiler::impCheckCanInline(GenTreeCall* call, } else { - JITDUMP("Class context: %s\n", compiler->eeGetClassName((CORINFO_CLASS_HANDLE)( - (size_t)pParam->exactContextHnd & ~CORINFO_CONTEXTFLAGS_MASK))); + JITDUMP("Class context: %s\n", + compiler->eeGetClassName( + (CORINFO_CLASS_HANDLE)((size_t)pParam->exactContextHnd & ~CORINFO_CONTEXTFLAGS_MASK))); } // Fetch method info. This may fail, if the method doesn't have IL. @@ -9560,372 +9562,374 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method) else #endif // defined(TARGET_XARCH) || defined(TARGET_ARM64) if (strcmp(namespaceName, "Collections.Generic") == 0) - { - if (strcmp(className, "Comparer`1") == 0) { - if (strcmp(methodName, "get_Default") == 0) + if (strcmp(className, "Comparer`1") == 0) { - result = NI_System_Collections_Generic_Comparer_get_Default; + if (strcmp(methodName, "get_Default") == 0) + { + result = NI_System_Collections_Generic_Comparer_get_Default; + } } - } - else if (strcmp(className, "EqualityComparer`1") == 0) - { - if (strcmp(methodName, "get_Default") == 0) + else if (strcmp(className, "EqualityComparer`1") == 0) { - result = NI_System_Collections_Generic_EqualityComparer_get_Default; + if (strcmp(methodName, "get_Default") == 0) + { + result = NI_System_Collections_Generic_EqualityComparer_get_Default; + } } } - } - else if (strcmp(namespaceName, "Numerics") == 0) - { - if (strcmp(className, "BitOperations") == 0) - { - result = lookupPrimitiveIntNamedIntrinsic(method, methodName); - } - else + else if (strcmp(namespaceName, "Numerics") == 0) { + if (strcmp(className, "BitOperations") == 0) + { + result = lookupPrimitiveIntNamedIntrinsic(method, methodName); + } + else + { #ifdef FEATURE_HW_INTRINSICS - CORINFO_SIG_INFO sig; - info.compCompHnd->getMethodSig(method, &sig); + CORINFO_SIG_INFO sig; + info.compCompHnd->getMethodSig(method, &sig); - result = SimdAsHWIntrinsicInfo::lookupId(this, &sig, className, methodName, enclosingClassName); + result = SimdAsHWIntrinsicInfo::lookupId(this, &sig, className, methodName, enclosingClassName); #endif // FEATURE_HW_INTRINSICS - if (result == NI_Illegal) - { - // This allows the relevant code paths to be dropped as dead code even - // on platforms where FEATURE_HW_INTRINSICS is not supported. - - if (strcmp(methodName, "get_IsSupported") == 0) - { - assert(strcmp(className, "Vector`1") == 0); - result = NI_IsSupported_Type; - } - else if (strcmp(methodName, "get_IsHardwareAccelerated") == 0) - { - result = NI_IsSupported_False; - } - else if (strcmp(methodName, "get_Count") == 0) - { - assert(strcmp(className, "Vector`1") == 0); - result = NI_Vector_GetCount; - } - else if (gtIsRecursiveCall(method)) + if (result == NI_Illegal) { - // For the framework itself, any recursive intrinsics will either be - // only supported on a single platform or will be guarded by a relevant - // IsSupported check so the throw PNSE will be valid or dropped. + // This allows the relevant code paths to be dropped as dead code even + // on platforms where FEATURE_HW_INTRINSICS is not supported. - result = NI_Throw_PlatformNotSupportedException; + if (strcmp(methodName, "get_IsSupported") == 0) + { + assert(strcmp(className, "Vector`1") == 0); + result = NI_IsSupported_Type; + } + else if (strcmp(methodName, "get_IsHardwareAccelerated") == 0) + { + result = NI_IsSupported_False; + } + else if (strcmp(methodName, "get_Count") == 0) + { + assert(strcmp(className, "Vector`1") == 0); + result = NI_Vector_GetCount; + } + else if (gtIsRecursiveCall(method)) + { + // For the framework itself, any recursive intrinsics will either be + // only supported on a single platform or will be guarded by a relevant + // IsSupported check so the throw PNSE will be valid or dropped. + + result = NI_Throw_PlatformNotSupportedException; + } } } } - } - else if (strncmp(namespaceName, "Runtime.", 8) == 0) - { - namespaceName += 8; - - if (strcmp(namespaceName, "CompilerServices") == 0) + else if (strncmp(namespaceName, "Runtime.", 8) == 0) { - if (strcmp(className, "RuntimeHelpers") == 0) + namespaceName += 8; + + if (strcmp(namespaceName, "CompilerServices") == 0) { - if (strcmp(methodName, "CreateSpan") == 0) - { - result = NI_System_Runtime_CompilerServices_RuntimeHelpers_CreateSpan; - } - else if (strcmp(methodName, "InitializeArray") == 0) + if (strcmp(className, "RuntimeHelpers") == 0) { - result = NI_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray; + if (strcmp(methodName, "CreateSpan") == 0) + { + result = NI_System_Runtime_CompilerServices_RuntimeHelpers_CreateSpan; + } + else if (strcmp(methodName, "InitializeArray") == 0) + { + result = NI_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray; + } + else if (strcmp(methodName, "IsKnownConstant") == 0) + { + result = NI_System_Runtime_CompilerServices_RuntimeHelpers_IsKnownConstant; + } } - else if (strcmp(methodName, "IsKnownConstant") == 0) + else if (strcmp(className, "Unsafe") == 0) { - result = NI_System_Runtime_CompilerServices_RuntimeHelpers_IsKnownConstant; + if (strcmp(methodName, "Add") == 0) + { + result = NI_SRCS_UNSAFE_Add; + } + else if (strcmp(methodName, "AddByteOffset") == 0) + { + result = NI_SRCS_UNSAFE_AddByteOffset; + } + else if (strcmp(methodName, "AreSame") == 0) + { + result = NI_SRCS_UNSAFE_AreSame; + } + else if (strcmp(methodName, "As") == 0) + { + result = NI_SRCS_UNSAFE_As; + } + else if (strcmp(methodName, "AsPointer") == 0) + { + result = NI_SRCS_UNSAFE_AsPointer; + } + else if (strcmp(methodName, "AsRef") == 0) + { + result = NI_SRCS_UNSAFE_AsRef; + } + else if (strcmp(methodName, "BitCast") == 0) + { + result = NI_SRCS_UNSAFE_BitCast; + } + else if (strcmp(methodName, "ByteOffset") == 0) + { + result = NI_SRCS_UNSAFE_ByteOffset; + } + else if (strcmp(methodName, "Copy") == 0) + { + result = NI_SRCS_UNSAFE_Copy; + } + else if (strcmp(methodName, "CopyBlock") == 0) + { + result = NI_SRCS_UNSAFE_CopyBlock; + } + else if (strcmp(methodName, "CopyBlockUnaligned") == 0) + { + result = NI_SRCS_UNSAFE_CopyBlockUnaligned; + } + else if (strcmp(methodName, "InitBlock") == 0) + { + result = NI_SRCS_UNSAFE_InitBlock; + } + else if (strcmp(methodName, "InitBlockUnaligned") == 0) + { + result = NI_SRCS_UNSAFE_InitBlockUnaligned; + } + else if (strcmp(methodName, "IsAddressGreaterThan") == 0) + { + result = NI_SRCS_UNSAFE_IsAddressGreaterThan; + } + else if (strcmp(methodName, "IsAddressLessThan") == 0) + { + result = NI_SRCS_UNSAFE_IsAddressLessThan; + } + else if (strcmp(methodName, "IsNullRef") == 0) + { + result = NI_SRCS_UNSAFE_IsNullRef; + } + else if (strcmp(methodName, "NullRef") == 0) + { + result = NI_SRCS_UNSAFE_NullRef; + } + else if (strcmp(methodName, "Read") == 0) + { + result = NI_SRCS_UNSAFE_Read; + } + else if (strcmp(methodName, "ReadUnaligned") == 0) + { + result = NI_SRCS_UNSAFE_ReadUnaligned; + } + else if (strcmp(methodName, "SizeOf") == 0) + { + result = NI_SRCS_UNSAFE_SizeOf; + } + else if (strcmp(methodName, "SkipInit") == 0) + { + result = NI_SRCS_UNSAFE_SkipInit; + } + else if (strcmp(methodName, "Subtract") == 0) + { + result = NI_SRCS_UNSAFE_Subtract; + } + else if (strcmp(methodName, "SubtractByteOffset") == 0) + { + result = NI_SRCS_UNSAFE_SubtractByteOffset; + } + else if (strcmp(methodName, "Unbox") == 0) + { + result = NI_SRCS_UNSAFE_Unbox; + } + else if (strcmp(methodName, "Write") == 0) + { + result = NI_SRCS_UNSAFE_Write; + } + else if (strcmp(methodName, "WriteUnaligned") == 0) + { + result = NI_SRCS_UNSAFE_WriteUnaligned; + } } } - else if (strcmp(className, "Unsafe") == 0) + else if (strcmp(namespaceName, "InteropServices") == 0) { - if (strcmp(methodName, "Add") == 0) - { - result = NI_SRCS_UNSAFE_Add; - } - else if (strcmp(methodName, "AddByteOffset") == 0) - { - result = NI_SRCS_UNSAFE_AddByteOffset; - } - else if (strcmp(methodName, "AreSame") == 0) - { - result = NI_SRCS_UNSAFE_AreSame; - } - else if (strcmp(methodName, "As") == 0) - { - result = NI_SRCS_UNSAFE_As; - } - else if (strcmp(methodName, "AsPointer") == 0) - { - result = NI_SRCS_UNSAFE_AsPointer; - } - else if (strcmp(methodName, "AsRef") == 0) - { - result = NI_SRCS_UNSAFE_AsRef; - } - else if (strcmp(methodName, "BitCast") == 0) - { - result = NI_SRCS_UNSAFE_BitCast; - } - else if (strcmp(methodName, "ByteOffset") == 0) - { - result = NI_SRCS_UNSAFE_ByteOffset; - } - else if (strcmp(methodName, "Copy") == 0) - { - result = NI_SRCS_UNSAFE_Copy; - } - else if (strcmp(methodName, "CopyBlock") == 0) - { - result = NI_SRCS_UNSAFE_CopyBlock; - } - else if (strcmp(methodName, "CopyBlockUnaligned") == 0) - { - result = NI_SRCS_UNSAFE_CopyBlockUnaligned; - } - else if (strcmp(methodName, "InitBlock") == 0) + if (strcmp(className, "MemoryMarshal") == 0) { - result = NI_SRCS_UNSAFE_InitBlock; - } - else if (strcmp(methodName, "InitBlockUnaligned") == 0) - { - result = NI_SRCS_UNSAFE_InitBlockUnaligned; - } - else if (strcmp(methodName, "IsAddressGreaterThan") == 0) - { - result = NI_SRCS_UNSAFE_IsAddressGreaterThan; - } - else if (strcmp(methodName, "IsAddressLessThan") == 0) - { - result = NI_SRCS_UNSAFE_IsAddressLessThan; - } - else if (strcmp(methodName, "IsNullRef") == 0) - { - result = NI_SRCS_UNSAFE_IsNullRef; - } - else if (strcmp(methodName, "NullRef") == 0) - { - result = NI_SRCS_UNSAFE_NullRef; - } - else if (strcmp(methodName, "Read") == 0) - { - result = NI_SRCS_UNSAFE_Read; - } - else if (strcmp(methodName, "ReadUnaligned") == 0) - { - result = NI_SRCS_UNSAFE_ReadUnaligned; - } - else if (strcmp(methodName, "SizeOf") == 0) - { - result = NI_SRCS_UNSAFE_SizeOf; - } - else if (strcmp(methodName, "SkipInit") == 0) - { - result = NI_SRCS_UNSAFE_SkipInit; - } - else if (strcmp(methodName, "Subtract") == 0) - { - result = NI_SRCS_UNSAFE_Subtract; - } - else if (strcmp(methodName, "SubtractByteOffset") == 0) - { - result = NI_SRCS_UNSAFE_SubtractByteOffset; - } - else if (strcmp(methodName, "Unbox") == 0) - { - result = NI_SRCS_UNSAFE_Unbox; - } - else if (strcmp(methodName, "Write") == 0) - { - result = NI_SRCS_UNSAFE_Write; - } - else if (strcmp(methodName, "WriteUnaligned") == 0) - { - result = NI_SRCS_UNSAFE_WriteUnaligned; + if (strcmp(methodName, "GetArrayDataReference") == 0) + { + result = NI_System_Runtime_InteropService_MemoryMarshal_GetArrayDataReference; + } } } - } - else if (strcmp(namespaceName, "InteropServices") == 0) - { - if (strcmp(className, "MemoryMarshal") == 0) + else if (strncmp(namespaceName, "Intrinsics", 10) == 0) { - if (strcmp(methodName, "GetArrayDataReference") == 0) - { - result = NI_System_Runtime_InteropService_MemoryMarshal_GetArrayDataReference; - } - } - } - else if (strncmp(namespaceName, "Intrinsics", 10) == 0) - { - // We go down this path even when FEATURE_HW_INTRINSICS isn't enabled - // so we can specially handle IsSupported and recursive calls. - - // This is required to appropriately handle the intrinsics on platforms - // which don't support them. On such a platform methods like Vector64.Create - // will be seen as `Intrinsic` and `mustExpand` due to having a code path - // which is recursive. When such a path is hit we expect it to be handled by - // the importer and we fire an assert if it wasn't and in previous versions - // of the JIT would fail fast. This was changed to throw a PNSE instead but - // we still assert as most intrinsics should have been recognized/handled. - - // In order to avoid the assert, we specially handle the IsSupported checks - // (to better allow dead-code optimizations) and we explicitly throw a PNSE - // as we know that is the desired behavior for the HWIntrinsics when not - // supported. For cases like Vector64.Create, this is fine because it will - // be behind a relevant IsSupported check and will never be hit and the - // software fallback will be executed instead. - - CLANG_FORMAT_COMMENT_ANCHOR; + // We go down this path even when FEATURE_HW_INTRINSICS isn't enabled + // so we can specially handle IsSupported and recursive calls. + + // This is required to appropriately handle the intrinsics on platforms + // which don't support them. On such a platform methods like Vector64.Create + // will be seen as `Intrinsic` and `mustExpand` due to having a code path + // which is recursive. When such a path is hit we expect it to be handled by + // the importer and we fire an assert if it wasn't and in previous versions + // of the JIT would fail fast. This was changed to throw a PNSE instead but + // we still assert as most intrinsics should have been recognized/handled. + + // In order to avoid the assert, we specially handle the IsSupported checks + // (to better allow dead-code optimizations) and we explicitly throw a PNSE + // as we know that is the desired behavior for the HWIntrinsics when not + // supported. For cases like Vector64.Create, this is fine because it will + // be behind a relevant IsSupported check and will never be hit and the + // software fallback will be executed instead. + + CLANG_FORMAT_COMMENT_ANCHOR; #ifdef FEATURE_HW_INTRINSICS - namespaceName += 10; - const char* platformNamespaceName; + namespaceName += 10; + const char* platformNamespaceName; #if defined(TARGET_XARCH) - platformNamespaceName = ".X86"; + platformNamespaceName = ".X86"; #elif defined(TARGET_ARM64) - platformNamespaceName = ".Arm"; + platformNamespaceName = ".Arm"; #else #error Unsupported platform #endif - if ((namespaceName[0] == '\0') || (strcmp(namespaceName, platformNamespaceName) == 0)) - { - CORINFO_SIG_INFO sig; - info.compCompHnd->getMethodSig(method, &sig); + if ((namespaceName[0] == '\0') || (strcmp(namespaceName, platformNamespaceName) == 0)) + { + CORINFO_SIG_INFO sig; + info.compCompHnd->getMethodSig(method, &sig); - result = HWIntrinsicInfo::lookupId(this, &sig, className, methodName, enclosingClassName); - } + result = HWIntrinsicInfo::lookupId(this, &sig, className, methodName, enclosingClassName); + } #endif // FEATURE_HW_INTRINSICS - if (result == NI_Illegal) - { - // This allows the relevant code paths to be dropped as dead code even - // on platforms where FEATURE_HW_INTRINSICS is not supported. - - if (strcmp(methodName, "get_IsSupported") == 0) + if (result == NI_Illegal) { - if (strncmp(className, "Vector", 6) == 0) + // This allows the relevant code paths to be dropped as dead code even + // on platforms where FEATURE_HW_INTRINSICS is not supported. + + if (strcmp(methodName, "get_IsSupported") == 0) { - assert( - (strcmp(className, "Vector64`1") == 0) || (strcmp(className, "Vector128`1") == 0) || - (strcmp(className, "Vector256`1") == 0) || (strcmp(className, "Vector512`1") == 0)); + if (strncmp(className, "Vector", 6) == 0) + { + assert((strcmp(className, "Vector64`1") == 0) || + (strcmp(className, "Vector128`1") == 0) || + (strcmp(className, "Vector256`1") == 0) || + (strcmp(className, "Vector512`1") == 0)); - result = NI_IsSupported_Type; + result = NI_IsSupported_Type; + } + else + { + result = NI_IsSupported_False; + } } - else + else if (strcmp(methodName, "get_IsHardwareAccelerated") == 0) { result = NI_IsSupported_False; } - } - else if (strcmp(methodName, "get_IsHardwareAccelerated") == 0) - { - result = NI_IsSupported_False; - } - else if (strcmp(methodName, "get_Count") == 0) - { - assert((strcmp(className, "Vector64`1") == 0) || (strcmp(className, "Vector128`1") == 0) || - (strcmp(className, "Vector256`1") == 0) || (strcmp(className, "Vector512`1") == 0)); + else if (strcmp(methodName, "get_Count") == 0) + { + assert( + (strcmp(className, "Vector64`1") == 0) || (strcmp(className, "Vector128`1") == 0) || + (strcmp(className, "Vector256`1") == 0) || (strcmp(className, "Vector512`1") == 0)); - result = NI_Vector_GetCount; - } - else if (gtIsRecursiveCall(method)) - { - // For the framework itself, any recursive intrinsics will either be - // only supported on a single platform or will be guarded by a relevant - // IsSupported check so the throw PNSE will be valid or dropped. + result = NI_Vector_GetCount; + } + else if (gtIsRecursiveCall(method)) + { + // For the framework itself, any recursive intrinsics will either be + // only supported on a single platform or will be guarded by a relevant + // IsSupported check so the throw PNSE will be valid or dropped. - result = NI_Throw_PlatformNotSupportedException; + result = NI_Throw_PlatformNotSupportedException; + } } } } - } - else if (strcmp(namespaceName, "StubHelpers") == 0) - { - if (strcmp(className, "StubHelpers") == 0) - { - if (strcmp(methodName, "GetStubContext") == 0) - { - result = NI_System_StubHelpers_GetStubContext; - } - else if (strcmp(methodName, "NextCallReturnAddress") == 0) - { - result = NI_System_StubHelpers_NextCallReturnAddress; - } - } - } - else if (strcmp(namespaceName, "Text") == 0) - { - if (strcmp(className, "UTF8EncodingSealed") == 0) + else if (strcmp(namespaceName, "StubHelpers") == 0) { - if (strcmp(methodName, "ReadUtf8") == 0) + if (strcmp(className, "StubHelpers") == 0) { - assert(strcmp(enclosingClassName, "UTF8Encoding") == 0); - result = NI_System_Text_UTF8Encoding_UTF8EncodingSealed_ReadUtf8; + if (strcmp(methodName, "GetStubContext") == 0) + { + result = NI_System_StubHelpers_GetStubContext; + } + else if (strcmp(methodName, "NextCallReturnAddress") == 0) + { + result = NI_System_StubHelpers_NextCallReturnAddress; + } } } - } - else if (strcmp(namespaceName, "Threading") == 0) - { - if (strcmp(className, "Interlocked") == 0) + else if (strcmp(namespaceName, "Text") == 0) { - if (strcmp(methodName, "And") == 0) - { - result = NI_System_Threading_Interlocked_And; - } - else if (strcmp(methodName, "Or") == 0) - { - result = NI_System_Threading_Interlocked_Or; - } - else if (strcmp(methodName, "CompareExchange") == 0) - { - result = NI_System_Threading_Interlocked_CompareExchange; - } - else if (strcmp(methodName, "Exchange") == 0) - { - result = NI_System_Threading_Interlocked_Exchange; - } - else if (strcmp(methodName, "ExchangeAdd") == 0) - { - result = NI_System_Threading_Interlocked_ExchangeAdd; - } - else if (strcmp(methodName, "MemoryBarrier") == 0) + if (strcmp(className, "UTF8EncodingSealed") == 0) { - result = NI_System_Threading_Interlocked_MemoryBarrier; - } - else if (strcmp(methodName, "ReadMemoryBarrier") == 0) - { - result = NI_System_Threading_Interlocked_ReadMemoryBarrier; + if (strcmp(methodName, "ReadUtf8") == 0) + { + assert(strcmp(enclosingClassName, "UTF8Encoding") == 0); + result = NI_System_Text_UTF8Encoding_UTF8EncodingSealed_ReadUtf8; + } } } - else if (strcmp(className, "Thread") == 0) + else if (strcmp(namespaceName, "Threading") == 0) { - if (strcmp(methodName, "get_CurrentThread") == 0) + if (strcmp(className, "Interlocked") == 0) { - result = NI_System_Threading_Thread_get_CurrentThread; - } - else if (strcmp(methodName, "get_ManagedThreadId") == 0) - { - result = NI_System_Threading_Thread_get_ManagedThreadId; + if (strcmp(methodName, "And") == 0) + { + result = NI_System_Threading_Interlocked_And; + } + else if (strcmp(methodName, "Or") == 0) + { + result = NI_System_Threading_Interlocked_Or; + } + else if (strcmp(methodName, "CompareExchange") == 0) + { + result = NI_System_Threading_Interlocked_CompareExchange; + } + else if (strcmp(methodName, "Exchange") == 0) + { + result = NI_System_Threading_Interlocked_Exchange; + } + else if (strcmp(methodName, "ExchangeAdd") == 0) + { + result = NI_System_Threading_Interlocked_ExchangeAdd; + } + else if (strcmp(methodName, "MemoryBarrier") == 0) + { + result = NI_System_Threading_Interlocked_MemoryBarrier; + } + else if (strcmp(methodName, "ReadMemoryBarrier") == 0) + { + result = NI_System_Threading_Interlocked_ReadMemoryBarrier; + } } - } - else if (strcmp(className, "Volatile") == 0) - { - if (strcmp(methodName, "Read") == 0) + else if (strcmp(className, "Thread") == 0) { - result = NI_System_Threading_Volatile_Read; + if (strcmp(methodName, "get_CurrentThread") == 0) + { + result = NI_System_Threading_Thread_get_CurrentThread; + } + else if (strcmp(methodName, "get_ManagedThreadId") == 0) + { + result = NI_System_Threading_Thread_get_ManagedThreadId; + } } - else if (strcmp(methodName, "Write") == 0) + else if (strcmp(className, "Volatile") == 0) { - result = NI_System_Threading_Volatile_Write; + if (strcmp(methodName, "Read") == 0) + { + result = NI_System_Threading_Volatile_Read; + } + else if (strcmp(methodName, "Write") == 0) + { + result = NI_System_Threading_Volatile_Write; + } } } - } } } else if (strcmp(namespaceName, "Internal.Runtime") == 0) diff --git a/src/coreclr/jit/importervectorization.cpp b/src/coreclr/jit/importervectorization.cpp index af7a2f2791d169..b001113618a4dd 100644 --- a/src/coreclr/jit/importervectorization.cpp +++ b/src/coreclr/jit/importervectorization.cpp @@ -182,7 +182,7 @@ GenTree* Compiler::impExpandHalfConstEqualsSIMD( xor1 = gtNewSimdBinOpNode(GT_XOR, simdType, vec1, cnsVec1, baseType, simdSize); } -// ((v1 ^ cns1) | (v2 ^ cns2)) == zero + // ((v1 ^ cns1) | (v2 ^ cns2)) == zero #if defined(TARGET_XARCH) if (compOpportunisticallyDependsOn(InstructionSet_AVX512F_VL)) @@ -516,10 +516,10 @@ GenTree* Compiler::impExpandHalfConstEquals(GenTreeLclVarCommon* data, GenTree* castedLen = gtNewCastNode(TYP_I_IMPL, gtCloneExpr(lengthFld), false, TYP_I_IMPL); GenTree* byteLen = gtNewOperNode(GT_MUL, TYP_I_IMPL, castedLen, gtNewIconNode(2, TYP_I_IMPL)); GenTreeOp* cmpStart = gtNewOperNode(GT_ADD, TYP_BYREF, gtClone(data), - gtNewOperNode(GT_SUB, TYP_I_IMPL, byteLen, - gtNewIconNode((ssize_t)(len * 2), TYP_I_IMPL))); - GenTree* storeTmp = gtNewTempStore(dataAddr->GetLclNum(), cmpStart); - indirCmp = gtNewOperNode(GT_COMMA, indirCmp->TypeGet(), storeTmp, indirCmp); + gtNewOperNode(GT_SUB, TYP_I_IMPL, byteLen, + gtNewIconNode((ssize_t)(len * 2), TYP_I_IMPL))); + GenTree* storeTmp = gtNewTempStore(dataAddr->GetLclNum(), cmpStart); + indirCmp = gtNewOperNode(GT_COMMA, indirCmp->TypeGet(), storeTmp, indirCmp); } GenTreeColon* lenCheckColon = gtNewColonNode(TYP_INT, indirCmp, gtNewFalse()); diff --git a/src/coreclr/jit/indirectcalltransformer.cpp b/src/coreclr/jit/indirectcalltransformer.cpp index 0839f9fc2a045e..2ea5efe4975f17 100644 --- a/src/coreclr/jit/indirectcalltransformer.cpp +++ b/src/coreclr/jit/indirectcalltransformer.cpp @@ -67,9 +67,7 @@ class IndirectCallTransformer { public: - IndirectCallTransformer(Compiler* compiler) : compiler(compiler) - { - } + IndirectCallTransformer(Compiler* compiler) : compiler(compiler) {} //------------------------------------------------------------------------ // Run: run transformation for each block. @@ -197,7 +195,7 @@ class IndirectCallTransformer virtual const char* Name() = 0; virtual void ClearFlag() = 0; virtual GenTreeCall* GetCall(Statement* callStmt) = 0; - virtual void FixupRetExpr() = 0; + virtual void FixupRetExpr() = 0; //------------------------------------------------------------------------ // CreateRemainder: split current block at the call stmt and @@ -366,9 +364,7 @@ class IndirectCallTransformer } // FixupRetExpr: no action needed as we handle this in the importer. - virtual void FixupRetExpr() - { - } + virtual void FixupRetExpr() {} //------------------------------------------------------------------------ // CreateCheck: create check block, that checks fat pointer bit set. diff --git a/src/coreclr/jit/inductionvariableopts.cpp b/src/coreclr/jit/inductionvariableopts.cpp index 59e5b6a0d497de..53b2452af828c4 100644 --- a/src/coreclr/jit/inductionvariableopts.cpp +++ b/src/coreclr/jit/inductionvariableopts.cpp @@ -65,27 +65,28 @@ bool Compiler::optCanSinkWidenedIV(unsigned lclNum, FlowGraphNaturalLoop* loop) { LclVarDsc* dsc = lvaGetDesc(lclNum); - BasicBlockVisit result = loop->VisitRegularExitBlocks([=](BasicBlock* exit) { - - if (!VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) + BasicBlockVisit result = loop->VisitRegularExitBlocks( + [=](BasicBlock* exit) { - JITDUMP(" Exit " FMT_BB " does not need a sink; V%02u is not live-in\n", exit->bbNum, lclNum); - return BasicBlockVisit::Continue; - } + if (!VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) + { + JITDUMP(" Exit " FMT_BB " does not need a sink; V%02u is not live-in\n", exit->bbNum, lclNum); + return BasicBlockVisit::Continue; + } - for (BasicBlock* pred : exit->PredBlocks()) - { - if (!loop->ContainsBlock(pred)) + for (BasicBlock* pred : exit->PredBlocks()) { - JITDUMP(" Cannot safely sink widened version of V%02u into exit " FMT_BB " of " FMT_LP - "; it has a non-loop pred " FMT_BB "\n", - lclNum, exit->bbNum, loop->GetIndex(), pred->bbNum); - return BasicBlockVisit::Abort; + if (!loop->ContainsBlock(pred)) + { + JITDUMP(" Cannot safely sink widened version of V%02u into exit " FMT_BB " of " FMT_LP + "; it has a non-loop pred " FMT_BB "\n", + lclNum, exit->bbNum, loop->GetIndex(), pred->bbNum); + return BasicBlockVisit::Abort; + } } - } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); #ifdef DEBUG // We currently do not expect to ever widen IVs that are live into @@ -93,20 +94,23 @@ bool Compiler::optCanSinkWidenedIV(unsigned lclNum, FlowGraphNaturalLoop* loop) // previously (EH write-thru is only for single def locals) which makes it // unprofitable. If this ever changes we need some more expansive handling // here. - loop->VisitLoopBlocks([=](BasicBlock* block) { - - block->VisitAllSuccs(this, [=](BasicBlock* succ) { - if (!loop->ContainsBlock(succ) && bbIsHandlerBeg(succ)) - { - assert(!VarSetOps::IsMember(this, succ->bbLiveIn, dsc->lvVarIndex) && - "Candidate IV for widening is live into exceptional exit"); - } + loop->VisitLoopBlocks( + [=](BasicBlock* block) + { + block->VisitAllSuccs(this, + [=](BasicBlock* succ) + { + if (!loop->ContainsBlock(succ) && bbIsHandlerBeg(succ)) + { + assert(!VarSetOps::IsMember(this, succ->bbLiveIn, dsc->lvVarIndex) && + "Candidate IV for widening is live into exceptional exit"); + } + + return BasicBlockVisit::Continue; + }); return BasicBlockVisit::Continue; }); - - return BasicBlockVisit::Continue; - }); #endif return result != BasicBlockVisit::Abort; @@ -170,58 +174,60 @@ bool Compiler::optIsIVWideningProfitable(unsigned lclNum, weight_t savedCost = 0; int savedSize = 0; - loop->VisitLoopBlocks([&](BasicBlock* block) { - for (Statement* stmt : block->NonPhiStatements()) + loop->VisitLoopBlocks( + [&](BasicBlock* block) { - bool hasUse = false; - int numExtensions = 0; - for (GenTree* node : stmt->TreeList()) + for (Statement* stmt : block->NonPhiStatements()) { - if (!node->OperIs(GT_CAST)) + bool hasUse = false; + int numExtensions = 0; + for (GenTree* node : stmt->TreeList()) { - hasUse |= node->OperIsLocal() && (node->AsLclVarCommon()->GetLclNum() == lclNum); - continue; - } + if (!node->OperIs(GT_CAST)) + { + hasUse |= node->OperIsLocal() && (node->AsLclVarCommon()->GetLclNum() == lclNum); + continue; + } - GenTreeCast* cast = node->AsCast(); - if ((cast->gtCastType != TYP_LONG) || !cast->IsUnsigned() || cast->gtOverflow()) - { - continue; - } + GenTreeCast* cast = node->AsCast(); + if ((cast->gtCastType != TYP_LONG) || !cast->IsUnsigned() || cast->gtOverflow()) + { + continue; + } - GenTree* op = cast->CastOp(); - if (!op->OperIs(GT_LCL_VAR) || (op->AsLclVarCommon()->GetLclNum() != lclNum)) - { - continue; + GenTree* op = cast->CastOp(); + if (!op->OperIs(GT_LCL_VAR) || (op->AsLclVarCommon()->GetLclNum() != lclNum)) + { + continue; + } + + // If this is already the source of a store then it is going to be + // free in our backends regardless. + GenTree* parent = node->gtGetParent(nullptr); + if ((parent != nullptr) && parent->OperIs(GT_STORE_LCL_VAR)) + { + continue; + } + + numExtensions++; } - // If this is already the source of a store then it is going to be - // free in our backends regardless. - GenTree* parent = node->gtGetParent(nullptr); - if ((parent != nullptr) && parent->OperIs(GT_STORE_LCL_VAR)) + if (hasUse) { - continue; + ivUses.Push(stmt); } - numExtensions++; - } - - if (hasUse) - { - ivUses.Push(stmt); - } - - if (numExtensions > 0) - { - JITDUMP(" Found %d zero extensions in " FMT_STMT "\n", numExtensions, stmt->GetID()); + if (numExtensions > 0) + { + JITDUMP(" Found %d zero extensions in " FMT_STMT "\n", numExtensions, stmt->GetID()); - savedSize += numExtensions * ExtensionSize; - savedCost += numExtensions * block->getBBWeight(this) * ExtensionCost; + savedSize += numExtensions * ExtensionSize; + savedCost += numExtensions * block->getBBWeight(this) * ExtensionCost; + } } - } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); if (!initedToConstant) { @@ -235,14 +241,16 @@ bool Compiler::optIsIVWideningProfitable(unsigned lclNum, // Now account for the cost of sinks. LclVarDsc* dsc = lvaGetDesc(lclNum); - loop->VisitRegularExitBlocks([&](BasicBlock* exit) { - if (VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) + loop->VisitRegularExitBlocks( + [&](BasicBlock* exit) { - savedSize -= ExtensionSize; - savedCost -= exit->getBBWeight(this) * ExtensionCost; - } - return BasicBlockVisit::Continue; - }); + if (VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) + { + savedSize -= ExtensionSize; + savedCost -= exit->getBBWeight(this) * ExtensionCost; + } + return BasicBlockVisit::Continue; + }); const weight_t ALLOWED_SIZE_REGRESSION_PER_CYCLE_IMPROVEMENT = 2; weight_t cycleImprovementPerInvoc = savedCost / fgFirstBB->getBBWeight(this); @@ -284,21 +292,24 @@ bool Compiler::optIsIVWideningProfitable(unsigned lclNum, void Compiler::optSinkWidenedIV(unsigned lclNum, unsigned newLclNum, FlowGraphNaturalLoop* loop) { LclVarDsc* dsc = lvaGetDesc(lclNum); - loop->VisitRegularExitBlocks([=](BasicBlock* exit) { - if (!VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) + loop->VisitRegularExitBlocks( + [=](BasicBlock* exit) { - return BasicBlockVisit::Continue; - } + if (!VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) + { + return BasicBlockVisit::Continue; + } - GenTree* narrowing = gtNewCastNode(TYP_INT, gtNewLclvNode(newLclNum, TYP_LONG), false, TYP_INT); - GenTree* store = gtNewStoreLclVarNode(lclNum, narrowing); - Statement* newStmt = fgNewStmtFromTree(store); - JITDUMP("Narrow IV local V%02u live into exit block " FMT_BB "; sinking a narrowing\n", lclNum, exit->bbNum); - DISPSTMT(newStmt); - fgInsertStmtAtBeg(exit, newStmt); + GenTree* narrowing = gtNewCastNode(TYP_INT, gtNewLclvNode(newLclNum, TYP_LONG), false, TYP_INT); + GenTree* store = gtNewStoreLclVarNode(lclNum, narrowing); + Statement* newStmt = fgNewStmtFromTree(store); + JITDUMP("Narrow IV local V%02u live into exit block " FMT_BB "; sinking a narrowing\n", lclNum, + exit->bbNum); + DISPSTMT(newStmt); + fgInsertStmtAtBeg(exit, newStmt); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ @@ -439,14 +450,17 @@ void Compiler::optBestEffortReplaceNarrowIVUses( optReplaceWidenedIV(lclNum, ssaNum, newLclNum, stmt); } - block->VisitRegularSuccs(this, [=](BasicBlock* succ) { - if (succ->GetUniquePred(this) == block) - { - optBestEffortReplaceNarrowIVUses(lclNum, ssaNum, newLclNum, succ, succ->firstStmt()); - } - - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(this, + [=](BasicBlock* succ) + { + if (succ->GetUniquePred(this) == block) + { + optBestEffortReplaceNarrowIVUses(lclNum, ssaNum, newLclNum, succ, + succ->firstStmt()); + } + + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/inline.cpp b/src/coreclr/jit/inline.cpp index 06ca71126f855c..c8831a75b39bc5 100644 --- a/src/coreclr/jit/inline.cpp +++ b/src/coreclr/jit/inline.cpp @@ -383,7 +383,7 @@ void InlineContext::Dump(bool verbose, unsigned indent) #if defined(DEBUG) calleeName = compiler->eeGetMethodFullName(m_Callee); #else - calleeName = "callee"; + calleeName = "callee"; #endif // defined(DEBUG) } diff --git a/src/coreclr/jit/inline.h b/src/coreclr/jit/inline.h index 342dc3fca5d238..fa32091bc49ff7 100644 --- a/src/coreclr/jit/inline.h +++ b/src/coreclr/jit/inline.h @@ -205,9 +205,7 @@ class InlinePolicy static InlinePolicy* GetPolicy(Compiler* compiler, bool isPrejitRoot); // Obligatory virtual dtor - virtual ~InlinePolicy() - { - } + virtual ~InlinePolicy() {} // Get the current decision InlineDecision GetDecision() const @@ -222,9 +220,9 @@ class InlinePolicy } // Policy observations - virtual void NoteSuccess() = 0; - virtual void NoteBool(InlineObservation obs, bool value) = 0; - virtual void NoteFatal(InlineObservation obs) = 0; + virtual void NoteSuccess() = 0; + virtual void NoteBool(InlineObservation obs, bool value) = 0; + virtual void NoteFatal(InlineObservation obs) = 0; virtual void NoteInt(InlineObservation obs, int value) = 0; virtual void NoteDouble(InlineObservation obs, double value) = 0; @@ -262,13 +260,9 @@ class InlinePolicy // Name of the policy virtual const char* GetName() const = 0; // Detailed data value dump - virtual void DumpData(FILE* file) const - { - } + virtual void DumpData(FILE* file) const {} // Detailed data name dump - virtual void DumpSchema(FILE* file) const - { - } + virtual void DumpSchema(FILE* file) const {} #define XATTR_I4(x) \ if ((INT32)x != 0) \ @@ -294,9 +288,7 @@ class InlinePolicy fprintf(file, " />\n"); } - virtual void OnDumpXml(FILE* file, unsigned indent = 0) const - { - } + virtual void OnDumpXml(FILE* file, unsigned indent = 0) const {} // True if this is the inline targeted by data collection bool IsDataCollectionTarget() @@ -321,7 +313,7 @@ class InlinePolicy private: // No copying or assignment supported - InlinePolicy(const InlinePolicy&) = delete; + InlinePolicy(const InlinePolicy&) = delete; InlinePolicy& operator=(const InlinePolicy&) = delete; protected: @@ -558,7 +550,7 @@ class InlineResult private: // No copying or assignment allowed. - InlineResult(const InlineResult&) = delete; + InlineResult(const InlineResult&) = delete; InlineResult& operator=(const InlineResult&) = delete; // Report/log/dump decision as appropriate @@ -1026,7 +1018,7 @@ class InlineStrategy void DumpDataContents(FILE* file); // Dump xml-formatted description of inlines - void DumpXml(FILE* file = stderr, unsigned indent = 0); + void DumpXml(FILE* file = stderr, unsigned indent = 0); static void FinalizeXml(FILE* file = stderr); // Cache for file position of this method in the inline xml diff --git a/src/coreclr/jit/inlinepolicy.cpp b/src/coreclr/jit/inlinepolicy.cpp index d057ccd09ed0d9..0b22414e740cb0 100644 --- a/src/coreclr/jit/inlinepolicy.cpp +++ b/src/coreclr/jit/inlinepolicy.cpp @@ -945,8 +945,9 @@ void DefaultPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo) { // Inline appears to be unprofitable JITLOG_THIS(m_RootCompiler, - (LL_INFO100000, "Native estimate for function size exceeds threshold" - " for inlining %g > %g (multiplier = %g)\n", + (LL_INFO100000, + "Native estimate for function size exceeds threshold" + " for inlining %g > %g (multiplier = %g)\n", (double)m_CalleeNativeSizeEstimate / SIZE_SCALE, (double)threshold / SIZE_SCALE, m_Multiplier)); // Fail the inline @@ -963,8 +964,9 @@ void DefaultPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo) { // Inline appears to be profitable JITLOG_THIS(m_RootCompiler, - (LL_INFO100000, "Native estimate for function size is within threshold" - " for inlining %g <= %g (multiplier = %g)\n", + (LL_INFO100000, + "Native estimate for function size is within threshold" + " for inlining %g <= %g (multiplier = %g)\n", (double)m_CalleeNativeSizeEstimate / SIZE_SCALE, (double)threshold / SIZE_SCALE, m_Multiplier)); // Update candidacy diff --git a/src/coreclr/jit/inlinepolicy.h b/src/coreclr/jit/inlinepolicy.h index 52333d5aacac3c..acc9b5e17b3429 100644 --- a/src/coreclr/jit/inlinepolicy.h +++ b/src/coreclr/jit/inlinepolicy.h @@ -157,7 +157,7 @@ class DefaultPolicy : public LegalPolicy // Helper methods virtual double DetermineMultiplier(); int DetermineNativeSizeEstimate(); - int DetermineCallsiteNativeSizeEstimate(CORINFO_METHOD_INFO* methodInfo); + int DetermineCallsiteNativeSizeEstimate(CORINFO_METHOD_INFO* methodInfo); // Data members Compiler* m_RootCompiler; // root compiler instance diff --git a/src/coreclr/jit/instr.cpp b/src/coreclr/jit/instr.cpp index dd82e7c08f92ba..7866c8a5e7b0f6 100644 --- a/src/coreclr/jit/instr.cpp +++ b/src/coreclr/jit/instr.cpp @@ -876,7 +876,7 @@ CodeGen::OperandDesc CodeGen::genOperandDesc(GenTree* op) // broadcast -> LCL_VAR(TYP_(U)INT) ssize_t scalarValue = hwintrinsicChild->AsIntCon()->IconValue(); UNATIVE_OFFSET cnum = emit->emitDataConst(&scalarValue, genTypeSize(simdBaseType), - genTypeSize(simdBaseType), simdBaseType); + genTypeSize(simdBaseType), simdBaseType); return OperandDesc(compiler->eeFindJitDataOffs(cnum)); } else @@ -1124,9 +1124,9 @@ void CodeGen::inst_RV_TT(instruction ins, emitAttr size, regNumber op1Reg, GenTr } /***************************************************************************** -* -* Generate an instruction of the form "op reg1, reg2, icon". -*/ + * + * Generate an instruction of the form "op reg1, reg2, icon". + */ void CodeGen::inst_RV_RV_IV(instruction ins, emitAttr size, regNumber reg1, regNumber reg2, unsigned ival) { @@ -1256,8 +1256,8 @@ void CodeGen::inst_RV_RV_TT(instruction ins, emitter* emit = GetEmitter(); noway_assert(emit->emitVerifyEncodable(ins, EA_SIZE(size), targetReg)); -// TODO-XArch-CQ: Commutative operations can have op1 be contained -// TODO-XArch-CQ: Non-VEX encoded instructions can have both ops contained + // TODO-XArch-CQ: Commutative operations can have op1 be contained + // TODO-XArch-CQ: Non-VEX encoded instructions can have both ops contained #if defined(TARGET_XARCH) && defined(FEATURE_HW_INTRINSICS) if (CodeGenInterface::IsEmbeddedBroadcastEnabled(ins, op2)) diff --git a/src/coreclr/jit/instrsarm.h b/src/coreclr/jit/instrsarm.h index 9356150d4b2e83..3a1c871d316f6a 100644 --- a/src/coreclr/jit/instrsarm.h +++ b/src/coreclr/jit/instrsarm.h @@ -19,7 +19,7 @@ * e8 -- encoding 8 * e9 -- encoding 9 * -******************************************************************************/ + ******************************************************************************/ #if !defined(TARGET_ARM) #error Unexpected target type diff --git a/src/coreclr/jit/instrsarm64.h b/src/coreclr/jit/instrsarm64.h index c07976f1eca0b6..c6ac7404c569d0 100644 --- a/src/coreclr/jit/instrsarm64.h +++ b/src/coreclr/jit/instrsarm64.h @@ -18,7 +18,7 @@ * e8 -- encoding 8 * e9 -- encoding 9 * -******************************************************************************/ + ******************************************************************************/ #if !defined(TARGET_ARM64) #error Unexpected target type diff --git a/src/coreclr/jit/instrsloongarch64.h b/src/coreclr/jit/instrsloongarch64.h index 4f94516c5fb91d..3794d91e02e388 100644 --- a/src/coreclr/jit/instrsloongarch64.h +++ b/src/coreclr/jit/instrsloongarch64.h @@ -11,7 +11,7 @@ * mask -- instruction's mask * fmt -- disasmbly format * -******************************************************************************/ + ******************************************************************************/ #if !defined(TARGET_LOONGARCH64) #error Unexpected target type diff --git a/src/coreclr/jit/instrsxarch.h b/src/coreclr/jit/instrsxarch.h index 17443cb9784927..440cc0033c82f9 100644 --- a/src/coreclr/jit/instrsxarch.h +++ b/src/coreclr/jit/instrsxarch.h @@ -18,7 +18,7 @@ * tt -- the tupletype for the instruction * flags -- flags, see INS_FLAGS_* enum * -******************************************************************************/ + ******************************************************************************/ // clang-format off #if !defined(TARGET_XARCH) diff --git a/src/coreclr/jit/jit.h b/src/coreclr/jit/jit.h index 1df8c034d0c1df..c0983e4da79f32 100644 --- a/src/coreclr/jit/jit.h +++ b/src/coreclr/jit/jit.h @@ -26,8 +26,9 @@ #define ZERO 0 #ifdef _MSC_VER -#define CHECK_STRUCT_PADDING 0 // Set this to '1' to enable warning C4820 "'bytes' bytes padding added after - // construct 'member_name'" on interesting structs/classes +#define CHECK_STRUCT_PADDING \ + 0 // Set this to '1' to enable warning C4820 "'bytes' bytes padding added after + // construct 'member_name'" on interesting structs/classes #else #define CHECK_STRUCT_PADDING 0 // Never enable it for non-MSFT compilers #endif @@ -487,17 +488,20 @@ class GlobalJitOptions #define VERIFY_GC_TABLES 0 #define REARRANGE_ADDS 1 -#define FUNC_INFO_LOGGING 1 // Support dumping function info to a file. In retail, only NYIs, with no function name, - // are dumped. +#define FUNC_INFO_LOGGING \ + 1 // Support dumping function info to a file. In retail, only NYIs, with no function name, + // are dumped. /*****************************************************************************/ /*****************************************************************************/ /* Set these to 1 to collect and output various statistics about the JIT */ -#define CALL_ARG_STATS 0 // Collect stats about calls and call arguments. -#define COUNT_BASIC_BLOCKS 0 // Create a histogram of basic block sizes, and a histogram of IL sizes in the simple - // case of single block methods. -#define COUNT_LOOPS 0 // Collect stats about loops, such as the total number of natural loops, a histogram of +#define CALL_ARG_STATS 0 // Collect stats about calls and call arguments. +#define COUNT_BASIC_BLOCKS \ + 0 // Create a histogram of basic block sizes, and a histogram of IL sizes in the simple + // case of single block methods. +#define COUNT_LOOPS \ + 0 // Collect stats about loops, such as the total number of natural loops, a histogram of // the number of loop exits, etc. #define DISPLAY_SIZES 0 // Display generated code, data, and GC information sizes. #define MEASURE_BLOCK_SIZE 0 // Collect stats about basic block and FlowEdge node sizes and memory allocations. @@ -628,8 +632,9 @@ const bool dspGCtbls = true; */ #ifdef TARGET_X86 -#define DOUBLE_ALIGN 1 // permit the double alignment of ESP in prolog, - // and permit the double alignment of local offsets +#define DOUBLE_ALIGN \ + 1 // permit the double alignment of ESP in prolog, + // and permit the double alignment of local offsets #else #define DOUBLE_ALIGN 0 // no special handling for double alignment #endif @@ -673,7 +678,7 @@ inline bool IsUninitialized(T data); #define MISALIGNED_RD_U2(src) (*castto(src, unsigned short*)) #define MISALIGNED_WR_I2(dst, val) *castto(dst, short*) = val; -#define MISALIGNED_WR_I4(dst, val) *castto(dst, int*) = val; +#define MISALIGNED_WR_I4(dst, val) *castto(dst, int*) = val; #define MISALIGNED_WR_ST(dst, val) *castto(dst, ssize_t*) = val; @@ -813,7 +818,7 @@ class JitTls #endif static Compiler* GetCompiler(); - static void SetCompiler(Compiler* compiler); + static void SetCompiler(Compiler* compiler); }; #if defined(DEBUG) diff --git a/src/coreclr/jit/jitconfig.cpp b/src/coreclr/jit/jitconfig.cpp index 3c85031cee6cda..89030c8541f07a 100644 --- a/src/coreclr/jit/jitconfig.cpp +++ b/src/coreclr/jit/jitconfig.cpp @@ -36,7 +36,8 @@ void JitConfigValues::MethodSet::initialize(const WCHAR* list, ICorJitHost* host } } - auto commitPattern = [this, host](const char* start, const char* end) { + auto commitPattern = [this, host](const char* start, const char* end) + { if (end <= start) { return; @@ -163,15 +164,17 @@ bool JitConfigValues::MethodSet::contains(CORINFO_METHOD_HANDLE methodHnd, (name->m_containsSignature != prevPattern->m_containsSignature)) { printer.Truncate(0); - bool success = comp->eeRunFunctorWithSPMIErrorTrap([&]() { - comp->eePrintMethod(&printer, name->m_containsClassName ? classHnd : NO_CLASS_HANDLE, methodHnd, - sigInfo, - /* includeClassInstantiation */ name->m_classNameContainsInstantiation, - /* includeMethodInstantiation */ name->m_methodNameContainsInstantiation, - /* includeSignature */ name->m_containsSignature, - /* includeReturnType */ false, - /* includeThis */ false); - }); + bool success = comp->eeRunFunctorWithSPMIErrorTrap( + [&]() + { + comp->eePrintMethod(&printer, name->m_containsClassName ? classHnd : NO_CLASS_HANDLE, methodHnd, + sigInfo, + /* includeClassInstantiation */ name->m_classNameContainsInstantiation, + /* includeMethodInstantiation */ name->m_methodNameContainsInstantiation, + /* includeSignature */ name->m_containsSignature, + /* includeReturnType */ false, + /* includeThis */ false); + }); if (!success) continue; diff --git a/src/coreclr/jit/jitconfig.h b/src/coreclr/jit/jitconfig.h index e19021cd52f22b..5e1b8f1505db33 100644 --- a/src/coreclr/jit/jitconfig.h +++ b/src/coreclr/jit/jitconfig.h @@ -31,13 +31,11 @@ class JitConfigValues char* m_list; MethodName* m_names; - MethodSet(const MethodSet& other) = delete; + MethodSet(const MethodSet& other) = delete; MethodSet& operator=(const MethodSet& other) = delete; public: - MethodSet() - { - } + MethodSet() {} inline const char* list() const { @@ -81,13 +79,11 @@ class JitConfigValues private: bool m_isInitialized; - JitConfigValues(const JitConfigValues& other) = delete; + JitConfigValues(const JitConfigValues& other) = delete; JitConfigValues& operator=(const JitConfigValues& other) = delete; public: - JitConfigValues() - { - } + JitConfigValues() {} inline bool isInitialized() const { diff --git a/src/coreclr/jit/jiteh.cpp b/src/coreclr/jit/jiteh.cpp index 75749e50fbd3bc..fc12d55c35a468 100644 --- a/src/coreclr/jit/jiteh.cpp +++ b/src/coreclr/jit/jiteh.cpp @@ -1718,7 +1718,7 @@ void Compiler::fgSortEHTable() (hndBegOff >= xtab1->ebdHndBegOffset && hndEndOff <= xtab1->ebdHndEndOffset) || (xtab1->HasFilter() && (hndBegOff >= xtab1->ebdFilterBegOffset && hndEndOff <= xtab1->ebdHndBegOffset)) // Note that end of filter is beginning of handler - ) + ) { #ifdef DEBUG if (verbose) @@ -2082,7 +2082,7 @@ bool Compiler::fgNormalizeEHCase2() if (ehOuter->ebdIsSameTry(mutualTryBeg, mutualTryLast)) { -// clang-format off + // clang-format off // Don't touch mutually-protect regions: their 'try' regions must remain identical! // We want to continue the looping outwards, in case we have something like this: // @@ -2131,7 +2131,7 @@ bool Compiler::fgNormalizeEHCase2() // // In this case, all the 'try' start at the same block! Note that there are two sets of mutually-protect regions, // separated by some nesting. -// clang-format on + // clang-format on #ifdef DEBUG if (verbose) @@ -2361,7 +2361,7 @@ bool Compiler::fgCreateFiltersForGenericExceptions() { GenTree* ctxTree = getRuntimeContextTree(embedInfo.lookup.lookupKind.runtimeLookupKind); runtimeLookup = impReadyToRunHelperToTree(&resolvedToken, CORINFO_HELP_READYTORUN_GENERIC_HANDLE, - TYP_I_IMPL, &embedInfo.lookup.lookupKind, ctxTree); + TYP_I_IMPL, &embedInfo.lookup.lookupKind, ctxTree); } else { @@ -3026,8 +3026,8 @@ void Compiler::fgVerifyHandlerTab() assert(blockNumMap[block->bbNum] == 0); // If this fails, we have two blocks with the same block number. blockNumMap[block->bbNum] = newBBnum++; } -// Note that there may be some blockNumMap[x] == 0, for a block number 'x' that has been deleted, if the blocks -// haven't been renumbered since the deletion. + // Note that there may be some blockNumMap[x] == 0, for a block number 'x' that has been deleted, if the blocks + // haven't been renumbered since the deletion. #if 0 // Useful for debugging, but don't want to put this in the dump all the time if (verbose) @@ -3274,9 +3274,9 @@ void Compiler::fgVerifyHandlerTab() assert(bbNumOuterHndLast != 0); assert(bbNumOuterHndBeg <= bbNumOuterHndLast); -// The outer handler must completely contain all the blocks in the EH region nested within it. However, if -// funclets have been created, it's harder to make any relationship asserts about the order of nested -// handlers, which also have been made into funclets. + // The outer handler must completely contain all the blocks in the EH region nested within it. However, if + // funclets have been created, it's harder to make any relationship asserts about the order of nested + // handlers, which also have been made into funclets. #if defined(FEATURE_EH_FUNCLETS) if (fgFuncletsCreated) @@ -4339,7 +4339,7 @@ void Compiler::fgExtendEHRegionBefore(BasicBlock* block) bFilterLast->bbNum, bPrev->bbNum); } #endif // DEBUG - // Change the target for bFilterLast from the old first 'block' to the new first 'bPrev' + // Change the target for bFilterLast from the old first 'block' to the new first 'bPrev' fgRedirectTargetEdge(bFilterLast, bPrev); } } diff --git a/src/coreclr/jit/jiteh.h b/src/coreclr/jit/jiteh.h index 95ae62527897ba..55b56ac9833c42 100644 --- a/src/coreclr/jit/jiteh.h +++ b/src/coreclr/jit/jiteh.h @@ -83,7 +83,8 @@ struct EHblkDsc BasicBlock* ebdTryLast; // Last block of the try BasicBlock* ebdHndBeg; // First block of the handler BasicBlock* ebdHndLast; // Last block of the handler - union { + union + { BasicBlock* ebdFilter; // First block of filter, if HasFilter() unsigned ebdTyp; // Exception type (a class token), otherwise }; @@ -165,8 +166,8 @@ struct EHblkDsc unsigned ebdGetEnclosingRegionIndex(bool* inTryRegion); static bool ebdIsSameTry(EHblkDsc* h1, EHblkDsc* h2); // Same 'try' region? Compare begin/last blocks. - bool ebdIsSameTry(Compiler* comp, unsigned t2); - bool ebdIsSameTry(BasicBlock* ebdTryBeg, BasicBlock* ebdTryLast); + bool ebdIsSameTry(Compiler* comp, unsigned t2); + bool ebdIsSameTry(BasicBlock* ebdTryBeg, BasicBlock* ebdTryLast); #ifdef DEBUG void DispEntry(unsigned num); // Display this table entry diff --git a/src/coreclr/jit/jitexpandarray.h b/src/coreclr/jit/jitexpandarray.h index 646f9e6747a3be..522ba841d6dab2 100644 --- a/src/coreclr/jit/jitexpandarray.h +++ b/src/coreclr/jit/jitexpandarray.h @@ -219,9 +219,7 @@ class JitExpandArrayStack : public JitExpandArray // Notes: // See JitExpandArray constructor notes. // - JitExpandArrayStack(CompAllocator alloc, unsigned minSize = 1) : JitExpandArray(alloc, minSize), m_used(0) - { - } + JitExpandArrayStack(CompAllocator alloc, unsigned minSize = 1) : JitExpandArray(alloc, minSize), m_used(0) {} //------------------------------------------------------------------------ // GetRef: Get a reference to the element at index `idx`. diff --git a/src/coreclr/jit/jitgcinfo.h b/src/coreclr/jit/jitgcinfo.h index b73e8fbc68773a..087e55e461ef54 100644 --- a/src/coreclr/jit/jitgcinfo.h +++ b/src/coreclr/jit/jitgcinfo.h @@ -23,9 +23,7 @@ struct RegSlotIdKey unsigned short m_regNum; unsigned short m_flags; - RegSlotIdKey() - { - } + RegSlotIdKey() {} RegSlotIdKey(unsigned short regNum, unsigned flags) : m_regNum(regNum), m_flags((unsigned short)flags) { @@ -49,9 +47,7 @@ struct StackSlotIdKey bool m_fpRel; unsigned short m_flags; - StackSlotIdKey() - { - } + StackSlotIdKey() {} StackSlotIdKey(int offset, bool fpRel, unsigned flags) : m_offset(offset), m_fpRel(fpRel), m_flags((unsigned short)flags) @@ -261,7 +257,8 @@ class GCInfo unsigned short cdArgCnt; - union { + union + { struct // used if cdArgCnt == 0 { unsigned cdArgMask; // ptr arg bitfield @@ -278,7 +275,7 @@ class GCInfo CallDsc* gcCallDescList; CallDsc* gcCallDescLast; -//------------------------------------------------------------------------- + //------------------------------------------------------------------------- #ifdef JIT32_GCENCODER void gcCountForHeader(UNALIGNED unsigned int* pUntrackedCount, UNALIGNED unsigned int* pVarPtrTableSize); @@ -303,7 +300,7 @@ class GCInfo #ifdef JIT32_GCENCODER size_t gcPtrTableSize(const InfoHdr& header, unsigned codeSize, size_t* pArgTabOffset); - BYTE* gcPtrTableSave(BYTE* destPtr, const InfoHdr& header, unsigned codeSize, size_t* pArgTabOffset); + BYTE* gcPtrTableSave(BYTE* destPtr, const InfoHdr& header, unsigned codeSize, size_t* pArgTabOffset); #endif void gcRegPtrSetInit(); /*****************************************************************************/ @@ -382,7 +379,7 @@ class GCInfo #ifdef JIT32_GCENCODER size_t gcInfoBlockHdrDump(const BYTE* table, - InfoHdr* header, /* OUT */ + InfoHdr* header, /* OUT */ unsigned* methodSize); /* OUT */ size_t gcDumpPtrTable(const BYTE* table, const InfoHdr& header, unsigned methodSize); diff --git a/src/coreclr/jit/jithashtable.h b/src/coreclr/jit/jithashtable.h index 9ad73dbf2f7d51..4857b70b12acc2 100644 --- a/src/coreclr/jit/jithashtable.h +++ b/src/coreclr/jit/jithashtable.h @@ -57,12 +57,8 @@ class JitHashTableBehavior class JitPrimeInfo { public: - constexpr JitPrimeInfo() : prime(0), magic(0), shift(0) - { - } - constexpr JitPrimeInfo(unsigned p, unsigned m, unsigned s) : prime(p), magic(m), shift(s) - { - } + constexpr JitPrimeInfo() : prime(0), magic(0), shift(0) {} + constexpr JitPrimeInfo(unsigned p, unsigned m, unsigned s) : prime(p), magic(m), shift(s) {} unsigned prime; unsigned magic; unsigned shift; @@ -492,9 +488,7 @@ class JitHashTable class KeyIterator : public NodeIterator { public: - KeyIterator(const JitHashTable* hash, bool begin) : NodeIterator(hash, begin) - { - } + KeyIterator(const JitHashTable* hash, bool begin) : NodeIterator(hash, begin) {} Key operator*() const { @@ -506,9 +500,7 @@ class JitHashTable class ValueIterator : public NodeIterator { public: - ValueIterator(const JitHashTable* hash, bool begin) : NodeIterator(hash, begin) - { - } + ValueIterator(const JitHashTable* hash, bool begin) : NodeIterator(hash, begin) {} Value operator*() const { @@ -521,9 +513,7 @@ class JitHashTable class KeyValueIterator : public NodeIterator { public: - KeyValueIterator(const JitHashTable* hash, bool begin) : NodeIterator(hash, begin) - { - } + KeyValueIterator(const JitHashTable* hash, bool begin) : NodeIterator(hash, begin) {} // We could return a new struct, but why bother copying data? Node* operator*() const @@ -538,9 +528,7 @@ class JitHashTable const JitHashTable* const m_hash; public: - KeyIteration(const JitHashTable* hash) : m_hash(hash) - { - } + KeyIteration(const JitHashTable* hash) : m_hash(hash) {} KeyIterator begin() const { @@ -559,9 +547,7 @@ class JitHashTable const JitHashTable* const m_hash; public: - ValueIteration(const JitHashTable* hash) : m_hash(hash) - { - } + ValueIteration(const JitHashTable* hash) : m_hash(hash) {} ValueIterator begin() const { @@ -580,9 +566,7 @@ class JitHashTable const JitHashTable* const m_hash; public: - KeyValueIteration(const JitHashTable* hash) : m_hash(hash) - { - } + KeyValueIteration(const JitHashTable* hash) : m_hash(hash) {} KeyValueIterator begin() const { diff --git a/src/coreclr/jit/layout.cpp b/src/coreclr/jit/layout.cpp index 918fd4ab6521d4..5ceed557d9ee99 100644 --- a/src/coreclr/jit/layout.cpp +++ b/src/coreclr/jit/layout.cpp @@ -21,7 +21,8 @@ class ClassLayoutTable typedef JitHashTable, unsigned> BlkLayoutIndexMap; typedef JitHashTable, unsigned> ObjLayoutIndexMap; - union { + union + { // Up to 3 layouts can be stored "inline" and finding a layout by handle/size can be done using linear search. // Most methods need no more than 2 layouts. ClassLayout* m_layoutArray[3]; @@ -43,9 +44,7 @@ class ClassLayoutTable ClassLayout m_zeroSizedBlockLayout; public: - ClassLayoutTable() : m_layoutCount(0), m_layoutLargeCapacity(0), m_zeroSizedBlockLayout(0) - { - } + ClassLayoutTable() : m_layoutCount(0), m_layoutLargeCapacity(0), m_zeroSizedBlockLayout(0) {} // Get a number that uniquely identifies the specified layout. unsigned GetLayoutNum(ClassLayout* layout) const diff --git a/src/coreclr/jit/layout.h b/src/coreclr/jit/layout.h index 59ecaa9405485d..3c6487e516b91c 100644 --- a/src/coreclr/jit/layout.h +++ b/src/coreclr/jit/layout.h @@ -30,7 +30,8 @@ class ClassLayout // Array of CorInfoGCType (as BYTE) that describes the GC layout of the class. // For small classes the array is stored inline, avoiding an extra allocation // and the pointer size overhead. - union { + union + { BYTE* m_gcPtrs; BYTE m_gcPtrsArray[sizeof(BYTE*)]; }; @@ -69,7 +70,7 @@ class ClassLayout ClassLayout(CORINFO_CLASS_HANDLE classHandle, bool isValueClass, unsigned size, - var_types type DEBUGARG(const char* className) DEBUGARG(const char* shortClassName)) + var_types type DEBUGARG(const char* className) DEBUGARG(const char* shortClassName)) : m_classHandle(classHandle) , m_size(size) , m_isValueClass(isValueClass) diff --git a/src/coreclr/jit/lclmorph.cpp b/src/coreclr/jit/lclmorph.cpp index 44b0afe1caf927..983d89e9c83196 100644 --- a/src/coreclr/jit/lclmorph.cpp +++ b/src/coreclr/jit/lclmorph.cpp @@ -14,9 +14,7 @@ class LocalSequencer final : public GenTreeVisitor UseExecutionOrder = true, }; - LocalSequencer(Compiler* comp) : GenTreeVisitor(comp), m_prevNode(nullptr) - { - } + LocalSequencer(Compiler* comp) : GenTreeVisitor(comp), m_prevNode(nullptr) {} //------------------------------------------------------------------- // Start: Start sequencing a statement. Must be called before other members @@ -918,9 +916,9 @@ class LocalAddressVisitor final : public GenTreeVisitor break; #ifdef FEATURE_HW_INTRINSICS - // We have two cases we want to handle: - // 1. Vector2/3/4 and Quaternion where we have 4x float fields - // 2. Plane where we have 1x Vector3 and 1x float field + // We have two cases we want to handle: + // 1. Vector2/3/4 and Quaternion where we have 4x float fields + // 2. Plane where we have 1x Vector3 and 1x float field case IndirTransform::GetElement: { @@ -934,7 +932,7 @@ class LocalAddressVisitor final : public GenTreeVisitor { GenTree* indexNode = m_compiler->gtNewIconNode(offset / genTypeSize(elementType)); hwiNode = m_compiler->gtNewSimdGetElementNode(elementType, lclNode, indexNode, - CORINFO_TYPE_FLOAT, genTypeSize(varDsc)); + CORINFO_TYPE_FLOAT, genTypeSize(varDsc)); break; } case TYP_SIMD12: diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index 50997980ca7488..bad0fdf5e7c35c 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -332,9 +332,9 @@ void Compiler::lvaInitTypeRef() } if ( // If there already exist unsafe buffers, don't mark more structs as unsafe - // as that will cause them to be placed along with the real unsafe buffers, - // unnecessarily exposing them to overruns. This can affect GS tests which - // intentionally do buffer-overruns. + // as that will cause them to be placed along with the real unsafe buffers, + // unnecessarily exposing them to overruns. This can affect GS tests which + // intentionally do buffer-overruns. !getNeedsGSSecurityCookie() && // GS checks require the stack to be re-ordered, which can't be done with EnC !opts.compDbgEnC && compStressCompile(STRESS_UNSAFE_BUFFER_CHECKS, 25)) @@ -440,7 +440,7 @@ void Compiler::lvaInitArgs(InitVarDscInfo* varDscInfo) lvaInitRetBuffArg(varDscInfo, true); } -//====================================================================== + //====================================================================== #if USER_ARGS_COME_LAST //@GENERICS: final instantiation-info argument for shared generic methods @@ -602,9 +602,9 @@ void Compiler::lvaInitRetBuffArg(InitVarDscInfo* varDscInfo, bool useFixedRetBuf // void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo, unsigned skipArgs, unsigned takeArgs) { -//------------------------------------------------------------------------- -// Walk the function signature for the explicit arguments -//------------------------------------------------------------------------- + //------------------------------------------------------------------------- + // Walk the function signature for the explicit arguments + //------------------------------------------------------------------------- #if defined(TARGET_X86) // Only (some of) the implicit args are enregistered for varargs @@ -1319,8 +1319,8 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo, unsigned skipArgs, un #if defined(TARGET_X86) varDsc->SetStackOffset(compArgSize); #else // !TARGET_X86 - // TODO-CQ: We shouldn't have to go as far as to declare these - // address-exposed -- DoNotEnregister should suffice. + // TODO-CQ: We shouldn't have to go as far as to declare these + // address-exposed -- DoNotEnregister should suffice. lvaSetVarAddrExposed(varDscInfo->varNum DEBUGARG(AddressExposedReason::TOO_CONSERVATIVE)); #endif // !TARGET_X86 @@ -2505,12 +2505,12 @@ bool Compiler::StructPromotionHelper::ShouldPromoteStructVar(unsigned lclNum) // with something else occupying the same 4-byte slot, it will // overwrite other fields. if (structPromotionInfo.fieldCnt != 1) - { - JITDUMP("Not promoting promotable struct local V%02u, because lvIsParam is true and #fields = " - "%d.\n", - lclNum, structPromotionInfo.fieldCnt); - shouldPromote = false; - } + { + JITDUMP("Not promoting promotable struct local V%02u, because lvIsParam is true and #fields = " + "%d.\n", + lclNum, structPromotionInfo.fieldCnt); + shouldPromote = false; + } } else if ((lclNum == compiler->genReturnLocal) && (structPromotionInfo.fieldCnt > 1)) { @@ -2548,9 +2548,8 @@ void Compiler::StructPromotionHelper::SortStructFields() if (!structPromotionInfo.fieldsSorted) { jitstd::sort(structPromotionInfo.fields, structPromotionInfo.fields + structPromotionInfo.fieldCnt, - [](const lvaStructFieldInfo& lhs, const lvaStructFieldInfo& rhs) { - return lhs.fldOffset < rhs.fldOffset; - }); + [](const lvaStructFieldInfo& lhs, const lvaStructFieldInfo& rhs) + { return lhs.fldOffset < rhs.fldOffset; }); structPromotionInfo.fieldsSorted = true; } } @@ -2605,7 +2604,7 @@ void Compiler::StructPromotionHelper::PromoteStructVar(unsigned lclNum) compiler->compFloatingPointUsed = true; } -// Now grab the temp for the field local. + // Now grab the temp for the field local. #ifdef DEBUG char fieldNameBuffer[128]; @@ -3251,7 +3250,8 @@ void Compiler::makeExtraStructQueries(CORINFO_CLASS_HANDLE structHandle, int lev #endif // In a lambda since this requires a lot of stack and this function is recursive. - auto queryLayout = [this, structHandle]() { + auto queryLayout = [this, structHandle]() + { CORINFO_TYPE_LAYOUT_NODE nodes[256]; size_t numNodes = ArrLen(nodes); info.compCompHnd->getTypeLayout(structHandle, nodes, &numNodes); @@ -3809,8 +3809,8 @@ void Compiler::lvaSortByRefCount() if (varDsc->IsAddressExposed()) { varDsc->lvTracked = 0; - assert(varDsc->lvType != TYP_STRUCT || - varDsc->lvDoNotEnregister); // For structs, should have set this when we set m_addrExposed. + assert(varDsc->lvType != TYP_STRUCT || varDsc->lvDoNotEnregister); // For structs, should have set this when + // we set m_addrExposed. } if (varTypeIsStruct(varDsc)) { @@ -4042,8 +4042,8 @@ unsigned LclVarDsc::lvSize() const // Size needed for storage representation. On } /********************************************************************************** -* Get stack size of the varDsc. -*/ + * Get stack size of the varDsc. + */ size_t LclVarDsc::lvArgStackSize() const { // Make sure this will have a stack size @@ -4888,11 +4888,11 @@ inline void Compiler::lvaIncrementFrameSize(unsigned size) } /**************************************************************************** -* -* Return true if absolute offsets of temps are larger than vars, or in other -* words, did we allocate temps before of after vars. The /GS buffer overrun -* checks want temps to be at low stack addresses than buffers -*/ + * + * Return true if absolute offsets of temps are larger than vars, or in other + * words, did we allocate temps before of after vars. The /GS buffer overrun + * checks want temps to be at low stack addresses than buffers + */ bool Compiler::lvaTempsHaveLargerOffsetThanVars() { #ifdef TARGET_ARM @@ -4911,10 +4911,10 @@ bool Compiler::lvaTempsHaveLargerOffsetThanVars() } /**************************************************************************** -* -* Return an upper bound estimate for the size of the compiler spill temps -* -*/ + * + * Return an upper bound estimate for the size of the compiler spill temps + * + */ unsigned Compiler::lvaGetMaxSpillTempSize() { unsigned result = 0; @@ -5531,7 +5531,7 @@ void Compiler::lvaFixVirtualFrameOffsets() #endif ) #endif // !defined(TARGET_AMD64) - ) + ) { doAssignStkOffs = false; // Not on frame or an incoming stack arg } @@ -5552,8 +5552,8 @@ void Compiler::lvaFixVirtualFrameOffsets() // We need to re-adjust the offsets of the parameters so they are EBP // relative rather than stack/frame pointer relative - varDsc->SetStackOffset(varDsc->GetStackOffset() + - (2 * TARGET_POINTER_SIZE)); // return address and pushed EBP + varDsc->SetStackOffset(varDsc->GetStackOffset() + (2 * TARGET_POINTER_SIZE)); // return address and + // pushed EBP noway_assert(varDsc->GetStackOffset() >= FIRST_ARG_STACK_OFFS); } @@ -5731,7 +5731,7 @@ void Compiler::lvaAssignVirtualFrameOffsetsToArgs() argOffs = lvaAssignVirtualFrameOffsetToArg(lclNum, REGSIZE_BYTES, argOffs); } #elif !defined(UNIX_AMD64_ABI) - argOffs = lvaAssignVirtualFrameOffsetToArg(lclNum, REGSIZE_BYTES, argOffs); + argOffs = lvaAssignVirtualFrameOffsetToArg(lclNum, REGSIZE_BYTES, argOffs); #endif // TARGET_X86 lclNum++; userArgsToSkip++; @@ -5892,8 +5892,8 @@ void Compiler::lvaAssignVirtualFrameOffsetsToArgs() // ret address slot, stack frame padding, alloca instructions, etc. // Note: This is the implementation for UNIX_AMD64 System V platforms. // -int Compiler::lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, - unsigned argSize, +int Compiler::lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, + unsigned argSize, int argOffs UNIX_AMD64_ABI_ONLY_ARG(int* callerArgOffset)) { noway_assert(lclNum < info.compArgsCount); @@ -5984,8 +5984,8 @@ int Compiler::lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, // The final offset is calculated in lvaFixVirtualFrameOffsets method. It accounts for FP existence, // ret address slot, stack frame padding, alloca instructions, etc. // Note: This implementation for all the platforms but UNIX_AMD64 OSs (System V 64 bit.) -int Compiler::lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, - unsigned argSize, +int Compiler::lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, + unsigned argSize, int argOffs UNIX_AMD64_ABI_ONLY_ARG(int* callerArgOffset)) { noway_assert(lclNum < info.compArgsCount); @@ -6213,8 +6213,8 @@ int Compiler::lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, (codeGen->regSet.rsMaskPreSpillAlign & genRegMask(REG_ARG_LAST)); noway_assert(cond); - noway_assert(sizeofPreSpillRegArgs <= - argOffs + TARGET_POINTER_SIZE); // at most one register of alignment + noway_assert(sizeofPreSpillRegArgs <= argOffs + TARGET_POINTER_SIZE); // at most one register of + // alignment } argOffs = sizeofPreSpillRegArgs; } @@ -6385,8 +6385,8 @@ void Compiler::lvaAssignVirtualFrameOffsetsToLocals() stkOffs -= initialStkOffs; } - if (codeGen->IsSaveFpLrWithAllCalleeSavedRegisters() || - !isFramePointerUsed()) // Note that currently we always have a frame pointer + if (codeGen->IsSaveFpLrWithAllCalleeSavedRegisters() || !isFramePointerUsed()) // Note that currently we always have + // a frame pointer { stkOffs -= compCalleeRegsPushed * REGSIZE_BYTES; } @@ -7126,8 +7126,8 @@ void Compiler::lvaAssignVirtualFrameOffsetsToLocals() #endif // FEATURE_EH_FUNCLETS && defined(TARGET_AMD64) #ifdef TARGET_ARM64 - if (!codeGen->IsSaveFpLrWithAllCalleeSavedRegisters() && - isFramePointerUsed()) // Note that currently we always have a frame pointer + if (!codeGen->IsSaveFpLrWithAllCalleeSavedRegisters() && isFramePointerUsed()) // Note that currently we always have + // a frame pointer { // Create space for saving FP and LR. stkOffs -= 2 * REGSIZE_BYTES; @@ -7412,9 +7412,9 @@ void Compiler::lvaAlignFrame() } // Align the stack with STACK_ALIGN value. - int adjustFrameSize = compLclFrameSize; + int adjustFrameSize = compLclFrameSize; #if defined(UNIX_X86_ABI) - bool isEbpPushed = codeGen->isFramePointerUsed(); + bool isEbpPushed = codeGen->isFramePointerUsed(); #if DOUBLE_ALIGN isEbpPushed |= genDoubleAlign(); #endif @@ -7892,9 +7892,9 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r } /***************************************************************************** -* -* dump the lvaTable -*/ + * + * dump the lvaTable + */ void Compiler::lvaTableDump(FrameLayoutState curState) { diff --git a/src/coreclr/jit/likelyclass.cpp b/src/coreclr/jit/likelyclass.cpp index fa0839725c9fb7..b1677bd93a3cce 100644 --- a/src/coreclr/jit/likelyclass.cpp +++ b/src/coreclr/jit/likelyclass.cpp @@ -254,9 +254,8 @@ static unsigned getLikelyClassesOrMethods(LikelyClassMethodRecord* // sort by m_count (descending) jitstd::sort(sortedEntries, sortedEntries + knownHandles, [](const LikelyClassMethodHistogramEntry& h1, - const LikelyClassMethodHistogramEntry& h2) -> bool { - return h1.m_count > h2.m_count; - }); + const LikelyClassMethodHistogramEntry& h2) -> bool + { return h1.m_count > h2.m_count; }); const UINT32 numberOfClasses = min(knownHandles, maxLikelyClasses); diff --git a/src/coreclr/jit/lir.cpp b/src/coreclr/jit/lir.cpp index b10bd98ff6221c..81b24cd7455ad5 100644 --- a/src/coreclr/jit/lir.cpp +++ b/src/coreclr/jit/lir.cpp @@ -9,9 +9,7 @@ #pragma hdrstop #endif -LIR::Use::Use() : m_range(nullptr), m_edge(nullptr), m_user(nullptr) -{ -} +LIR::Use::Use() : m_range(nullptr), m_edge(nullptr), m_user(nullptr) {} LIR::Use::Use(const Use& other) { @@ -280,9 +278,7 @@ unsigned LIR::Use::ReplaceWithLclVar(Compiler* compiler, unsigned lclNum, GenTre return lclNum; } -LIR::ReadOnlyRange::ReadOnlyRange() : m_firstNode(nullptr), m_lastNode(nullptr) -{ -} +LIR::ReadOnlyRange::ReadOnlyRange() : m_firstNode(nullptr), m_lastNode(nullptr) {} LIR::ReadOnlyRange::ReadOnlyRange(ReadOnlyRange&& other) : m_firstNode(other.m_firstNode), m_lastNode(other.m_lastNode) { @@ -426,13 +422,9 @@ bool LIR::ReadOnlyRange::Contains(GenTree* node) const #endif -LIR::Range::Range() : ReadOnlyRange() -{ -} +LIR::Range::Range() : ReadOnlyRange() {} -LIR::Range::Range(Range&& other) : ReadOnlyRange(std::move(other)) -{ -} +LIR::Range::Range(Range&& other) : ReadOnlyRange(std::move(other)) {} //------------------------------------------------------------------------ // LIR::Range::Range: Creates a `Range` value given the first and last @@ -442,9 +434,7 @@ LIR::Range::Range(Range&& other) : ReadOnlyRange(std::move(other)) // firstNode - The first node in the range. // lastNode - The last node in the range. // -LIR::Range::Range(GenTree* firstNode, GenTree* lastNode) : ReadOnlyRange(firstNode, lastNode) -{ -} +LIR::Range::Range(GenTree* firstNode, GenTree* lastNode) : ReadOnlyRange(firstNode, lastNode) {} //------------------------------------------------------------------------ // LIR::Range::FirstNonCatchArgNode: Returns the first node after all catch arg nodes in this range. @@ -925,14 +915,16 @@ void LIR::Range::Remove(GenTree* node, bool markOperandsUnused) if (markOperandsUnused) { - node->VisitOperands([](GenTree* operand) -> GenTree::VisitResult { - // The operand of JTRUE does not produce a value (just sets the flags). - if (operand->IsValue()) + node->VisitOperands( + [](GenTree* operand) -> GenTree::VisitResult { - operand->SetUnusedValue(); - } - return GenTree::VisitResult::Continue; - }); + // The operand of JTRUE does not produce a value (just sets the flags). + if (operand->IsValue()) + { + operand->SetUnusedValue(); + } + return GenTree::VisitResult::Continue; + }); } GenTree* prev = node->gtPrev; @@ -1186,7 +1178,7 @@ bool LIR::Range::TryGetUse(GenTree* node, Use* use) // Returns: // The computed subrange. // -template +template LIR::ReadOnlyRange LIR::Range::GetMarkedRange(unsigned markCount, GenTree* start, bool* isClosed, @@ -1218,11 +1210,13 @@ LIR::ReadOnlyRange LIR::Range::GetMarkedRange(unsigned markCount, } // Mark the node's operands - firstNode->VisitOperands([&markCount](GenTree* operand) -> GenTree::VisitResult { - operand->gtLIRFlags |= LIR::Flags::Mark; - markCount++; - return GenTree::VisitResult::Continue; - }); + firstNode->VisitOperands( + [&markCount](GenTree* operand) -> GenTree::VisitResult + { + operand->gtLIRFlags |= LIR::Flags::Mark; + markCount++; + return GenTree::VisitResult::Continue; + }); if (markFlagsOperands && firstNode->OperConsumesFlags()) { @@ -1366,11 +1360,13 @@ LIR::ReadOnlyRange LIR::Range::GetRangeOfOperandTrees(GenTree* root, bool* isClo // Mark the root node's operands unsigned markCount = 0; - root->VisitOperands([&markCount](GenTree* operand) -> GenTree::VisitResult { - operand->gtLIRFlags |= LIR::Flags::Mark; - markCount++; - return GenTree::VisitResult::Continue; - }); + root->VisitOperands( + [&markCount](GenTree* operand) -> GenTree::VisitResult + { + operand->gtLIRFlags |= LIR::Flags::Mark; + markCount++; + return GenTree::VisitResult::Continue; + }); if (markCount == 0) { @@ -1406,8 +1402,8 @@ class CheckLclVarSemanticsHelper // range - a range to do the check. // unusedDefs - map of defs that do no have users. // - CheckLclVarSemanticsHelper(Compiler* compiler, - const LIR::Range* range, + CheckLclVarSemanticsHelper(Compiler* compiler, + const LIR::Range* range, SmallHashTable& unusedDefs) : compiler(compiler) , range(range) @@ -1554,7 +1550,7 @@ class CheckLclVarSemanticsHelper void PopLclVarRead(const AliasSet::NodeInfo& defInfo) { SmallHashTable* reads; - const bool foundReads = unusedLclVarReads.TryGetValue(defInfo.LclNum(), &reads); + const bool foundReads = unusedLclVarReads.TryGetValue(defInfo.LclNum(), &reads); assert(foundReads); bool found = reads->TryRemove(defInfo.Node()); @@ -1569,11 +1565,11 @@ class CheckLclVarSemanticsHelper } private: - Compiler* compiler; - const LIR::Range* range; - SmallHashTable& unusedDefs; + Compiler* compiler; + const LIR::Range* range; + SmallHashTable& unusedDefs; SmallHashTable*, 16U> unusedLclVarReads; - ArrayStack*> lclVarReadsMapsCache; + ArrayStack*> lclVarReadsMapsCache; }; //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/lir.h b/src/coreclr/jit/lir.h index 9b4f940bc0ae38..80c14f2c90d628 100644 --- a/src/coreclr/jit/lir.h +++ b/src/coreclr/jit/lir.h @@ -73,7 +73,7 @@ class LIR final void AssertIsValid() const; bool IsDummyUse() const; - void ReplaceWith(GenTree* replacement); + void ReplaceWith(GenTree* replacement); unsigned ReplaceWithLclVar(Compiler* compiler, unsigned lclNum = BAD_VAR_NUM, GenTree** pStore = nullptr); }; @@ -113,7 +113,7 @@ class LIR final GenTree* m_firstNode; GenTree* m_lastNode; - ReadOnlyRange(const ReadOnlyRange& other) = delete; + ReadOnlyRange(const ReadOnlyRange& other) = delete; ReadOnlyRange& operator=(const ReadOnlyRange& other) = delete; public: @@ -125,14 +125,10 @@ class LIR final GenTree* m_node; - Iterator(GenTree* begin) : m_node(begin) - { - } + Iterator(GenTree* begin) : m_node(begin) {} public: - Iterator() : m_node(nullptr) - { - } + Iterator() : m_node(nullptr) {} inline GenTree* operator*() { @@ -167,14 +163,10 @@ class LIR final GenTree* m_node; - ReverseIterator(GenTree* begin) : m_node(begin) - { - } + ReverseIterator(GenTree* begin) : m_node(begin) {} public: - ReverseIterator() : m_node(nullptr) - { - } + ReverseIterator() : m_node(nullptr) {} inline GenTree* operator*() { @@ -245,7 +237,7 @@ class LIR final private: Range(GenTree* firstNode, GenTree* lastNode); - Range(const Range& other) = delete; + Range(const Range& other) = delete; Range& operator=(const Range& other) = delete; template @@ -280,7 +272,7 @@ class LIR final void InsertAtBeginning(Range&& range); void InsertAtEnd(Range&& range); - void Remove(GenTree* node, bool markOperandsUnused = false); + void Remove(GenTree* node, bool markOperandsUnused = false); Range Remove(GenTree* firstNode, GenTree* lastNode); Range Remove(ReadOnlyRange&& range); @@ -303,7 +295,7 @@ class LIR final }; public: - static Range& AsRange(BasicBlock* block); + static Range& AsRange(BasicBlock* block); static const Range& AsRange(const BasicBlock* block); static Range EmptyRange(); diff --git a/src/coreclr/jit/liveness.cpp b/src/coreclr/jit/liveness.cpp index 78fb96fe3d77d2..697b8172231626 100644 --- a/src/coreclr/jit/liveness.cpp +++ b/src/coreclr/jit/liveness.cpp @@ -811,10 +811,10 @@ void Compiler::fgExtendDbgLifetimes() fgExtendDbgScopes(); -/*------------------------------------------------------------------------- - * Partly update liveness info so that we handle any funky BBF_INTERNAL - * blocks inserted out of sequence. - */ + /*------------------------------------------------------------------------- + * Partly update liveness info so that we handle any funky BBF_INTERNAL + * blocks inserted out of sequence. + */ #ifdef DEBUG if (verbose && 0) @@ -1005,7 +1005,7 @@ void Compiler::fgExtendDbgLifetimes() // So just ensure that they don't have a 0 ref cnt unsigned lclNum = 0; - for (LclVarDsc *varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++) + for (LclVarDsc* varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++) { if (lclNum >= info.compArgsCount) { @@ -1042,11 +1042,13 @@ void Compiler::fgAddHandlerLiveVars(BasicBlock* block, VARSET_TP& ehHandlerLiveV { assert(block->HasPotentialEHSuccs(this)); - block->VisitEHSuccs(this, [&](BasicBlock* succ) { - VarSetOps::UnionD(this, ehHandlerLiveVars, succ->bbLiveIn); - memoryLiveness |= succ->bbMemoryLiveIn; - return BasicBlockVisit::Continue; - }); + block->VisitEHSuccs(this, + [&](BasicBlock* succ) + { + VarSetOps::UnionD(this, ehHandlerLiveVars, succ->bbLiveIn); + memoryLiveness |= succ->bbMemoryLiveIn; + return BasicBlockVisit::Continue; + }); } class LiveVarAnalysis @@ -1117,16 +1119,18 @@ class LiveVarAnalysis // successors. EH successors need to be handled more conservatively // (their live-in state is live in this entire basic block). Those are // handled below. - block->VisitRegularSuccs(m_compiler, [=](BasicBlock* succ) { - VarSetOps::UnionD(m_compiler, m_liveOut, succ->bbLiveIn); - m_memoryLiveOut |= succ->bbMemoryLiveIn; - if (succ->bbNum <= block->bbNum) - { - m_hasPossibleBackEdge = true; - } - - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(m_compiler, + [=](BasicBlock* succ) + { + VarSetOps::UnionD(m_compiler, m_liveOut, succ->bbLiveIn); + m_memoryLiveOut |= succ->bbMemoryLiveIn; + if (succ->bbNum <= block->bbNum) + { + m_hasPossibleBackEdge = true; + } + + return BasicBlockVisit::Continue; + }); /* For lvaKeepAliveAndReportThis methods, "this" has to be kept alive everywhere Note that a function may end in a throw on an infinite loop (as opposed to a return). @@ -1676,10 +1680,10 @@ GenTree* Compiler::fgTryRemoveDeadStoreEarly(Statement* stmt, GenTreeLclVarCommo * or subtree of a statement moving backward from startNode to endNode */ -void Compiler::fgComputeLife(VARSET_TP& life, - GenTree* startNode, - GenTree* endNode, - VARSET_VALARG_TP volatileVars, +void Compiler::fgComputeLife(VARSET_TP& life, + GenTree* startNode, + GenTree* endNode, + VARSET_VALARG_TP volatileVars, bool* pStmtInfoDirty DEBUGARG(bool* treeModf)) { // Don't kill vars in scope @@ -1773,22 +1777,24 @@ void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALAR JITDUMP("Removing dead call:\n"); DISPNODE(call); - node->VisitOperands([](GenTree* operand) -> GenTree::VisitResult { - if (operand->IsValue()) + node->VisitOperands( + [](GenTree* operand) -> GenTree::VisitResult { - operand->SetUnusedValue(); - } + if (operand->IsValue()) + { + operand->SetUnusedValue(); + } - // Special-case PUTARG_STK: since this operator is not considered a value, DCE will not remove - // these nodes. - if (operand->OperIs(GT_PUTARG_STK)) - { - operand->AsPutArgStk()->gtOp1->SetUnusedValue(); - operand->gtBashToNOP(); - } + // Special-case PUTARG_STK: since this operator is not considered a value, DCE will not + // remove these nodes. + if (operand->OperIs(GT_PUTARG_STK)) + { + operand->AsPutArgStk()->gtOp1->SetUnusedValue(); + operand->gtBashToNOP(); + } - return GenTree::VisitResult::Continue; - }); + return GenTree::VisitResult::Continue; + }); blockRange.Remove(node); @@ -2048,10 +2054,12 @@ bool Compiler::fgTryRemoveNonLocal(GenTree* node, LIR::Range* blockRange) JITDUMP("Removing dead node:\n"); DISPNODE(node); - node->VisitOperands([](GenTree* operand) -> GenTree::VisitResult { - operand->SetUnusedValue(); - return GenTree::VisitResult::Continue; - }); + node->VisitOperands( + [](GenTree* operand) -> GenTree::VisitResult + { + operand->SetUnusedValue(); + return GenTree::VisitResult::Continue; + }); if (node->OperConsumesFlags() && node->gtPrev->gtSetFlags()) { @@ -2116,11 +2124,11 @@ bool Compiler::fgTryRemoveDeadStoreLIR(GenTree* store, GenTreeLclVarCommon* lclN // Return Value: // true if we should skip the rest of the statement, false if we should continue // -bool Compiler::fgRemoveDeadStore(GenTree** pTree, - LclVarDsc* varDsc, - VARSET_VALARG_TP life, - bool* doAgain, - bool* pStmtInfoDirty, +bool Compiler::fgRemoveDeadStore(GenTree** pTree, + LclVarDsc* varDsc, + VARSET_VALARG_TP life, + bool* doAgain, + bool* pStmtInfoDirty, bool* pStoreRemoved DEBUGARG(bool* treeModf)) { assert(!compRationalIRForm); @@ -2186,7 +2194,7 @@ bool Compiler::fgRemoveDeadStore(GenTree** pTree, #ifdef DEBUG *treeModf = true; #endif // DEBUG - // Update ordering, costs, FP levels, etc. + // Update ordering, costs, FP levels, etc. gtSetStmtInfo(compCurStmt); // Re-link the nodes for this statement @@ -2278,7 +2286,7 @@ bool Compiler::fgRemoveDeadStore(GenTree** pTree, printf("\n"); } #endif // DEBUG - // No side effects - Change the store to a GT_NOP node + // No side effects - Change the store to a GT_NOP node store->gtBashToNOP(); #ifdef DEBUG diff --git a/src/coreclr/jit/loopcloning.cpp b/src/coreclr/jit/loopcloning.cpp index 7283cc0d1d88c2..114e5aed1286ef 100644 --- a/src/coreclr/jit/loopcloning.cpp +++ b/src/coreclr/jit/loopcloning.cpp @@ -1371,7 +1371,7 @@ bool Compiler::optDeriveLoopCloningConditions(FlowGraphNaturalLoop* loop, LoopCl LcMdArrayOptInfo* mdArrInfo = optInfo->AsLcMdArrayOptInfo(); LC_Array arrLen(LC_Array(LC_Array::MdArray, mdArrInfo->GetArrIndexForDim(getAllocator(CMK_LoopClone)), mdArrInfo->dim, LC_Array::None)); - LC_Ident arrLenIdent = LC_Ident::CreateArrAccess(arrLen); + LC_Ident arrLenIdent = LC_Ident::CreateArrAccess(arrLen); LC_Condition cond(opLimitCondition, LC_Expr(ident), LC_Expr(arrLenIdent)); context->EnsureConditions(loop->GetIndex())->Push(cond); @@ -1666,7 +1666,7 @@ void Compiler::optDebugLogLoopCloning(BasicBlock* block, Statement* insertBefore // performs the optimizations assuming that the path in which the candidates // were collected is the fast path in which the optimizations will be performed. // -void Compiler::optPerformStaticOptimizations(FlowGraphNaturalLoop* loop, +void Compiler::optPerformStaticOptimizations(FlowGraphNaturalLoop* loop, LoopCloneContext* context DEBUGARG(bool dynamicPath)) { JitExpandArrayStack* optInfos = context->GetLoopOptInfo(loop->GetIndex()); @@ -1813,10 +1813,12 @@ bool Compiler::optIsLoopClonable(FlowGraphNaturalLoop* loop, LoopCloneContext* c // flow can reach the header, but that would require the handler to also be // part of the loop, which guarantees that the loop contains two distinct // EH regions. - loop->VisitLoopBlocks([](BasicBlock* block) { - assert(!block->KindIs(BBJ_RETURN)); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks( + [](BasicBlock* block) + { + assert(!block->KindIs(BBJ_RETURN)); + return BasicBlockVisit::Continue; + }); #endif // Is the entry block a handler or filter start? If so, then if we cloned, we could create a jump @@ -2018,10 +2020,12 @@ void Compiler::optCloneLoop(FlowGraphNaturalLoop* loop, LoopCloneContext* contex loop->Duplicate(&newPred, blockMap, LoopCloneContext::slowPathWeightScaleFactor); // Scale old blocks to the fast path weight. - loop->VisitLoopBlocks([=](BasicBlock* block) { - block->scaleBBWeight(LoopCloneContext::fastPathWeightScaleFactor); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks( + [=](BasicBlock* block) + { + block->scaleBBWeight(LoopCloneContext::fastPathWeightScaleFactor); + return BasicBlockVisit::Continue; + }); // Perform the static optimizations on the fast path. optPerformStaticOptimizations(loop, context DEBUGARG(true)); @@ -2803,19 +2807,21 @@ bool Compiler::optIdentifyLoopOptInfo(FlowGraphNaturalLoop* loop, LoopCloneConte LoopCloneVisitorInfo info(context, loop, nullptr, shouldCloneForArrayBounds, shouldCloneForGdvTests); - loop->VisitLoopBlocksReversePostOrder([=, &info](BasicBlock* block) { - compCurBB = block; - for (Statement* const stmt : block->Statements()) + loop->VisitLoopBlocksReversePostOrder( + [=, &info](BasicBlock* block) { - info.stmt = stmt; - const bool lclVarsOnly = false; - const bool computeStack = false; - fgWalkTreePre(stmt->GetRootNodePointer(), optCanOptimizeByLoopCloningVisitor, &info, lclVarsOnly, - computeStack); - } + compCurBB = block; + for (Statement* const stmt : block->Statements()) + { + info.stmt = stmt; + const bool lclVarsOnly = false; + const bool computeStack = false; + fgWalkTreePre(stmt->GetRootNodePointer(), optCanOptimizeByLoopCloningVisitor, &info, lclVarsOnly, + computeStack); + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); return true; } diff --git a/src/coreclr/jit/loopcloning.h b/src/coreclr/jit/loopcloning.h index 64e810be6ff424..d76ef577ca9ced 100644 --- a/src/coreclr/jit/loopcloning.h +++ b/src/coreclr/jit/loopcloning.h @@ -196,9 +196,7 @@ struct ArrIndex unsigned rank; // Rank of the array BasicBlock* useBlock; // Block where the [] occurs - ArrIndex(CompAllocator alloc) : arrLcl(BAD_VAR_NUM), indLcls(alloc), bndsChks(alloc), rank(0), useBlock(nullptr) - { - } + ArrIndex(CompAllocator alloc) : arrLcl(BAD_VAR_NUM), indLcls(alloc), bndsChks(alloc), rank(0), useBlock(nullptr) {} #ifdef DEBUG void Print(unsigned dim = -1); @@ -236,9 +234,7 @@ struct LcOptInfo }; OptType optType; - LcOptInfo(OptType optType) : optType(optType) - { - } + LcOptInfo(OptType optType) : optType(optType) {} OptType GetOptType() { @@ -343,7 +339,7 @@ struct LcMethodAddrTestOptInfo : public LcOptInfo GenTreeIndir* delegateAddressIndir, unsigned delegateLclNum, void* methAddr, - bool isSlot DEBUG_ARG(CORINFO_METHOD_HANDLE targetMethHnd)) + bool isSlot DEBUG_ARG(CORINFO_METHOD_HANDLE targetMethHnd)) : LcOptInfo(LcMethodAddrTest) , stmt(stmt) , delegateAddressIndir(delegateAddressIndir) @@ -393,17 +389,13 @@ struct LC_Array int dim; // "dim" = which index to invoke arrLen on, if -1 invoke on the whole array // Example 1: a[0][1][2] and dim = 2 implies a[0][1].length // Example 2: a[0][1][2] and dim = -1 implies a[0][1][2].length - LC_Array() : type(Invalid), dim(-1) - { - } + LC_Array() : type(Invalid), dim(-1) {} LC_Array(ArrType type, ArrIndex* arrIndex, int dim, OperType oper) : type(type), arrIndex(arrIndex), oper(oper), dim(dim) { } - LC_Array(ArrType type, ArrIndex* arrIndex, OperType oper) : type(type), arrIndex(arrIndex), oper(oper), dim(-1) - { - } + LC_Array(ArrType type, ArrIndex* arrIndex, OperType oper) : type(type), arrIndex(arrIndex), oper(oper), dim(-1) {} // Equality operator bool operator==(const LC_Array& that) const @@ -464,7 +456,8 @@ struct LC_Ident }; private: - union { + union + { unsigned constant; struct { @@ -482,17 +475,13 @@ struct LC_Ident }; }; - LC_Ident(IdentType type) : type(type) - { - } + LC_Ident(IdentType type) : type(type) {} public: // The type of this object IdentType type; - LC_Ident() : type(Invalid) - { - } + LC_Ident() : type(Invalid) {} // Equality operator bool operator==(const LC_Ident& that) const @@ -680,12 +669,8 @@ struct LC_Expr } #endif - LC_Expr() : type(Invalid) - { - } - explicit LC_Expr(const LC_Ident& ident) : ident(ident), type(Ident) - { - } + LC_Expr() : type(Invalid) {} + explicit LC_Expr(const LC_Ident& ident) : ident(ident), type(Ident) {} // Convert LC_Expr into a tree node. GenTree* ToGenTree(Compiler* comp, BasicBlock* bb); @@ -720,9 +705,7 @@ struct LC_Condition // Check if two conditions can be combined to yield one condition. bool Combines(const LC_Condition& cond, LC_Condition* newCond); - LC_Condition() - { - } + LC_Condition() {} LC_Condition(genTreeOps oper, const LC_Expr& op1, const LC_Expr& op2, bool asUnsigned = false) : op1(op1), op2(op2), oper(oper), compareUnsigned(asUnsigned) { @@ -756,16 +739,14 @@ struct LC_ArrayDeref unsigned level; - LC_ArrayDeref(const LC_Array& array, unsigned level) : array(array), children(nullptr), level(level) - { - } + LC_ArrayDeref(const LC_Array& array, unsigned level) : array(array), children(nullptr), level(level) {} LC_ArrayDeref* Find(unsigned lcl); unsigned Lcl(); - bool HasChildren(); - void EnsureChildren(CompAllocator alloc); + bool HasChildren(); + void EnsureChildren(CompAllocator alloc); static LC_ArrayDeref* Find(JitExpandArrayStack* children, unsigned lcl); void DeriveLevelConditions(JitExpandArrayStack*>* len); @@ -859,7 +840,7 @@ struct LoopCloneContext } NaturalLoopIterInfo* GetLoopIterInfo(unsigned loopNum); - void SetLoopIterInfo(unsigned loopNum, NaturalLoopIterInfo* info); + void SetLoopIterInfo(unsigned loopNum, NaturalLoopIterInfo* info); // Evaluate conditions into a JTRUE stmt and put it in a new block after `insertAfter`. BasicBlock* CondToStmtInBlock(Compiler* comp, diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 935479beff01b3..5de63779947709 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -1163,8 +1163,8 @@ GenTree* Lowering::LowerSwitch(GenTree* node) // |____ (ICon) (The actual case constant) GenTree* gtCaseCond = comp->gtNewOperNode(GT_EQ, TYP_INT, comp->gtNewLclvNode(tempLclNum, tempLclType), comp->gtNewIconNode(i, genActualType(tempLclType))); - GenTree* gtCaseBranch = comp->gtNewOperNode(GT_JTRUE, TYP_VOID, gtCaseCond); - LIR::Range caseRange = LIR::SeqTree(comp, gtCaseBranch); + GenTree* gtCaseBranch = comp->gtNewOperNode(GT_JTRUE, TYP_VOID, gtCaseCond); + LIR::Range caseRange = LIR::SeqTree(comp, gtCaseBranch); currentBBRange->InsertAtEnd(std::move(caseRange)); } } @@ -2320,7 +2320,8 @@ bool Lowering::LowerCallMemcmp(GenTreeCall* call, GenTree** next) GenTree* result = nullptr; auto newBinaryOp = [](Compiler* comp, genTreeOps oper, var_types type, GenTree* op1, - GenTree* op2) -> GenTree* { + GenTree* op2) -> GenTree* + { #ifdef FEATURE_SIMD if (varTypeIsSIMD(op1)) { @@ -3887,7 +3888,7 @@ GenTree* Lowering::OptimizeConstCompare(GenTree* cmp) #ifdef TARGET_XARCH || IsContainableMemoryOp(castOp) #endif - ); + ); if (removeCast) { @@ -4771,10 +4772,10 @@ void Lowering::LowerStoreLocCommon(GenTreeLclVarCommon* lclStore) } convertToStoreObj = false; #else // TARGET_ARM64 - // This optimization on arm64 allows more SIMD16 vars to be enregistered but it could cause - // regressions when there are many calls and before/after each one we have to store/save the upper - // half of these registers. So enable this for arm64 only when LSRA is taught not to allocate registers when - // it would have to spilled too many times. + // This optimization on arm64 allows more SIMD16 vars to be enregistered but it could cause + // regressions when there are many calls and before/after each one we have to store/save the upper + // half of these registers. So enable this for arm64 only when LSRA is taught not to allocate registers when + // it would have to spilled too many times. convertToStoreObj = true; #endif // TARGET_ARM64 } @@ -5091,8 +5092,8 @@ void Lowering::LowerCallStruct(GenTreeCall* call) break; } #endif // FEATURE_SIMD - // importer has a separate mechanism to retype calls to helpers, - // keep it for now. + // importer has a separate mechanism to retype calls to helpers, + // keep it for now. assert(user->TypeIs(TYP_REF) || (user->TypeIs(TYP_I_IMPL) && comp->IsTargetAbi(CORINFO_NATIVEAOT_ABI))); assert(call->IsHelperCall()); assert(returnType == user->TypeGet()); @@ -8086,7 +8087,7 @@ void Lowering::ContainCheckNode(GenTree* node) #if FEATURE_ARG_SPLIT case GT_PUTARG_SPLIT: #endif // FEATURE_ARG_SPLIT - // The regNum must have been set by the lowering of the call. + // The regNum must have been set by the lowering of the call. assert(node->GetRegNum() != REG_NA); break; #ifdef TARGET_XARCH @@ -8374,7 +8375,8 @@ static bool GetStoreCoalescingData(Compiler* comp, GenTreeStoreInd* ind, StoreCo return false; } - auto isNodeInvariant = [](Compiler* comp, GenTree* node, bool allowNull) { + auto isNodeInvariant = [](Compiler* comp, GenTree* node, bool allowNull) + { if (node == nullptr) { return allowNull; @@ -8799,7 +8801,7 @@ void Lowering::LowerStoreIndirCommon(GenTreeStoreInd* ind) // const bool isContainable = IsInvariantInRange(ind->Addr(), ind); #else - const bool isContainable = true; + const bool isContainable = true; #endif TryCreateAddrMode(ind->Addr(), isContainable, ind); @@ -8863,7 +8865,7 @@ GenTree* Lowering::LowerIndir(GenTreeIndir* ind) // const bool isContainable = IsInvariantInRange(ind->Addr(), ind); #else - const bool isContainable = true; + const bool isContainable = true; #endif TryCreateAddrMode(ind->Addr(), isContainable, ind); @@ -9016,7 +9018,8 @@ bool Lowering::TryMakeIndirsAdjacent(GenTreeIndir* prevIndir, GenTreeIndir* indi GenTree* startDumpNode = BlockRange().GetTreeRange(prevIndir, &isClosed).FirstNode(); GenTree* endDumpNode = indir->gtNext; - auto dumpWithMarks = [=]() { + auto dumpWithMarks = [=]() + { if (!comp->verbose) { return; @@ -9098,7 +9101,8 @@ bool Lowering::TryMakeIndirsAdjacent(GenTreeIndir* prevIndir, GenTreeIndir* indi } // Helper lambda to check if a single node interferes with 'indir'. - auto interferes = [=](GenTree* node) { + auto interferes = [=](GenTree* node) + { if (((node->gtFlags & GTF_ORDER_SIDEEFF) != 0) && node->OperSupportsOrderingSideEffect()) { // Cannot normally reorder GTF_ORDER_SIDEEFF and GTF_GLOB_REF, @@ -9206,10 +9210,12 @@ bool Lowering::TryMakeIndirsAdjacent(GenTreeIndir* prevIndir, GenTreeIndir* indi void Lowering::MarkTree(GenTree* node) { node->gtLIRFlags |= LIR::Flags::Mark; - node->VisitOperands([=](GenTree* op) { - MarkTree(op); - return GenTree::VisitResult::Continue; - }); + node->VisitOperands( + [=](GenTree* op) + { + MarkTree(op); + return GenTree::VisitResult::Continue; + }); } //------------------------------------------------------------------------ @@ -9221,10 +9227,12 @@ void Lowering::MarkTree(GenTree* node) void Lowering::UnmarkTree(GenTree* node) { node->gtLIRFlags &= ~LIR::Flags::Mark; - node->VisitOperands([=](GenTree* op) { - UnmarkTree(op); - return GenTree::VisitResult::Continue; - }); + node->VisitOperands( + [=](GenTree* op) + { + UnmarkTree(op); + return GenTree::VisitResult::Continue; + }); } #endif // TARGET_ARM64 @@ -9294,7 +9302,7 @@ void Lowering::TransformUnusedIndirection(GenTreeIndir* ind, Compiler* comp, Bas #if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) bool useNullCheck = true; #elif defined(TARGET_ARM) - bool useNullCheck = false; + bool useNullCheck = false; #else // TARGET_XARCH bool useNullCheck = !ind->Addr()->isContained(); ind->ClearDontExtend(); @@ -9533,7 +9541,7 @@ void Lowering::TryRetypingFloatingPointStoreToIntegerStore(GenTree* store) #if defined(TARGET_XARCH) || defined(TARGET_ARM) bool shouldSwitchToInteger = true; #else // TARGET_ARM64 || TARGET_LOONGARCH64 || TARGET_RISCV64 - bool shouldSwitchToInteger = FloatingPointUtils::isPositiveZero(dblCns); + bool shouldSwitchToInteger = FloatingPointUtils::isPositiveZero(dblCns); #endif if (shouldSwitchToInteger) diff --git a/src/coreclr/jit/lower.h b/src/coreclr/jit/lower.h index 76124820944f3c..4c07a35f2ca385 100644 --- a/src/coreclr/jit/lower.h +++ b/src/coreclr/jit/lower.h @@ -88,14 +88,14 @@ class Lowering final : public Phase void ContainCheckLclHeap(GenTreeOp* node); void ContainCheckRet(GenTreeUnOp* ret); #ifdef TARGET_ARM64 - bool TryLowerAndOrToCCMP(GenTreeOp* tree, GenTree** next); + bool TryLowerAndOrToCCMP(GenTreeOp* tree, GenTree** next); insCflags TruthifyingFlags(GenCondition cond); - void ContainCheckConditionalCompare(GenTreeCCMP* ccmp); - void ContainCheckNeg(GenTreeOp* neg); - void TryLowerCnsIntCselToCinc(GenTreeOp* select, GenTree* cond); - void TryLowerCselToCSOp(GenTreeOp* select, GenTree* cond); - bool TryLowerAddSubToMulLongOp(GenTreeOp* op, GenTree** next); - bool TryLowerNegToMulLongOp(GenTreeOp* op, GenTree** next); + void ContainCheckConditionalCompare(GenTreeCCMP* ccmp); + void ContainCheckNeg(GenTreeOp* neg); + void TryLowerCnsIntCselToCinc(GenTreeOp* select, GenTree* cond); + void TryLowerCselToCSOp(GenTreeOp* select, GenTree* cond); + bool TryLowerAddSubToMulLongOp(GenTreeOp* op, GenTree** next); + bool TryLowerNegToMulLongOp(GenTreeOp* op, GenTree** next); #endif void ContainCheckSelect(GenTreeOp* select); void ContainCheckBitCast(GenTree* node); @@ -129,7 +129,7 @@ class Lowering final : public Phase static bool CheckBlock(Compiler* compiler, BasicBlock* block); #endif // DEBUG - void LowerBlock(BasicBlock* block); + void LowerBlock(BasicBlock* block); GenTree* LowerNode(GenTree* node); bool IsCFGCallArgInvariantInRange(GenTree* node, GenTree* endExclusive); @@ -138,28 +138,28 @@ class Lowering final : public Phase // Call Lowering // ------------------------------ GenTree* LowerCall(GenTree* call); - bool LowerCallMemmove(GenTreeCall* call, GenTree** next); - bool LowerCallMemcmp(GenTreeCall* call, GenTree** next); - bool LowerCallMemset(GenTreeCall* call, GenTree** next); - void LowerCFGCall(GenTreeCall* call); - void MoveCFGCallArgs(GenTreeCall* call); - void MoveCFGCallArg(GenTreeCall* call, GenTree* node); + bool LowerCallMemmove(GenTreeCall* call, GenTree** next); + bool LowerCallMemcmp(GenTreeCall* call, GenTree** next); + bool LowerCallMemset(GenTreeCall* call, GenTree** next); + void LowerCFGCall(GenTreeCall* call); + void MoveCFGCallArgs(GenTreeCall* call); + void MoveCFGCallArg(GenTreeCall* call, GenTree* node); #ifndef TARGET_64BIT GenTree* DecomposeLongCompare(GenTree* cmp); #endif - GenTree* OptimizeConstCompare(GenTree* cmp); - GenTree* LowerCompare(GenTree* cmp); - GenTree* LowerJTrue(GenTreeOp* jtrue); - GenTree* LowerSelect(GenTreeConditional* cond); - bool TryLowerConditionToFlagsNode(GenTree* parent, GenTree* condition, GenCondition* code); + GenTree* OptimizeConstCompare(GenTree* cmp); + GenTree* LowerCompare(GenTree* cmp); + GenTree* LowerJTrue(GenTreeOp* jtrue); + GenTree* LowerSelect(GenTreeConditional* cond); + bool TryLowerConditionToFlagsNode(GenTree* parent, GenTree* condition, GenCondition* code); GenTreeCC* LowerNodeCC(GenTree* node, GenCondition condition); - void LowerJmpMethod(GenTree* jmp); - void LowerRet(GenTreeUnOp* ret); - void LowerStoreLocCommon(GenTreeLclVarCommon* lclVar); - void LowerRetStruct(GenTreeUnOp* ret); - void LowerRetSingleRegStructLclVar(GenTreeUnOp* ret); - void LowerCallStruct(GenTreeCall* call); - void LowerStoreSingleRegCallStruct(GenTreeBlk* store); + void LowerJmpMethod(GenTree* jmp); + void LowerRet(GenTreeUnOp* ret); + void LowerStoreLocCommon(GenTreeLclVarCommon* lclVar); + void LowerRetStruct(GenTreeUnOp* ret); + void LowerRetSingleRegStructLclVar(GenTreeUnOp* ret); + void LowerCallStruct(GenTreeCall* call); + void LowerStoreSingleRegCallStruct(GenTreeBlk* store); #if !defined(WINDOWS_AMD64_ABI) GenTreeLclVar* SpillStructCallResult(GenTreeCall* call) const; #endif // WINDOWS_AMD64_ABI @@ -168,29 +168,29 @@ class Lowering final : public Phase GenTree* LowerDirectCall(GenTreeCall* call); GenTree* LowerNonvirtPinvokeCall(GenTreeCall* call); GenTree* LowerTailCallViaJitHelper(GenTreeCall* callNode, GenTree* callTarget); - void LowerFastTailCall(GenTreeCall* callNode); - void RehomeArgForFastTailCall(unsigned int lclNum, - GenTree* insertTempBefore, - GenTree* lookForUsesStart, - GenTreeCall* callNode); - void InsertProfTailCallHook(GenTreeCall* callNode, GenTree* insertionPoint); + void LowerFastTailCall(GenTreeCall* callNode); + void RehomeArgForFastTailCall(unsigned int lclNum, + GenTree* insertTempBefore, + GenTree* lookForUsesStart, + GenTreeCall* callNode); + void InsertProfTailCallHook(GenTreeCall* callNode, GenTree* insertionPoint); GenTree* FindEarliestPutArg(GenTreeCall* call); - size_t MarkPutArgNodes(GenTree* node); + size_t MarkPutArgNodes(GenTree* node); GenTree* LowerVirtualVtableCall(GenTreeCall* call); GenTree* LowerVirtualStubCall(GenTreeCall* call); - void LowerArgsForCall(GenTreeCall* call); - void ReplaceArgWithPutArgOrBitcast(GenTree** ppChild, GenTree* newNode); + void LowerArgsForCall(GenTreeCall* call); + void ReplaceArgWithPutArgOrBitcast(GenTree** ppChild, GenTree* newNode); GenTree* NewPutArg(GenTreeCall* call, GenTree* arg, CallArg* callArg, var_types type); - void LowerArg(GenTreeCall* call, CallArg* callArg, bool late); + void LowerArg(GenTreeCall* call, CallArg* callArg, bool late); #if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) GenTree* LowerFloatArg(GenTree** pArg, CallArg* callArg); GenTree* LowerFloatArgReg(GenTree* arg, regNumber regNum); #endif - void InsertPInvokeCallProlog(GenTreeCall* call); - void InsertPInvokeCallEpilog(GenTreeCall* call); - void InsertPInvokeMethodProlog(); - void InsertPInvokeMethodEpilog(BasicBlock* returnBB DEBUGARG(GenTree* lastExpr)); + void InsertPInvokeCallProlog(GenTreeCall* call); + void InsertPInvokeCallEpilog(GenTreeCall* call); + void InsertPInvokeMethodProlog(); + void InsertPInvokeMethodEpilog(BasicBlock* returnBB DEBUGARG(GenTree* lastExpr)); GenTree* SetGCState(int cns); GenTree* CreateReturnTrapSeq(); enum FrameLinkAction @@ -316,31 +316,31 @@ class Lowering final : public Phase #endif // defined(TARGET_XARCH) // Per tree node member functions - void LowerStoreIndirCommon(GenTreeStoreInd* ind); + void LowerStoreIndirCommon(GenTreeStoreInd* ind); GenTree* LowerIndir(GenTreeIndir* ind); - bool OptimizeForLdp(GenTreeIndir* ind); - bool TryMakeIndirsAdjacent(GenTreeIndir* prevIndir, GenTreeIndir* indir); - void MarkTree(GenTree* root); - void UnmarkTree(GenTree* root); - void LowerStoreIndir(GenTreeStoreInd* node); - void LowerStoreIndirCoalescing(GenTreeStoreInd* node); + bool OptimizeForLdp(GenTreeIndir* ind); + bool TryMakeIndirsAdjacent(GenTreeIndir* prevIndir, GenTreeIndir* indir); + void MarkTree(GenTree* root); + void UnmarkTree(GenTree* root); + void LowerStoreIndir(GenTreeStoreInd* node); + void LowerStoreIndirCoalescing(GenTreeStoreInd* node); GenTree* LowerAdd(GenTreeOp* node); GenTree* LowerMul(GenTreeOp* mul); - bool TryLowerAndNegativeOne(GenTreeOp* node, GenTree** nextNode); + bool TryLowerAndNegativeOne(GenTreeOp* node, GenTree** nextNode); GenTree* LowerBinaryArithmetic(GenTreeOp* binOp); - bool LowerUnsignedDivOrMod(GenTreeOp* divMod); - bool TryLowerConstIntDivOrMod(GenTree* node, GenTree** nextNode); + bool LowerUnsignedDivOrMod(GenTreeOp* divMod); + bool TryLowerConstIntDivOrMod(GenTree* node, GenTree** nextNode); GenTree* LowerSignedDivOrMod(GenTree* node); - void LowerBlockStore(GenTreeBlk* blkNode); - void LowerBlockStoreCommon(GenTreeBlk* blkNode); - void LowerBlockStoreAsHelperCall(GenTreeBlk* blkNode); - void LowerLclHeap(GenTree* node); - void ContainBlockStoreAddress(GenTreeBlk* blkNode, unsigned size, GenTree* addr, GenTree* addrParent); - void LowerPutArgStkOrSplit(GenTreePutArgStk* putArgNode); + void LowerBlockStore(GenTreeBlk* blkNode); + void LowerBlockStoreCommon(GenTreeBlk* blkNode); + void LowerBlockStoreAsHelperCall(GenTreeBlk* blkNode); + void LowerLclHeap(GenTree* node); + void ContainBlockStoreAddress(GenTreeBlk* blkNode, unsigned size, GenTree* addr, GenTree* addrParent); + void LowerPutArgStkOrSplit(GenTreePutArgStk* putArgNode); GenTree* LowerArrLength(GenTreeArrCommon* node); #ifdef TARGET_XARCH - void LowerPutArgStk(GenTreePutArgStk* putArgStk); + void LowerPutArgStk(GenTreePutArgStk* putArgStk); GenTree* TryLowerMulWithConstant(GenTreeOp* node); #endif // TARGET_XARCH @@ -351,12 +351,12 @@ class Lowering final : public Phase void TryRetypingFloatingPointStoreToIntegerStore(GenTree* store); GenTree* LowerSwitch(GenTree* node); - bool TryLowerSwitchToBitTest(FlowEdge* jumpTable[], - unsigned jumpCount, - unsigned targetCount, - BasicBlock* bbSwitch, - GenTree* switchValue, - weight_t defaultLikelihood); + bool TryLowerSwitchToBitTest(FlowEdge* jumpTable[], + unsigned jumpCount, + unsigned targetCount, + BasicBlock* bbSwitch, + GenTree* switchValue, + weight_t defaultLikelihood); void LowerCast(GenTree* node); @@ -374,12 +374,12 @@ class Lowering final : public Phase void LowerShift(GenTreeOp* shift); #ifdef FEATURE_HW_INTRINSICS GenTree* LowerHWIntrinsic(GenTreeHWIntrinsic* node); - void LowerHWIntrinsicCC(GenTreeHWIntrinsic* node, NamedIntrinsic newIntrinsicId, GenCondition condition); + void LowerHWIntrinsicCC(GenTreeHWIntrinsic* node, NamedIntrinsic newIntrinsicId, GenCondition condition); GenTree* LowerHWIntrinsicCmpOp(GenTreeHWIntrinsic* node, genTreeOps cmpOp); GenTree* LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node); GenTree* LowerHWIntrinsicDot(GenTreeHWIntrinsic* node); #if defined(TARGET_XARCH) - void LowerFusedMultiplyAdd(GenTreeHWIntrinsic* node); + void LowerFusedMultiplyAdd(GenTreeHWIntrinsic* node); GenTree* LowerHWIntrinsicToScalar(GenTreeHWIntrinsic* node); GenTree* LowerHWIntrinsicGetElement(GenTreeHWIntrinsic* node); GenTree* LowerHWIntrinsicCndSel(GenTreeHWIntrinsic* node); @@ -389,7 +389,7 @@ class Lowering final : public Phase GenTree* TryLowerAndOpToExtractLowestSetBit(GenTreeOp* andNode); GenTree* TryLowerAndOpToAndNot(GenTreeOp* andNode); GenTree* TryLowerXorOpToGetMaskUpToLowestSetBit(GenTreeOp* xorNode); - void LowerBswapOp(GenTreeOp* node); + void LowerBswapOp(GenTreeOp* node); #elif defined(TARGET_ARM64) bool IsValidConstForMovImm(GenTreeHWIntrinsic* node); void LowerHWIntrinsicFusedMultiplyAddScalar(GenTreeHWIntrinsic* node); diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 9d28135c92a1a0..32041425d3b10a 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -726,7 +726,7 @@ void Lowering::ContainBlockStoreAddress(GenTreeBlk* blkNode, unsigned size, GenT { return; } -#else // !TARGET_ARM +#else // !TARGET_ARM if ((ClrSafeInt(offset) + ClrSafeInt(size)).IsOverflow()) { return; @@ -1088,7 +1088,8 @@ void Lowering::LowerHWIntrinsicFusedMultiplyAddScalar(GenTreeHWIntrinsic* node) GenTree* op2 = node->Op(2); GenTree* op3 = node->Op(3); - auto lowerOperand = [this](GenTree* op) { + auto lowerOperand = [this](GenTree* op) + { bool wasNegated = false; if (op->OperIsHWIntrinsic() && diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 5c4f05a04ad57a..813cb77217339d 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -690,13 +690,13 @@ void Lowering::LowerPutArgStk(GenTreePutArgStk* putArgStk) else #endif // TARGET_X86 if (loadSize <= comp->getUnrollThreshold(Compiler::UnrollKind::Memcpy)) - { - putArgStk->gtPutArgStkKind = GenTreePutArgStk::Kind::Unroll; - } - else - { - putArgStk->gtPutArgStkKind = GenTreePutArgStk::Kind::RepInstr; - } + { + putArgStk->gtPutArgStkKind = GenTreePutArgStk::Kind::Unroll; + } + else + { + putArgStk->gtPutArgStkKind = GenTreePutArgStk::Kind::RepInstr; + } } else // There are GC pointers. { @@ -767,7 +767,7 @@ void Lowering::LowerPutArgStk(GenTreePutArgStk* putArgStk) #if defined(TARGET_AMD64) && !src->IsIntegralConst(0) #endif // TARGET_AMD64 - ) + ) { MakeSrcContained(putArgStk, src); } @@ -1767,8 +1767,8 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) // currently ANDNOT logic cannot be optimized by the ternary node. break; } - GenTree* op3 = second->AsHWIntrinsic()->Op(1) == node ? second->AsHWIntrinsic()->Op(2) - : second->AsHWIntrinsic()->Op(1); + GenTree* op3 = second->AsHWIntrinsic()->Op(1) == node ? second->AsHWIntrinsic()->Op(2) + : second->AsHWIntrinsic()->Op(1); GenTree* control = comp->gtNewIconNode(node->GetTernaryControlByte(second->AsHWIntrinsic())); CorInfoType simdBaseJitType = node->GetSimdBaseJitType(); unsigned simdSize = node->GetSimdSize(); @@ -6188,12 +6188,14 @@ bool Lowering::IsRMWIndirCandidate(GenTree* operand, GenTree* storeInd) return false; } - node->VisitOperands([&markCount](GenTree* nodeOperand) -> GenTree::VisitResult { - assert((nodeOperand->gtLIRFlags & LIR::Flags::Mark) == 0); - nodeOperand->gtLIRFlags |= LIR::Flags::Mark; - markCount++; - return GenTree::VisitResult::Continue; - }); + node->VisitOperands( + [&markCount](GenTree* nodeOperand) -> GenTree::VisitResult + { + assert((nodeOperand->gtLIRFlags & LIR::Flags::Mark) == 0); + nodeOperand->gtLIRFlags |= LIR::Flags::Mark; + markCount++; + return GenTree::VisitResult::Continue; + }); } } @@ -6650,12 +6652,12 @@ void Lowering::ContainCheckCallOperands(GenTreeCall* call) else #endif // TARGET_X86 if (ctrlExpr->isIndir()) - { - // We may have cases where we have set a register target on the ctrlExpr, but if it - // contained we must clear it. - ctrlExpr->SetRegNum(REG_NA); - MakeSrcContained(call, ctrlExpr); - } + { + // We may have cases where we have set a register target on the ctrlExpr, but if it + // contained we must clear it. + ctrlExpr->SetRegNum(REG_NA); + MakeSrcContained(call, ctrlExpr); + } } } @@ -10027,8 +10029,8 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) if (op1->IsVectorZero()) { -// When op1 is zero, we can contain it and we expect that -// ival is already in the correct state to account for it + // When op1 is zero, we can contain it and we expect that + // ival is already in the correct state to account for it #if DEBUG ssize_t ival = lastOp->AsIntConCommon()->IconValue(); @@ -10048,8 +10050,8 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) } else if (op2->IsVectorZero()) { -// When op2 is zero, we can contain it and we expect that -// zmask is already in the correct state to account for it + // When op2 is zero, we can contain it and we expect that + // zmask is already in the correct state to account for it #if DEBUG ssize_t ival = lastOp->AsIntConCommon()->IconValue(); diff --git a/src/coreclr/jit/lsra.cpp b/src/coreclr/jit/lsra.cpp index b2d37b9becad9d..b9edf935919698 100644 --- a/src/coreclr/jit/lsra.cpp +++ b/src/coreclr/jit/lsra.cpp @@ -384,9 +384,9 @@ void LinearScan::updateSpillCost(regNumber reg, Interval* interval) // interval - Interval of Refposition. // assignedReg - Assigned register for this refposition. // -void LinearScan::updateRegsFreeBusyState(RefPosition& refPosition, - regMaskTP regsBusy, - regMaskTP* regsToFree, +void LinearScan::updateRegsFreeBusyState(RefPosition& refPosition, + regMaskTP regsBusy, + regMaskTP* regsToFree, regMaskTP* delayRegsToFree DEBUG_ARG(Interval* interval) DEBUG_ARG(regNumber assignedReg)) { @@ -1437,7 +1437,7 @@ PhaseStatus LinearScan::doLinearScan() #ifdef DEBUG || VERBOSE #endif - ) + ) { dumpLsraStats(jitstdout()); } @@ -1771,7 +1771,7 @@ template void LinearScan::identifyCandidates(); // TODO-Cleanup: This was cloned from Compiler::lvaSortByRefCount() in lclvars.cpp in order // to avoid perturbation, but should be merged. template -void LinearScan::identifyCandidates() +void LinearScan::identifyCandidates() { if (localVarsEnregistered) { @@ -2022,24 +2022,24 @@ void LinearScan::identifyCandidates() else #endif // FEATURE_PARTIAL_SIMD_CALLEE_SAVE if (regType(type) == FloatRegisterType) - { - floatVarCount++; - weight_t refCntWtd = varDsc->lvRefCntWtd(); - if (varDsc->lvIsRegArg) - { - // Don't count the initial reference for register params. In those cases, - // using a callee-save causes an extra copy. - refCntWtd -= BB_UNITY_WEIGHT; - } - if (refCntWtd >= thresholdFPRefCntWtd) { - VarSetOps::AddElemD(compiler, fpCalleeSaveCandidateVars, varDsc->lvVarIndex); - } - else if (refCntWtd >= maybeFPRefCntWtd) - { - VarSetOps::AddElemD(compiler, fpMaybeCandidateVars, varDsc->lvVarIndex); + floatVarCount++; + weight_t refCntWtd = varDsc->lvRefCntWtd(); + if (varDsc->lvIsRegArg) + { + // Don't count the initial reference for register params. In those cases, + // using a callee-save causes an extra copy. + refCntWtd -= BB_UNITY_WEIGHT; + } + if (refCntWtd >= thresholdFPRefCntWtd) + { + VarSetOps::AddElemD(compiler, fpCalleeSaveCandidateVars, varDsc->lvVarIndex); + } + else if (refCntWtd >= maybeFPRefCntWtd) + { + VarSetOps::AddElemD(compiler, fpMaybeCandidateVars, varDsc->lvVarIndex); + } } - } JITDUMP(" "); DBEXEC(VERBOSE, newInt->dump(compiler)); } @@ -2498,7 +2498,7 @@ void LinearScan::checkLastUses(BasicBlock* block) // the register locations will be "rotated" to stress the resolution and allocation // code. // -BasicBlock* LinearScan::findPredBlockForLiveIn(BasicBlock* block, +BasicBlock* LinearScan::findPredBlockForLiveIn(BasicBlock* block, BasicBlock* prevBlock DEBUGARG(bool* pPredBlockIsAllocated)) { BasicBlock* predBlock = nullptr; @@ -2695,33 +2695,33 @@ void LinearScan::setFrameType() else #endif // DOUBLE_ALIGN if (compiler->codeGen->isFramePointerRequired()) - { - frameType = FT_EBP_FRAME; - } - else - { - if (compiler->rpMustCreateEBPCalled == false) - { -#ifdef DEBUG - const char* reason; -#endif // DEBUG - compiler->rpMustCreateEBPCalled = true; - if (compiler->rpMustCreateEBPFrame(INDEBUG(&reason))) - { - JITDUMP("; Decided to create an EBP based frame for ETW stackwalking (%s)\n", reason); - compiler->codeGen->setFrameRequired(true); - } - } - - if (compiler->codeGen->isFrameRequired()) { frameType = FT_EBP_FRAME; } else { - frameType = FT_ESP_FRAME; + if (compiler->rpMustCreateEBPCalled == false) + { +#ifdef DEBUG + const char* reason; +#endif // DEBUG + compiler->rpMustCreateEBPCalled = true; + if (compiler->rpMustCreateEBPFrame(INDEBUG(&reason))) + { + JITDUMP("; Decided to create an EBP based frame for ETW stackwalking (%s)\n", reason); + compiler->codeGen->setFrameRequired(true); + } + } + + if (compiler->codeGen->isFrameRequired()) + { + frameType = FT_EBP_FRAME; + } + else + { + frameType = FT_ESP_FRAME; + } } - } switch (frameType) { @@ -2941,7 +2941,7 @@ bool LinearScan::isMatchingConstant(RegRecord* physRegRecord, RefPosition* refPo // for enregistration. It simply finds the register to be assigned, if it was assigned to something // else, then will unassign it and then assign to the currentInterval // -regNumber LinearScan::allocateRegMinimal(Interval* currentInterval, +regNumber LinearScan::allocateRegMinimal(Interval* currentInterval, RefPosition* refPosition DEBUG_ARG(RegisterScore* registerScore)) { assert(!enregisterLocalVars); @@ -3004,7 +3004,7 @@ regNumber LinearScan::allocateRegMinimal(Interval* currentInterval, // no such ref position, no register will be allocated. // template -regNumber LinearScan::allocateReg(Interval* currentInterval, +regNumber LinearScan::allocateReg(Interval* currentInterval, RefPosition* refPosition DEBUG_ARG(RegisterScore* registerScore)) { regMaskTP foundRegBit = @@ -7829,7 +7829,7 @@ void LinearScan::updateMaxSpill(RefPosition* refPosition) // the tree, and performs resolution across joins and back edges. // template -void LinearScan::resolveRegisters() +void LinearScan::resolveRegisters() { // Iterate over the tree and the RefPositions in lockstep // - annotate the tree with register assignments by setting GetRegNum() or gtRegPair (for longs) @@ -8302,8 +8302,8 @@ void LinearScan::resolveRegisters() { regMaskTP initialRegMask = interval->firstRefPosition->registerAssignment; regNumber initialReg = (initialRegMask == RBM_NONE || interval->firstRefPosition->spillAfter) - ? REG_STK - : genRegNumFromMask(initialRegMask); + ? REG_STK + : genRegNumFromMask(initialRegMask); #ifdef TARGET_ARM if (varTypeIsMultiReg(varDsc)) @@ -8750,12 +8750,12 @@ regNumber LinearScan::getTempRegForResolution(BasicBlock* fromBlock, // Notes: // It inserts at least one move and updates incoming parameter 'location'. // -void LinearScan::addResolutionForDouble(BasicBlock* block, - GenTree* insertionPoint, - Interval** sourceIntervals, - regNumberSmall* location, - regNumber toReg, - regNumber fromReg, +void LinearScan::addResolutionForDouble(BasicBlock* block, + GenTree* insertionPoint, + Interval** sourceIntervals, + regNumberSmall* location, + regNumber toReg, + regNumber fromReg, ResolveType resolveType DEBUG_ARG(BasicBlock* fromBlock) DEBUG_ARG(BasicBlock* toBlock)) { @@ -8825,10 +8825,10 @@ void LinearScan::addResolutionForDouble(BasicBlock* block, // The next time, we want to move from the stack to the destination (toReg), // in which case fromReg will be REG_STK, and we insert at the top. // -void LinearScan::addResolution(BasicBlock* block, - GenTree* insertionPoint, - Interval* interval, - regNumber toReg, +void LinearScan::addResolution(BasicBlock* block, + GenTree* insertionPoint, + Interval* interval, + regNumber toReg, regNumber fromReg DEBUG_ARG(BasicBlock* fromBlock) DEBUG_ARG(BasicBlock* toBlock) DEBUG_ARG(const char* reason)) { @@ -11272,9 +11272,8 @@ void LinearScan::dumpRegRecordHeader() // l is either '*' (if a last use) or ' ' (otherwise) // d is either 'D' (if a delayed use) or ' ' (otherwise) - maxNodeLocation = (maxNodeLocation == 0) - ? 1 - : maxNodeLocation; // corner case of a method with an infinite loop without any GenTree nodes + maxNodeLocation = (maxNodeLocation == 0) ? 1 : maxNodeLocation; // corner case of a method with an infinite loop + // without any GenTree nodes assert(maxNodeLocation >= 1); assert(refPositions.size() >= 1); int treeIdWidth = 9; /* '[XXXXX] '*/ @@ -12404,7 +12403,7 @@ LinearScan::RegisterSelection::RegisterSelection(LinearScan* linearScan) #ifdef TARGET_ARM64 && !linearScan->compiler->info.compNeedsConsecutiveRegisters #endif - ) + ) { ordering = W("MQQQQQQQQQQQQQQQQ"); } @@ -13121,7 +13120,7 @@ void LinearScan::RegisterSelection::try_PREV_REG_OPT() && !refPosition->needsConsecutive #endif - ) + ) { assert(!"Spill candidate has no assignedInterval recentRefPosition"); } @@ -13253,7 +13252,7 @@ void LinearScan::RegisterSelection::calculateCoversSets() // Register bit selected (a single register) and REG_NA if no register was selected. // template -regMaskTP LinearScan::RegisterSelection::select(Interval* currentInterval, +regMaskTP LinearScan::RegisterSelection::select(Interval* currentInterval, RefPosition* refPosition DEBUG_ARG(RegisterScore* registerScore)) { #ifdef DEBUG @@ -13718,7 +13717,7 @@ regMaskTP LinearScan::RegisterSelection::select(Interval* currentInterval, // select the REG_ORDER heuristics (if there are any free candidates) or REG_NUM (if all registers // are busy). // -regMaskTP LinearScan::RegisterSelection::selectMinimal(Interval* currentInterval, +regMaskTP LinearScan::RegisterSelection::selectMinimal(Interval* currentInterval, RefPosition* refPosition DEBUG_ARG(RegisterScore* registerScore)) { assert(!linearScan->enregisterLocalVars); diff --git a/src/coreclr/jit/lsra.h b/src/coreclr/jit/lsra.h index 9620abbc5a7824..38948e0d350f69 100644 --- a/src/coreclr/jit/lsra.h +++ b/src/coreclr/jit/lsra.h @@ -30,8 +30,8 @@ const unsigned int MaxInternalRegisters = 8; const unsigned int RegisterTypeCount = 2; /***************************************************************************** -* Register types -*****************************************************************************/ + * Register types + *****************************************************************************/ typedef var_types RegisterType; #define IntRegisterType TYP_INT @@ -83,14 +83,10 @@ struct RefInfo RefPosition* ref; GenTree* treeNode; - RefInfo(RefPosition* r, GenTree* t) : ref(r), treeNode(t) - { - } + RefInfo(RefPosition* r, GenTree* t) : ref(r), treeNode(t) {} // default constructor for data structures - RefInfo() - { - } + RefInfo() {} }; //------------------------------------------------------------------------ @@ -107,9 +103,7 @@ class RefInfoListNode final : public RefInfo RefInfoListNode* m_next; // The next node in the list public: - RefInfoListNode(RefPosition* r, GenTree* t) : RefInfo(r, t) - { - } + RefInfoListNode(RefPosition* r, GenTree* t) : RefInfo(r, t) {} //------------------------------------------------------------------------ // RefInfoListNode::Next: Returns the next node in the list. @@ -134,9 +128,7 @@ class RefInfoList final RefInfoListNode* m_tail; // The tail of the list public: - RefInfoList() : m_head(nullptr), m_tail(nullptr) - { - } + RefInfoList() : m_head(nullptr), m_tail(nullptr) {} RefInfoList(RefInfoListNode* node) : m_head(node), m_tail(node) { @@ -365,7 +357,7 @@ class RefInfoListNodePool final public: RefInfoListNodePool(Compiler* compiler, unsigned preallocate = defaultPreallocation); RefInfoListNode* GetNode(RefPosition* r, GenTree* t); - void ReturnNode(RefInfoListNode* listNode); + void ReturnNode(RefInfoListNode* listNode); }; #if TRACK_LSRA_STATS @@ -635,7 +627,7 @@ class LinearScan : public LinearScanInterface // This does the dataflow analysis and builds the intervals template - void buildIntervals(); + void buildIntervals(); // This is where the actual assignment is done for scenarios where // no local var enregistration is done. @@ -648,7 +640,7 @@ class LinearScan : public LinearScanInterface void allocateRegisters(); // This is the resolution phase, where cross-block mismatches are fixed up template - void resolveRegisters(); + void resolveRegisters(); void writeRegisters(RefPosition* currentRefPosition, GenTree* tree); @@ -658,7 +650,7 @@ class LinearScan : public LinearScanInterface void insertCopyOrReload(BasicBlock* block, GenTree* tree, unsigned multiRegIdx, RefPosition* refPosition); #if FEATURE_PARTIAL_SIMD_CALLEE_SAVE - void makeUpperVectorInterval(unsigned varIndex); + void makeUpperVectorInterval(unsigned varIndex); Interval* getUpperVectorInterval(unsigned varIndex); // Save the upper half of a vector that lives in a callee-save register at the point of a call. @@ -693,20 +685,20 @@ class LinearScan : public LinearScanInterface }; #ifdef TARGET_ARM - void addResolutionForDouble(BasicBlock* block, - GenTree* insertionPoint, - Interval** sourceIntervals, - regNumberSmall* location, - regNumber toReg, - regNumber fromReg, + void addResolutionForDouble(BasicBlock* block, + GenTree* insertionPoint, + Interval** sourceIntervals, + regNumberSmall* location, + regNumber toReg, + regNumber fromReg, ResolveType resolveType DEBUG_ARG(BasicBlock* fromBlock) DEBUG_ARG(BasicBlock* toBlock)); #endif - void addResolution(BasicBlock* block, - GenTree* insertionPoint, - Interval* interval, - regNumber outReg, + void addResolution(BasicBlock* block, + GenTree* insertionPoint, + Interval* interval, + regNumber outReg, regNumber inReg DEBUG_ARG(BasicBlock* fromBlock) DEBUG_ARG(BasicBlock* toBlock) DEBUG_ARG(const char* reason)); @@ -988,7 +980,7 @@ class LinearScan : public LinearScanInterface private: // Determine which locals are candidates for allocation template - void identifyCandidates(); + void identifyCandidates(); // determine which locals are used in EH constructs we don't want to deal with void identifyCandidatesExceptionDataflow(); @@ -997,8 +989,8 @@ class LinearScan : public LinearScanInterface #ifdef DEBUG void checkLastUses(BasicBlock* block); - int ComputeOperandDstCount(GenTree* operand); - int ComputeAvailableSrcCount(GenTree* node); + int ComputeOperandDstCount(GenTree* operand); + int ComputeAvailableSrcCount(GenTree* node); #endif // DEBUG void setFrameType(); @@ -1014,20 +1006,20 @@ class LinearScan : public LinearScanInterface void resetAllRegistersState(); #ifdef TARGET_ARM - bool isSecondHalfReg(RegRecord* regRec, Interval* interval); + bool isSecondHalfReg(RegRecord* regRec, Interval* interval); RegRecord* getSecondHalfRegRec(RegRecord* regRec); RegRecord* findAnotherHalfRegRec(RegRecord* regRec); - regNumber findAnotherHalfRegNum(regNumber regNum); - bool canSpillDoubleReg(RegRecord* physRegRecord, LsraLocation refLocation); - void unassignDoublePhysReg(RegRecord* doubleRegRecord); + regNumber findAnotherHalfRegNum(regNumber regNum); + bool canSpillDoubleReg(RegRecord* physRegRecord, LsraLocation refLocation); + void unassignDoublePhysReg(RegRecord* doubleRegRecord); #endif - void clearAssignedInterval(RegRecord* reg ARM_ARG(RegisterType regType)); - void updateAssignedInterval(RegRecord* reg, Interval* interval ARM_ARG(RegisterType regType)); - void updatePreviousInterval(RegRecord* reg, Interval* interval ARM_ARG(RegisterType regType)); - bool canRestorePreviousInterval(RegRecord* regRec, Interval* assignedInterval); - bool isAssignedToInterval(Interval* interval, RegRecord* regRec); - bool isRefPositionActive(RefPosition* refPosition, LsraLocation refLocation); - bool canSpillReg(RegRecord* physRegRecord, LsraLocation refLocation); + void clearAssignedInterval(RegRecord* reg ARM_ARG(RegisterType regType)); + void updateAssignedInterval(RegRecord* reg, Interval* interval ARM_ARG(RegisterType regType)); + void updatePreviousInterval(RegRecord* reg, Interval* interval ARM_ARG(RegisterType regType)); + bool canRestorePreviousInterval(RegRecord* regRec, Interval* assignedInterval); + bool isAssignedToInterval(Interval* interval, RegRecord* regRec); + bool isRefPositionActive(RefPosition* refPosition, LsraLocation refLocation); + bool canSpillReg(RegRecord* physRegRecord, LsraLocation refLocation); weight_t getSpillWeight(RegRecord* physRegRecord); // insert refpositions representing prolog zero-inits which will be added later @@ -1214,13 +1206,13 @@ class LinearScan : public LinearScanInterface void spillGCRefs(RefPosition* killRefPosition); -/***************************************************************************** -* Register selection -****************************************************************************/ + /***************************************************************************** + * Register selection + ****************************************************************************/ #if defined(TARGET_ARM64) - bool canAssignNextConsecutiveRegisters(RefPosition* firstRefPosition, regNumber firstRegAssigned); - void assignConsecutiveRegisters(RefPosition* firstRefPosition, regNumber firstRegAssigned); + bool canAssignNextConsecutiveRegisters(RefPosition* firstRefPosition, regNumber firstRegAssigned); + void assignConsecutiveRegisters(RefPosition* firstRefPosition, regNumber firstRegAssigned); regMaskTP getConsecutiveCandidates(regMaskTP candidates, RefPosition* refPosition, regMaskTP* busyCandidates); regMaskTP filterConsecutiveCandidates(regMaskTP candidates, unsigned int registersNeeded, @@ -1258,10 +1250,10 @@ class LinearScan : public LinearScanInterface // Perform register selection and update currentInterval or refPosition template - FORCEINLINE regMaskTP select(Interval* currentInterval, + FORCEINLINE regMaskTP select(Interval* currentInterval, RefPosition* refPosition DEBUG_ARG(RegisterScore* registerScore)); - FORCEINLINE regMaskTP selectMinimal(Interval* currentInterval, + FORCEINLINE regMaskTP selectMinimal(Interval* currentInterval, RefPosition* refPosition DEBUG_ARG(RegisterScore* registerScore)); // If the register is from unassigned set such that it was not already @@ -1344,8 +1336,8 @@ class LinearScan : public LinearScanInterface return (prevRegBit & preferences) == foundRegBit; } - bool applySelection(int selectionScore, regMaskTP selectionCandidates); - bool applySingleRegSelection(int selectionScore, regMaskTP selectionCandidate); + bool applySelection(int selectionScore, regMaskTP selectionCandidates); + bool applySingleRegSelection(int selectionScore, regMaskTP selectionCandidate); FORCEINLINE void calculateCoversSets(); FORCEINLINE void calculateUnassignedSets(); FORCEINLINE void reset(Interval* interval, RefPosition* refPosition); @@ -1379,8 +1371,8 @@ class LinearScan : public LinearScanInterface unsigned toBBNum; }; typedef JitHashTable, SplitEdgeInfo> SplitBBNumToTargetBBNumMap; - SplitBBNumToTargetBBNumMap* splitBBNumToTargetBBNumMap; - SplitBBNumToTargetBBNumMap* getSplitBBNumToTargetBBNumMap() + SplitBBNumToTargetBBNumMap* splitBBNumToTargetBBNumMap; + SplitBBNumToTargetBBNumMap* getSplitBBNumToTargetBBNumMap() { if (splitBBNumToTargetBBNumMap == nullptr) { @@ -1391,13 +1383,13 @@ class LinearScan : public LinearScanInterface } SplitEdgeInfo getSplitEdgeInfo(unsigned int bbNum); - void initVarRegMaps(); - void setInVarRegForBB(unsigned int bbNum, unsigned int varNum, regNumber reg); - void setOutVarRegForBB(unsigned int bbNum, unsigned int varNum, regNumber reg); + void initVarRegMaps(); + void setInVarRegForBB(unsigned int bbNum, unsigned int varNum, regNumber reg); + void setOutVarRegForBB(unsigned int bbNum, unsigned int varNum, regNumber reg); VarToRegMap getInVarToRegMap(unsigned int bbNum); VarToRegMap getOutVarToRegMap(unsigned int bbNum); - void setVarReg(VarToRegMap map, unsigned int trackedVarIndex, regNumber reg); - regNumber getVarReg(VarToRegMap map, unsigned int trackedVarIndex); + void setVarReg(VarToRegMap map, unsigned int trackedVarIndex, regNumber reg); + regNumber getVarReg(VarToRegMap map, unsigned int trackedVarIndex); // Initialize the incoming VarToRegMap to the given map values (generally a predecessor of // the block) VarToRegMap setInVarToRegMap(unsigned int bbNum, VarToRegMap srcVarToRegMap); @@ -1410,8 +1402,8 @@ class LinearScan : public LinearScanInterface #ifdef TARGET_ARM64 typedef JitHashTable, RefPosition*> NextConsecutiveRefPositionsMap; - NextConsecutiveRefPositionsMap* nextConsecutiveRefPositionMap; - NextConsecutiveRefPositionsMap* getNextConsecutiveRefPositionsMap() + NextConsecutiveRefPositionsMap* nextConsecutiveRefPositionMap; + NextConsecutiveRefPositionsMap* getNextConsecutiveRefPositionsMap() { if (nextConsecutiveRefPositionMap == nullptr) { @@ -1477,7 +1469,7 @@ class LinearScan : public LinearScanInterface regMaskTP lastDumpedRegisters; regMaskTP registersToDump; int lastUsedRegNumIndex; - bool shouldDumpReg(regNumber regNum) + bool shouldDumpReg(regNumber regNum) { return (registersToDump & genRegMask(regNum)) != 0; } @@ -1500,27 +1492,51 @@ class LinearScan : public LinearScanInterface // Events during the allocation phase that cause some dump output enum LsraDumpEvent{ // Conflicting def/use - LSRA_EVENT_DEFUSE_CONFLICT, LSRA_EVENT_DEFUSE_FIXED_DELAY_USE, LSRA_EVENT_DEFUSE_CASE1, LSRA_EVENT_DEFUSE_CASE2, - LSRA_EVENT_DEFUSE_CASE3, LSRA_EVENT_DEFUSE_CASE4, LSRA_EVENT_DEFUSE_CASE5, LSRA_EVENT_DEFUSE_CASE6, + LSRA_EVENT_DEFUSE_CONFLICT, + LSRA_EVENT_DEFUSE_FIXED_DELAY_USE, + LSRA_EVENT_DEFUSE_CASE1, + LSRA_EVENT_DEFUSE_CASE2, + LSRA_EVENT_DEFUSE_CASE3, + LSRA_EVENT_DEFUSE_CASE4, + LSRA_EVENT_DEFUSE_CASE5, + LSRA_EVENT_DEFUSE_CASE6, // Spilling - LSRA_EVENT_SPILL, LSRA_EVENT_SPILL_EXTENDED_LIFETIME, LSRA_EVENT_RESTORE_PREVIOUS_INTERVAL, - LSRA_EVENT_RESTORE_PREVIOUS_INTERVAL_AFTER_SPILL, LSRA_EVENT_DONE_KILL_GC_REFS, LSRA_EVENT_NO_GC_KILLS, + LSRA_EVENT_SPILL, + LSRA_EVENT_SPILL_EXTENDED_LIFETIME, + LSRA_EVENT_RESTORE_PREVIOUS_INTERVAL, + LSRA_EVENT_RESTORE_PREVIOUS_INTERVAL_AFTER_SPILL, + LSRA_EVENT_DONE_KILL_GC_REFS, + LSRA_EVENT_NO_GC_KILLS, // Block boundaries - LSRA_EVENT_START_BB, LSRA_EVENT_END_BB, + LSRA_EVENT_START_BB, + LSRA_EVENT_END_BB, // Miscellaneous - LSRA_EVENT_FREE_REGS, LSRA_EVENT_UPPER_VECTOR_SAVE, LSRA_EVENT_UPPER_VECTOR_RESTORE, + LSRA_EVENT_FREE_REGS, + LSRA_EVENT_UPPER_VECTOR_SAVE, + LSRA_EVENT_UPPER_VECTOR_RESTORE, // Characteristics of the current RefPosition LSRA_EVENT_INCREMENT_RANGE_END, // ??? - LSRA_EVENT_LAST_USE, LSRA_EVENT_LAST_USE_DELAYED, LSRA_EVENT_NEEDS_NEW_REG, + LSRA_EVENT_LAST_USE, + LSRA_EVENT_LAST_USE_DELAYED, + LSRA_EVENT_NEEDS_NEW_REG, // Allocation decisions - LSRA_EVENT_FIXED_REG, LSRA_EVENT_EXP_USE, LSRA_EVENT_ZERO_REF, LSRA_EVENT_NO_ENTRY_REG_ALLOCATED, - LSRA_EVENT_KEPT_ALLOCATION, LSRA_EVENT_COPY_REG, LSRA_EVENT_MOVE_REG, LSRA_EVENT_ALLOC_REG, - LSRA_EVENT_NO_REG_ALLOCATED, LSRA_EVENT_RELOAD, LSRA_EVENT_SPECIAL_PUTARG, LSRA_EVENT_REUSE_REG, + LSRA_EVENT_FIXED_REG, + LSRA_EVENT_EXP_USE, + LSRA_EVENT_ZERO_REF, + LSRA_EVENT_NO_ENTRY_REG_ALLOCATED, + LSRA_EVENT_KEPT_ALLOCATION, + LSRA_EVENT_COPY_REG, + LSRA_EVENT_MOVE_REG, + LSRA_EVENT_ALLOC_REG, + LSRA_EVENT_NO_REG_ALLOCATED, + LSRA_EVENT_RELOAD, + LSRA_EVENT_SPECIAL_PUTARG, + LSRA_EVENT_REUSE_REG, }; void dumpLsraAllocationEvent(LsraDumpEvent event, Interval* interval = nullptr, @@ -1533,14 +1549,14 @@ class LinearScan : public LinearScanInterface #if TRACK_LSRA_STATS unsigned regCandidateVarCount; - void updateLsraStat(LsraStat stat, unsigned currentBBNum); - void dumpLsraStats(FILE* file); + void updateLsraStat(LsraStat stat, unsigned currentBBNum); + void dumpLsraStats(FILE* file); LsraStat getLsraStatFromScore(RegisterScore registerScore); LsraStat firstRegSelStat = STAT_FREE; public: - virtual void dumpLsraStatsCsv(FILE* file); - virtual void dumpLsraStatsSummary(FILE* file); + virtual void dumpLsraStatsCsv(FILE* file); + virtual void dumpLsraStatsSummary(FILE* file); static const char* getStatName(unsigned stat); #define INTRACK_STATS(x) x @@ -1576,7 +1592,7 @@ class LinearScan : public LinearScanInterface // Set of blocks that have been visited. BlockSet bbVisitedSet; - void markBlockVisited(BasicBlock* block) + void markBlockVisited(BasicBlock* block) { BlockSetOps::AddElemD(compiler, bbVisitedSet, block->bbNum); } @@ -1603,17 +1619,17 @@ class LinearScan : public LinearScanInterface BasicBlock** blockSequence; // The verifiedAllBBs flag indicates whether we have verified that all BBs have been // included in the blockSeuqence above, during setBlockSequence(). - bool verifiedAllBBs; - void setBlockSequence(); - int compareBlocksForSequencing(BasicBlock* block1, BasicBlock* block2, bool useBlockWeights); + bool verifiedAllBBs; + void setBlockSequence(); + int compareBlocksForSequencing(BasicBlock* block1, BasicBlock* block2, bool useBlockWeights); BasicBlockList* blockSequenceWorkList; bool blockSequencingDone; #ifdef DEBUG // LSRA must not change number of blocks and blockEpoch that it initializes at start. unsigned blockEpoch; #endif // DEBUG - void addToBlockSequenceWorkList(BlockSet sequencedBlockSet, BasicBlock* block, BlockSet& predSet); - void removeFromBlockSequenceWorkList(BasicBlockList* listNode, BasicBlockList* prevNode); + void addToBlockSequenceWorkList(BlockSet sequencedBlockSet, BasicBlock* block, BlockSet& predSet); + void removeFromBlockSequenceWorkList(BasicBlockList* listNode, BasicBlockList* prevNode); BasicBlock* getNextCandidateFromWorkList(); // Indicates whether the allocation pass has been completed. @@ -1714,7 +1730,7 @@ class LinearScan : public LinearScanInterface #if defined(TARGET_AMD64) static const var_types LargeVectorSaveType = TYP_SIMD16; #elif defined(TARGET_ARM64) - static const var_types LargeVectorSaveType = TYP_DOUBLE; + static const var_types LargeVectorSaveType = TYP_DOUBLE; #endif // !defined(TARGET_AMD64) && !defined(TARGET_ARM64) // Set of large vector (TYP_SIMD32 on AVX) variables. VARSET_TP largeVectorVars; @@ -1790,14 +1806,14 @@ class LinearScan : public LinearScanInterface void clearSpillCost(regNumber reg, var_types regType); void updateSpillCost(regNumber reg, Interval* interval); - FORCEINLINE void updateRegsFreeBusyState(RefPosition& refPosition, - regMaskTP regsBusy, - regMaskTP* regsToFree, + FORCEINLINE void updateRegsFreeBusyState(RefPosition& refPosition, + regMaskTP regsBusy, + regMaskTP* regsToFree, regMaskTP* delayRegsToFree DEBUG_ARG(Interval* interval) DEBUG_ARG(regNumber assignedReg)); regMaskTP m_RegistersWithConstants; - void clearConstantReg(regNumber reg, var_types regType) + void clearConstantReg(regNumber reg, var_types regType) { m_RegistersWithConstants &= ~getRegMask(reg, regType); } @@ -1815,7 +1831,7 @@ class LinearScan : public LinearScanInterface regMaskTP fixedRegs; LsraLocation nextFixedRef[REG_COUNT]; - void updateNextFixedRef(RegRecord* regRecord, RefPosition* nextRefPosition); + void updateNextFixedRef(RegRecord* regRecord, RefPosition* nextRefPosition); LsraLocation getNextFixedRef(regNumber regNum, var_types regType) { LsraLocation loc = nextFixedRef[regNum]; @@ -1932,11 +1948,11 @@ class LinearScan : public LinearScanInterface bool checkContainedOrCandidateLclVar(GenTreeLclVar* lclNode); RefPosition* BuildUse(GenTree* operand, regMaskTP candidates = RBM_NONE, int multiRegIdx = 0); - void setDelayFree(RefPosition* use); - int BuildBinaryUses(GenTreeOp* node, regMaskTP candidates = RBM_NONE); - int BuildCastUses(GenTreeCast* cast, regMaskTP candidates); + void setDelayFree(RefPosition* use); + int BuildBinaryUses(GenTreeOp* node, regMaskTP candidates = RBM_NONE); + int BuildCastUses(GenTreeCast* cast, regMaskTP candidates); #ifdef TARGET_XARCH - int BuildRMWUses(GenTree* node, GenTree* op1, GenTree* op2, regMaskTP candidates = RBM_NONE); + int BuildRMWUses(GenTree* node, GenTree* op1, GenTree* op2, regMaskTP candidates = RBM_NONE); inline regMaskTP BuildEvexIncompatibleMask(GenTree* tree); #endif // !TARGET_XARCH int BuildSelect(GenTreeOp* select); @@ -1948,19 +1964,19 @@ class LinearScan : public LinearScanInterface void getTgtPrefOperands(GenTree* tree, GenTree* op1, GenTree* op2, bool* prefOp1, bool* prefOp2); bool supportsSpecialPutArg(); - int BuildSimple(GenTree* tree); - int BuildOperandUses(GenTree* node, regMaskTP candidates = RBM_NONE); - void AddDelayFreeUses(RefPosition* refPosition, GenTree* rmwNode); - int BuildDelayFreeUses(GenTree* node, - GenTree* rmwNode = nullptr, - regMaskTP candidates = RBM_NONE, - RefPosition** useRefPosition = nullptr); - int BuildIndirUses(GenTreeIndir* indirTree, regMaskTP candidates = RBM_NONE); - int BuildAddrUses(GenTree* addr, regMaskTP candidates = RBM_NONE); - void HandleFloatVarArgs(GenTreeCall* call, GenTree* argNode, bool* callHasFloatRegArgs); + int BuildSimple(GenTree* tree); + int BuildOperandUses(GenTree* node, regMaskTP candidates = RBM_NONE); + void AddDelayFreeUses(RefPosition* refPosition, GenTree* rmwNode); + int BuildDelayFreeUses(GenTree* node, + GenTree* rmwNode = nullptr, + regMaskTP candidates = RBM_NONE, + RefPosition** useRefPosition = nullptr); + int BuildIndirUses(GenTreeIndir* indirTree, regMaskTP candidates = RBM_NONE); + int BuildAddrUses(GenTree* addr, regMaskTP candidates = RBM_NONE); + void HandleFloatVarArgs(GenTreeCall* call, GenTree* argNode, bool* callHasFloatRegArgs); RefPosition* BuildDef(GenTree* tree, regMaskTP dstCandidates = RBM_NONE, int multiRegIdx = 0); - void BuildDefs(GenTree* tree, int dstCount, regMaskTP dstCandidates = RBM_NONE); - void BuildDefsWithKills(GenTree* tree, int dstCount, regMaskTP dstCandidates, regMaskTP killMask); + void BuildDefs(GenTree* tree, int dstCount, regMaskTP dstCandidates = RBM_NONE); + void BuildDefsWithKills(GenTree* tree, int dstCount, regMaskTP dstCandidates, regMaskTP killMask); int BuildReturn(GenTree* tree); #ifdef TARGET_XARCH @@ -1971,24 +1987,24 @@ class LinearScan : public LinearScanInterface #ifdef TARGET_ARM int BuildShiftLongCarry(GenTree* tree); #endif - int BuildPutArgReg(GenTreeUnOp* node); - int BuildCall(GenTreeCall* call); - int BuildCmp(GenTree* tree); - int BuildCmpOperands(GenTree* tree); - int BuildBlockStore(GenTreeBlk* blkNode); - int BuildModDiv(GenTree* tree); - int BuildIntrinsic(GenTree* tree); + int BuildPutArgReg(GenTreeUnOp* node); + int BuildCall(GenTreeCall* call); + int BuildCmp(GenTree* tree); + int BuildCmpOperands(GenTree* tree); + int BuildBlockStore(GenTreeBlk* blkNode); + int BuildModDiv(GenTree* tree); + int BuildIntrinsic(GenTree* tree); void BuildStoreLocDef(GenTreeLclVarCommon* storeLoc, LclVarDsc* varDsc, RefPosition* singleUseRef, int index); - int BuildMultiRegStoreLoc(GenTreeLclVar* storeLoc); - int BuildStoreLoc(GenTreeLclVarCommon* tree); - int BuildIndir(GenTreeIndir* indirTree); - int BuildGCWriteBarrier(GenTree* tree); - int BuildCast(GenTreeCast* cast); + int BuildMultiRegStoreLoc(GenTreeLclVar* storeLoc); + int BuildStoreLoc(GenTreeLclVarCommon* tree); + int BuildIndir(GenTreeIndir* indirTree); + int BuildGCWriteBarrier(GenTree* tree); + int BuildCast(GenTreeCast* cast); #if defined(TARGET_XARCH) // returns true if the tree can use the read-modify-write memory instruction form bool isRMWRegOper(GenTree* tree); - int BuildMul(GenTree* tree); + int BuildMul(GenTree* tree); void SetContainsAVXFlags(unsigned sizeOfSIMDVector = 0); #endif // defined(TARGET_XARCH) @@ -2017,7 +2033,7 @@ class LinearScan : public LinearScanInterface #ifdef FEATURE_HW_INTRINSICS int BuildHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree, int* pDstCount); #ifdef TARGET_ARM64 - int BuildConsecutiveRegistersForUse(GenTree* treeNode, GenTree* rmwNode = nullptr); + int BuildConsecutiveRegistersForUse(GenTree* treeNode, GenTree* rmwNode = nullptr); void BuildConsecutiveRegistersForDef(GenTree* treeNode, int fieldCount); #endif // TARGET_ARM64 #endif // FEATURE_HW_INTRINSICS @@ -2538,9 +2554,9 @@ class RefPosition GenTree* buildNode; #endif // DEBUG - RefPosition(unsigned int bbNum, - LsraLocation nodeLocation, - GenTree* treeNode, + RefPosition(unsigned int bbNum, + LsraLocation nodeLocation, + GenTree* treeNode, RefType refType DEBUG_ARG(GenTree* buildNode)) : referent(nullptr) , nextRefPosition(nullptr) diff --git a/src/coreclr/jit/lsraarmarch.cpp b/src/coreclr/jit/lsraarmarch.cpp index 4738fcf33725e6..c2b8b74406584e 100644 --- a/src/coreclr/jit/lsraarmarch.cpp +++ b/src/coreclr/jit/lsraarmarch.cpp @@ -212,7 +212,7 @@ int LinearScan::BuildCall(GenTreeCall* call) RegisterType registerType = call->TypeGet(); -// Set destination candidates for return value of the call. + // Set destination candidates for return value of the call. #ifdef TARGET_ARM if (call->IsHelperCall(compiler, CORINFO_HELP_INIT_PINVOKE_FRAME)) @@ -224,22 +224,22 @@ int LinearScan::BuildCall(GenTreeCall* call) else #endif // TARGET_ARM if (hasMultiRegRetVal) - { - assert(retTypeDesc != nullptr); - dstCandidates = retTypeDesc->GetABIReturnRegs(call->GetUnmanagedCallConv()); - } - else if (varTypeUsesFloatArgReg(registerType)) - { - dstCandidates = RBM_FLOATRET; - } - else if (registerType == TYP_LONG) - { - dstCandidates = RBM_LNGRET; - } - else - { - dstCandidates = RBM_INTRET; - } + { + assert(retTypeDesc != nullptr); + dstCandidates = retTypeDesc->GetABIReturnRegs(call->GetUnmanagedCallConv()); + } + else if (varTypeUsesFloatArgReg(registerType)) + { + dstCandidates = RBM_FLOATRET; + } + else if (registerType == TYP_LONG) + { + dstCandidates = RBM_LNGRET; + } + else + { + dstCandidates = RBM_INTRET; + } // First, count reg args // Each register argument corresponds to one source. diff --git a/src/coreclr/jit/lsrabuild.cpp b/src/coreclr/jit/lsrabuild.cpp index 0eba0d6b19bdc2..511f0d48bb3ae1 100644 --- a/src/coreclr/jit/lsrabuild.cpp +++ b/src/coreclr/jit/lsrabuild.cpp @@ -1155,9 +1155,9 @@ bool LinearScan::buildKillPositionsForNode(GenTree* tree, LsraLocation currentLo #endif // FEATURE_PARTIAL_SIMD_CALLEE_SAVE if (varTypeIsFloating(varDsc) && !VarSetOps::IsMember(compiler, fpCalleeSaveCandidateVars, varIndex)) - { - continue; - } + { + continue; + } Interval* interval = getIntervalForLocalVar(varIndex); const bool isCallKill = ((killMask == RBM_INT_CALLEE_TRASH) || (killMask == RBM_CALLEE_TRASH)); @@ -2217,7 +2217,7 @@ template void LinearScan::buildIntervals(); // which we will do register allocation. // template -void LinearScan::buildIntervals() +void LinearScan::buildIntervals() { BasicBlock* block; @@ -2473,7 +2473,7 @@ void LinearScan::buildIntervals() assert(isCandidateVar(varDsc)); Interval* interval = getIntervalForLocalVar(varIndex); RefPosition* pos = newRefPosition(interval, currentLoc, RefTypeDummyDef, nullptr, - allRegs(interval->registerType)); + allRegs(interval->registerType)); pos->setRegOptional(true); } JITDUMP("Finished creating dummy definitions\n\n"); @@ -2603,19 +2603,21 @@ void LinearScan::buildIntervals() VarSetOps::DiffD(compiler, expUseSet, nextBlock->bbLiveIn); } - block->VisitAllSuccs(compiler, [=, &expUseSet](BasicBlock* succ) { - if (VarSetOps::IsEmpty(compiler, expUseSet)) - { - return BasicBlockVisit::Abort; - } + block->VisitAllSuccs(compiler, + [=, &expUseSet](BasicBlock* succ) + { + if (VarSetOps::IsEmpty(compiler, expUseSet)) + { + return BasicBlockVisit::Abort; + } - if (!isBlockVisited(succ)) - { - VarSetOps::DiffD(compiler, expUseSet, succ->bbLiveIn); - } + if (!isBlockVisited(succ)) + { + VarSetOps::DiffD(compiler, expUseSet, succ->bbLiveIn); + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); if (!VarSetOps::IsEmpty(compiler, expUseSet)) { @@ -3691,7 +3693,7 @@ void LinearScan::BuildStoreLocDef(GenTreeLclVarCommon* storeLoc, defCandidates = allRegs(type); } #else - defCandidates = allRegs(type); + defCandidates = allRegs(type); #endif // TARGET_X86 RefPosition* def = newRefPosition(varDefInterval, currentLoc + 1, RefTypeDef, storeLoc, defCandidates, index); @@ -3965,114 +3967,114 @@ int LinearScan::BuildReturn(GenTree* tree) else #endif // !defined(TARGET_64BIT) if ((tree->TypeGet() != TYP_VOID) && !op1->isContained()) - { - regMaskTP useCandidates = RBM_NONE; + { + regMaskTP useCandidates = RBM_NONE; #if FEATURE_MULTIREG_RET #ifdef TARGET_ARM64 - if (varTypeIsSIMD(tree) && !op1->IsMultiRegLclVar()) - { - BuildUse(op1, RBM_DOUBLERET); - return 1; - } -#endif // TARGET_ARM64 - - if (varTypeIsStruct(tree)) - { - // op1 has to be either a lclvar or a multi-reg returning call - if ((op1->OperGet() == GT_LCL_VAR) && !op1->IsMultiRegLclVar()) + if (varTypeIsSIMD(tree) && !op1->IsMultiRegLclVar()) { - BuildUse(op1, useCandidates); + BuildUse(op1, RBM_DOUBLERET); + return 1; } - else +#endif // TARGET_ARM64 + + if (varTypeIsStruct(tree)) { - noway_assert(op1->IsMultiRegCall() || (op1->IsMultiRegLclVar() && compiler->lvaEnregMultiRegVars)); + // op1 has to be either a lclvar or a multi-reg returning call + if ((op1->OperGet() == GT_LCL_VAR) && !op1->IsMultiRegLclVar()) + { + BuildUse(op1, useCandidates); + } + else + { + noway_assert(op1->IsMultiRegCall() || (op1->IsMultiRegLclVar() && compiler->lvaEnregMultiRegVars)); - ReturnTypeDesc retTypeDesc = compiler->compRetTypeDesc; - const int srcCount = retTypeDesc.GetReturnRegCount(); - assert(op1->GetMultiRegCount(compiler) == static_cast(srcCount)); + ReturnTypeDesc retTypeDesc = compiler->compRetTypeDesc; + const int srcCount = retTypeDesc.GetReturnRegCount(); + assert(op1->GetMultiRegCount(compiler) == static_cast(srcCount)); - // For any source that's coming from a different register file, we need to ensure that - // we reserve the specific ABI register we need. - bool hasMismatchedRegTypes = false; - if (op1->IsMultiRegLclVar()) - { - for (int i = 0; i < srcCount; i++) + // For any source that's coming from a different register file, we need to ensure that + // we reserve the specific ABI register we need. + bool hasMismatchedRegTypes = false; + if (op1->IsMultiRegLclVar()) { - RegisterType srcType = regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i)); - RegisterType dstType = regType(retTypeDesc.GetReturnRegType(i)); - if (srcType != dstType) + for (int i = 0; i < srcCount; i++) { - hasMismatchedRegTypes = true; - regMaskTP dstRegMask = - genRegMask(retTypeDesc.GetABIReturnReg(i, compiler->info.compCallConv)); - - if (varTypeUsesIntReg(dstType)) + RegisterType srcType = regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i)); + RegisterType dstType = regType(retTypeDesc.GetReturnRegType(i)); + if (srcType != dstType) { - buildInternalIntRegisterDefForNode(tree, dstRegMask); - } + hasMismatchedRegTypes = true; + regMaskTP dstRegMask = + genRegMask(retTypeDesc.GetABIReturnReg(i, compiler->info.compCallConv)); + + if (varTypeUsesIntReg(dstType)) + { + buildInternalIntRegisterDefForNode(tree, dstRegMask); + } #if defined(TARGET_XARCH) && defined(FEATURE_SIMD) - else if (varTypeUsesMaskReg(dstType)) - { - buildInternalMaskRegisterDefForNode(tree, dstRegMask); - } + else if (varTypeUsesMaskReg(dstType)) + { + buildInternalMaskRegisterDefForNode(tree, dstRegMask); + } #endif // TARGET_XARCH && FEATURE_SIMD - else - { - assert(varTypeUsesFloatReg(dstType)); - buildInternalFloatRegisterDefForNode(tree, dstRegMask); + else + { + assert(varTypeUsesFloatReg(dstType)); + buildInternalFloatRegisterDefForNode(tree, dstRegMask); + } } } } - } - for (int i = 0; i < srcCount; i++) - { - // We will build uses of the type of the operand registers/fields, and the codegen - // for return will move as needed. - if (!hasMismatchedRegTypes || (regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i)) == - regType(retTypeDesc.GetReturnRegType(i)))) + for (int i = 0; i < srcCount; i++) { - BuildUse(op1, genRegMask(retTypeDesc.GetABIReturnReg(i, compiler->info.compCallConv)), i); + // We will build uses of the type of the operand registers/fields, and the codegen + // for return will move as needed. + if (!hasMismatchedRegTypes || (regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i)) == + regType(retTypeDesc.GetReturnRegType(i)))) + { + BuildUse(op1, genRegMask(retTypeDesc.GetABIReturnReg(i, compiler->info.compCallConv)), i); + } + else + { + BuildUse(op1, RBM_NONE, i); + } } - else + if (hasMismatchedRegTypes) { - BuildUse(op1, RBM_NONE, i); + buildInternalRegisterUses(); } + return srcCount; } - if (hasMismatchedRegTypes) - { - buildInternalRegisterUses(); - } - return srcCount; } - } - else + else #endif // FEATURE_MULTIREG_RET - { - // Non-struct type return - determine useCandidates - switch (tree->TypeGet()) { - case TYP_VOID: - useCandidates = RBM_NONE; - break; - case TYP_FLOAT: - useCandidates = RBM_FLOATRET; - break; - case TYP_DOUBLE: - // We ONLY want the valid double register in the RBM_DOUBLERET mask. - useCandidates = (RBM_DOUBLERET & RBM_ALLDOUBLE); - break; - case TYP_LONG: - useCandidates = RBM_LNGRET; - break; - default: - useCandidates = RBM_INTRET; - break; + // Non-struct type return - determine useCandidates + switch (tree->TypeGet()) + { + case TYP_VOID: + useCandidates = RBM_NONE; + break; + case TYP_FLOAT: + useCandidates = RBM_FLOATRET; + break; + case TYP_DOUBLE: + // We ONLY want the valid double register in the RBM_DOUBLERET mask. + useCandidates = (RBM_DOUBLERET & RBM_ALLDOUBLE); + break; + case TYP_LONG: + useCandidates = RBM_LNGRET; + break; + default: + useCandidates = RBM_INTRET; + break; + } + BuildUse(op1, useCandidates); + return 1; } - BuildUse(op1, useCandidates); - return 1; } - } // No kills or defs. return 0; diff --git a/src/coreclr/jit/lsraxarch.cpp b/src/coreclr/jit/lsraxarch.cpp index 1e7935ee5a2153..ad7d25709ee303 100644 --- a/src/coreclr/jit/lsraxarch.cpp +++ b/src/coreclr/jit/lsraxarch.cpp @@ -1182,33 +1182,33 @@ int LinearScan::BuildCall(GenTreeCall* call) else #endif // TARGET_X86 if (hasMultiRegRetVal) - { - assert(retTypeDesc != nullptr); - dstCandidates = retTypeDesc->GetABIReturnRegs(call->GetUnmanagedCallConv()); - assert((int)genCountBits(dstCandidates) == dstCount); - } - else if (varTypeUsesFloatReg(registerType)) - { + { + assert(retTypeDesc != nullptr); + dstCandidates = retTypeDesc->GetABIReturnRegs(call->GetUnmanagedCallConv()); + assert((int)genCountBits(dstCandidates) == dstCount); + } + else if (varTypeUsesFloatReg(registerType)) + { #ifdef TARGET_X86 - // The return value will be on the X87 stack, and we will need to move it. - dstCandidates = allRegs(registerType); + // The return value will be on the X87 stack, and we will need to move it. + dstCandidates = allRegs(registerType); #else // !TARGET_X86 dstCandidates = RBM_FLOATRET; #endif // !TARGET_X86 - } - else - { - assert(varTypeUsesIntReg(registerType)); - - if (registerType == TYP_LONG) - { - dstCandidates = RBM_LNGRET; } else { - dstCandidates = RBM_INTRET; + assert(varTypeUsesIntReg(registerType)); + + if (registerType == TYP_LONG) + { + dstCandidates = RBM_LNGRET; + } + else + { + dstCandidates = RBM_INTRET; + } } - } // number of args to a call = // callRegArgs + (callargs - placeholders, setup, etc) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index d342a85a324486..75036487fc7dcd 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -344,7 +344,7 @@ GenTree* Compiler::fgMorphExpandCast(GenTreeCast* tree) // x86: src = float, dst = uint32/int64/uint64 or overflow conversion. && (tree->gtOverflow() || varTypeIsLong(dstType) || (dstType == TYP_UINT)) #endif - ) + ) { oper = gtNewCastNode(TYP_DOUBLE, oper, false, TYP_DOUBLE); } @@ -436,7 +436,7 @@ GenTree* Compiler::fgMorphExpandCast(GenTreeCast* tree) #ifdef TARGET_ARM && !varTypeIsLong(oper->AsCast()->CastOp()) #endif - ) + ) { oper->gtType = TYP_FLOAT; oper->CastToType() = TYP_FLOAT; @@ -2109,8 +2109,8 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call unsigned numArgs = CountArgs(); #ifdef TARGET_X86 -// Compute the maximum number of arguments that can be passed in registers. -// For X86 we handle the varargs and unmanaged calling conventions + // Compute the maximum number of arguments that can be passed in registers. + // For X86 we handle the varargs and unmanaged calling conventions #ifndef UNIX_X86_ABI if (call->gtFlags & GTF_CALL_POP_ARGS) @@ -2513,7 +2513,7 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call #elif defined(TARGET_X86) || (isStructArg && comp->isTrivialPointerSizedStruct(argSigClass)) #endif - ) + ) { #ifdef TARGET_ARM if (passUsingFloatRegs) @@ -2936,7 +2936,7 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call // we skip the corresponding floating point register argument intArgRegNum = min(intArgRegNum + size, MAX_REG_ARG); #endif // WINDOWS_AMD64_ABI - // No supported architecture supports partial structs using float registers. + // No supported architecture supports partial structs using float registers. assert(fltArgRegNum <= MAX_FLOAT_REG_ARG); } else @@ -3242,12 +3242,12 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) assert(arg.AbiInfo.GetStackSlotsNumber() == 1); makeOutArgCopy = true; #else // UNIX_AMD64_ABI - // On Unix, structs are always passed by value. - // We only need a copy if we have one of the following: - // - The sizes don't match for a non-lclVar argument. - // - We have a known struct type (e.g. SIMD) that requires multiple registers. - // TODO-Amd64-Unix-Throughput: We don't need to keep the structDesc in the argEntry if it's not - // actually passed in registers. + // On Unix, structs are always passed by value. + // We only need a copy if we have one of the following: + // - The sizes don't match for a non-lclVar argument. + // - We have a known struct type (e.g. SIMD) that requires multiple registers. + // TODO-Amd64-Unix-Throughput: We don't need to keep the structDesc in the argEntry if it's not + // actually passed in registers. if (arg.AbiInfo.IsPassedInRegisters()) { if (argObj->OperIs(GT_BLK)) @@ -3332,9 +3332,9 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) } #ifdef TARGET_AMD64 else if (!argObj->OperIs(GT_LCL_VAR) || !argObj->TypeIs(TYP_SIMD8)) // Handled by lowering. -#else // !TARGET_ARM64 +#else // !TARGET_ARM64 else -#endif // !TARGET_ARM64 +#endif // !TARGET_ARM64 { // TODO-CQ: perform this transformation in lowering instead of here and // avoid marking enregisterable structs DNER. @@ -3615,9 +3615,8 @@ GenTree* Compiler::fgMorphMultiregStructArg(CallArg* arg) { assert(structSize <= MAX_ARG_REG_COUNT * TARGET_POINTER_SIZE); - auto getSlotType = [layout](unsigned inx) { - return (layout != nullptr) ? layout->GetGCPtrType(inx) : TYP_I_IMPL; - }; + auto getSlotType = [layout](unsigned inx) + { return (layout != nullptr) ? layout->GetGCPtrType(inx) : TYP_I_IMPL; }; // Here, we will set the sizes "rounded up" and then adjust the type of the last element below. for (unsigned inx = 0, offset = 0; inx < elemCount; inx++) @@ -3964,19 +3963,21 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg) // We do not reuse within a statement. if (!opts.MinOpts()) { - found = ForEachHbvBitSet(*fgAvailableOutgoingArgTemps, [&](indexType lclNum) { - LclVarDsc* varDsc = lvaGetDesc((unsigned)lclNum); - ClassLayout* layout = varDsc->GetLayout(); - if (!layout->IsBlockLayout() && (layout->GetClassHandle() == copyBlkClass)) - { - tmp = (unsigned)lclNum; - JITDUMP("reusing outgoing struct arg V%02u\n", tmp); - fgAvailableOutgoingArgTemps->clearBit(lclNum); - return HbvWalk::Abort; - } + found = ForEachHbvBitSet(*fgAvailableOutgoingArgTemps, + [&](indexType lclNum) + { + LclVarDsc* varDsc = lvaGetDesc((unsigned)lclNum); + ClassLayout* layout = varDsc->GetLayout(); + if (!layout->IsBlockLayout() && (layout->GetClassHandle() == copyBlkClass)) + { + tmp = (unsigned)lclNum; + JITDUMP("reusing outgoing struct arg V%02u\n", tmp); + fgAvailableOutgoingArgTemps->clearBit(lclNum); + return HbvWalk::Abort; + } - return HbvWalk::Continue; - }) == HbvWalk::Abort; + return HbvWalk::Continue; + }) == HbvWalk::Abort; } // Create the CopyBlk tree and insert it. @@ -4019,7 +4020,7 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg) GenTree* argNode = call->gtArgs.MakeTmpArgNode(this, arg); // Change the expression to "(tmp=val),tmp" - argNode = gtNewOperNode(GT_COMMA, argNode->TypeGet(), copyBlk, argNode); + argNode = gtNewOperNode(GT_COMMA, argNode->TypeGet(), copyBlk, argNode); #endif // !FEATURE_FIXED_OUT_ARGS @@ -4520,7 +4521,7 @@ GenTree* Compiler::fgMorphLeafLocal(GenTreeLclVarCommon* lclNode) #if FEATURE_IMPLICIT_BYREFS || varDsc->lvIsLastUseCopyOmissionCandidate #endif - ) + ) { lclNode->gtFlags |= GTF_GLOB_REF; } @@ -4594,7 +4595,7 @@ GenTree* Compiler::fgMorphExpandStackArgForVarArgs(GenTreeLclVarCommon* lclNode) { GenTree* data = lclNode->Data(); argNode = lclNode->TypeIs(TYP_STRUCT) ? gtNewStoreBlkNode(lclNode->GetLayout(this), argAddr, data) - : gtNewStoreIndNode(lclNode->TypeGet(), argAddr, data)->AsIndir(); + : gtNewStoreIndNode(lclNode->TypeGet(), argAddr, data)->AsIndir(); } else if (lclNode->OperIsLocalRead()) { @@ -5336,7 +5337,8 @@ bool Compiler::fgCanFastTailCall(GenTreeCall* callee, const char** failReason) unsigned calleeArgStackSize = 0; unsigned callerArgStackSize = info.compArgStackSize; - auto reportFastTailCallDecision = [&](const char* thisFailReason) { + auto reportFastTailCallDecision = [&](const char* thisFailReason) + { if (failReason != nullptr) { *failReason = thisFailReason; @@ -5665,7 +5667,8 @@ GenTree* Compiler::fgMorphPotentialTailCall(GenTreeCall* call) // It cannot be an inline candidate assert(!call->IsInlineCandidate()); - auto failTailCall = [&](const char* reason, unsigned lclNum = BAD_VAR_NUM) { + auto failTailCall = [&](const char* reason, unsigned lclNum = BAD_VAR_NUM) + { #ifdef DEBUG if (verbose) { @@ -6860,7 +6863,8 @@ GenTree* Compiler::getRuntimeLookupTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, ArrayStack stmts(getAllocator(CMK_ArrayStack)); - auto cloneTree = [&](GenTree** tree DEBUGARG(const char* reason)) -> GenTree* { + auto cloneTree = [&](GenTree** tree DEBUGARG(const char* reason)) -> GenTree* + { if (!((*tree)->gtFlags & GTF_GLOB_EFFECT)) { GenTree* clone = gtClone(*tree, true); @@ -7779,7 +7783,8 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call) } #ifdef DEBUG - auto resetMorphedFlag = [](GenTree** slot, fgWalkData* data) -> fgWalkResult { + auto resetMorphedFlag = [](GenTree** slot, fgWalkData* data) -> fgWalkResult + { (*slot)->gtDebugFlags &= ~GTF_DEBUG_NODE_MORPHED; return WALK_CONTINUE; }; @@ -7903,7 +7908,7 @@ GenTree* Compiler::fgExpandVirtualVtableCallTarget(GenTreeCall* call) // [tmp + vtabOffsOfIndirection] GenTree* tmpTree1 = gtNewOperNode(GT_ADD, TYP_I_IMPL, gtNewLclvNode(varNum1, TYP_I_IMPL), gtNewIconNode(vtabOffsOfIndirection, TYP_I_IMPL)); - tmpTree1 = gtNewIndir(TYP_I_IMPL, tmpTree1, GTF_IND_NONFAULTING | GTF_IND_INVARIANT); + tmpTree1 = gtNewIndir(TYP_I_IMPL, tmpTree1, GTF_IND_NONFAULTING | GTF_IND_INVARIANT); // var1 + vtabOffsOfIndirection + vtabOffsAfterIndirection GenTree* tmpTree2 = @@ -8321,7 +8326,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA #if FEATURE_IMPLICIT_BYREFS || lclDsc->lvIsLastUseCopyOmissionCandidate #endif - ) + ) { tree->AddAllEffectsFlags(GTF_GLOB_REF); } @@ -8566,8 +8571,8 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA // Note for TARGET_ARMARCH we don't have a remainder instruction, so we don't do this optimization // #else // TARGET_XARCH - // If this is an unsigned long mod with a constant divisor, - // then don't morph to a helper call - it can be done faster inline using idiv. + // If this is an unsigned long mod with a constant divisor, + // then don't morph to a helper call - it can be done faster inline using idiv. noway_assert(op2); if ((typ == TYP_LONG) && opts.OptimizationEnabled()) @@ -11329,7 +11334,8 @@ GenTree* Compiler::fgOptimizeRelationalComparisonWithCasts(GenTreeOp* cmp) return cmp; } - auto supportedOp = [](GenTree* op) { + auto supportedOp = [](GenTree* op) + { if (op->IsIntegralConst()) { return true; @@ -11359,7 +11365,8 @@ GenTree* Compiler::fgOptimizeRelationalComparisonWithCasts(GenTreeOp* cmp) return cmp; } - auto isUpperZero = [this](GenTree* op) { + auto isUpperZero = [this](GenTree* op) + { if (op->IsIntegralConst()) { int64_t lng = op->AsIntConCommon()->LngValue(); @@ -11385,7 +11392,8 @@ GenTree* Compiler::fgOptimizeRelationalComparisonWithCasts(GenTreeOp* cmp) cmp->SetUnsigned(); - auto transform = [this](GenTree** use) { + auto transform = [this](GenTree** use) + { if ((*use)->IsIntegralConst()) { (*use)->BashToConst(static_cast((*use)->AsIntConCommon()->LngValue())); @@ -11545,8 +11553,8 @@ GenTree* Compiler::fgMorphRetInd(GenTreeUnOp* ret) #if defined(TARGET_64BIT) bool canFold = (indSize == lclVarSize); #else // !TARGET_64BIT - // TODO: improve 32 bit targets handling for LONG returns if necessary, nowadays we do not support `BITCAST - // long<->double` there. + // TODO: improve 32 bit targets handling for LONG returns if necessary, nowadays we do not support `BITCAST + // long<->double` there. bool canFold = (indSize == lclVarSize) && (lclVarSize <= REGSIZE_BYTES); #endif @@ -12571,12 +12579,12 @@ GenTree* Compiler::fgMorphTree(GenTree* tree, MorphAddrContext* mac) bool optAssertionPropDone = false; -/*------------------------------------------------------------------------- - * fgMorphTree() can potentially replace a tree with another, and the - * caller has to store the return value correctly. - * Turn this on to always make copy of "tree" here to shake out - * hidden/unupdated references. - */ + /*------------------------------------------------------------------------- + * fgMorphTree() can potentially replace a tree with another, and the + * caller has to store the return value correctly. + * Turn this on to always make copy of "tree" here to shake out + * hidden/unupdated references. + */ #ifdef DEBUG @@ -12877,7 +12885,8 @@ void Compiler::fgAssertionGen(GenTree* tree) // Helper to note when an existing assertion has been // brought back to life. // - auto announce = [&](AssertionIndex apIndex, const char* condition) { + auto announce = [&](AssertionIndex apIndex, const char* condition) + { #ifdef DEBUG if (verbose) { @@ -13499,9 +13508,7 @@ void Compiler::fgMorphStmtBlockOps(BasicBlock* block, Statement* stmt) DoPostOrder = true, }; - Visitor(Compiler* comp) : GenTreeVisitor(comp) - { - } + Visitor(Compiler* comp) : GenTreeVisitor(comp) {} fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { @@ -14975,9 +14982,7 @@ PhaseStatus Compiler::fgMarkImplicitByRefCopyOmissionCandidates() UseExecutionOrder = true, }; - Visitor(Compiler* comp) : GenTreeVisitor(comp) - { - } + Visitor(Compiler* comp) : GenTreeVisitor(comp) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -15187,9 +15192,9 @@ PhaseStatus Compiler::fgRetypeImplicitByRefArgs() { // Insert IR that initializes the temp from the parameter. fgEnsureFirstBBisScratch(); - GenTree* addr = gtNewLclvNode(lclNum, TYP_BYREF); - GenTree* data = (varDsc->TypeGet() == TYP_STRUCT) ? gtNewBlkIndir(varDsc->GetLayout(), addr) - : gtNewIndir(varDsc->TypeGet(), addr); + GenTree* addr = gtNewLclvNode(lclNum, TYP_BYREF); + GenTree* data = (varDsc->TypeGet() == TYP_STRUCT) ? gtNewBlkIndir(varDsc->GetLayout(), addr) + : gtNewIndir(varDsc->TypeGet(), addr); GenTree* store = gtNewStoreLclVarNode(newLclNum, data); fgNewStmtAtBeg(fgFirstBB, store); } diff --git a/src/coreclr/jit/morphblock.cpp b/src/coreclr/jit/morphblock.cpp index d7fa5821eb9dbc..ede7c64ad2bcaa 100644 --- a/src/coreclr/jit/morphblock.cpp +++ b/src/coreclr/jit/morphblock.cpp @@ -530,13 +530,15 @@ GenTree* MorphInitBlockHelper::EliminateCommas(GenTree** commaPool) { *commaPool = nullptr; - GenTree* sideEffects = nullptr; - auto addSideEffect = [&sideEffects](GenTree* sideEff) { + GenTree* sideEffects = nullptr; + auto addSideEffect = [&sideEffects](GenTree* sideEff) + { sideEff->gtNext = sideEffects; sideEffects = sideEff; }; - auto addComma = [commaPool, &addSideEffect](GenTree* comma) { + auto addComma = [commaPool, &addSideEffect](GenTree* comma) + { addSideEffect(comma->gtGetOp1()); comma->gtNext = *commaPool; *commaPool = comma; @@ -645,9 +647,7 @@ GenTree* MorphCopyBlockHelper::MorphCopyBlock(Compiler* comp, GenTree* tree) // Notes: // Most class members are initialized via in-class member initializers. // -MorphCopyBlockHelper::MorphCopyBlockHelper(Compiler* comp, GenTree* store) : MorphInitBlockHelper(comp, store, false) -{ -} +MorphCopyBlockHelper::MorphCopyBlockHelper(Compiler* comp, GenTree* store) : MorphInitBlockHelper(comp, store, false) {} //------------------------------------------------------------------------ // PrepareSrc: Initialize member fields with information about the store's @@ -1042,7 +1042,8 @@ void MorphCopyBlockHelper::TryPrimitiveCopy() return; } - auto doRetypeNode = [storeType](GenTree* op, LclVarDsc* varDsc, bool isUse) { + auto doRetypeNode = [storeType](GenTree* op, LclVarDsc* varDsc, bool isUse) + { if (op->OperIsIndir()) { op->SetOper(isUse ? GT_IND : GT_STOREIND); @@ -1182,7 +1183,8 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField() addrSpillStore = m_comp->gtNewTempStore(addrSpillTemp, addrSpill); } - auto grabAddr = [=, &result](unsigned offs) { + auto grabAddr = [=, &result](unsigned offs) + { GenTree* addrClone = nullptr; // Need address of the source. if (addrSpill) diff --git a/src/coreclr/jit/objectalloc.cpp b/src/coreclr/jit/objectalloc.cpp index a86039dc333840..16847c29ee74f5 100644 --- a/src/coreclr/jit/objectalloc.cpp +++ b/src/coreclr/jit/objectalloc.cpp @@ -504,8 +504,8 @@ unsigned int ObjectAllocator::MorphAllocObjNodeIntoStackAlloc(GenTreeAllocObj* a assert(m_AnalysisDone); const bool shortLifetime = false; - const unsigned int lclNum = comp->lvaGrabTemp(shortLifetime DEBUGARG("MorphAllocObjNodeIntoStackAlloc temp")); - const int unsafeValueClsCheck = true; + const unsigned int lclNum = comp->lvaGrabTemp(shortLifetime DEBUGARG("MorphAllocObjNodeIntoStackAlloc temp")); + const int unsafeValueClsCheck = true; comp->lvaSetStruct(lclNum, allocObj->gtAllocObjClsHnd, unsafeValueClsCheck); // Initialize the object memory if necessary. diff --git a/src/coreclr/jit/objectalloc.h b/src/coreclr/jit/objectalloc.h index f4a56cb4ca39d9..07307161da002b 100644 --- a/src/coreclr/jit/objectalloc.h +++ b/src/coreclr/jit/objectalloc.h @@ -47,21 +47,21 @@ class ObjectAllocator final : public Phase virtual PhaseStatus DoPhase() override; private: - bool CanAllocateLclVarOnStack(unsigned int lclNum, CORINFO_CLASS_HANDLE clsHnd); - bool CanLclVarEscape(unsigned int lclNum); - void MarkLclVarAsPossiblyStackPointing(unsigned int lclNum); - void MarkLclVarAsDefinitelyStackPointing(unsigned int lclNum); - bool MayLclVarPointToStack(unsigned int lclNum); - bool DoesLclVarPointToStack(unsigned int lclNum); - void DoAnalysis(); - void MarkLclVarAsEscaping(unsigned int lclNum); - void MarkEscapingVarsAndBuildConnGraph(); - void AddConnGraphEdge(unsigned int sourceLclNum, unsigned int targetLclNum); - void ComputeEscapingNodes(BitVecTraits* bitVecTraits, BitVec& escapingNodes); - void ComputeStackObjectPointers(BitVecTraits* bitVecTraits); - bool MorphAllocObjNodes(); - void RewriteUses(); - GenTree* MorphAllocObjNodeIntoHelperCall(GenTreeAllocObj* allocObj); + bool CanAllocateLclVarOnStack(unsigned int lclNum, CORINFO_CLASS_HANDLE clsHnd); + bool CanLclVarEscape(unsigned int lclNum); + void MarkLclVarAsPossiblyStackPointing(unsigned int lclNum); + void MarkLclVarAsDefinitelyStackPointing(unsigned int lclNum); + bool MayLclVarPointToStack(unsigned int lclNum); + bool DoesLclVarPointToStack(unsigned int lclNum); + void DoAnalysis(); + void MarkLclVarAsEscaping(unsigned int lclNum); + void MarkEscapingVarsAndBuildConnGraph(); + void AddConnGraphEdge(unsigned int sourceLclNum, unsigned int targetLclNum); + void ComputeEscapingNodes(BitVecTraits* bitVecTraits, BitVec& escapingNodes); + void ComputeStackObjectPointers(BitVecTraits* bitVecTraits); + bool MorphAllocObjNodes(); + void RewriteUses(); + GenTree* MorphAllocObjNodeIntoHelperCall(GenTreeAllocObj* allocObj); unsigned int MorphAllocObjNodeIntoStackAlloc(GenTreeAllocObj* allocObj, BasicBlock* block, Statement* stmt); struct BuildConnGraphVisitorCallbackData; bool CanLclVarEscapeViaParentStack(ArrayStack* parentStack, unsigned int lclNum); diff --git a/src/coreclr/jit/optcse.cpp b/src/coreclr/jit/optcse.cpp index cb17b65035cd5f..ad58b44b966f43 100644 --- a/src/coreclr/jit/optcse.cpp +++ b/src/coreclr/jit/optcse.cpp @@ -204,9 +204,7 @@ void Compiler::optCSE_GetMaskData(GenTree* tree, optCSE_MaskData* pMaskData) DoPreOrder = true, }; - MaskDataWalker(Compiler* comp, optCSE_MaskData* maskData) : GenTreeVisitor(comp), m_maskData(maskData) - { - } + MaskDataWalker(Compiler* comp, optCSE_MaskData* maskData) : GenTreeVisitor(comp), m_maskData(maskData) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -1186,9 +1184,7 @@ class CSE_DataFlow EXPSET_TP m_preMergeOut; public: - CSE_DataFlow(Compiler* pCompiler) : m_comp(pCompiler), m_preMergeOut(BitVecOps::UninitVal()) - { - } + CSE_DataFlow(Compiler* pCompiler) : m_comp(pCompiler), m_preMergeOut(BitVecOps::UninitVal()) {} // At the start of the merge function of the dataflow equations, initialize premerge state (to detect changes.) void StartMerge(BasicBlock* block) @@ -2200,9 +2196,7 @@ void CSE_HeuristicRandom::ConsiderCandidates() // This creates the replay CSE heuristic. It does CSEs specifed by // the ArrayConfig parsing of JitReplayCSE. // -CSE_HeuristicReplay::CSE_HeuristicReplay(Compiler* pCompiler) : CSE_HeuristicCommon(pCompiler) -{ -} +CSE_HeuristicReplay::CSE_HeuristicReplay(Compiler* pCompiler) : CSE_HeuristicCommon(pCompiler) {} //------------------------------------------------------------------------ // Announce: describe heuristic in jit dump @@ -2605,7 +2599,7 @@ void CSE_HeuristicParameterized::GetFeatures(CSEdsc* cse, double* features) if (!isLiveAcrossCallLSRA) { unsigned count = 0; - for (BasicBlock *block = minPostorderBlock; + for (BasicBlock* block = minPostorderBlock; block != nullptr && block != maxPostorderBlock && count < blockSpread; block = block->Next(), count++) { if (block->HasFlag(BBF_HAS_CALL)) diff --git a/src/coreclr/jit/optcse.h b/src/coreclr/jit/optcse.h index 550f754f6a8b6e..b18f6e2a79783d 100644 --- a/src/coreclr/jit/optcse.h +++ b/src/coreclr/jit/optcse.h @@ -31,13 +31,9 @@ class CSE_HeuristicCommon #endif public: - virtual void Initialize() - { - } + virtual void Initialize() {} - virtual void SortCandidates() - { - } + virtual void SortCandidates() {} virtual bool PromotionCheck(CSE_Candidate* candidate) { @@ -62,9 +58,7 @@ class CSE_HeuristicCommon return false; } - virtual void AdjustHeuristic(CSE_Candidate* candidate) - { - } + virtual void AdjustHeuristic(CSE_Candidate* candidate) {} virtual const char* Name() const { @@ -181,11 +175,11 @@ class CSE_HeuristicParameterized : public CSE_HeuristicCommon void CaptureLocalWeights(); void GreedyPolicy(); - void GetFeatures(CSEdsc* dsc, double* features); + void GetFeatures(CSEdsc* dsc, double* features); double Preference(CSEdsc* dsc); - void GetStoppingFeatures(double* features); + void GetStoppingFeatures(double* features); double StoppingPreference(); - void BuildChoices(ArrayStack& choices); + void BuildChoices(ArrayStack& choices); Choice& ChooseGreedy(ArrayStack& choices, bool recompute); @@ -227,12 +221,12 @@ class CSE_HeuristicRL : public CSE_HeuristicParameterized bool m_updateParameters; bool m_greedy; - Choice& ChooseSoftmax(ArrayStack& choices); - void Softmax(ArrayStack& choices); - void SoftmaxPolicy(); - void UpdateParametersStep(CSEdsc* dsc, ArrayStack& choices, double reward, double* delta); - void UpdateParameters(); - Choice* FindChoice(CSEdsc* dsc, ArrayStack& choices); + Choice& ChooseSoftmax(ArrayStack& choices); + void Softmax(ArrayStack& choices); + void SoftmaxPolicy(); + void UpdateParametersStep(CSEdsc* dsc, ArrayStack& choices, double reward, double* delta); + void UpdateParameters(); + Choice* FindChoice(CSEdsc* dsc, ArrayStack& choices); const char* Name() const; public: diff --git a/src/coreclr/jit/optimizebools.cpp b/src/coreclr/jit/optimizebools.cpp index d456cb3793f5ef..3d1da4aa772ff2 100644 --- a/src/coreclr/jit/optimizebools.cpp +++ b/src/coreclr/jit/optimizebools.cpp @@ -74,10 +74,10 @@ class OptBoolsDsc private: Statement* optOptimizeBoolsChkBlkCond(); - GenTree* optIsBoolComp(OptTestInfo* pOptTest); - bool optOptimizeBoolsChkTypeCostCond(); - void optOptimizeBoolsUpdateTrees(); - bool FindCompareChain(GenTree* condition, bool* isTestCondition); + GenTree* optIsBoolComp(OptTestInfo* pOptTest); + bool optOptimizeBoolsChkTypeCostCond(); + void optOptimizeBoolsUpdateTrees(); + bool FindCompareChain(GenTree* condition, bool* isTestCondition); }; //----------------------------------------------------------------------------- @@ -439,7 +439,8 @@ static bool GetIntersection(var_types type, } // Convert to a canonical form with GT_GE or GT_LE (inclusive). - auto normalize = [](genTreeOps* cmp, ssize_t* cns) { + auto normalize = [](genTreeOps* cmp, ssize_t* cns) + { if (*cmp == GT_GT) { // "X > cns" -> "X >= cns + 1" diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index c7760c4241c361..182ddaff022fea 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -37,9 +37,7 @@ void Compiler::optInit() optCSEunmarks = 0; } -DataFlow::DataFlow(Compiler* pCompiler) : m_pCompiler(pCompiler) -{ -} +DataFlow::DataFlow(Compiler* pCompiler) : m_pCompiler(pCompiler) {} //------------------------------------------------------------------------ // optSetBlockWeights: adjust block weights, as follows: @@ -221,7 +219,8 @@ void Compiler::optScaleLoopBlocks(BasicBlock* begBlk, BasicBlock* endBlk) // At least one backedge must have been found (the one from endBlk). noway_assert(backedgeList); - auto reportBlockWeight = [&](BasicBlock* blk, const char* message) { + auto reportBlockWeight = [&](BasicBlock* blk, const char* message) + { #ifdef DEBUG if (verbose) { @@ -889,7 +888,7 @@ bool Compiler::optComputeLoopRep(int constInit, switch (iterOperType) { -// For small types, the iteration operator will narrow these values if big + // For small types, the iteration operator will narrow these values if big #define INIT_ITER_BY_TYPE(type) \ constInitX = (type)constInit; \ @@ -908,7 +907,7 @@ bool Compiler::optComputeLoopRep(int constInit, INIT_ITER_BY_TYPE(unsigned short); break; - // For the big types, 32 bit arithmetic is performed + // For the big types, 32 bit arithmetic is performed case TYP_INT: if (unsTest) @@ -1550,15 +1549,17 @@ bool Compiler::optTryUnrollLoop(FlowGraphNaturalLoop* loop, bool* changedIR) ClrSafeInt loopCostSz; // Cost is size of one iteration - loop->VisitLoopBlocksReversePostOrder([=, &loopCostSz](BasicBlock* block) { - for (Statement* const stmt : block->Statements()) + loop->VisitLoopBlocksReversePostOrder( + [=, &loopCostSz](BasicBlock* block) { - gtSetStmtInfo(stmt); - loopCostSz += stmt->GetCostSz(); - } + for (Statement* const stmt : block->Statements()) + { + gtSetStmtInfo(stmt); + loopCostSz += stmt->GetCostSz(); + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); #ifdef DEBUG // Today we will never see any BBJ_RETURN blocks because we cannot @@ -1568,10 +1569,12 @@ bool Compiler::optTryUnrollLoop(FlowGraphNaturalLoop* loop, bool* changedIR) // flow can reach the header, but that would require the handler to also be // part of the loop, which guarantees that the loop contains two distinct // EH regions. - loop->VisitLoopBlocks([](BasicBlock* block) { - assert(!block->KindIs(BBJ_RETURN)); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks( + [](BasicBlock* block) + { + assert(!block->KindIs(BBJ_RETURN)); + return BasicBlockVisit::Continue; + }); #endif // Compute the estimated increase in code size for the unrolled loop. @@ -1646,10 +1649,12 @@ bool Compiler::optTryUnrollLoop(FlowGraphNaturalLoop* loop, bool* changedIR) loop->Duplicate(&insertAfter, &blockMap, scaleWeight); // Replace all uses of the loop iterator with the current value. - loop->VisitLoopBlocks([=, &blockMap](BasicBlock* block) { - optReplaceScalarUsesWithConst(blockMap[block], lvar, lval); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks( + [=, &blockMap](BasicBlock* block) + { + optReplaceScalarUsesWithConst(blockMap[block], lvar, lval); + return BasicBlockVisit::Continue; + }); // Remove the test we created in the duplicate; we're doing a full unroll. BasicBlock* testBlock = blockMap[iterInfo.TestBlock]; @@ -1841,9 +1846,7 @@ Compiler::OptInvertCountTreeInfoType Compiler::optInvertCountTreeInfo(GenTree* t Compiler::OptInvertCountTreeInfoType Result = {}; - CountTreeInfoVisitor(Compiler* comp) : GenTreeVisitor(comp) - { - } + CountTreeInfoVisitor(Compiler* comp) : GenTreeVisitor(comp) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -3126,14 +3129,16 @@ bool Compiler::optCanonicalizeExits(FlowGraphNaturalLoop* loop) // destination block of the exit edge may no longer be right, so we // cannot use VisitRegularExitBlocks. The canonicalization here works // despite this. - edge->getSourceBlock()->VisitRegularSuccs(this, [=, &changed](BasicBlock* succ) { - if (!loop->ContainsBlock(succ)) - { - changed |= optCanonicalizeExit(loop, succ); - } + edge->getSourceBlock()->VisitRegularSuccs(this, + [=, &changed](BasicBlock* succ) + { + if (!loop->ContainsBlock(succ)) + { + changed |= optCanonicalizeExit(loop, succ); + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } return changed; @@ -3260,21 +3265,23 @@ weight_t Compiler::optEstimateEdgeLikelihood(BasicBlock* from, BasicBlock* to, b if (useEdgeWeights) { - from->VisitRegularSuccs(this, [&, to](BasicBlock* succ) { - *fromProfile &= succ->hasProfileWeight(); - FlowEdge* edge = fgGetPredForBlock(succ, from); - weight_t edgeWeight = (edge->edgeWeightMin() + edge->edgeWeightMax()) / 2.0; + from->VisitRegularSuccs(this, + [&, to](BasicBlock* succ) + { + *fromProfile &= succ->hasProfileWeight(); + FlowEdge* edge = fgGetPredForBlock(succ, from); + weight_t edgeWeight = (edge->edgeWeightMin() + edge->edgeWeightMax()) / 2.0; - if (succ == to) - { - takenCount += edgeWeight; - } - else - { - notTakenCount += edgeWeight; - } - return BasicBlockVisit::Continue; - }); + if (succ == to) + { + takenCount += edgeWeight; + } + else + { + notTakenCount += edgeWeight; + } + return BasicBlockVisit::Continue; + }); // Watch out for cases where edge weights were not properly maintained // so that it appears no profile flow goes to 'to'. @@ -3287,19 +3294,21 @@ weight_t Compiler::optEstimateEdgeLikelihood(BasicBlock* from, BasicBlock* to, b takenCount = 0; notTakenCount = 0; - from->VisitRegularSuccs(this, [&, to](BasicBlock* succ) { - *fromProfile &= succ->hasProfileWeight(); - if (succ == to) - { - takenCount += succ->bbWeight; - } - else - { - notTakenCount += succ->bbWeight; - } + from->VisitRegularSuccs(this, + [&, to](BasicBlock* succ) + { + *fromProfile &= succ->hasProfileWeight(); + if (succ == to) + { + takenCount += succ->bbWeight; + } + else + { + notTakenCount += succ->bbWeight; + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } if (!*fromProfile) @@ -3516,8 +3525,8 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu return true; - /* Operands that are in memory can usually be narrowed - simply by changing their gtType */ + /* Operands that are in memory can usually be narrowed + simply by changing their gtType */ case GT_LCL_VAR: /* We only allow narrowing long -> int for a GT_LCL_VAR */ @@ -4812,9 +4821,9 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop, // To be invariant the variable must be in SSA ... bool isInvariant = lclVar->HasSsaName(); // and the SSA definition must be outside the loop we're hoisting from ... - isInvariant = isInvariant && - !m_loop->ContainsBlock( - m_compiler->lvaGetDesc(lclNum)->GetPerSsaData(lclVar->GetSsaNum())->GetBlock()); + isInvariant = + isInvariant && !m_loop->ContainsBlock( + m_compiler->lvaGetDesc(lclNum)->GetPerSsaData(lclVar->GetSsaNum())->GetBlock()); // and the VN of the tree is considered invariant as well. // @@ -5499,13 +5508,15 @@ void Compiler::optComputeLoopSideEffects() // The side effect code benefits from seeing things in RPO as it has some // limited treatment assignments it has seen the value of. - loop->VisitLoopBlocksReversePostOrder([=](BasicBlock* loopBlock) { - FlowGraphNaturalLoop* loop = m_blockToLoop->GetLoop(loopBlock); - assert(loop != nullptr); - optComputeLoopSideEffectsOfBlock(loopBlock, loop); + loop->VisitLoopBlocksReversePostOrder( + [=](BasicBlock* loopBlock) + { + FlowGraphNaturalLoop* loop = m_blockToLoop->GetLoop(loopBlock); + assert(loop != nullptr); + optComputeLoopSideEffectsOfBlock(loopBlock, loop); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } } diff --git a/src/coreclr/jit/patchpoint.cpp b/src/coreclr/jit/patchpoint.cpp index 5a273679067748..daff2cb4a56aaf 100644 --- a/src/coreclr/jit/patchpoint.cpp +++ b/src/coreclr/jit/patchpoint.cpp @@ -34,9 +34,7 @@ class PatchpointTransformer Compiler* compiler; public: - PatchpointTransformer(Compiler* compiler) : ppCounterLclNum(BAD_VAR_NUM), compiler(compiler) - { - } + PatchpointTransformer(Compiler* compiler) : ppCounterLclNum(BAD_VAR_NUM), compiler(compiler) {} //------------------------------------------------------------------------ // Run: run transformation for each block. diff --git a/src/coreclr/jit/phase.h b/src/coreclr/jit/phase.h index 6288d596729daf..12adf0bd70d36a 100644 --- a/src/coreclr/jit/phase.h +++ b/src/coreclr/jit/phase.h @@ -41,7 +41,7 @@ class Phase virtual void PrePhase(); virtual PhaseStatus DoPhase() = 0; - virtual void PostPhase(PhaseStatus status); + virtual void PostPhase(PhaseStatus status); Compiler* comp; const char* m_name; @@ -54,9 +54,7 @@ template class ActionPhase final : public Phase { public: - ActionPhase(Compiler* _compiler, Phases _phase, A _action) : Phase(_compiler, _phase), action(_action) - { - } + ActionPhase(Compiler* _compiler, Phases _phase, A _action) : Phase(_compiler, _phase), action(_action) {} protected: virtual PhaseStatus DoPhase() override diff --git a/src/coreclr/jit/promotion.cpp b/src/coreclr/jit/promotion.cpp index 2f7b1e0b31372c..3c8ef9a45cc1d3 100644 --- a/src/coreclr/jit/promotion.cpp +++ b/src/coreclr/jit/promotion.cpp @@ -277,9 +277,7 @@ struct PrimitiveAccess unsigned Offset; var_types AccessType; - PrimitiveAccess(unsigned offset, var_types accessType) : Offset(offset), AccessType(accessType) - { - } + PrimitiveAccess(unsigned offset, var_types accessType) : Offset(offset), AccessType(accessType) {} }; // Tracks all the accesses into one particular struct local. @@ -973,7 +971,7 @@ class LocalsUseVisitor : public GenTreeVisitor , m_prom(prom) , m_candidateStores(prom->m_compiler->getAllocator(CMK_Promotion)) { - m_uses = new (prom->m_compiler, CMK_Promotion) LocalUses*[prom->m_compiler->lvaCount]{}; + m_uses = new (prom->m_compiler, CMK_Promotion) LocalUses* [prom->m_compiler->lvaCount] {}; } //------------------------------------------------------------------------ @@ -2269,9 +2267,7 @@ void ReplaceVisitor::InsertPreStatementWriteBacks() DoPreOrder = true, }; - Visitor(Compiler* comp, ReplaceVisitor* replacer) : GenTreeVisitor(comp), m_replacer(replacer) - { - } + Visitor(Compiler* comp, ReplaceVisitor* replacer) : GenTreeVisitor(comp), m_replacer(replacer) {} fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -2680,19 +2676,22 @@ void ReplaceVisitor::CheckForwardSubForLastUse(unsigned lclNum) // void ReplaceVisitor::WriteBackBeforeCurrentStatement(unsigned lcl, unsigned offs, unsigned size) { - VisitOverlappingReplacements(lcl, offs, size, [this, lcl](Replacement& rep) { - if (!rep.NeedsWriteBack) - { - return; - } - - GenTree* readBack = Promotion::CreateWriteBack(m_compiler, lcl, rep); - Statement* stmt = m_compiler->fgNewStmtFromTree(readBack); - JITDUMP("Writing back %s before " FMT_STMT "\n", rep.Description, m_currentStmt->GetID()); - DISPSTMT(stmt); - m_compiler->fgInsertStmtBefore(m_currentBlock, m_currentStmt, stmt); - ClearNeedsWriteBack(rep); - }); + VisitOverlappingReplacements(lcl, offs, size, + [this, lcl](Replacement& rep) + { + if (!rep.NeedsWriteBack) + { + return; + } + + GenTree* readBack = Promotion::CreateWriteBack(m_compiler, lcl, rep); + Statement* stmt = m_compiler->fgNewStmtFromTree(readBack); + JITDUMP("Writing back %s before " FMT_STMT "\n", rep.Description, + m_currentStmt->GetID()); + DISPSTMT(stmt); + m_compiler->fgInsertStmtBefore(m_currentBlock, m_currentStmt, stmt); + ClearNeedsWriteBack(rep); + }); } //------------------------------------------------------------------------ @@ -2708,20 +2707,24 @@ void ReplaceVisitor::WriteBackBeforeCurrentStatement(unsigned lcl, unsigned offs // void ReplaceVisitor::WriteBackBeforeUse(GenTree** use, unsigned lcl, unsigned offs, unsigned size) { - VisitOverlappingReplacements(lcl, offs, size, [this, &use, lcl](Replacement& rep) { - if (!rep.NeedsWriteBack) - { - return; - } - - GenTreeOp* comma = m_compiler->gtNewOperNode(GT_COMMA, (*use)->TypeGet(), - Promotion::CreateWriteBack(m_compiler, lcl, rep), *use); - *use = comma; - use = &comma->gtOp2; - - ClearNeedsWriteBack(rep); - m_madeChanges = true; - }); + VisitOverlappingReplacements(lcl, offs, size, + [this, &use, lcl](Replacement& rep) + { + if (!rep.NeedsWriteBack) + { + return; + } + + GenTreeOp* comma = + m_compiler->gtNewOperNode(GT_COMMA, (*use)->TypeGet(), + Promotion::CreateWriteBack(m_compiler, lcl, rep), + *use); + *use = comma; + use = &comma->gtOp2; + + ClearNeedsWriteBack(rep); + m_madeChanges = true; + }); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/promotion.h b/src/coreclr/jit/promotion.h index c421b019bc8f99..f0a87783da87ea 100644 --- a/src/coreclr/jit/promotion.h +++ b/src/coreclr/jit/promotion.h @@ -31,9 +31,7 @@ struct Replacement const char* Description = ""; #endif - Replacement(unsigned offset, var_types accessType) : Offset(offset), AccessType(accessType) - { - } + Replacement(unsigned offset, var_types accessType) : Offset(offset), AccessType(accessType) {} bool Overlaps(unsigned otherStart, unsigned otherSize) const; }; @@ -51,13 +49,9 @@ class StructSegments unsigned Start = 0; unsigned End = 0; - Segment() - { - } + Segment() {} - Segment(unsigned start, unsigned end) : Start(start), End(end) - { - } + Segment(unsigned start, unsigned end) : Start(start), End(end) {} bool IntersectsOrAdjacent(const Segment& other) const; bool Intersects(const Segment& other) const; @@ -69,9 +63,7 @@ class StructSegments jitstd::vector m_segments; public: - explicit StructSegments(CompAllocator allocator) : m_segments(allocator) - { - } + explicit StructSegments(CompAllocator allocator) : m_segments(allocator) {} void Add(const Segment& segment); void Subtract(const Segment& segment); @@ -96,9 +88,7 @@ struct AggregateInfo // Max offset in the struct local of the unpromoted part. unsigned UnpromotedMax = 0; - AggregateInfo(CompAllocator alloc, unsigned lclNum) : Replacements(alloc), LclNum(lclNum), Unpromoted(alloc) - { - } + AggregateInfo(CompAllocator alloc, unsigned lclNum) : Replacements(alloc), LclNum(lclNum), Unpromoted(alloc) {} bool OverlappingReplacements(unsigned offset, unsigned size, @@ -115,7 +105,7 @@ class AggregateInfoMap public: AggregateInfoMap(CompAllocator allocator, unsigned numLocals); - void Add(AggregateInfo* agg); + void Add(AggregateInfo* agg); AggregateInfo* Lookup(unsigned lclNum); jitstd::vector::iterator begin() @@ -146,10 +136,10 @@ class Promotion StructSegments SignificantSegments(ClassLayout* layout); - void ExplicitlyZeroInitReplacementLocals(unsigned lclNum, - const jitstd::vector& replacements, - Statement** prevStmt); - void InsertInitStatement(Statement** prevStmt, GenTree* tree); + void ExplicitlyZeroInitReplacementLocals(unsigned lclNum, + const jitstd::vector& replacements, + Statement** prevStmt); + void InsertInitStatement(Statement** prevStmt, GenTree* tree); static GenTree* CreateWriteBack(Compiler* compiler, unsigned structLclNum, const Replacement& replacement); static GenTree* CreateReadBack(Compiler* compiler, unsigned structLclNum, const Replacement& replacement); @@ -198,13 +188,11 @@ class Promotion bool HaveCandidateLocals(); - static bool IsCandidateForPhysicalPromotion(LclVarDsc* dsc); + static bool IsCandidateForPhysicalPromotion(LclVarDsc* dsc); static GenTree* EffectiveUser(Compiler::GenTreeStack& ancestors); public: - explicit Promotion(Compiler* compiler) : m_compiler(compiler) - { - } + explicit Promotion(Compiler* compiler) : m_compiler(compiler) {} PhaseStatus Run(); }; @@ -218,14 +206,10 @@ class StructDeaths friend class PromotionLiveness; private: - StructDeaths(BitVec deaths, AggregateInfo* agg) : m_deaths(deaths), m_aggregate(agg) - { - } + StructDeaths(BitVec deaths, AggregateInfo* agg) : m_deaths(deaths), m_aggregate(agg) {} public: - StructDeaths() : m_deaths(BitVecOps::UninitVal()) - { - } + StructDeaths() : m_deaths(BitVecOps::UninitVal()) {} bool IsRemainderDying() const; bool IsReplacementDying(unsigned index) const; @@ -236,15 +220,15 @@ struct BasicBlockLiveness; // Class to compute and track liveness information pertaining promoted structs. class PromotionLiveness { - Compiler* m_compiler; - AggregateInfoMap& m_aggregates; - BitVecTraits* m_bvTraits = nullptr; - unsigned* m_structLclToTrackedIndex = nullptr; - unsigned m_numVars = 0; - BasicBlockLiveness* m_bbInfo = nullptr; - bool m_hasPossibleBackEdge = false; - BitVec m_liveIn; - BitVec m_ehLiveVars; + Compiler* m_compiler; + AggregateInfoMap& m_aggregates; + BitVecTraits* m_bvTraits = nullptr; + unsigned* m_structLclToTrackedIndex = nullptr; + unsigned m_numVars = 0; + BasicBlockLiveness* m_bbInfo = nullptr; + bool m_hasPossibleBackEdge = false; + BitVec m_liveIn; + BitVec m_ehLiveVars; JitHashTable, BitVec> m_aggDeaths; public: @@ -253,9 +237,9 @@ class PromotionLiveness { } - void Run(); - bool IsReplacementLiveIn(BasicBlock* bb, unsigned structLcl, unsigned replacement); - bool IsReplacementLiveOut(BasicBlock* bb, unsigned structLcl, unsigned replacement); + void Run(); + bool IsReplacementLiveIn(BasicBlock* bb, unsigned structLcl, unsigned replacement); + bool IsReplacementLiveOut(BasicBlock* bb, unsigned structLcl, unsigned replacement); StructDeaths GetDeathsForStructLocal(GenTreeLclVarCommon* use); private: diff --git a/src/coreclr/jit/promotiondecomposition.cpp b/src/coreclr/jit/promotiondecomposition.cpp index 18ac84c58e4f2b..76a64e1ddf3f11 100644 --- a/src/coreclr/jit/promotiondecomposition.cpp +++ b/src/coreclr/jit/promotiondecomposition.cpp @@ -727,8 +727,8 @@ class DecompositionPlan // remainderStrategy - The strategy we are using for the remainder // dump - Whether to JITDUMP decisions made // - bool CanSkipEntry(const Entry& entry, - const StructDeaths& deaths, + bool CanSkipEntry(const Entry& entry, + const StructDeaths& deaths, const RemainderStrategy& remainderStrategy DEBUGARG(bool dump = false)) { if (entry.ToReplacement != nullptr) diff --git a/src/coreclr/jit/promotionliveness.cpp b/src/coreclr/jit/promotionliveness.cpp index 174388ecb129fe..dc2fe43a0bece4 100644 --- a/src/coreclr/jit/promotionliveness.cpp +++ b/src/coreclr/jit/promotionliveness.cpp @@ -343,11 +343,13 @@ bool PromotionLiveness::PerBlockLiveness(BasicBlock* block) BasicBlockLiveness& bbInfo = m_bbInfo[block->bbNum]; BitVecOps::ClearD(m_bvTraits, bbInfo.LiveOut); - block->VisitRegularSuccs(m_compiler, [=, &bbInfo](BasicBlock* succ) { - BitVecOps::UnionD(m_bvTraits, bbInfo.LiveOut, m_bbInfo[succ->bbNum].LiveIn); - m_hasPossibleBackEdge |= succ->bbNum <= block->bbNum; - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(m_compiler, + [=, &bbInfo](BasicBlock* succ) + { + BitVecOps::UnionD(m_bvTraits, bbInfo.LiveOut, m_bbInfo[succ->bbNum].LiveIn); + m_hasPossibleBackEdge |= succ->bbNum <= block->bbNum; + return BasicBlockVisit::Continue; + }); BitVecOps::LivenessD(m_bvTraits, m_liveIn, bbInfo.VarDef, bbInfo.VarUse, bbInfo.LiveOut); @@ -386,10 +388,12 @@ void PromotionLiveness::AddHandlerLiveVars(BasicBlock* block, BitVec& ehLiveVars { assert(block->HasPotentialEHSuccs(m_compiler)); - block->VisitEHSuccs(m_compiler, [=, &ehLiveVars](BasicBlock* succ) { - BitVecOps::UnionD(m_bvTraits, ehLiveVars, m_bbInfo[succ->bbNum].LiveIn); - return BasicBlockVisit::Continue; - }); + block->VisitEHSuccs(m_compiler, + [=, &ehLiveVars](BasicBlock* succ) + { + BitVecOps::UnionD(m_bvTraits, ehLiveVars, m_bbInfo[succ->bbNum].LiveIn); + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/rangecheck.cpp b/src/coreclr/jit/rangecheck.cpp index 475df2d659cabc..fc508bc6e06215 100644 --- a/src/coreclr/jit/rangecheck.cpp +++ b/src/coreclr/jit/rangecheck.cpp @@ -1123,7 +1123,7 @@ Range RangeCheck::GetRangeFromType(var_types type) // Compute the range for a local var definition. Range RangeCheck::ComputeRangeForLocalDef(BasicBlock* block, GenTreeLclVarCommon* lcl, - bool monIncreasing DEBUGARG(int indent)) + bool monIncreasing DEBUGARG(int indent)) { LclSsaVarDsc* ssaDef = GetSsaDefStore(lcl); if (ssaDef == nullptr) @@ -1566,9 +1566,7 @@ struct MapMethodDefsData BasicBlock* block; Statement* stmt; - MapMethodDefsData(RangeCheck* rc, BasicBlock* block, Statement* stmt) : rc(rc), block(block), stmt(stmt) - { - } + MapMethodDefsData(RangeCheck* rc, BasicBlock* block, Statement* stmt) : rc(rc), block(block), stmt(stmt) {} }; Compiler::fgWalkResult MapMethodDefsVisitor(GenTree** ptr, Compiler::fgWalkData* data) diff --git a/src/coreclr/jit/rangecheck.h b/src/coreclr/jit/rangecheck.h index 098e1cc62b0d7a..e98adceabd9568 100644 --- a/src/coreclr/jit/rangecheck.h +++ b/src/coreclr/jit/rangecheck.h @@ -83,13 +83,9 @@ struct Limit keUnknown, // The limit could not be determined. }; - Limit() : type(keUndef) - { - } + Limit() : type(keUndef) {} - Limit(LimitType type) : type(type) - { - } + Limit(LimitType type) : type(type) {} Limit(LimitType type, int cns) : cns(cns), vn(ValueNumStore::NoVN), type(type) { @@ -242,13 +238,9 @@ struct Range Limit uLimit; Limit lLimit; - Range(const Limit& limit) : uLimit(limit), lLimit(limit) - { - } + Range(const Limit& limit) : uLimit(limit), lLimit(limit) {} - Range(const Limit& lLimit, const Limit& uLimit) : uLimit(uLimit), lLimit(lLimit) - { - } + Range(const Limit& lLimit, const Limit& uLimit) : uLimit(uLimit), lLimit(lLimit) {} Limit& UpperLimit() { diff --git a/src/coreclr/jit/rationalize.h b/src/coreclr/jit/rationalize.h index 65264f8294582c..f2965be8cef8f9 100644 --- a/src/coreclr/jit/rationalize.h +++ b/src/coreclr/jit/rationalize.h @@ -55,8 +55,6 @@ class Rationalizer final : public Phase Compiler::fgWalkResult RewriteNode(GenTree** useEdge, Compiler::GenTreeStack& parents); }; -inline Rationalizer::Rationalizer(Compiler* _comp) : Phase(_comp, PHASE_RATIONALIZE) -{ -} +inline Rationalizer::Rationalizer(Compiler* _comp) : Phase(_comp, PHASE_RATIONALIZE) {} #endif diff --git a/src/coreclr/jit/redundantbranchopts.cpp b/src/coreclr/jit/redundantbranchopts.cpp index e8b346faccc376..dc0992e282d8f8 100644 --- a/src/coreclr/jit/redundantbranchopts.cpp +++ b/src/coreclr/jit/redundantbranchopts.cpp @@ -24,13 +24,9 @@ PhaseStatus Compiler::optRedundantBranches() public: bool madeChanges; - OptRedundantBranchesDomTreeVisitor(Compiler* compiler) : DomTreeVisitor(compiler), madeChanges(false) - { - } + OptRedundantBranchesDomTreeVisitor(Compiler* compiler) : DomTreeVisitor(compiler), madeChanges(false) {} - void PreOrderVisit(BasicBlock* block) - { - } + void PreOrderVisit(BasicBlock* block) {} void PostOrderVisit(BasicBlock* block) { @@ -208,7 +204,8 @@ RelopResult IsCmp2ImpliedByCmp1(genTreeOps oper1, target_ssize_t bound1, genTree IntegralRange range2 = {minValue, maxValue}; // Update ranges based on inputs - auto setRange = [](genTreeOps oper, target_ssize_t bound, IntegralRange* range) -> bool { + auto setRange = [](genTreeOps oper, target_ssize_t bound, IntegralRange* range) -> bool + { switch (oper) { case GT_LT: @@ -2186,22 +2183,26 @@ bool Compiler::optReachable(BasicBlock* const fromBlock, BasicBlock* const toBlo continue; } - BasicBlockVisit result = nextBlock->VisitAllSuccs(this, [this, toBlock, &stack](BasicBlock* succ) { - if (succ == toBlock) - { - return BasicBlockVisit::Abort; - } - - if (BitVecOps::IsMember(optReachableBitVecTraits, optReachableBitVec, succ->bbNum)) - { - return BasicBlockVisit::Continue; - } - - BitVecOps::AddElemD(optReachableBitVecTraits, optReachableBitVec, succ->bbNum); - - stack.Push(succ); - return BasicBlockVisit::Continue; - }); + BasicBlockVisit result = + nextBlock->VisitAllSuccs(this, + [this, toBlock, &stack](BasicBlock* succ) + { + if (succ == toBlock) + { + return BasicBlockVisit::Abort; + } + + if (BitVecOps::IsMember(optReachableBitVecTraits, optReachableBitVec, + succ->bbNum)) + { + return BasicBlockVisit::Continue; + } + + BitVecOps::AddElemD(optReachableBitVecTraits, optReachableBitVec, succ->bbNum); + + stack.Push(succ); + return BasicBlockVisit::Continue; + }); if (result == BasicBlockVisit::Abort) { diff --git a/src/coreclr/jit/regset.cpp b/src/coreclr/jit/regset.cpp index efec31a78f5bd5..28b49133370232 100644 --- a/src/coreclr/jit/regset.cpp +++ b/src/coreclr/jit/regset.cpp @@ -425,9 +425,9 @@ void RegSet::rsSpillTree(regNumber reg, GenTree* tree, unsigned regIdx /* =0 */) #if defined(TARGET_X86) /***************************************************************************** -* -* Spill the top of the FP x87 stack. -*/ + * + * Spill the top of the FP x87 stack. + */ void RegSet::rsSpillFPStack(GenTreeCall* call) { SpillDsc* spill; @@ -1064,8 +1064,6 @@ void RegSet::rsSpillChk() #else // inline -void RegSet::rsSpillChk() -{ -} +void RegSet::rsSpillChk() {} #endif diff --git a/src/coreclr/jit/regset.h b/src/coreclr/jit/regset.h index 73eb08aa943eb9..0924c410e3b85b 100644 --- a/src/coreclr/jit/regset.h +++ b/src/coreclr/jit/regset.h @@ -58,7 +58,7 @@ class RegSet TempDsc* spillTemp; // the temp holding the spilled value static SpillDsc* alloc(Compiler* pComp, RegSet* regSet, var_types type); - static void freeDsc(RegSet* regSet, SpillDsc* spillDsc); + static void freeDsc(RegSet* regSet, SpillDsc* spillDsc); }; //------------------------------------------------------------------------- @@ -179,14 +179,14 @@ class RegSet }; static var_types tmpNormalizeType(var_types type); - TempDsc* tmpGetTemp(var_types type); // get temp for the given type - void tmpRlsTemp(TempDsc* temp); - TempDsc* tmpFindNum(int temp, TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; + TempDsc* tmpGetTemp(var_types type); // get temp for the given type + void tmpRlsTemp(TempDsc* temp); + TempDsc* tmpFindNum(int temp, TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; void tmpEnd(); TempDsc* tmpListBeg(TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; TempDsc* tmpListNxt(TempDsc* curTemp, TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; - void tmpDone(); + void tmpDone(); #ifdef DEBUG bool tmpAllFree() const; diff --git a/src/coreclr/jit/scev.cpp b/src/coreclr/jit/scev.cpp index 5819b56bdfd3a1..925801f0600834 100644 --- a/src/coreclr/jit/scev.cpp +++ b/src/coreclr/jit/scev.cpp @@ -722,14 +722,16 @@ Scev* ScalarEvolutionContext::MakeAddRecFromRecursiveScev(Scev* startScev, Scev* } else { - ScevVisit result = addOperand->Visit([=](Scev* node) { - if (node == recursiveScev) + ScevVisit result = addOperand->Visit( + [=](Scev* node) { - return ScevVisit::Abort; - } + if (node == recursiveScev) + { + return ScevVisit::Abort; + } - return ScevVisit::Continue; - }); + return ScevVisit::Continue; + }); if (result == ScevVisit::Abort) { @@ -967,8 +969,8 @@ Scev* ScalarEvolutionContext::Simplify(Scev* scev) ScevAddRec* addRec = (ScevAddRec*)op1; Scev* newStart = Simplify(NewBinop(binop->Oper, addRec->Start, op2)); Scev* newStep = scev->OperIs(ScevOper::Mul, ScevOper::Lsh) - ? Simplify(NewBinop(binop->Oper, addRec->Step, op2)) - : addRec->Step; + ? Simplify(NewBinop(binop->Oper, addRec->Step, op2)) + : addRec->Step; return NewAddRec(newStart, newStep); } diff --git a/src/coreclr/jit/scev.h b/src/coreclr/jit/scev.h index 0800be905503a9..33b6ab467eaa71 100644 --- a/src/coreclr/jit/scev.h +++ b/src/coreclr/jit/scev.h @@ -48,9 +48,7 @@ struct Scev const ScevOper Oper; const var_types Type; - Scev(ScevOper oper, var_types type) : Oper(oper), Type(type) - { - } + Scev(ScevOper oper, var_types type) : Oper(oper), Type(type) {} template bool OperIs(Args... opers) @@ -74,9 +72,7 @@ struct Scev struct ScevConstant : Scev { - ScevConstant(var_types type, int64_t value) : Scev(ScevOper::Constant, type), Value(value) - { - } + ScevConstant(var_types type, int64_t value) : Scev(ScevOper::Constant, type), Value(value) {} int64_t Value; }; @@ -96,18 +92,14 @@ struct ScevLocal : Scev struct ScevUnop : Scev { - ScevUnop(ScevOper oper, var_types type, Scev* op1) : Scev(oper, type), Op1(op1) - { - } + ScevUnop(ScevOper oper, var_types type, Scev* op1) : Scev(oper, type), Op1(op1) {} Scev* const Op1; }; struct ScevBinop : ScevUnop { - ScevBinop(ScevOper oper, var_types type, Scev* op1, Scev* op2) : ScevUnop(oper, type, op1), Op2(op2) - { - } + ScevBinop(ScevOper oper, var_types type, Scev* op1, Scev* op2) : ScevUnop(oper, type, op1), Op2(op2) {} Scev* const Op2; }; @@ -204,7 +196,7 @@ class ScalarEvolutionContext Scev* MakeAddRecFromRecursiveScev(Scev* start, Scev* scev, Scev* recursiveScev); Scev* CreateSimpleInvariantScev(GenTree* tree); Scev* CreateScevForConstant(GenTreeIntConCommon* tree); - void ExtractAddOperands(ScevBinop* add, ArrayStack& operands); + void ExtractAddOperands(ScevBinop* add, ArrayStack& operands); public: ScalarEvolutionContext(Compiler* comp); @@ -212,10 +204,10 @@ class ScalarEvolutionContext void ResetForLoop(FlowGraphNaturalLoop* loop); ScevConstant* NewConstant(var_types type, int64_t value); - ScevLocal* NewLocal(unsigned lclNum, unsigned ssaNum); - ScevUnop* NewExtension(ScevOper oper, var_types targetType, Scev* op); - ScevBinop* NewBinop(ScevOper oper, Scev* op1, Scev* op2); - ScevAddRec* NewAddRec(Scev* start, Scev* step); + ScevLocal* NewLocal(unsigned lclNum, unsigned ssaNum); + ScevUnop* NewExtension(ScevOper oper, var_types targetType, Scev* op); + ScevBinop* NewBinop(ScevOper oper, Scev* op1, Scev* op2); + ScevAddRec* NewAddRec(Scev* start, Scev* step); Scev* Analyze(BasicBlock* block, GenTree* tree); Scev* Simplify(Scev* scev); diff --git a/src/coreclr/jit/scopeinfo.cpp b/src/coreclr/jit/scopeinfo.cpp index 7a1290f9ac7858..d7dc6ff9cc3a0f 100644 --- a/src/coreclr/jit/scopeinfo.cpp +++ b/src/coreclr/jit/scopeinfo.cpp @@ -790,11 +790,9 @@ void CodeGenInterface::VariableLiveKeeper::VariableLiveDescriptor::startLiveRang else { JITDUMP("Debug: New V%02u debug range: %s\n", m_varNum, - m_VariableLiveRanges->empty() - ? "first" - : siVarLoc::Equals(&varLocation, &(m_VariableLiveRanges->back().m_VarLocation)) - ? "new var or location" - : "not adjacent"); + m_VariableLiveRanges->empty() ? "first" + : siVarLoc::Equals(&varLocation, &(m_VariableLiveRanges->back().m_VarLocation)) ? "new var or location" + : "not adjacent"); // Creates new live range with invalid end m_VariableLiveRanges->emplace_back(varLocation, emitLocation(), emitLocation()); m_VariableLiveRanges->back().m_StartEmitLocation.CaptureLocation(emit); @@ -1685,9 +1683,9 @@ NATIVE_OFFSET CodeGen::psiGetVarStackOffset(const LclVarDsc* lclVarDsc) const } /*============================================================================ -* INTERFACE (public) Functions for PrologScopeInfo -*============================================================================ -*/ + * INTERFACE (public) Functions for PrologScopeInfo + *============================================================================ + */ //------------------------------------------------------------------------ // psiBegProlog: Initializes the PrologScopeInfo creating open psiScopes or @@ -1891,8 +1889,9 @@ void CodeGen::genSetScopeInfoUsingVariableRanges() continue; } - auto reportRange = [this, varDsc, varNum, &liveRangeIndex](siVarLoc* loc, UNATIVE_OFFSET start, - UNATIVE_OFFSET end) { + auto reportRange = + [this, varDsc, varNum, &liveRangeIndex](siVarLoc* loc, UNATIVE_OFFSET start, UNATIVE_OFFSET end) + { if (varDsc->lvIsParam && (start == end)) { // If the length is zero, it means that the prolog is empty. In that case, diff --git a/src/coreclr/jit/sideeffects.cpp b/src/coreclr/jit/sideeffects.cpp index e39bf596c4770b..049eb8c86cde48 100644 --- a/src/coreclr/jit/sideeffects.cpp +++ b/src/coreclr/jit/sideeffects.cpp @@ -8,9 +8,7 @@ #include "sideeffects.h" -LclVarSet::LclVarSet() : m_bitVector(nullptr), m_hasAnyLcl(false), m_hasBitVector(false) -{ -} +LclVarSet::LclVarSet() : m_bitVector(nullptr), m_hasAnyLcl(false), m_hasBitVector(false) {} //------------------------------------------------------------------------ // LclVarSet::Add: @@ -274,23 +272,25 @@ void AliasSet::AddNode(Compiler* compiler, GenTree* node) { // First, add all lclVar uses associated with the node to the set. This is necessary because the lclVar reads occur // at the position of the user, not at the position of the GenTreeLclVar node. - node->VisitOperands([compiler, this](GenTree* operand) -> GenTree::VisitResult { - if (operand->OperIsLocalRead()) + node->VisitOperands( + [compiler, this](GenTree* operand) -> GenTree::VisitResult { - const unsigned lclNum = operand->AsLclVarCommon()->GetLclNum(); - if (compiler->lvaTable[lclNum].IsAddressExposed()) + if (operand->OperIsLocalRead()) { - m_readsAddressableLocation = true; - } + const unsigned lclNum = operand->AsLclVarCommon()->GetLclNum(); + if (compiler->lvaTable[lclNum].IsAddressExposed()) + { + m_readsAddressableLocation = true; + } - m_lclVarReads.Add(compiler, lclNum); - } - if (operand->isContained()) - { - AddNode(compiler, operand); - } - return GenTree::VisitResult::Continue; - }); + m_lclVarReads.Add(compiler, lclNum); + } + if (operand->isContained()) + { + AddNode(compiler, operand); + } + return GenTree::VisitResult::Continue; + }); NodeInfo nodeInfo(compiler, node); if (nodeInfo.ReadsAddressableLocation()) @@ -444,9 +444,7 @@ void AliasSet::Clear() m_lclVarWrites.Clear(); } -SideEffectSet::SideEffectSet() : m_sideEffectFlags(0), m_aliasSet() -{ -} +SideEffectSet::SideEffectSet() : m_sideEffectFlags(0), m_aliasSet() {} //------------------------------------------------------------------------ // SideEffectSet::SideEffectSet: diff --git a/src/coreclr/jit/sideeffects.h b/src/coreclr/jit/sideeffects.h index d94622d9f0ca8b..0fef277532cf1a 100644 --- a/src/coreclr/jit/sideeffects.h +++ b/src/coreclr/jit/sideeffects.h @@ -13,7 +13,8 @@ // class LclVarSet final { - union { + union + { hashBv* m_bitVector; unsigned m_lclNum; }; diff --git a/src/coreclr/jit/simd.h b/src/coreclr/jit/simd.h index aec72eaab542e8..3a5311aaaa79df 100644 --- a/src/coreclr/jit/simd.h +++ b/src/coreclr/jit/simd.h @@ -6,7 +6,8 @@ struct simd8_t { - union { + union + { float f32[2]; double f64[1]; int8_t i8[8]; @@ -58,7 +59,8 @@ static_assert_no_msg(sizeof(simd8_t) == 8); #include struct simd12_t { - union { + union + { float f32[3]; int8_t i8[12]; int16_t i16[6]; @@ -116,7 +118,8 @@ static_assert_no_msg(sizeof(simd12_t) == 12); struct simd16_t { - union { + union + { float f32[4]; double f64[2]; int8_t i8[16]; @@ -170,7 +173,8 @@ static_assert_no_msg(sizeof(simd16_t) == 16); #if defined(TARGET_XARCH) struct simd32_t { - union { + union + { float f32[8]; double f64[4]; int8_t i8[32]; @@ -224,7 +228,8 @@ static_assert_no_msg(sizeof(simd32_t) == 32); struct simd64_t { - union { + union + { float f32[16]; double f64[8]; int8_t i8[64]; @@ -279,7 +284,8 @@ static_assert_no_msg(sizeof(simd64_t) == 64); struct simdmask_t { - union { + union + { int8_t i8[8]; int16_t i16[4]; int32_t i32[2]; diff --git a/src/coreclr/jit/simdashwintrinsic.cpp b/src/coreclr/jit/simdashwintrinsic.cpp index f06b38736ddadb..c22ebc7b635440 100644 --- a/src/coreclr/jit/simdashwintrinsic.cpp +++ b/src/coreclr/jit/simdashwintrinsic.cpp @@ -399,7 +399,7 @@ GenTree* Compiler::impSimdAsHWIntrinsic(NamedIntrinsic intrinsic, { argType = isInstanceMethod ? simdType : JITtype2varType(strip(info.compCompHnd->getArgType(sig, argList, &argClass))); - op1 = getArgForHWIntrinsic(argType, argClass, isInstanceMethod); + op1 = getArgForHWIntrinsic(argType, argClass, isInstanceMethod); return gtNewSimdAsHWIntrinsicNode(retType, op1, hwIntrinsic, simdBaseJitType, simdSize); } @@ -421,7 +421,7 @@ GenTree* Compiler::impSimdAsHWIntrinsic(NamedIntrinsic intrinsic, argType = isInstanceMethod ? simdType : JITtype2varType(strip(info.compCompHnd->getArgType(sig, argList, &argClass))); - op1 = getArgForHWIntrinsic(argType, argClass, isInstanceMethod); + op1 = getArgForHWIntrinsic(argType, argClass, isInstanceMethod); return gtNewSimdAsHWIntrinsicNode(retType, op1, op2, hwIntrinsic, simdBaseJitType, simdSize); } @@ -954,7 +954,7 @@ GenTree* Compiler::impSimdAsHWIntrinsicSpecial(NamedIntrinsic intrinsic, argType = isInstanceMethod ? simdType : JITtype2varType(strip(info.compCompHnd->getArgType(sig, argList, &argClass))); - op1 = getArgForHWIntrinsic(argType, argClass, isInstanceMethod); + op1 = getArgForHWIntrinsic(argType, argClass, isInstanceMethod); switch (intrinsic) { diff --git a/src/coreclr/jit/sm.cpp b/src/coreclr/jit/sm.cpp index 5cd6e9879c78da..5e9b97699b841f 100644 --- a/src/coreclr/jit/sm.cpp +++ b/src/coreclr/jit/sm.cpp @@ -130,8 +130,8 @@ SM_STATE_ID CodeSeqSM::GetDestState(SM_STATE_ID srcState, SM_OPCODE opcode) if (cell->srcState != srcState) { - assert(cell->srcState == 0 || - cell->srcState != srcState); // Either way means there is not outgoing edge from srcState. + assert(cell->srcState == 0 || cell->srcState != srcState); // Either way means there is not outgoing edge from + // srcState. return 0; } else diff --git a/src/coreclr/jit/smallhash.h b/src/coreclr/jit/smallhash.h index f16905c995fbd4..1666ceb6f0b22b 100644 --- a/src/coreclr/jit/smallhash.h +++ b/src/coreclr/jit/smallhash.h @@ -365,9 +365,7 @@ class HashTableBase } public: - KeyValuePair() : m_bucket(nullptr) - { - } + KeyValuePair() : m_bucket(nullptr) {} inline TKey& Key() { @@ -405,9 +403,7 @@ class HashTableBase } public: - Iterator() : m_buckets(nullptr), m_numBuckets(0), m_index(0) - { - } + Iterator() : m_buckets(nullptr), m_numBuckets(0), m_index(0) {} KeyValuePair operator*() const { @@ -636,9 +632,7 @@ class HashTable final : public HashTableBase } public: - HashTable(TAllocator alloc) : TBase(alloc, nullptr, 0) - { - } + HashTable(TAllocator alloc) : TBase(alloc, nullptr, 0) {} HashTable(TAllocator alloc, unsigned initialSize) : TBase(alloc, alloc.template allocate(RoundUp(initialSize)), RoundUp(initialSize)) @@ -670,9 +664,7 @@ class SmallHashTable final : public HashTableBaselvaTable[lclNum].lvVarIndex; - block->VisitEHSuccs(m_pCompiler, [=](BasicBlock* succ) { - // Is "lclNum" live on entry to the handler? - if (!VarSetOps::IsMember(m_pCompiler, succ->bbLiveIn, lclIndex)) - { - return BasicBlockVisit::Continue; - } + block->VisitEHSuccs(m_pCompiler, + [=](BasicBlock* succ) + { + // Is "lclNum" live on entry to the handler? + if (!VarSetOps::IsMember(m_pCompiler, succ->bbLiveIn, lclIndex)) + { + return BasicBlockVisit::Continue; + } #ifdef DEBUG - bool phiFound = false; + bool phiFound = false; #endif - // A prefix of blocks statements will be SSA definitions. Search those for "lclNum". - for (Statement* const stmt : succ->Statements()) - { - // If the tree is not an SSA def, break out of the loop: we're done. - if (!stmt->IsPhiDefnStmt()) - { - break; - } - - GenTreeLclVar* phiDef = stmt->GetRootNode()->AsLclVar(); - assert(phiDef->IsPhiDefn()); - - if (phiDef->GetLclNum() == lclNum) - { - // It's the definition for the right local. Add "ssaNum" to the RHS. - AddPhiArg(succ, stmt, phiDef->Data()->AsPhi(), lclNum, ssaNum, block); + // A prefix of blocks statements will be SSA definitions. Search those for "lclNum". + for (Statement* const stmt : succ->Statements()) + { + // If the tree is not an SSA def, break out of the loop: we're done. + if (!stmt->IsPhiDefnStmt()) + { + break; + } + + GenTreeLclVar* phiDef = stmt->GetRootNode()->AsLclVar(); + assert(phiDef->IsPhiDefn()); + + if (phiDef->GetLclNum() == lclNum) + { + // It's the definition for the right local. Add "ssaNum" to the RHS. + AddPhiArg(succ, stmt, phiDef->Data()->AsPhi(), lclNum, ssaNum, block); #ifdef DEBUG - phiFound = true; + phiFound = true; #endif - break; - } - } - assert(phiFound); - - return BasicBlockVisit::Continue; + break; + } + } + assert(phiFound); - }); + return BasicBlockVisit::Continue; + }); } void SsaBuilder::AddMemoryDefToEHSuccessorPhis(MemoryKind memoryKind, BasicBlock* block, unsigned ssaNum) @@ -802,58 +803,60 @@ void SsaBuilder::AddMemoryDefToEHSuccessorPhis(MemoryKind memoryKind, BasicBlock " has potential EH successors; adding as phi arg to EH successors.\n", memoryKindNames[memoryKind], ssaNum, block->bbNum); - block->VisitEHSuccs(m_pCompiler, [=](BasicBlock* succ) { - // Is memoryKind live on entry to the handler? - if ((succ->bbMemoryLiveIn & memoryKindSet(memoryKind)) == 0) - { - return BasicBlockVisit::Continue; - } + block->VisitEHSuccs(m_pCompiler, + [=](BasicBlock* succ) + { + // Is memoryKind live on entry to the handler? + if ((succ->bbMemoryLiveIn & memoryKindSet(memoryKind)) == 0) + { + return BasicBlockVisit::Continue; + } - // Add "ssaNum" to the phi args of memoryKind. - BasicBlock::MemoryPhiArg*& handlerMemoryPhi = succ->bbMemorySsaPhiFunc[memoryKind]; + // Add "ssaNum" to the phi args of memoryKind. + BasicBlock::MemoryPhiArg*& handlerMemoryPhi = succ->bbMemorySsaPhiFunc[memoryKind]; #if DEBUG - if (m_pCompiler->byrefStatesMatchGcHeapStates) - { - // When sharing phis for GcHeap and ByrefExposed, callers should ask to add phis - // for ByrefExposed only. - assert(memoryKind != GcHeap); - if (memoryKind == ByrefExposed) - { - // The GcHeap and ByrefExposed phi funcs should always be in sync. - assert(handlerMemoryPhi == succ->bbMemorySsaPhiFunc[GcHeap]); - } - } + if (m_pCompiler->byrefStatesMatchGcHeapStates) + { + // When sharing phis for GcHeap and ByrefExposed, callers should ask to add phis + // for ByrefExposed only. + assert(memoryKind != GcHeap); + if (memoryKind == ByrefExposed) + { + // The GcHeap and ByrefExposed phi funcs should always be in sync. + assert(handlerMemoryPhi == succ->bbMemorySsaPhiFunc[GcHeap]); + } + } #endif - if (handlerMemoryPhi == BasicBlock::EmptyMemoryPhiDef) - { - handlerMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum); - } - else - { + if (handlerMemoryPhi == BasicBlock::EmptyMemoryPhiDef) + { + handlerMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum); + } + else + { #ifdef DEBUG - BasicBlock::MemoryPhiArg* curArg = succ->bbMemorySsaPhiFunc[memoryKind]; - while (curArg != nullptr) - { - assert(curArg->GetSsaNum() != ssaNum); - curArg = curArg->m_nextArg; - } + BasicBlock::MemoryPhiArg* curArg = succ->bbMemorySsaPhiFunc[memoryKind]; + while (curArg != nullptr) + { + assert(curArg->GetSsaNum() != ssaNum); + curArg = curArg->m_nextArg; + } #endif // DEBUG - handlerMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum, handlerMemoryPhi); - } + handlerMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum, handlerMemoryPhi); + } - DBG_SSA_JITDUMP(" Added phi arg u:%d for %s to phi defn in handler block " FMT_BB ".\n", ssaNum, - memoryKindNames[memoryKind], memoryKind, succ->bbNum); + DBG_SSA_JITDUMP(" Added phi arg u:%d for %s to phi defn in handler block " FMT_BB ".\n", + ssaNum, memoryKindNames[memoryKind], memoryKind, succ->bbNum); - if ((memoryKind == ByrefExposed) && m_pCompiler->byrefStatesMatchGcHeapStates) - { - // Share the phi between GcHeap and ByrefExposed. - succ->bbMemorySsaPhiFunc[GcHeap] = handlerMemoryPhi; - } + if ((memoryKind == ByrefExposed) && m_pCompiler->byrefStatesMatchGcHeapStates) + { + // Share the phi between GcHeap and ByrefExposed. + succ->bbMemorySsaPhiFunc[GcHeap] = handlerMemoryPhi; + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ @@ -962,131 +965,140 @@ void SsaBuilder::BlockRenameVariables(BasicBlock* block) // void SsaBuilder::AddPhiArgsToSuccessors(BasicBlock* block) { - block->VisitAllSuccs(m_pCompiler, [this, block](BasicBlock* succ) { - // Walk the statements for phi nodes. - for (Statement* const stmt : succ->Statements()) - { - // A prefix of the statements of the block are phi definition nodes. If we complete processing - // that prefix, exit. - if (!stmt->IsPhiDefnStmt()) - { - break; - } - - GenTreeLclVar* store = stmt->GetRootNode()->AsLclVar(); - GenTreePhi* phi = store->Data()->AsPhi(); - unsigned lclNum = store->GetLclNum(); - unsigned ssaNum = m_renameStack.Top(lclNum); - - AddPhiArg(succ, stmt, phi, lclNum, ssaNum, block); - } - - // Now handle memory. - for (MemoryKind memoryKind : allMemoryKinds()) - { - BasicBlock::MemoryPhiArg*& succMemoryPhi = succ->bbMemorySsaPhiFunc[memoryKind]; - if (succMemoryPhi != nullptr) - { - if ((memoryKind == GcHeap) && m_pCompiler->byrefStatesMatchGcHeapStates) - { - // We've already propagated the "out" number to the phi shared with ByrefExposed, - // but still need to update bbMemorySsaPhiFunc to be in sync between GcHeap and ByrefExposed. - assert(memoryKind > ByrefExposed); - assert(block->bbMemorySsaNumOut[memoryKind] == block->bbMemorySsaNumOut[ByrefExposed]); - assert((succ->bbMemorySsaPhiFunc[ByrefExposed] == succMemoryPhi) || - (succ->bbMemorySsaPhiFunc[ByrefExposed]->m_nextArg == - (succMemoryPhi == BasicBlock::EmptyMemoryPhiDef ? nullptr : succMemoryPhi))); - succMemoryPhi = succ->bbMemorySsaPhiFunc[ByrefExposed]; - - continue; - } - - if (succMemoryPhi == BasicBlock::EmptyMemoryPhiDef) - { - succMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(block->bbMemorySsaNumOut[memoryKind]); - } - else - { - BasicBlock::MemoryPhiArg* curArg = succMemoryPhi; - unsigned ssaNum = block->bbMemorySsaNumOut[memoryKind]; - bool found = false; - // This is a quadratic algorithm. We might need to consider some switch over to a hash table - // representation for the arguments of a phi node, to make this linear. - while (curArg != nullptr) - { - if (curArg->m_ssaNum == ssaNum) - { - found = true; - break; - } - curArg = curArg->m_nextArg; - } - if (!found) - { - succMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum, succMemoryPhi); - } - } - DBG_SSA_JITDUMP(" Added phi arg for %s u:%d from " FMT_BB " in " FMT_BB ".\n", - memoryKindNames[memoryKind], block->bbMemorySsaNumOut[memoryKind], block->bbNum, - succ->bbNum); - } - } - - // If "succ" is the first block of a try block (and "block" is not also in that try block) - // then we must look at the vars that have phi defs in the corresponding handler; - // the current SSA name for such vars must be included as an argument to that phi. - if (m_pCompiler->bbIsTryBeg(succ)) - { - assert(succ->hasTryIndex()); - unsigned tryInd = succ->getTryIndex(); - - while (tryInd != EHblkDsc::NO_ENCLOSING_INDEX) - { - // Check if the predecessor "block" is within the same try block. - if (block->hasTryIndex()) - { - for (unsigned blockTryInd = block->getTryIndex(); blockTryInd != EHblkDsc::NO_ENCLOSING_INDEX; - blockTryInd = m_pCompiler->ehGetEnclosingTryIndex(blockTryInd)) - { - if (blockTryInd == tryInd) - { - // It is; don't execute the loop below. - tryInd = EHblkDsc::NO_ENCLOSING_INDEX; - break; - } - } - - // The loop just above found that the predecessor "block" is within the same - // try block as "succ." So we don't need to process this try, or any - // further outer try blocks here, since they would also contain both "succ" - // and "block". - if (tryInd == EHblkDsc::NO_ENCLOSING_INDEX) - { - break; - } - } - - EHblkDsc* succTry = m_pCompiler->ehGetDsc(tryInd); - // This is necessarily true on the first iteration, but not - // necessarily on the second and subsequent. - if (succTry->ebdTryBeg != succ) - { - break; - } - - if (succTry->HasFilter()) - { - AddPhiArgsToNewlyEnteredHandler(block, succ, succTry->ebdFilter); - } - - AddPhiArgsToNewlyEnteredHandler(block, succ, succTry->ebdHndBeg); - - tryInd = succTry->ebdEnclosingTryIndex; - } - } - - return BasicBlockVisit::Continue; - }); + block->VisitAllSuccs(m_pCompiler, + [this, block](BasicBlock* succ) + { + // Walk the statements for phi nodes. + for (Statement* const stmt : succ->Statements()) + { + // A prefix of the statements of the block are phi definition nodes. If we complete + // processing that prefix, exit. + if (!stmt->IsPhiDefnStmt()) + { + break; + } + + GenTreeLclVar* store = stmt->GetRootNode()->AsLclVar(); + GenTreePhi* phi = store->Data()->AsPhi(); + unsigned lclNum = store->GetLclNum(); + unsigned ssaNum = m_renameStack.Top(lclNum); + + AddPhiArg(succ, stmt, phi, lclNum, ssaNum, block); + } + + // Now handle memory. + for (MemoryKind memoryKind : allMemoryKinds()) + { + BasicBlock::MemoryPhiArg*& succMemoryPhi = succ->bbMemorySsaPhiFunc[memoryKind]; + if (succMemoryPhi != nullptr) + { + if ((memoryKind == GcHeap) && m_pCompiler->byrefStatesMatchGcHeapStates) + { + // We've already propagated the "out" number to the phi shared with + // ByrefExposed, but still need to update bbMemorySsaPhiFunc to be in sync + // between GcHeap and ByrefExposed. + assert(memoryKind > ByrefExposed); + assert(block->bbMemorySsaNumOut[memoryKind] == + block->bbMemorySsaNumOut[ByrefExposed]); + assert((succ->bbMemorySsaPhiFunc[ByrefExposed] == succMemoryPhi) || + (succ->bbMemorySsaPhiFunc[ByrefExposed]->m_nextArg == + (succMemoryPhi == BasicBlock::EmptyMemoryPhiDef ? nullptr + : succMemoryPhi))); + succMemoryPhi = succ->bbMemorySsaPhiFunc[ByrefExposed]; + + continue; + } + + if (succMemoryPhi == BasicBlock::EmptyMemoryPhiDef) + { + succMemoryPhi = new (m_pCompiler) + BasicBlock::MemoryPhiArg(block->bbMemorySsaNumOut[memoryKind]); + } + else + { + BasicBlock::MemoryPhiArg* curArg = succMemoryPhi; + unsigned ssaNum = block->bbMemorySsaNumOut[memoryKind]; + bool found = false; + // This is a quadratic algorithm. We might need to consider some switch over + // to a hash table representation for the arguments of a phi node, to make this + // linear. + while (curArg != nullptr) + { + if (curArg->m_ssaNum == ssaNum) + { + found = true; + break; + } + curArg = curArg->m_nextArg; + } + if (!found) + { + succMemoryPhi = + new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum, succMemoryPhi); + } + } + DBG_SSA_JITDUMP(" Added phi arg for %s u:%d from " FMT_BB " in " FMT_BB ".\n", + memoryKindNames[memoryKind], block->bbMemorySsaNumOut[memoryKind], + block->bbNum, succ->bbNum); + } + } + + // If "succ" is the first block of a try block (and "block" is not also in that try block) + // then we must look at the vars that have phi defs in the corresponding handler; + // the current SSA name for such vars must be included as an argument to that phi. + if (m_pCompiler->bbIsTryBeg(succ)) + { + assert(succ->hasTryIndex()); + unsigned tryInd = succ->getTryIndex(); + + while (tryInd != EHblkDsc::NO_ENCLOSING_INDEX) + { + // Check if the predecessor "block" is within the same try block. + if (block->hasTryIndex()) + { + for (unsigned blockTryInd = block->getTryIndex(); + blockTryInd != EHblkDsc::NO_ENCLOSING_INDEX; + blockTryInd = m_pCompiler->ehGetEnclosingTryIndex(blockTryInd)) + { + if (blockTryInd == tryInd) + { + // It is; don't execute the loop below. + tryInd = EHblkDsc::NO_ENCLOSING_INDEX; + break; + } + } + + // The loop just above found that the predecessor "block" is within the same + // try block as "succ." So we don't need to process this try, or any + // further outer try blocks here, since they would also contain both "succ" + // and "block". + if (tryInd == EHblkDsc::NO_ENCLOSING_INDEX) + { + break; + } + } + + EHblkDsc* succTry = m_pCompiler->ehGetDsc(tryInd); + // This is necessarily true on the first iteration, but not + // necessarily on the second and subsequent. + if (succTry->ebdTryBeg != succ) + { + break; + } + + if (succTry->HasFilter()) + { + AddPhiArgsToNewlyEnteredHandler(block, succ, succTry->ebdFilter); + } + + AddPhiArgsToNewlyEnteredHandler(block, succ, succTry->ebdHndBeg); + + tryInd = succTry->ebdEnclosingTryIndex; + } + } + + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/ssabuilder.h b/src/coreclr/jit/ssabuilder.h index d07e59e4e732cf..014edb94f1e01e 100644 --- a/src/coreclr/jit/ssabuilder.h +++ b/src/coreclr/jit/ssabuilder.h @@ -57,7 +57,7 @@ class SsaBuilder // Rename all definitions and uses within a block. void BlockRenameVariables(BasicBlock* block); // Rename a local or memory definition generated by a local store/GT_CALL node. - void RenameDef(GenTree* defNode, BasicBlock* block); + void RenameDef(GenTree* defNode, BasicBlock* block); unsigned RenamePushDef(GenTree* defNode, BasicBlock* block, unsigned lclNum, bool isFullDef); // Rename a use of a local variable. void RenameLclUse(GenTreeLclVarCommon* lclNode, BasicBlock* block); diff --git a/src/coreclr/jit/ssarenamestate.h b/src/coreclr/jit/ssarenamestate.h index 37dc332746b5ab..609d9b89f9b160 100644 --- a/src/coreclr/jit/ssarenamestate.h +++ b/src/coreclr/jit/ssarenamestate.h @@ -12,9 +12,7 @@ class SsaRenameState StackNode* m_top; public: - Stack() : m_top(nullptr) - { - } + Stack() : m_top(nullptr) {} StackNode* Top() { diff --git a/src/coreclr/jit/stacklevelsetter.h b/src/coreclr/jit/stacklevelsetter.h index fa788b0431f0d4..7813e0e645e078 100644 --- a/src/coreclr/jit/stacklevelsetter.h +++ b/src/coreclr/jit/stacklevelsetter.h @@ -20,8 +20,8 @@ class StackLevelSetter final : public Phase void SetThrowHelperBlock(SpecialCodeKind kind, BasicBlock* block); unsigned PopArgumentsFromCall(GenTreeCall* call); - void AddStackLevel(unsigned value); - void SubStackLevel(unsigned value); + void AddStackLevel(unsigned value); + void SubStackLevel(unsigned value); void CheckArgCnt(); void CheckAdditionalArgs(); diff --git a/src/coreclr/jit/target.h b/src/coreclr/jit/target.h index 6d427774c68e54..cac9b3968a230c 100644 --- a/src/coreclr/jit/target.h +++ b/src/coreclr/jit/target.h @@ -212,7 +212,7 @@ enum _regMask_enum : unsigned #if defined(TARGET_AMD64) || defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) typedef unsigned __int64 regMaskTP; #else -typedef unsigned regMaskTP; +typedef unsigned regMaskTP; #endif #if REGMASK_BITS == 8 @@ -764,8 +764,8 @@ typedef __int64 target_ssize_t; #define TARGET_SIGN_BIT (1ULL << 63) #else // !TARGET_64BIT -typedef unsigned int target_size_t; -typedef int target_ssize_t; +typedef unsigned int target_size_t; +typedef int target_ssize_t; #define TARGET_SIGN_BIT (1ULL << 31) #endif // !TARGET_64BIT diff --git a/src/coreclr/jit/targetarm.cpp b/src/coreclr/jit/targetarm.cpp index 14cb85adbcc16d..7816880dd21967 100644 --- a/src/coreclr/jit/targetarm.cpp +++ b/src/coreclr/jit/targetarm.cpp @@ -33,9 +33,7 @@ static_assert_no_msg(RBM_ALLDOUBLE == (RBM_ALLDOUBLE_HIGH >> 1)); // Parameters: // info - Info about the method being classified. // -Arm32Classifier::Arm32Classifier(const ClassifierInfo& info) : m_info(info) -{ -} +Arm32Classifier::Arm32Classifier(const ClassifierInfo& info) : m_info(info) {} //----------------------------------------------------------------------------- // Classify: diff --git a/src/coreclr/jit/treelifeupdater.cpp b/src/coreclr/jit/treelifeupdater.cpp index 9ae6d3cd02f74d..31563b4d501cc8 100644 --- a/src/coreclr/jit/treelifeupdater.cpp +++ b/src/coreclr/jit/treelifeupdater.cpp @@ -339,7 +339,7 @@ void TreeLifeUpdater::UpdateLifeBit(VARSET_TP& set, LclVarDsc* dsc, // can be dumped after potential updates. // template -void TreeLifeUpdater::StoreCurrentLifeForDump() +void TreeLifeUpdater::StoreCurrentLifeForDump() { #ifdef DEBUG if (compiler->verbose) diff --git a/src/coreclr/jit/unwind.cpp b/src/coreclr/jit/unwind.cpp index a927e73c02b9f1..e1ff9bc464a163 100644 --- a/src/coreclr/jit/unwind.cpp +++ b/src/coreclr/jit/unwind.cpp @@ -128,7 +128,7 @@ void Compiler::unwindGetFuncLocations(FuncInfoDsc* func, assert(func->funKind == FUNC_HANDLER); *ppStartLoc = new (this, CMK_UnwindInfo) emitLocation(ehEmitCookie(HBtab->ebdHndBeg)); *ppEndLoc = HBtab->ebdHndLast->IsLast() ? nullptr - : new (this, CMK_UnwindInfo) + : new (this, CMK_UnwindInfo) emitLocation(ehEmitCookie(HBtab->ebdHndLast->Next())); } } diff --git a/src/coreclr/jit/unwind.h b/src/coreclr/jit/unwind.h index 4d1b540f060624..f5609c1842d2b9 100644 --- a/src/coreclr/jit/unwind.h +++ b/src/coreclr/jit/unwind.h @@ -23,9 +23,10 @@ const unsigned MAX_PROLOG_SIZE_BYTES = 44; const unsigned MAX_EPILOG_SIZE_BYTES = 44; #define UWC_END 0xFF // "end" unwind code #define UW_MAX_FRAGMENT_SIZE_BYTES (1U << 19) -#define UW_MAX_CODE_WORDS_COUNT 15 // Max number that can be encoded in the "Code Words" field of the .pdata record -#define UW_MAX_EPILOG_START_INDEX 0xFFU // Max number that can be encoded in the "Epilog Start Index" field - // of the .pdata record +#define UW_MAX_CODE_WORDS_COUNT 15 // Max number that can be encoded in the "Code Words" field of the .pdata record +#define UW_MAX_EPILOG_START_INDEX \ + 0xFFU // Max number that can be encoded in the "Epilog Start Index" field + // of the .pdata record #elif defined(TARGET_ARM64) const unsigned MAX_PROLOG_SIZE_BYTES = 100; const unsigned MAX_EPILOG_SIZE_BYTES = 100; @@ -53,14 +54,18 @@ const unsigned MAX_EPILOG_SIZE_BYTES = 200; #endif // TARGET_RISCV64 -#define UW_MAX_EPILOG_COUNT 31 // Max number that can be encoded in the "Epilog count" field - // of the .pdata record -#define UW_MAX_EXTENDED_CODE_WORDS_COUNT 0xFFU // Max number that can be encoded in the "Extended Code Words" - // field of the .pdata record -#define UW_MAX_EXTENDED_EPILOG_COUNT 0xFFFFU // Max number that can be encoded in the "Extended Epilog Count" - // field of the .pdata record -#define UW_MAX_EPILOG_START_OFFSET 0x3FFFFU // Max number that can be encoded in the "Epilog Start Offset" - // field of the .pdata record +#define UW_MAX_EPILOG_COUNT \ + 31 // Max number that can be encoded in the "Epilog count" field + // of the .pdata record +#define UW_MAX_EXTENDED_CODE_WORDS_COUNT \ + 0xFFU // Max number that can be encoded in the "Extended Code Words" + // field of the .pdata record +#define UW_MAX_EXTENDED_EPILOG_COUNT \ + 0xFFFFU // Max number that can be encoded in the "Extended Epilog Count" + // field of the .pdata record +#define UW_MAX_EPILOG_START_OFFSET \ + 0x3FFFFU // Max number that can be encoded in the "Epilog Start Offset" + // field of the .pdata record // // Forward declaration of class defined in emit.h @@ -85,16 +90,10 @@ class UnwindInfo; class UnwindBase { protected: - UnwindBase(Compiler* comp) : uwiComp(comp) - { - } + UnwindBase(Compiler* comp) : uwiComp(comp) {} - UnwindBase() - { - } - ~UnwindBase() - { - } + UnwindBase() {} + ~UnwindBase() {} Compiler* uwiComp; }; @@ -107,9 +106,9 @@ class UnwindCodesBase public: // Add a single unwind code. - virtual void AddCode(BYTE b1) = 0; - virtual void AddCode(BYTE b1, BYTE b2) = 0; - virtual void AddCode(BYTE b1, BYTE b2, BYTE b3) = 0; + virtual void AddCode(BYTE b1) = 0; + virtual void AddCode(BYTE b1, BYTE b2) = 0; + virtual void AddCode(BYTE b1, BYTE b2, BYTE b3) = 0; virtual void AddCode(BYTE b1, BYTE b2, BYTE b3, BYTE b4) = 0; // Get access to the unwind codes @@ -252,12 +251,8 @@ class UnwindPrologCodes : public UnwindBase, public UnwindCodesBase // Copy the prolog codes from another prolog void CopyFrom(UnwindPrologCodes* pCopyFrom); - UnwindPrologCodes() - { - } - ~UnwindPrologCodes() - { - } + UnwindPrologCodes() {} + ~UnwindPrologCodes() {} #ifdef DEBUG void Dump(int indent = 0); @@ -426,12 +421,8 @@ class UnwindEpilogCodes : public UnwindBase, public UnwindCodesBase #endif // !TARGET_RISCV64 } - UnwindEpilogCodes() - { - } - ~UnwindEpilogCodes() - { - } + UnwindEpilogCodes() {} + ~UnwindEpilogCodes() {} #ifdef DEBUG void Dump(int indent = 0); @@ -539,12 +530,8 @@ class UnwindEpilogInfo : public UnwindBase // Match the codes to a set of epilog codes int Match(UnwindEpilogInfo* pEpi); - UnwindEpilogInfo() - { - } - ~UnwindEpilogInfo() - { - } + UnwindEpilogInfo() {} + ~UnwindEpilogInfo() {} #ifdef DEBUG void Dump(int indent = 0); @@ -659,12 +646,8 @@ class UnwindFragmentInfo : public UnwindBase void Allocate( CorJitFuncKind funKind, void* pHotCode, void* pColdCode, UNATIVE_OFFSET funcEndOffset, bool isHotCode); - UnwindFragmentInfo() - { - } - ~UnwindFragmentInfo() - { - } + UnwindFragmentInfo() {} + ~UnwindFragmentInfo() {} #ifdef DEBUG void Dump(int indent = 0); @@ -793,12 +776,8 @@ class UnwindInfo : public UnwindBase void CaptureLocation(); - UnwindInfo() - { - } - ~UnwindInfo() - { - } + UnwindInfo() {} + ~UnwindInfo() {} #ifdef DEBUG @@ -807,9 +786,7 @@ class UnwindInfo : public UnwindBase // the last instruction added in the emitter. void CheckOpsize(BYTE b1); #elif defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) - void CheckOpsize(BYTE b1) - { - } // nothing to do; all instructions are 4 bytes + void CheckOpsize(BYTE b1) {} // nothing to do; all instructions are 4 bytes #endif // defined(TARGET_ARM64) void Dump(bool isHotCode, int indent = 0); diff --git a/src/coreclr/jit/unwindamd64.cpp b/src/coreclr/jit/unwindamd64.cpp index 549c4e9910567c..e42a4368581fb7 100644 --- a/src/coreclr/jit/unwindamd64.cpp +++ b/src/coreclr/jit/unwindamd64.cpp @@ -199,7 +199,7 @@ void Compiler::unwindPushWindows(regNumber reg) // since it is pushed as a frame register. || (reg == REG_FPBASE) #endif // ETW_EBP_FRAMED - ) + ) { code->UnwindOp = UWOP_PUSH_NONVOL; code->OpInfo = (BYTE)reg; diff --git a/src/coreclr/jit/unwindarm64.cpp b/src/coreclr/jit/unwindarm64.cpp index 0725eb41dfdba5..f842737171c0b4 100644 --- a/src/coreclr/jit/unwindarm64.cpp +++ b/src/coreclr/jit/unwindarm64.cpp @@ -461,8 +461,8 @@ void Compiler::unwindSaveRegPairPreindexed(regNumber reg1, regNumber reg2, int o pu->AddCode(0x80 | (BYTE)z); } - else if ((reg1 == REG_R19) && - (-256 <= offset)) // If the offset is between -512 and -256, we use the save_regp_x unwind code. + else if ((reg1 == REG_R19) && (-256 <= offset)) // If the offset is between -512 and -256, we use the save_regp_x + // unwind code. { // save_r19r20_x: 001zzzzz: save pair at [sp-#Z*8]!, pre-indexed offset >= -248 // NOTE: I'm not sure why we allow Z==0 here; seems useless, and the calculation of offset is different from the @@ -758,7 +758,7 @@ void DumpUnwindInfo(Compiler* comp, // pHeader is not guaranteed to be aligned. We put four 0xFF end codes at the end // to provide padding, and round down to get a multiple of 4 bytes in size. DWORD UNALIGNED* pdw = (DWORD UNALIGNED*)pHeader; - DWORD dw; + DWORD dw; dw = *pdw++; diff --git a/src/coreclr/jit/unwindarmarch.cpp b/src/coreclr/jit/unwindarmarch.cpp index 445b2581ca0abb..bdc7663bde7ed1 100644 --- a/src/coreclr/jit/unwindarmarch.cpp +++ b/src/coreclr/jit/unwindarmarch.cpp @@ -243,9 +243,8 @@ void Compiler::unwindPushPopMaskInt(regMaskTP maskInt, bool useOpsize16) } else { - assert((maskInt & - ~(RBM_R0 | RBM_R1 | RBM_R2 | RBM_R3 | RBM_R4 | RBM_R5 | RBM_R6 | RBM_R7 | RBM_R8 | RBM_R9 | RBM_R10 | - RBM_R11 | RBM_R12 | RBM_LR)) == 0); + assert((maskInt & ~(RBM_R0 | RBM_R1 | RBM_R2 | RBM_R3 | RBM_R4 | RBM_R5 | RBM_R6 | RBM_R7 | RBM_R8 | RBM_R9 | + RBM_R10 | RBM_R11 | RBM_R12 | RBM_LR)) == 0); bool shortFormat = false; BYTE val = 0; @@ -321,9 +320,8 @@ void Compiler::unwindPushPopMaskFloat(regMaskTP maskFloat) void Compiler::unwindPushMaskInt(regMaskTP maskInt) { // Only r0-r12 and lr are supported - assert((maskInt & - ~(RBM_R0 | RBM_R1 | RBM_R2 | RBM_R3 | RBM_R4 | RBM_R5 | RBM_R6 | RBM_R7 | RBM_R8 | RBM_R9 | RBM_R10 | - RBM_R11 | RBM_R12 | RBM_LR)) == 0); + assert((maskInt & ~(RBM_R0 | RBM_R1 | RBM_R2 | RBM_R3 | RBM_R4 | RBM_R5 | RBM_R6 | RBM_R7 | RBM_R8 | RBM_R9 | + RBM_R10 | RBM_R11 | RBM_R12 | RBM_LR)) == 0); #if defined(FEATURE_CFI_SUPPORT) if (generateCFIUnwindCodes()) @@ -364,9 +362,8 @@ void Compiler::unwindPopMaskInt(regMaskTP maskInt) #endif // FEATURE_CFI_SUPPORT // Only r0-r12 and lr and pc are supported (pc is mapped to lr when encoding) - assert((maskInt & - ~(RBM_R0 | RBM_R1 | RBM_R2 | RBM_R3 | RBM_R4 | RBM_R5 | RBM_R6 | RBM_R7 | RBM_R8 | RBM_R9 | RBM_R10 | - RBM_R11 | RBM_R12 | RBM_LR | RBM_PC)) == 0); + assert((maskInt & ~(RBM_R0 | RBM_R1 | RBM_R2 | RBM_R3 | RBM_R4 | RBM_R5 | RBM_R6 | RBM_R7 | RBM_R8 | RBM_R9 | + RBM_R10 | RBM_R11 | RBM_R12 | RBM_LR | RBM_PC)) == 0); bool useOpsize16 = ((maskInt & (RBM_LOW_REGS | RBM_PC)) == maskInt); // Can POP use the 16-bit encoding? @@ -721,8 +718,8 @@ unsigned GetOpcodeSizeFromUnwindHeader(BYTE b1) }; BYTE opsize = s_UnwindOpsize[b1]; - assert(opsize == 2 || - opsize == 4); // We shouldn't get a code with no opsize (the 0xFF end code is handled specially) + assert(opsize == 2 || opsize == 4); // We shouldn't get a code with no opsize (the 0xFF end code is handled + // specially) return opsize; } @@ -887,9 +884,9 @@ void UnwindPrologCodes::AppendEpilog(UnwindEpilogInfo* pEpi) int epiSize = pEpi->Size(); memcpy_s(&upcMem[upcEpilogSlot], upcMemSize - upcEpilogSlot - 3, pEpi->GetCodes(), - epiSize); // -3 to avoid writing to the alignment padding - assert(pEpi->GetStartIndex() == - upcEpilogSlot - upcCodeSlot); // Make sure we copied it where we expected to copy it. + epiSize); // -3 to avoid writing to the alignment padding + assert(pEpi->GetStartIndex() == upcEpilogSlot - upcCodeSlot); // Make sure we copied it where we expected to copy + // it. upcEpilogSlot += epiSize; assert(upcEpilogSlot <= upcMemSize - 3); @@ -1455,7 +1452,7 @@ void UnwindFragmentInfo::Finalize(UNATIVE_OFFSET functionLength) } #endif -// Compute the header + // Compute the header #if defined(TARGET_ARM) noway_assert((functionLength & 1) == 0); @@ -1504,8 +1501,8 @@ void UnwindFragmentInfo::Finalize(UNATIVE_OFFSET functionLength) // Start writing the header - noway_assert(headerFunctionLength <= - 0x3FFFFU); // We create fragments to prevent this from firing, so if it hits, we have an internal error + noway_assert(headerFunctionLength <= 0x3FFFFU); // We create fragments to prevent this from firing, so if it hits, + // we have an internal error if ((headerEpilogCount > UW_MAX_EPILOG_COUNT) || (headerCodeWords > UW_MAX_CODE_WORDS_COUNT)) { @@ -1516,7 +1513,7 @@ void UnwindFragmentInfo::Finalize(UNATIVE_OFFSET functionLength) DWORD header = headerFunctionLength | (headerVers << 18) | (headerXBit << 20) | (headerEBit << 21) | (headerFBit << 22) | (headerEpilogCount << 23) | (headerCodeWords << 28); #elif defined(TARGET_ARM64) - DWORD header = headerFunctionLength | (headerVers << 18) | (headerXBit << 20) | (headerEBit << 21) | + DWORD header = headerFunctionLength | (headerVers << 18) | (headerXBit << 20) | (headerEBit << 21) | (headerEpilogCount << 22) | (headerCodeWords << 27); #endif // defined(TARGET_ARM64) @@ -2203,7 +2200,7 @@ DWORD DumpRegSetRange(const char* const rtype, DWORD start, DWORD end, DWORD lr) DWORD DumpOpsize(DWORD padding, DWORD opsize) { if (padding > 100) // underflow? - padding = 4; + padding = 4; DWORD printed = padding; for (; padding > 0; padding--) printf(" "); @@ -2231,7 +2228,7 @@ void DumpUnwindInfo(Compiler* comp, // pHeader is not guaranteed to be aligned. We put four 0xFF end codes at the end // to provide padding, and round down to get a multiple of 4 bytes in size. DWORD UNALIGNED* pdw = (DWORD UNALIGNED*)pHeader; - DWORD dw; + DWORD dw; dw = *pdw++; diff --git a/src/coreclr/jit/unwindloongarch64.cpp b/src/coreclr/jit/unwindloongarch64.cpp index 3aa5fd668d40c6..1b561eaaaae669 100644 --- a/src/coreclr/jit/unwindloongarch64.cpp +++ b/src/coreclr/jit/unwindloongarch64.cpp @@ -516,7 +516,7 @@ void DumpUnwindInfo(Compiler* comp, // pHeader is not guaranteed to be aligned. We put four 0xFF end codes at the end // to provide padding, and round down to get a multiple of 4 bytes in size. DWORD UNALIGNED* pdw = (DWORD UNALIGNED*)pHeader; - DWORD dw; + DWORD dw; dw = *pdw++; @@ -1149,9 +1149,9 @@ void UnwindPrologCodes::AppendEpilog(UnwindEpilogInfo* pEpi) int epiSize = pEpi->Size(); memcpy_s(&upcMem[upcEpilogSlot], upcMemSize - upcEpilogSlot - 3, pEpi->GetCodes(), - epiSize); // -3 to avoid writing to the alignment padding - assert(pEpi->GetStartIndex() == - upcEpilogSlot - upcCodeSlot); // Make sure we copied it where we expected to copy it. + epiSize); // -3 to avoid writing to the alignment padding + assert(pEpi->GetStartIndex() == upcEpilogSlot - upcCodeSlot); // Make sure we copied it where we expected to copy + // it. upcEpilogSlot += epiSize; assert(upcEpilogSlot <= upcMemSize - 3); @@ -1772,8 +1772,8 @@ void UnwindFragmentInfo::Finalize(UNATIVE_OFFSET functionLength) // Start writing the header - noway_assert(headerFunctionLength <= - 0x3FFFFU); // We create fragments to prevent this from firing, so if it hits, we have an internal error + noway_assert(headerFunctionLength <= 0x3FFFFU); // We create fragments to prevent this from firing, so if it hits, + // we have an internal error if ((headerEpilogCount > UW_MAX_EPILOG_COUNT) || (headerCodeWords > UW_MAX_CODE_WORDS_COUNT)) { diff --git a/src/coreclr/jit/unwindriscv64.cpp b/src/coreclr/jit/unwindriscv64.cpp index b78eb04c228e93..f9db0d433c6f13 100644 --- a/src/coreclr/jit/unwindriscv64.cpp +++ b/src/coreclr/jit/unwindriscv64.cpp @@ -327,7 +327,7 @@ void DumpUnwindInfo(Compiler* comp, // pHeader is not guaranteed to be aligned. We put four 0xFF end codes at the end // to provide padding, and round down to get a multiple of 4 bytes in size. DWORD UNALIGNED* pdw = (DWORD UNALIGNED*)pHeader; - DWORD dw; + DWORD dw; dw = *pdw++; diff --git a/src/coreclr/jit/unwindx86.cpp b/src/coreclr/jit/unwindx86.cpp index 32d077429af6a1..1889c1f116f58e 100644 --- a/src/coreclr/jit/unwindx86.cpp +++ b/src/coreclr/jit/unwindx86.cpp @@ -30,37 +30,21 @@ short Compiler::mapRegNumToDwarfReg(regNumber reg) } #endif // FEATURE_CFI_SUPPORT -void Compiler::unwindBegProlog() -{ -} +void Compiler::unwindBegProlog() {} -void Compiler::unwindEndProlog() -{ -} +void Compiler::unwindEndProlog() {} -void Compiler::unwindBegEpilog() -{ -} +void Compiler::unwindBegEpilog() {} -void Compiler::unwindEndEpilog() -{ -} +void Compiler::unwindEndEpilog() {} -void Compiler::unwindPush(regNumber reg) -{ -} +void Compiler::unwindPush(regNumber reg) {} -void Compiler::unwindAllocStack(unsigned size) -{ -} +void Compiler::unwindAllocStack(unsigned size) {} -void Compiler::unwindSetFrameReg(regNumber reg, unsigned offset) -{ -} +void Compiler::unwindSetFrameReg(regNumber reg, unsigned offset) {} -void Compiler::unwindSaveReg(regNumber reg, unsigned offset) -{ -} +void Compiler::unwindSaveReg(regNumber reg, unsigned offset) {} //------------------------------------------------------------------------ // Compiler::unwindReserve: Ask the VM to reserve space for the unwind information diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index 9e706fd884e56b..33d46bf1acd7c3 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -1190,19 +1190,21 @@ void NodeCounts::dump(FILE* output) sorted[i].count = static_cast(m_counts[i]); } - jitstd::sort(sorted, sorted + ArrLen(sorted), [](const Entry& lhs, const Entry& rhs) { - if (lhs.count > rhs.count) - { - return true; - } - - if (lhs.count < rhs.count) - { - return false; - } - - return static_cast(lhs.oper) < static_cast(rhs.oper); - }); + jitstd::sort(sorted, sorted + ArrLen(sorted), + [](const Entry& lhs, const Entry& rhs) + { + if (lhs.count > rhs.count) + { + return true; + } + + if (lhs.count < rhs.count) + { + return false; + } + + return static_cast(lhs.oper) < static_cast(rhs.oper); + }); for (const Entry& entry : sorted) { @@ -2155,9 +2157,7 @@ double CachedCyclesPerSecond() } #ifdef FEATURE_JIT_METHOD_PERF -CycleCount::CycleCount() : cps(CachedCyclesPerSecond()) -{ -} +CycleCount::CycleCount() : cps(CachedCyclesPerSecond()) {} bool CycleCount::GetCycles(unsigned __int64* time) { @@ -2299,7 +2299,7 @@ unsigned __int64 FloatingPointUtils::convertDoubleToUInt64(double d) u64 = UINT64(INT64(d)); #else - u64 = UINT64(d); + u64 = UINT64(d); #endif // TARGET_XARCH return u64; @@ -4099,7 +4099,7 @@ int64_t GetSigned64Magic(int64_t d, int* shift /*out*/) return GetSignedMagic(d, shift); } #endif -} +} // namespace MagicDivide namespace CheckedOps { @@ -4293,4 +4293,4 @@ bool CastFromDoubleOverflows(double fromValue, var_types toType) unreached(); } } -} +} // namespace CheckedOps diff --git a/src/coreclr/jit/utils.h b/src/coreclr/jit/utils.h index 0b1b6840be6ec3..17406cb6bfabe6 100644 --- a/src/coreclr/jit/utils.h +++ b/src/coreclr/jit/utils.h @@ -88,9 +88,7 @@ class IteratorPair TIterator m_end; public: - IteratorPair(TIterator begin, TIterator end) : m_begin(begin), m_end(end) - { - } + IteratorPair(TIterator begin, TIterator end) : m_begin(begin), m_end(end) {} inline TIterator begin() { @@ -246,9 +244,7 @@ class ConfigMethodRange class ConfigIntArray { public: - ConfigIntArray() : m_values(nullptr), m_length(0) - { - } + ConfigIntArray() : m_values(nullptr), m_length(0) {} // Ensure the string has been parsed. void EnsureInit(const WCHAR* str) @@ -270,7 +266,7 @@ class ConfigIntArray } private: - void Init(const WCHAR* str); + void Init(const WCHAR* str); int* m_values; unsigned m_length; }; @@ -280,9 +276,7 @@ class ConfigIntArray class ConfigDoubleArray { public: - ConfigDoubleArray() : m_values(nullptr), m_length(0) - { - } + ConfigDoubleArray() : m_values(nullptr), m_length(0) {} // Ensure the string has been parsed. void EnsureInit(const WCHAR* str) @@ -304,7 +298,7 @@ class ConfigDoubleArray } private: - void Init(const WCHAR* str); + void Init(const WCHAR* str); double* m_values; unsigned m_length; }; @@ -786,8 +780,8 @@ unsigned CountDigits(double num, unsigned base = 10); #endif // DEBUG /***************************************************************************** -* Floating point utility class -*/ + * Floating point utility class + */ class FloatingPointUtils { public: @@ -1019,7 +1013,7 @@ class CritSecObject CRITSEC_COOKIE m_pCs; // No copying or assignment allowed. - CritSecObject(const CritSecObject&) = delete; + CritSecObject(const CritSecObject&) = delete; CritSecObject& operator=(const CritSecObject&) = delete; }; @@ -1043,7 +1037,7 @@ class CritSecHolder CritSecObject& m_CritSec; // No copying or assignment allowed. - CritSecHolder(const CritSecHolder&) = delete; + CritSecHolder(const CritSecHolder&) = delete; CritSecHolder& operator=(const CritSecHolder&) = delete; }; @@ -1059,7 +1053,7 @@ int32_t GetSigned32Magic(int32_t d, int* shift /*out*/); #ifdef TARGET_64BIT int64_t GetSigned64Magic(int64_t d, int* shift /*out*/); #endif -} +} // namespace MagicDivide // // Profiling helpers @@ -1160,6 +1154,6 @@ bool CastFromIntOverflows(int32_t fromValue, var_types toType, bool fromUnsigned bool CastFromLongOverflows(int64_t fromValue, var_types toType, bool fromUnsigned); bool CastFromFloatOverflows(float fromValue, var_types toType); bool CastFromDoubleOverflows(double fromValue, var_types toType); -} +} // namespace CheckedOps #endif // _UTILS_H_ diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index 7ebde5995cf732..a255e0cf146fba 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -45,7 +45,7 @@ struct FloatTraits #if defined(TARGET_XARCH) unsigned bits = 0xFFC00000u; #elif defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) - unsigned bits = 0x7FC00000u; + unsigned bits = 0x7FC00000u; #else #error Unsupported or unset target architecture #endif @@ -2971,7 +2971,8 @@ typedef JitHashTable, bool> ValueN class SmallValueNumSet { - union { + union + { ValueNum m_inlineElements[4]; ValueNumSet* m_set; }; @@ -3072,9 +3073,9 @@ ValueNum ValueNumStore::VNForMapSelectInner(ValueNumKind vnk, var_types type, Va FlowGraphNaturalLoop* loop = m_pComp->m_blockToLoop->GetLoop(m_pComp->compCurBB); if (loop != nullptr) { - memoryDependencies.ForEach([this](ValueNum vn) { - m_pComp->optRecordLoopMemoryDependence(m_pComp->compCurTree, m_pComp->compCurBB, vn); - }); + memoryDependencies.ForEach( + [this](ValueNum vn) + { m_pComp->optRecordLoopMemoryDependence(m_pComp->compCurTree, m_pComp->compCurBB, vn); }); } } @@ -3105,10 +3106,12 @@ void ValueNumStore::MapSelectWorkCacheEntry::SetMemoryDependencies(Compiler* com } size_t i = 0; - set.ForEach([&i, arr](ValueNum vn) { - arr[i] = vn; - i++; - }); + set.ForEach( + [&i, arr](ValueNum vn) + { + arr[i] = vn; + i++; + }); } //------------------------------------------------------------------------------ @@ -3416,7 +3419,7 @@ ValueNum ValueNumStore::VNForMapSelectWork(ValueNumKind vnk, { bool usedRecursiveVN = false; ValueNum curResult = VNForMapSelectWork(vnk, type, phiArgVN, index, pBudget, - &usedRecursiveVN, recMemoryDependencies); + &usedRecursiveVN, recMemoryDependencies); *pUsedRecursiveVN |= usedRecursiveVN; if (sameSelResult == ValueNumStore::RecursiveVN) @@ -3449,8 +3452,8 @@ ValueNum ValueNumStore::VNForMapSelectWork(ValueNumKind vnk, GetMapSelectWorkCache()->Set(fstruct, entry); } - recMemoryDependencies.ForEach( - [this, &memoryDependencies](ValueNum vn) { memoryDependencies.Add(m_pComp, vn); }); + recMemoryDependencies.ForEach([this, &memoryDependencies](ValueNum vn) + { memoryDependencies.Add(m_pComp, vn); }); return sameSelResult; } @@ -4818,7 +4821,8 @@ ValueNum ValueNumStore::EvalUsingMathIdentity(var_types typ, VNFunc func, ValueN // (0 + x) == x // (x + 0) == x // This identity does not apply for floating point (when x == -0.0). - auto identityForAddition = [=]() -> ValueNum { + auto identityForAddition = [=]() -> ValueNum + { if (!varTypeIsFloating(typ)) { ValueNum ZeroVN = VNZeroForType(typ); @@ -4838,7 +4842,8 @@ ValueNum ValueNumStore::EvalUsingMathIdentity(var_types typ, VNFunc func, ValueN // (x - 0) == x // (x - x) == 0 // This identity does not apply for floating point (when x == -0.0). - auto identityForSubtraction = [=](bool ovf) -> ValueNum { + auto identityForSubtraction = [=](bool ovf) -> ValueNum + { if (!varTypeIsFloating(typ)) { ValueNum ZeroVN = VNZeroForType(typ); @@ -4889,7 +4894,8 @@ ValueNum ValueNumStore::EvalUsingMathIdentity(var_types typ, VNFunc func, ValueN }; // These identities do not apply for floating point. - auto identityForMultiplication = [=]() -> ValueNum { + auto identityForMultiplication = [=]() -> ValueNum + { if (!varTypeIsFloating(typ)) { // (0 * x) == 0 @@ -5610,7 +5616,7 @@ ValueNum ValueNumStore::ExtendPtrVN(GenTree* opA, FieldSeq* fldSeq, ssize_t offs { fldSeq = m_pComp->GetFieldSeqStore()->Append(FieldSeqVNToFieldSeq(funcApp.m_args[1]), fldSeq); res = VNForFunc(TYP_BYREF, VNF_PtrToStatic, funcApp.m_args[0], VNForFieldSeq(fldSeq), - VNForIntPtrCon(ConstantValue(funcApp.m_args[2]) + offset)); + VNForIntPtrCon(ConstantValue(funcApp.m_args[2]) + offset)); } else if (funcApp.m_func == VNF_PtrToArrElem) { @@ -5651,9 +5657,9 @@ void Compiler::fgValueNumberLocalStore(GenTree* storeNode, // Should not have been recorded as updating the GC heap. assert(!GetMemorySsaMap(GcHeap)->Lookup(storeNode)); - auto processDef = [=](unsigned defLclNum, unsigned defSsaNum, ssize_t defOffset, unsigned defSize, - ValueNumPair defValue) { - + auto processDef = + [=](unsigned defLclNum, unsigned defSsaNum, ssize_t defOffset, unsigned defSize, ValueNumPair defValue) + { LclVarDsc* defVarDsc = lvaGetDesc(defLclNum); if (defSsaNum != SsaConfig::RESERVED_SSA_NUM) @@ -11151,7 +11157,8 @@ bool Compiler::fgValueNumberConstLoad(GenTreeIndir* tree) } // Is given VN representing a frozen object handle - auto isCnsObjHandle = [](ValueNumStore* vnStore, ValueNum vn, CORINFO_OBJECT_HANDLE* handle) -> bool { + auto isCnsObjHandle = [](ValueNumStore* vnStore, ValueNum vn, CORINFO_OBJECT_HANDLE* handle) -> bool + { if (vnStore->IsVNObjHandle(vn)) { *handle = vnStore->ConstantObjHandle(vn); @@ -11996,7 +12003,8 @@ void Compiler::fgValueNumberHWIntrinsic(GenTreeHWIntrinsic* tree) JITDUMP("\n"); } - auto getOperandVNs = [this, addr](GenTree* operand, ValueNumPair* pNormVNPair, ValueNumPair* pExcVNPair) { + auto getOperandVNs = [this, addr](GenTree* operand, ValueNumPair* pNormVNPair, ValueNumPair* pExcVNPair) + { vnStore->VNPUnpackExc(operand->gtVNPair, pNormVNPair, pExcVNPair); // If we have a load operation we will use the fgValueNumberByrefExposedLoad @@ -12189,8 +12197,8 @@ void Compiler::fgValueNumberCastTree(GenTree* tree) ValueNum ValueNumStore::VNForCast(ValueNum srcVN, var_types castToType, var_types castFromType, - bool srcIsUnsigned, /* = false */ - bool hasOverflowCheck) /* = false */ + bool srcIsUnsigned, /* = false */ + bool hasOverflowCheck) /* = false */ { if ((castFromType == TYP_I_IMPL) && (castToType == TYP_BYREF) && IsVNHandle(srcVN)) @@ -12235,8 +12243,8 @@ ValueNum ValueNumStore::VNForCast(ValueNum srcVN, ValueNumPair ValueNumStore::VNPairForCast(ValueNumPair srcVNPair, var_types castToType, var_types castFromType, - bool srcIsUnsigned, /* = false */ - bool hasOverflowCheck) /* = false */ + bool srcIsUnsigned, /* = false */ + bool hasOverflowCheck) /* = false */ { ValueNum srcLibVN = srcVNPair.GetLiberal(); ValueNum srcConVN = srcVNPair.GetConservative(); @@ -13741,15 +13749,17 @@ void Compiler::fgDebugCheckExceptionSets() assert(tree->gtVNPair.BothDefined() || tree->OperIs(GT_PHI_ARG)); ValueNumPair operandsExcSet = vnStore->VNPForEmptyExcSet(); - tree->VisitOperands([&](GenTree* operand) -> GenTree::VisitResult { - - CheckTree(operand, vnStore); + tree->VisitOperands( + [&](GenTree* operand) -> GenTree::VisitResult + { + CheckTree(operand, vnStore); - ValueNumPair operandVNP = operand->gtVNPair.BothDefined() ? operand->gtVNPair : vnStore->VNPForVoid(); - operandsExcSet = vnStore->VNPUnionExcSet(operandVNP, operandsExcSet); + ValueNumPair operandVNP = + operand->gtVNPair.BothDefined() ? operand->gtVNPair : vnStore->VNPForVoid(); + operandsExcSet = vnStore->VNPUnionExcSet(operandVNP, operandsExcSet); - return GenTree::VisitResult::Continue; - }); + return GenTree::VisitResult::Continue; + }); // Currently, we fail to properly maintain the exception sets for trees with user calls. if ((tree->gtFlags & GTF_CALL) != 0) @@ -13796,7 +13806,7 @@ void Compiler::JitTestCheckVN() // First we have to know which nodes in the tree are reachable. typedef JitHashTable, int> NodeToIntMap; - NodeToIntMap* reachable = FindReachableNodesInNodeTestData(); + NodeToIntMap* reachable = FindReachableNodesInNodeTestData(); LabelToVNMap* labelToVN = new (getAllocatorDebugOnly()) LabelToVNMap(getAllocatorDebugOnly()); VNToLabelMap* vnToLabel = new (getAllocatorDebugOnly()) VNToLabelMap(getAllocatorDebugOnly()); @@ -13931,9 +13941,7 @@ void Compiler::vnPrint(ValueNum vn, unsigned level) #endif // DEBUG // Methods of ValueNumPair. -ValueNumPair::ValueNumPair() : m_liberal(ValueNumStore::NoVN), m_conservative(ValueNumStore::NoVN) -{ -} +ValueNumPair::ValueNumPair() : m_liberal(ValueNumStore::NoVN), m_conservative(ValueNumStore::NoVN) {} bool ValueNumPair::BothDefined() const { diff --git a/src/coreclr/jit/valuenum.h b/src/coreclr/jit/valuenum.h index 7cd6c27aec206c..7f437496917cf7 100644 --- a/src/coreclr/jit/valuenum.h +++ b/src/coreclr/jit/valuenum.h @@ -238,9 +238,7 @@ class ValueNumStore class VNMap : public JitHashTable { public: - VNMap(CompAllocator alloc) : JitHashTable(alloc) - { - } + VNMap(CompAllocator alloc) : JitHashTable(alloc) {} bool Set(fromType k, ValueNum val) { @@ -306,7 +304,7 @@ class ValueNumStore bool illegalAsVNFunc, GenTreeOperKind kind); static constexpr uint8_t GetOpAttribsForFunc(int arity, bool commute, bool knownNonNull, bool sharedStatic); - static const uint8_t s_vnfOpAttribs[]; + static const uint8_t s_vnfOpAttribs[]; // Returns "true" iff gtOper is a legal value number function. // (Requires InitValueNumStoreStatics to have been run.) @@ -355,18 +353,18 @@ class ValueNumStore public: // Given an constant value number return its value. - int GetConstantInt32(ValueNum argVN); - INT64 GetConstantInt64(ValueNum argVN); + int GetConstantInt32(ValueNum argVN); + INT64 GetConstantInt64(ValueNum argVN); double GetConstantDouble(ValueNum argVN); - float GetConstantSingle(ValueNum argVN); + float GetConstantSingle(ValueNum argVN); #if defined(FEATURE_SIMD) - simd8_t GetConstantSimd8(ValueNum argVN); + simd8_t GetConstantSimd8(ValueNum argVN); simd12_t GetConstantSimd12(ValueNum argVN); simd16_t GetConstantSimd16(ValueNum argVN); #if defined(TARGET_XARCH) - simd32_t GetConstantSimd32(ValueNum argVN); - simd64_t GetConstantSimd64(ValueNum argVN); + simd32_t GetConstantSimd32(ValueNum argVN); + simd64_t GetConstantSimd64(ValueNum argVN); simdmask_t GetConstantSimdMask(ValueNum argVN); #endif // TARGET_XARCH #endif // FEATURE_SIMD @@ -560,7 +558,7 @@ class ValueNumStore // Create or return the existimg value number representing a singleton exception set // for the exception value "x". - ValueNum VNExcSetSingleton(ValueNum x); + ValueNum VNExcSetSingleton(ValueNum x); ValueNumPair VNPExcSetSingleton(ValueNumPair x); // Returns true if the current pair of items are in ascending order and they are not duplicates. @@ -814,7 +812,7 @@ class ValueNumStore return ValueNumPair(liberalFuncVN, conservativeFuncVN); } - ValueNum VNForExpr(BasicBlock* block, var_types type = TYP_UNKNOWN); + ValueNum VNForExpr(BasicBlock* block, var_types type = TYP_UNKNOWN); ValueNumPair VNPairForExpr(BasicBlock* block, var_types type); // This controls extra tracing of the "evaluation" of "VNF_MapSelect" functions. @@ -916,9 +914,7 @@ class ValueNumStore ValueNum vnIdx; ValueNum vnBound; - UnsignedCompareCheckedBoundInfo() : cmpOper(GT_NONE), vnIdx(NoVN), vnBound(NoVN) - { - } + UnsignedCompareCheckedBoundInfo() : cmpOper(GT_NONE), vnIdx(NoVN), vnBound(NoVN) {} }; struct CompareCheckedBoundArithInfo @@ -930,9 +926,7 @@ class ValueNumStore ValueNum arrOp; unsigned cmpOper; ValueNum cmpOp; - CompareCheckedBoundArithInfo() : vnBound(NoVN), arrOper(GT_NONE), arrOp(NoVN), cmpOper(GT_NONE), cmpOp(NoVN) - { - } + CompareCheckedBoundArithInfo() : vnBound(NoVN), arrOper(GT_NONE), arrOp(NoVN), cmpOper(GT_NONE), cmpOp(NoVN) {} #ifdef DEBUG void dump(ValueNumStore* vnStore) { @@ -958,9 +952,7 @@ class ValueNumStore ValueNum cmpOpVN; bool isUnsigned; - ConstantBoundInfo() : constVal(0), cmpOper(GT_NONE), cmpOpVN(NoVN), isUnsigned(false) - { - } + ConstantBoundInfo() : constVal(0), cmpOper(GT_NONE), cmpOpVN(NoVN), isUnsigned(false) {} #ifdef DEBUG void dump(ValueNumStore* vnStore) @@ -1477,7 +1469,7 @@ class ValueNumStore static const int SmallIntConstMin = -1; static const int SmallIntConstMax = 10; static const unsigned SmallIntConstNum = SmallIntConstMax - SmallIntConstMin + 1; - static bool IsSmallIntConst(int i) + static bool IsSmallIntConst(int i) { return SmallIntConstMin <= i && i <= SmallIntConstMax; } @@ -1487,9 +1479,7 @@ class ValueNumStore { ValueNum vn; ValueNumList* next; - ValueNumList(const ValueNum& v, ValueNumList* n = nullptr) : vn(v), next(n) - { - } + ValueNumList(const ValueNum& v, ValueNumList* n = nullptr) : vn(v), next(n) {} }; // Keeps track of value numbers that are integer constants and also handles (GTG_ICON_HDL_MASK.) @@ -1518,8 +1508,8 @@ class ValueNumStore } typedef VNMap HandleToValueNumMap; - HandleToValueNumMap* m_handleMap; - HandleToValueNumMap* GetHandleMap() + HandleToValueNumMap* m_handleMap; + HandleToValueNumMap* GetHandleMap() { if (m_handleMap == nullptr) { @@ -1529,10 +1519,10 @@ class ValueNumStore } typedef SmallHashTable EmbeddedToCompileTimeHandleMap; - EmbeddedToCompileTimeHandleMap m_embeddedToCompileTimeHandleMap; + EmbeddedToCompileTimeHandleMap m_embeddedToCompileTimeHandleMap; typedef SmallHashTable FieldAddressToFieldSeqMap; - FieldAddressToFieldSeqMap m_fieldAddressToFieldSeqMap; + FieldAddressToFieldSeqMap m_fieldAddressToFieldSeqMap; struct LargePrimitiveKeyFuncsFloat : public JitLargePrimitiveKeyFuncs { @@ -1543,8 +1533,8 @@ class ValueNumStore }; typedef VNMap FloatToValueNumMap; - FloatToValueNumMap* m_floatCnsMap; - FloatToValueNumMap* GetFloatCnsMap() + FloatToValueNumMap* m_floatCnsMap; + FloatToValueNumMap* GetFloatCnsMap() { if (m_floatCnsMap == nullptr) { @@ -1563,8 +1553,8 @@ class ValueNumStore }; typedef VNMap DoubleToValueNumMap; - DoubleToValueNumMap* m_doubleCnsMap; - DoubleToValueNumMap* GetDoubleCnsMap() + DoubleToValueNumMap* m_doubleCnsMap; + DoubleToValueNumMap* GetDoubleCnsMap() { if (m_doubleCnsMap == nullptr) { @@ -1604,8 +1594,8 @@ class ValueNumStore }; typedef VNMap Simd8ToValueNumMap; - Simd8ToValueNumMap* m_simd8CnsMap; - Simd8ToValueNumMap* GetSimd8CnsMap() + Simd8ToValueNumMap* m_simd8CnsMap; + Simd8ToValueNumMap* GetSimd8CnsMap() { if (m_simd8CnsMap == nullptr) { @@ -1634,8 +1624,8 @@ class ValueNumStore }; typedef VNMap Simd12ToValueNumMap; - Simd12ToValueNumMap* m_simd12CnsMap; - Simd12ToValueNumMap* GetSimd12CnsMap() + Simd12ToValueNumMap* m_simd12CnsMap; + Simd12ToValueNumMap* GetSimd12CnsMap() { if (m_simd12CnsMap == nullptr) { @@ -1665,8 +1655,8 @@ class ValueNumStore }; typedef VNMap Simd16ToValueNumMap; - Simd16ToValueNumMap* m_simd16CnsMap; - Simd16ToValueNumMap* GetSimd16CnsMap() + Simd16ToValueNumMap* m_simd16CnsMap; + Simd16ToValueNumMap* GetSimd16CnsMap() { if (m_simd16CnsMap == nullptr) { @@ -1701,8 +1691,8 @@ class ValueNumStore }; typedef VNMap Simd32ToValueNumMap; - Simd32ToValueNumMap* m_simd32CnsMap; - Simd32ToValueNumMap* GetSimd32CnsMap() + Simd32ToValueNumMap* m_simd32CnsMap; + Simd32ToValueNumMap* GetSimd32CnsMap() { if (m_simd32CnsMap == nullptr) { @@ -1744,8 +1734,8 @@ class ValueNumStore }; typedef VNMap Simd64ToValueNumMap; - Simd64ToValueNumMap* m_simd64CnsMap; - Simd64ToValueNumMap* GetSimd64CnsMap() + Simd64ToValueNumMap* m_simd64CnsMap; + Simd64ToValueNumMap* GetSimd64CnsMap() { if (m_simd64CnsMap == nullptr) { @@ -1773,8 +1763,8 @@ class ValueNumStore }; typedef VNMap SimdMaskToValueNumMap; - SimdMaskToValueNumMap* m_simdMaskCnsMap; - SimdMaskToValueNumMap* GetSimdMaskCnsMap() + SimdMaskToValueNumMap* m_simdMaskCnsMap; + SimdMaskToValueNumMap* GetSimdMaskCnsMap() { if (m_simdMaskCnsMap == nullptr) { @@ -1813,8 +1803,8 @@ class ValueNumStore } typedef VNMap, VNDefFuncAppKeyFuncs<1>> VNFunc1ToValueNumMap; - VNFunc1ToValueNumMap* m_VNFunc1Map; - VNFunc1ToValueNumMap* GetVNFunc1Map() + VNFunc1ToValueNumMap* m_VNFunc1Map; + VNFunc1ToValueNumMap* GetVNFunc1Map() { if (m_VNFunc1Map == nullptr) { @@ -1824,8 +1814,8 @@ class ValueNumStore } typedef VNMap, VNDefFuncAppKeyFuncs<2>> VNFunc2ToValueNumMap; - VNFunc2ToValueNumMap* m_VNFunc2Map; - VNFunc2ToValueNumMap* GetVNFunc2Map() + VNFunc2ToValueNumMap* m_VNFunc2Map; + VNFunc2ToValueNumMap* GetVNFunc2Map() { if (m_VNFunc2Map == nullptr) { @@ -1835,8 +1825,8 @@ class ValueNumStore } typedef VNMap, VNDefFuncAppKeyFuncs<3>> VNFunc3ToValueNumMap; - VNFunc3ToValueNumMap* m_VNFunc3Map; - VNFunc3ToValueNumMap* GetVNFunc3Map() + VNFunc3ToValueNumMap* m_VNFunc3Map; + VNFunc3ToValueNumMap* GetVNFunc3Map() { if (m_VNFunc3Map == nullptr) { @@ -1846,8 +1836,8 @@ class ValueNumStore } typedef VNMap, VNDefFuncAppKeyFuncs<4>> VNFunc4ToValueNumMap; - VNFunc4ToValueNumMap* m_VNFunc4Map; - VNFunc4ToValueNumMap* GetVNFunc4Map() + VNFunc4ToValueNumMap* m_VNFunc4Map; + VNFunc4ToValueNumMap* GetVNFunc4Map() { if (m_VNFunc4Map == nullptr) { @@ -1858,7 +1848,8 @@ class ValueNumStore class MapSelectWorkCacheEntry { - union { + union + { ValueNum* m_memoryDependencies; ValueNum m_inlineMemoryDependencies[sizeof(ValueNum*) / sizeof(ValueNum)]; }; diff --git a/src/coreclr/jit/valuenumtype.h b/src/coreclr/jit/valuenumtype.h index 2eb3254e3e18b5..1b36d19fb9ca54 100644 --- a/src/coreclr/jit/valuenumtype.h +++ b/src/coreclr/jit/valuenumtype.h @@ -115,9 +115,7 @@ struct ValueNumPair // Initializes both elements to "NoVN". Defined in ValueNum.cpp. ValueNumPair(); - ValueNumPair(ValueNum lib, ValueNum cons) : m_liberal(lib), m_conservative(cons) - { - } + ValueNumPair(ValueNum lib, ValueNum cons) : m_liberal(lib), m_conservative(cons) {} // True iff neither element is "NoVN". Defined in ValueNum.cpp. bool BothDefined() const; diff --git a/src/coreclr/jit/varset.h b/src/coreclr/jit/varset.h index 465ab146cbaca3..b9e4cab1a0c458 100644 --- a/src/coreclr/jit/varset.h +++ b/src/coreclr/jit/varset.h @@ -108,7 +108,7 @@ typedef BitSetOpsWithCounter VarSetOps; #else -typedef VarSetOpsRaw VarSetOps; +typedef VarSetOpsRaw VarSetOps; #endif #define ALLVARSET_REP BSShortLong diff --git a/src/coreclr/jit/vartype.h b/src/coreclr/jit/vartype.h index 1623addb69b079..642ab159360350 100644 --- a/src/coreclr/jit/vartype.h +++ b/src/coreclr/jit/vartype.h @@ -225,7 +225,7 @@ inline bool varTypeIsIntOrI(T vt) #ifdef TARGET_64BIT || (TypeGet(vt) == TYP_I_IMPL) #endif // TARGET_64BIT - ); + ); } template @@ -321,11 +321,11 @@ inline bool varTypeUsesFloatReg(T vt) template inline bool varTypeUsesMaskReg(T vt) { -// The technically correct check is: -// return varTypeRegister[TypeGet(vt)] == VTR_MASK; -// -// However, we only have one type that uses VTR_MASK today -// and so its quite a bit cheaper to just check that directly + // The technically correct check is: + // return varTypeRegister[TypeGet(vt)] == VTR_MASK; + // + // However, we only have one type that uses VTR_MASK today + // and so its quite a bit cheaper to just check that directly #if defined(FEATURE_SIMD) && (defined(TARGET_XARCH) || defined(TARGET_ARM64)) assert((TypeGet(vt) == TYP_MASK) || (varTypeRegister[TypeGet(vt)] != VTR_MASK)); From ebcb17402c00eabcfa2389313a79f636418bd4b4 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Sat, 6 Apr 2024 07:57:59 -0700 Subject: [PATCH 13/47] fix merge conflicts --- src/coreclr/jit/hwintrinsic.cpp | 48 +++++++++---------- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 12 ++--- .../GenerateHWIntrinsicTests_Arm.cs | 15 +++--- 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index 7d4dbf6cb07471..2959b4d24d8b93 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1407,10 +1407,10 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, break; case 3: - assert(addRangeCheckIfNeeded(intrinsic, op3, mustExpand, immLowerBound, immUpperBound) == op3); op3 = getArgForHWIntrinsic(sigReader.GetOp3Type(), sigReader.op3ClsHnd); op2 = getArgForHWIntrinsic(sigReader.GetOp2Type(), sigReader.op2ClsHnd); op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); + assert(addRangeCheckIfNeeded(intrinsic, op3, mustExpand, immLowerBound, immUpperBound) == op3); break; case 2: @@ -1427,29 +1427,29 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, break; } -//#if defined(TARGET_ARM64) -// // Embedded masks need inserting as op1. -// if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsic)) -// { -// numArgs++; -// assert(numArgs <= 4); -// switch (numArgs) -// { -// case 4: -// op4 = op3; -// FALLTHROUGH; -// case 3: -// op3 = op2; -// FALLTHROUGH; -// case 2: -// op2 = op1; -// FALLTHROUGH; -// default: -// break; -// } -// op1 = gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); -// } -//#endif +#if defined(TARGET_ARM64) + // Embedded masks need inserting as op1. + if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsic)) + { + numArgs++; + assert(numArgs <= 4); + switch (numArgs) + { + case 4: + op4 = op3; + FALLTHROUGH; + case 3: + op3 = op2; + FALLTHROUGH; + case 2: + op2 = op1; + FALLTHROUGH; + default: + break; + } + op1 = gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); + } +#endif switch (numArgs) { diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 390162332d4bfc..7bd9105a67929c 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -462,7 +462,6 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) assert(!hasImmediateOperand); switch (intrin.numOperands) - { { case 1: GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op1Reg, opt); @@ -479,15 +478,14 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) else { GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, opt); - } - } - else - { - GetEmitter()->emitIns_R_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, op3Reg, opt, - INS_SCALABLE_OPTS_UNPREDICATED); } break; + case 3: + GetEmitter()->emitIns_R_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, op3Reg, opt, + INS_SCALABLE_OPTS_UNPREDICATED); + break; + default: unreached(); } diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index fdd17cce33c460..1f50f6dee2fea2 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -2899,6 +2899,14 @@ ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(sbyte)TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(byte)TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), @@ -2909,13 +2917,6 @@ ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(byte)TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), From 28aa7b7eb1c586be96a6503a57e1dfcac11ebcde Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Sun, 7 Apr 2024 01:00:56 -0700 Subject: [PATCH 14/47] Make predicated/unpredicated work with ConditionalSelect Still some handling around RMW is needed, but this basically works --- src/coreclr/jit/codegenlinear.cpp | 4 +- src/coreclr/jit/gentree.cpp | 4 + src/coreclr/jit/gentree.h | 8 +- src/coreclr/jit/hwintrinsic.cpp | 66 ++++++------ src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 112 +++++++++++++------- src/coreclr/jit/hwintrinsiclistarm64sve.h | 2 +- src/coreclr/jit/lowerarmarch.cpp | 55 +++++++++- src/coreclr/jit/lowerxarch.cpp | 2 +- src/coreclr/jit/lsrabuild.cpp | 12 ++- 9 files changed, 184 insertions(+), 81 deletions(-) diff --git a/src/coreclr/jit/codegenlinear.cpp b/src/coreclr/jit/codegenlinear.cpp index 3176808d02c7ae..5f148d415c45c0 100644 --- a/src/coreclr/jit/codegenlinear.cpp +++ b/src/coreclr/jit/codegenlinear.cpp @@ -1653,7 +1653,7 @@ void CodeGen::genConsumeRegs(GenTree* tree) // Update the life of the lcl var. genUpdateLife(tree); } -#ifdef TARGET_XARCH +//#ifdef TARGET_XARCH #ifdef FEATURE_HW_INTRINSICS else if (tree->OperIs(GT_HWINTRINSIC)) { @@ -1661,7 +1661,7 @@ void CodeGen::genConsumeRegs(GenTree* tree) genConsumeMultiOpOperands(hwintrinsic); } #endif // FEATURE_HW_INTRINSICS -#endif // TARGET_XARCH +//#endif // TARGET_XARCH else if (tree->OperIs(GT_BITCAST, GT_NEG, GT_CAST, GT_LSH, GT_RSH, GT_RSZ, GT_BSWAP, GT_BSWAP16)) { genConsumeRegs(tree->gtGetOp1()); diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 88aff2c08a1efc..3c45167c16be36 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -17967,7 +17967,11 @@ bool GenTree::canBeContained() const } else if (OperIsHWIntrinsic() && !isContainableHWIntrinsic()) { +#ifdef TARGET_XARCH return isEvexEmbeddedMaskingCompatibleHWIntrinsic(); +#elif TARGET_ARM64 + return HWIntrinsicInfo::IsEmbeddedMaskedOperation(AsHWIntrinsic()->GetHWIntrinsicId()); +#endif } return true; diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 0fc2a67d0ee7bb..e70986f18c4b0f 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -547,9 +547,9 @@ enum GenTreeFlags : unsigned int GTF_MDARRLOWERBOUND_NONFAULTING = 0x20000000, // GT_MDARR_LOWER_BOUND -- An MD array lower bound operation that cannot fault. Same as GT_IND_NONFAULTING. -#if defined(TARGET_XARCH) && defined(FEATURE_HW_INTRINSICS) +#ifdef FEATURE_HW_INTRINSICS GTF_HW_EM_OP = 0x10000000, // GT_HWINTRINSIC -- node is used as an operand to an embedded mask -#endif // TARGET_XARCH && FEATURE_HW_INTRINSICS +#endif // FEATURE_HW_INTRINSICS }; inline constexpr GenTreeFlags operator ~(GenTreeFlags a) @@ -2220,7 +2220,7 @@ struct GenTree gtFlags &= ~GTF_ICON_HDL_MASK; } -#if defined(TARGET_XARCH) && defined(FEATURE_HW_INTRINSICS) +#ifdef FEATURE_HW_INTRINSICS bool IsEmbMaskOp() { @@ -2234,7 +2234,7 @@ struct GenTree gtFlags |= GTF_HW_EM_OP; } -#endif // TARGET_XARCH && FEATURE_HW_INTRINSICS +#endif // FEATURE_HW_INTRINSICS static bool HandleKindDataIsInvariant(GenTreeFlags flags); diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index 2959b4d24d8b93..01eab8457cddd5 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1427,29 +1427,29 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, break; } -#if defined(TARGET_ARM64) - // Embedded masks need inserting as op1. - if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsic)) - { - numArgs++; - assert(numArgs <= 4); - switch (numArgs) - { - case 4: - op4 = op3; - FALLTHROUGH; - case 3: - op3 = op2; - FALLTHROUGH; - case 2: - op2 = op1; - FALLTHROUGH; - default: - break; - } - op1 = gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); - } -#endif +//#if defined(TARGET_ARM64) +// // Embedded masks need inserting as op1. +// if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsic)) +// { +// numArgs++; +// assert(numArgs <= 4); +// switch (numArgs) +// { +// case 4: +// op4 = op3; +// FALLTHROUGH; +// case 3: +// op3 = op2; +// FALLTHROUGH; +// case 2: +// op2 = op1; +// FALLTHROUGH; +// default: +// break; +// } +// op1 = gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); +// } +//#endif switch (numArgs) { @@ -1630,16 +1630,16 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, } #if defined(TARGET_ARM64) - if (HWIntrinsicInfo::IsMaskedOperation(intrinsic)) - { - assert(numArgs > 0); - GenTree* op1 = retNode->AsHWIntrinsic()->Op(1); - if (!varTypeIsMask(op1)) - { - // Op1 input is a vector. HWInstrinsic requires a mask. - retNode->AsHWIntrinsic()->Op(1) = gtNewSimdConvertVectorToMaskNode(retType, op1, simdBaseJitType, simdSize); - } - } + //if (HWIntrinsicInfo::IsMaskedOperation(intrinsic)) + //{ + // assert(numArgs > 0); + // GenTree* op1 = retNode->AsHWIntrinsic()->Op(1); + // if (!varTypeIsMask(op1)) + // { + // // Op1 input is a vector. HWInstrinsic requires a mask. + // retNode->AsHWIntrinsic()->Op(1) = gtNewSimdConvertVectorToMaskNode(retType, op1, simdBaseJitType, simdSize); + // } + //} if (retType != nodeRetType) { diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 7bd9105a67929c..91c5e821322157 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -399,45 +399,23 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) unreached(); } } - else if (isRMW) + else if (intrin.numOperands >= 2 && intrin.op2->IsEmbMaskOp()) { - assert(!hasImmediateOperand); - assert(!HWIntrinsicInfo::SupportsContainment(intrin.id)); + // Handle case where op2 is operation that needs embedded mask + GenTree* op2 = intrin.op2; + const HWIntrinsic intrinOp2(op2->AsHWIntrinsic()); + instruction insOp2 = HWIntrinsicInfo::lookupIns(intrinOp2.id, intrinOp2.baseType); - // Move the RMW register out of the way and do not pass it to the emit. + assert(intrin.id == NI_Sve_ConditionalSelect); + assert(op2->isContained()); + assert(op2->OperIsHWIntrinsic()); - if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrin.id)) - { + //if (isRMW) + //{ // op1Reg contains a mask, op2Reg contains the RMW register. - if (targetReg != op2Reg) - { - assert(targetReg != op3Reg); - GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op2Reg, /* canSkip */ true); - } - - switch (intrin.numOperands) - { - case 2: - GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op1Reg, opt); - break; - - case 3: - assert(targetReg != op3Reg); - GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op3Reg, opt); - break; - - default: - unreached(); - } - } - else - { - // op1Reg contains the RMW register. - if (targetReg != op1Reg) { - assert(targetReg != op2Reg); assert(targetReg != op3Reg); GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); } @@ -445,17 +423,42 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) switch (intrin.numOperands) { case 2: - GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op2Reg, opt); + GetEmitter()->emitIns_R_R(insOp2, emitSize, targetReg, op1Reg, opt); break; case 3: - GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); + assert(targetReg != op3Reg); + GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, op1Reg, op3Reg, opt); break; default: unreached(); } - } + //} + //else + //{ + //// op1Reg contains the RMW register. + //if (targetReg != op1Reg) + //{ + // assert(targetReg != op2Reg); + // assert(targetReg != op3Reg); + // GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); + //} + + //switch (intrin.numOperands) + //{ + // case 2: + // GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op2Reg, opt); + // break; + + // case 3: + // GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); + // break; + + // default: + // unreached(); + //} + //} } else { @@ -475,6 +478,25 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) { GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op1Reg, opt); } + else if (HWIntrinsicInfo::IsScalable(intrin.id)) + { + assert(!node->IsEmbMaskOp()); + // This generates unpredicated version + // Predicated should be taken care above `intrin.op2->IsEmbMaskOp()` + GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, opt, + INS_SCALABLE_OPTS_UNPREDICATED); + } + else if (isRMW) + { + if (targetReg != op1Reg) + { + assert(targetReg != op2Reg); + + GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, + /* canSkip */ true); + } + GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op2Reg, opt); + } else { GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, opt); @@ -482,10 +504,24 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) break; case 3: - GetEmitter()->emitIns_R_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, op3Reg, opt, - INS_SCALABLE_OPTS_UNPREDICATED); - break; + if (isRMW) + { + if (targetReg != op1Reg) + { + assert(targetReg != op2Reg); + assert(targetReg != op3Reg); + GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, + /* canSkip */ true); + } + GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); + } + else + { + GetEmitter()->emitIns_R_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, op3Reg, opt, + INS_SCALABLE_OPTS_UNPREDICATED); + } + break; default: unreached(); } diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index dfdfe1338b775e..f5f304b546a109 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -43,7 +43,7 @@ HARDWARE_INTRINSIC(Sve, LoadVector, // Special intrinsics that are generated during importing or lowering 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, ConditionalSelect, -1, 3, true, {INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_MaskedOperation) +HARDWARE_INTRINSIC(Sve, ConditionalSelect, -1, 3, true, {INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_MaskedOperation|HW_Flag_SupportsContainment) 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_MaskedOperation) 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) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 78c17d0741ffec..5ea4c63a42bd04 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1209,8 +1209,35 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) case NI_Sve_Abs: { - GenTree* op1 = node->Op(1); + assert(HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsicId)); + CorInfoType simdBaseJitType = node->GetSimdBaseJitType(); + var_types simdBaseType = node->GetSimdBaseType(); + unsigned simdSize = node->GetSimdSize(); + var_types simdType = Compiler::getSIMDTypeForSize(simdSize); + + GenTree* trueMaskAllNode = comp->gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); + GenTree* trueVal = node; + GenTree* falseVal = comp->gtNewZeroConNode(simdType); + + GenTreeHWIntrinsic* condSelNode = + comp->gtNewSimdHWIntrinsicNode(simdType, trueMaskAllNode, trueVal, falseVal, NI_Sve_ConditionalSelect, + simdBaseJitType, simdSize); + BlockRange().InsertBefore(node, trueMaskAllNode); + BlockRange().InsertBefore(node, falseVal); + + LIR::Use use; + if (BlockRange().TryGetUse(node, &use)) + { + BlockRange().InsertAfter(node, condSelNode); + use.ReplaceWith(condSelNode); + } + else + { + condSelNode->SetUnusedValue(); + } + //MakeSrcContained(condSelNode, node); + //node = condSelNode; break; } @@ -3213,6 +3240,32 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) } break; + case NI_Sve_ConditionalSelect: + { + assert(intrin.numOperands == 3); + GenTree* op1 = intrin.op1; + GenTree* op2 = intrin.op2; + if (op2->OperIsHWIntrinsic()) + { + uint32_t maskSize = genTypeSize(node->GetSimdBaseType()); + uint32_t operSize = genTypeSize(op2->AsHWIntrinsic()->GetSimdBaseType()); + + if ((maskSize == operSize) && IsInvariantInRange(op2, node)) + { + MakeSrcContained(node, op2); + op2->MakeEmbMaskOp(); + + if (op1->IsVectorZero()) + { + // When we are merging with zero, we can specialize + // and avoid instantiating the vector constant. + MakeSrcContained(node, op1); + } + } + } + break; + } + default: unreached(); } diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 813cb77217339d..e8b3a5c638e83e 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -2655,7 +2655,7 @@ GenTree* Lowering::LowerHWIntrinsicCndSel(GenTreeHWIntrinsic* node) } //---------------------------------------------------------------------------------------------- -// Lowering::LowerHWIntrinsicCndSel: Lowers an AVX512 TernaryLogic call +// Lowering::LowerHWIntrinsicTernaryLogic: Lowers an AVX512 TernaryLogic call // // Arguments: // node - The hardware intrinsic node. diff --git a/src/coreclr/jit/lsrabuild.cpp b/src/coreclr/jit/lsrabuild.cpp index 511f0d48bb3ae1..2cb8263410ef1c 100644 --- a/src/coreclr/jit/lsrabuild.cpp +++ b/src/coreclr/jit/lsrabuild.cpp @@ -3387,7 +3387,17 @@ int LinearScan::BuildOperandUses(GenTree* node, regMaskTP candidates) if (numArgs != 1) { - assert(numArgs == 2); +#ifdef TARGET_ARM64 + if (HWIntrinsicInfo::IsScalable(hwintrinsic->GetHWIntrinsicId())) + { + for (int argNum = 1; argNum <= numArgs; argNum++) + { + BuildOperandUses(hwintrinsic->Op(argNum), candidates); + } + return (int)numArgs; + } +#endif + assert(numArgs == 2); assert(hwintrinsic->Op(2)->isContained()); assert(hwintrinsic->Op(2)->IsCnsIntOrI()); } From 1c7b4b28ff85a8411038fb4e528290b3d14ea787 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Sun, 7 Apr 2024 02:20:05 -0700 Subject: [PATCH 15/47] Misc. changes --- src/coreclr/jit/codegenlinear.cpp | 2 -- src/coreclr/jit/hwintrinsic.cpp | 35 ------------------------------- src/coreclr/jit/lowerarmarch.cpp | 2 -- 3 files changed, 39 deletions(-) diff --git a/src/coreclr/jit/codegenlinear.cpp b/src/coreclr/jit/codegenlinear.cpp index 5f148d415c45c0..ed5f377ece6c7f 100644 --- a/src/coreclr/jit/codegenlinear.cpp +++ b/src/coreclr/jit/codegenlinear.cpp @@ -1653,7 +1653,6 @@ void CodeGen::genConsumeRegs(GenTree* tree) // Update the life of the lcl var. genUpdateLife(tree); } -//#ifdef TARGET_XARCH #ifdef FEATURE_HW_INTRINSICS else if (tree->OperIs(GT_HWINTRINSIC)) { @@ -1661,7 +1660,6 @@ void CodeGen::genConsumeRegs(GenTree* tree) genConsumeMultiOpOperands(hwintrinsic); } #endif // FEATURE_HW_INTRINSICS -//#endif // TARGET_XARCH else if (tree->OperIs(GT_BITCAST, GT_NEG, GT_CAST, GT_LSH, GT_RSH, GT_RSZ, GT_BSWAP, GT_BSWAP16)) { genConsumeRegs(tree->gtGetOp1()); diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index 01eab8457cddd5..f0c35d0d056ac8 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1427,30 +1427,6 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, break; } -//#if defined(TARGET_ARM64) -// // Embedded masks need inserting as op1. -// if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsic)) -// { -// numArgs++; -// assert(numArgs <= 4); -// switch (numArgs) -// { -// case 4: -// op4 = op3; -// FALLTHROUGH; -// case 3: -// op3 = op2; -// FALLTHROUGH; -// case 2: -// op2 = op1; -// FALLTHROUGH; -// default: -// break; -// } -// op1 = gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); -// } -//#endif - switch (numArgs) { case 0: @@ -1630,17 +1606,6 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, } #if defined(TARGET_ARM64) - //if (HWIntrinsicInfo::IsMaskedOperation(intrinsic)) - //{ - // assert(numArgs > 0); - // GenTree* op1 = retNode->AsHWIntrinsic()->Op(1); - // if (!varTypeIsMask(op1)) - // { - // // Op1 input is a vector. HWInstrinsic requires a mask. - // retNode->AsHWIntrinsic()->Op(1) = gtNewSimdConvertVectorToMaskNode(retType, op1, simdBaseJitType, simdSize); - // } - //} - if (retType != nodeRetType) { // HWInstrinsic returns a mask, but all returns must be vectors, so convert mask to vector. diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 5ea4c63a42bd04..3a991e5e609f14 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1236,8 +1236,6 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) { condSelNode->SetUnusedValue(); } - //MakeSrcContained(condSelNode, node); - //node = condSelNode; break; } From 6adf6c68a55b15f57e9f549b3c97a101f019d43c Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Sun, 7 Apr 2024 02:21:01 -0700 Subject: [PATCH 16/47] jit format --- src/coreclr/jit/codegenlinear.cpp | 5 +- src/coreclr/jit/hwintrinsicarm64.cpp | 3 +- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 84 ++++++++++----------- src/coreclr/jit/lowerarmarch.cpp | 12 +-- src/coreclr/jit/lsrabuild.cpp | 2 +- 5 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/coreclr/jit/codegenlinear.cpp b/src/coreclr/jit/codegenlinear.cpp index ed5f377ece6c7f..c6f8dbe9b56822 100644 --- a/src/coreclr/jit/codegenlinear.cpp +++ b/src/coreclr/jit/codegenlinear.cpp @@ -156,8 +156,9 @@ void CodeGen::genCodeForBBlist() genMarkLabelsForCodegen(); - assert(!compiler->fgFirstBBScratch || compiler->fgFirstBB == compiler->fgFirstBBScratch); // compiler->fgFirstBBScratch - // has to be first. + assert(!compiler->fgFirstBBScratch || + compiler->fgFirstBB == compiler->fgFirstBBScratch); // compiler->fgFirstBBScratch + // has to be first. /* Initialize structures used in the block list iteration */ genInitialize(); diff --git a/src/coreclr/jit/hwintrinsicarm64.cpp b/src/coreclr/jit/hwintrinsicarm64.cpp index 33e8e0826e9c91..43bbd2ffe25253 100644 --- a/src/coreclr/jit/hwintrinsicarm64.cpp +++ b/src/coreclr/jit/hwintrinsicarm64.cpp @@ -2223,8 +2223,7 @@ GenTree* Compiler::gtNewSimdConvertVectorToMaskNode(var_types type, // ConvertVectorToMask uses cmpne which requires an embedded mask. GenTree* trueMask = gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); - return gtNewSimdHWIntrinsicNode(TYP_MASK, trueMask, node, NI_Sve_ConvertVectorToMask, simdBaseJitType, - simdSize); + return gtNewSimdHWIntrinsicNode(TYP_MASK, trueMask, node, NI_Sve_ConvertVectorToMask, simdBaseJitType, simdSize); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 91c5e821322157..aaee0202755312 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -402,7 +402,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) else if (intrin.numOperands >= 2 && intrin.op2->IsEmbMaskOp()) { // Handle case where op2 is operation that needs embedded mask - GenTree* op2 = intrin.op2; + GenTree* op2 = intrin.op2; const HWIntrinsic intrinOp2(op2->AsHWIntrinsic()); instruction insOp2 = HWIntrinsicInfo::lookupIns(intrinOp2.id, intrinOp2.baseType); @@ -410,54 +410,54 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) assert(op2->isContained()); assert(op2->OperIsHWIntrinsic()); - //if (isRMW) + // if (isRMW) //{ - // op1Reg contains a mask, op2Reg contains the RMW register. + // op1Reg contains a mask, op2Reg contains the RMW register. - if (targetReg != op1Reg) - { - assert(targetReg != op3Reg); - GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); - } + if (targetReg != op1Reg) + { + assert(targetReg != op3Reg); + GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); + } - switch (intrin.numOperands) - { - case 2: - GetEmitter()->emitIns_R_R(insOp2, emitSize, targetReg, op1Reg, opt); - break; + switch (intrin.numOperands) + { + case 2: + GetEmitter()->emitIns_R_R(insOp2, emitSize, targetReg, op1Reg, opt); + break; - case 3: - assert(targetReg != op3Reg); - GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, op1Reg, op3Reg, opt); - break; + case 3: + assert(targetReg != op3Reg); + GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, op1Reg, op3Reg, opt); + break; - default: - unreached(); - } + default: + unreached(); + } //} - //else + // else + //{ + //// op1Reg contains the RMW register. + // if (targetReg != op1Reg) + //{ + // assert(targetReg != op2Reg); + // assert(targetReg != op3Reg); + // GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); + // } + + // switch (intrin.numOperands) //{ - //// op1Reg contains the RMW register. - //if (targetReg != op1Reg) - //{ - // assert(targetReg != op2Reg); - // assert(targetReg != op3Reg); - // GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); - //} - - //switch (intrin.numOperands) - //{ - // case 2: - // GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op2Reg, opt); - // break; - - // case 3: - // GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); - // break; - - // default: - // unreached(); - //} + // case 2: + // GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op2Reg, opt); + // break; + + // case 3: + // GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); + // break; + + // default: + // unreached(); + //} //} } else diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 3a991e5e609f14..b066a4f4c23b7e 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1210,10 +1210,10 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) case NI_Sve_Abs: { assert(HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsicId)); - CorInfoType simdBaseJitType = node->GetSimdBaseJitType(); - var_types simdBaseType = node->GetSimdBaseType(); - unsigned simdSize = node->GetSimdSize(); - var_types simdType = Compiler::getSIMDTypeForSize(simdSize); + CorInfoType simdBaseJitType = node->GetSimdBaseJitType(); + var_types simdBaseType = node->GetSimdBaseType(); + unsigned simdSize = node->GetSimdSize(); + var_types simdType = Compiler::getSIMDTypeForSize(simdSize); GenTree* trueMaskAllNode = comp->gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); GenTree* trueVal = node; @@ -3241,8 +3241,8 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) case NI_Sve_ConditionalSelect: { assert(intrin.numOperands == 3); - GenTree* op1 = intrin.op1; - GenTree* op2 = intrin.op2; + GenTree* op1 = intrin.op1; + GenTree* op2 = intrin.op2; if (op2->OperIsHWIntrinsic()) { uint32_t maskSize = genTypeSize(node->GetSimdBaseType()); diff --git a/src/coreclr/jit/lsrabuild.cpp b/src/coreclr/jit/lsrabuild.cpp index 2cb8263410ef1c..af5de253de8913 100644 --- a/src/coreclr/jit/lsrabuild.cpp +++ b/src/coreclr/jit/lsrabuild.cpp @@ -3397,7 +3397,7 @@ int LinearScan::BuildOperandUses(GenTree* node, regMaskTP candidates) return (int)numArgs; } #endif - assert(numArgs == 2); + assert(numArgs == 2); assert(hwintrinsic->Op(2)->isContained()); assert(hwintrinsic->Op(2)->IsCnsIntOrI()); } From ecf4e013317e71f1b949a91df66ce739d34fb7fd Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Sun, 7 Apr 2024 02:22:49 -0700 Subject: [PATCH 17/47] jit format --- src/coreclr/jit/.clang-format | 119 ++-- src/coreclr/jit/_typeinfo.h | 22 +- src/coreclr/jit/abi.h | 11 +- src/coreclr/jit/alloc.cpp | 5 +- src/coreclr/jit/alloc.h | 9 +- src/coreclr/jit/arraystack.h | 3 +- src/coreclr/jit/assertionprop.cpp | 4 +- src/coreclr/jit/bitset.h | 15 +- src/coreclr/jit/bitsetasshortlong.h | 4 +- src/coreclr/jit/bitsetasuint64.h | 6 +- src/coreclr/jit/bitsetasuint64inclass.h | 11 +- src/coreclr/jit/block.cpp | 59 +- src/coreclr/jit/block.h | 160 ++++-- src/coreclr/jit/blockset.h | 9 +- src/coreclr/jit/buildstring.cpp | 4 +- src/coreclr/jit/codegen.h | 56 +- src/coreclr/jit/codegenarmarch.cpp | 27 +- src/coreclr/jit/codegencommon.cpp | 14 +- src/coreclr/jit/codegeninterface.h | 7 +- src/coreclr/jit/codegenlinear.cpp | 3 +- src/coreclr/jit/codegenxarch.cpp | 12 +- src/coreclr/jit/compiler.cpp | 90 +-- src/coreclr/jit/compiler.h | 111 ++-- src/coreclr/jit/compiler.hpp | 62 +- src/coreclr/jit/compilerbitsettraits.h | 4 +- src/coreclr/jit/copyprop.cpp | 10 +- src/coreclr/jit/dataflow.h | 10 +- src/coreclr/jit/debuginfo.h | 28 +- src/coreclr/jit/decomposelongs.h | 5 +- src/coreclr/jit/disasm.cpp | 3 +- src/coreclr/jit/ee_il_dll.cpp | 16 +- src/coreclr/jit/eeinterface.cpp | 118 ++-- src/coreclr/jit/emit.cpp | 27 +- src/coreclr/jit/emit.h | 246 ++++---- src/coreclr/jit/emitarm.cpp | 4 +- src/coreclr/jit/emitarm64.cpp | 4 +- src/coreclr/jit/emitarm64.h | 12 +- src/coreclr/jit/emitriscv64.cpp | 3 +- src/coreclr/jit/emitxarch.cpp | 198 ++++--- src/coreclr/jit/emitxarch.h | 8 +- src/coreclr/jit/error.cpp | 6 +- src/coreclr/jit/fgbasic.cpp | 5 +- src/coreclr/jit/fgdiagnostic.cpp | 121 ++-- src/coreclr/jit/fgehopt.cpp | 12 +- src/coreclr/jit/fginline.cpp | 132 ++--- src/coreclr/jit/fgopt.cpp | 59 +- src/coreclr/jit/fgprofile.cpp | 79 ++- src/coreclr/jit/fgprofilesynthesis.cpp | 92 ++- src/coreclr/jit/fgprofilesynthesis.h | 5 +- src/coreclr/jit/flowgraph.cpp | 308 +++++----- src/coreclr/jit/forwardsub.cpp | 10 +- src/coreclr/jit/gcencode.cpp | 12 +- src/coreclr/jit/gcinfo.cpp | 3 +- src/coreclr/jit/gentree.cpp | 139 +++-- src/coreclr/jit/gentree.h | 600 +++++++++++++++----- src/coreclr/jit/gschecks.cpp | 5 +- src/coreclr/jit/hashbv.cpp | 104 ++-- src/coreclr/jit/hashbv.h | 12 +- src/coreclr/jit/hostallocator.h | 4 +- src/coreclr/jit/hwintrinsic.h | 13 +- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 8 +- src/coreclr/jit/hwintrinsiccodegenxarch.cpp | 33 +- src/coreclr/jit/importer.cpp | 3 +- src/coreclr/jit/importercalls.cpp | 274 ++++----- src/coreclr/jit/importervectorization.cpp | 2 +- src/coreclr/jit/indirectcalltransformer.cpp | 20 +- src/coreclr/jit/inductionvariableopts.cpp | 203 ++++--- src/coreclr/jit/inline.h | 46 +- src/coreclr/jit/inlinepolicy.cpp | 15 +- src/coreclr/jit/inlinepolicy.h | 37 +- src/coreclr/jit/jit.h | 72 +-- src/coreclr/jit/jitconfig.cpp | 27 +- src/coreclr/jit/jitconfig.h | 12 +- src/coreclr/jit/jitconfigvalues.h | 6 +- src/coreclr/jit/jitee.h | 6 +- src/coreclr/jit/jitexpandarray.h | 11 +- src/coreclr/jit/jitgcinfo.h | 22 +- src/coreclr/jit/jithashtable.h | 56 +- src/coreclr/jit/layout.cpp | 7 +- src/coreclr/jit/lclmorph.cpp | 6 +- src/coreclr/jit/lclvars.cpp | 17 +- src/coreclr/jit/likelyclass.cpp | 9 +- src/coreclr/jit/lir.cpp | 81 ++- src/coreclr/jit/lir.h | 20 +- src/coreclr/jit/liveness.cpp | 72 ++- src/coreclr/jit/loopcloning.cpp | 44 +- src/coreclr/jit/loopcloning.h | 86 ++- src/coreclr/jit/lower.cpp | 32 +- src/coreclr/jit/lower.h | 4 +- src/coreclr/jit/lowerarmarch.cpp | 3 +- src/coreclr/jit/lowerxarch.cpp | 14 +- src/coreclr/jit/lsra.cpp | 2 +- src/coreclr/jit/lsra.h | 118 +++- src/coreclr/jit/lsrabuild.cpp | 31 +- src/coreclr/jit/morph.cpp | 75 +-- src/coreclr/jit/morphblock.cpp | 20 +- src/coreclr/jit/objectalloc.cpp | 6 +- src/coreclr/jit/optcse.cpp | 38 +- src/coreclr/jit/optcse.h | 18 +- src/coreclr/jit/optimizebools.cpp | 3 +- src/coreclr/jit/optimizer.cpp | 152 ++--- src/coreclr/jit/patchpoint.cpp | 6 +- src/coreclr/jit/phase.h | 17 +- src/coreclr/jit/promotion.cpp | 83 +-- src/coreclr/jit/promotion.h | 53 +- src/coreclr/jit/promotiondecomposition.cpp | 4 +- src/coreclr/jit/promotionliveness.cpp | 22 +- src/coreclr/jit/rangecheck.cpp | 11 +- src/coreclr/jit/rangecheck.h | 37 +- src/coreclr/jit/rationalize.cpp | 3 +- src/coreclr/jit/rationalize.h | 5 +- src/coreclr/jit/redundantbranchopts.cpp | 49 +- src/coreclr/jit/regset.cpp | 8 +- src/coreclr/jit/scev.cpp | 18 +- src/coreclr/jit/scev.h | 32 +- src/coreclr/jit/scopeinfo.cpp | 5 +- src/coreclr/jit/sideeffects.cpp | 58 +- src/coreclr/jit/smallhash.h | 34 +- src/coreclr/jit/smcommon.h | 2 +- src/coreclr/jit/ssabuilder.cpp | 413 +++++++------- src/coreclr/jit/ssarenamestate.cpp | 5 +- src/coreclr/jit/ssarenamestate.h | 9 +- src/coreclr/jit/switchrecognition.cpp | 2 +- src/coreclr/jit/target.h | 33 +- src/coreclr/jit/targetamd64.cpp | 6 +- src/coreclr/jit/targetarm.cpp | 5 +- src/coreclr/jit/targetarm64.cpp | 4 +- src/coreclr/jit/targetx86.cpp | 3 +- src/coreclr/jit/typelist.h | 2 +- src/coreclr/jit/unwind.h | 93 ++- src/coreclr/jit/unwindx86.cpp | 32 +- src/coreclr/jit/utils.cpp | 39 +- src/coreclr/jit/utils.h | 34 +- src/coreclr/jit/valuenum.cpp | 72 +-- src/coreclr/jit/valuenum.h | 42 +- src/coreclr/jit/valuenumtype.h | 6 +- 136 files changed, 3726 insertions(+), 2472 deletions(-) diff --git a/src/coreclr/jit/.clang-format b/src/coreclr/jit/.clang-format index 1e3930f7379d13..307b1d7128bdfb 100644 --- a/src/coreclr/jit/.clang-format +++ b/src/coreclr/jit/.clang-format @@ -1,80 +1,131 @@ --- -Language: Cpp +Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: true -AlignConsecutiveDeclarations: true -AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true + +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: true + +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + +AlignEscapedNewlines: Right +AlignOperands: true + +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 + +AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false +AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: Empty -AllowShortIfStatementsOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: false + +BreakBeforeBraces: Custom BraceWrapping: - AfterClass: true - AfterControlStatement: true - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: true - AfterUnion: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true + BreakBeforeBinaryOperators: None -BreakBeforeBraces: Allman BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: true -ColumnLimit: 120 -CommentPragmas: '^ IWYU pragma:' -ConstructorInitializerAllOnOneLineOrOnePerLine: true +BreakConstructorInitializers: BeforeComma +BreakInheritanceList: BeforeComma +BreakStringLiterals: false + +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DerivePointerAlignment: false -DisableFormat: false +DisableFormat: false + +EmptyLineAfterAccessModifier: Leave +EmptyLineBeforeAccessModifier: Leave ExperimentalAutoDetectBinPacking: false -ForEachMacros: [ ] +ForEachMacros: [ ] +IndentAccessModifiers: false +IndentCaseBlocks: false IndentCaseLabels: true -IndentWidth: 4 +IndentExternBlock: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentWidth: 4 IndentWrappedFunctionNames: false + +InsertNewlineAtEOF: true KeepEmptyLinesAtTheStartOfBlocks: true +LambdaBodyIndentation: OuterScope MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: None -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true + PenaltyBreakBeforeFirstCallParameter: 400 PenaltyBreakComment: 50 PenaltyBreakFirstLessLess: 500 PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 100000 + PointerAlignment: Left ReflowComments: true -SortIncludes: false +SortIncludes: Never + SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 -SpacesInAngles: false +SpacesInAngles: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Cpp11 + +Standard: Latest TabWidth: 4 UseTab: Never ... diff --git a/src/coreclr/jit/_typeinfo.h b/src/coreclr/jit/_typeinfo.h index a4848bd3c63a52..9285535b5531c4 100644 --- a/src/coreclr/jit/_typeinfo.h +++ b/src/coreclr/jit/_typeinfo.h @@ -48,13 +48,27 @@ class typeInfo }; public: - typeInfo() : m_type(TYP_UNDEF), m_cls(NO_CLASS_HANDLE) {} + typeInfo() + : m_type(TYP_UNDEF) + , m_cls(NO_CLASS_HANDLE) + { + } - typeInfo(var_types type) : m_type(type), m_cls(NO_CLASS_HANDLE) {} + typeInfo(var_types type) + : m_type(type) + , m_cls(NO_CLASS_HANDLE) + { + } - typeInfo(CORINFO_CLASS_HANDLE cls) : m_type(TYP_REF), m_cls(cls) {} + typeInfo(CORINFO_CLASS_HANDLE cls) + : m_type(TYP_REF) + , m_cls(cls) + { + } - typeInfo(methodPointerInfo* methodPointerInfo) : m_type(TYP_I_IMPL), m_methodPointerInfo(methodPointerInfo) + typeInfo(methodPointerInfo* methodPointerInfo) + : m_type(TYP_I_IMPL) + , m_methodPointerInfo(methodPointerInfo) { assert(methodPointerInfo != nullptr); assert(methodPointerInfo->m_token.hMethod != nullptr); diff --git a/src/coreclr/jit/abi.h b/src/coreclr/jit/abi.h index 88470265c6e576..82ec58b5d807f0 100644 --- a/src/coreclr/jit/abi.h +++ b/src/coreclr/jit/abi.h @@ -63,7 +63,11 @@ class RegisterQueue unsigned int m_index = 0; public: - RegisterQueue(const regNumber* regs, unsigned int numRegs) : m_regs(regs), m_numRegs(numRegs) {} + RegisterQueue(const regNumber* regs, unsigned int numRegs) + : m_regs(regs) + , m_numRegs(numRegs) + { + } unsigned Count() { @@ -185,7 +189,10 @@ class SwiftABIClassifier PlatformClassifier m_classifier; public: - SwiftABIClassifier(const ClassifierInfo& info) : m_classifier(info) {} + SwiftABIClassifier(const ClassifierInfo& info) + : m_classifier(info) + { + } ABIPassingInformation Classify(Compiler* comp, var_types type, diff --git a/src/coreclr/jit/alloc.cpp b/src/coreclr/jit/alloc.cpp index 6300376beeb6d4..7178066ab584c5 100644 --- a/src/coreclr/jit/alloc.cpp +++ b/src/coreclr/jit/alloc.cpp @@ -42,7 +42,10 @@ size_t ArenaAllocator::getDefaultPageSize() // ArenaAllocator::ArenaAllocator: // Default-constructs an arena allocator. ArenaAllocator::ArenaAllocator() - : m_firstPage(nullptr), m_lastPage(nullptr), m_nextFreeByte(nullptr), m_lastFreeByte(nullptr) + : m_firstPage(nullptr) + , m_lastPage(nullptr) + , m_nextFreeByte(nullptr) + , m_lastFreeByte(nullptr) { #if MEASURE_MEM_ALLOC memset(&m_stats, 0, sizeof(m_stats)); diff --git a/src/coreclr/jit/alloc.h b/src/coreclr/jit/alloc.h index 1bb4679ce71afe..8899b87ad35523 100644 --- a/src/coreclr/jit/alloc.h +++ b/src/coreclr/jit/alloc.h @@ -249,7 +249,9 @@ class CompAllocator // Deallocate a block of memory previously allocated by `allocate`. // The arena allocator does not release memory so this doesn't do anything. - void deallocate(void* p) {} + void deallocate(void* p) + { + } }; // Global operator new overloads that work with CompAllocator @@ -274,7 +276,10 @@ class CompIAllocator : public IAllocator char m_zeroLenAllocTarg; public: - CompIAllocator(CompAllocator alloc) : m_alloc(alloc) {} + CompIAllocator(CompAllocator alloc) + : m_alloc(alloc) + { + } // Allocates a block of memory at least `sz` in size. virtual void* Alloc(size_t sz) override diff --git a/src/coreclr/jit/arraystack.h b/src/coreclr/jit/arraystack.h index 83a43c9432ba0e..5d8a697a3820d3 100644 --- a/src/coreclr/jit/arraystack.h +++ b/src/coreclr/jit/arraystack.h @@ -10,7 +10,8 @@ class ArrayStack static const int builtinSize = 8; public: - explicit ArrayStack(CompAllocator alloc, int initialCapacity = builtinSize) : m_alloc(alloc) + explicit ArrayStack(CompAllocator alloc, int initialCapacity = builtinSize) + : m_alloc(alloc) { if (initialCapacity > builtinSize) { diff --git a/src/coreclr/jit/assertionprop.cpp b/src/coreclr/jit/assertionprop.cpp index d8fd2f7b6a6326..e4e73adc58c6c4 100644 --- a/src/coreclr/jit/assertionprop.cpp +++ b/src/coreclr/jit/assertionprop.cpp @@ -6283,7 +6283,9 @@ struct VNAssertionPropVisitorInfo Statement* stmt; BasicBlock* block; VNAssertionPropVisitorInfo(Compiler* pThis, BasicBlock* block, Statement* stmt) - : pThis(pThis), stmt(stmt), block(block) + : pThis(pThis) + , stmt(stmt) + , block(block) { } }; diff --git a/src/coreclr/jit/bitset.h b/src/coreclr/jit/bitset.h index aefa0e380a7d5f..6f1e3d8dcd0db1 100644 --- a/src/coreclr/jit/bitset.h +++ b/src/coreclr/jit/bitset.h @@ -59,7 +59,10 @@ class BitSetSupport FILE* OpOutputFile; public: - BitSetOpCounter(const char* fileName) : TotalOps(0), m_fileName(fileName), OpOutputFile(nullptr) + BitSetOpCounter(const char* fileName) + : TotalOps(0) + , m_fileName(fileName) + , OpOutputFile(nullptr) { for (unsigned i = 0; i < BSOP_NUMOPS; i++) { @@ -435,7 +438,11 @@ class BitSetOpsWithCounter Env m_env; public: - Iter(Env env, BitSetValueArgType bs) : m_iter(env, bs), m_env(env) {} + Iter(Env env, BitSetValueArgType bs) + : m_iter(env, bs) + , m_env(env) + { + } bool NextElem(unsigned* pElem) { @@ -447,8 +454,8 @@ class BitSetOpsWithCounter // We define symbolic names for the various bitset implementations available, to allow choices between them. -#define BSUInt64 0 -#define BSShortLong 1 +#define BSUInt64 0 +#define BSShortLong 1 #define BSUInt64Class 2 /*****************************************************************************/ diff --git a/src/coreclr/jit/bitsetasshortlong.h b/src/coreclr/jit/bitsetasshortlong.h index 7ace234e8a0868..006f66fc178dcb 100644 --- a/src/coreclr/jit/bitsetasshortlong.h +++ b/src/coreclr/jit/bitsetasshortlong.h @@ -500,7 +500,9 @@ class BitSetOps m_bs; public: - BitSetUint64ValueRetType(const BitSetUint64& bs) : m_bs(bs) {} + BitSetUint64ValueRetType(const BitSetUint64& bs) + : m_bs(bs) + { + } }; template @@ -449,7 +452,11 @@ class BitSetOps, unsigned m_bitNum; public: - Iter(Env env, const BitSetUint64& bs) : m_bits(bs.m_bits), m_bitNum(0) {} + Iter(Env env, const BitSetUint64& bs) + : m_bits(bs.m_bits) + , m_bitNum(0) + { + } bool NextElem(unsigned* pElem) { diff --git a/src/coreclr/jit/block.cpp b/src/coreclr/jit/block.cpp index 01031cd8b7f58d..6cde9e0e93d8b1 100644 --- a/src/coreclr/jit/block.cpp +++ b/src/coreclr/jit/block.cpp @@ -140,33 +140,30 @@ void FlowEdge::addLikelihood(weight_t addedLikelihood) // comp - Compiler instance // block - The block whose successors are to be iterated // -AllSuccessorEnumerator::AllSuccessorEnumerator(Compiler* comp, BasicBlock* block) : m_block(block) +AllSuccessorEnumerator::AllSuccessorEnumerator(Compiler* comp, BasicBlock* block) + : m_block(block) { m_numSuccs = 0; - block->VisitAllSuccs(comp, - [this](BasicBlock* succ) - { - if (m_numSuccs < ArrLen(m_successors)) - { - m_successors[m_numSuccs] = succ; - } - - m_numSuccs++; - return BasicBlockVisit::Continue; - }); + block->VisitAllSuccs(comp, [this](BasicBlock* succ) { + if (m_numSuccs < ArrLen(m_successors)) + { + m_successors[m_numSuccs] = succ; + } + + m_numSuccs++; + return BasicBlockVisit::Continue; + }); if (m_numSuccs > ArrLen(m_successors)) { m_pSuccessors = new (comp, CMK_BasicBlock) BasicBlock*[m_numSuccs]; unsigned numSuccs = 0; - block->VisitAllSuccs(comp, - [this, &numSuccs](BasicBlock* succ) - { - assert(numSuccs < m_numSuccs); - m_pSuccessors[numSuccs++] = succ; - return BasicBlockVisit::Continue; - }); + block->VisitAllSuccs(comp, [this, &numSuccs](BasicBlock* succ) { + assert(numSuccs < m_numSuccs); + m_pSuccessors[numSuccs++] = succ; + return BasicBlockVisit::Continue; + }); assert(numSuccs == m_numSuccs); } @@ -235,12 +232,9 @@ FlowEdge* Compiler::BlockPredsWithEH(BasicBlock* blk) { res = new (this, CMK_FlowEdge) FlowEdge(filterBlk, blk, res); - assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, - [blk](BasicBlock* succ) { - return succ == blk - ? BasicBlockVisit::Abort - : BasicBlockVisit::Continue; - }) == BasicBlockVisit::Abort); + assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, [blk](BasicBlock* succ) { + return succ == blk ? BasicBlockVisit::Abort : BasicBlockVisit::Continue; + }) == BasicBlockVisit::Abort); } } @@ -313,12 +307,9 @@ FlowEdge* Compiler::BlockDominancePreds(BasicBlock* blk) { res = new (this, CMK_FlowEdge) FlowEdge(filterBlk, blk, res); - assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, - [blk](BasicBlock* succ) { - return succ == blk - ? BasicBlockVisit::Abort - : BasicBlockVisit::Continue; - }) == BasicBlockVisit::Abort); + assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, [blk](BasicBlock* succ) { + return succ == blk ? BasicBlockVisit::Abort : BasicBlockVisit::Continue; + }) == BasicBlockVisit::Abort); } } @@ -700,8 +691,7 @@ void BasicBlock::dspSuccs(Compiler* compiler) // things strictly. void BasicBlock::dspKind() const { - auto dspBlockNum = [](const FlowEdge* e) -> const char* - { + auto dspBlockNum = [](const FlowEdge* e) -> const char* { static char buffers[3][64]; // static array of 3 to allow 3 concurrent calls in one printf() static int nextBufferIndex = 0; @@ -1902,7 +1892,8 @@ BBswtDesc::BBswtDesc(Compiler* comp, const BBswtDesc* other) // comp - compiler instance // other - existing descriptor to copy // -BBehfDesc::BBehfDesc(Compiler* comp, const BBehfDesc* other) : bbeCount(other->bbeCount) +BBehfDesc::BBehfDesc(Compiler* comp, const BBehfDesc* other) + : bbeCount(other->bbeCount) { // Allocate and fill in a new dst tab // diff --git a/src/coreclr/jit/block.h b/src/coreclr/jit/block.h index 5c0de29449c460..16321157664a50 100644 --- a/src/coreclr/jit/block.h +++ b/src/coreclr/jit/block.h @@ -162,7 +162,10 @@ class MemoryKindIterator int value; public: - explicit inline MemoryKindIterator(int val) : value(val) {} + explicit inline MemoryKindIterator(int val) + : value(val) + { + } inline MemoryKindIterator& operator++() { ++value; @@ -189,7 +192,9 @@ class MemoryKindIterator // Empty struct that allows enumerating memory kinds via `for(MemoryKind kind : allMemoryKinds())` struct allMemoryKinds { - inline allMemoryKinds() {} + inline allMemoryKinds() + { + } inline MemoryKindIterator begin() { return MemoryKindIterator(0); @@ -240,7 +245,10 @@ class PredEdgeList }; public: - PredEdgeList(FlowEdge* pred) : m_begin(pred) {} + PredEdgeList(FlowEdge* pred) + : m_begin(pred) + { + } iterator begin() const { @@ -291,7 +299,10 @@ class PredBlockList }; public: - PredBlockList(FlowEdge* pred) : m_begin(pred) {} + PredBlockList(FlowEdge* pred) + : m_begin(pred) + { + } iterator begin() const { @@ -314,7 +325,10 @@ class BBArrayIterator FlowEdge* const* m_edgeEntry; public: - BBArrayIterator(FlowEdge* const* edgeEntry) : m_edgeEntry(edgeEntry) {} + BBArrayIterator(FlowEdge* const* edgeEntry) + : m_edgeEntry(edgeEntry) + { + } BasicBlock* operator*() const; @@ -341,7 +355,10 @@ class FlowEdgeArrayIterator FlowEdge* const* m_edgeEntry; public: - FlowEdgeArrayIterator(FlowEdge* const* edgeEntry) : m_edgeEntry(edgeEntry) {} + FlowEdgeArrayIterator(FlowEdge* const* edgeEntry) + : m_edgeEntry(edgeEntry) + { + } FlowEdge* operator*() const { @@ -1166,11 +1183,11 @@ struct BasicBlock : private LIR::Range const char* dspToString(int blockNumPadding = 0) const; #endif // DEBUG -#define BB_UNITY_WEIGHT 100.0 // how much a normal execute once block weighs -#define BB_UNITY_WEIGHT_UNSIGNED 100 // how much a normal execute once block weighs -#define BB_LOOP_WEIGHT_SCALE 8.0 // synthetic profile scale factor for loops -#define BB_ZERO_WEIGHT 0.0 -#define BB_MAX_WEIGHT FLT_MAX // maximum finite weight -- needs rethinking. +#define BB_UNITY_WEIGHT 100.0 // how much a normal execute once block weighs +#define BB_UNITY_WEIGHT_UNSIGNED 100 // how much a normal execute once block weighs +#define BB_LOOP_WEIGHT_SCALE 8.0 // synthetic profile scale factor for loops +#define BB_ZERO_WEIGHT 0.0 +#define BB_MAX_WEIGHT FLT_MAX // maximum finite weight -- needs rethinking. weight_t bbWeight; // The dynamic execution weight of this block @@ -1518,11 +1535,11 @@ struct BasicBlock : private LIR::Range bool hasEHBoundaryOut() const; // Some non-zero value that will not collide with real tokens for bbCatchTyp -#define BBCT_NONE 0x00000000 -#define BBCT_FAULT 0xFFFFFFFC -#define BBCT_FINALLY 0xFFFFFFFD -#define BBCT_FILTER 0xFFFFFFFE -#define BBCT_FILTER_HANDLER 0xFFFFFFFF +#define BBCT_NONE 0x00000000 +#define BBCT_FAULT 0xFFFFFFFC +#define BBCT_FINALLY 0xFFFFFFFD +#define BBCT_FILTER 0xFFFFFFFE +#define BBCT_FILTER_HANDLER 0xFFFFFFFF #define handlerGetsXcptnObj(hndTyp) ((hndTyp) != BBCT_NONE && (hndTyp) != BBCT_FAULT && (hndTyp) != BBCT_FINALLY) // TODO-Cleanup: Get rid of bbStkDepth and use bbStackDepthOnEntry() instead @@ -1615,7 +1632,11 @@ struct BasicBlock : private LIR::Range return m_ssaNum; } - MemoryPhiArg(unsigned ssaNum, MemoryPhiArg* nextArg = nullptr) : m_ssaNum(ssaNum), m_nextArg(nextArg) {} + MemoryPhiArg(unsigned ssaNum, MemoryPhiArg* nextArg = nullptr) + : m_ssaNum(ssaNum) + , m_nextArg(nextArg) + { + } void* operator new(size_t sz, class Compiler* comp); }; @@ -1747,7 +1768,12 @@ struct BasicBlock : private LIR::Range Statement* FirstNonPhiDef() const; Statement* FirstNonPhiDefOrCatchArgStore() const; - BasicBlock() : bbStmtList(nullptr), bbLiveIn(VarSetOps::UninitVal()), bbLiveOut(VarSetOps::UninitVal()) {} + BasicBlock() + : bbStmtList(nullptr) + , bbLiveIn(VarSetOps::UninitVal()) + , bbLiveOut(VarSetOps::UninitVal()) + { + } // Iteratable collection of successors of a block. template @@ -1757,7 +1783,11 @@ struct BasicBlock : private LIR::Range BasicBlock* m_block; public: - Successors(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block) {} + Successors(Compiler* comp, BasicBlock* block) + : m_comp(comp) + , m_block(block) + { + } class iterator { @@ -1766,9 +1796,17 @@ struct BasicBlock : private LIR::Range TPosition m_pos; public: - iterator(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block), m_pos(comp, block) {} + iterator(Compiler* comp, BasicBlock* block) + : m_comp(comp) + , m_block(block) + , m_pos(comp, block) + { + } - iterator() : m_pos() {} + iterator() + : m_pos() + { + } void operator++(void) { @@ -1839,7 +1877,10 @@ struct BasicBlock : private LIR::Range class BBSuccList : private SuccList { public: - BBSuccList(const BasicBlock* block) : SuccList(block) {} + BBSuccList(const BasicBlock* block) + : SuccList(block) + { + } BBArrayIterator begin() const { @@ -1859,7 +1900,10 @@ struct BasicBlock : private LIR::Range class BBSuccEdgeList : private SuccList { public: - BBSuccEdgeList(const BasicBlock* block) : SuccList(block) {} + BBSuccEdgeList(const BasicBlock* block) + : SuccList(block) + { + } FlowEdgeArrayIterator begin() const { @@ -1893,7 +1937,9 @@ struct BasicBlock : private LIR::Range public: iterator(Compiler* comp, BasicBlock* block, unsigned succNum) - : m_comp(comp), m_block(block), m_succNum(succNum) + : m_comp(comp) + , m_block(block) + , m_succNum(succNum) { } @@ -1918,7 +1964,11 @@ struct BasicBlock : private LIR::Range }; public: - BBCompilerSuccList(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block) {} + BBCompilerSuccList(Compiler* comp, BasicBlock* block) + : m_comp(comp) + , m_block(block) + { + } iterator begin() const { @@ -1952,7 +2002,9 @@ struct BasicBlock : private LIR::Range public: iterator(Compiler* comp, BasicBlock* block, unsigned succNum) - : m_comp(comp), m_block(block), m_succNum(succNum) + : m_comp(comp) + , m_block(block) + , m_succNum(succNum) { } @@ -1977,7 +2029,11 @@ struct BasicBlock : private LIR::Range }; public: - BBCompilerSuccEdgeList(Compiler* comp, BasicBlock* block) : m_comp(comp), m_block(block) {} + BBCompilerSuccEdgeList(Compiler* comp, BasicBlock* block) + : m_comp(comp) + , m_block(block) + { + } iterator begin() const { @@ -2085,7 +2141,10 @@ class BasicBlockIterator BasicBlock* m_block; public: - BasicBlockIterator(BasicBlock* block) : m_block(block) {} + BasicBlockIterator(BasicBlock* block) + : m_block(block) + { + } BasicBlock* operator*() const { @@ -2119,7 +2178,10 @@ class BasicBlockSimpleList BasicBlock* m_begin; public: - BasicBlockSimpleList(BasicBlock* begin) : m_begin(begin) {} + BasicBlockSimpleList(BasicBlock* begin) + : m_begin(begin) + { + } BasicBlockIterator begin() const { @@ -2147,7 +2209,9 @@ class BasicBlockRangeList BasicBlock* m_end; public: - BasicBlockRangeList(BasicBlock* begin, BasicBlock* end) : m_begin(begin), m_end(end) + BasicBlockRangeList(BasicBlock* begin, BasicBlock* end) + : m_begin(begin) + , m_end(end) { assert(begin != nullptr); assert(end != nullptr); @@ -2187,7 +2251,11 @@ struct BBswtDesc bool bbsHasDefault; // true if last switch case is a default case bool bbsHasDominantCase; // true if switch has a dominant case - BBswtDesc() : bbsHasDefault(true), bbsHasDominantCase(false) {} + BBswtDesc() + : bbsHasDefault(true) + , bbsHasDominantCase(false) + { + } BBswtDesc(const BBswtDesc* other); @@ -2212,7 +2280,8 @@ struct BBswtDesc // BBSwitchTargetList out-of-class-declaration implementations (here due to C++ ordering requirements). // -inline BBSwitchTargetList::BBSwitchTargetList(BBswtDesc* bbsDesc) : m_bbsDesc(bbsDesc) +inline BBSwitchTargetList::BBSwitchTargetList(BBswtDesc* bbsDesc) + : m_bbsDesc(bbsDesc) { assert(m_bbsDesc != nullptr); assert(m_bbsDesc->bbsDstTab != nullptr); @@ -2235,7 +2304,11 @@ struct BBehfDesc FlowEdge** bbeSuccs; // array of `FlowEdge*` pointing to BBJ_EHFINALLYRET block successors unsigned bbeCount; // size of `bbeSuccs` array - BBehfDesc() : bbeSuccs(nullptr), bbeCount(0) {} + BBehfDesc() + : bbeSuccs(nullptr) + , bbeCount(0) + { + } BBehfDesc(Compiler* comp, const BBehfDesc* other); }; @@ -2243,7 +2316,8 @@ struct BBehfDesc // BBEhfSuccList out-of-class-declaration implementations (here due to C++ ordering requirements). // -inline BBEhfSuccList::BBEhfSuccList(BBehfDesc* bbeDesc) : m_bbeDesc(bbeDesc) +inline BBEhfSuccList::BBEhfSuccList(BBehfDesc* bbeDesc) + : m_bbeDesc(bbeDesc) { assert(m_bbeDesc != nullptr); assert((m_bbeDesc->bbeSuccs != nullptr) || (m_bbeDesc->bbeCount == 0)); @@ -2342,9 +2416,17 @@ struct BasicBlockList BasicBlockList* next; // The next BasicBlock in the list, nullptr for end of list. BasicBlock* block; // The BasicBlock of interest. - BasicBlockList() : next(nullptr), block(nullptr) {} + BasicBlockList() + : next(nullptr) + , block(nullptr) + { + } - BasicBlockList(BasicBlock* blk, BasicBlockList* rest) : next(rest), block(blk) {} + BasicBlockList(BasicBlock* blk, BasicBlockList* rest) + : next(rest) + , block(blk) + { + } }; // FlowEdge implementations (that are required to be defined after the declaration of BasicBlock) @@ -2368,7 +2450,8 @@ inline BasicBlock* BBArrayIterator::operator*() const // Pred list iterator implementations (that are required to be defined after the declaration of BasicBlock and FlowEdge) -inline PredEdgeList::iterator::iterator(FlowEdge* pred) : m_pred(pred) +inline PredEdgeList::iterator::iterator(FlowEdge* pred) + : m_pred(pred) { #ifdef DEBUG m_next = (m_pred == nullptr) ? nullptr : m_pred->getNextPredEdge(); @@ -2390,7 +2473,8 @@ inline PredEdgeList::iterator& PredEdgeList::iterator::operator++() } template -inline PredBlockList::iterator::iterator(FlowEdge* pred) : m_pred(pred) +inline PredBlockList::iterator::iterator(FlowEdge* pred) + : m_pred(pred) { bool initNextPointer = allowEdits; INDEBUG(initNextPointer = true); diff --git a/src/coreclr/jit/blockset.h b/src/coreclr/jit/blockset.h index 83de7a5dad1e59..f69e1e59ace324 100644 --- a/src/coreclr/jit/blockset.h +++ b/src/coreclr/jit/blockset.h @@ -24,10 +24,11 @@ #include "compilerbitsettraits.h" #include "bitsetasshortlong.h" -class BlockSetOps : public BitSetOps +class BlockSetOps + : public BitSetOps { public: // Specialize BlockSetOps::MakeFull(). Since we number basic blocks from one, we remove bit zero from diff --git a/src/coreclr/jit/buildstring.cpp b/src/coreclr/jit/buildstring.cpp index f432fec47475ff..3f0222ad2649ac 100644 --- a/src/coreclr/jit/buildstring.cpp +++ b/src/coreclr/jit/buildstring.cpp @@ -1,9 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#define STRINGIFY(L) #L +#define STRINGIFY(L) #L #define MAKESTRING(M, L) M(L) -#define STRINGIZE(X) MAKESTRING(STRINGIFY, X) +#define STRINGIZE(X) MAKESTRING(STRINGIFY, X) #if defined(__clang__) #define BUILD_COMPILER \ diff --git a/src/coreclr/jit/codegen.h b/src/coreclr/jit/codegen.h index faec6fd1bb5a27..0ab8a81d89ef93 100644 --- a/src/coreclr/jit/codegen.h +++ b/src/coreclr/jit/codegen.h @@ -317,9 +317,17 @@ class CodeGen final : public CodeGenInterface regNumber reg2; bool useSaveNextPair; - RegPair(regNumber reg1) : reg1(reg1), reg2(REG_NA), useSaveNextPair(false) {} + RegPair(regNumber reg1) + : reg1(reg1) + , reg2(REG_NA) + , useSaveNextPair(false) + { + } - RegPair(regNumber reg1, regNumber reg2) : reg1(reg1), reg2(reg2), useSaveNextPair(false) + RegPair(regNumber reg1, regNumber reg2) + : reg1(reg1) + , reg2(reg2) + , useSaveNextPair(false) { assert(reg2 == REG_NEXT(reg1)); } @@ -1359,7 +1367,9 @@ class CodeGen final : public CodeGenInterface void genNumberOperandUse(GenTree* const operand, int& useNum) const; void genCheckConsumeNode(GenTree* const node); #else // !DEBUG - inline void genCheckConsumeNode(GenTree* treeNode) {} + inline void genCheckConsumeNode(GenTree* treeNode) + { + } #endif // DEBUG /* @@ -1433,7 +1443,8 @@ class CodeGen final : public CodeGenInterface #if defined(TARGET_XARCH) - enum class OperandKind{ + enum class OperandKind + { ClsVar, // [CLS_VAR_ADDR] - "C" in the emitter. Local, // [Local or spill temp + offset] - "S" in the emitter. Indir, // [base+index*scale+disp] - "A" in the emitter. @@ -1473,26 +1484,47 @@ class CodeGen final : public CodeGenInterface }; public: - OperandDesc(CORINFO_FIELD_HANDLE fieldHnd) : m_kind(OperandKind::ClsVar), m_fieldHnd(fieldHnd) {} + OperandDesc(CORINFO_FIELD_HANDLE fieldHnd) + : m_kind(OperandKind::ClsVar) + , m_fieldHnd(fieldHnd) + { + } - OperandDesc(int varNum, uint16_t offset) : m_kind(OperandKind::Local), m_varNum(varNum), m_offset(offset) {} + OperandDesc(int varNum, uint16_t offset) + : m_kind(OperandKind::Local) + , m_varNum(varNum) + , m_offset(offset) + { + } OperandDesc(GenTreeIndir* indir) - : m_kind(OperandKind::Indir), m_addr(indir->Addr()), m_indir(indir), m_indirType(indir->TypeGet()) + : m_kind(OperandKind::Indir) + , m_addr(indir->Addr()) + , m_indir(indir) + , m_indirType(indir->TypeGet()) { } OperandDesc(var_types indirType, GenTree* addr) - : m_kind(OperandKind::Indir), m_addr(addr), m_indir(nullptr), m_indirType(indirType) + : m_kind(OperandKind::Indir) + , m_addr(addr) + , m_indir(nullptr) + , m_indirType(indirType) { } OperandDesc(ssize_t immediate, bool immediateNeedsReloc) - : m_kind(OperandKind::Imm), m_immediate(immediate), m_immediateNeedsReloc(immediateNeedsReloc) + : m_kind(OperandKind::Imm) + , m_immediate(immediate) + , m_immediateNeedsReloc(immediateNeedsReloc) { } - OperandDesc(regNumber reg) : m_kind(OperandKind::Reg), m_reg(reg) {} + OperandDesc(regNumber reg) + : m_kind(OperandKind::Reg) + , m_reg(reg) + { + } OperandKind GetKind() const { @@ -1680,7 +1712,9 @@ class CodeGenPhase final : public Phase { public: CodeGenPhase(CodeGen* _codeGen, Phases _phase, void (CodeGen::*_action)()) - : Phase(_codeGen->GetCompiler(), _phase), codeGen(_codeGen), action(_action) + : Phase(_codeGen->GetCompiler(), _phase) + , codeGen(_codeGen) + , action(_action) { } diff --git a/src/coreclr/jit/codegenarmarch.cpp b/src/coreclr/jit/codegenarmarch.cpp index 160addef1b9656..965b72721aaaa0 100644 --- a/src/coreclr/jit/codegenarmarch.cpp +++ b/src/coreclr/jit/codegenarmarch.cpp @@ -2060,7 +2060,10 @@ class ProducingStreamBaseInstrs { public: ProducingStreamBaseInstrs(regNumber intReg1, regNumber intReg2, regNumber addrReg, emitter* emitter) - : intReg1(intReg1), intReg2(intReg2), addrReg(addrReg), emitter(emitter) + : intReg1(intReg1) + , intReg2(intReg2) + , addrReg(addrReg) + , emitter(emitter) { } @@ -2121,7 +2124,11 @@ class ProducingStream { public: ProducingStream(regNumber intReg1, regNumber simdReg1, regNumber simdReg2, regNumber addrReg, emitter* emitter) - : intReg1(intReg1), simdReg1(simdReg1), simdReg2(simdReg2), addrReg(addrReg), emitter(emitter) + : intReg1(intReg1) + , simdReg1(simdReg1) + , simdReg2(simdReg2) + , addrReg(addrReg) + , emitter(emitter) { } @@ -2244,7 +2251,11 @@ class BlockUnrollHelper class InitBlockUnrollHelper { public: - InitBlockUnrollHelper(int dstOffset, unsigned byteCount) : dstStartOffset(dstOffset), byteCount(byteCount) {} + InitBlockUnrollHelper(int dstOffset, unsigned byteCount) + : dstStartOffset(dstOffset) + , byteCount(byteCount) + { + } int GetDstOffset() const { @@ -2371,7 +2382,9 @@ class CopyBlockUnrollHelper { public: CopyBlockUnrollHelper(int srcOffset, int dstOffset, unsigned byteCount) - : srcStartOffset(srcOffset), dstStartOffset(dstOffset), byteCount(byteCount) + : srcStartOffset(srcOffset) + , dstStartOffset(dstOffset) + , byteCount(byteCount) { } @@ -3088,8 +3101,7 @@ void CodeGen::genCodeForMemmove(GenTreeBlk* tree) regNumber src = genConsumeReg(srcIndir->Addr()); unsigned size = tree->Size(); - auto emitLoadStore = [&](bool load, unsigned regSize, regNumber tempReg, unsigned offset) - { + auto emitLoadStore = [&](bool load, unsigned regSize, regNumber tempReg, unsigned offset) { var_types memType; switch (regSize) { @@ -3138,8 +3150,7 @@ void CodeGen::genCodeForMemmove(GenTreeBlk* tree) tempRegs[i] = tree->ExtractTempReg(RBM_ALLFLOAT); } - auto emitSimdLoadStore = [&](bool load) - { + auto emitSimdLoadStore = [&](bool load) { unsigned offset = 0; int regIndex = 0; do diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index 30fcd2532436ad..62fe40ed3c5876 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -65,7 +65,10 @@ CodeGenInterface* getCodeGenerator(Compiler* comp) // CodeGen constructor CodeGenInterface::CodeGenInterface(Compiler* theCompiler) - : gcInfo(theCompiler), regSet(theCompiler, gcInfo), compiler(theCompiler), treeLifeUpdater(nullptr) + : gcInfo(theCompiler) + , regSet(theCompiler, gcInfo) + , compiler(theCompiler) + , treeLifeUpdater(nullptr) { } @@ -84,7 +87,8 @@ void CodeGenInterface::CopyRegisterInfo() /*****************************************************************************/ -CodeGen::CodeGen(Compiler* theCompiler) : CodeGenInterface(theCompiler) +CodeGen::CodeGen(Compiler* theCompiler) + : CodeGenInterface(theCompiler) { #if defined(TARGET_XARCH) negBitmaskFlt = nullptr; @@ -6251,8 +6255,7 @@ void CodeGen::genFnProlog() genFnPrologCalleeRegArgs(); } #else - auto assignIncomingRegisterArgs = [this, initReg, &initRegZeroed](RegState* regState) - { + auto assignIncomingRegisterArgs = [this, initReg, &initRegZeroed](RegState* regState) { if (regState->rsCalleeRegArgMaskLiveIn) { // If we need an extra register to shuffle around the incoming registers @@ -7326,8 +7329,7 @@ void CodeGen::genReportRichDebugInfoInlineTreeToFile(FILE* file, InlineContext* fprintf(file, "\"ILOffset\":%u,", context->GetLocation().GetOffset()); fprintf(file, "\"LocationFlags\":%u,", (uint32_t)context->GetLocation().EncodeSourceTypes()); fprintf(file, "\"ExactILOffset\":%u,", context->GetActualCallOffset()); - auto append = [&]() - { + auto append = [&]() { char buffer[256]; const char* methodName = compiler->eeGetMethodName(context->GetCallee(), buffer, sizeof(buffer)); fprintf(file, "\"MethodName\":\"%s\",", methodName); diff --git a/src/coreclr/jit/codegeninterface.h b/src/coreclr/jit/codegeninterface.h index 5a228a73eca160..ef87ccca858702 100644 --- a/src/coreclr/jit/codegeninterface.h +++ b/src/coreclr/jit/codegeninterface.h @@ -628,7 +628,9 @@ class CodeGenInterface VariableLiveRange(CodeGenInterface::siVarLoc varLocation, emitLocation startEmitLocation, emitLocation endEmitLocation) - : m_StartEmitLocation(startEmitLocation), m_EndEmitLocation(endEmitLocation), m_VarLocation(varLocation) + : m_StartEmitLocation(startEmitLocation) + , m_EndEmitLocation(endEmitLocation) + , m_VarLocation(varLocation) { } @@ -676,7 +678,8 @@ class CodeGenInterface public: LiveRangeDumper(const LiveRangeList* liveRanges) - : m_startingLiveRange(liveRanges->end()), m_hasLiveRangesToDump(false){}; + : m_startingLiveRange(liveRanges->end()) + , m_hasLiveRangesToDump(false){}; // Make the dumper point to the last "VariableLiveRange" opened or nullptr if all are closed void resetDumper(const LiveRangeList* list); diff --git a/src/coreclr/jit/codegenlinear.cpp b/src/coreclr/jit/codegenlinear.cpp index c6f8dbe9b56822..b60999d35b4aeb 100644 --- a/src/coreclr/jit/codegenlinear.cpp +++ b/src/coreclr/jit/codegenlinear.cpp @@ -645,8 +645,7 @@ void CodeGen::genCodeForBBlist() #endif // TARGET_AMD64 #if FEATURE_LOOP_ALIGN - auto SetLoopAlignBackEdge = [=](const BasicBlock* block, const BasicBlock* target) - { + auto SetLoopAlignBackEdge = [=](const BasicBlock* block, const BasicBlock* target) { // This is the last place where we operate on blocks and after this, we operate // on IG. Hence, if we know that the destination of "block" is the first block // of a loop and that loop needs alignment (it has BBF_LOOP_ALIGN), then "block" diff --git a/src/coreclr/jit/codegenxarch.cpp b/src/coreclr/jit/codegenxarch.cpp index e282c7df4f4812..ede5df1bea39d1 100644 --- a/src/coreclr/jit/codegenxarch.cpp +++ b/src/coreclr/jit/codegenxarch.cpp @@ -2677,8 +2677,7 @@ void CodeGen::genCodeForMemmove(GenTreeBlk* tree) tempRegs[i] = tree->ExtractTempReg(RBM_ALLFLOAT); } - auto emitSimdLoadStore = [&](bool load) - { + auto emitSimdLoadStore = [&](bool load) { unsigned offset = 0; int regIndex = 0; instruction simdMov = simdUnalignedMovIns(); @@ -2724,8 +2723,7 @@ void CodeGen::genCodeForMemmove(GenTreeBlk* tree) // Here we work with size 1..15 (x64) assert((size > 0) && (size < XMM_REGSIZE_BYTES)); - auto emitScalarLoadStore = [&](bool load, int size, regNumber tempReg, int offset) - { + auto emitScalarLoadStore = [&](bool load, int size, regNumber tempReg, int offset) { var_types memType; switch (size) { @@ -3235,8 +3233,7 @@ void CodeGen::genCodeForInitBlkUnroll(GenTreeBlk* node) instruction simdMov = simdUnalignedMovIns(); unsigned bytesWritten = 0; - auto emitSimdMovs = [&]() - { + auto emitSimdMovs = [&]() { if (dstLclNum != BAD_VAR_NUM) { emit->emitIns_S_R(simdMov, EA_ATTR(regSize), srcXmmReg, dstLclNum, dstOffset); @@ -3527,8 +3524,7 @@ void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* node) instruction simdMov = simdUnalignedMovIns(); - auto emitSimdMovs = [&]() - { + auto emitSimdMovs = [&]() { if (srcLclNum != BAD_VAR_NUM) { emit->emitIns_R_S(simdMov, EA_ATTR(regSize), tempReg, srcLclNum, srcOffset); diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 676135b10b6246..ef45fa5ca81ab8 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -1157,9 +1157,15 @@ struct FileLine unsigned m_line; char* m_condStr; - FileLine() : m_file(nullptr), m_line(0), m_condStr(nullptr) {} + FileLine() + : m_file(nullptr) + , m_line(0) + , m_condStr(nullptr) + { + } - FileLine(const char* file, unsigned line, const char* condStr) : m_line(line) + FileLine(const char* file, unsigned line, const char* condStr) + : m_line(line) { size_t newSize = (strlen(file) + 1) * sizeof(char); m_file = HostAllocator::getHostAllocator().allocate(newSize); @@ -1231,7 +1237,10 @@ struct NowayAssertCountMap size_t count; FileLine fl; - NowayAssertCountMap() : count(0) {} + NowayAssertCountMap() + : count(0) + { + } struct compare { @@ -1455,12 +1464,10 @@ void Compiler::compShutdown() opers[op] = {GenTree::s_gtNodeCounts[op], GenTree::s_gtTrueSizes[op], static_cast(op)}; } - jitstd::sort(opers, opers + ArrLen(opers), - [](const OperInfo& l, const OperInfo& r) - { - // We'll be sorting in descending order. - return l.Count >= r.Count; - }); + jitstd::sort(opers, opers + ArrLen(opers), [](const OperInfo& l, const OperInfo& r) { + // We'll be sorting in descending order. + return l.Count >= r.Count; + }); unsigned remainingCount = totalCount; unsigned remainingCountLarge = 0; @@ -4566,8 +4573,7 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl // Prepare for importation // - auto preImportPhase = [this]() - { + auto preImportPhase = [this]() { if (compIsForInlining()) { // Notify root instance that an inline attempt is about to import IL @@ -4792,7 +4798,9 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl { // Tail merge // - DoPhase(this, PHASE_HEAD_TAIL_MERGE, [this]() { return fgHeadTailMerge(true); }); + DoPhase(this, PHASE_HEAD_TAIL_MERGE, [this]() { + return fgHeadTailMerge(true); + }); // Merge common throw blocks // @@ -4862,8 +4870,7 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl unsigned const preMorphBBCount = fgBBcount; DoPhase(this, PHASE_MORPH_GLOBAL, &Compiler::fgMorphBlocks); - auto postMorphPhase = [this]() - { + auto postMorphPhase = [this]() { // Fix any LclVar annotations on discarded struct promotion temps for implicit by-ref args fgMarkDemotedImplicitByRefArgs(); lvaRefCountState = RCS_INVALID; @@ -4918,7 +4925,9 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl // Second pass of tail merge // - DoPhase(this, PHASE_HEAD_TAIL_MERGE2, [this]() { return fgHeadTailMerge(false); }); + DoPhase(this, PHASE_HEAD_TAIL_MERGE2, [this]() { + return fgHeadTailMerge(false); + }); // Canonicalize entry to give a unique dominator tree root // @@ -5273,7 +5282,9 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl // Now that lowering is completed we can proceed to perform register allocation // - auto linearScanPhase = [this]() { m_pLinearScan->doLinearScan(); }; + auto linearScanPhase = [this]() { + m_pLinearScan->doLinearScan(); + }; DoPhase(this, PHASE_LINEAR_SCAN, linearScanPhase); // Copied from rpPredictRegUse() @@ -5420,19 +5431,17 @@ bool Compiler::shouldAlignLoop(FlowGraphNaturalLoop* loop, BasicBlock* top) return false; } - bool hasCall = loop->VisitLoopBlocks( - [](BasicBlock* block) - { - for (GenTree* tree : LIR::AsRange(block)) - { - if (tree->IsCall()) - { - return BasicBlockVisit::Abort; - } - } + bool hasCall = loop->VisitLoopBlocks([](BasicBlock* block) { + for (GenTree* tree : LIR::AsRange(block)) + { + if (tree->IsCall()) + { + return BasicBlockVisit::Abort; + } + } - return BasicBlockVisit::Continue; - }) == BasicBlockVisit::Abort; + return BasicBlockVisit::Continue; + }) == BasicBlockVisit::Abort; if (hasCall) { @@ -5995,7 +6004,9 @@ void Compiler::RecomputeFlowGraphAnnotations() } /*****************************************************************************/ -void Compiler::ProcessShutdownWork(ICorStaticInfo* statInfo) {} +void Compiler::ProcessShutdownWork(ICorStaticInfo* statInfo) +{ +} /*****************************************************************************/ @@ -8324,7 +8335,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ /*****************************************************************************/ -void codeGeneratorCodeSizeBeg() {} +void codeGeneratorCodeSizeBeg() +{ +} /***************************************************************************** * @@ -8332,7 +8345,9 @@ void codeGeneratorCodeSizeBeg() {} */ /*****************************************************************************/ -void codeGeneratorCodeSizeEnd() {} +void codeGeneratorCodeSizeEnd() +{ +} /***************************************************************************** * * Gather statistics - mainly used for the standalone @@ -8935,7 +8950,8 @@ void CompTimeSummaryInfo::Print(FILE* f) fprintf(f, "\n"); } -JitTimer::JitTimer(unsigned byteCodeSize) : m_info(byteCodeSize) +JitTimer::JitTimer(unsigned byteCodeSize) + : m_info(byteCodeSize) { #if MEASURE_CLRAPI_CALLS m_CLRcallInvokes = 0; @@ -10489,12 +10505,10 @@ JITDBGAPI GenTree* __cdecl dFindTreeInTree(GenTree* tree, unsigned id) } GenTree* child = nullptr; - tree->VisitOperands( - [&child, id](GenTree* operand) -> GenTree::VisitResult - { - child = dFindTreeInTree(child, id); - return (child != nullptr) ? GenTree::VisitResult::Abort : GenTree::VisitResult::Continue; - }); + tree->VisitOperands([&child, id](GenTree* operand) -> GenTree::VisitResult { + child = dFindTreeInTree(child, id); + return (child != nullptr) ? GenTree::VisitResult::Abort : GenTree::VisitResult::Continue; + }); return child; } diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 13c2d43a7e1045..d1e71dc41106df 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -230,11 +230,17 @@ class LclSsaVarDsc bool m_hasGlobalUse = false; public: - LclSsaVarDsc() {} + LclSsaVarDsc() + { + } - LclSsaVarDsc(BasicBlock* block) : m_block(block) {} + LclSsaVarDsc(BasicBlock* block) + : m_block(block) + { + } - LclSsaVarDsc(BasicBlock* block, GenTreeLclVarCommon* defNode) : m_block(block) + LclSsaVarDsc(BasicBlock* block, GenTreeLclVarCommon* defNode) + : m_block(block) { SetDefNode(defNode); } @@ -359,7 +365,12 @@ class SsaDefArray public: // Construct an empty SsaDefArray. - SsaDefArray() : m_array(nullptr), m_arraySize(0), m_count(0) {} + SsaDefArray() + : m_array(nullptr) + , m_arraySize(0) + , m_count(0) + { + } // Reset the array (used only if the SSA form is reconstructed). void Reset() @@ -497,11 +508,11 @@ class LclVarDsc // note this only packs because var_types is a typedef of unsigned char var_types lvType : 5; // TYP_INT/LONG/FLOAT/DOUBLE/REF - unsigned char lvIsParam : 1; // is this a parameter? - unsigned char lvIsRegArg : 1; // is this an argument that was passed by register? + unsigned char lvIsParam : 1; // is this a parameter? + unsigned char lvIsRegArg : 1; // is this an argument that was passed by register? unsigned char lvFramePointerBased : 1; // 0 = off of REG_SPBASE (e.g., ESP), 1 = off of REG_FPBASE (e.g., EBP) - unsigned char lvOnFrame : 1; // (part of) the variable lives on the frame + unsigned char lvOnFrame : 1; // (part of) the variable lives on the frame unsigned char lvRegister : 1; // assigned to live in a register? For RyuJIT backend, this is only set if the // variable is in the same register for the entire function. unsigned char lvTracked : 1; // is this a tracked variable? @@ -523,16 +534,16 @@ class LclVarDsc // We cannot reason reliably about the value of the variable. public: unsigned char lvDoNotEnregister : 1; // Do not enregister this variable. - unsigned char lvFieldAccessed : 1; // The var is a struct local, and a field of the variable is accessed. Affects + unsigned char lvFieldAccessed : 1; // The var is a struct local, and a field of the variable is accessed. Affects // struct promotion. unsigned char lvLiveInOutOfHndlr : 1; // The variable is live in or out of an exception handler, and therefore must // be on the stack (at least at those boundaries.) - unsigned char lvInSsa : 1; // The variable is in SSA form (set by SsaBuilder) - unsigned char lvIsCSE : 1; // Indicates if this LclVar is a CSE variable. + unsigned char lvInSsa : 1; // The variable is in SSA form (set by SsaBuilder) + unsigned char lvIsCSE : 1; // Indicates if this LclVar is a CSE variable. unsigned char lvHasLdAddrOp : 1; // has ldloca or ldarga opcode on this local. - unsigned char lvHasILStoreOp : 1; // there is at least one STLOC or STARG on this local + unsigned char lvHasILStoreOp : 1; // there is at least one STLOC or STARG on this local unsigned char lvHasMultipleILStoreOp : 1; // there is more than one STLOC on this local unsigned char lvIsTemp : 1; // Short-lifetime compiler temp @@ -547,13 +558,13 @@ class LclVarDsc #if defined(TARGET_LOONGARCH64) unsigned char lvIs4Field1 : 1; // Set if the 1st field is int or float within struct for LA-ABI64. unsigned char lvIs4Field2 : 1; // Set if the 2nd field is int or float within struct for LA-ABI64. - unsigned char lvIsSplit : 1; // Set if the argument is splited. + unsigned char lvIsSplit : 1; // Set if the argument is splited. #endif // defined(TARGET_LOONGARCH64) #if defined(TARGET_RISCV64) unsigned char lvIs4Field1 : 1; // Set if the 1st field is int or float within struct for RISCV64. unsigned char lvIs4Field2 : 1; // Set if the 2nd field is int or float within struct for RISCV64. - unsigned char lvIsSplit : 1; // Set if the argument is splited. + unsigned char lvIsSplit : 1; // Set if the argument is splited. #endif // defined(TARGET_RISCV64) unsigned char lvSingleDef : 1; // variable has a single def. Used to identify ref type locals that can get type @@ -582,7 +593,7 @@ class LclVarDsc unsigned char lvQuirkToLong : 1; // Quirk to allocate this LclVar as a 64-bit long #endif #ifdef DEBUG - unsigned char lvKeepType : 1; // Don't change the type of this variable + unsigned char lvKeepType : 1; // Don't change the type of this variable unsigned char lvNoLclFldStress : 1; // Can't apply local field stress on this one #endif unsigned char lvIsPtr : 1; // Might this be used in an address computation? (used by buffer overflow security @@ -637,8 +648,8 @@ class LclVarDsc #ifdef DEBUG unsigned char lvClassInfoUpdated : 1; // true if this var has updated class handle or exactness - unsigned char lvIsHoist : 1; // CSE temp for a hoisted tree - unsigned char lvIsMultiDefCSE : 1; // CSE temp for a multi-def CSE + unsigned char lvIsHoist : 1; // CSE temp for a hoisted tree + unsigned char lvIsMultiDefCSE : 1; // CSE temp for a multi-def CSE #endif unsigned char lvImplicitlyReferenced : 1; // true if there are non-IR references to this local (prolog, epilog, gc, @@ -1329,7 +1340,8 @@ class IntegralRange IntegralRange() = default; IntegralRange(SymbolicIntegerValue lowerBound, SymbolicIntegerValue upperBound) - : m_lowerBound(lowerBound), m_upperBound(upperBound) + : m_lowerBound(lowerBound) + , m_upperBound(upperBound) { assert(lowerBound <= upperBound); } @@ -1417,7 +1429,10 @@ class TempDsc var_types tdType; public: - TempDsc(int _tdNum, unsigned _tdSize, var_types _tdType) : tdNum(_tdNum), tdSize((BYTE)_tdSize), tdType(_tdType) + TempDsc(int _tdNum, unsigned _tdSize, var_types _tdType) + : tdNum(_tdNum) + , tdSize((BYTE)_tdSize) + , tdType(_tdType) { #ifdef DEBUG // temps must have a negative number (so they have a different number from all local variables) @@ -8351,7 +8366,11 @@ class Compiler template bool eeRunFunctorWithSPMIErrorTrap(Functor f) { - return eeRunWithSPMIErrorTrap([](Functor* pf) { (*pf)(); }, &f); + return eeRunWithSPMIErrorTrap( + [](Functor* pf) { + (*pf)(); + }, + &f); } bool eeRunWithSPMIErrorTrapImp(void (*function)(void*), void* param); @@ -9642,9 +9661,9 @@ class Compiler // optimize maximally and/or favor speed over size? -#define DEFAULT_MIN_OPTS_CODE_SIZE 60000 -#define DEFAULT_MIN_OPTS_INSTR_COUNT 20000 -#define DEFAULT_MIN_OPTS_BB_COUNT 2000 +#define DEFAULT_MIN_OPTS_CODE_SIZE 60000 +#define DEFAULT_MIN_OPTS_INSTR_COUNT 20000 +#define DEFAULT_MIN_OPTS_BB_COUNT 2000 #define DEFAULT_MIN_OPTS_LV_NUM_COUNT 2000 #define DEFAULT_MIN_OPTS_LV_REF_COUNT 8000 @@ -10250,11 +10269,11 @@ class Compiler // (2) the code is hot/cold split, and we issued less code than we expected // in the cold section (the hot section will always be padded out to compTotalHotCodeSize). - bool compIsStatic : 1; // Is the method static (no 'this' pointer)? - bool compIsVarArgs : 1; // Does the method have varargs parameters? - bool compInitMem : 1; // Is the CORINFO_OPT_INIT_LOCALS bit set in the method info options? - bool compProfilerCallback : 1; // JIT inserted a profiler Enter callback - bool compPublishStubParam : 1; // EAX captured in prolog will be available through an intrinsic + bool compIsStatic : 1; // Is the method static (no 'this' pointer)? + bool compIsVarArgs : 1; // Does the method have varargs parameters? + bool compInitMem : 1; // Is the CORINFO_OPT_INIT_LOCALS bit set in the method info options? + bool compProfilerCallback : 1; // JIT inserted a profiler Enter callback + bool compPublishStubParam : 1; // EAX captured in prolog will be available through an intrinsic bool compHasNextCallRetAddr : 1; // The NextCallReturnAddress intrinsic is used. var_types compRetType; // Return type of the method as declared in IL (including SIMD normalization) @@ -11302,7 +11321,9 @@ class GenTreeVisitor Compiler* m_compiler; ArrayStack m_ancestors; - GenTreeVisitor(Compiler* compiler) : m_compiler(compiler), m_ancestors(compiler->getAllocator(CMK_ArrayStack)) + GenTreeVisitor(Compiler* compiler) + : m_compiler(compiler) + , m_ancestors(compiler->getAllocator(CMK_ArrayStack)) { assert(compiler != nullptr); @@ -11725,15 +11746,26 @@ class DomTreeVisitor protected: Compiler* m_compiler; - DomTreeVisitor(Compiler* compiler) : m_compiler(compiler) {} + DomTreeVisitor(Compiler* compiler) + : m_compiler(compiler) + { + } - void Begin() {} + void Begin() + { + } - void PreOrderVisit(BasicBlock* block) {} + void PreOrderVisit(BasicBlock* block) + { + } - void PostOrderVisit(BasicBlock* block) {} + void PostOrderVisit(BasicBlock* block) + { + } - void End() {} + void End() + { + } private: void WalkTree(const DomTreeNode* tree) @@ -11804,7 +11836,10 @@ class EHClauses EHblkDsc* m_ehDsc; public: - iterator(EHblkDsc* ehDsc) : m_ehDsc(ehDsc) {} + iterator(EHblkDsc* ehDsc) + : m_ehDsc(ehDsc) + { + } EHblkDsc* operator*() const { @@ -11824,7 +11859,9 @@ class EHClauses }; public: - EHClauses(Compiler* comp) : m_begin(comp->compHndBBtab), m_end(comp->compHndBBtab + comp->compHndBBtabCount) + EHClauses(Compiler* comp) + : m_begin(comp->compHndBBtab) + , m_end(comp->compHndBBtab + comp->compHndBBtabCount) { assert((m_begin != nullptr) || (m_begin == m_end)); } @@ -11861,7 +11898,9 @@ class StringPrinter public: StringPrinter(CompAllocator alloc, char* buffer = nullptr, size_t bufferMax = 0) - : m_alloc(alloc), m_buffer(buffer), m_bufferMax(bufferMax) + : m_alloc(alloc) + , m_buffer(buffer) + , m_bufferMax(bufferMax) { if ((m_buffer == nullptr) || (m_bufferMax == 0)) { diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index 4e2c52f5cc0666..336c95f7527616 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -280,7 +280,10 @@ class Counter : public Dumpable public: int64_t Value; - Counter(int64_t initialValue = 0) : Value(initialValue) {} + Counter(int64_t initialValue = 0) + : Value(initialValue) + { + } void dump(FILE* output); }; @@ -330,7 +333,10 @@ class Histogram : public Dumpable class NodeCounts : public Dumpable { public: - NodeCounts() : m_counts() {} + NodeCounts() + : m_counts() + { + } void dump(FILE* output); void record(genTreeOps oper); @@ -4776,8 +4782,7 @@ unsigned Compiler::fgRunDfs(VisitPreorder visitPreorder, VisitPostorder visitPos ArrayStack blocks(getAllocator(CMK_DepthFirstSearch)); - auto dfsFrom = [&](BasicBlock* firstBB) - { + auto dfsFrom = [&](BasicBlock* firstBB) { BitVecOps::AddElemD(&traits, visited, firstBB->bbNum); blocks.Emplace(this, firstBB); visitPreorder(firstBB, preOrderIndex++); @@ -4847,17 +4852,15 @@ template BasicBlockVisit FlowGraphNaturalLoop::VisitLoopBlocksReversePostOrder(TFunc func) { BitVecTraits traits(m_blocksSize, m_dfsTree->GetCompiler()); - bool result = BitVecOps::VisitBits(&traits, m_blocks, - [=](unsigned index) - { - // head block rpo index = PostOrderCount - 1 - headPreOrderIndex - // loop block rpo index = head block rpoIndex + index - // loop block po index = PostOrderCount - 1 - loop block rpo index - // = headPreOrderIndex - index - unsigned poIndex = m_header->bbPostorderNum - index; - assert(poIndex < m_dfsTree->GetPostOrderCount()); - return func(m_dfsTree->GetPostOrder(poIndex)) == BasicBlockVisit::Continue; - }); + bool result = BitVecOps::VisitBits(&traits, m_blocks, [=](unsigned index) { + // head block rpo index = PostOrderCount - 1 - headPreOrderIndex + // loop block rpo index = head block rpoIndex + index + // loop block po index = PostOrderCount - 1 - loop block rpo index + // = headPreOrderIndex - index + unsigned poIndex = m_header->bbPostorderNum - index; + assert(poIndex < m_dfsTree->GetPostOrderCount()); + return func(m_dfsTree->GetPostOrder(poIndex)) == BasicBlockVisit::Continue; + }); return result ? BasicBlockVisit::Continue : BasicBlockVisit::Abort; } @@ -4881,14 +4884,11 @@ template BasicBlockVisit FlowGraphNaturalLoop::VisitLoopBlocksPostOrder(TFunc func) { BitVecTraits traits(m_blocksSize, m_dfsTree->GetCompiler()); - bool result = - BitVecOps::VisitBitsReverse(&traits, m_blocks, - [=](unsigned index) - { - unsigned poIndex = m_header->bbPostorderNum - index; - assert(poIndex < m_dfsTree->GetPostOrderCount()); - return func(m_dfsTree->GetPostOrder(poIndex)) == BasicBlockVisit::Continue; - }); + bool result = BitVecOps::VisitBitsReverse(&traits, m_blocks, [=](unsigned index) { + unsigned poIndex = m_header->bbPostorderNum - index; + assert(poIndex < m_dfsTree->GetPostOrderCount()); + return func(m_dfsTree->GetPostOrder(poIndex)) == BasicBlockVisit::Continue; + }); return result ? BasicBlockVisit::Continue : BasicBlockVisit::Abort; } @@ -4933,17 +4933,15 @@ BasicBlockVisit FlowGraphNaturalLoop::VisitLoopBlocksLexical(TFunc func) { BasicBlock* top = m_header; unsigned numLoopBlocks = 0; - VisitLoopBlocks( - [&](BasicBlock* block) + VisitLoopBlocks([&](BasicBlock* block) { + if (block->bbNum < top->bbNum) { - if (block->bbNum < top->bbNum) - { - top = block; - } + top = block; + } - numLoopBlocks++; - return BasicBlockVisit::Continue; - }); + numLoopBlocks++; + return BasicBlockVisit::Continue; + }); INDEBUG(BasicBlock* prev = nullptr); BasicBlock* cur = top; diff --git a/src/coreclr/jit/compilerbitsettraits.h b/src/coreclr/jit/compilerbitsettraits.h index 02223b1ecedfce..965ffac55465e1 100644 --- a/src/coreclr/jit/compilerbitsettraits.h +++ b/src/coreclr/jit/compilerbitsettraits.h @@ -107,7 +107,9 @@ struct BitVecTraits Compiler* comp; public: - BitVecTraits(unsigned size, Compiler* comp) : size(size), comp(comp) + BitVecTraits(unsigned size, Compiler* comp) + : size(size) + , comp(comp) { const unsigned elemBits = 8 * sizeof(size_t); arraySize = roundUp(size, elemBits) / elemBits; diff --git a/src/coreclr/jit/copyprop.cpp b/src/coreclr/jit/copyprop.cpp index 58cd770453f7f7..142c745fc7c317 100644 --- a/src/coreclr/jit/copyprop.cpp +++ b/src/coreclr/jit/copyprop.cpp @@ -30,8 +30,7 @@ // void Compiler::optBlockCopyPropPopStacks(BasicBlock* block, LclNumToLiveDefsMap* curSsaName) { - auto popDef = [=](unsigned defLclNum, unsigned defSsaNum) - { + auto popDef = [=](unsigned defLclNum, unsigned defSsaNum) { CopyPropSsaDefStack* stack = nullptr; if ((defSsaNum != SsaConfig::RESERVED_SSA_NUM) && curSsaName->Lookup(defLclNum, &stack)) { @@ -301,8 +300,7 @@ void Compiler::optCopyPropPushDef(GenTree* defNode, GenTreeLclVarCommon* lclNode return; } - auto pushDef = [=](unsigned defLclNum, unsigned defSsaNum) - { + auto pushDef = [=](unsigned defLclNum, unsigned defSsaNum) { // The default is "not available". LclSsaVarDsc* ssaDef = nullptr; @@ -464,7 +462,9 @@ PhaseStatus Compiler::optVnCopyProp() public: CopyPropDomTreeVisitor(Compiler* compiler) - : DomTreeVisitor(compiler), m_curSsaName(compiler->getAllocator(CMK_CopyProp)), m_madeChanges(false) + : DomTreeVisitor(compiler) + , m_curSsaName(compiler->getAllocator(CMK_CopyProp)) + , m_madeChanges(false) { } diff --git a/src/coreclr/jit/dataflow.h b/src/coreclr/jit/dataflow.h index d29769d0aa7a6c..6f27c6a998d771 100644 --- a/src/coreclr/jit/dataflow.h +++ b/src/coreclr/jit/dataflow.h @@ -78,12 +78,10 @@ void DataFlow::ForwardAnalysis(TCallback& callback) // block dominates all other blocks in the 'try'. That will happen // as part of processing handlers below. // - block->VisitRegularSuccs(m_pCompiler, - [&worklist](BasicBlock* succ) - { - worklist.insert(worklist.end(), succ); - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(m_pCompiler, [&worklist](BasicBlock* succ) { + worklist.insert(worklist.end(), succ); + return BasicBlockVisit::Continue; + }); } if (m_pCompiler->bbIsTryBeg(block)) diff --git a/src/coreclr/jit/debuginfo.h b/src/coreclr/jit/debuginfo.h index 53cadbeaddd030..72119b905c948a 100644 --- a/src/coreclr/jit/debuginfo.h +++ b/src/coreclr/jit/debuginfo.h @@ -12,10 +12,17 @@ class InlineContext; class ILLocation { public: - ILLocation() : m_offset(BAD_IL_OFFSET), m_isStackEmpty(false), m_isCall(false) {} + ILLocation() + : m_offset(BAD_IL_OFFSET) + , m_isStackEmpty(false) + , m_isCall(false) + { + } ILLocation(IL_OFFSET offset, bool isStackEmpty, bool isCall) - : m_offset(offset), m_isStackEmpty(isStackEmpty), m_isCall(isCall) + : m_offset(offset) + , m_isStackEmpty(isStackEmpty) + , m_isCall(isCall) { } @@ -63,16 +70,23 @@ class ILLocation private: IL_OFFSET m_offset; bool m_isStackEmpty : 1; - bool m_isCall : 1; + bool m_isCall : 1; }; // Represents debug information about a statement. class DebugInfo { public: - DebugInfo() : m_inlineContext(nullptr) {} + DebugInfo() + : m_inlineContext(nullptr) + { + } - DebugInfo(InlineContext* inlineContext, ILLocation loc) : m_inlineContext(inlineContext), m_location(loc) {} + DebugInfo(InlineContext* inlineContext, ILLocation loc) + : m_inlineContext(inlineContext) + , m_location(loc) + { + } InlineContext* GetInlineContext() const { @@ -97,7 +111,9 @@ class DebugInfo #ifdef DEBUG void Validate() const; #else - void Validate() const {} + void Validate() const + { + } #endif #ifdef DEBUG diff --git a/src/coreclr/jit/decomposelongs.h b/src/coreclr/jit/decomposelongs.h index 597c4d6b5e3789..744061091e42be 100644 --- a/src/coreclr/jit/decomposelongs.h +++ b/src/coreclr/jit/decomposelongs.h @@ -18,7 +18,10 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX class DecomposeLongs { public: - DecomposeLongs(Compiler* compiler) : m_compiler(compiler) {} + DecomposeLongs(Compiler* compiler) + : m_compiler(compiler) + { + } void PrepareForDecomposition(); void DecomposeBlock(BasicBlock* block); diff --git a/src/coreclr/jit/disasm.cpp b/src/coreclr/jit/disasm.cpp index 02dfc3cadd977a..bff93c85150a68 100644 --- a/src/coreclr/jit/disasm.cpp +++ b/src/coreclr/jit/disasm.cpp @@ -1737,8 +1737,7 @@ void DisAssembler::DisasmBuffer(FILE* pfile, bool printit) unsigned errorCount = 0; static const unsigned maxErrorCount = 50; - auto disasmRegion = [&](size_t executionAddress, size_t blockAddress, size_t blockSize) - { + auto disasmRegion = [&](size_t executionAddress, size_t blockAddress, size_t blockSize) { uint8_t* address = (uint8_t*)executionAddress; uint8_t* codeBytes = (uint8_t*)blockAddress; size_t codeSizeBytes = blockSize; diff --git a/src/coreclr/jit/ee_il_dll.cpp b/src/coreclr/jit/ee_il_dll.cpp index 8d7f8f4f9baf79..b33e6eed17bbc3 100644 --- a/src/coreclr/jit/ee_il_dll.cpp +++ b/src/coreclr/jit/ee_il_dll.cpp @@ -211,7 +211,9 @@ void SetJitTls(void* value) #if defined(DEBUG) -JitTls::JitTls(ICorJitInfo* jitInfo) : m_compiler(nullptr), m_logEnv(jitInfo) +JitTls::JitTls(ICorJitInfo* jitInfo) + : m_compiler(nullptr) + , m_logEnv(jitInfo) { m_next = reinterpret_cast(GetJitTls()); SetJitTls(this); @@ -239,9 +241,13 @@ void JitTls::SetCompiler(Compiler* compiler) #else // !defined(DEBUG) -JitTls::JitTls(ICorJitInfo* jitInfo) {} +JitTls::JitTls(ICorJitInfo* jitInfo) +{ +} -JitTls::~JitTls() {} +JitTls::~JitTls() +{ +} Compiler* JitTls::GetCompiler() { @@ -1403,7 +1409,9 @@ bool Compiler::eeRunWithSPMIErrorTrapImp(void (*function)(void*), void* param) unsigned Compiler::eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd) { unsigned classSize = UINT_MAX; - eeRunFunctorWithSPMIErrorTrap([&]() { classSize = info.compCompHnd->getClassSize(clsHnd); }); + eeRunFunctorWithSPMIErrorTrap([&]() { + classSize = info.compCompHnd->getClassSize(clsHnd); + }); return classSize; } diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 6536eac8650c45..a6552c2194294c 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -156,8 +156,9 @@ void Compiler::eePrintType(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, return; } - eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) - { return info.compCompHnd->printClassName(clsHnd, buffer, bufferSize, requiredBufferSize); }); + eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { + return info.compCompHnd->printClassName(clsHnd, buffer, bufferSize, requiredBufferSize); + }); if (!includeInstantiation) { @@ -209,7 +210,7 @@ void Compiler::eePrintTypeOrJitAlias(StringPrinter* printer, CORINFO_CLASS_HANDL } static const char* s_jitHelperNames[CORINFO_HELP_COUNT] = { -#define JITHELPER(code, pfnHelper, sig) #code, +#define JITHELPER(code, pfnHelper, sig) #code, #define DYNAMICJITHELPER(code, pfnHelper, sig) #code, #include "jithelpers.h" }; @@ -254,8 +255,9 @@ void Compiler::eePrintMethod(StringPrinter* printer, printer->Append(':'); } - eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) - { return info.compCompHnd->printMethodName(methHnd, buffer, bufferSize, requiredBufferSize); }); + eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { + return info.compCompHnd->printMethodName(methHnd, buffer, bufferSize, requiredBufferSize); + }); if (includeMethodInstantiation && (sig->sigInst.methInstCount > 0)) { @@ -362,8 +364,9 @@ void Compiler::eePrintField(StringPrinter* printer, CORINFO_FIELD_HANDLE fld, bo printer->Append(':'); } - eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) - { return info.compCompHnd->printFieldName(fld, buffer, bufferSize, requiredBufferSize); }); + eeAppendPrint(printer, [&](char* buffer, size_t bufferSize, size_t* requiredBufferSize) { + return info.compCompHnd->printFieldName(fld, buffer, bufferSize, requiredBufferSize); + }); } //------------------------------------------------------------------------ @@ -395,17 +398,15 @@ const char* Compiler::eeGetMethodFullName( StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); CORINFO_CLASS_HANDLE clsHnd = NO_CLASS_HANDLE; - bool success = eeRunFunctorWithSPMIErrorTrap( - [&]() - { - clsHnd = info.compCompHnd->getMethodClass(hnd); - CORINFO_SIG_INFO sig; - eeGetMethodSig(hnd, &sig); - eePrintMethod(&p, clsHnd, hnd, &sig, - /* includeClassInstantiation */ true, - /* includeMethodInstantiation */ true, - /* includeSignature */ true, includeReturnType, includeThisSpecifier); - }); + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { + clsHnd = info.compCompHnd->getMethodClass(hnd); + CORINFO_SIG_INFO sig; + eeGetMethodSig(hnd, &sig); + eePrintMethod(&p, clsHnd, hnd, &sig, + /* includeClassInstantiation */ true, + /* includeMethodInstantiation */ true, + /* includeSignature */ true, includeReturnType, includeThisSpecifier); + }); if (success) { @@ -415,17 +416,15 @@ const char* Compiler::eeGetMethodFullName( // Try without signature p.Truncate(0); - success = eeRunFunctorWithSPMIErrorTrap( - [&]() - { - eePrintMethod(&p, clsHnd, hnd, - /* sig */ nullptr, - /* includeClassInstantiation */ false, - /* includeMethodInstantiation */ false, - /* includeSignature */ false, - /* includeReturnType */ false, - /* includeThisSpecifier */ false); - }); + success = eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintMethod(&p, clsHnd, hnd, + /* sig */ nullptr, + /* includeClassInstantiation */ false, + /* includeMethodInstantiation */ false, + /* includeSignature */ false, + /* includeReturnType */ false, + /* includeThisSpecifier */ false); + }); if (success) { @@ -435,17 +434,15 @@ const char* Compiler::eeGetMethodFullName( // Try with bare minimum p.Truncate(0); - success = eeRunFunctorWithSPMIErrorTrap( - [&]() - { - eePrintMethod(&p, nullptr, hnd, - /* sig */ nullptr, - /* includeClassInstantiation */ false, - /* includeMethodInstantiation */ false, - /* includeSignature */ false, - /* includeReturnType */ false, - /* includeThisSpecifier */ false); - }); + success = eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintMethod(&p, nullptr, hnd, + /* sig */ nullptr, + /* includeClassInstantiation */ false, + /* includeMethodInstantiation */ false, + /* includeSignature */ false, + /* includeReturnType */ false, + /* includeThisSpecifier */ false); + }); if (success) { @@ -475,17 +472,15 @@ const char* Compiler::eeGetMethodFullName( const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffer, size_t bufferSize) { StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); - bool success = eeRunFunctorWithSPMIErrorTrap( - [&]() - { - eePrintMethod(&p, NO_CLASS_HANDLE, methHnd, - /* sig */ nullptr, - /* includeClassInstantiation */ false, - /* includeMethodInstantiation */ false, - /* includeSignature */ false, - /* includeReturnType */ false, - /* includeThisSpecifier */ false); - }); + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintMethod(&p, NO_CLASS_HANDLE, methHnd, + /* sig */ nullptr, + /* includeClassInstantiation */ false, + /* includeMethodInstantiation */ false, + /* includeSignature */ false, + /* includeReturnType */ false, + /* includeThisSpecifier */ false); + }); if (!success) { @@ -515,7 +510,9 @@ const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffe const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE fldHnd, bool includeType, char* buffer, size_t bufferSize) { StringPrinter p(getAllocator(CMK_DebugOnly), buffer, bufferSize); - bool success = eeRunFunctorWithSPMIErrorTrap([&]() { eePrintField(&p, fldHnd, includeType); }); + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintField(&p, fldHnd, includeType); + }); if (success) { @@ -528,7 +525,9 @@ const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE fldHnd, bool includeTy { p.Append(":"); - success = eeRunFunctorWithSPMIErrorTrap([&]() { eePrintField(&p, fldHnd, false); }); + success = eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintField(&p, fldHnd, false); + }); if (success) { @@ -563,7 +562,9 @@ const char* Compiler::eeGetFieldName(CORINFO_FIELD_HANDLE fldHnd, bool includeTy const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer, size_t bufferSize) { StringPrinter printer(getAllocator(CMK_DebugOnly), buffer, bufferSize); - if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, true); })) + if (!eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintType(&printer, clsHnd, true); + })) { printer.Truncate(0); printer.Append(""); @@ -584,7 +585,9 @@ const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd, char* buffer, const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd) { StringPrinter printer(getAllocator(CMK_DebugOnly)); - if (!eeRunFunctorWithSPMIErrorTrap([&]() { eePrintType(&printer, clsHnd, false); })) + if (!eeRunFunctorWithSPMIErrorTrap([&]() { + eePrintType(&printer, clsHnd, false); + })) { printer.Truncate(0); printer.Append(""); @@ -600,8 +603,9 @@ void Compiler::eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDL size_t actualLen = 0; // Ignore potential SPMI failures - bool success = eeRunFunctorWithSPMIErrorTrap( - [&]() { actualLen = this->info.compCompHnd->printObjectDescription(handle, str, maxStrSize); }); + bool success = eeRunFunctorWithSPMIErrorTrap([&]() { + actualLen = this->info.compCompHnd->printObjectDescription(handle, str, maxStrSize); + }); if (!success) { diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index a2a6cb15adc6e5..6b6b96b0265460 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -613,14 +613,18 @@ const unsigned short emitTypeActSz[] = { * Initialize the emitter - called once, at DLL load time. */ -void emitter::emitInit() {} +void emitter::emitInit() +{ +} /***************************************************************************** * * Shut down the emitter - called once, at DLL exit time. */ -void emitter::emitDone() {} +void emitter::emitDone() +{ +} /***************************************************************************** * @@ -755,7 +759,9 @@ void emitter::emitBegCG(Compiler* comp, COMP_HANDLE cmpHandle) #endif // TARGET_XARCH } -void emitter::emitEndCG() {} +void emitter::emitEndCG() +{ +} /***************************************************************************** * @@ -1363,7 +1369,9 @@ int emitter::emitNextRandomNop() * Done generating code to be scheduled; called once per method. */ -void emitter::emitEndFN() {} +void emitter::emitEndFN() +{ +} // member function iiaIsJitDataOffset for idAddrUnion, defers to Compiler::eeIsJitDataOffs bool emitter::instrDesc::idAddrUnion::iiaIsJitDataOffset() const @@ -2689,7 +2697,9 @@ void emitter::emitSetFrameRangeGCRs(int offsLo, int offsHi) * method. */ -void emitter::emitSetFrameRangeLcls(int offsLo, int offsHi) {} +void emitter::emitSetFrameRangeLcls(int offsLo, int offsHi) +{ +} /***************************************************************************** * @@ -2697,7 +2707,9 @@ void emitter::emitSetFrameRangeLcls(int offsLo, int offsHi) {} * method. */ -void emitter::emitSetFrameRangeArgs(int offsLo, int offsHi) {} +void emitter::emitSetFrameRangeArgs(int offsLo, int offsHi) +{ +} /***************************************************************************** * @@ -3036,8 +3048,7 @@ void emitter::emitSplit(emitLocation* startLoc, UNATIVE_OFFSET curSize; UNATIVE_OFFSET candidateSize; - auto splitIfNecessary = [&]() - { + auto splitIfNecessary = [&]() { if (curSize < maxSplitSize) { return; diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index fa7c53b21572af..094720597ead70 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -129,9 +129,17 @@ inline const char* GCtypeStr(GCtype gcType) class emitLocation { public: - emitLocation() : ig(nullptr), codePos(0) {} + emitLocation() + : ig(nullptr) + , codePos(0) + { + } - emitLocation(insGroup* _ig) : ig(_ig), codePos(0) {} + emitLocation(insGroup* _ig) + : ig(_ig) + , codePos(0) + { + } emitLocation(insGroup* _ig, unsigned _codePos) { @@ -143,7 +151,11 @@ class emitLocation CaptureLocation(emit); } - emitLocation(void* emitCookie) : ig((insGroup*)emitCookie), codePos(0) {} + emitLocation(void* emitCookie) + : ig((insGroup*)emitCookie) + , codePos(0) + { + } // A constructor for code that needs to call it explicitly. void Init() @@ -280,14 +292,14 @@ struct insGroup insGroup* igLoopBackEdge; // "last" back-edge that branches back to an aligned loop head. #endif -#define IGF_GC_VARS 0x0001 // new set of live GC ref variables -#define IGF_BYREF_REGS 0x0002 // new set of live by-ref registers +#define IGF_GC_VARS 0x0001 // new set of live GC ref variables +#define IGF_BYREF_REGS 0x0002 // new set of live by-ref registers #define IGF_FUNCLET_PROLOG 0x0004 // this group belongs to a funclet prolog #define IGF_FUNCLET_EPILOG 0x0008 // this group belongs to a funclet epilog. -#define IGF_EPILOG 0x0010 // this group belongs to a main function epilog -#define IGF_NOGCINTERRUPT 0x0020 // this IG is in a no-interrupt region (prolog, epilog, etc.) -#define IGF_UPD_ISZ 0x0040 // some instruction sizes updated -#define IGF_PLACEHOLDER 0x0080 // this is a placeholder group, to be filled in later +#define IGF_EPILOG 0x0010 // this group belongs to a main function epilog +#define IGF_NOGCINTERRUPT 0x0020 // this IG is in a no-interrupt region (prolog, epilog, etc.) +#define IGF_UPD_ISZ 0x0040 // some instruction sizes updated +#define IGF_PLACEHOLDER 0x0080 // this is a placeholder group, to be filled in later #define IGF_EXTEND \ 0x0100 // this block is conceptually an extension of the previous block // and the emitter should continue to track GC info as if there was no new block. @@ -426,8 +438,8 @@ struct emitLclVarAddr // protected: unsigned _lvaVarNum : 15; // Usually the lvaVarNum - unsigned _lvaExtra : 15; // Usually the lvaOffset - unsigned _lvaTag : 2; // tag field to support larger varnums + unsigned _lvaExtra : 15; // Usually the lvaOffset + unsigned _lvaTag : 2; // tag field to support larger varnums }; enum idAddrUnionTag @@ -568,10 +580,10 @@ class emitter #ifdef TARGET_XARCH -#define AM_DISP_BITS ((sizeof(unsigned) * 8) - 2 * (REGNUM_BITS + 1) - 2) +#define AM_DISP_BITS ((sizeof(unsigned) * 8) - 2 * (REGNUM_BITS + 1) - 2) #define AM_DISP_BIG_VAL (-(1 << (AM_DISP_BITS - 1))) -#define AM_DISP_MIN (-((1 << (AM_DISP_BITS - 1)) - 1)) -#define AM_DISP_MAX (+((1 << (AM_DISP_BITS - 1)) - 1)) +#define AM_DISP_MIN (-((1 << (AM_DISP_BITS - 1)) - 1)) +#define AM_DISP_MAX (+((1 << (AM_DISP_BITS - 1)) - 1)) struct emitAddrMode { @@ -679,7 +691,9 @@ class emitter { // not used for LOONGARCH64. return (insFormat)0; } - void idInsFmt(insFormat insFmt) {} + void idInsFmt(insFormat insFmt) + { + } #elif defined(TARGET_RISCV64) insFormat idInsFmt() const { @@ -717,7 +731,7 @@ class emitter private: #if defined(TARGET_XARCH) unsigned _idCodeSize : 4; // size of instruction in bytes. Max size of an Intel instruction is 15 bytes. - opSize _idOpSize : 3; // operand size: 0=1 , 1=2 , 2=4 , 3=8, 4=16, 5=32 + opSize _idOpSize : 3; // operand size: 0=1 , 1=2 , 2=4 , 3=8, 4=16, 5=32 // At this point we have fully consumed first DWORD so that next field // doesn't cross a byte boundary. #elif defined(TARGET_ARM64) @@ -759,9 +773,9 @@ class emitter // loongarch64: 28 bits // risc-v: 28 bits - unsigned _idSmallDsc : 1; // is this a "small" descriptor? - unsigned _idLargeCns : 1; // does a large constant follow? - unsigned _idLargeDsp : 1; // does a large displacement follow? + unsigned _idSmallDsc : 1; // is this a "small" descriptor? + unsigned _idLargeCns : 1; // does a large constant follow? + unsigned _idLargeDsp : 1; // does a large displacement follow? unsigned _idLargeCall : 1; // large call descriptor used // We have several pieces of information we need to encode but which are only applicable @@ -772,15 +786,15 @@ class emitter unsigned _idCustom2 : 1; unsigned _idCustom3 : 1; -#define _idBound _idCustom1 /* jump target / frame offset bound */ -#define _idTlsGD _idCustom2 /* Used to store information related to TLS GD access on linux */ -#define _idNoGC _idCustom3 /* Some helpers don't get recorded in GC tables */ +#define _idBound _idCustom1 /* jump target / frame offset bound */ +#define _idTlsGD _idCustom2 /* Used to store information related to TLS GD access on linux */ +#define _idNoGC _idCustom3 /* Some helpers don't get recorded in GC tables */ #define _idEvexAaaContext (_idCustom3 << 2) | (_idCustom2 << 1) | _idCustom1 /* bits used for the EVEX.aaa context */ #if !defined(TARGET_ARMARCH) unsigned _idCustom4 : 1; -#define _idCallRegPtr _idCustom4 /* IL indirect calls : addr in reg */ +#define _idCallRegPtr _idCustom4 /* IL indirect calls : addr in reg */ #define _idEvexZContext _idCustom4 /* bits used for the EVEX.z context */ #endif // !TARGET_ARMARCH @@ -794,8 +808,8 @@ class emitter #ifdef TARGET_ARM64 - unsigned _idLclVar : 1; // access a local on stack - unsigned _idLclVarPair : 1 // carries information for 2 GC lcl vars. + unsigned _idLclVar : 1; // access a local on stack + unsigned _idLclVarPair : 1 // carries information for 2 GC lcl vars. #endif #ifdef TARGET_LOONGARCH64 @@ -814,11 +828,11 @@ class emitter #endif #ifdef TARGET_ARM - insSize _idInsSize : 2; // size of instruction: 16, 32 or 48 bits - insFlags _idInsFlags : 1; // will this instruction set the flags - unsigned _idLclVar : 1; // access a local on stack + insSize _idInsSize : 2; // size of instruction: 16, 32 or 48 bits + insFlags _idInsFlags : 1; // will this instruction set the flags + unsigned _idLclVar : 1; // access a local on stack unsigned _idLclFPBase : 1; // access a local on stack - SP based offset - insOpts _idInsOpt : 3; // options for Load/Store instructions + insOpts _idInsOpt : 3; // options for Load/Store instructions #endif //////////////////////////////////////////////////////////////////////// @@ -1854,137 +1868,137 @@ class emitter #define PERFSCORE_THROUGHPUT_1C 1.0f // Single Issue -#define PERFSCORE_THROUGHPUT_2C 2.0f // slower - 2 cycles -#define PERFSCORE_THROUGHPUT_3C 3.0f // slower - 3 cycles -#define PERFSCORE_THROUGHPUT_4C 4.0f // slower - 4 cycles -#define PERFSCORE_THROUGHPUT_5C 5.0f // slower - 5 cycles -#define PERFSCORE_THROUGHPUT_6C 6.0f // slower - 6 cycles -#define PERFSCORE_THROUGHPUT_7C 7.0f // slower - 7 cycles -#define PERFSCORE_THROUGHPUT_8C 8.0f // slower - 8 cycles -#define PERFSCORE_THROUGHPUT_9C 9.0f // slower - 9 cycles -#define PERFSCORE_THROUGHPUT_10C 10.0f // slower - 10 cycles -#define PERFSCORE_THROUGHPUT_11C 10.0f // slower - 10 cycles -#define PERFSCORE_THROUGHPUT_13C 13.0f // slower - 13 cycles -#define PERFSCORE_THROUGHPUT_14C 14.0f // slower - 13 cycles -#define PERFSCORE_THROUGHPUT_16C 16.0f // slower - 13 cycles -#define PERFSCORE_THROUGHPUT_19C 19.0f // slower - 19 cycles -#define PERFSCORE_THROUGHPUT_25C 25.0f // slower - 25 cycles -#define PERFSCORE_THROUGHPUT_33C 33.0f // slower - 33 cycles -#define PERFSCORE_THROUGHPUT_50C 50.0f // slower - 50 cycles -#define PERFSCORE_THROUGHPUT_52C 52.0f // slower - 52 cycles -#define PERFSCORE_THROUGHPUT_57C 57.0f // slower - 57 cycles +#define PERFSCORE_THROUGHPUT_2C 2.0f // slower - 2 cycles +#define PERFSCORE_THROUGHPUT_3C 3.0f // slower - 3 cycles +#define PERFSCORE_THROUGHPUT_4C 4.0f // slower - 4 cycles +#define PERFSCORE_THROUGHPUT_5C 5.0f // slower - 5 cycles +#define PERFSCORE_THROUGHPUT_6C 6.0f // slower - 6 cycles +#define PERFSCORE_THROUGHPUT_7C 7.0f // slower - 7 cycles +#define PERFSCORE_THROUGHPUT_8C 8.0f // slower - 8 cycles +#define PERFSCORE_THROUGHPUT_9C 9.0f // slower - 9 cycles +#define PERFSCORE_THROUGHPUT_10C 10.0f // slower - 10 cycles +#define PERFSCORE_THROUGHPUT_11C 10.0f // slower - 10 cycles +#define PERFSCORE_THROUGHPUT_13C 13.0f // slower - 13 cycles +#define PERFSCORE_THROUGHPUT_14C 14.0f // slower - 13 cycles +#define PERFSCORE_THROUGHPUT_16C 16.0f // slower - 13 cycles +#define PERFSCORE_THROUGHPUT_19C 19.0f // slower - 19 cycles +#define PERFSCORE_THROUGHPUT_25C 25.0f // slower - 25 cycles +#define PERFSCORE_THROUGHPUT_33C 33.0f // slower - 33 cycles +#define PERFSCORE_THROUGHPUT_50C 50.0f // slower - 50 cycles +#define PERFSCORE_THROUGHPUT_52C 52.0f // slower - 52 cycles +#define PERFSCORE_THROUGHPUT_57C 57.0f // slower - 57 cycles #define PERFSCORE_THROUGHPUT_140C 140.0f // slower - 140 cycles #define PERFSCORE_LATENCY_ILLEGAL -1024.0f #define PERFSCORE_LATENCY_ZERO 0.0f -#define PERFSCORE_LATENCY_1C 1.0f -#define PERFSCORE_LATENCY_2C 2.0f -#define PERFSCORE_LATENCY_3C 3.0f -#define PERFSCORE_LATENCY_4C 4.0f -#define PERFSCORE_LATENCY_5C 5.0f -#define PERFSCORE_LATENCY_6C 6.0f -#define PERFSCORE_LATENCY_7C 7.0f -#define PERFSCORE_LATENCY_8C 8.0f -#define PERFSCORE_LATENCY_9C 9.0f -#define PERFSCORE_LATENCY_10C 10.0f -#define PERFSCORE_LATENCY_11C 11.0f -#define PERFSCORE_LATENCY_12C 12.0f -#define PERFSCORE_LATENCY_13C 13.0f -#define PERFSCORE_LATENCY_14C 14.0f -#define PERFSCORE_LATENCY_15C 15.0f -#define PERFSCORE_LATENCY_16C 16.0f -#define PERFSCORE_LATENCY_18C 18.0f -#define PERFSCORE_LATENCY_20C 20.0f -#define PERFSCORE_LATENCY_22C 22.0f -#define PERFSCORE_LATENCY_23C 23.0f -#define PERFSCORE_LATENCY_26C 26.0f -#define PERFSCORE_LATENCY_62C 62.0f -#define PERFSCORE_LATENCY_69C 69.0f +#define PERFSCORE_LATENCY_1C 1.0f +#define PERFSCORE_LATENCY_2C 2.0f +#define PERFSCORE_LATENCY_3C 3.0f +#define PERFSCORE_LATENCY_4C 4.0f +#define PERFSCORE_LATENCY_5C 5.0f +#define PERFSCORE_LATENCY_6C 6.0f +#define PERFSCORE_LATENCY_7C 7.0f +#define PERFSCORE_LATENCY_8C 8.0f +#define PERFSCORE_LATENCY_9C 9.0f +#define PERFSCORE_LATENCY_10C 10.0f +#define PERFSCORE_LATENCY_11C 11.0f +#define PERFSCORE_LATENCY_12C 12.0f +#define PERFSCORE_LATENCY_13C 13.0f +#define PERFSCORE_LATENCY_14C 14.0f +#define PERFSCORE_LATENCY_15C 15.0f +#define PERFSCORE_LATENCY_16C 16.0f +#define PERFSCORE_LATENCY_18C 18.0f +#define PERFSCORE_LATENCY_20C 20.0f +#define PERFSCORE_LATENCY_22C 22.0f +#define PERFSCORE_LATENCY_23C 23.0f +#define PERFSCORE_LATENCY_26C 26.0f +#define PERFSCORE_LATENCY_62C 62.0f +#define PERFSCORE_LATENCY_69C 69.0f #define PERFSCORE_LATENCY_140C 140.0f #define PERFSCORE_LATENCY_400C 400.0f // Intel microcode issue with these instructions -#define PERFSCORE_LATENCY_BRANCH_DIRECT 1.0f // cost of an unconditional branch -#define PERFSCORE_LATENCY_BRANCH_COND 2.0f // includes cost of a possible misprediction +#define PERFSCORE_LATENCY_BRANCH_DIRECT 1.0f // cost of an unconditional branch +#define PERFSCORE_LATENCY_BRANCH_COND 2.0f // includes cost of a possible misprediction #define PERFSCORE_LATENCY_BRANCH_INDIRECT 2.0f // includes cost of a possible misprediction #if defined(TARGET_XARCH) // a read,write or modify from stack location, possible def to use latency from L0 cache -#define PERFSCORE_LATENCY_RD_STACK PERFSCORE_LATENCY_2C -#define PERFSCORE_LATENCY_WR_STACK PERFSCORE_LATENCY_2C +#define PERFSCORE_LATENCY_RD_STACK PERFSCORE_LATENCY_2C +#define PERFSCORE_LATENCY_WR_STACK PERFSCORE_LATENCY_2C #define PERFSCORE_LATENCY_RD_WR_STACK PERFSCORE_LATENCY_5C // a read, write or modify from constant location, possible def to use latency from L0 cache -#define PERFSCORE_LATENCY_RD_CONST_ADDR PERFSCORE_LATENCY_2C -#define PERFSCORE_LATENCY_WR_CONST_ADDR PERFSCORE_LATENCY_2C +#define PERFSCORE_LATENCY_RD_CONST_ADDR PERFSCORE_LATENCY_2C +#define PERFSCORE_LATENCY_WR_CONST_ADDR PERFSCORE_LATENCY_2C #define PERFSCORE_LATENCY_RD_WR_CONST_ADDR PERFSCORE_LATENCY_5C // a read, write or modify from memory location, possible def to use latency from L0 or L1 cache // plus an extra cost (of 1.0) for a increased chance of a cache miss -#define PERFSCORE_LATENCY_RD_GENERAL PERFSCORE_LATENCY_3C -#define PERFSCORE_LATENCY_WR_GENERAL PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_RD_GENERAL PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_WR_GENERAL PERFSCORE_LATENCY_3C #define PERFSCORE_LATENCY_RD_WR_GENERAL PERFSCORE_LATENCY_6C #elif defined(TARGET_ARM64) || defined(TARGET_ARM) // a read,write or modify from stack location, possible def to use latency from L0 cache -#define PERFSCORE_LATENCY_RD_STACK PERFSCORE_LATENCY_3C -#define PERFSCORE_LATENCY_WR_STACK PERFSCORE_LATENCY_1C -#define PERFSCORE_LATENCY_RD_WR_STACK PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_RD_STACK PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_WR_STACK PERFSCORE_LATENCY_1C +#define PERFSCORE_LATENCY_RD_WR_STACK PERFSCORE_LATENCY_3C // a read, write or modify from constant location, possible def to use latency from L0 cache -#define PERFSCORE_LATENCY_RD_CONST_ADDR PERFSCORE_LATENCY_3C -#define PERFSCORE_LATENCY_WR_CONST_ADDR PERFSCORE_LATENCY_1C +#define PERFSCORE_LATENCY_RD_CONST_ADDR PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_WR_CONST_ADDR PERFSCORE_LATENCY_1C #define PERFSCORE_LATENCY_RD_WR_CONST_ADDR PERFSCORE_LATENCY_3C // a read, write or modify from memory location, possible def to use latency from L0 or L1 cache // plus an extra cost (of 1.0) for a increased chance of a cache miss -#define PERFSCORE_LATENCY_RD_GENERAL PERFSCORE_LATENCY_4C -#define PERFSCORE_LATENCY_WR_GENERAL PERFSCORE_LATENCY_1C -#define PERFSCORE_LATENCY_RD_WR_GENERAL PERFSCORE_LATENCY_4C +#define PERFSCORE_LATENCY_RD_GENERAL PERFSCORE_LATENCY_4C +#define PERFSCORE_LATENCY_WR_GENERAL PERFSCORE_LATENCY_1C +#define PERFSCORE_LATENCY_RD_WR_GENERAL PERFSCORE_LATENCY_4C #elif defined(TARGET_LOONGARCH64) // a read,write or modify from stack location, possible def to use latency from L0 cache -#define PERFSCORE_LATENCY_RD_STACK PERFSCORE_LATENCY_3C -#define PERFSCORE_LATENCY_WR_STACK PERFSCORE_LATENCY_1C -#define PERFSCORE_LATENCY_RD_WR_STACK PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_RD_STACK PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_WR_STACK PERFSCORE_LATENCY_1C +#define PERFSCORE_LATENCY_RD_WR_STACK PERFSCORE_LATENCY_3C // a read, write or modify from constant location, possible def to use latency from L0 cache -#define PERFSCORE_LATENCY_RD_CONST_ADDR PERFSCORE_LATENCY_3C -#define PERFSCORE_LATENCY_WR_CONST_ADDR PERFSCORE_LATENCY_1C +#define PERFSCORE_LATENCY_RD_CONST_ADDR PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_WR_CONST_ADDR PERFSCORE_LATENCY_1C #define PERFSCORE_LATENCY_RD_WR_CONST_ADDR PERFSCORE_LATENCY_3C // a read, write or modify from memory location, possible def to use latency from L0 or L1 cache // plus an extra cost (of 1.0) for a increased chance of a cache miss -#define PERFSCORE_LATENCY_RD_GENERAL PERFSCORE_LATENCY_4C -#define PERFSCORE_LATENCY_WR_GENERAL PERFSCORE_LATENCY_1C -#define PERFSCORE_LATENCY_RD_WR_GENERAL PERFSCORE_LATENCY_4C +#define PERFSCORE_LATENCY_RD_GENERAL PERFSCORE_LATENCY_4C +#define PERFSCORE_LATENCY_WR_GENERAL PERFSCORE_LATENCY_1C +#define PERFSCORE_LATENCY_RD_WR_GENERAL PERFSCORE_LATENCY_4C #elif defined(TARGET_RISCV64) // a read,write or modify from stack location, possible def to use latency from L0 cache -#define PERFSCORE_LATENCY_RD_STACK PERFSCORE_LATENCY_3C -#define PERFSCORE_LATENCY_WR_STACK PERFSCORE_LATENCY_1C -#define PERFSCORE_LATENCY_RD_WR_STACK PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_RD_STACK PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_WR_STACK PERFSCORE_LATENCY_1C +#define PERFSCORE_LATENCY_RD_WR_STACK PERFSCORE_LATENCY_3C // a read, write or modify from constant location, possible def to use latency from L0 cache -#define PERFSCORE_LATENCY_RD_CONST_ADDR PERFSCORE_LATENCY_3C -#define PERFSCORE_LATENCY_WR_CONST_ADDR PERFSCORE_LATENCY_1C +#define PERFSCORE_LATENCY_RD_CONST_ADDR PERFSCORE_LATENCY_3C +#define PERFSCORE_LATENCY_WR_CONST_ADDR PERFSCORE_LATENCY_1C #define PERFSCORE_LATENCY_RD_WR_CONST_ADDR PERFSCORE_LATENCY_3C // a read, write or modify from memory location, possible def to use latency from L0 or L1 cache // plus an extra cost (of 1.0) for a increased chance of a cache miss -#define PERFSCORE_LATENCY_RD_GENERAL PERFSCORE_LATENCY_4C -#define PERFSCORE_LATENCY_WR_GENERAL PERFSCORE_LATENCY_1C -#define PERFSCORE_LATENCY_RD_WR_GENERAL PERFSCORE_LATENCY_4C +#define PERFSCORE_LATENCY_RD_GENERAL PERFSCORE_LATENCY_4C +#define PERFSCORE_LATENCY_WR_GENERAL PERFSCORE_LATENCY_1C +#define PERFSCORE_LATENCY_RD_WR_GENERAL PERFSCORE_LATENCY_4C #endif // TARGET_XXX // Make this an enum: // -#define PERFSCORE_MEMORY_NONE 0 -#define PERFSCORE_MEMORY_READ 1 -#define PERFSCORE_MEMORY_WRITE 2 +#define PERFSCORE_MEMORY_NONE 0 +#define PERFSCORE_MEMORY_READ 1 +#define PERFSCORE_MEMORY_WRITE 2 #define PERFSCORE_MEMORY_READ_WRITE 3 struct insExecutionCharacteristics @@ -2041,7 +2055,7 @@ class emitter #else 30; #endif - unsigned idjShort : 1; // is the jump known to be a short one? + unsigned idjShort : 1; // is the jump known to be a short one? unsigned idjKeepLong : 1; // should the jump be kept long? (used for hot to cold and cold to hot jumps) }; @@ -2182,7 +2196,9 @@ class emitter alignas(alignof(T)) char idStorage[sizeof(T)]; public: - inlineInstrDesc() : idDebugInfo(nullptr), idStorage() + inlineInstrDesc() + : idDebugInfo(nullptr) + , idStorage() { static_assert_no_msg((offsetof(inlineInstrDesc, idStorage) - sizeof(instrDescDebugInfo*)) == offsetof(inlineInstrDesc, idDebugInfo)); @@ -2323,7 +2339,11 @@ class emitter EpilogList* elNext; emitLocation elLoc; - EpilogList() : elNext(nullptr), elLoc() {} + EpilogList() + : elNext(nullptr) + , elLoc() + { + } }; EpilogList* emitEpilogList; // per method epilog list - head @@ -3272,7 +3292,13 @@ class emitter UNATIVE_OFFSET dsdOffs; UNATIVE_OFFSET alignment; // in bytes, defaults to 4 - dataSecDsc() : dsdList(nullptr), dsdLast(nullptr), dsdOffs(0), alignment(4) {} + dataSecDsc() + : dsdList(nullptr) + , dsdLast(nullptr) + , dsdOffs(0) + , alignment(4) + { + } }; dataSecDsc emitConsDsc; diff --git a/src/coreclr/jit/emitarm.cpp b/src/coreclr/jit/emitarm.cpp index 52453dca5657ad..4dd1d470887a20 100644 --- a/src/coreclr/jit/emitarm.cpp +++ b/src/coreclr/jit/emitarm.cpp @@ -700,8 +700,8 @@ emitter::insFormat emitter::emitInsFormat(instruction ins) } // INST_FP is 1 -#define LD 2 -#define ST 4 +#define LD 2 +#define ST 4 #define CMP 8 // clang-format off diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index c02f665a1e6c05..a9a63fe62221a7 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -1471,8 +1471,8 @@ emitter::insFormat emitter::emitInsFormat(instruction ins) return insFormats[ins]; } -#define LD 1 -#define ST 2 +#define LD 1 +#define ST 2 #define CMP 4 #define RSH 8 #define WID 16 diff --git a/src/coreclr/jit/emitarm64.h b/src/coreclr/jit/emitarm64.h index 2d08ba87880a3b..cc3254c06810ab 100644 --- a/src/coreclr/jit/emitarm64.h +++ b/src/coreclr/jit/emitarm64.h @@ -242,7 +242,7 @@ union halfwordImm struct { unsigned immVal : 16; // bits 0..15 - unsigned immHW : 2; // bits 16..17 + unsigned immHW : 2; // bits 16..17 }; unsigned immHWVal; // concat HW:Val forming a 18-bit unsigned immediate }; @@ -265,8 +265,8 @@ union byteShiftedImm { struct { - unsigned immVal : 8; // bits 0..7 - unsigned immBY : 2; // bits 8..9 + unsigned immVal : 8; // bits 0..7 + unsigned immBY : 2; // bits 8..9 unsigned immOnes : 1; // bit 10 }; unsigned immBSVal; // concat Ones:BY:Val forming a 10-bit unsigned immediate @@ -291,7 +291,7 @@ union floatImm8 struct { unsigned immMant : 4; // bits 0..3 - unsigned immExp : 3; // bits 4..6 + unsigned immExp : 3; // bits 4..6 unsigned immSign : 1; // bits 7 }; unsigned immFPIVal; // concat Sign:Exp:Mant forming an 8-bit unsigned immediate @@ -332,9 +332,9 @@ union condFlagsImm { struct { - insCond cond : 4; // bits 0..3 + insCond cond : 4; // bits 0..3 insCflags flags : 4; // bits 4..7 - unsigned imm5 : 5; // bits 8..12 + unsigned imm5 : 5; // bits 8..12 }; unsigned immCFVal; // concat imm5:flags:cond forming an 13-bit unsigned immediate }; diff --git a/src/coreclr/jit/emitriscv64.cpp b/src/coreclr/jit/emitriscv64.cpp index e0aef5af4a954e..525d5e5274ba74 100644 --- a/src/coreclr/jit/emitriscv64.cpp +++ b/src/coreclr/jit/emitriscv64.cpp @@ -1710,8 +1710,7 @@ void emitter::emitJumpDistBind() #if DEBUG_EMIT auto printJmpInfo = [this](const instrDescJmp* jmp, const insGroup* jmpIG, NATIVE_OFFSET extra, UNATIVE_OFFSET srcInstrOffs, UNATIVE_OFFSET srcEncodingOffs, UNATIVE_OFFSET dstOffs, - NATIVE_OFFSET jmpDist, const char* direction) - { + NATIVE_OFFSET jmpDist, const char* direction) { assert(jmp->idDebugOnlyInfo() != nullptr); if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0) { diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 37170e54070550..e356ab8b3d1132 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -567,52 +567,50 @@ bool emitter::AreUpperBitsZero(regNumber reg, emitAttr size) bool result = false; - emitPeepholeIterateLastInstrs( - [&](instrDesc* id) + emitPeepholeIterateLastInstrs([&](instrDesc* id) { + if (emitIsInstrWritingToReg(id, reg)) { - if (emitIsInstrWritingToReg(id, reg)) + switch (id->idIns()) { - switch (id->idIns()) - { - // Conservative. - case INS_call: - return PEEPHOLE_ABORT; - - // These instructions sign-extend. - case INS_cwde: - case INS_cdq: - case INS_movsx: - case INS_movsxd: - return PEEPHOLE_ABORT; - - case INS_movzx: - if ((size == EA_1BYTE) || (size == EA_2BYTE)) - { - result = (id->idOpSize() <= size); - } - // movzx always zeroes the upper 32 bits. - else if (size == EA_4BYTE) - { - result = true; - } - return PEEPHOLE_ABORT; + // Conservative. + case INS_call: + return PEEPHOLE_ABORT; - default: - break; - } + // These instructions sign-extend. + case INS_cwde: + case INS_cdq: + case INS_movsx: + case INS_movsxd: + return PEEPHOLE_ABORT; - // otherwise rely on operation size. - if (size == EA_4BYTE) - { - result = (id->idOpSize() == EA_4BYTE); - } - return PEEPHOLE_ABORT; + case INS_movzx: + if ((size == EA_1BYTE) || (size == EA_2BYTE)) + { + result = (id->idOpSize() <= size); + } + // movzx always zeroes the upper 32 bits. + else if (size == EA_4BYTE) + { + result = true; + } + return PEEPHOLE_ABORT; + + default: + break; } - else + + // otherwise rely on operation size. + if (size == EA_4BYTE) { - return PEEPHOLE_CONTINUE; + result = (id->idOpSize() == EA_4BYTE); } - }); + return PEEPHOLE_ABORT; + } + else + { + return PEEPHOLE_CONTINUE; + } + }); return result; } @@ -648,41 +646,39 @@ bool emitter::AreUpperBitsSignExtended(regNumber reg, emitAttr size) bool result = false; - emitPeepholeIterateLastInstrs( - [&](instrDesc* id) + emitPeepholeIterateLastInstrs([&](instrDesc* id) { + if (emitIsInstrWritingToReg(id, reg)) { - if (emitIsInstrWritingToReg(id, reg)) + switch (id->idIns()) { - switch (id->idIns()) - { - // Conservative. - case INS_call: - return PEEPHOLE_ABORT; - - case INS_movsx: - case INS_movsxd: - if ((size == EA_1BYTE) || (size == EA_2BYTE)) - { - result = (id->idOpSize() <= size); - } - // movsx/movsxd always sign extends to 8 bytes. W-bit is set. - else if (size == EA_4BYTE) - { - result = true; - } - break; + // Conservative. + case INS_call: + return PEEPHOLE_ABORT; - default: - break; - } + case INS_movsx: + case INS_movsxd: + if ((size == EA_1BYTE) || (size == EA_2BYTE)) + { + result = (id->idOpSize() <= size); + } + // movsx/movsxd always sign extends to 8 bytes. W-bit is set. + else if (size == EA_4BYTE) + { + result = true; + } + break; - return PEEPHOLE_ABORT; - } - else - { - return PEEPHOLE_CONTINUE; + default: + break; } - }); + + return PEEPHOLE_ABORT; + } + else + { + return PEEPHOLE_CONTINUE; + } + }); return result; } @@ -893,43 +889,41 @@ bool emitter::IsRedundantCmp(emitAttr size, regNumber reg1, regNumber reg2) bool result = false; - emitPeepholeIterateLastInstrs( - [&](instrDesc* id) - { - instruction ins = id->idIns(); + emitPeepholeIterateLastInstrs([&](instrDesc* id) { + instruction ins = id->idIns(); - switch (ins) + switch (ins) + { + case INS_cmp: { - case INS_cmp: - { - // We only care about 'cmp reg, reg'. - if (id->idInsFmt() != IF_RRD_RRD) - return PEEPHOLE_ABORT; - - if ((id->idReg1() == reg1) && (id->idReg2() == reg2)) - { - result = (size == id->idOpSize()); - } - + // We only care about 'cmp reg, reg'. + if (id->idInsFmt() != IF_RRD_RRD) return PEEPHOLE_ABORT; - } - default: - break; - } + if ((id->idReg1() == reg1) && (id->idReg2() == reg2)) + { + result = (size == id->idOpSize()); + } - if (emitDoesInsModifyFlags(ins)) - { return PEEPHOLE_ABORT; } - if (emitIsInstrWritingToReg(id, reg1) || emitIsInstrWritingToReg(id, reg2)) - { - return PEEPHOLE_ABORT; - } + default: + break; + } - return PEEPHOLE_CONTINUE; - }); + if (emitDoesInsModifyFlags(ins)) + { + return PEEPHOLE_ABORT; + } + + if (emitIsInstrWritingToReg(id, reg1) || emitIsInstrWritingToReg(id, reg2)) + { + return PEEPHOLE_ABORT; + } + + return PEEPHOLE_CONTINUE; + }); return result; } @@ -1293,10 +1287,10 @@ bool emitter::TakesEvexPrefix(const instrDesc* id) const #define DEFAULT_BYTE_EVEX_PREFIX 0x62F07C0800000000ULL #define DEFAULT_BYTE_EVEX_PREFIX_MASK 0xFFFFFFFF00000000ULL -#define BBIT_IN_BYTE_EVEX_PREFIX 0x0000001000000000ULL -#define LBIT_IN_BYTE_EVEX_PREFIX 0x0000002000000000ULL +#define BBIT_IN_BYTE_EVEX_PREFIX 0x0000001000000000ULL +#define LBIT_IN_BYTE_EVEX_PREFIX 0x0000002000000000ULL #define LPRIMEBIT_IN_BYTE_EVEX_PREFIX 0x0000004000000000ULL -#define ZBIT_IN_BYTE_EVEX_PREFIX 0x0000008000000000ULL +#define ZBIT_IN_BYTE_EVEX_PREFIX 0x0000008000000000ULL //------------------------------------------------------------------------ // AddEvexPrefix: Add default EVEX prefix with only LL' bits set. @@ -1466,9 +1460,9 @@ bool emitter::TakesVexPrefix(instruction ins) const // 01 - 66 (66 0F - packed double) // 10 - F3 (F3 0F - scalar float // 11 - F2 (F2 0F - scalar double) -#define DEFAULT_3BYTE_VEX_PREFIX 0xC4E07800000000ULL +#define DEFAULT_3BYTE_VEX_PREFIX 0xC4E07800000000ULL #define DEFAULT_3BYTE_VEX_PREFIX_MASK 0xFFFFFF00000000ULL -#define LBIT_IN_3BYTE_VEX_PREFIX 0x00000400000000ULL +#define LBIT_IN_3BYTE_VEX_PREFIX 0x00000400000000ULL emitter::code_t emitter::AddVexPrefix(instruction ins, code_t code, emitAttr attr) { // The 2-byte VEX encoding is preferred when possible, but actually emitting diff --git a/src/coreclr/jit/emitxarch.h b/src/coreclr/jit/emitxarch.h index e83efd96dca03b..e32cab66254fe8 100644 --- a/src/coreclr/jit/emitxarch.h +++ b/src/coreclr/jit/emitxarch.h @@ -562,8 +562,12 @@ bool emitVerifyEncodable(instruction ins, emitAttr size, regNumber reg1, regNumb bool emitInsCanOnlyWriteSSE2OrAVXReg(instrDesc* id); #if FEATURE_FIXED_OUT_ARGS -void emitAdjustStackDepthPushPop(instruction ins) {} -void emitAdjustStackDepth(instruction ins, ssize_t val) {} +void emitAdjustStackDepthPushPop(instruction ins) +{ +} +void emitAdjustStackDepth(instruction ins, ssize_t val) +{ +} #else // !FEATURE_FIXED_OUT_ARGS void emitAdjustStackDepthPushPop(instruction ins); void emitAdjustStackDepth(instruction ins, ssize_t val); diff --git a/src/coreclr/jit/error.cpp b/src/coreclr/jit/error.cpp index dd49ad56131ae5..5ae6cea056efeb 100644 --- a/src/coreclr/jit/error.cpp +++ b/src/coreclr/jit/error.cpp @@ -250,7 +250,11 @@ void debugError(const char* msg, const char* file, unsigned line) } /*****************************************************************************/ -LogEnv::LogEnv(ICorJitInfo* aCompHnd) : compHnd(aCompHnd), compiler(nullptr) {} +LogEnv::LogEnv(ICorJitInfo* aCompHnd) + : compHnd(aCompHnd) + , compiler(nullptr) +{ +} /*****************************************************************************/ extern "C" void __cdecl assertAbort(const char* why, const char* file, unsigned line) diff --git a/src/coreclr/jit/fgbasic.cpp b/src/coreclr/jit/fgbasic.cpp index b3b8c0bd1ded0b..a650ae437fccc6 100644 --- a/src/coreclr/jit/fgbasic.cpp +++ b/src/coreclr/jit/fgbasic.cpp @@ -899,7 +899,10 @@ BasicBlock* Compiler::fgLookupBB(unsigned addr) class FgStack { public: - FgStack() : slot0(SLOT_INVALID), slot1(SLOT_INVALID), depth(0) + FgStack() + : slot0(SLOT_INVALID) + , slot1(SLOT_INVALID) + , depth(0) { // Empty } diff --git a/src/coreclr/jit/fgdiagnostic.cpp b/src/coreclr/jit/fgdiagnostic.cpp index d038a2204a4781..e2af55f45ac820 100644 --- a/src/coreclr/jit/fgdiagnostic.cpp +++ b/src/coreclr/jit/fgdiagnostic.cpp @@ -546,7 +546,7 @@ FILE* Compiler::fgOpenFlowGraphFile(bool* wbDontClose, Phases phase, PhasePositi ONE_FILE_PER_METHOD:; -#define FILENAME_PATTERN "%s-%s-%s-%s.%s" +#define FILENAME_PATTERN "%s-%s-%s-%s.%s" #define FILENAME_PATTERN_WITH_NUMBER "%s-%s-%s-%s~%d.%s" const size_t MaxFileNameLength = MAX_PATH_FNAME - 20 /* give us some extra buffer */; @@ -1249,7 +1249,10 @@ bool Compiler::fgDumpFlowGraph(Phases phase, PhasePosition pos) public: RegionGraph(Compiler* comp, unsigned* blkMap, unsigned blkMapSize) - : m_comp(comp), m_rgnRoot(nullptr), m_blkMap(blkMap), m_blkMapSize(blkMapSize) + : m_comp(comp) + , m_rgnRoot(nullptr) + , m_blkMap(blkMap) + , m_blkMapSize(blkMapSize) { // Create a root region that encompasses the whole function. m_rgnRoot = @@ -1758,31 +1761,29 @@ void Compiler::fgDumpFlowGraphLoops(FILE* file) fprintf(m_file, "%*scolor = blue;\n", m_indent, ""); fprintf(m_file, "%*s", m_indent, ""); - loop->VisitLoopBlocksReversePostOrder( - [=](BasicBlock* block) + loop->VisitLoopBlocksReversePostOrder([=](BasicBlock* block) { + if (BitVecOps::IsMember(&m_traits, m_outputBlocks, block->bbPostorderNum)) { - if (BitVecOps::IsMember(&m_traits, m_outputBlocks, block->bbPostorderNum)) - { - return BasicBlockVisit::Continue; - } + return BasicBlockVisit::Continue; + } - if (block != loop->GetHeader()) + if (block != loop->GetHeader()) + { + FlowGraphNaturalLoop* childLoop = m_loops->GetLoopByHeader(block); + if (childLoop != nullptr) { - FlowGraphNaturalLoop* childLoop = m_loops->GetLoopByHeader(block); - if (childLoop != nullptr) - { - fprintf(m_file, "\n"); - Output(childLoop); - fprintf(m_file, "\n%*s", m_indent, ""); - return BasicBlockVisit::Continue; - } + fprintf(m_file, "\n"); + Output(childLoop); + fprintf(m_file, "\n%*s", m_indent, ""); + return BasicBlockVisit::Continue; } + } - fprintf(m_file, FMT_BB ";", block->bbNum); - BitVecOps::AddElemD(&m_traits, m_outputBlocks, block->bbPostorderNum); + fprintf(m_file, FMT_BB ";", block->bbNum); + BitVecOps::AddElemD(&m_traits, m_outputBlocks, block->bbPostorderNum); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); m_indent -= 4; fprintf(m_file, "\n%*s}", m_indent, ""); @@ -1935,8 +1936,7 @@ void Compiler::fgTableDispBasicBlock(const BasicBlock* block, // of the generated string. Note that any computation using `printedBlockWidth` must be done after all // calls to this function. auto dspBlockNum = [printEdgeLikelihoods, terseNext, nextBlock, - &printedBlockWidth](const FlowEdge* e) -> const char* - { + &printedBlockWidth](const FlowEdge* e) -> const char* { static char buffers[3][64]; // static array of 3 to allow 3 concurrent calls in one printf() static int nextBufferIndex = 0; @@ -2645,7 +2645,10 @@ void Compiler::fgStress64RsltMul() class BBPredsChecker { public: - BBPredsChecker(Compiler* compiler) : comp(compiler) {} + BBPredsChecker(Compiler* compiler) + : comp(compiler) + { + } unsigned CheckBBPreds(BasicBlock* block, unsigned curTraversalStamp); @@ -3285,7 +3288,10 @@ void Compiler::fgDebugCheckTypes(GenTree* tree) DoPostOrder = true, }; - NodeTypeValidator(Compiler* comp) : GenTreeVisitor(comp) {} + NodeTypeValidator(Compiler* comp) + : GenTreeVisitor(comp) + { + } fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) const { @@ -3517,14 +3523,12 @@ void Compiler::fgDebugCheckFlags(GenTree* tree, BasicBlock* block) break; } - tree->VisitOperands( - [&](GenTree* operand) -> GenTree::VisitResult - { - fgDebugCheckFlags(operand, block); - expectedFlags |= (operand->gtFlags & GTF_ALL_EFFECT); + tree->VisitOperands([&](GenTree* operand) -> GenTree::VisitResult { + fgDebugCheckFlags(operand, block); + expectedFlags |= (operand->gtFlags & GTF_ALL_EFFECT); - return GenTree::VisitResult::Continue; - }); + return GenTree::VisitResult::Continue; + }); fgDebugCheckFlagsHelper(tree, actualFlags, expectedFlags); } @@ -3734,7 +3738,11 @@ void Compiler::fgDebugCheckLinkedLocals() UseExecutionOrder = true, }; - DebugLocalSequencer(Compiler* comp) : GenTreeVisitor(comp), m_locals(comp->getAllocator(CMK_DebugOnly)) {} + DebugLocalSequencer(Compiler* comp) + : GenTreeVisitor(comp) + , m_locals(comp->getAllocator(CMK_DebugOnly)) + { + } void Sequence(Statement* stmt) { @@ -4013,7 +4021,9 @@ class UniquenessCheckWalker { public: UniquenessCheckWalker(Compiler* comp) - : comp(comp), nodesVecTraits(comp->compGenTreeID, comp), uniqueNodes(BitVecOps::MakeEmpty(&nodesVecTraits)) + : comp(comp) + , nodesVecTraits(comp->compGenTreeID, comp) + , uniqueNodes(BitVecOps::MakeEmpty(&nodesVecTraits)) { } @@ -4131,9 +4141,17 @@ class SsaCheckVisitor : public GenTreeVisitor unsigned m_ssaNum; public: - SsaKey() : m_lclNum(BAD_VAR_NUM), m_ssaNum(SsaConfig::RESERVED_SSA_NUM) {} + SsaKey() + : m_lclNum(BAD_VAR_NUM) + , m_ssaNum(SsaConfig::RESERVED_SSA_NUM) + { + } - SsaKey(unsigned lclNum, unsigned ssaNum) : m_lclNum(lclNum), m_ssaNum(ssaNum) {} + SsaKey(unsigned lclNum, unsigned ssaNum) + : m_lclNum(lclNum) + , m_ssaNum(ssaNum) + { + } static bool Equals(const SsaKey& x, const SsaKey& y) { @@ -4745,15 +4763,13 @@ void Compiler::fgDebugCheckLoops() assert(loop->EntryEdges().size() == 1); assert(loop->EntryEdge(0)->getSourceBlock()->KindIs(BBJ_ALWAYS)); - loop->VisitRegularExitBlocks( - [=](BasicBlock* exit) + loop->VisitRegularExitBlocks([=](BasicBlock* exit) { + for (BasicBlock* pred : exit->PredBlocks()) { - for (BasicBlock* pred : exit->PredBlocks()) - { - assert(loop->ContainsBlock(pred)); - } - return BasicBlockVisit::Continue; - }); + assert(loop->ContainsBlock(pred)); + } + return BasicBlockVisit::Continue; + }); } } } @@ -4770,14 +4786,15 @@ void Compiler::fgDebugCheckFlowGraphAnnotations() return; } - unsigned count = - fgRunDfs([](BasicBlock* block, unsigned preorderNum) { assert(block->bbPreorderNum == preorderNum); }, - [=](BasicBlock* block, unsigned postorderNum) - { - assert(block->bbPostorderNum == postorderNum); - assert(m_dfsTree->GetPostOrder(postorderNum) == block); - }, - [](BasicBlock* block, BasicBlock* succ) {}); + unsigned count = fgRunDfs( + [](BasicBlock* block, unsigned preorderNum) { + assert(block->bbPreorderNum == preorderNum); + }, + [=](BasicBlock* block, unsigned postorderNum) { + assert(block->bbPostorderNum == postorderNum); + assert(m_dfsTree->GetPostOrder(postorderNum) == block); + }, + [](BasicBlock* block, BasicBlock* succ) {}); assert(m_dfsTree->GetPostOrderCount() == count); diff --git a/src/coreclr/jit/fgehopt.cpp b/src/coreclr/jit/fgehopt.cpp index 43849d2dad5c39..0e1ce24c39ed87 100644 --- a/src/coreclr/jit/fgehopt.cpp +++ b/src/coreclr/jit/fgehopt.cpp @@ -1867,9 +1867,17 @@ PhaseStatus Compiler::fgTailMergeThrows() BasicBlock* m_block; GenTreeCall* m_call; - ThrowHelper() : m_block(nullptr), m_call(nullptr) {} + ThrowHelper() + : m_block(nullptr) + , m_call(nullptr) + { + } - ThrowHelper(BasicBlock* block, GenTreeCall* call) : m_block(block), m_call(call) {} + ThrowHelper(BasicBlock* block, GenTreeCall* call) + : m_block(block) + , m_call(call) + { + } static bool Equals(const ThrowHelper& x, const ThrowHelper& y) { diff --git a/src/coreclr/jit/fginline.cpp b/src/coreclr/jit/fginline.cpp index cff786c23922f0..ba5ed96610dd32 100644 --- a/src/coreclr/jit/fginline.cpp +++ b/src/coreclr/jit/fginline.cpp @@ -214,7 +214,10 @@ class SubstitutePlaceholdersAndDevirtualizeWalker : public GenTreeVisitor( - [](Param* pParam) - { - // Init the local var info of the inlinee - pParam->pThis->impInlineInitVars(pParam->inlineInfo); + [](Param* pParam) { + // Init the local var info of the inlinee + pParam->pThis->impInlineInitVars(pParam->inlineInfo); - if (pParam->inlineInfo->inlineResult->IsCandidate()) - { - /* Clear the temp table */ - memset(pParam->inlineInfo->lclTmpNum, -1, sizeof(pParam->inlineInfo->lclTmpNum)); + if (pParam->inlineInfo->inlineResult->IsCandidate()) + { + /* Clear the temp table */ + memset(pParam->inlineInfo->lclTmpNum, -1, sizeof(pParam->inlineInfo->lclTmpNum)); - // - // Prepare the call to jitNativeCode - // + // + // Prepare the call to jitNativeCode + // - pParam->inlineInfo->InlinerCompiler = pParam->pThis; - if (pParam->pThis->impInlineInfo == nullptr) - { - pParam->inlineInfo->InlineRoot = pParam->pThis; - } - else - { - pParam->inlineInfo->InlineRoot = pParam->pThis->impInlineInfo->InlineRoot; - } + pParam->inlineInfo->InlinerCompiler = pParam->pThis; + if (pParam->pThis->impInlineInfo == nullptr) + { + pParam->inlineInfo->InlineRoot = pParam->pThis; + } + else + { + pParam->inlineInfo->InlineRoot = pParam->pThis->impInlineInfo->InlineRoot; + } - // The inline context is part of debug info and must be created - // before we start creating statements; we lazily create it as - // late as possible, which is here. - pParam->inlineInfo->inlineContext = - pParam->inlineInfo->InlineRoot->m_inlineStrategy - ->NewContext(pParam->inlineInfo->inlineCandidateInfo->inlinersContext, - pParam->inlineInfo->iciStmt, pParam->inlineInfo->iciCall); - pParam->inlineInfo->argCnt = pParam->inlineCandidateInfo->methInfo.args.totalILArgs(); - pParam->inlineInfo->tokenLookupContextHandle = pParam->inlineCandidateInfo->exactContextHnd; - - JITLOG_THIS(pParam->pThis, - (LL_INFO100000, "INLINER: inlineInfo.tokenLookupContextHandle for %s set to 0x%p:\n", - pParam->pThis->eeGetMethodFullName(pParam->fncHandle), - pParam->pThis->dspPtr(pParam->inlineInfo->tokenLookupContextHandle))); - - JitFlags compileFlagsForInlinee = *pParam->pThis->opts.jitFlags; - - // The following flags are lost when inlining. - // (This is checked in Compiler::compInitOptions().) - compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_BBINSTR); - compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_BBINSTR_IF_LOOPS); - compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_PROF_ENTERLEAVE); - compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_DEBUG_EnC); - compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_REVERSE_PINVOKE); - compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_TRACK_TRANSITIONS); + // The inline context is part of debug info and must be created + // before we start creating statements; we lazily create it as + // late as possible, which is here. + pParam->inlineInfo->inlineContext = + pParam->inlineInfo->InlineRoot->m_inlineStrategy + ->NewContext(pParam->inlineInfo->inlineCandidateInfo->inlinersContext, pParam->inlineInfo->iciStmt, + pParam->inlineInfo->iciCall); + pParam->inlineInfo->argCnt = pParam->inlineCandidateInfo->methInfo.args.totalILArgs(); + pParam->inlineInfo->tokenLookupContextHandle = pParam->inlineCandidateInfo->exactContextHnd; + + JITLOG_THIS(pParam->pThis, + (LL_INFO100000, "INLINER: inlineInfo.tokenLookupContextHandle for %s set to 0x%p:\n", + pParam->pThis->eeGetMethodFullName(pParam->fncHandle), + pParam->pThis->dspPtr(pParam->inlineInfo->tokenLookupContextHandle))); + + JitFlags compileFlagsForInlinee = *pParam->pThis->opts.jitFlags; + + // The following flags are lost when inlining. + // (This is checked in Compiler::compInitOptions().) + compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_BBINSTR); + compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_BBINSTR_IF_LOOPS); + compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_PROF_ENTERLEAVE); + compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_DEBUG_EnC); + compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_REVERSE_PINVOKE); + compileFlagsForInlinee.Clear(JitFlags::JIT_FLAG_TRACK_TRANSITIONS); #ifdef DEBUG - if (pParam->pThis->verbose) - { - printf("\nInvoking compiler for the inlinee method %s :\n", - pParam->pThis->eeGetMethodFullName(pParam->fncHandle)); - } + if (pParam->pThis->verbose) + { + printf("\nInvoking compiler for the inlinee method %s :\n", + pParam->pThis->eeGetMethodFullName(pParam->fncHandle)); + } #endif // DEBUG - int result = - jitNativeCode(pParam->fncHandle, pParam->inlineCandidateInfo->methInfo.scope, - pParam->pThis->info.compCompHnd, &pParam->inlineCandidateInfo->methInfo, - (void**)pParam->inlineInfo, nullptr, &compileFlagsForInlinee, pParam->inlineInfo); + int result = + jitNativeCode(pParam->fncHandle, pParam->inlineCandidateInfo->methInfo.scope, + pParam->pThis->info.compCompHnd, &pParam->inlineCandidateInfo->methInfo, + (void**)pParam->inlineInfo, nullptr, &compileFlagsForInlinee, pParam->inlineInfo); - if (result != CORJIT_OK) - { - // If we haven't yet determined why this inline fails, use - // a catch-all something bad happened observation. - InlineResult* innerInlineResult = pParam->inlineInfo->inlineResult; + if (result != CORJIT_OK) + { + // If we haven't yet determined why this inline fails, use + // a catch-all something bad happened observation. + InlineResult* innerInlineResult = pParam->inlineInfo->inlineResult; - if (!innerInlineResult->IsFailure()) - { - innerInlineResult->NoteFatal(InlineObservation::CALLSITE_COMPILATION_FAILURE); - } + if (!innerInlineResult->IsFailure()) + { + innerInlineResult->NoteFatal(InlineObservation::CALLSITE_COMPILATION_FAILURE); } } - }, + } + }, ¶m); if (!success) { diff --git a/src/coreclr/jit/fgopt.cpp b/src/coreclr/jit/fgopt.cpp index f2e34c9b6d3561..433a512469816a 100644 --- a/src/coreclr/jit/fgopt.cpp +++ b/src/coreclr/jit/fgopt.cpp @@ -230,8 +230,7 @@ bool Compiler::fgRemoveDeadBlocks() // or not. bool hasUnreachableBlock = false; - auto isBlockRemovable = [&](BasicBlock* block) -> bool - { + auto isBlockRemovable = [&](BasicBlock* block) -> bool { const bool isVisited = BlockSetOps::IsMember(this, visitedBlocks, block->bbNum); const bool isRemovable = !isVisited || (block->bbRefs == 0); @@ -730,9 +729,8 @@ PhaseStatus Compiler::fgPostImportationCleanup() // Helper method to add flow // - auto addConditionalFlow = - [this, entryStateVar, &entryJumpTarget, &addedBlocks](BasicBlock* fromBlock, BasicBlock* toBlock) - { + auto addConditionalFlow = [this, entryStateVar, &entryJumpTarget, &addedBlocks](BasicBlock* fromBlock, + BasicBlock* toBlock) { // We may have previously though this try entry was unreachable, but now we're going to // step through it on the way to the OSR entry. So ensure it has plausible profile weight. // @@ -3141,8 +3139,7 @@ bool Compiler::fgExpandRarelyRunBlocks() // Note this is potentially expensive for large flow graphs and blocks // with lots of predecessors. // - auto newRunRarely = [](BasicBlock* block, BasicBlock* bPrev) - { + auto newRunRarely = [](BasicBlock* block, BasicBlock* bPrev) { // Figure out earliest block that might be impacted BasicBlock* bPrevPrev = nullptr; BasicBlock* tmpbb; @@ -5253,17 +5250,15 @@ PhaseStatus Compiler::fgDfsBlocksAndRemove() while (true) { bool anyCallFinallyPairs = false; - fgRemoveUnreachableBlocks( - [=, &anyCallFinallyPairs](BasicBlock* block) + fgRemoveUnreachableBlocks([=, &anyCallFinallyPairs](BasicBlock* block) { + if (!m_dfsTree->Contains(block)) { - if (!m_dfsTree->Contains(block)) - { - anyCallFinallyPairs |= block->isBBCallFinallyPair(); - return true; - } + anyCallFinallyPairs |= block->isBBCallFinallyPair(); + return true; + } - return false; - }); + return false; + }); if (!anyCallFinallyPairs) { @@ -5370,11 +5365,10 @@ unsigned Compiler::fgMeasureIR() { fgWalkTreePre( stmt->GetRootNodePointer(), - [](GenTree** slot, fgWalkData* data) -> Compiler::fgWalkResult - { - (*reinterpret_cast(data->pCallbackData))++; - return Compiler::WALK_CONTINUE; - }, + [](GenTree** slot, fgWalkData* data) -> Compiler::fgWalkResult { + (*reinterpret_cast(data->pCallbackData))++; + return Compiler::WALK_CONTINUE; + }, &nodeCount); } } @@ -5450,7 +5444,11 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) struct PredInfo { - PredInfo(BasicBlock* block, Statement* stmt) : m_block(block), m_stmt(stmt) {} + PredInfo(BasicBlock* block, Statement* stmt) + : m_block(block) + , m_stmt(stmt) + { + } BasicBlock* m_block; Statement* m_stmt; }; @@ -5463,8 +5461,7 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) // If return value is true, retry. // May also add to retryBlocks. // - auto tailMergePreds = [&](BasicBlock* commSucc) -> bool - { + auto tailMergePreds = [&](BasicBlock* commSucc) -> bool { // Are there enough preds to make it interesting? // if (predInfo.Height() < 2) @@ -5689,8 +5686,7 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) return false; }; - auto tailMerge = [&](BasicBlock* block) -> bool - { + auto tailMerge = [&](BasicBlock* block) -> bool { if (block->countOfInEdges() < 2) { // Nothing to merge here @@ -5755,8 +5751,7 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) return tailMergePreds(block); }; - auto iterateTailMerge = [&](BasicBlock* block) -> void - { + auto iterateTailMerge = [&](BasicBlock* block) -> void { int numOpts = 0; while (tailMerge(block)) @@ -5842,8 +5837,7 @@ bool Compiler::fgTryOneHeadMerge(BasicBlock* block, bool early) } // Verify that both successors are reached along non-critical edges. - auto getSuccCandidate = [=](BasicBlock* succ, Statement** firstStmt) -> bool - { + auto getSuccCandidate = [=](BasicBlock* succ, Statement** firstStmt) -> bool { if (succ->GetUniquePred(this) != block) { return false; @@ -5975,7 +5969,10 @@ bool Compiler::gtTreeContainsTailCall(GenTree* tree) DoPreOrder = true }; - HasTailCallCandidateVisitor(Compiler* comp) : GenTreeVisitor(comp) {} + HasTailCallCandidateVisitor(Compiler* comp) + : GenTreeVisitor(comp) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { diff --git a/src/coreclr/jit/fgprofile.cpp b/src/coreclr/jit/fgprofile.cpp index a9b316b46ecd09..9fa4e7273862a2 100644 --- a/src/coreclr/jit/fgprofile.cpp +++ b/src/coreclr/jit/fgprofile.cpp @@ -309,7 +309,13 @@ class Instrumentor bool m_modifiedFlow; protected: - Instrumentor(Compiler* comp) : m_comp(comp), m_schemaCount(0), m_instrCount(0), m_modifiedFlow(false) {} + Instrumentor(Compiler* comp) + : m_comp(comp) + , m_schemaCount(0) + , m_instrCount(0) + , m_modifiedFlow(false) + { + } public: virtual bool ShouldProcess(BasicBlock* block) @@ -320,11 +326,19 @@ class Instrumentor { return ShouldProcess(block); } - virtual void Prepare(bool preImport) {} - virtual void BuildSchemaElements(BasicBlock* block, Schema& schema) {} - virtual void Instrument(BasicBlock* block, Schema& schema, uint8_t* profileMemory) {} - virtual void InstrumentMethodEntry(Schema& schema, uint8_t* profileMemory) {} - unsigned SchemaCount() const + virtual void Prepare(bool preImport) + { + } + virtual void BuildSchemaElements(BasicBlock* block, Schema& schema) + { + } + virtual void Instrument(BasicBlock* block, Schema& schema, uint8_t* profileMemory) + { + } + virtual void InstrumentMethodEntry(Schema& schema, uint8_t* profileMemory) + { + } + unsigned SchemaCount() const { return m_schemaCount; } @@ -350,7 +364,10 @@ class Instrumentor class NonInstrumentor : public Instrumentor { public: - NonInstrumentor(Compiler* comp) : Instrumentor(comp) {} + NonInstrumentor(Compiler* comp) + : Instrumentor(comp) + { + } }; //------------------------------------------------------------------------ @@ -364,7 +381,11 @@ class BlockCountInstrumentor : public Instrumentor BasicBlock* m_entryBlock; public: - BlockCountInstrumentor(Compiler* comp) : Instrumentor(comp), m_entryBlock(nullptr) {} + BlockCountInstrumentor(Compiler* comp) + : Instrumentor(comp) + , m_entryBlock(nullptr) + { + } bool ShouldProcess(BasicBlock* block) override { return block->HasFlag(BBF_IMPORTED) && !block->HasFlag(BBF_INTERNAL); @@ -1225,7 +1246,9 @@ static int32_t EfficientEdgeCountBlockToKey(BasicBlock* block) // Based on "Optimally Profiling and Tracing Programs," // Ball and Larus PLDI '92. // -class EfficientEdgeCountInstrumentor : public Instrumentor, public SpanningTreeVisitor +class EfficientEdgeCountInstrumentor + : public Instrumentor + , public SpanningTreeVisitor { private: // A particular edge probe. These are linked @@ -1364,7 +1387,9 @@ class EfficientEdgeCountInstrumentor : public Instrumentor, public SpanningTreeV block->bbSparseProbeList = nullptr; } - void VisitTreeEdge(BasicBlock* source, BasicBlock* target) override {} + void VisitTreeEdge(BasicBlock* source, BasicBlock* target) override + { + } void VisitNonTreeEdge(BasicBlock* source, BasicBlock* target, SpanningTreeVisitor::EdgeKind kind) override { @@ -1887,7 +1912,9 @@ class HandleHistogramProbeVisitor final : public GenTreeVisitor(compiler), m_functor(functor), m_compiler(compiler) + : GenTreeVisitor(compiler) + , m_functor(functor) + , m_compiler(compiler) { } Compiler::fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) @@ -1919,7 +1946,9 @@ class ValueHistogramProbeVisitor final : public GenTreeVisitor(compiler), m_functor(functor), m_compiler(compiler) + : GenTreeVisitor(compiler) + , m_functor(functor) + , m_compiler(compiler) { } @@ -1949,7 +1978,8 @@ class BuildHandleHistogramProbeSchemaGen public: BuildHandleHistogramProbeSchemaGen(Schema& schema, unsigned& schemaCount) - : m_schema(schema), m_schemaCount(schemaCount) + : m_schema(schema) + , m_schemaCount(schemaCount) { } @@ -2011,7 +2041,8 @@ class BuildValueHistogramProbeSchemaGen public: BuildValueHistogramProbeSchemaGen(Schema& schema, unsigned& schemaCount) - : m_schema(schema), m_schemaCount(schemaCount) + : m_schema(schema) + , m_schemaCount(schemaCount) { } @@ -2316,7 +2347,10 @@ class ValueHistogramProbeInserter class HandleHistogramProbeInstrumentor : public Instrumentor { public: - HandleHistogramProbeInstrumentor(Compiler* comp) : Instrumentor(comp) {} + HandleHistogramProbeInstrumentor(Compiler* comp) + : Instrumentor(comp) + { + } bool ShouldProcess(BasicBlock* block) override { return block->HasFlag(BBF_IMPORTED) && !block->HasFlag(BBF_INTERNAL); @@ -2332,7 +2366,10 @@ class HandleHistogramProbeInstrumentor : public Instrumentor class ValueInstrumentor : public Instrumentor { public: - ValueInstrumentor(Compiler* comp) : Instrumentor(comp) {} + ValueInstrumentor(Compiler* comp) + : Instrumentor(comp) + { + } bool ShouldProcess(BasicBlock* block) override { return block->HasFlag(BBF_IMPORTED) && !block->HasFlag(BBF_INTERNAL); @@ -3091,7 +3128,11 @@ class EfficientEdgeCountReconstructor : public SpanningTreeVisitor int32_t const m_sourceKey; int32_t const m_targetKey; - EdgeKey(int32_t sourceKey, int32_t targetKey) : m_sourceKey(sourceKey), m_targetKey(targetKey) {} + EdgeKey(int32_t sourceKey, int32_t targetKey) + : m_sourceKey(sourceKey) + , m_targetKey(targetKey) + { + } EdgeKey(BasicBlock* sourceBlock, BasicBlock* targetBlock) : m_sourceKey(EfficientEdgeCountBlockToKey(sourceBlock)) @@ -3249,7 +3290,9 @@ class EfficientEdgeCountReconstructor : public SpanningTreeVisitor return !(m_entryWeightZero || m_negativeCount); } - void VisitBlock(BasicBlock*) override {} + void VisitBlock(BasicBlock*) override + { + } void VisitTreeEdge(BasicBlock* source, BasicBlock* target) override { diff --git a/src/coreclr/jit/fgprofilesynthesis.cpp b/src/coreclr/jit/fgprofilesynthesis.cpp index 7afbbf070190a5..77803454f0cfde 100644 --- a/src/coreclr/jit/fgprofilesynthesis.cpp +++ b/src/coreclr/jit/fgprofilesynthesis.cpp @@ -672,73 +672,69 @@ void ProfileSynthesis::ComputeCyclicProbabilities(FlowGraphNaturalLoop* loop) { // Initialize // - loop->VisitLoopBlocks( - [](BasicBlock* loopBlock) - { - loopBlock->bbWeight = 0.0; - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks([](BasicBlock* loopBlock) { + loopBlock->bbWeight = 0.0; + return BasicBlockVisit::Continue; + }); // Process loop blocks in RPO. Just takes one pass through the loop blocks // as any cyclic contributions are handled by cyclic probabilities. // - loop->VisitLoopBlocksReversePostOrder( - [=](BasicBlock* block) + loop->VisitLoopBlocksReversePostOrder([=](BasicBlock* block) { + // Loop head gets external count of 1 + // + if (block == loop->GetHeader()) { - // Loop head gets external count of 1 - // - if (block == loop->GetHeader()) - { - JITDUMP("ccp: " FMT_BB " :: 1.0\n", block->bbNum); - block->bbWeight = 1.0; - } - else - { - FlowGraphNaturalLoop* const nestedLoop = m_loops->GetLoopByHeader(block); + JITDUMP("ccp: " FMT_BB " :: 1.0\n", block->bbNum); + block->bbWeight = 1.0; + } + else + { + FlowGraphNaturalLoop* const nestedLoop = m_loops->GetLoopByHeader(block); - if (nestedLoop != nullptr) - { - // We should have figured this out already. - // - assert(m_cyclicProbabilities[nestedLoop->GetIndex()] != 0); + if (nestedLoop != nullptr) + { + // We should have figured this out already. + // + assert(m_cyclicProbabilities[nestedLoop->GetIndex()] != 0); - // Sum entry edges, multply by Cp - // - weight_t newWeight = 0.0; + // Sum entry edges, multply by Cp + // + weight_t newWeight = 0.0; - for (FlowEdge* const edge : nestedLoop->EntryEdges()) + for (FlowEdge* const edge : nestedLoop->EntryEdges()) + { + if (BasicBlock::sameHndRegion(block, edge->getSourceBlock())) { - if (BasicBlock::sameHndRegion(block, edge->getSourceBlock())) - { - newWeight += edge->getLikelyWeight(); - } + newWeight += edge->getLikelyWeight(); } + } - newWeight *= m_cyclicProbabilities[nestedLoop->GetIndex()]; - block->bbWeight = newWeight; + newWeight *= m_cyclicProbabilities[nestedLoop->GetIndex()]; + block->bbWeight = newWeight; - JITDUMP("ccp (nested header): " FMT_BB " :: " FMT_WT "\n", block->bbNum, newWeight); - } - else - { - weight_t newWeight = 0.0; + JITDUMP("ccp (nested header): " FMT_BB " :: " FMT_WT "\n", block->bbNum, newWeight); + } + else + { + weight_t newWeight = 0.0; - for (FlowEdge* const edge : block->PredEdges()) + for (FlowEdge* const edge : block->PredEdges()) + { + if (BasicBlock::sameHndRegion(block, edge->getSourceBlock())) { - if (BasicBlock::sameHndRegion(block, edge->getSourceBlock())) - { - newWeight += edge->getLikelyWeight(); - } + newWeight += edge->getLikelyWeight(); } + } - block->bbWeight = newWeight; + block->bbWeight = newWeight; - JITDUMP("ccp: " FMT_BB " :: " FMT_WT "\n", block->bbNum, newWeight); - } + JITDUMP("ccp: " FMT_BB " :: " FMT_WT "\n", block->bbNum, newWeight); } + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); // Now look at cyclic flow back to the head block. // diff --git a/src/coreclr/jit/fgprofilesynthesis.h b/src/coreclr/jit/fgprofilesynthesis.h index b293c4597e1617..e2e7c58cbac4f2 100644 --- a/src/coreclr/jit/fgprofilesynthesis.h +++ b/src/coreclr/jit/fgprofilesynthesis.h @@ -40,7 +40,10 @@ class ProfileSynthesis static constexpr weight_t epsilon = 0.001; private: - ProfileSynthesis(Compiler* compiler) : m_comp(compiler) {} + ProfileSynthesis(Compiler* compiler) + : m_comp(compiler) + { + } static constexpr weight_t exceptionScale = 0.001; static constexpr weight_t blendFactor = 0.99; diff --git a/src/coreclr/jit/flowgraph.cpp b/src/coreclr/jit/flowgraph.cpp index 788515e325ef43..96e0a3e785f1fc 100644 --- a/src/coreclr/jit/flowgraph.cpp +++ b/src/coreclr/jit/flowgraph.cpp @@ -1823,7 +1823,8 @@ class MergedReturns bool mergingReturns = false; public: - MergedReturns(Compiler* comp) : comp(comp) + MergedReturns(Compiler* comp) + : comp(comp) { comp->fgReturnCount = 0; } @@ -3589,7 +3590,9 @@ GenTree* Compiler::fgSetTreeSeq(GenTree* tree, bool isLIR) }; SetTreeSeqVisitor(Compiler* compiler, GenTree* tree, bool isLIR) - : GenTreeVisitor(compiler), m_prevNode(tree), m_isLIR(isLIR) + : GenTreeVisitor(compiler) + , m_prevNode(tree) + , m_isLIR(isLIR) { INDEBUG(tree->gtSeqNum = 0); } @@ -3689,20 +3692,19 @@ class GCSafePointSuccessorEnumerator public: // Constructs an enumerator of successors to be used for checking for GC // safe point cycles. - GCSafePointSuccessorEnumerator(Compiler* comp, BasicBlock* block) : m_block(block) + GCSafePointSuccessorEnumerator(Compiler* comp, BasicBlock* block) + : m_block(block) { m_numSuccs = 0; - block->VisitRegularSuccs(comp, - [this](BasicBlock* succ) - { - if (m_numSuccs < ArrLen(m_successors)) - { - m_successors[m_numSuccs] = succ; - } - - m_numSuccs++; - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(comp, [this](BasicBlock* succ) { + if (m_numSuccs < ArrLen(m_successors)) + { + m_successors[m_numSuccs] = succ; + } + + m_numSuccs++; + return BasicBlockVisit::Continue; + }); if (m_numSuccs == 0) { @@ -3726,13 +3728,11 @@ class GCSafePointSuccessorEnumerator m_pSuccessors = new (comp, CMK_BasicBlock) BasicBlock*[m_numSuccs]; unsigned numSuccs = 0; - block->VisitRegularSuccs(comp, - [this, &numSuccs](BasicBlock* succ) - { - assert(numSuccs < m_numSuccs); - m_pSuccessors[numSuccs++] = succ; - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(comp, [this, &numSuccs](BasicBlock* succ) { + assert(numSuccs < m_numSuccs); + m_pSuccessors[numSuccs++] = succ; + return BasicBlockVisit::Continue; + }); assert(numSuccs == m_numSuccs); } @@ -4001,21 +4001,18 @@ FlowGraphDfsTree* Compiler::fgComputeDfs() BasicBlock** postOrder = new (this, CMK_DepthFirstSearch) BasicBlock*[fgBBcount]; bool hasCycle = false; - auto visitPreorder = [](BasicBlock* block, unsigned preorderNum) - { + auto visitPreorder = [](BasicBlock* block, unsigned preorderNum) { block->bbPreorderNum = preorderNum; block->bbPostorderNum = UINT_MAX; }; - auto visitPostorder = [=](BasicBlock* block, unsigned postorderNum) - { + auto visitPostorder = [=](BasicBlock* block, unsigned postorderNum) { block->bbPostorderNum = postorderNum; assert(postorderNum < fgBBcount); postOrder[postorderNum] = block; }; - auto visitEdge = [&hasCycle](BasicBlock* block, BasicBlock* succ) - { + auto visitEdge = [&hasCycle](BasicBlock* block, BasicBlock* succ) { // Check if block -> succ is a backedge, in which case the flow // graph has a cycle. if ((succ->bbPreorderNum <= block->bbPreorderNum) && (succ->bbPostorderNum == UINT_MAX)) @@ -4211,7 +4208,9 @@ unsigned FlowGraphNaturalLoop::NumLoopBlocks() // dfs - A DFS tree. // FlowGraphNaturalLoops::FlowGraphNaturalLoops(const FlowGraphDfsTree* dfsTree) - : m_dfsTree(dfsTree), m_loops(m_dfsTree->GetCompiler()->getAllocator(CMK_Loops)), m_improperLoopHeaders(0) + : m_dfsTree(dfsTree) + , m_loops(m_dfsTree->GetCompiler()->getAllocator(CMK_Loops)) + , m_improperLoopHeaders(0) { } @@ -4401,27 +4400,21 @@ FlowGraphNaturalLoops* FlowGraphNaturalLoops::Find(const FlowGraphDfsTree* dfsTr // Find the exit edges // - loop->VisitLoopBlocksReversePostOrder( - [=](BasicBlock* loopBlock) - { - loopBlock->VisitRegularSuccs(comp, - [=](BasicBlock* succBlock) - { - if (!loop->ContainsBlock(succBlock)) - { - FlowEdge* const exitEdge = - comp->fgGetPredForBlock(succBlock, loopBlock); - JITDUMP(FMT_BB " -> " FMT_BB " is an exit edge\n", - loopBlock->bbNum, succBlock->bbNum); - loop->m_exitEdges.push_back(exitEdge); - } - - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocksReversePostOrder([=](BasicBlock* loopBlock) { + loopBlock->VisitRegularSuccs(comp, [=](BasicBlock* succBlock) { + if (!loop->ContainsBlock(succBlock)) + { + FlowEdge* const exitEdge = comp->fgGetPredForBlock(succBlock, loopBlock); + JITDUMP(FMT_BB " -> " FMT_BB " is an exit edge\n", loopBlock->bbNum, succBlock->bbNum); + loop->m_exitEdges.push_back(exitEdge); + } return BasicBlockVisit::Continue; }); + return BasicBlockVisit::Continue; + }); + // Find the entry edges // // Note if fgEntryBB is a loop head we won't have an entry edge. @@ -4462,23 +4455,19 @@ FlowGraphNaturalLoops* FlowGraphNaturalLoops::Find(const FlowGraphDfsTree* dfsTr { // Ancestor loop; should contain all blocks of this loop // - loop->VisitLoopBlocks( - [otherLoop](BasicBlock* loopBlock) - { - assert(otherLoop->ContainsBlock(loopBlock)); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks([otherLoop](BasicBlock* loopBlock) { + assert(otherLoop->ContainsBlock(loopBlock)); + return BasicBlockVisit::Continue; + }); } else { // Non-ancestor loop; should have no blocks in common with current loop // - loop->VisitLoopBlocks( - [otherLoop](BasicBlock* loopBlock) - { - assert(!otherLoop->ContainsBlock(loopBlock)); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks([otherLoop](BasicBlock* loopBlock) { + assert(!otherLoop->ContainsBlock(loopBlock)); + return BasicBlockVisit::Continue; + }); } } #endif @@ -4687,8 +4676,7 @@ void FlowGraphNaturalLoop::Dump(FlowGraphNaturalLoop* loop) BasicBlock* firstInRange = nullptr; BasicBlock* lastInRange = nullptr; first = true; - auto printRange = [&]() - { + auto printRange = [&]() { // Dump current range if there is one; reset firstInRange. if (firstInRange == nullptr) { @@ -4733,13 +4721,11 @@ void FlowGraphNaturalLoop::Dump(FlowGraphNaturalLoop* loop) // not well ordered such that `top` and `bottom` are not first/last in `bbNext` order. // Just dump all the blocks individually using the loop block visitor. first = true; - loop->VisitLoopBlocksReversePostOrder( - [&first](BasicBlock* block) - { - printf("%s" FMT_BB, first ? "" : ";", block->bbNum); - first = false; - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocksReversePostOrder([&first](BasicBlock* block) { + printf("%s" FMT_BB, first ? "" : ";", block->bbNum); + first = false; + return BasicBlockVisit::Continue; + }); // Print out the lexical top and bottom blocks, which will explain why we didn't print ranges. printf("\n Lexical top: " FMT_BB, lexicalTopBlock->bbNum); @@ -4859,7 +4845,11 @@ bool FlowGraphNaturalLoop::VisitDefs(TFunc func) DoPreOrder = true, }; - VisitDefsVisitor(Compiler* comp, TFunc& func) : GenTreeVisitor(comp), m_func(func) {} + VisitDefsVisitor(Compiler* comp, TFunc& func) + : GenTreeVisitor(comp) + , m_func(func) + { + } Compiler::fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -4882,17 +4872,15 @@ bool FlowGraphNaturalLoop::VisitDefs(TFunc func) VisitDefsVisitor visitor(m_dfsTree->GetCompiler(), func); - BasicBlockVisit result = VisitLoopBlocks( - [&](BasicBlock* loopBlock) + BasicBlockVisit result = VisitLoopBlocks([&](BasicBlock* loopBlock) { + for (Statement* stmt : loopBlock->Statements()) { - for (Statement* stmt : loopBlock->Statements()) - { - if (visitor.WalkTree(stmt->GetRootNodePointer(), nullptr) == Compiler::WALK_ABORT) - return BasicBlockVisit::Abort; - } + if (visitor.WalkTree(stmt->GetRootNodePointer(), nullptr) == Compiler::WALK_ABORT) + return BasicBlockVisit::Abort; + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); return result == BasicBlockVisit::Continue; } @@ -4924,17 +4912,15 @@ GenTreeLclVarCommon* FlowGraphNaturalLoop::FindDef(unsigned lclNum) } GenTreeLclVarCommon* result = nullptr; - VisitDefs( - [&result, lclNum, lclNum2](GenTreeLclVarCommon* def) + VisitDefs([&result, lclNum, lclNum2](GenTreeLclVarCommon* def) { + if ((def->GetLclNum() == lclNum) || (def->GetLclNum() == lclNum2)) { - if ((def->GetLclNum() == lclNum) || (def->GetLclNum() == lclNum2)) - { - result = def; - return false; - } + result = def; + return false; + } - return true; - }); + return true; + }); return result; } @@ -5039,15 +5025,13 @@ bool FlowGraphNaturalLoop::AnalyzeIteration(NaturalLoopIterInfo* info) continue; } - bool result = VisitDefs( - [=](GenTreeLclVarCommon* def) - { - if ((def->GetLclNum() != iterVar) || (def == iterTree)) - return true; + bool result = VisitDefs([=](GenTreeLclVarCommon* def) { + if ((def->GetLclNum() != iterVar) || (def == iterTree)) + return true; - JITDUMP(" Loop has extraneous def [%06u]\n", Compiler::dspTreeID(def)); - return false; - }); + JITDUMP(" Loop has extraneous def [%06u]\n", Compiler::dspTreeID(def)); + return false; + }); if (!result) { @@ -5080,15 +5064,13 @@ bool FlowGraphNaturalLoop::AnalyzeIteration(NaturalLoopIterInfo* info) MatchInit(info, initBlock, init); - bool result = VisitDefs( - [=](GenTreeLclVarCommon* def) - { - if ((def->GetLclNum() != info->IterVar) || (def == info->IterTree)) - return true; + bool result = VisitDefs([=](GenTreeLclVarCommon* def) { + if ((def->GetLclNum() != info->IterVar) || (def == info->IterTree)) + return true; - JITDUMP(" Loop has extraneous def [%06u]\n", Compiler::dspTreeID(def)); - return false; - }); + JITDUMP(" Loop has extraneous def [%06u]\n", Compiler::dspTreeID(def)); + return false; + }); if (!result) { @@ -5521,13 +5503,11 @@ bool FlowGraphNaturalLoop::InitBlockEntersLoopOnTrue(BasicBlock* initBlock) BasicBlock* FlowGraphNaturalLoop::GetLexicallyTopMostBlock() { BasicBlock* top = m_header; - VisitLoopBlocks( - [&top](BasicBlock* loopBlock) - { - if (loopBlock->bbNum < top->bbNum) - top = loopBlock; - return BasicBlockVisit::Continue; - }); + VisitLoopBlocks([&top](BasicBlock* loopBlock) { + if (loopBlock->bbNum < top->bbNum) + top = loopBlock; + return BasicBlockVisit::Continue; + }); return top; } @@ -5546,13 +5526,11 @@ BasicBlock* FlowGraphNaturalLoop::GetLexicallyTopMostBlock() BasicBlock* FlowGraphNaturalLoop::GetLexicallyBottomMostBlock() { BasicBlock* bottom = m_header; - VisitLoopBlocks( - [&bottom](BasicBlock* loopBlock) - { - if (loopBlock->bbNum > bottom->bbNum) - bottom = loopBlock; - return BasicBlockVisit::Continue; - }); + VisitLoopBlocks([&bottom](BasicBlock* loopBlock) { + if (loopBlock->bbNum > bottom->bbNum) + bottom = loopBlock; + return BasicBlockVisit::Continue; + }); return bottom; } @@ -5582,16 +5560,14 @@ bool FlowGraphNaturalLoop::HasDef(unsigned lclNum) defLclNum2 = dsc->lvParentLcl; } - bool result = VisitDefs( - [=](GenTreeLclVarCommon* lcl) + bool result = VisitDefs([=](GenTreeLclVarCommon* lcl) { + if ((lcl->GetLclNum() == defLclNum1) || (lcl->GetLclNum() == defLclNum2)) { - if ((lcl->GetLclNum() == defLclNum1) || (lcl->GetLclNum() == defLclNum2)) - { - return false; - } + return false; + } - return true; - }); + return true; + }); // If we stopped early we found a def. return !result; @@ -5620,17 +5596,15 @@ bool FlowGraphNaturalLoop::CanDuplicate(INDEBUG(const char** reason)) #endif Compiler* comp = m_dfsTree->GetCompiler(); - BasicBlockVisit result = VisitLoopBlocks( - [=](BasicBlock* block) + BasicBlockVisit result = VisitLoopBlocks([=](BasicBlock* block) { + if (comp->bbIsTryBeg(block)) { - if (comp->bbIsTryBeg(block)) - { - INDEBUG(*reason = "Loop has a `try` begin"); - return BasicBlockVisit::Abort; - } + INDEBUG(*reason = "Loop has a `try` begin"); + return BasicBlockVisit::Abort; + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); return result != BasicBlockVisit::Abort; } @@ -5651,47 +5625,43 @@ void FlowGraphNaturalLoop::Duplicate(BasicBlock** insertAfter, BlockToBlockMap* BasicBlock* bottom = GetLexicallyBottomMostBlock(); - VisitLoopBlocksLexical( - [=](BasicBlock* blk) - { - // Initialize newBlk as BBJ_ALWAYS without jump target, and fix up jump target later - // with BasicBlock::CopyTarget(). - BasicBlock* newBlk = comp->fgNewBBafter(BBJ_ALWAYS, *insertAfter, /*extendRegion*/ true); - JITDUMP("Adding " FMT_BB " (copy of " FMT_BB ") after " FMT_BB "\n", newBlk->bbNum, blk->bbNum, - (*insertAfter)->bbNum); + VisitLoopBlocksLexical([=](BasicBlock* blk) { + // Initialize newBlk as BBJ_ALWAYS without jump target, and fix up jump target later + // with BasicBlock::CopyTarget(). + BasicBlock* newBlk = comp->fgNewBBafter(BBJ_ALWAYS, *insertAfter, /*extendRegion*/ true); + JITDUMP("Adding " FMT_BB " (copy of " FMT_BB ") after " FMT_BB "\n", newBlk->bbNum, blk->bbNum, + (*insertAfter)->bbNum); - BasicBlock::CloneBlockState(comp, newBlk, blk); + BasicBlock::CloneBlockState(comp, newBlk, blk); - // We're going to create the preds below, which will set the bbRefs properly, - // so clear out the cloned bbRefs field. - newBlk->bbRefs = 0; + // We're going to create the preds below, which will set the bbRefs properly, + // so clear out the cloned bbRefs field. + newBlk->bbRefs = 0; - newBlk->scaleBBWeight(weightScale); + newBlk->scaleBBWeight(weightScale); - *insertAfter = newBlk; - map->Set(blk, newBlk, BlockToBlockMap::Overwrite); + *insertAfter = newBlk; + map->Set(blk, newBlk, BlockToBlockMap::Overwrite); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); // Now go through the new blocks, remapping their jump targets within the loop // and updating the preds lists. - VisitLoopBlocks( - [=](BasicBlock* blk) - { - BasicBlock* newBlk = nullptr; - bool b = map->Lookup(blk, &newBlk); - assert(b && newBlk != nullptr); + VisitLoopBlocks([=](BasicBlock* blk) { + BasicBlock* newBlk = nullptr; + bool b = map->Lookup(blk, &newBlk); + assert(b && newBlk != nullptr); - // Jump target should not be set yet - assert(!newBlk->HasInitializedTarget()); + // Jump target should not be set yet + assert(!newBlk->HasInitializedTarget()); - // Redirect the new block according to "blockMap". - // optSetMappedBlockTargets will set newBlk's successors, and add pred edges for the successors. - comp->optSetMappedBlockTargets(blk, newBlk, map); + // Redirect the new block according to "blockMap". + // optSetMappedBlockTargets will set newBlk's successors, and add pred edges for the successors. + comp->optSetMappedBlockTargets(blk, newBlk, map); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ @@ -6128,7 +6098,9 @@ FlowGraphDominatorTree* FlowGraphDominatorTree::Build(const FlowGraphDfsTree* df public: NumberDomTreeVisitor(Compiler* comp, unsigned* preorderNums, unsigned* postorderNums) - : DomTreeVisitor(comp), m_preorderNums(preorderNums), m_postorderNums(postorderNums) + : DomTreeVisitor(comp) + , m_preorderNums(preorderNums) + , m_postorderNums(postorderNums) { } @@ -6204,12 +6176,10 @@ BlockToNaturalLoopMap* BlockToNaturalLoopMap::Build(FlowGraphNaturalLoops* loops // loops last and thus write their indices into the map last. for (FlowGraphNaturalLoop* loop : loops->InReversePostOrder()) { - loop->VisitLoopBlocks( - [=](BasicBlock* block) - { - indices[block->bbPostorderNum] = loop->GetIndex(); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks([=](BasicBlock* block) { + indices[block->bbPostorderNum] = loop->GetIndex(); + return BasicBlockVisit::Continue; + }); } return new (comp, CMK_Loops) BlockToNaturalLoopMap(loops, indices); diff --git a/src/coreclr/jit/forwardsub.cpp b/src/coreclr/jit/forwardsub.cpp index b6a1c8534bb1fd..de4ac5fe8a4758 100644 --- a/src/coreclr/jit/forwardsub.cpp +++ b/src/coreclr/jit/forwardsub.cpp @@ -191,7 +191,9 @@ class ForwardSubVisitor final : public GenTreeVisitor UseExecutionOrder = true }; - ForwardSubVisitor(Compiler* compiler, unsigned lclNum) : GenTreeVisitor(compiler), m_lclNum(lclNum) + ForwardSubVisitor(Compiler* compiler, unsigned lclNum) + : GenTreeVisitor(compiler) + , m_lclNum(lclNum) { LclVarDsc* dsc = compiler->lvaGetDesc(m_lclNum); if (dsc->lvIsStructField) @@ -399,7 +401,11 @@ class EffectsVisitor final : public GenTreeVisitor UseExecutionOrder = true }; - EffectsVisitor(Compiler* compiler) : GenTreeVisitor(compiler), m_flags(GTF_EMPTY) {} + EffectsVisitor(Compiler* compiler) + : GenTreeVisitor(compiler) + , m_flags(GTF_EMPTY) + { + } Compiler::fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { diff --git a/src/coreclr/jit/gcencode.cpp b/src/coreclr/jit/gcencode.cpp index 68e4c10d7b6a86..9d521ebef799cd 100644 --- a/src/coreclr/jit/gcencode.cpp +++ b/src/coreclr/jit/gcencode.cpp @@ -1818,7 +1818,7 @@ static int (*zeroFunc)() = zeroFN; */ typedef unsigned pasMaskType; -#define BITS_IN_pasMask (BITS_PER_BYTE * sizeof(pasMaskType)) +#define BITS_IN_pasMask (BITS_PER_BYTE * sizeof(pasMaskType)) #define HIGHEST_pasMask_BIT (((pasMaskType)0x1) << (BITS_IN_pasMask - 1)) //----------------------------------------------------------------------------- @@ -1851,8 +1851,8 @@ class PendingArgsStack // Use these in the case where there actually are more ptrs than pasArgMask unsigned pasEnumGCoffsCount(); #define pasENUM_START ((unsigned)-1) -#define pasENUM_LAST ((unsigned)-2) -#define pasENUM_END ((unsigned)-3) +#define pasENUM_LAST ((unsigned)-2) +#define pasENUM_END ((unsigned)-3) unsigned pasEnumGCoffs(unsigned iter, unsigned* offs); protected: @@ -3647,7 +3647,8 @@ class GcInfoEncoderWithLogging public: GcInfoEncoderWithLogging(GcInfoEncoder* gcInfoEncoder, bool verbose) - : m_gcInfoEncoder(gcInfoEncoder), m_doLogging(verbose INDEBUG(|| JitConfig.JitGCInfoLogging() != 0)) + : m_gcInfoEncoder(gcInfoEncoder) + , m_doLogging(verbose INDEBUG(|| JitConfig.JitGCInfoLogging() != 0)) { } @@ -4025,7 +4026,8 @@ struct InterruptibleRangeReporter Encoder* gcInfoEncoderWithLog; InterruptibleRangeReporter(unsigned _prevStart, Encoder* _gcInfo) - : prevStart(_prevStart), gcInfoEncoderWithLog(_gcInfo) + : prevStart(_prevStart) + , gcInfoEncoderWithLog(_gcInfo) { } diff --git a/src/coreclr/jit/gcinfo.cpp b/src/coreclr/jit/gcinfo.cpp index cb72d3e82ddebb..8045cd873260ea 100644 --- a/src/coreclr/jit/gcinfo.cpp +++ b/src/coreclr/jit/gcinfo.cpp @@ -46,7 +46,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ -GCInfo::GCInfo(Compiler* theCompiler) : compiler(theCompiler) +GCInfo::GCInfo(Compiler* theCompiler) + : compiler(theCompiler) { regSet = nullptr; gcVarPtrList = nullptr; diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 3c45167c16be36..bd288322624d0c 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -78,7 +78,8 @@ struct IndentStack const char** indents; // Constructor for IndentStack. Uses 'compiler' to determine the mode of printing. - IndentStack(Compiler* compiler) : stack(compiler->getAllocator(CMK_DebugOnly)) + IndentStack(Compiler* compiler) + : stack(compiler->getAllocator(CMK_DebugOnly)) { if (compiler->asciiTrees) { @@ -3199,17 +3200,15 @@ bool GenTree::Compare(GenTree* op1, GenTree* op2, bool swapOK) } bool result = false; - tree->VisitOperands( - [lclNum, &result](GenTree* operand) -> GenTree::VisitResult + tree->VisitOperands([lclNum, &result](GenTree* operand) -> GenTree::VisitResult { + if (gtHasRef(operand, lclNum)) { - if (gtHasRef(operand, lclNum)) - { - result = true; - return GenTree::VisitResult::Abort; - } + result = true; + return GenTree::VisitResult::Abort; + } - return GenTree::VisitResult::Continue; - }); + return GenTree::VisitResult::Continue; + }); return result; } @@ -3235,7 +3234,10 @@ bool Compiler::gtHasLocalsWithAddrOp(GenTree* tree) DoLclVarsOnly = true, }; - LocalsWithAddrOpVisitor(Compiler* comp) : GenTreeVisitor(comp) {} + LocalsWithAddrOpVisitor(Compiler* comp) + : GenTreeVisitor(comp) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -3274,7 +3276,10 @@ bool Compiler::gtHasAddressExposedLocals(GenTree* tree) DoLclVarsOnly = true, }; - Visitor(Compiler* comp) : GenTreeVisitor(comp) {} + Visitor(Compiler* comp) + : GenTreeVisitor(comp) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -3881,8 +3886,7 @@ bool GenTreeOp::IsValidLongMul() if (gtOverflow()) { - auto getMaxValue = [this](GenTree* op) -> int64_t - { + auto getMaxValue = [this](GenTree* op) -> int64_t { if (op->OperIs(GT_CAST)) { if (op->IsUnsigned()) @@ -3979,8 +3983,7 @@ unsigned Compiler::gtSetCallArgsOrder(CallArgs* args, bool lateArgs, int* callCo unsigned costEx = 0; unsigned costSz = 0; - auto update = [&level, &costEx, &costSz, lateArgs](GenTree* argNode, unsigned argLevel) - { + auto update = [&level, &costEx, &costSz, lateArgs](GenTree* argNode, unsigned argLevel) { if (argLevel > level) { level = argLevel; @@ -6436,7 +6439,11 @@ bool Compiler::gtMayHaveStoreInterference(GenTree* treeWithStores, GenTree* tree DoPreOrder = true, }; - Visitor(Compiler* compiler, GenTree* readTree) : GenTreeVisitor(compiler), m_readTree(readTree) {} + Visitor(Compiler* compiler, GenTree* readTree) + : GenTreeVisitor(compiler) + , m_readTree(readTree) + { + } Compiler::fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -6495,7 +6502,9 @@ bool Compiler::gtTreeHasLocalRead(GenTree* tree, unsigned lclNum) unsigned m_lclNum; LclVarDsc* m_lclDsc; - Visitor(Compiler* compiler, unsigned lclNum) : GenTreeVisitor(compiler), m_lclNum(lclNum) + Visitor(Compiler* compiler, unsigned lclNum) + : GenTreeVisitor(compiler) + , m_lclNum(lclNum) { m_lclDsc = compiler->lvaGetDesc(lclNum); } @@ -9842,7 +9851,9 @@ GenTreeCall* Compiler::gtCloneExprCallHelper(GenTreeCall* tree) copy->gtCallMoreFlags = tree->gtCallMoreFlags; INDEBUG(copy->gtCallDebugFlags = tree->gtCallDebugFlags); - copy->gtArgs.InternalCopyFrom(this, &tree->gtArgs, [=](GenTree* node) { return gtCloneExpr(node); }); + copy->gtArgs.InternalCopyFrom(this, &tree->gtArgs, [=](GenTree* node) { + return gtCloneExpr(node); + }); // The call sig comes from the EE and doesn't change throughout the compilation process, meaning // we only really need one physical copy of it. Therefore a shallow pointer copy will suffice. @@ -9992,7 +10003,10 @@ void Compiler::gtUpdateStmtSideEffects(Statement* stmt) DoPostOrder = true, }; - UpdateSideEffectsWalker(Compiler* comp) : GenTreeVisitor(comp) {} + UpdateSideEffectsWalker(Compiler* comp) + : GenTreeVisitor(comp) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -10101,12 +10115,10 @@ void Compiler::gtUpdateNodeOperSideEffects(GenTree* tree) void Compiler::gtUpdateNodeSideEffects(GenTree* tree) { gtUpdateNodeOperSideEffects(tree); - tree->VisitOperands( - [tree](GenTree* operand) -> GenTree::VisitResult - { - tree->gtFlags |= (operand->gtFlags & GTF_ALL_EFFECT); - return GenTree::VisitResult::Continue; - }); + tree->VisitOperands([tree](GenTree* operand) -> GenTree::VisitResult { + tree->gtFlags |= (operand->gtFlags & GTF_ALL_EFFECT); + return GenTree::VisitResult::Continue; + }); } bool GenTree::gtSetFlags() const @@ -10189,12 +10201,20 @@ bool GenTree::gtRequestSetFlags() } GenTreeUseEdgeIterator::GenTreeUseEdgeIterator() - : m_advance(nullptr), m_node(nullptr), m_edge(nullptr), m_statePtr(nullptr), m_state(-1) + : m_advance(nullptr) + , m_node(nullptr) + , m_edge(nullptr) + , m_statePtr(nullptr) + , m_state(-1) { } GenTreeUseEdgeIterator::GenTreeUseEdgeIterator(GenTree* node) - : m_advance(nullptr), m_node(node), m_edge(nullptr), m_statePtr(nullptr), m_state(0) + : m_advance(nullptr) + , m_node(node) + , m_edge(nullptr) + , m_statePtr(nullptr) + , m_state(0) { assert(m_node != nullptr); @@ -11697,9 +11717,9 @@ void Compiler::gtDispRegVal(GenTree* tree) } // We usually/commonly don't expect to print anything longer than this string, -#define LONGEST_COMMON_LCL_VAR_DISPLAY "V99 PInvokeFrame" +#define LONGEST_COMMON_LCL_VAR_DISPLAY "V99 PInvokeFrame" #define LONGEST_COMMON_LCL_VAR_DISPLAY_LENGTH (sizeof(LONGEST_COMMON_LCL_VAR_DISPLAY)) -#define BUF_SIZE (LONGEST_COMMON_LCL_VAR_DISPLAY_LENGTH * 2) +#define BUF_SIZE (LONGEST_COMMON_LCL_VAR_DISPLAY_LENGTH * 2) void Compiler::gtGetLclVarNameInfo(unsigned lclNum, const char** ilKindOut, const char** ilNameOut, unsigned* ilNumOut) { @@ -12697,8 +12717,7 @@ void Compiler::gtDispTree(GenTree* tree, if (tree->OperIs(GT_FIELD_ADDR)) { - auto disp = [&]() - { + auto disp = [&]() { char buffer[256]; printf(" %s", eeGetFieldName(tree->AsFieldAddr()->gtFldHnd, true, buffer, sizeof(buffer))); }; @@ -12939,17 +12958,14 @@ void Compiler::gtDispTree(GenTree* tree, { GenTreeCall* call = tree->AsCall(); GenTree* lastChild = nullptr; - call->VisitOperands( - [&lastChild](GenTree* operand) -> GenTree::VisitResult - { - lastChild = operand; - return GenTree::VisitResult::Continue; - }); + call->VisitOperands([&lastChild](GenTree* operand) -> GenTree::VisitResult { + lastChild = operand; + return GenTree::VisitResult::Continue; + }); if (call->gtCallType != CT_INDIRECT) { - auto disp = [&]() - { + auto disp = [&]() { char buffer[256]; printf(" %s", eeGetMethodFullName(call->gtCallMethHnd, true, true, buffer, sizeof(buffer))); }; @@ -13414,9 +13430,8 @@ void Compiler::gtDispTreeRange(LIR::Range& containingRange, GenTree* tree) // void Compiler::gtDispLIRNode(GenTree* node, const char* prefixMsg /* = nullptr */) { - auto displayOperand = - [](GenTree* operand, const char* message, IndentInfo operandArc, IndentStack& indentStack, size_t prefixIndent) - { + auto displayOperand = [](GenTree* operand, const char* message, IndentInfo operandArc, IndentStack& indentStack, + size_t prefixIndent) { assert(operand != nullptr); assert(message != nullptr); @@ -14279,8 +14294,7 @@ GenTree* Compiler::gtFoldExprSpecial(GenTree* tree) bool opHasSideEffects = (op->gtFlags & GTF_SIDE_EFFECT) != 0; // Helper function that creates a new IntCon node and morphs it, if required - auto NewMorphedIntConNode = [&](int value) -> GenTreeIntCon* - { + auto NewMorphedIntConNode = [&](int value) -> GenTreeIntCon* { GenTreeIntCon* icon = gtNewIconNode(value); if (fgGlobalMorph) { @@ -14289,8 +14303,7 @@ GenTree* Compiler::gtFoldExprSpecial(GenTree* tree) return icon; }; - auto NewZeroExtendNode = [&](var_types type, GenTree* op1, var_types castToType) -> GenTree* - { + auto NewZeroExtendNode = [&](var_types type, GenTree* op1, var_types castToType) -> GenTree* { assert(varTypeIsIntegral(type)); assert(!varTypeIsSmall(type)); assert(!varTypeIsUnsigned(type)); @@ -17100,7 +17113,11 @@ void Compiler::gtExtractSideEffList(GenTree* expr, return m_result; } - SideEffectExtractor(Compiler* compiler, GenTreeFlags flags) : GenTreeVisitor(compiler), m_flags(flags) {} + SideEffectExtractor(Compiler* compiler, GenTreeFlags flags) + : GenTreeVisitor(compiler) + , m_flags(flags) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -17379,7 +17396,11 @@ Compiler::FindLinkData Compiler::gtFindLink(Statement* stmt, GenTree* node) DoPreOrder = true, }; - FindLinkWalker(Compiler* comp, GenTree* node) : GenTreeVisitor(comp), m_node(node) {} + FindLinkWalker(Compiler* comp, GenTree* node) + : GenTreeVisitor(comp) + , m_node(node) + { + } FindLinkData GetResult() { @@ -17563,7 +17584,11 @@ bool Compiler::gtTreeContainsOper(GenTree* tree, genTreeOps oper) genTreeOps m_oper; public: - Visitor(Compiler* comp, genTreeOps oper) : GenTreeVisitor(comp), m_oper(oper) {} + Visitor(Compiler* comp, genTreeOps oper) + : GenTreeVisitor(comp) + , m_oper(oper) + { + } enum { @@ -17602,7 +17627,10 @@ ExceptionSetFlags Compiler::gtCollectExceptions(GenTree* tree) ExceptionSetFlags m_preciseExceptions = ExceptionSetFlags::None; public: - ExceptionsWalker(Compiler* comp) : GenTreeVisitor(comp) {} + ExceptionsWalker(Compiler* comp) + : GenTreeVisitor(comp) + { + } enum { @@ -17658,7 +17686,11 @@ bool Compiler::gtComplexityExceeds(GenTree* tree, unsigned limit) DoPreOrder = true, }; - ComplexityVisitor(Compiler* comp, unsigned limit) : GenTreeVisitor(comp), m_limit(limit) {} + ComplexityVisitor(Compiler* comp, unsigned limit) + : GenTreeVisitor(comp) + , m_limit(limit) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -19417,7 +19449,8 @@ FieldSeq* FieldSeqStore::Append(FieldSeq* a, FieldSeq* b) return nullptr; } -FieldSeq::FieldSeq(CORINFO_FIELD_HANDLE fieldHnd, ssize_t offset, FieldKind fieldKind) : m_offset(offset) +FieldSeq::FieldSeq(CORINFO_FIELD_HANDLE fieldHnd, ssize_t offset, FieldKind fieldKind) + : m_offset(offset) { assert(fieldHnd != NO_FIELD_HANDLE); diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index e70986f18c4b0f..a5d1657ec12538 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -200,15 +200,22 @@ class AssertionInfo unsigned short m_assertionIndex : 15; AssertionInfo(bool assertionHoldsOnFalseEdge, AssertionIndex assertionIndex) - : m_assertionHoldsOnFalseEdge(assertionHoldsOnFalseEdge), m_assertionIndex(assertionIndex) + : m_assertionHoldsOnFalseEdge(assertionHoldsOnFalseEdge) + , m_assertionIndex(assertionIndex) { assert(m_assertionIndex == assertionIndex); } public: - AssertionInfo() : AssertionInfo(false, 0) {} + AssertionInfo() + : AssertionInfo(false, 0) + { + } - AssertionInfo(AssertionIndex assertionIndex) : AssertionInfo(false, assertionIndex) {} + AssertionInfo(AssertionIndex assertionIndex) + : AssertionInfo(false, assertionIndex) + { + } static AssertionInfo ForNextEdge(AssertionIndex assertionIndex) { @@ -310,7 +317,10 @@ class FieldSeqStore JitHashTable, FieldSeq> m_map; public: - FieldSeqStore(CompAllocator alloc) : m_map(alloc) {} + FieldSeqStore(CompAllocator alloc) + : m_map(alloc) + { + } FieldSeq* Create(CORINFO_FIELD_HANDLE fieldHnd, ssize_t offset, FieldSeq::FieldKind fieldKind); @@ -325,13 +335,13 @@ struct Statement; /*****************************************************************************/ // Forward declarations of the subtypes -#define GTSTRUCT_0(fn, en) struct GenTree##fn; -#define GTSTRUCT_1(fn, en) struct GenTree##fn; -#define GTSTRUCT_2(fn, en, en2) struct GenTree##fn; -#define GTSTRUCT_3(fn, en, en2, en3) struct GenTree##fn; -#define GTSTRUCT_4(fn, en, en2, en3, en4) struct GenTree##fn; -#define GTSTRUCT_N(fn, ...) struct GenTree##fn; -#define GTSTRUCT_2_SPECIAL(fn, en, en2) GTSTRUCT_2(fn, en, en2) +#define GTSTRUCT_0(fn, en) struct GenTree##fn; +#define GTSTRUCT_1(fn, en) struct GenTree##fn; +#define GTSTRUCT_2(fn, en, en2) struct GenTree##fn; +#define GTSTRUCT_3(fn, en, en2, en3) struct GenTree##fn; +#define GTSTRUCT_4(fn, en, en2, en3, en4) struct GenTree##fn; +#define GTSTRUCT_N(fn, ...) struct GenTree##fn; +#define GTSTRUCT_2_SPECIAL(fn, en, en2) GTSTRUCT_2(fn, en, en2) #define GTSTRUCT_3_SPECIAL(fn, en, en2, en3) GTSTRUCT_3(fn, en, en2, en3) #include "gtstructs.h" @@ -684,11 +694,11 @@ struct GenTree return *As##fn(); \ } -#define GTSTRUCT_1(fn, en) GTSTRUCT_N(fn, en) -#define GTSTRUCT_2(fn, en, en2) GTSTRUCT_N(fn, en, en2) -#define GTSTRUCT_3(fn, en, en2, en3) GTSTRUCT_N(fn, en, en2, en3) -#define GTSTRUCT_4(fn, en, en2, en3, en4) GTSTRUCT_N(fn, en, en2, en3, en4) -#define GTSTRUCT_2_SPECIAL(fn, en, en2) GTSTRUCT_2(fn, en, en2) +#define GTSTRUCT_1(fn, en) GTSTRUCT_N(fn, en) +#define GTSTRUCT_2(fn, en, en2) GTSTRUCT_N(fn, en, en2) +#define GTSTRUCT_3(fn, en, en2, en3) GTSTRUCT_N(fn, en, en2, en3) +#define GTSTRUCT_4(fn, en, en2, en3, en4) GTSTRUCT_N(fn, en, en2, en3, en4) +#define GTSTRUCT_2_SPECIAL(fn, en, en2) GTSTRUCT_2(fn, en, en2) #define GTSTRUCT_3_SPECIAL(fn, en, en2, en3) GTSTRUCT_3(fn, en, en2, en3) #include "gtstructs.h" @@ -713,11 +723,11 @@ struct GenTree #define NO_CSE (0) -#define IS_CSE_INDEX(x) ((x) != 0) -#define IS_CSE_USE(x) ((x) > 0) -#define IS_CSE_DEF(x) ((x) < 0) +#define IS_CSE_INDEX(x) ((x) != 0) +#define IS_CSE_USE(x) ((x) > 0) +#define IS_CSE_DEF(x) ((x) < 0) #define GET_CSE_INDEX(x) (((x) > 0) ? x : -(x)) -#define TO_CSE_DEF(x) (-(x)) +#define TO_CSE_DEF(x) (-(x)) signed char gtCSEnum; // 0 or the CSE index (negated if def) // valid only for CSE expressions @@ -760,7 +770,7 @@ struct GenTree bool gtCostsInitialized; #endif // DEBUG -#define MAX_COST UCHAR_MAX +#define MAX_COST UCHAR_MAX #define IND_COST_EX 3 // execution cost for an indirection unsigned char GetCostEx() const @@ -2268,7 +2278,9 @@ struct GenTree // we can't synthesize an assignment operator. // TODO-Cleanup: Could change this w/o liveset on tree nodes // (This is also necessary for the VTable trick.) - GenTree() {} + GenTree() + { + } // Returns an iterator that will produce the use edge to each operand of this node. Differs // from the sequence of nodes produced by a loop over `GetChild` in its handling of call, phi, @@ -2360,7 +2372,9 @@ struct GenTree #if DEBUGGABLE_GENTREE // In DEBUG builds, add a dummy virtual method, to give the debugger run-time type information. - virtual void DummyVirt() {} + virtual void DummyVirt() + { + } typedef void* VtablePtr; @@ -2399,7 +2413,9 @@ struct GenTreePhi final : public GenTree Use* m_next; public: - Use(GenTree* node, Use* next = nullptr) : m_node(node), m_next(next) + Use(GenTree* node, Use* next = nullptr) + : m_node(node) + , m_next(next) { assert(node->OperIs(GT_PHI_ARG)); } @@ -2437,7 +2453,10 @@ struct GenTreePhi final : public GenTree Use* m_use; public: - UseIterator(Use* use) : m_use(use) {} + UseIterator(Use* use) + : m_use(use) + { + } Use& operator*() const { @@ -2471,7 +2490,10 @@ struct GenTreePhi final : public GenTree Use* m_uses; public: - UseList(Use* uses) : m_uses(uses) {} + UseList(Use* uses) + : m_uses(uses) + { + } UseIterator begin() const { @@ -2486,7 +2508,11 @@ struct GenTreePhi final : public GenTree Use* gtUses; - GenTreePhi(var_types type) : GenTree(GT_PHI, type), gtUses(nullptr) {} + GenTreePhi(var_types type) + : GenTree(GT_PHI, type) + , gtUses(nullptr) + { + } UseList Uses() { @@ -2533,7 +2559,10 @@ struct GenTreePhi final : public GenTree } #if DEBUGGABLE_GENTREE - GenTreePhi() : GenTree() {} + GenTreePhi() + : GenTree() + { + } #endif }; @@ -2550,7 +2579,10 @@ struct GenTreeFieldList : public GenTree public: Use(GenTree* node, unsigned offset, var_types type) - : m_node(node), m_next(nullptr), m_offset(static_cast(offset)), m_type(type) + : m_node(node) + , m_next(nullptr) + , m_offset(static_cast(offset)) + , m_type(type) { // We can save space on 32 bit hosts by storing the offset as uint16_t. Struct promotion // only accepts structs which are much smaller than that - 128 bytes = max 4 fields * max @@ -2610,7 +2642,10 @@ struct GenTreeFieldList : public GenTree Use* use; public: - UseIterator(Use* use) : use(use) {} + UseIterator(Use* use) + : use(use) + { + } Use& operator*() { @@ -2644,7 +2679,11 @@ struct GenTreeFieldList : public GenTree Use* m_tail; public: - UseList() : m_head(nullptr), m_tail(nullptr) {} + UseList() + : m_head(nullptr) + , m_tail(nullptr) + { + } Use* GetHead() const { @@ -2722,7 +2761,8 @@ struct GenTreeFieldList : public GenTree UseList m_uses; public: - GenTreeFieldList() : GenTree(GT_FIELD_LIST, TYP_STRUCT) + GenTreeFieldList() + : GenTree(GT_FIELD_LIST, TYP_STRUCT) { SetContained(); } @@ -2890,10 +2930,16 @@ class GenTreeOperandIterator final GenTreeUseEdgeIterator m_useEdges; - GenTreeOperandIterator(GenTree* node) : m_useEdges(node) {} + GenTreeOperandIterator(GenTree* node) + : m_useEdges(node) + { + } public: - GenTreeOperandIterator() : m_useEdges() {} + GenTreeOperandIterator() + : m_useEdges() + { + } inline GenTree* operator*() { @@ -2934,12 +2980,14 @@ struct GenTreeUnOp : public GenTree protected: GenTreeUnOp(genTreeOps oper, var_types type DEBUGARG(bool largeNode = false)) - : GenTree(oper, type DEBUGARG(largeNode)), gtOp1(nullptr) + : GenTree(oper, type DEBUGARG(largeNode)) + , gtOp1(nullptr) { } GenTreeUnOp(genTreeOps oper, var_types type, GenTree* op1 DEBUGARG(bool largeNode = false)) - : GenTree(oper, type DEBUGARG(largeNode)), gtOp1(op1) + : GenTree(oper, type DEBUGARG(largeNode)) + , gtOp1(op1) { assert(op1 != nullptr || NullOp1Legal()); if (op1 != nullptr) @@ -2949,7 +2997,11 @@ struct GenTreeUnOp : public GenTree } #if DEBUGGABLE_GENTREE - GenTreeUnOp() : GenTree(), gtOp1(nullptr) {} + GenTreeUnOp() + : GenTree() + , gtOp1(nullptr) + { + } #endif }; @@ -2958,7 +3010,8 @@ struct GenTreeOp : public GenTreeUnOp GenTree* gtOp2; GenTreeOp(genTreeOps oper, var_types type, GenTree* op1, GenTree* op2 DEBUGARG(bool largeNode = false)) - : GenTreeUnOp(oper, type, op1 DEBUGARG(largeNode)), gtOp2(op2) + : GenTreeUnOp(oper, type, op1 DEBUGARG(largeNode)) + , gtOp2(op2) { // comparisons are always integral types assert(!GenTree::OperIsCompare(oper) || varTypeIsIntegral(type)); @@ -2977,7 +3030,8 @@ struct GenTreeOp : public GenTreeUnOp // A small set of types are unary operators with optional arguments. We use // this constructor to build those. GenTreeOp(genTreeOps oper, var_types type DEBUGARG(bool largeNode = false)) - : GenTreeUnOp(oper, type DEBUGARG(largeNode)), gtOp2(nullptr) + : GenTreeUnOp(oper, type DEBUGARG(largeNode)) + , gtOp2(nullptr) { // Unary operators with optional arguments: assert(oper == GT_RETURN || oper == GT_RETFILT || OperIsBlk(oper)); @@ -2999,7 +3053,11 @@ struct GenTreeOp : public GenTreeUnOp #endif #if DEBUGGABLE_GENTREE - GenTreeOp() : GenTreeUnOp(), gtOp2(nullptr) {} + GenTreeOp() + : GenTreeUnOp() + , gtOp2(nullptr) + { + } #endif }; @@ -3007,9 +3065,16 @@ struct GenTreeVal : public GenTree { size_t gtVal1; - GenTreeVal(genTreeOps oper, var_types type, ssize_t val) : GenTree(oper, type), gtVal1(val) {} + GenTreeVal(genTreeOps oper, var_types type, ssize_t val) + : GenTree(oper, type) + , gtVal1(val) + { + } #if DEBUGGABLE_GENTREE - GenTreeVal() : GenTree() {} + GenTreeVal() + : GenTree() + { + } #endif }; @@ -3063,7 +3128,10 @@ struct GenTreeIntConCommon : public GenTree #endif #if DEBUGGABLE_GENTREE - GenTreeIntConCommon() : GenTree() {} + GenTreeIntConCommon() + : GenTree() + { + } #endif }; @@ -3074,9 +3142,16 @@ struct GenTreePhysReg : public GenTree // GetRegNum() indicates the destination (and can be changed) // whereas reg indicates the source regNumber gtSrcReg; - GenTreePhysReg(regNumber r, var_types type = TYP_I_IMPL) : GenTree(GT_PHYSREG, type), gtSrcReg(r) {} + GenTreePhysReg(regNumber r, var_types type = TYP_I_IMPL) + : GenTree(GT_PHYSREG, type) + , gtSrcReg(r) + { + } #if DEBUGGABLE_GENTREE - GenTreePhysReg() : GenTree() {} + GenTreePhysReg() + : GenTree() + { + } #endif }; @@ -3133,7 +3208,10 @@ struct GenTreeIntCon : public GenTreeIntConCommon void FixupInitBlkValue(var_types type); #if DEBUGGABLE_GENTREE - GenTreeIntCon() : GenTreeIntConCommon() {} + GenTreeIntCon() + : GenTreeIntConCommon() + { + } #endif }; @@ -3152,12 +3230,16 @@ struct GenTreeLngCon : public GenTreeIntConCommon return (INT32)(gtLconVal >> 32); } - GenTreeLngCon(INT64 val) : GenTreeIntConCommon(GT_CNS_NATIVELONG, TYP_LONG) + GenTreeLngCon(INT64 val) + : GenTreeIntConCommon(GT_CNS_NATIVELONG, TYP_LONG) { SetLngValue(val); } #if DEBUGGABLE_GENTREE - GenTreeLngCon() : GenTreeIntConCommon() {} + GenTreeLngCon() + : GenTreeIntConCommon() + { + } #endif }; @@ -3286,13 +3368,17 @@ struct GenTreeDblCon : public GenTree return (bits == otherBits); } - GenTreeDblCon(double val, var_types type = TYP_DOUBLE) : GenTree(GT_CNS_DBL, type) + GenTreeDblCon(double val, var_types type = TYP_DOUBLE) + : GenTree(GT_CNS_DBL, type) { assert(varTypeIsFloating(type)); SetDconValue(val); } #if DEBUGGABLE_GENTREE - GenTreeDblCon() : GenTree() {} + GenTreeDblCon() + : GenTree() + { + } #endif }; @@ -3314,11 +3400,16 @@ struct GenTreeStrCon : public GenTree // Because this node can come from an inlined method we need to // have the scope handle, since it will become a helper call. GenTreeStrCon(unsigned sconCPX, CORINFO_MODULE_HANDLE mod DEBUGARG(bool largeNode = false)) - : GenTree(GT_CNS_STR, TYP_REF DEBUGARG(largeNode)), gtSconCPX(sconCPX), gtScpHnd(mod) + : GenTree(GT_CNS_STR, TYP_REF DEBUGARG(largeNode)) + , gtSconCPX(sconCPX) + , gtScpHnd(mod) { } #if DEBUGGABLE_GENTREE - GenTreeStrCon() : GenTree() {} + GenTreeStrCon() + : GenTree() + { + } #endif }; @@ -3359,10 +3450,16 @@ class SsaNumInfo final int m_value; - SsaNumInfo(int value) : m_value(value) {} + SsaNumInfo(int value) + : m_value(value) + { + } public: - SsaNumInfo() : m_value(SsaConfig::RESERVED_SSA_NUM) {} + SsaNumInfo() + : m_value(SsaConfig::RESERVED_SSA_NUM) + { + } bool IsSimple() const { @@ -3493,7 +3590,10 @@ struct GenTreeLclVarCommon : public GenTreeUnOp } #if DEBUGGABLE_GENTREE - GenTreeLclVarCommon() : GenTreeUnOp() {} + GenTreeLclVarCommon() + : GenTreeUnOp() + { + } #endif }; @@ -3683,7 +3783,10 @@ struct GenTreeLclVar : public GenTreeLclVarCommon } #if DEBUGGABLE_GENTREE - GenTreeLclVar() : GenTreeLclVarCommon() {} + GenTreeLclVar() + : GenTreeLclVarCommon() + { + } #endif }; @@ -3697,14 +3800,16 @@ struct GenTreeLclFld : public GenTreeLclVarCommon public: GenTreeLclFld(genTreeOps oper, var_types type, unsigned lclNum, unsigned lclOffs, ClassLayout* layout = nullptr) - : GenTreeLclVarCommon(oper, type, lclNum), m_lclOffs(static_cast(lclOffs)) + : GenTreeLclVarCommon(oper, type, lclNum) + , m_lclOffs(static_cast(lclOffs)) { assert(lclOffs <= UINT16_MAX); SetLayout(layout); } GenTreeLclFld(var_types type, unsigned lclNum, unsigned lclOffs, GenTree* data, ClassLayout* layout) - : GenTreeLclVarCommon(GT_STORE_LCL_FLD, type, lclNum, data), m_lclOffs(static_cast(lclOffs)) + : GenTreeLclVarCommon(GT_STORE_LCL_FLD, type, lclNum, data) + , m_lclOffs(static_cast(lclOffs)) { assert(lclOffs <= UINT16_MAX); SetLayout(layout); @@ -3739,7 +3844,10 @@ struct GenTreeLclFld : public GenTreeLclVarCommon #endif // TARGET_ARM #if DEBUGGABLE_GENTREE - GenTreeLclFld() : GenTreeLclVarCommon() {} + GenTreeLclFld() + : GenTreeLclVarCommon() + { + } #endif }; @@ -3779,7 +3887,8 @@ struct GenTreeCast : public GenTreeOp var_types gtCastType; GenTreeCast(var_types type, GenTree* op, bool fromUnsigned, var_types castType DEBUGARG(bool largeNode = false)) - : GenTreeOp(GT_CAST, type, op, nullptr DEBUGARG(largeNode)), gtCastType(castType) + : GenTreeOp(GT_CAST, type, op, nullptr DEBUGARG(largeNode)) + , gtCastType(castType) { // We do not allow casts from floating point types to be treated as from // unsigned to avoid bugs related to wrong GTF_UNSIGNED in case the @@ -3789,7 +3898,10 @@ struct GenTreeCast : public GenTreeOp gtFlags |= fromUnsigned ? GTF_UNSIGNED : GTF_EMPTY; } #if DEBUGGABLE_GENTREE - GenTreeCast() : GenTreeOp() {} + GenTreeCast() + : GenTreeOp() + { + } #endif bool IsZeroExtending() @@ -3836,7 +3948,10 @@ struct GenTreeBox : public GenTreeUnOp { } #if DEBUGGABLE_GENTREE - GenTreeBox() : GenTreeUnOp() {} + GenTreeBox() + : GenTreeUnOp() + { + } #endif bool WasCloned() @@ -3878,7 +3993,10 @@ struct GenTreeFieldAddr : public GenTreeUnOp } #if DEBUGGABLE_GENTREE - GenTreeFieldAddr() : GenTreeUnOp() {} + GenTreeFieldAddr() + : GenTreeUnOp() + { + } #endif // The object this field belongs to. Will be "nullptr" for static fields. @@ -3946,10 +4064,16 @@ struct GenTreeColon : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeColon() : GenTreeOp() {} + GenTreeColon() + : GenTreeOp() + { + } #endif - GenTreeColon(var_types typ, GenTree* thenNode, GenTree* elseNode) : GenTreeOp(GT_COLON, typ, elseNode, thenNode) {} + GenTreeColon(var_types typ, GenTree* thenNode, GenTree* elseNode) + : GenTreeOp(GT_COLON, typ, elseNode, thenNode) + { + } }; // GenTreeConditional -- Conditionally do an operation @@ -3960,13 +4084,17 @@ struct GenTreeConditional : public GenTreeOp GenTreeConditional( genTreeOps oper, var_types type, GenTree* cond, GenTree* op1, GenTree* op2 DEBUGARG(bool largeNode = false)) - : GenTreeOp(oper, type, op1, op2 DEBUGARG(largeNode)), gtCond(cond) + : GenTreeOp(oper, type, op1, op2 DEBUGARG(largeNode)) + , gtCond(cond) { assert(cond != nullptr); } #if DEBUGGABLE_GENTREE - GenTreeConditional() : GenTreeOp() {} + GenTreeConditional() + : GenTreeOp() + { + } #endif }; @@ -4245,7 +4373,7 @@ struct ReturnTypeDesc class TailCallSiteInfo { bool m_isCallvirt : 1; - bool m_isCalli : 1; + bool m_isCalli : 1; CORINFO_SIG_INFO m_sig; CORINFO_RESOLVED_TOKEN m_token; @@ -4554,7 +4682,9 @@ struct NewCallArg #ifdef DEBUG void ValidateTypes(); #else - void ValidateTypes() {} + void ValidateTypes() + { + } #endif }; @@ -4604,7 +4734,8 @@ class CallArg public: CallArgABIInformation AbiInfo; - CallArg(const NewCallArg& arg) : CallArg() + CallArg(const NewCallArg& arg) + : CallArg() { m_earlyNode = arg.Node; m_wellKnownArg = arg.WellKnownArg; @@ -4674,9 +4805,9 @@ class CallArgs // made for this call. unsigned m_padStkAlign; #endif - bool m_hasThisPointer : 1; - bool m_hasRetBuffer : 1; - bool m_isVarArgs : 1; + bool m_hasThisPointer : 1; + bool m_hasRetBuffer : 1; + bool m_isVarArgs : 1; bool m_abiInformationDetermined : 1; // True if we have one or more register arguments. bool m_hasRegArgs : 1; @@ -4783,7 +4914,10 @@ class CallArgs CallArg* m_arg; public: - explicit CallArgIterator(CallArg* arg) : m_arg(arg) {} + explicit CallArgIterator(CallArg* arg) + : m_arg(arg) + { + } // clang-format off CallArg& operator*() const { return *m_arg; } @@ -4825,7 +4959,10 @@ class CallArgs } public: - explicit EarlyArgIterator(CallArg* arg) : m_arg(arg) {} + explicit EarlyArgIterator(CallArg* arg) + : m_arg(arg) + { + } // clang-format off CallArg& operator*() const { return *m_arg; } @@ -5508,7 +5645,7 @@ struct GenTreeCall final : public GenTree } GenTreeCallFlags gtCallMoreFlags; // in addition to gtFlags - gtCallTypes gtCallType : 3; // value from the gtCallTypes enumeration + gtCallTypes gtCallType : 3; // value from the gtCallTypes enumeration var_types gtReturnType : 5; // exact return type uint8_t gtInlineInfoCount; // number of inline candidates for the given call @@ -5594,9 +5731,15 @@ struct GenTreeCall final : public GenTree static bool Equals(GenTreeCall* c1, GenTreeCall* c2); - GenTreeCall(var_types type) : GenTree(GT_CALL, type) {} + GenTreeCall(var_types type) + : GenTree(GT_CALL, type) + { + } #if DEBUGGABLE_GENTREE - GenTreeCall() : GenTree() {} + GenTreeCall() + : GenTree() + { + } #endif }; @@ -5613,7 +5756,8 @@ struct GenTreeMultiRegOp : public GenTreeOp MultiRegSpillFlags gtSpillFlags; GenTreeMultiRegOp(genTreeOps oper, var_types type, GenTree* op1, GenTree* op2) - : GenTreeOp(oper, type, op1, op2), gtOtherReg(REG_NA) + : GenTreeOp(oper, type, op1, op2) + , gtOtherReg(REG_NA) { ClearOtherRegFlags(); } @@ -5696,7 +5840,10 @@ struct GenTreeMultiRegOp : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeMultiRegOp() : GenTreeOp() {} + GenTreeMultiRegOp() + : GenTreeOp() + { + } #endif }; #endif // !defined(TARGET_64BIT) @@ -5712,7 +5859,9 @@ struct GenTreeFptrVal : public GenTree #endif GenTreeFptrVal(var_types type, CORINFO_METHOD_HANDLE meth) - : GenTree(GT_FTN_ADDR, type), gtFptrMethod(meth), gtFptrDelegateTarget(false) + : GenTree(GT_FTN_ADDR, type) + , gtFptrMethod(meth) + , gtFptrDelegateTarget(false) { #ifdef FEATURE_READYTORUN gtEntryPoint.addr = nullptr; @@ -5720,7 +5869,10 @@ struct GenTreeFptrVal : public GenTree #endif } #if DEBUGGABLE_GENTREE - GenTreeFptrVal() : GenTree() {} + GenTreeFptrVal() + : GenTree() + { + } #endif }; @@ -5730,7 +5882,8 @@ struct GenTreeQmark : public GenTreeOp unsigned gtThenLikelihood; GenTreeQmark(var_types type, GenTree* cond, GenTreeColon* colon, unsigned thenLikelihood = 50) - : GenTreeOp(GT_QMARK, type, cond, colon), gtThenLikelihood(thenLikelihood) + : GenTreeOp(GT_QMARK, type, cond, colon) + , gtThenLikelihood(thenLikelihood) { // These must follow a specific form. assert((cond != nullptr) && cond->TypeIs(TYP_INT)); @@ -5766,7 +5919,10 @@ struct GenTreeQmark : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeQmark() : GenTreeOp() {} + GenTreeQmark() + : GenTreeOp() + { + } #endif }; @@ -5783,20 +5939,27 @@ struct GenTreeIntrinsic : public GenTreeOp #endif GenTreeIntrinsic(var_types type, GenTree* op1, NamedIntrinsic intrinsicName, CORINFO_METHOD_HANDLE methodHandle) - : GenTreeOp(GT_INTRINSIC, type, op1, nullptr), gtIntrinsicName(intrinsicName), gtMethodHandle(methodHandle) + : GenTreeOp(GT_INTRINSIC, type, op1, nullptr) + , gtIntrinsicName(intrinsicName) + , gtMethodHandle(methodHandle) { assert(intrinsicName != NI_Illegal); } GenTreeIntrinsic( var_types type, GenTree* op1, GenTree* op2, NamedIntrinsic intrinsicName, CORINFO_METHOD_HANDLE methodHandle) - : GenTreeOp(GT_INTRINSIC, type, op1, op2), gtIntrinsicName(intrinsicName), gtMethodHandle(methodHandle) + : GenTreeOp(GT_INTRINSIC, type, op1, op2) + , gtIntrinsicName(intrinsicName) + , gtMethodHandle(methodHandle) { assert(intrinsicName != NI_Illegal); } #if DEBUGGABLE_GENTREE - GenTreeIntrinsic() : GenTreeOp() {} + GenTreeIntrinsic() + : GenTreeOp() + { + } #endif }; @@ -5814,7 +5977,10 @@ struct GenTreeMultiOp : public GenTree protected: GenTree** m_use; - Iterator(GenTree** use) : m_use(use) {} + Iterator(GenTree** use) + : m_use(use) + { + } public: Iterator& operator++() @@ -5837,7 +6003,10 @@ struct GenTreeMultiOp : public GenTree class OperandsIterator final : public Iterator { public: - OperandsIterator(GenTree** use) : Iterator(use) {} + OperandsIterator(GenTree** use) + : Iterator(use) + { + } GenTree* operator*() { @@ -5848,7 +6017,10 @@ struct GenTreeMultiOp : public GenTree class UseEdgesIterator final : public Iterator { public: - UseEdgesIterator(GenTree** use) : Iterator(use) {} + UseEdgesIterator(GenTree** use) + : Iterator(use) + { + } GenTree** operator*() { @@ -5893,7 +6065,10 @@ struct GenTreeMultiOp : public GenTree public: #if DEBUGGABLE_GENTREE - GenTreeMultiOp() : GenTree() {} + GenTreeMultiOp() + : GenTree() + { + } #endif GenTree*& Op(size_t index) @@ -5964,7 +6139,8 @@ class IntrinsicNodeBuilder final GenTree* m_inlineOperands[2]; public: - IntrinsicNodeBuilder(CompAllocator allocator, size_t operandCount) : m_operandCount(operandCount) + IntrinsicNodeBuilder(CompAllocator allocator, size_t operandCount) + : m_operandCount(operandCount) { m_operands = (operandCount <= ArrLen(m_inlineOperands)) ? m_inlineOperands : allocator.allocate(operandCount); @@ -5976,7 +6152,8 @@ class IntrinsicNodeBuilder final #endif // DEBUG } - IntrinsicNodeBuilder(CompAllocator allocator, GenTreeMultiOp* source) : m_operandCount(source->GetOperandCount()) + IntrinsicNodeBuilder(CompAllocator allocator, GenTreeMultiOp* source) + : m_operandCount(source->GetOperandCount()) { m_operands = (m_operandCount <= ArrLen(m_inlineOperands)) ? m_inlineOperands : allocator.allocate(m_operandCount); @@ -6188,7 +6365,10 @@ struct GenTreeJitIntrinsic : public GenTreeMultiOp } #if DEBUGGABLE_GENTREE - GenTreeJitIntrinsic() : GenTreeMultiOp() {} + GenTreeJitIntrinsic() + : GenTreeMultiOp() + { + } #endif protected: @@ -6247,7 +6427,10 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic } #if DEBUGGABLE_GENTREE - GenTreeHWIntrinsic() : GenTreeJitIntrinsic() {} + GenTreeHWIntrinsic() + : GenTreeJitIntrinsic() + { + } #endif bool OperIsMemoryLoad(GenTree** pAddr = nullptr) const; @@ -6763,7 +6946,8 @@ struct GenTreeVecCon : public GenTree } } - GenTreeVecCon(var_types type) : GenTree(GT_CNS_VEC, type) + GenTreeVecCon(var_types type) + : GenTree(GT_CNS_VEC, type) { assert(varTypeIsSIMD(type)); @@ -6779,7 +6963,10 @@ struct GenTreeVecCon : public GenTree } #if DEBUGGABLE_GENTREE - GenTreeVecCon() : GenTree() {} + GenTreeVecCon() + : GenTree() + { + } #endif }; @@ -6834,7 +7021,10 @@ struct GenTreeIndexAddr : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeIndexAddr() : GenTreeOp() {} + GenTreeIndexAddr() + : GenTreeOp() + { + } #endif bool IsBoundsChecked() const @@ -6872,7 +7062,10 @@ struct GenTreeArrAddr : GenTreeUnOp } #if DEBUGGABLE_GENTREE - GenTreeArrAddr() : GenTreeUnOp() {} + GenTreeArrAddr() + : GenTreeUnOp() + { + } #endif GenTree*& Addr() @@ -6917,10 +7110,16 @@ struct GenTreeArrCommon : public GenTreeUnOp return gtOp1; } - GenTreeArrCommon(genTreeOps oper, var_types type, GenTree* arrRef) : GenTreeUnOp(oper, type, arrRef) {} + GenTreeArrCommon(genTreeOps oper, var_types type, GenTree* arrRef) + : GenTreeUnOp(oper, type, arrRef) + { + } #if DEBUGGABLE_GENTREE - GenTreeArrCommon() : GenTreeUnOp() {} + GenTreeArrCommon() + : GenTreeUnOp() + { + } #endif }; @@ -6943,12 +7142,16 @@ struct GenTreeArrLen : public GenTreeArrCommon } GenTreeArrLen(var_types type, GenTree* arrRef, int lenOffset) - : GenTreeArrCommon(GT_ARR_LENGTH, type, arrRef), gtArrLenOffset(lenOffset) + : GenTreeArrCommon(GT_ARR_LENGTH, type, arrRef) + , gtArrLenOffset(lenOffset) { } #if DEBUGGABLE_GENTREE - GenTreeArrLen() : GenTreeArrCommon() {} + GenTreeArrLen() + : GenTreeArrCommon() + { + } #endif }; @@ -6973,13 +7176,18 @@ struct GenTreeMDArr : public GenTreeArrCommon } GenTreeMDArr(genTreeOps oper, GenTree* arrRef, unsigned dim, unsigned rank) - : GenTreeArrCommon(oper, TYP_INT, arrRef), gtDim(dim), gtRank(rank) + : GenTreeArrCommon(oper, TYP_INT, arrRef) + , gtDim(dim) + , gtRank(rank) { assert(OperIs(GT_MDARR_LENGTH, GT_MDARR_LOWER_BOUND)); } #if DEBUGGABLE_GENTREE - GenTreeMDArr() : GenTreeArrCommon() {} + GenTreeMDArr() + : GenTreeArrCommon() + { + } #endif }; @@ -7009,7 +7217,10 @@ struct GenTreeBoundsChk : public GenTreeOp gtFlags |= GTF_EXCEPT; } #if DEBUGGABLE_GENTREE - GenTreeBoundsChk() : GenTreeOp() {} + GenTreeBoundsChk() + : GenTreeOp() + { + } #endif // If this check is against GT_ARR_LENGTH or GT_MDARR_LENGTH, returns array reference, else nullptr. @@ -7057,7 +7268,10 @@ struct GenTreeArrElem : public GenTree // Requires that "inds" is a pointer to an array of "rank" nodes for the indices. GenTreeArrElem(var_types type, GenTree* arr, unsigned char rank, unsigned char elemSize, GenTree** inds) - : GenTree(GT_ARR_ELEM, type), gtArrObj(arr), gtArrRank(rank), gtArrElemSize(elemSize) + : GenTree(GT_ARR_ELEM, type) + , gtArrObj(arr) + , gtArrRank(rank) + , gtArrElemSize(elemSize) { assert(rank <= ArrLen(gtArrInds)); gtFlags |= (arr->gtFlags & GTF_ALL_EFFECT); @@ -7069,7 +7283,10 @@ struct GenTreeArrElem : public GenTree gtFlags |= GTF_EXCEPT; } #if DEBUGGABLE_GENTREE - GenTreeArrElem() : GenTree() {} + GenTreeArrElem() + : GenTree() + { + } #endif }; @@ -7161,7 +7378,10 @@ struct GenTreeAddrMode : public GenTreeOp protected: friend GenTree; // Used only for GenTree::GetVtableForOper() - GenTreeAddrMode() : GenTreeOp() {} + GenTreeAddrMode() + : GenTreeOp() + { + } #endif }; @@ -7195,7 +7415,10 @@ struct GenTreeIndir : public GenTreeOp unsigned Size() const; - GenTreeIndir(genTreeOps oper, var_types type, GenTree* addr, GenTree* data) : GenTreeOp(oper, type, addr, data) {} + GenTreeIndir(genTreeOps oper, var_types type, GenTree* addr, GenTree* data) + : GenTreeOp(oper, type, addr, data) + { + } // True if this indirection is a volatile memory operation. bool IsVolatile() const @@ -7219,10 +7442,16 @@ struct GenTreeIndir : public GenTreeOp #if DEBUGGABLE_GENTREE // Used only for GenTree::GetVtableForOper() - GenTreeIndir() : GenTreeOp() {} + GenTreeIndir() + : GenTreeOp() + { + } #else // Used by XARCH codegen to construct temporary trees to pass to the emitter. - GenTreeIndir() : GenTreeOp(GT_NOP, TYP_UNDEF) {} + GenTreeIndir() + : GenTreeOp(GT_NOP, TYP_UNDEF) + { + } #endif }; @@ -7328,7 +7557,10 @@ struct GenTreeBlk : public GenTreeIndir #if DEBUGGABLE_GENTREE protected: friend GenTree; - GenTreeBlk() : GenTreeIndir() {} + GenTreeBlk() + : GenTreeIndir() + { + } #endif // DEBUGGABLE_GENTREE }; @@ -7432,7 +7664,8 @@ struct GenTreeStoreInd : public GenTreeIndir return gtOp2; } - GenTreeStoreInd(var_types type, GenTree* destPtr, GenTree* data) : GenTreeIndir(GT_STOREIND, type, destPtr, data) + GenTreeStoreInd(var_types type, GenTree* destPtr, GenTree* data) + : GenTreeIndir(GT_STOREIND, type, destPtr, data) { SetRMWStatusDefault(); } @@ -7441,7 +7674,8 @@ struct GenTreeStoreInd : public GenTreeIndir protected: friend GenTree; // Used only for GenTree::GetVtableForOper() - GenTreeStoreInd() : GenTreeIndir() + GenTreeStoreInd() + : GenTreeIndir() { SetRMWStatusDefault(); } @@ -7455,13 +7689,17 @@ struct GenTreeCmpXchg : public GenTreeIndir public: GenTreeCmpXchg(var_types type, GenTree* loc, GenTree* val, GenTree* comparand) - : GenTreeIndir(GT_CMPXCHG, type, loc, val), m_comparand(comparand) + : GenTreeIndir(GT_CMPXCHG, type, loc, val) + , m_comparand(comparand) { gtFlags |= comparand->gtFlags & GTF_ALL_EFFECT; } #if DEBUGGABLE_GENTREE - GenTreeCmpXchg() : GenTreeIndir() {} + GenTreeCmpXchg() + : GenTreeIndir() + { + } #endif GenTree*& Comparand() @@ -7487,9 +7725,15 @@ struct GenTreeRetExpr : public GenTree // nullptr for cases where gtSubstExpr is not a tree from the inlinee. BasicBlock* gtSubstBB; - GenTreeRetExpr(var_types type) : GenTree(GT_RET_EXPR, type) {} + GenTreeRetExpr(var_types type) + : GenTree(GT_RET_EXPR, type) + { + } #if DEBUGGABLE_GENTREE - GenTreeRetExpr() : GenTree() {} + GenTreeRetExpr() + : GenTree() + { + } #endif }; @@ -7511,7 +7755,10 @@ struct GenTreeILOffset : public GenTree } #if DEBUGGABLE_GENTREE - GenTreeILOffset() : GenTree(GT_IL_OFFSET, TYP_VOID) {} + GenTreeILOffset() + : GenTree(GT_IL_OFFSET, TYP_VOID) + { + } #endif }; @@ -7531,7 +7778,10 @@ class GenTreeList GenTree* m_tree; public: - explicit iterator(GenTree* tree) : m_tree(tree) {} + explicit iterator(GenTree* tree) + : m_tree(tree) + { + } GenTree* operator*() const { @@ -7550,7 +7800,10 @@ class GenTreeList } }; - explicit GenTreeList(GenTree* trees) : m_trees(trees) {} + explicit GenTreeList(GenTree* trees) + : m_trees(trees) + { + } iterator begin() const { @@ -7573,7 +7826,10 @@ class LocalsGenTreeList GenTreeLclVarCommon* m_tree; public: - explicit iterator(GenTreeLclVarCommon* tree) : m_tree(tree) {} + explicit iterator(GenTreeLclVarCommon* tree) + : m_tree(tree) + { + } GenTreeLclVarCommon* operator*() const { @@ -7600,7 +7856,10 @@ class LocalsGenTreeList } }; - explicit LocalsGenTreeList(Statement* stmt) : m_stmt(stmt) {} + explicit LocalsGenTreeList(Statement* stmt) + : m_stmt(stmt) + { + } iterator begin() const; @@ -7798,7 +8057,10 @@ class StatementList Statement* m_stmt; public: - iterator(Statement* stmt) : m_stmt(stmt) {} + iterator(Statement* stmt) + : m_stmt(stmt) + { + } Statement* operator*() const { @@ -7818,7 +8080,10 @@ class StatementList }; public: - StatementList(Statement* stmts) : m_stmts(stmts) {} + StatementList(Statement* stmts) + : m_stmts(stmts) + { + } iterator begin() const { @@ -7841,13 +8106,17 @@ struct GenTreePhiArg : public GenTreeLclVarCommon BasicBlock* gtPredBB; GenTreePhiArg(var_types type, unsigned lclNum, unsigned ssaNum, BasicBlock* block) - : GenTreeLclVarCommon(GT_PHI_ARG, type, lclNum), gtPredBB(block) + : GenTreeLclVarCommon(GT_PHI_ARG, type, lclNum) + , gtPredBB(block) { SetSsaNum(ssaNum); } #if DEBUGGABLE_GENTREE - GenTreePhiArg() : GenTreeLclVarCommon() {} + GenTreePhiArg() + : GenTreeLclVarCommon() + { + } #endif }; @@ -7883,8 +8152,13 @@ struct GenTreePutArgStk : public GenTreeUnOp // TODO-Throughput: The following information should be obtained from the child // block node. - enum class Kind : int8_t{ - Invalid, RepInstr, PartialRepInstr, Unroll, Push, + enum class Kind : int8_t + { + Invalid, + RepInstr, + PartialRepInstr, + Unroll, + Push, }; Kind gtPutArgStkKind; @@ -8016,7 +8290,10 @@ struct GenTreePutArgStk : public GenTreeUnOp #endif // !FEATURE_PUT_STRUCT_ARG_STK #if DEBUGGABLE_GENTREE - GenTreePutArgStk() : GenTreeUnOp() {} + GenTreePutArgStk() + : GenTreeUnOp() + { + } #endif }; @@ -8164,7 +8441,10 @@ struct GenTreePutArgSplit : public GenTreePutArgStk } #if DEBUGGABLE_GENTREE - GenTreePutArgSplit() : GenTreePutArgStk() {} + GenTreePutArgSplit() + : GenTreePutArgStk() + { + } #endif }; #endif // FEATURE_ARG_SPLIT @@ -8289,7 +8569,8 @@ struct GenTreeCopyOrReload : public GenTreeUnOp return 1; } - GenTreeCopyOrReload(genTreeOps oper, var_types type, GenTree* op1) : GenTreeUnOp(oper, type, op1) + GenTreeCopyOrReload(genTreeOps oper, var_types type, GenTree* op1) + : GenTreeUnOp(oper, type, op1) { assert(type != TYP_STRUCT || op1->IsMultiRegNode()); SetRegNum(REG_NA); @@ -8297,7 +8578,10 @@ struct GenTreeCopyOrReload : public GenTreeUnOp } #if DEBUGGABLE_GENTREE - GenTreeCopyOrReload() : GenTreeUnOp() {} + GenTreeCopyOrReload() + : GenTreeUnOp() + { + } #endif }; @@ -8325,7 +8609,10 @@ struct GenTreeAllocObj final : public GenTreeUnOp #endif } #if DEBUGGABLE_GENTREE - GenTreeAllocObj() : GenTreeUnOp() {} + GenTreeAllocObj() + : GenTreeUnOp() + { + } #endif }; @@ -8337,12 +8624,17 @@ struct GenTreeRuntimeLookup final : public GenTreeUnOp CorInfoGenericHandleType gtHndType; GenTreeRuntimeLookup(CORINFO_GENERIC_HANDLE hnd, CorInfoGenericHandleType hndTyp, GenTree* tree) - : GenTreeUnOp(GT_RUNTIMELOOKUP, tree->gtType, tree DEBUGARG(/*largeNode*/ FALSE)), gtHnd(hnd), gtHndType(hndTyp) + : GenTreeUnOp(GT_RUNTIMELOOKUP, tree->gtType, tree DEBUGARG(/*largeNode*/ FALSE)) + , gtHnd(hnd) + , gtHndType(hndTyp) { assert(hnd != nullptr); } #if DEBUGGABLE_GENTREE - GenTreeRuntimeLookup() : GenTreeUnOp() {} + GenTreeRuntimeLookup() + : GenTreeUnOp() + { + } #endif // Return reference to the actual tree that does the lookup @@ -8504,9 +8796,15 @@ struct GenCondition return names[m_code]; } - GenCondition() : m_code() {} + GenCondition() + : m_code() + { + } - GenCondition(Code cond) : m_code(cond) {} + GenCondition(Code cond) + : m_code(cond) + { + } static_assert((GT_NE - GT_EQ) == (NE & ~Unsigned), "bad relop"); static_assert((GT_LT - GT_EQ) == SLT, "bad relop"); @@ -8628,13 +8926,17 @@ struct GenTreeCC final : public GenTree GenCondition gtCondition; GenTreeCC(genTreeOps oper, var_types type, GenCondition condition) - : GenTree(oper, type DEBUGARG(/*largeNode*/ FALSE)), gtCondition(condition) + : GenTree(oper, type DEBUGARG(/*largeNode*/ FALSE)) + , gtCondition(condition) { assert(OperIs(GT_JCC, GT_SETCC)); } #if DEBUGGABLE_GENTREE - GenTreeCC() : GenTree() {} + GenTreeCC() + : GenTree() + { + } #endif // DEBUGGABLE_GENTREE }; @@ -8644,7 +8946,8 @@ struct GenTreeOpCC : public GenTreeOp GenCondition gtCondition; GenTreeOpCC(genTreeOps oper, var_types type, GenCondition condition, GenTree* op1 = nullptr, GenTree* op2 = nullptr) - : GenTreeOp(oper, type, op1, op2 DEBUGARG(/*largeNode*/ FALSE)), gtCondition(condition) + : GenTreeOp(oper, type, op1, op2 DEBUGARG(/*largeNode*/ FALSE)) + , gtCondition(condition) { #ifdef TARGET_ARM64 assert(OperIs(GT_SELECTCC, GT_SELECT_INCCC, GT_SELECT_INVCC, GT_SELECT_NEGCC)); @@ -8654,7 +8957,10 @@ struct GenTreeOpCC : public GenTreeOp } #if DEBUGGABLE_GENTREE - GenTreeOpCC() : GenTreeOp() {} + GenTreeOpCC() + : GenTreeOp() + { + } #endif // DEBUGGABLE_GENTREE }; @@ -8687,12 +8993,16 @@ struct GenTreeCCMP final : public GenTreeOpCC insCflags gtFlagsVal; GenTreeCCMP(var_types type, GenCondition condition, GenTree* op1, GenTree* op2, insCflags flagsVal) - : GenTreeOpCC(GT_CCMP, type, condition, op1, op2), gtFlagsVal(flagsVal) + : GenTreeOpCC(GT_CCMP, type, condition, op1, op2) + , gtFlagsVal(flagsVal) { } #if DEBUGGABLE_GENTREE - GenTreeCCMP() : GenTreeOpCC() {} + GenTreeCCMP() + : GenTreeOpCC() + { + } #endif // DEBUGGABLE_GENTREE }; #endif diff --git a/src/coreclr/jit/gschecks.cpp b/src/coreclr/jit/gschecks.cpp index 0fff29596c2866..7b448b8ca3d24e 100644 --- a/src/coreclr/jit/gschecks.cpp +++ b/src/coreclr/jit/gschecks.cpp @@ -455,7 +455,10 @@ void Compiler::gsParamsToShadows() DoPostOrder = true }; - ReplaceShadowParamsVisitor(Compiler* compiler) : GenTreeVisitor(compiler) {} + ReplaceShadowParamsVisitor(Compiler* compiler) + : GenTreeVisitor(compiler) + { + } Compiler::fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { diff --git a/src/coreclr/jit/hashbv.cpp b/src/coreclr/jit/hashbv.cpp index da9bc5c5eb0d6a..203219a7ec20ca 100644 --- a/src/coreclr/jit/hashbv.cpp +++ b/src/coreclr/jit/hashbv.cpp @@ -449,7 +449,9 @@ hashBv* hashBv::CreateFrom(hashBv* other, Compiler* comp) return result; } -void hashBv::MergeLists(hashBvNode** root1, hashBvNode** root2) {} +void hashBv::MergeLists(hashBvNode** root1, hashBvNode** root2) +{ +} bool hashBv::TooSmall() { @@ -615,17 +617,15 @@ void hashBv::dump() // DBEXEC(TRUE, printf("[%d(%d)(nodes:%d)]{ ", hashtable_size(), countBits(), this->numNodes)); printf("{"); - ForEachHbvBitSet(*this, - [&](indexType index) - { - if (!first) - { - printf(" "); - } - printf("%d", index); - first = false; - return HbvWalk::Continue; - }); + ForEachHbvBitSet(*this, [&](indexType index) { + if (!first) + { + printf(" "); + } + printf("%d", index); + first = false; + return HbvWalk::Continue; + }); printf("}\n"); } @@ -636,25 +636,23 @@ void hashBv::dumpFancy() printf("{"); printf("count:%d", this->countBits()); - ForEachHbvBitSet(*this, - [&](indexType index) - { - if (last_1 != index - 1) - { - if (last_0 + 1 != last_1) - { - printf(" %d-%d", last_0 + 1, last_1); - } - else - { - printf(" %d", last_1); - } - last_0 = index - 1; - } - last_1 = index; - - return HbvWalk::Continue; - }); + ForEachHbvBitSet(*this, [&](indexType index) { + if (last_1 != index - 1) + { + if (last_0 + 1 != last_1) + { + printf(" %d-%d", last_0 + 1, last_1); + } + else + { + printf(" %d", last_1); + } + last_0 = index - 1; + } + last_1 = index; + + return HbvWalk::Continue; + }); // Print the last one if (last_0 + 1 != last_1) @@ -936,8 +934,12 @@ bool hashBv::anySet() class AndAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) {} - static inline void PostAction(hashBv* lhs, hashBv* rhs) {} + static inline void PreAction(hashBv* lhs, hashBv* rhs) + { + } + static inline void PostAction(hashBv* lhs, hashBv* rhs) + { + } static inline bool DefaultResult() { return false; @@ -994,8 +996,12 @@ class AndAction class SubtractAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) {} - static inline void PostAction(hashBv* lhs, hashBv* rhs) {} + static inline void PreAction(hashBv* lhs, hashBv* rhs) + { + } + static inline void PostAction(hashBv* lhs, hashBv* rhs) + { + } static inline bool DefaultResult() { return false; @@ -1046,8 +1052,12 @@ class SubtractAction class XorAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) {} - static inline void PostAction(hashBv* lhs, hashBv* rhs) {} + static inline void PreAction(hashBv* lhs, hashBv* rhs) + { + } + static inline void PostAction(hashBv* lhs, hashBv* rhs) + { + } static inline bool DefaultResult() { return false; @@ -1115,7 +1125,9 @@ class OrAction rhs->Resize(rhs->numNodes); } } - static inline void PostAction(hashBv* lhs, hashBv* rhs) {} + static inline void PostAction(hashBv* lhs, hashBv* rhs) + { + } static inline bool DefaultResult() { return false; @@ -1170,8 +1182,12 @@ class OrAction class CompareAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) {} - static inline void PostAction(hashBv* lhs, hashBv* rhs) {} + static inline void PreAction(hashBv* lhs, hashBv* rhs) + { + } + static inline void PostAction(hashBv* lhs, hashBv* rhs) + { + } static inline bool DefaultResult() { return true; @@ -1209,8 +1225,12 @@ class CompareAction class IntersectsAction { public: - static inline void PreAction(hashBv* lhs, hashBv* rhs) {} - static inline void PostAction(hashBv* lhs, hashBv* rhs) {} + static inline void PreAction(hashBv* lhs, hashBv* rhs) + { + } + static inline void PostAction(hashBv* lhs, hashBv* rhs) + { + } static inline bool DefaultResult() { return false; diff --git a/src/coreclr/jit/hashbv.h b/src/coreclr/jit/hashbv.h index 2cebf3c1f7bfca..561a1c5641e491 100644 --- a/src/coreclr/jit/hashbv.h +++ b/src/coreclr/jit/hashbv.h @@ -15,13 +15,13 @@ // #define TESTING 1 -#define LOG2_BITS_PER_ELEMENT 5 +#define LOG2_BITS_PER_ELEMENT 5 #define LOG2_ELEMENTS_PER_NODE 2 -#define LOG2_BITS_PER_NODE (LOG2_BITS_PER_ELEMENT + LOG2_ELEMENTS_PER_NODE) +#define LOG2_BITS_PER_NODE (LOG2_BITS_PER_ELEMENT + LOG2_ELEMENTS_PER_NODE) -#define BITS_PER_ELEMENT (1 << LOG2_BITS_PER_ELEMENT) +#define BITS_PER_ELEMENT (1 << LOG2_BITS_PER_ELEMENT) #define ELEMENTS_PER_NODE (1 << LOG2_ELEMENTS_PER_NODE) -#define BITS_PER_NODE (1 << LOG2_BITS_PER_NODE) +#define BITS_PER_NODE (1 << LOG2_BITS_PER_NODE) #ifdef TARGET_AMD64 typedef unsigned __int64 elemType; @@ -124,7 +124,9 @@ class hashBvNode public: hashBvNode(indexType base); - hashBvNode() {} + hashBvNode() + { + } static hashBvNode* Create(indexType base, Compiler* comp); void Reconstruct(indexType base); int numElements() diff --git a/src/coreclr/jit/hostallocator.h b/src/coreclr/jit/hostallocator.h index fc6d0c80660dcc..0e8f192063fb06 100644 --- a/src/coreclr/jit/hostallocator.h +++ b/src/coreclr/jit/hostallocator.h @@ -6,7 +6,9 @@ class HostAllocator final { private: - HostAllocator() {} + HostAllocator() + { + } public: template diff --git a/src/coreclr/jit/hwintrinsic.h b/src/coreclr/jit/hwintrinsic.h index 1f88758b847679..b95f9fc85e946f 100644 --- a/src/coreclr/jit/hwintrinsic.h +++ b/src/coreclr/jit/hwintrinsic.h @@ -454,13 +454,13 @@ struct TernaryLogicInfo // We have 256 entries, so we compress as much as possible // This gives us 3-bytes per entry (21-bits) - TernaryLogicOperKind oper1 : 4; + TernaryLogicOperKind oper1 : 4; TernaryLogicUseFlags oper1Use : 3; - TernaryLogicOperKind oper2 : 4; + TernaryLogicOperKind oper2 : 4; TernaryLogicUseFlags oper2Use : 3; - TernaryLogicOperKind oper3 : 4; + TernaryLogicOperKind oper3 : 4; TernaryLogicUseFlags oper3Use : 3; static const TernaryLogicInfo& lookup(uint8_t control); @@ -936,7 +936,12 @@ struct HWIntrinsicInfo struct HWIntrinsic final { HWIntrinsic(const GenTreeHWIntrinsic* node) - : op1(nullptr), op2(nullptr), op3(nullptr), op4(nullptr), numOperands(0), baseType(TYP_UNDEF) + : op1(nullptr) + , op2(nullptr) + , op3(nullptr) + , op4(nullptr) + , numOperands(0) + , baseType(TYP_UNDEF) { assert(node != nullptr); diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index aaee0202755312..816e41862d6277 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -36,7 +36,10 @@ // of a for-loop. // CodeGen::HWIntrinsicImmOpHelper::HWIntrinsicImmOpHelper(CodeGen* codeGen, GenTree* immOp, GenTreeHWIntrinsic* intrin) - : codeGen(codeGen), endLabel(nullptr), nonZeroLabel(nullptr), branchTargetReg(REG_NA) + : codeGen(codeGen) + , endLabel(nullptr) + , nonZeroLabel(nullptr) + , branchTargetReg(REG_NA) { assert(codeGen != nullptr); assert(varTypeIsIntegral(immOp)); @@ -346,8 +349,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) { assert(hasImmediateOperand); - auto emitShift = [&](GenTree* op, regNumber reg) - { + auto emitShift = [&](GenTree* op, regNumber reg) { HWIntrinsicImmOpHelper helper(this, op, node); for (helper.EmitBegin(); !helper.Done(); helper.EmitCaseEnd()) diff --git a/src/coreclr/jit/hwintrinsiccodegenxarch.cpp b/src/coreclr/jit/hwintrinsiccodegenxarch.cpp index d915abcee148e2..79e6b497c368a9 100644 --- a/src/coreclr/jit/hwintrinsiccodegenxarch.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenxarch.cpp @@ -319,8 +319,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) { regNumber targetReg = node->GetRegNum(); GenTree* rmOp = node->Op(1); - auto emitSwCase = [&](int8_t i) - { + auto emitSwCase = [&](int8_t i) { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_RM(node, ins, simdSize, targetReg, rmOp, newInstOptions); }; @@ -332,8 +331,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) } case 2: { - auto emitSwCase = [&](int8_t i) - { + auto emitSwCase = [&](int8_t i) { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_R_RM(node, ins, simdSize, newInstOptions); }; @@ -500,8 +498,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) } else if (HWIntrinsicInfo::isImmOp(intrinsicId, op2)) { - auto emitSwCase = [&](int8_t i) - { + auto emitSwCase = [&](int8_t i) { if (HWIntrinsicInfo::CopiesUpperBits(intrinsicId)) { assert(!op1->isContained()); @@ -562,7 +559,9 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) if (HWIntrinsicInfo::isImmOp(intrinsicId, op3)) { - auto emitSwCase = [&](int8_t i) { genHWIntrinsic_R_R_RM_I(node, ins, simdSize, i); }; + auto emitSwCase = [&](int8_t i) { + genHWIntrinsic_R_R_RM_I(node, ins, simdSize, i); + }; if (op3->IsCnsIntOrI()) { @@ -656,7 +655,9 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) if (HWIntrinsicInfo::isImmOp(intrinsicId, op4)) { - auto emitSwCase = [&](int8_t i) { genHWIntrinsic_R_R_R_RM_I(node, ins, simdSize, i); }; + auto emitSwCase = [&](int8_t i) { + genHWIntrinsic_R_R_R_RM_I(node, ins, simdSize, i); + }; if (op4->IsCnsIntOrI()) { @@ -1368,8 +1369,7 @@ void CodeGen::genNonTableDrivenHWIntrinsicsJumpTableFallback(GenTreeHWIntrinsic* // This intrinsic has several overloads, only the ones with floating number inputs should reach this part. assert(varTypeIsFloating(baseType)); GenTree* rmOp = node->Op(1); - auto emitSwCase = [&](int8_t i) - { + auto emitSwCase = [&](int8_t i) { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_RM(node, ins, attr, targetReg, rmOp, newInstOptions); }; @@ -1390,8 +1390,7 @@ void CodeGen::genNonTableDrivenHWIntrinsicsJumpTableFallback(GenTreeHWIntrinsic* attr = emitTypeSize(targetType); GenTree* rmOp = node->Op(1); - auto emitSwCase = [&](int8_t i) - { + auto emitSwCase = [&](int8_t i) { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_RM(node, ins, attr, targetReg, rmOp, newInstOptions); }; @@ -1405,8 +1404,7 @@ void CodeGen::genNonTableDrivenHWIntrinsicsJumpTableFallback(GenTreeHWIntrinsic* case NI_AVX512F_X64_ConvertScalarToVector128Double: { assert(varTypeIsLong(baseType)); - auto emitSwCase = [&](int8_t i) - { + auto emitSwCase = [&](int8_t i) { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_R_RM(node, ins, EA_8BYTE, newInstOptions); }; @@ -1438,8 +1436,7 @@ void CodeGen::genNonTableDrivenHWIntrinsicsJumpTableFallback(GenTreeHWIntrinsic* regNumber op1Reg = op1->GetRegNum(); regNumber op2Reg = op2->GetRegNum(); - auto emitSwCase = [&](int8_t i) - { + auto emitSwCase = [&](int8_t i) { insOpts newInstOptions = AddEmbRoundingMode(instOptions, i); genHWIntrinsic_R_R_R_RM(ins, attr, targetReg, op1Reg, op2Reg, op3, newInstOptions); }; @@ -2062,7 +2059,9 @@ void CodeGen::genSSE41Intrinsic(GenTreeHWIntrinsic* node) instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); emitAttr attr = emitActualTypeSize(node->TypeGet()); - auto emitSwCase = [&](int8_t i) { inst_RV_TT_IV(ins, attr, targetReg, op1, i); }; + auto emitSwCase = [&](int8_t i) { + inst_RV_TT_IV(ins, attr, targetReg, op1, i); + }; if (op2->IsCnsIntOrI()) { diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 515a22accdec6c..bb5231b11ce63f 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -10916,8 +10916,7 @@ void Compiler::impPoisonImplicitByrefsBeforeReturn() ClassLayout* layout = dsc->GetLayout(); assert(layout != nullptr); - auto poisonBlock = [this, lclNum](unsigned start, unsigned count) - { + auto poisonBlock = [this, lclNum](unsigned start, unsigned count) { if (count <= 0) { return; diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index c10f7aea175bcf..52fdf5ab3cd476 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -2204,10 +2204,9 @@ void Compiler::impPopArgsForSwiftCall(GenTreeCall* call, CORINFO_SIG_INFO* sig, else { unsigned relOffset = 0; - auto addSegment = [=, &loweredNode, &relOffset](var_types type) - { + auto addSegment = [=, &loweredNode, &relOffset](var_types type) { GenTree* val = gtNewLclFldNode(structVal->GetLclNum(), type, - structVal->GetLclOffs() + offset + relOffset); + structVal->GetLclOffs() + offset + relOffset); if (loweredType == TYP_LONG) { @@ -2217,7 +2216,7 @@ void Compiler::impPopArgsForSwiftCall(GenTreeCall* call, CORINFO_SIG_INFO* sig, if (relOffset > 0) { val = gtNewOperNode(GT_LSH, genActualType(loweredType), val, - gtNewIconNode(relOffset * 8)); + gtNewIconNode(relOffset * 8)); } if (loweredNode == nullptr) @@ -6116,7 +6115,10 @@ void Compiler::impCheckForPInvokeCall( class SpillRetExprHelper { public: - SpillRetExprHelper(Compiler* comp) : comp(comp) {} + SpillRetExprHelper(Compiler* comp) + : comp(comp) + { + } void StoreRetExprResultsInArgs(GenTreeCall* call) { @@ -8432,163 +8434,161 @@ void Compiler::impCheckCanInline(GenTreeCall* call, param.ppInlineCandidateInfo = ppInlineCandidateInfo; bool success = eeRunWithErrorTrap( - [](Param* pParam) - { - // Cache some frequently accessed state. - // - Compiler* const compiler = pParam->pThis; - COMP_HANDLE compCompHnd = compiler->info.compCompHnd; - CORINFO_METHOD_HANDLE ftn = pParam->fncHandle; - InlineResult* const inlineResult = pParam->result; + [](Param* pParam) { + // Cache some frequently accessed state. + // + Compiler* const compiler = pParam->pThis; + COMP_HANDLE compCompHnd = compiler->info.compCompHnd; + CORINFO_METHOD_HANDLE ftn = pParam->fncHandle; + InlineResult* const inlineResult = pParam->result; #ifdef DEBUG - if (JitConfig.JitNoInline()) - { - inlineResult->NoteFatal(InlineObservation::CALLEE_IS_JIT_NOINLINE); - return; - } + if (JitConfig.JitNoInline()) + { + inlineResult->NoteFatal(InlineObservation::CALLEE_IS_JIT_NOINLINE); + return; + } #endif - JITDUMP("\nCheckCanInline: fetching method info for inline candidate %s -- context %p\n", - compiler->eeGetMethodName(ftn), compiler->dspPtr(pParam->exactContextHnd)); - - if (pParam->exactContextHnd == METHOD_BEING_COMPILED_CONTEXT()) - { - JITDUMP("Current method context\n"); - } - else if ((((size_t)pParam->exactContextHnd & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_METHOD)) - { - JITDUMP("Method context: %s\n", - compiler->eeGetMethodFullName((CORINFO_METHOD_HANDLE)pParam->exactContextHnd)); - } - else - { - JITDUMP("Class context: %s\n", - compiler->eeGetClassName( - (CORINFO_CLASS_HANDLE)((size_t)pParam->exactContextHnd & ~CORINFO_CONTEXTFLAGS_MASK))); - } + JITDUMP("\nCheckCanInline: fetching method info for inline candidate %s -- context %p\n", + compiler->eeGetMethodName(ftn), compiler->dspPtr(pParam->exactContextHnd)); - // Fetch method info. This may fail, if the method doesn't have IL. - // - CORINFO_METHOD_INFO methInfo; - if (!compCompHnd->getMethodInfo(ftn, &methInfo, pParam->exactContextHnd)) - { - inlineResult->NoteFatal(InlineObservation::CALLEE_NO_METHOD_INFO); - return; - } + if (pParam->exactContextHnd == METHOD_BEING_COMPILED_CONTEXT()) + { + JITDUMP("Current method context\n"); + } + else if ((((size_t)pParam->exactContextHnd & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_METHOD)) + { + JITDUMP("Method context: %s\n", + compiler->eeGetMethodFullName((CORINFO_METHOD_HANDLE)pParam->exactContextHnd)); + } + else + { + JITDUMP("Class context: %s\n", + compiler->eeGetClassName( + (CORINFO_CLASS_HANDLE)((size_t)pParam->exactContextHnd & ~CORINFO_CONTEXTFLAGS_MASK))); + } - // Profile data allows us to avoid early "too many IL bytes" outs. - // - inlineResult->NoteBool(InlineObservation::CALLSITE_HAS_PROFILE_WEIGHTS, - compiler->fgHaveSufficientProfileWeights()); - inlineResult->NoteBool(InlineObservation::CALLSITE_INSIDE_THROW_BLOCK, - compiler->compCurBB->KindIs(BBJ_THROW)); + // Fetch method info. This may fail, if the method doesn't have IL. + // + CORINFO_METHOD_INFO methInfo; + if (!compCompHnd->getMethodInfo(ftn, &methInfo, pParam->exactContextHnd)) + { + inlineResult->NoteFatal(InlineObservation::CALLEE_NO_METHOD_INFO); + return; + } - bool const forceInline = (pParam->methAttr & CORINFO_FLG_FORCEINLINE) != 0; + // Profile data allows us to avoid early "too many IL bytes" outs. + // + inlineResult->NoteBool(InlineObservation::CALLSITE_HAS_PROFILE_WEIGHTS, + compiler->fgHaveSufficientProfileWeights()); + inlineResult->NoteBool(InlineObservation::CALLSITE_INSIDE_THROW_BLOCK, compiler->compCurBB->KindIs(BBJ_THROW)); - compiler->impCanInlineIL(ftn, &methInfo, forceInline, inlineResult); + bool const forceInline = (pParam->methAttr & CORINFO_FLG_FORCEINLINE) != 0; - if (inlineResult->IsFailure()) - { - assert(inlineResult->IsNever()); - return; - } + compiler->impCanInlineIL(ftn, &methInfo, forceInline, inlineResult); - // Speculatively check if initClass() can be done. - // If it can be done, we will try to inline the method. - CorInfoInitClassResult const initClassResult = - compCompHnd->initClass(nullptr /* field */, ftn /* method */, pParam->exactContextHnd /* context */); + if (inlineResult->IsFailure()) + { + assert(inlineResult->IsNever()); + return; + } - if (initClassResult & CORINFO_INITCLASS_DONT_INLINE) - { - inlineResult->NoteFatal(InlineObservation::CALLSITE_CANT_CLASS_INIT); - return; - } + // Speculatively check if initClass() can be done. + // If it can be done, we will try to inline the method. + CorInfoInitClassResult const initClassResult = + compCompHnd->initClass(nullptr /* field */, ftn /* method */, pParam->exactContextHnd /* context */); - // Given the VM the final say in whether to inline or not. - // This should be last since for verifiable code, this can be expensive - // - CorInfoInline const vmResult = compCompHnd->canInline(compiler->info.compMethodHnd, ftn); + if (initClassResult & CORINFO_INITCLASS_DONT_INLINE) + { + inlineResult->NoteFatal(InlineObservation::CALLSITE_CANT_CLASS_INIT); + return; + } - if (vmResult == INLINE_FAIL) - { - inlineResult->NoteFatal(InlineObservation::CALLSITE_IS_VM_NOINLINE); - } - else if (vmResult == INLINE_NEVER) - { - inlineResult->NoteFatal(InlineObservation::CALLEE_IS_VM_NOINLINE); - } + // Given the VM the final say in whether to inline or not. + // This should be last since for verifiable code, this can be expensive + // + CorInfoInline const vmResult = compCompHnd->canInline(compiler->info.compMethodHnd, ftn); - if (inlineResult->IsFailure()) - { - // The VM already self-reported this failure, so mark it specially - // so the JIT doesn't also try reporting it. - // - inlineResult->SetVMFailure(); - return; - } + if (vmResult == INLINE_FAIL) + { + inlineResult->NoteFatal(InlineObservation::CALLSITE_IS_VM_NOINLINE); + } + else if (vmResult == INLINE_NEVER) + { + inlineResult->NoteFatal(InlineObservation::CALLEE_IS_VM_NOINLINE); + } - // Get the method's class properties + if (inlineResult->IsFailure()) + { + // The VM already self-reported this failure, so mark it specially + // so the JIT doesn't also try reporting it. // - CORINFO_CLASS_HANDLE clsHandle = compCompHnd->getMethodClass(ftn); - unsigned const clsAttr = compCompHnd->getClassAttribs(clsHandle); + inlineResult->SetVMFailure(); + return; + } - // Return type - // - var_types const fncRetType = pParam->call->TypeGet(); + // Get the method's class properties + // + CORINFO_CLASS_HANDLE clsHandle = compCompHnd->getMethodClass(ftn); + unsigned const clsAttr = compCompHnd->getClassAttribs(clsHandle); + + // Return type + // + var_types const fncRetType = pParam->call->TypeGet(); #ifdef DEBUG - var_types fncRealRetType = JITtype2varType(methInfo.args.retType); + var_types fncRealRetType = JITtype2varType(methInfo.args.retType); - assert((genActualType(fncRealRetType) == genActualType(fncRetType)) || - // VSW 288602 - // In case of IJW, we allow to assign a native pointer to a BYREF. - (fncRetType == TYP_BYREF && methInfo.args.retType == CORINFO_TYPE_PTR) || - (varTypeIsStruct(fncRetType) && (fncRealRetType == TYP_STRUCT))); + assert((genActualType(fncRealRetType) == genActualType(fncRetType)) || + // VSW 288602 + // In case of IJW, we allow to assign a native pointer to a BYREF. + (fncRetType == TYP_BYREF && methInfo.args.retType == CORINFO_TYPE_PTR) || + (varTypeIsStruct(fncRetType) && (fncRealRetType == TYP_STRUCT))); #endif - // Allocate an InlineCandidateInfo structure, - // - // Or, reuse the existing GuardedDevirtualizationCandidateInfo, - // which was pre-allocated to have extra room. - // - InlineCandidateInfo* pInfo; + // Allocate an InlineCandidateInfo structure, + // + // Or, reuse the existing GuardedDevirtualizationCandidateInfo, + // which was pre-allocated to have extra room. + // + InlineCandidateInfo* pInfo; - if (pParam->call->IsGuardedDevirtualizationCandidate()) - { - pInfo = pParam->call->GetGDVCandidateInfo(pParam->candidateIndex); - } - else - { - pInfo = new (pParam->pThis, CMK_Inlining) InlineCandidateInfo; + if (pParam->call->IsGuardedDevirtualizationCandidate()) + { + pInfo = pParam->call->GetGDVCandidateInfo(pParam->candidateIndex); + } + else + { + pInfo = new (pParam->pThis, CMK_Inlining) InlineCandidateInfo; - // Null out bits we don't use when we're just inlining - // - pInfo->guardedClassHandle = nullptr; - pInfo->guardedMethodHandle = nullptr; - pInfo->guardedMethodUnboxedEntryHandle = nullptr; - pInfo->likelihood = 0; - pInfo->requiresInstMethodTableArg = false; - } - - pInfo->methInfo = methInfo; - pInfo->ilCallerHandle = pParam->pThis->info.compMethodHnd; - pInfo->clsHandle = clsHandle; - pInfo->exactContextHnd = pParam->exactContextHnd; - pInfo->retExpr = nullptr; - pInfo->preexistingSpillTemp = BAD_VAR_NUM; - pInfo->clsAttr = clsAttr; - pInfo->methAttr = pParam->methAttr; - pInfo->initClassResult = initClassResult; - pInfo->fncRetType = fncRetType; - pInfo->exactContextNeedsRuntimeLookup = false; - pInfo->inlinersContext = pParam->pThis->compInlineContext; - - // Note exactContextNeedsRuntimeLookup is reset later on, - // over in impMarkInlineCandidate. + // Null out bits we don't use when we're just inlining // - *(pParam->ppInlineCandidateInfo) = pInfo; - }, + pInfo->guardedClassHandle = nullptr; + pInfo->guardedMethodHandle = nullptr; + pInfo->guardedMethodUnboxedEntryHandle = nullptr; + pInfo->likelihood = 0; + pInfo->requiresInstMethodTableArg = false; + } + + pInfo->methInfo = methInfo; + pInfo->ilCallerHandle = pParam->pThis->info.compMethodHnd; + pInfo->clsHandle = clsHandle; + pInfo->exactContextHnd = pParam->exactContextHnd; + pInfo->retExpr = nullptr; + pInfo->preexistingSpillTemp = BAD_VAR_NUM; + pInfo->clsAttr = clsAttr; + pInfo->methAttr = pParam->methAttr; + pInfo->initClassResult = initClassResult; + pInfo->fncRetType = fncRetType; + pInfo->exactContextNeedsRuntimeLookup = false; + pInfo->inlinersContext = pParam->pThis->compInlineContext; + + // Note exactContextNeedsRuntimeLookup is reset later on, + // over in impMarkInlineCandidate. + // + *(pParam->ppInlineCandidateInfo) = pInfo; + }, ¶m); if (!success) diff --git a/src/coreclr/jit/importervectorization.cpp b/src/coreclr/jit/importervectorization.cpp index b001113618a4dd..26ae9225cbd7ed 100644 --- a/src/coreclr/jit/importervectorization.cpp +++ b/src/coreclr/jit/importervectorization.cpp @@ -317,7 +317,7 @@ GenTree* Compiler::impExpandHalfConstEqualsSWAR( assert(len >= 1 && len <= 8); // Compose Int32 or Int64 values from ushort components -#define MAKEINT32(c1, c2) ((UINT64)c2 << 16) | ((UINT64)c1 << 0) +#define MAKEINT32(c1, c2) ((UINT64)c2 << 16) | ((UINT64)c1 << 0) #define MAKEINT64(c1, c2, c3, c4) ((UINT64)c4 << 48) | ((UINT64)c3 << 32) | ((UINT64)c2 << 16) | ((UINT64)c1 << 0) if (len == 1) diff --git a/src/coreclr/jit/indirectcalltransformer.cpp b/src/coreclr/jit/indirectcalltransformer.cpp index 2ea5efe4975f17..a85ba05596b519 100644 --- a/src/coreclr/jit/indirectcalltransformer.cpp +++ b/src/coreclr/jit/indirectcalltransformer.cpp @@ -67,7 +67,10 @@ class IndirectCallTransformer { public: - IndirectCallTransformer(Compiler* compiler) : compiler(compiler) {} + IndirectCallTransformer(Compiler* compiler) + : compiler(compiler) + { + } //------------------------------------------------------------------------ // Run: run transformation for each block. @@ -155,7 +158,9 @@ class IndirectCallTransformer { public: Transformer(Compiler* compiler, BasicBlock* block, Statement* stmt) - : compiler(compiler), currBlock(block), stmt(stmt) + : compiler(compiler) + , currBlock(block) + , stmt(stmt) { remainderBlock = nullptr; checkBlock = nullptr; @@ -364,7 +369,9 @@ class IndirectCallTransformer } // FixupRetExpr: no action needed as we handle this in the importer. - virtual void FixupRetExpr() {} + virtual void FixupRetExpr() + { + } //------------------------------------------------------------------------ // CreateCheck: create check block, that checks fat pointer bit set. @@ -469,7 +476,8 @@ class IndirectCallTransformer { public: GuardedDevirtualizationTransformer(Compiler* compiler, BasicBlock* block, Statement* stmt) - : Transformer(compiler, block, stmt), returnTemp(BAD_VAR_NUM) + : Transformer(compiler, block, stmt) + , returnTemp(BAD_VAR_NUM) { } @@ -1255,7 +1263,9 @@ class IndirectCallTransformer unsigned m_nodeCount; ClonabilityVisitor(Compiler* compiler) - : GenTreeVisitor(compiler), m_unclonableNode(nullptr), m_nodeCount(0) + : GenTreeVisitor(compiler) + , m_unclonableNode(nullptr) + , m_nodeCount(0) { } diff --git a/src/coreclr/jit/inductionvariableopts.cpp b/src/coreclr/jit/inductionvariableopts.cpp index 53b2452af828c4..19755c312de350 100644 --- a/src/coreclr/jit/inductionvariableopts.cpp +++ b/src/coreclr/jit/inductionvariableopts.cpp @@ -65,28 +65,26 @@ bool Compiler::optCanSinkWidenedIV(unsigned lclNum, FlowGraphNaturalLoop* loop) { LclVarDsc* dsc = lvaGetDesc(lclNum); - BasicBlockVisit result = loop->VisitRegularExitBlocks( - [=](BasicBlock* exit) + BasicBlockVisit result = loop->VisitRegularExitBlocks([=](BasicBlock* exit) { + if (!VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) { - if (!VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) - { - JITDUMP(" Exit " FMT_BB " does not need a sink; V%02u is not live-in\n", exit->bbNum, lclNum); - return BasicBlockVisit::Continue; - } + JITDUMP(" Exit " FMT_BB " does not need a sink; V%02u is not live-in\n", exit->bbNum, lclNum); + return BasicBlockVisit::Continue; + } - for (BasicBlock* pred : exit->PredBlocks()) + for (BasicBlock* pred : exit->PredBlocks()) + { + if (!loop->ContainsBlock(pred)) { - if (!loop->ContainsBlock(pred)) - { - JITDUMP(" Cannot safely sink widened version of V%02u into exit " FMT_BB " of " FMT_LP - "; it has a non-loop pred " FMT_BB "\n", - lclNum, exit->bbNum, loop->GetIndex(), pred->bbNum); - return BasicBlockVisit::Abort; - } + JITDUMP(" Cannot safely sink widened version of V%02u into exit " FMT_BB " of " FMT_LP + "; it has a non-loop pred " FMT_BB "\n", + lclNum, exit->bbNum, loop->GetIndex(), pred->bbNum); + return BasicBlockVisit::Abort; } + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); #ifdef DEBUG // We currently do not expect to ever widen IVs that are live into @@ -94,23 +92,19 @@ bool Compiler::optCanSinkWidenedIV(unsigned lclNum, FlowGraphNaturalLoop* loop) // previously (EH write-thru is only for single def locals) which makes it // unprofitable. If this ever changes we need some more expansive handling // here. - loop->VisitLoopBlocks( - [=](BasicBlock* block) - { - block->VisitAllSuccs(this, - [=](BasicBlock* succ) - { - if (!loop->ContainsBlock(succ) && bbIsHandlerBeg(succ)) - { - assert(!VarSetOps::IsMember(this, succ->bbLiveIn, dsc->lvVarIndex) && - "Candidate IV for widening is live into exceptional exit"); - } - - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks([=](BasicBlock* block) { + block->VisitAllSuccs(this, [=](BasicBlock* succ) { + if (!loop->ContainsBlock(succ) && bbIsHandlerBeg(succ)) + { + assert(!VarSetOps::IsMember(this, succ->bbLiveIn, dsc->lvVarIndex) && + "Candidate IV for widening is live into exceptional exit"); + } return BasicBlockVisit::Continue; }); + + return BasicBlockVisit::Continue; + }); #endif return result != BasicBlockVisit::Abort; @@ -174,60 +168,58 @@ bool Compiler::optIsIVWideningProfitable(unsigned lclNum, weight_t savedCost = 0; int savedSize = 0; - loop->VisitLoopBlocks( - [&](BasicBlock* block) + loop->VisitLoopBlocks([&](BasicBlock* block) { + for (Statement* stmt : block->NonPhiStatements()) { - for (Statement* stmt : block->NonPhiStatements()) + bool hasUse = false; + int numExtensions = 0; + for (GenTree* node : stmt->TreeList()) { - bool hasUse = false; - int numExtensions = 0; - for (GenTree* node : stmt->TreeList()) + if (!node->OperIs(GT_CAST)) { - if (!node->OperIs(GT_CAST)) - { - hasUse |= node->OperIsLocal() && (node->AsLclVarCommon()->GetLclNum() == lclNum); - continue; - } - - GenTreeCast* cast = node->AsCast(); - if ((cast->gtCastType != TYP_LONG) || !cast->IsUnsigned() || cast->gtOverflow()) - { - continue; - } - - GenTree* op = cast->CastOp(); - if (!op->OperIs(GT_LCL_VAR) || (op->AsLclVarCommon()->GetLclNum() != lclNum)) - { - continue; - } - - // If this is already the source of a store then it is going to be - // free in our backends regardless. - GenTree* parent = node->gtGetParent(nullptr); - if ((parent != nullptr) && parent->OperIs(GT_STORE_LCL_VAR)) - { - continue; - } - - numExtensions++; + hasUse |= node->OperIsLocal() && (node->AsLclVarCommon()->GetLclNum() == lclNum); + continue; } - if (hasUse) + GenTreeCast* cast = node->AsCast(); + if ((cast->gtCastType != TYP_LONG) || !cast->IsUnsigned() || cast->gtOverflow()) { - ivUses.Push(stmt); + continue; } - if (numExtensions > 0) + GenTree* op = cast->CastOp(); + if (!op->OperIs(GT_LCL_VAR) || (op->AsLclVarCommon()->GetLclNum() != lclNum)) { - JITDUMP(" Found %d zero extensions in " FMT_STMT "\n", numExtensions, stmt->GetID()); + continue; + } - savedSize += numExtensions * ExtensionSize; - savedCost += numExtensions * block->getBBWeight(this) * ExtensionCost; + // If this is already the source of a store then it is going to be + // free in our backends regardless. + GenTree* parent = node->gtGetParent(nullptr); + if ((parent != nullptr) && parent->OperIs(GT_STORE_LCL_VAR)) + { + continue; } + + numExtensions++; } - return BasicBlockVisit::Continue; - }); + if (hasUse) + { + ivUses.Push(stmt); + } + + if (numExtensions > 0) + { + JITDUMP(" Found %d zero extensions in " FMT_STMT "\n", numExtensions, stmt->GetID()); + + savedSize += numExtensions * ExtensionSize; + savedCost += numExtensions * block->getBBWeight(this) * ExtensionCost; + } + } + + return BasicBlockVisit::Continue; + }); if (!initedToConstant) { @@ -241,16 +233,14 @@ bool Compiler::optIsIVWideningProfitable(unsigned lclNum, // Now account for the cost of sinks. LclVarDsc* dsc = lvaGetDesc(lclNum); - loop->VisitRegularExitBlocks( - [&](BasicBlock* exit) + loop->VisitRegularExitBlocks([&](BasicBlock* exit) { + if (VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) { - if (VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) - { - savedSize -= ExtensionSize; - savedCost -= exit->getBBWeight(this) * ExtensionCost; - } - return BasicBlockVisit::Continue; - }); + savedSize -= ExtensionSize; + savedCost -= exit->getBBWeight(this) * ExtensionCost; + } + return BasicBlockVisit::Continue; + }); const weight_t ALLOWED_SIZE_REGRESSION_PER_CYCLE_IMPROVEMENT = 2; weight_t cycleImprovementPerInvoc = savedCost / fgFirstBB->getBBWeight(this); @@ -292,24 +282,21 @@ bool Compiler::optIsIVWideningProfitable(unsigned lclNum, void Compiler::optSinkWidenedIV(unsigned lclNum, unsigned newLclNum, FlowGraphNaturalLoop* loop) { LclVarDsc* dsc = lvaGetDesc(lclNum); - loop->VisitRegularExitBlocks( - [=](BasicBlock* exit) + loop->VisitRegularExitBlocks([=](BasicBlock* exit) { + if (!VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) { - if (!VarSetOps::IsMember(this, exit->bbLiveIn, dsc->lvVarIndex)) - { - return BasicBlockVisit::Continue; - } + return BasicBlockVisit::Continue; + } - GenTree* narrowing = gtNewCastNode(TYP_INT, gtNewLclvNode(newLclNum, TYP_LONG), false, TYP_INT); - GenTree* store = gtNewStoreLclVarNode(lclNum, narrowing); - Statement* newStmt = fgNewStmtFromTree(store); - JITDUMP("Narrow IV local V%02u live into exit block " FMT_BB "; sinking a narrowing\n", lclNum, - exit->bbNum); - DISPSTMT(newStmt); - fgInsertStmtAtBeg(exit, newStmt); + GenTree* narrowing = gtNewCastNode(TYP_INT, gtNewLclvNode(newLclNum, TYP_LONG), false, TYP_INT); + GenTree* store = gtNewStoreLclVarNode(lclNum, narrowing); + Statement* newStmt = fgNewStmtFromTree(store); + JITDUMP("Narrow IV local V%02u live into exit block " FMT_BB "; sinking a narrowing\n", lclNum, exit->bbNum); + DISPSTMT(newStmt); + fgInsertStmtAtBeg(exit, newStmt); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ @@ -345,7 +332,10 @@ void Compiler::optReplaceWidenedIV(unsigned lclNum, unsigned ssaNum, unsigned ne }; ReplaceVisitor(Compiler* comp, unsigned lclNum, unsigned ssaNum, unsigned newLclNum) - : GenTreeVisitor(comp), m_lclNum(lclNum), m_ssaNum(ssaNum), m_newLclNum(newLclNum) + : GenTreeVisitor(comp) + , m_lclNum(lclNum) + , m_ssaNum(ssaNum) + , m_newLclNum(newLclNum) { } @@ -450,17 +440,14 @@ void Compiler::optBestEffortReplaceNarrowIVUses( optReplaceWidenedIV(lclNum, ssaNum, newLclNum, stmt); } - block->VisitRegularSuccs(this, - [=](BasicBlock* succ) - { - if (succ->GetUniquePred(this) == block) - { - optBestEffortReplaceNarrowIVUses(lclNum, ssaNum, newLclNum, succ, - succ->firstStmt()); - } - - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(this, [=](BasicBlock* succ) { + if (succ->GetUniquePred(this) == block) + { + optBestEffortReplaceNarrowIVUses(lclNum, ssaNum, newLclNum, succ, succ->firstStmt()); + } + + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/inline.h b/src/coreclr/jit/inline.h index fa32091bc49ff7..a87b2de79c058e 100644 --- a/src/coreclr/jit/inline.h +++ b/src/coreclr/jit/inline.h @@ -205,7 +205,9 @@ class InlinePolicy static InlinePolicy* GetPolicy(Compiler* compiler, bool isPrejitRoot); // Obligatory virtual dtor - virtual ~InlinePolicy() {} + virtual ~InlinePolicy() + { + } // Get the current decision InlineDecision GetDecision() const @@ -260,9 +262,13 @@ class InlinePolicy // Name of the policy virtual const char* GetName() const = 0; // Detailed data value dump - virtual void DumpData(FILE* file) const {} + virtual void DumpData(FILE* file) const + { + } // Detailed data name dump - virtual void DumpSchema(FILE* file) const {} + virtual void DumpSchema(FILE* file) const + { + } #define XATTR_I4(x) \ if ((INT32)x != 0) \ @@ -288,7 +294,9 @@ class InlinePolicy fprintf(file, " />\n"); } - virtual void OnDumpXml(FILE* file, unsigned indent = 0) const {} + virtual void OnDumpXml(FILE* file, unsigned indent = 0) const + { + } // True if this is the inline targeted by data collection bool IsDataCollectionTarget() @@ -629,16 +637,16 @@ struct InlArgInfo CallArg* arg; // the caller argument GenTree* argBashTmpNode; // tmp node created, if it may be replaced with actual arg unsigned argTmpNum; // the argument tmp number - unsigned argIsUsed : 1; // is this arg used at all? - unsigned argIsInvariant : 1; // the argument is a constant or a local variable address - unsigned argIsLclVar : 1; // the argument is a local variable - unsigned argIsThis : 1; // the argument is the 'this' pointer - unsigned argHasSideEff : 1; // the argument has side effects - unsigned argHasGlobRef : 1; // the argument has a global ref - unsigned argHasCallerLocalRef : 1; // the argument value depends on an aliased caller local - unsigned argHasTmp : 1; // the argument will be evaluated to a temp - unsigned argHasLdargaOp : 1; // Is there LDARGA(s) operation on this argument? - unsigned argHasStargOp : 1; // Is there STARG(s) operation on this argument? + unsigned argIsUsed : 1; // is this arg used at all? + unsigned argIsInvariant : 1; // the argument is a constant or a local variable address + unsigned argIsLclVar : 1; // the argument is a local variable + unsigned argIsThis : 1; // the argument is the 'this' pointer + unsigned argHasSideEff : 1; // the argument has side effects + unsigned argHasGlobRef : 1; // the argument has a global ref + unsigned argHasCallerLocalRef : 1; // the argument value depends on an aliased caller local + unsigned argHasTmp : 1; // the argument will be evaluated to a temp + unsigned argHasLdargaOp : 1; // Is there LDARGA(s) operation on this argument? + unsigned argHasStargOp : 1; // Is there STARG(s) operation on this argument? unsigned argIsByRefToStructLocal : 1; // Is this arg an address of a struct local or a normed struct local or a // field in them? unsigned argIsExact : 1; // Is this arg of an exact class? @@ -650,10 +658,10 @@ struct InlLclVarInfo { CORINFO_CLASS_HANDLE lclTypeHandle; // Type handle from the signature. Available for structs and REFs. var_types lclTypeInfo; // Type from the signature. - unsigned char lclHasLdlocaOp : 1; // Is there LDLOCA(s) operation on this local? - unsigned char lclHasStlocOp : 1; // Is there a STLOC on this local? + unsigned char lclHasLdlocaOp : 1; // Is there LDLOCA(s) operation on this local? + unsigned char lclHasStlocOp : 1; // Is there a STLOC on this local? unsigned char lclHasMultipleStlocOp : 1; // Is there more than one STLOC on this local - unsigned char lclIsPinned : 1; + unsigned char lclIsPinned : 1; }; // InlineInfo provides detailed information about a particular inline candidate. @@ -879,8 +887,8 @@ class InlineContext InlinePolicy* m_Policy; // policy that evaluated this inline unsigned m_TreeID; // ID of the GenTreeCall in the parent bool m_Devirtualized : 1; // true if this was a devirtualized call - bool m_Guarded : 1; // true if this was a guarded call - bool m_Unboxed : 1; // true if this call now invokes the unboxed entry + bool m_Guarded : 1; // true if this was a guarded call + bool m_Unboxed : 1; // true if this call now invokes the unboxed entry #endif // defined(DEBUG) diff --git a/src/coreclr/jit/inlinepolicy.cpp b/src/coreclr/jit/inlinepolicy.cpp index 0b22414e740cb0..3b771f291607bb 100644 --- a/src/coreclr/jit/inlinepolicy.cpp +++ b/src/coreclr/jit/inlinepolicy.cpp @@ -1074,7 +1074,8 @@ bool DefaultPolicy::PropagateNeverToRuntime() const // compiler -- compiler instance doing the inlining (root compiler) // isPrejitRoot -- true if this compiler is prejitting the root method -RandomPolicy::RandomPolicy(Compiler* compiler, bool isPrejitRoot) : DiscretionaryPolicy(compiler, isPrejitRoot) +RandomPolicy::RandomPolicy(Compiler* compiler, bool isPrejitRoot) + : DiscretionaryPolicy(compiler, isPrejitRoot) { m_Random = compiler->m_inlineStrategy->GetRandom(); } @@ -2770,7 +2771,8 @@ void DiscretionaryPolicy::DumpData(FILE* file) const // compiler -- compiler instance doing the inlining (root compiler) // isPrejitRoot -- true if this compiler is prejitting the root method -ModelPolicy::ModelPolicy(Compiler* compiler, bool isPrejitRoot) : DiscretionaryPolicy(compiler, isPrejitRoot) +ModelPolicy::ModelPolicy(Compiler* compiler, bool isPrejitRoot) + : DiscretionaryPolicy(compiler, isPrejitRoot) { // Empty } @@ -2971,7 +2973,8 @@ void ModelPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo) // compiler -- compiler instance doing the inlining (root compiler) // isPrejitRoot -- true if this compiler is prejitting the root method -ProfilePolicy::ProfilePolicy(Compiler* compiler, bool isPrejitRoot) : DiscretionaryPolicy(compiler, isPrejitRoot) +ProfilePolicy::ProfilePolicy(Compiler* compiler, bool isPrejitRoot) + : DiscretionaryPolicy(compiler, isPrejitRoot) { // Empty } @@ -3171,7 +3174,8 @@ void ProfilePolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo) // compiler -- compiler instance doing the inlining (root compiler) // isPrejitRoot -- true if this compiler is prejitting the root method -FullPolicy::FullPolicy(Compiler* compiler, bool isPrejitRoot) : DiscretionaryPolicy(compiler, isPrejitRoot) +FullPolicy::FullPolicy(Compiler* compiler, bool isPrejitRoot) + : DiscretionaryPolicy(compiler, isPrejitRoot) { // Empty } @@ -3238,7 +3242,8 @@ void FullPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo) // compiler -- compiler instance doing the inlining (root compiler) // isPrejitRoot -- true if this compiler is prejitting the root method -SizePolicy::SizePolicy(Compiler* compiler, bool isPrejitRoot) : DiscretionaryPolicy(compiler, isPrejitRoot) +SizePolicy::SizePolicy(Compiler* compiler, bool isPrejitRoot) + : DiscretionaryPolicy(compiler, isPrejitRoot) { // Empty } diff --git a/src/coreclr/jit/inlinepolicy.h b/src/coreclr/jit/inlinepolicy.h index acc9b5e17b3429..a8d8e67f1db3cb 100644 --- a/src/coreclr/jit/inlinepolicy.h +++ b/src/coreclr/jit/inlinepolicy.h @@ -48,7 +48,8 @@ class LegalPolicy : public InlinePolicy public: // Constructor - LegalPolicy(bool isPrejitRoot) : InlinePolicy(isPrejitRoot) + LegalPolicy(bool isPrejitRoot) + : InlinePolicy(isPrejitRoot) { // empty } @@ -174,20 +175,20 @@ class DefaultPolicy : public LegalPolicy unsigned m_ConstantArgFeedsConstantTest; int m_CalleeNativeSizeEstimate; int m_CallsiteNativeSizeEstimate; - bool m_IsForceInline : 1; - bool m_IsForceInlineKnown : 1; - bool m_IsInstanceCtor : 1; + bool m_IsForceInline : 1; + bool m_IsForceInlineKnown : 1; + bool m_IsInstanceCtor : 1; bool m_IsFromPromotableValueClass : 1; - bool m_HasSimd : 1; - bool m_LooksLikeWrapperMethod : 1; - bool m_MethodIsMostlyLoadStore : 1; - bool m_CallsiteIsInTryRegion : 1; - bool m_CallsiteIsInLoop : 1; - bool m_IsNoReturn : 1; - bool m_IsNoReturnKnown : 1; - bool m_ConstArgFeedsIsKnownConst : 1; - bool m_ArgFeedsIsKnownConst : 1; - bool m_InsideThrowBlock : 1; + bool m_HasSimd : 1; + bool m_LooksLikeWrapperMethod : 1; + bool m_MethodIsMostlyLoadStore : 1; + bool m_CallsiteIsInTryRegion : 1; + bool m_CallsiteIsInLoop : 1; + bool m_IsNoReturn : 1; + bool m_IsNoReturnKnown : 1; + bool m_ConstArgFeedsIsKnownConst : 1; + bool m_ArgFeedsIsKnownConst : 1; + bool m_InsideThrowBlock : 1; }; // ExtendedDefaultPolicy is a slightly more aggressive variant of @@ -271,11 +272,11 @@ class ExtendedDefaultPolicy : public DefaultPolicy unsigned m_UnrollableMemop; unsigned m_Switch; unsigned m_DivByCns; - bool m_ReturnsStructByValue : 1; - bool m_IsFromValueClass : 1; - bool m_NonGenericCallsGeneric : 1; + bool m_ReturnsStructByValue : 1; + bool m_IsFromValueClass : 1; + bool m_NonGenericCallsGeneric : 1; bool m_IsCallsiteInNoReturnRegion : 1; - bool m_HasProfileWeights : 1; + bool m_HasProfileWeights : 1; }; // DiscretionaryPolicy is a variant of the default policy. It diff --git a/src/coreclr/jit/jit.h b/src/coreclr/jit/jit.h index c0983e4da79f32..754e6b27f44416 100644 --- a/src/coreclr/jit/jit.h +++ b/src/coreclr/jit/jit.h @@ -296,9 +296,9 @@ typedef ptrdiff_t ssize_t; #include "corjit.h" #include "jitee.h" -#define __OPERATOR_NEW_INLINE 1 // indicate that I will define these -#define __PLACEMENT_NEW_INLINE // don't bring in the global placement new, it is easy to make a mistake - // with our new(compiler*) pattern. +#define __OPERATOR_NEW_INLINE 1 // indicate that I will define these +#define __PLACEMENT_NEW_INLINE // don't bring in the global placement new, it is easy to make a mistake + // with our new(compiler*) pattern. #include "utilcode.h" // this defines assert as _ASSERTE #include "host.h" // this redefines assert for the JIT to use assertAbort @@ -320,7 +320,7 @@ typedef ptrdiff_t ssize_t; #endif #ifdef DEBUG -#define INDEBUG(x) x +#define INDEBUG(x) x #define DEBUGARG(x) , x #else #define INDEBUG(x) @@ -335,7 +335,7 @@ typedef ptrdiff_t ssize_t; #if defined(UNIX_AMD64_ABI) #define UNIX_AMD64_ABI_ONLY_ARG(x) , x -#define UNIX_AMD64_ABI_ONLY(x) x +#define UNIX_AMD64_ABI_ONLY(x) x #else // !defined(UNIX_AMD64_ABI) #define UNIX_AMD64_ABI_ONLY_ARG(x) #define UNIX_AMD64_ABI_ONLY(x) @@ -343,7 +343,7 @@ typedef ptrdiff_t ssize_t; #if defined(TARGET_LOONGARCH64) #define UNIX_LOONGARCH64_ONLY_ARG(x) , x -#define UNIX_LOONGARCH64_ONLY(x) x +#define UNIX_LOONGARCH64_ONLY(x) x #else // !TARGET_LOONGARCH64 #define UNIX_LOONGARCH64_ONLY_ARG(x) #define UNIX_LOONGARCH64_ONLY(x) @@ -356,16 +356,16 @@ typedef ptrdiff_t ssize_t; #if defined(UNIX_AMD64_ABI) #define UNIX_AMD64_ABI_ONLY_ARG(x) , x -#define UNIX_AMD64_ABI_ONLY(x) x +#define UNIX_AMD64_ABI_ONLY(x) x #else // !defined(UNIX_AMD64_ABI) #define UNIX_AMD64_ABI_ONLY_ARG(x) #define UNIX_AMD64_ABI_ONLY(x) #endif // defined(UNIX_AMD64_ABI) #if defined(UNIX_AMD64_ABI) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) -#define MULTIREG_HAS_SECOND_GC_RET 1 +#define MULTIREG_HAS_SECOND_GC_RET 1 #define MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(x) , x -#define MULTIREG_HAS_SECOND_GC_RET_ONLY(x) x +#define MULTIREG_HAS_SECOND_GC_RET_ONLY(x) x #else // !defined(UNIX_AMD64_ABI) #define MULTIREG_HAS_SECOND_GC_RET 0 #define MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(x) @@ -386,7 +386,7 @@ typedef ptrdiff_t ssize_t; #define DUMMY_INIT(x) (x) #define REGEN_SHORTCUTS 0 -#define REGEN_CALLPAT 0 +#define REGEN_CALLPAT 0 /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX @@ -474,9 +474,9 @@ class GlobalJitOptions /*****************************************************************************/ -#define CSE_INTO_HANDLERS 0 -#define DUMP_FLOWGRAPHS DEBUG // Support for creating Xml Flowgraph reports in *.fgx files -#define HANDLER_ENTRY_MUST_BE_IN_HOT_SECTION 0 // if 1 we must have all handler entry points in the Hot code section +#define CSE_INTO_HANDLERS 0 +#define DUMP_FLOWGRAPHS DEBUG // Support for creating Xml Flowgraph reports in *.fgx files +#define HANDLER_ENTRY_MUST_BE_IN_HOT_SECTION 0 // if 1 we must have all handler entry points in the Hot code section /*****************************************************************************/ @@ -484,9 +484,9 @@ class GlobalJitOptions /*****************************************************************************/ -#define DUMP_GC_TABLES DEBUG +#define DUMP_GC_TABLES DEBUG #define VERIFY_GC_TABLES 0 -#define REARRANGE_ADDS 1 +#define REARRANGE_ADDS 1 #define FUNC_INFO_LOGGING \ 1 // Support dumping function info to a file. In retail, only NYIs, with no function name, @@ -503,24 +503,24 @@ class GlobalJitOptions #define COUNT_LOOPS \ 0 // Collect stats about loops, such as the total number of natural loops, a histogram of // the number of loop exits, etc. -#define DISPLAY_SIZES 0 // Display generated code, data, and GC information sizes. -#define MEASURE_BLOCK_SIZE 0 // Collect stats about basic block and FlowEdge node sizes and memory allocations. -#define MEASURE_FATAL 0 // Count the number of calls to fatal(), including NYIs and noway_asserts. -#define MEASURE_NODE_SIZE 0 // Collect stats about GenTree node allocations. +#define DISPLAY_SIZES 0 // Display generated code, data, and GC information sizes. +#define MEASURE_BLOCK_SIZE 0 // Collect stats about basic block and FlowEdge node sizes and memory allocations. +#define MEASURE_FATAL 0 // Count the number of calls to fatal(), including NYIs and noway_asserts. +#define MEASURE_NODE_SIZE 0 // Collect stats about GenTree node allocations. #define MEASURE_PTRTAB_SIZE 0 // Collect stats about GC pointer table allocations. -#define EMITTER_STATS 0 // Collect stats on the emitter. -#define NODEBASH_STATS 0 // Collect stats on changed gtOper values in GenTree's. -#define COUNT_AST_OPERS 0 // Display use counts for GenTree operators. +#define EMITTER_STATS 0 // Collect stats on the emitter. +#define NODEBASH_STATS 0 // Collect stats on changed gtOper values in GenTree's. +#define COUNT_AST_OPERS 0 // Display use counts for GenTree operators. #ifdef DEBUG #define MEASURE_MEM_ALLOC 1 // Collect memory allocation stats. -#define LOOP_HOIST_STATS 1 // Collect loop hoisting stats. -#define TRACK_LSRA_STATS 1 // Collect LSRA stats +#define LOOP_HOIST_STATS 1 // Collect loop hoisting stats. +#define TRACK_LSRA_STATS 1 // Collect LSRA stats #define TRACK_ENREG_STATS 1 // Collect enregistration stats #else #define MEASURE_MEM_ALLOC 0 // You can set this to 1 to get memory stats in retail, as well -#define LOOP_HOIST_STATS 0 // You can set this to 1 to get loop hoist stats in retail, as well -#define TRACK_LSRA_STATS 0 // You can set this to 1 to get LSRA stats in retail, as well +#define LOOP_HOIST_STATS 0 // You can set this to 1 to get loop hoist stats in retail, as well +#define TRACK_LSRA_STATS 0 // You can set this to 1 to get LSRA stats in retail, as well #define TRACK_ENREG_STATS 0 #endif @@ -606,7 +606,7 @@ const bool dspGCtbls = true; JitTls::GetCompiler()->fgTableDispBasicBlock(b); #define VERBOSE JitTls::GetCompiler()->verbose // Development-time only macros, simplify guards for specified IL methods one wants to debug/add log messages for -#define ISMETHOD(name) (strcmp(JitTls::GetCompiler()->impInlineRoot()->info.compMethodName, name) == 0) +#define ISMETHOD(name) (strcmp(JitTls::GetCompiler()->impInlineRoot()->info.compMethodName, name) == 0) #define ISMETHODHASH(hash) (JitTls::GetCompiler()->impInlineRoot()->info.compMethodHash() == hash) #else // !DEBUG #define JITDUMP(...) @@ -745,16 +745,16 @@ inline size_t unsigned_abs(__int64 x) #define FEATURE_TAILCALL_OPT_SHARED_RETURN 0 #endif // !FEATURE_TAILCALL_OPT -#define CLFLG_CODESIZE 0x00001 -#define CLFLG_CODESPEED 0x00002 -#define CLFLG_CSE 0x00004 -#define CLFLG_REGVAR 0x00008 -#define CLFLG_RNGCHKOPT 0x00010 -#define CLFLG_DEADSTORE 0x00020 +#define CLFLG_CODESIZE 0x00001 +#define CLFLG_CODESPEED 0x00002 +#define CLFLG_CSE 0x00004 +#define CLFLG_REGVAR 0x00008 +#define CLFLG_RNGCHKOPT 0x00010 +#define CLFLG_DEADSTORE 0x00020 #define CLFLG_CODEMOTION 0x00040 -#define CLFLG_QMARK 0x00080 -#define CLFLG_TREETRANS 0x00100 -#define CLFLG_INLINING 0x00200 +#define CLFLG_QMARK 0x00080 +#define CLFLG_TREETRANS 0x00100 +#define CLFLG_INLINING 0x00200 #if FEATURE_STRUCTPROMOTE #define CLFLG_STRUCTPROMOTE 0x00400 diff --git a/src/coreclr/jit/jitconfig.cpp b/src/coreclr/jit/jitconfig.cpp index 89030c8541f07a..19730be75c2cdc 100644 --- a/src/coreclr/jit/jitconfig.cpp +++ b/src/coreclr/jit/jitconfig.cpp @@ -36,8 +36,7 @@ void JitConfigValues::MethodSet::initialize(const WCHAR* list, ICorJitHost* host } } - auto commitPattern = [this, host](const char* start, const char* end) - { + auto commitPattern = [this, host](const char* start, const char* end) { if (end <= start) { return; @@ -164,17 +163,15 @@ bool JitConfigValues::MethodSet::contains(CORINFO_METHOD_HANDLE methodHnd, (name->m_containsSignature != prevPattern->m_containsSignature)) { printer.Truncate(0); - bool success = comp->eeRunFunctorWithSPMIErrorTrap( - [&]() - { - comp->eePrintMethod(&printer, name->m_containsClassName ? classHnd : NO_CLASS_HANDLE, methodHnd, - sigInfo, - /* includeClassInstantiation */ name->m_classNameContainsInstantiation, - /* includeMethodInstantiation */ name->m_methodNameContainsInstantiation, - /* includeSignature */ name->m_containsSignature, - /* includeReturnType */ false, - /* includeThis */ false); - }); + bool success = comp->eeRunFunctorWithSPMIErrorTrap([&]() { + comp->eePrintMethod(&printer, name->m_containsClassName ? classHnd : NO_CLASS_HANDLE, methodHnd, + sigInfo, + /* includeClassInstantiation */ name->m_classNameContainsInstantiation, + /* includeMethodInstantiation */ name->m_methodNameContainsInstantiation, + /* includeSignature */ name->m_containsSignature, + /* includeReturnType */ false, + /* includeThis */ false); + }); if (!success) continue; @@ -196,7 +193,7 @@ void JitConfigValues::initialize(ICorJitHost* host) assert(!m_isInitialized); #define CONFIG_INTEGER(name, key, defaultValue) m_##name = host->getIntConfigValue(key, defaultValue); -#define CONFIG_STRING(name, key) m_##name = host->getStringConfigValue(key); +#define CONFIG_STRING(name, key) m_##name = host->getStringConfigValue(key); #define CONFIG_METHODSET(name, key) \ const WCHAR* name##value = host->getStringConfigValue(key); \ m_##name.initialize(name##value, host); \ @@ -215,7 +212,7 @@ void JitConfigValues::destroy(ICorJitHost* host) } #define CONFIG_INTEGER(name, key, defaultValue) -#define CONFIG_STRING(name, key) host->freeStringConfigValue(m_##name); +#define CONFIG_STRING(name, key) host->freeStringConfigValue(m_##name); #define CONFIG_METHODSET(name, key) m_##name.destroy(host); #include "jitconfigvalues.h" diff --git a/src/coreclr/jit/jitconfig.h b/src/coreclr/jit/jitconfig.h index 5e1b8f1505db33..bd1c552f59438a 100644 --- a/src/coreclr/jit/jitconfig.h +++ b/src/coreclr/jit/jitconfig.h @@ -35,7 +35,9 @@ class JitConfigValues MethodSet& operator=(const MethodSet& other) = delete; public: - MethodSet() {} + MethodSet() + { + } inline const char* list() const { @@ -54,8 +56,8 @@ class JitConfigValues private: #define CONFIG_INTEGER(name, key, defaultValue) int m_##name; -#define CONFIG_STRING(name, key) const WCHAR* m_##name; -#define CONFIG_METHODSET(name, key) MethodSet m_##name; +#define CONFIG_STRING(name, key) const WCHAR* m_##name; +#define CONFIG_METHODSET(name, key) MethodSet m_##name; #include "jitconfigvalues.h" public: @@ -83,7 +85,9 @@ class JitConfigValues JitConfigValues& operator=(const JitConfigValues& other) = delete; public: - JitConfigValues() {} + JitConfigValues() + { + } inline bool isInitialized() const { diff --git a/src/coreclr/jit/jitconfigvalues.h b/src/coreclr/jit/jitconfigvalues.h index e0a2d7cb16fcb8..28d75fc93c3104 100644 --- a/src/coreclr/jit/jitconfigvalues.h +++ b/src/coreclr/jit/jitconfigvalues.h @@ -377,10 +377,10 @@ CONFIG_INTEGER(JitDisableSimdVN, W("JitDisableSimdVN"), 0) // Default 0, ValueNu // CONFIG_INTEGER(JitConstCSE, W("JitConstCSE"), 0) -#define CONST_CSE_ENABLE_ARM 0 -#define CONST_CSE_DISABLE_ALL 1 +#define CONST_CSE_ENABLE_ARM 0 +#define CONST_CSE_DISABLE_ALL 1 #define CONST_CSE_ENABLE_ARM_NO_SHARING 2 -#define CONST_CSE_ENABLE_ALL 3 +#define CONST_CSE_ENABLE_ALL 3 #define CONST_CSE_ENABLE_ALL_NO_SHARING 4 // If nonzero, use the greedy RL policy. diff --git a/src/coreclr/jit/jitee.h b/src/coreclr/jit/jitee.h index 27963ac356efb5..71f53b4e10d7d6 100644 --- a/src/coreclr/jit/jitee.h +++ b/src/coreclr/jit/jitee.h @@ -54,13 +54,15 @@ class JitFlags }; // clang-format on - JitFlags() : m_jitFlags(0) + JitFlags() + : m_jitFlags(0) { // empty } // Convenience constructor to set exactly one flags. - JitFlags(JitFlag flag) : m_jitFlags(0) + JitFlags(JitFlag flag) + : m_jitFlags(0) { Set(flag); } diff --git a/src/coreclr/jit/jitexpandarray.h b/src/coreclr/jit/jitexpandarray.h index 522ba841d6dab2..8eaf52705986ad 100644 --- a/src/coreclr/jit/jitexpandarray.h +++ b/src/coreclr/jit/jitexpandarray.h @@ -54,7 +54,10 @@ class JitExpandArray // of size max(`minSize`, `idx`) is allocated. // JitExpandArray(CompAllocator alloc, unsigned minSize = 1) - : m_alloc(alloc), m_members(nullptr), m_size(0), m_minSize(minSize) + : m_alloc(alloc) + , m_members(nullptr) + , m_size(0) + , m_minSize(minSize) { assert(minSize > 0); } @@ -219,7 +222,11 @@ class JitExpandArrayStack : public JitExpandArray // Notes: // See JitExpandArray constructor notes. // - JitExpandArrayStack(CompAllocator alloc, unsigned minSize = 1) : JitExpandArray(alloc, minSize), m_used(0) {} + JitExpandArrayStack(CompAllocator alloc, unsigned minSize = 1) + : JitExpandArray(alloc, minSize) + , m_used(0) + { + } //------------------------------------------------------------------------ // GetRef: Get a reference to the element at index `idx`. diff --git a/src/coreclr/jit/jitgcinfo.h b/src/coreclr/jit/jitgcinfo.h index 087e55e461ef54..288042d4c6b1e4 100644 --- a/src/coreclr/jit/jitgcinfo.h +++ b/src/coreclr/jit/jitgcinfo.h @@ -23,9 +23,13 @@ struct RegSlotIdKey unsigned short m_regNum; unsigned short m_flags; - RegSlotIdKey() {} + RegSlotIdKey() + { + } - RegSlotIdKey(unsigned short regNum, unsigned flags) : m_regNum(regNum), m_flags((unsigned short)flags) + RegSlotIdKey(unsigned short regNum, unsigned flags) + : m_regNum(regNum) + , m_flags((unsigned short)flags) { assert(m_flags == flags); } @@ -47,10 +51,14 @@ struct StackSlotIdKey bool m_fpRel; unsigned short m_flags; - StackSlotIdKey() {} + StackSlotIdKey() + { + } StackSlotIdKey(int offset, bool fpRel, unsigned flags) - : m_offset(offset), m_fpRel(fpRel), m_flags((unsigned short)flags) + : m_offset(offset) + , m_fpRel(fpRel) + , m_flags((unsigned short)flags) { assert(flags == m_flags); } @@ -161,7 +169,7 @@ class GCInfo unsigned char rpdCallInstrSize; // Length of the call instruction. #endif - unsigned short rpdArg : 1; // is this an argument descriptor? + unsigned short rpdArg : 1; // is this an argument descriptor? unsigned short rpdArgType : 2; // is this an argument push,pop, or kill? rpdArgType_t rpdArgTypeGet() { @@ -175,8 +183,8 @@ class GCInfo } unsigned short rpdIsThis : 1; // is it the 'this' pointer - unsigned short rpdCall : 1; // is this a true call site? - unsigned short : 1; // Padding bit, so next two start on a byte boundary + unsigned short rpdCall : 1; // is this a true call site? + unsigned short : 1; // Padding bit, so next two start on a byte boundary unsigned short rpdCallGCrefRegs : CNT_CALLEE_SAVED; // Callee-saved registers containing GC pointers. unsigned short rpdCallByrefRegs : CNT_CALLEE_SAVED; // Callee-saved registers containing byrefs. diff --git a/src/coreclr/jit/jithashtable.h b/src/coreclr/jit/jithashtable.h index 4857b70b12acc2..f699c3eee19d24 100644 --- a/src/coreclr/jit/jithashtable.h +++ b/src/coreclr/jit/jithashtable.h @@ -57,8 +57,18 @@ class JitHashTableBehavior class JitPrimeInfo { public: - constexpr JitPrimeInfo() : prime(0), magic(0), shift(0) {} - constexpr JitPrimeInfo(unsigned p, unsigned m, unsigned s) : prime(p), magic(m), shift(s) {} + constexpr JitPrimeInfo() + : prime(0) + , magic(0) + , shift(0) + { + } + constexpr JitPrimeInfo(unsigned p, unsigned m, unsigned s) + : prime(p) + , magic(m) + , shift(s) + { + } unsigned prime; unsigned magic; unsigned shift; @@ -126,7 +136,10 @@ class JitHashTable Value m_val; template - Node(Node* next, Key k, Args&&... args) : m_next(next), m_key(k), m_val(std::forward(args)...) + Node(Node* next, Key k, Args&&... args) + : m_next(next) + , m_key(k) + , m_val(std::forward(args)...) { } @@ -162,7 +175,12 @@ class JitHashTable // JitHashTable always starts out empty, with no allocation overhead. // Call Reallocate to prime with an initial size if desired. // - JitHashTable(Allocator alloc) : m_alloc(alloc), m_table(nullptr), m_tableSizeInfo(), m_tableCount(0), m_tableMax(0) + JitHashTable(Allocator alloc) + : m_alloc(alloc) + , m_table(nullptr) + , m_tableSizeInfo() + , m_tableCount(0) + , m_tableMax(0) { #ifndef __GNUC__ // these crash GCC static_assert_no_msg(Behavior::s_growth_factor_numerator > Behavior::s_growth_factor_denominator); @@ -488,7 +506,10 @@ class JitHashTable class KeyIterator : public NodeIterator { public: - KeyIterator(const JitHashTable* hash, bool begin) : NodeIterator(hash, begin) {} + KeyIterator(const JitHashTable* hash, bool begin) + : NodeIterator(hash, begin) + { + } Key operator*() const { @@ -500,7 +521,10 @@ class JitHashTable class ValueIterator : public NodeIterator { public: - ValueIterator(const JitHashTable* hash, bool begin) : NodeIterator(hash, begin) {} + ValueIterator(const JitHashTable* hash, bool begin) + : NodeIterator(hash, begin) + { + } Value operator*() const { @@ -513,7 +537,10 @@ class JitHashTable class KeyValueIterator : public NodeIterator { public: - KeyValueIterator(const JitHashTable* hash, bool begin) : NodeIterator(hash, begin) {} + KeyValueIterator(const JitHashTable* hash, bool begin) + : NodeIterator(hash, begin) + { + } // We could return a new struct, but why bother copying data? Node* operator*() const @@ -528,7 +555,10 @@ class JitHashTable const JitHashTable* const m_hash; public: - KeyIteration(const JitHashTable* hash) : m_hash(hash) {} + KeyIteration(const JitHashTable* hash) + : m_hash(hash) + { + } KeyIterator begin() const { @@ -547,7 +577,10 @@ class JitHashTable const JitHashTable* const m_hash; public: - ValueIteration(const JitHashTable* hash) : m_hash(hash) {} + ValueIteration(const JitHashTable* hash) + : m_hash(hash) + { + } ValueIterator begin() const { @@ -566,7 +599,10 @@ class JitHashTable const JitHashTable* const m_hash; public: - KeyValueIteration(const JitHashTable* hash) : m_hash(hash) {} + KeyValueIteration(const JitHashTable* hash) + : m_hash(hash) + { + } KeyValueIterator begin() const { diff --git a/src/coreclr/jit/layout.cpp b/src/coreclr/jit/layout.cpp index 5ceed557d9ee99..ad4c0077c22bd3 100644 --- a/src/coreclr/jit/layout.cpp +++ b/src/coreclr/jit/layout.cpp @@ -44,7 +44,12 @@ class ClassLayoutTable ClassLayout m_zeroSizedBlockLayout; public: - ClassLayoutTable() : m_layoutCount(0), m_layoutLargeCapacity(0), m_zeroSizedBlockLayout(0) {} + ClassLayoutTable() + : m_layoutCount(0) + , m_layoutLargeCapacity(0) + , m_zeroSizedBlockLayout(0) + { + } // Get a number that uniquely identifies the specified layout. unsigned GetLayoutNum(ClassLayout* layout) const diff --git a/src/coreclr/jit/lclmorph.cpp b/src/coreclr/jit/lclmorph.cpp index 983d89e9c83196..6b4c6cc693f9b2 100644 --- a/src/coreclr/jit/lclmorph.cpp +++ b/src/coreclr/jit/lclmorph.cpp @@ -14,7 +14,11 @@ class LocalSequencer final : public GenTreeVisitor UseExecutionOrder = true, }; - LocalSequencer(Compiler* comp) : GenTreeVisitor(comp), m_prevNode(nullptr) {} + LocalSequencer(Compiler* comp) + : GenTreeVisitor(comp) + , m_prevNode(nullptr) + { + } //------------------------------------------------------------------- // Start: Start sequencing a statement. Must be called before other members diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index bad0fdf5e7c35c..2753ce1978e413 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -1926,7 +1926,9 @@ void Compiler::lvSetMinOptsDoNotEnreg() // Arguments: // compiler - pointer to a compiler to get access to an allocator, compHandle etc. // -Compiler::StructPromotionHelper::StructPromotionHelper(Compiler* compiler) : compiler(compiler), structPromotionInfo() +Compiler::StructPromotionHelper::StructPromotionHelper(Compiler* compiler) + : compiler(compiler) + , structPromotionInfo() { } @@ -2548,8 +2550,9 @@ void Compiler::StructPromotionHelper::SortStructFields() if (!structPromotionInfo.fieldsSorted) { jitstd::sort(structPromotionInfo.fields, structPromotionInfo.fields + structPromotionInfo.fieldCnt, - [](const lvaStructFieldInfo& lhs, const lvaStructFieldInfo& rhs) - { return lhs.fldOffset < rhs.fldOffset; }); + [](const lvaStructFieldInfo& lhs, const lvaStructFieldInfo& rhs) { + return lhs.fldOffset < rhs.fldOffset; + }); structPromotionInfo.fieldsSorted = true; } } @@ -3250,8 +3253,7 @@ void Compiler::makeExtraStructQueries(CORINFO_CLASS_HANDLE structHandle, int lev #endif // In a lambda since this requires a lot of stack and this function is recursive. - auto queryLayout = [this, structHandle]() - { + auto queryLayout = [this, structHandle]() { CORINFO_TYPE_LAYOUT_NODE nodes[256]; size_t numNodes = ArrLen(nodes); info.compCompHnd->getTypeLayout(structHandle, nodes, &numNodes); @@ -4463,7 +4465,10 @@ void Compiler::lvaMarkLocalVars(BasicBlock* block, bool isRecompute) }; MarkLocalVarsVisitor(Compiler* compiler, BasicBlock* block, Statement* stmt, bool isRecompute) - : GenTreeVisitor(compiler), m_block(block), m_stmt(stmt), m_isRecompute(isRecompute) + : GenTreeVisitor(compiler) + , m_block(block) + , m_stmt(stmt) + , m_isRecompute(isRecompute) { } diff --git a/src/coreclr/jit/likelyclass.cpp b/src/coreclr/jit/likelyclass.cpp index b1677bd93a3cce..e181a2e9a135ab 100644 --- a/src/coreclr/jit/likelyclass.cpp +++ b/src/coreclr/jit/likelyclass.cpp @@ -254,8 +254,9 @@ static unsigned getLikelyClassesOrMethods(LikelyClassMethodRecord* // sort by m_count (descending) jitstd::sort(sortedEntries, sortedEntries + knownHandles, [](const LikelyClassMethodHistogramEntry& h1, - const LikelyClassMethodHistogramEntry& h2) -> bool - { return h1.m_count > h2.m_count; }); + const LikelyClassMethodHistogramEntry& h2) -> bool { + return h1.m_count > h2.m_count; + }); const UINT32 numberOfClasses = min(knownHandles, maxLikelyClasses); @@ -409,7 +410,9 @@ extern "C" DLLEXPORT UINT32 WINAPI getLikelyValues(LikelyValueRecord* // sort by m_count (descending) jitstd::sort(sortedEntries, sortedEntries + h.countHistogramElements, [](const LikelyClassMethodHistogramEntry& h1, - const LikelyClassMethodHistogramEntry& h2) -> bool { return h1.m_count > h2.m_count; }); + const LikelyClassMethodHistogramEntry& h2) -> bool { + return h1.m_count > h2.m_count; + }); const UINT32 numberOfLikelyConst = min(h.countHistogramElements, maxLikelyValues); diff --git a/src/coreclr/jit/lir.cpp b/src/coreclr/jit/lir.cpp index 81b24cd7455ad5..d172cea22d369a 100644 --- a/src/coreclr/jit/lir.cpp +++ b/src/coreclr/jit/lir.cpp @@ -9,7 +9,12 @@ #pragma hdrstop #endif -LIR::Use::Use() : m_range(nullptr), m_edge(nullptr), m_user(nullptr) {} +LIR::Use::Use() + : m_range(nullptr) + , m_edge(nullptr) + , m_user(nullptr) +{ +} LIR::Use::Use(const Use& other) { @@ -28,7 +33,10 @@ LIR::Use::Use(const Use& other) // // Return Value: // -LIR::Use::Use(Range& range, GenTree** edge, GenTree* user) : m_range(&range), m_edge(edge), m_user(user) +LIR::Use::Use(Range& range, GenTree** edge, GenTree* user) + : m_range(&range) + , m_edge(edge) + , m_user(user) { AssertIsValid(); } @@ -278,9 +286,15 @@ unsigned LIR::Use::ReplaceWithLclVar(Compiler* compiler, unsigned lclNum, GenTre return lclNum; } -LIR::ReadOnlyRange::ReadOnlyRange() : m_firstNode(nullptr), m_lastNode(nullptr) {} +LIR::ReadOnlyRange::ReadOnlyRange() + : m_firstNode(nullptr) + , m_lastNode(nullptr) +{ +} -LIR::ReadOnlyRange::ReadOnlyRange(ReadOnlyRange&& other) : m_firstNode(other.m_firstNode), m_lastNode(other.m_lastNode) +LIR::ReadOnlyRange::ReadOnlyRange(ReadOnlyRange&& other) + : m_firstNode(other.m_firstNode) + , m_lastNode(other.m_lastNode) { #ifdef DEBUG other.m_firstNode = nullptr; @@ -297,7 +311,9 @@ LIR::ReadOnlyRange::ReadOnlyRange(ReadOnlyRange&& other) : m_firstNode(other.m_f // firstNode - The first node in the range. // lastNode - The last node in the range. // -LIR::ReadOnlyRange::ReadOnlyRange(GenTree* firstNode, GenTree* lastNode) : m_firstNode(firstNode), m_lastNode(lastNode) +LIR::ReadOnlyRange::ReadOnlyRange(GenTree* firstNode, GenTree* lastNode) + : m_firstNode(firstNode) + , m_lastNode(lastNode) { assert((m_firstNode == nullptr) == (m_lastNode == nullptr)); assert((m_firstNode == m_lastNode) || (Contains(m_lastNode))); @@ -422,9 +438,15 @@ bool LIR::ReadOnlyRange::Contains(GenTree* node) const #endif -LIR::Range::Range() : ReadOnlyRange() {} +LIR::Range::Range() + : ReadOnlyRange() +{ +} -LIR::Range::Range(Range&& other) : ReadOnlyRange(std::move(other)) {} +LIR::Range::Range(Range&& other) + : ReadOnlyRange(std::move(other)) +{ +} //------------------------------------------------------------------------ // LIR::Range::Range: Creates a `Range` value given the first and last @@ -434,7 +456,10 @@ LIR::Range::Range(Range&& other) : ReadOnlyRange(std::move(other)) {} // firstNode - The first node in the range. // lastNode - The last node in the range. // -LIR::Range::Range(GenTree* firstNode, GenTree* lastNode) : ReadOnlyRange(firstNode, lastNode) {} +LIR::Range::Range(GenTree* firstNode, GenTree* lastNode) + : ReadOnlyRange(firstNode, lastNode) +{ +} //------------------------------------------------------------------------ // LIR::Range::FirstNonCatchArgNode: Returns the first node after all catch arg nodes in this range. @@ -915,16 +940,14 @@ void LIR::Range::Remove(GenTree* node, bool markOperandsUnused) if (markOperandsUnused) { - node->VisitOperands( - [](GenTree* operand) -> GenTree::VisitResult + node->VisitOperands([](GenTree* operand) -> GenTree::VisitResult { + // The operand of JTRUE does not produce a value (just sets the flags). + if (operand->IsValue()) { - // The operand of JTRUE does not produce a value (just sets the flags). - if (operand->IsValue()) - { - operand->SetUnusedValue(); - } - return GenTree::VisitResult::Continue; - }); + operand->SetUnusedValue(); + } + return GenTree::VisitResult::Continue; + }); } GenTree* prev = node->gtPrev; @@ -1210,13 +1233,11 @@ LIR::ReadOnlyRange LIR::Range::GetMarkedRange(unsigned markCount, } // Mark the node's operands - firstNode->VisitOperands( - [&markCount](GenTree* operand) -> GenTree::VisitResult - { - operand->gtLIRFlags |= LIR::Flags::Mark; - markCount++; - return GenTree::VisitResult::Continue; - }); + firstNode->VisitOperands([&markCount](GenTree* operand) -> GenTree::VisitResult { + operand->gtLIRFlags |= LIR::Flags::Mark; + markCount++; + return GenTree::VisitResult::Continue; + }); if (markFlagsOperands && firstNode->OperConsumesFlags()) { @@ -1360,13 +1381,11 @@ LIR::ReadOnlyRange LIR::Range::GetRangeOfOperandTrees(GenTree* root, bool* isClo // Mark the root node's operands unsigned markCount = 0; - root->VisitOperands( - [&markCount](GenTree* operand) -> GenTree::VisitResult - { - operand->gtLIRFlags |= LIR::Flags::Mark; - markCount++; - return GenTree::VisitResult::Continue; - }); + root->VisitOperands([&markCount](GenTree* operand) -> GenTree::VisitResult { + operand->gtLIRFlags |= LIR::Flags::Mark; + markCount++; + return GenTree::VisitResult::Continue; + }); if (markCount == 0) { diff --git a/src/coreclr/jit/lir.h b/src/coreclr/jit/lir.h index 80c14f2c90d628..8a3a9a507a38bb 100644 --- a/src/coreclr/jit/lir.h +++ b/src/coreclr/jit/lir.h @@ -125,10 +125,16 @@ class LIR final GenTree* m_node; - Iterator(GenTree* begin) : m_node(begin) {} + Iterator(GenTree* begin) + : m_node(begin) + { + } public: - Iterator() : m_node(nullptr) {} + Iterator() + : m_node(nullptr) + { + } inline GenTree* operator*() { @@ -163,10 +169,16 @@ class LIR final GenTree* m_node; - ReverseIterator(GenTree* begin) : m_node(begin) {} + ReverseIterator(GenTree* begin) + : m_node(begin) + { + } public: - ReverseIterator() : m_node(nullptr) {} + ReverseIterator() + : m_node(nullptr) + { + } inline GenTree* operator*() { diff --git a/src/coreclr/jit/liveness.cpp b/src/coreclr/jit/liveness.cpp index 697b8172231626..39c8f1b09219af 100644 --- a/src/coreclr/jit/liveness.cpp +++ b/src/coreclr/jit/liveness.cpp @@ -1042,13 +1042,11 @@ void Compiler::fgAddHandlerLiveVars(BasicBlock* block, VARSET_TP& ehHandlerLiveV { assert(block->HasPotentialEHSuccs(this)); - block->VisitEHSuccs(this, - [&](BasicBlock* succ) - { - VarSetOps::UnionD(this, ehHandlerLiveVars, succ->bbLiveIn); - memoryLiveness |= succ->bbMemoryLiveIn; - return BasicBlockVisit::Continue; - }); + block->VisitEHSuccs(this, [&](BasicBlock* succ) { + VarSetOps::UnionD(this, ehHandlerLiveVars, succ->bbLiveIn); + memoryLiveness |= succ->bbMemoryLiveIn; + return BasicBlockVisit::Continue; + }); } class LiveVarAnalysis @@ -1119,18 +1117,16 @@ class LiveVarAnalysis // successors. EH successors need to be handled more conservatively // (their live-in state is live in this entire basic block). Those are // handled below. - block->VisitRegularSuccs(m_compiler, - [=](BasicBlock* succ) - { - VarSetOps::UnionD(m_compiler, m_liveOut, succ->bbLiveIn); - m_memoryLiveOut |= succ->bbMemoryLiveIn; - if (succ->bbNum <= block->bbNum) - { - m_hasPossibleBackEdge = true; - } - - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(m_compiler, [=](BasicBlock* succ) { + VarSetOps::UnionD(m_compiler, m_liveOut, succ->bbLiveIn); + m_memoryLiveOut |= succ->bbMemoryLiveIn; + if (succ->bbNum <= block->bbNum) + { + m_hasPossibleBackEdge = true; + } + + return BasicBlockVisit::Continue; + }); /* For lvaKeepAliveAndReportThis methods, "this" has to be kept alive everywhere Note that a function may end in a throw on an infinite loop (as opposed to a return). @@ -1777,24 +1773,22 @@ void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALAR JITDUMP("Removing dead call:\n"); DISPNODE(call); - node->VisitOperands( - [](GenTree* operand) -> GenTree::VisitResult + node->VisitOperands([](GenTree* operand) -> GenTree::VisitResult { + if (operand->IsValue()) { - if (operand->IsValue()) - { - operand->SetUnusedValue(); - } + operand->SetUnusedValue(); + } - // Special-case PUTARG_STK: since this operator is not considered a value, DCE will not - // remove these nodes. - if (operand->OperIs(GT_PUTARG_STK)) - { - operand->AsPutArgStk()->gtOp1->SetUnusedValue(); - operand->gtBashToNOP(); - } + // Special-case PUTARG_STK: since this operator is not considered a value, DCE will not + // remove these nodes. + if (operand->OperIs(GT_PUTARG_STK)) + { + operand->AsPutArgStk()->gtOp1->SetUnusedValue(); + operand->gtBashToNOP(); + } - return GenTree::VisitResult::Continue; - }); + return GenTree::VisitResult::Continue; + }); blockRange.Remove(node); @@ -2054,12 +2048,10 @@ bool Compiler::fgTryRemoveNonLocal(GenTree* node, LIR::Range* blockRange) JITDUMP("Removing dead node:\n"); DISPNODE(node); - node->VisitOperands( - [](GenTree* operand) -> GenTree::VisitResult - { - operand->SetUnusedValue(); - return GenTree::VisitResult::Continue; - }); + node->VisitOperands([](GenTree* operand) -> GenTree::VisitResult { + operand->SetUnusedValue(); + return GenTree::VisitResult::Continue; + }); if (node->OperConsumesFlags() && node->gtPrev->gtSetFlags()) { diff --git a/src/coreclr/jit/loopcloning.cpp b/src/coreclr/jit/loopcloning.cpp index 114e5aed1286ef..4c5ffe247634a4 100644 --- a/src/coreclr/jit/loopcloning.cpp +++ b/src/coreclr/jit/loopcloning.cpp @@ -1813,12 +1813,10 @@ bool Compiler::optIsLoopClonable(FlowGraphNaturalLoop* loop, LoopCloneContext* c // flow can reach the header, but that would require the handler to also be // part of the loop, which guarantees that the loop contains two distinct // EH regions. - loop->VisitLoopBlocks( - [](BasicBlock* block) - { - assert(!block->KindIs(BBJ_RETURN)); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks([](BasicBlock* block) { + assert(!block->KindIs(BBJ_RETURN)); + return BasicBlockVisit::Continue; + }); #endif // Is the entry block a handler or filter start? If so, then if we cloned, we could create a jump @@ -2020,12 +2018,10 @@ void Compiler::optCloneLoop(FlowGraphNaturalLoop* loop, LoopCloneContext* contex loop->Duplicate(&newPred, blockMap, LoopCloneContext::slowPathWeightScaleFactor); // Scale old blocks to the fast path weight. - loop->VisitLoopBlocks( - [=](BasicBlock* block) - { - block->scaleBBWeight(LoopCloneContext::fastPathWeightScaleFactor); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks([=](BasicBlock* block) { + block->scaleBBWeight(LoopCloneContext::fastPathWeightScaleFactor); + return BasicBlockVisit::Continue; + }); // Perform the static optimizations on the fast path. optPerformStaticOptimizations(loop, context DEBUGARG(true)); @@ -2807,21 +2803,19 @@ bool Compiler::optIdentifyLoopOptInfo(FlowGraphNaturalLoop* loop, LoopCloneConte LoopCloneVisitorInfo info(context, loop, nullptr, shouldCloneForArrayBounds, shouldCloneForGdvTests); - loop->VisitLoopBlocksReversePostOrder( - [=, &info](BasicBlock* block) + loop->VisitLoopBlocksReversePostOrder([=, &info](BasicBlock* block) { + compCurBB = block; + for (Statement* const stmt : block->Statements()) { - compCurBB = block; - for (Statement* const stmt : block->Statements()) - { - info.stmt = stmt; - const bool lclVarsOnly = false; - const bool computeStack = false; - fgWalkTreePre(stmt->GetRootNodePointer(), optCanOptimizeByLoopCloningVisitor, &info, lclVarsOnly, - computeStack); - } + info.stmt = stmt; + const bool lclVarsOnly = false; + const bool computeStack = false; + fgWalkTreePre(stmt->GetRootNodePointer(), optCanOptimizeByLoopCloningVisitor, &info, lclVarsOnly, + computeStack); + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); return true; } diff --git a/src/coreclr/jit/loopcloning.h b/src/coreclr/jit/loopcloning.h index d76ef577ca9ced..20f041eab40a52 100644 --- a/src/coreclr/jit/loopcloning.h +++ b/src/coreclr/jit/loopcloning.h @@ -196,7 +196,14 @@ struct ArrIndex unsigned rank; // Rank of the array BasicBlock* useBlock; // Block where the [] occurs - ArrIndex(CompAllocator alloc) : arrLcl(BAD_VAR_NUM), indLcls(alloc), bndsChks(alloc), rank(0), useBlock(nullptr) {} + ArrIndex(CompAllocator alloc) + : arrLcl(BAD_VAR_NUM) + , indLcls(alloc) + , bndsChks(alloc) + , rank(0) + , useBlock(nullptr) + { + } #ifdef DEBUG void Print(unsigned dim = -1); @@ -234,7 +241,10 @@ struct LcOptInfo }; OptType optType; - LcOptInfo(OptType optType) : optType(optType) {} + LcOptInfo(OptType optType) + : optType(optType) + { + } OptType GetOptType() { @@ -263,7 +273,10 @@ struct LcMdArrayOptInfo : public LcOptInfo ArrIndex* index; // "index" cached computation in the form of an ArrIndex representation. LcMdArrayOptInfo(GenTreeArrElem* arrElem, unsigned dim) - : LcOptInfo(LcMdArray), arrElem(arrElem), dim(dim), index(nullptr) + : LcOptInfo(LcMdArray) + , arrElem(arrElem) + , dim(dim) + , index(nullptr) { } @@ -296,7 +309,10 @@ struct LcJaggedArrayOptInfo : public LcOptInfo Statement* stmt; // "stmt" where the optimization opportunity occurs. LcJaggedArrayOptInfo(ArrIndex& arrIndex, unsigned dim, Statement* stmt) - : LcOptInfo(LcJaggedArray), dim(dim), arrIndex(arrIndex), stmt(stmt) + : LcOptInfo(LcJaggedArray) + , dim(dim) + , arrIndex(arrIndex) + , stmt(stmt) { } }; @@ -315,7 +331,11 @@ struct LcTypeTestOptInfo : public LcOptInfo CORINFO_CLASS_HANDLE clsHnd; LcTypeTestOptInfo(Statement* stmt, GenTreeIndir* methodTableIndir, unsigned lclNum, CORINFO_CLASS_HANDLE clsHnd) - : LcOptInfo(LcTypeTest), stmt(stmt), methodTableIndir(methodTableIndir), lclNum(lclNum), clsHnd(clsHnd) + : LcOptInfo(LcTypeTest) + , stmt(stmt) + , methodTableIndir(methodTableIndir) + , lclNum(lclNum) + , clsHnd(clsHnd) { } }; @@ -389,13 +409,26 @@ struct LC_Array int dim; // "dim" = which index to invoke arrLen on, if -1 invoke on the whole array // Example 1: a[0][1][2] and dim = 2 implies a[0][1].length // Example 2: a[0][1][2] and dim = -1 implies a[0][1][2].length - LC_Array() : type(Invalid), dim(-1) {} + LC_Array() + : type(Invalid) + , dim(-1) + { + } LC_Array(ArrType type, ArrIndex* arrIndex, int dim, OperType oper) - : type(type), arrIndex(arrIndex), oper(oper), dim(dim) + : type(type) + , arrIndex(arrIndex) + , oper(oper) + , dim(dim) { } - LC_Array(ArrType type, ArrIndex* arrIndex, OperType oper) : type(type), arrIndex(arrIndex), oper(oper), dim(-1) {} + LC_Array(ArrType type, ArrIndex* arrIndex, OperType oper) + : type(type) + , arrIndex(arrIndex) + , oper(oper) + , dim(-1) + { + } // Equality operator bool operator==(const LC_Array& that) const @@ -475,13 +508,19 @@ struct LC_Ident }; }; - LC_Ident(IdentType type) : type(type) {} + LC_Ident(IdentType type) + : type(type) + { + } public: // The type of this object IdentType type; - LC_Ident() : type(Invalid) {} + LC_Ident() + : type(Invalid) + { + } // Equality operator bool operator==(const LC_Ident& that) const @@ -669,8 +708,15 @@ struct LC_Expr } #endif - LC_Expr() : type(Invalid) {} - explicit LC_Expr(const LC_Ident& ident) : ident(ident), type(Ident) {} + LC_Expr() + : type(Invalid) + { + } + explicit LC_Expr(const LC_Ident& ident) + : ident(ident) + , type(Ident) + { + } // Convert LC_Expr into a tree node. GenTree* ToGenTree(Compiler* comp, BasicBlock* bb); @@ -705,9 +751,14 @@ struct LC_Condition // Check if two conditions can be combined to yield one condition. bool Combines(const LC_Condition& cond, LC_Condition* newCond); - LC_Condition() {} + LC_Condition() + { + } LC_Condition(genTreeOps oper, const LC_Expr& op1, const LC_Expr& op2, bool asUnsigned = false) - : op1(op1), op2(op2), oper(oper), compareUnsigned(asUnsigned) + : op1(op1) + , op2(op2) + , oper(oper) + , compareUnsigned(asUnsigned) { } @@ -739,7 +790,12 @@ struct LC_ArrayDeref unsigned level; - LC_ArrayDeref(const LC_Array& array, unsigned level) : array(array), children(nullptr), level(level) {} + LC_ArrayDeref(const LC_Array& array, unsigned level) + : array(array) + , children(nullptr) + , level(level) + { + } LC_ArrayDeref* Find(unsigned lcl); diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 5de63779947709..e5e7aa9dbd301a 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -2320,8 +2320,7 @@ bool Lowering::LowerCallMemcmp(GenTreeCall* call, GenTree** next) GenTree* result = nullptr; auto newBinaryOp = [](Compiler* comp, genTreeOps oper, var_types type, GenTree* op1, - GenTree* op2) -> GenTree* - { + GenTree* op2) -> GenTree* { #ifdef FEATURE_SIMD if (varTypeIsSIMD(op1)) { @@ -8375,8 +8374,7 @@ static bool GetStoreCoalescingData(Compiler* comp, GenTreeStoreInd* ind, StoreCo return false; } - auto isNodeInvariant = [](Compiler* comp, GenTree* node, bool allowNull) - { + auto isNodeInvariant = [](Compiler* comp, GenTree* node, bool allowNull) { if (node == nullptr) { return allowNull; @@ -9018,8 +9016,7 @@ bool Lowering::TryMakeIndirsAdjacent(GenTreeIndir* prevIndir, GenTreeIndir* indi GenTree* startDumpNode = BlockRange().GetTreeRange(prevIndir, &isClosed).FirstNode(); GenTree* endDumpNode = indir->gtNext; - auto dumpWithMarks = [=]() - { + auto dumpWithMarks = [=]() { if (!comp->verbose) { return; @@ -9101,8 +9098,7 @@ bool Lowering::TryMakeIndirsAdjacent(GenTreeIndir* prevIndir, GenTreeIndir* indi } // Helper lambda to check if a single node interferes with 'indir'. - auto interferes = [=](GenTree* node) - { + auto interferes = [=](GenTree* node) { if (((node->gtFlags & GTF_ORDER_SIDEEFF) != 0) && node->OperSupportsOrderingSideEffect()) { // Cannot normally reorder GTF_ORDER_SIDEEFF and GTF_GLOB_REF, @@ -9210,12 +9206,10 @@ bool Lowering::TryMakeIndirsAdjacent(GenTreeIndir* prevIndir, GenTreeIndir* indi void Lowering::MarkTree(GenTree* node) { node->gtLIRFlags |= LIR::Flags::Mark; - node->VisitOperands( - [=](GenTree* op) - { - MarkTree(op); - return GenTree::VisitResult::Continue; - }); + node->VisitOperands([=](GenTree* op) { + MarkTree(op); + return GenTree::VisitResult::Continue; + }); } //------------------------------------------------------------------------ @@ -9227,12 +9221,10 @@ void Lowering::MarkTree(GenTree* node) void Lowering::UnmarkTree(GenTree* node) { node->gtLIRFlags &= ~LIR::Flags::Mark; - node->VisitOperands( - [=](GenTree* op) - { - UnmarkTree(op); - return GenTree::VisitResult::Continue; - }); + node->VisitOperands([=](GenTree* op) { + UnmarkTree(op); + return GenTree::VisitResult::Continue; + }); } #endif // TARGET_ARM64 diff --git a/src/coreclr/jit/lower.h b/src/coreclr/jit/lower.h index 4c07a35f2ca385..318a148ee9c1c9 100644 --- a/src/coreclr/jit/lower.h +++ b/src/coreclr/jit/lower.h @@ -589,7 +589,9 @@ class Lowering final : public Phase target_ssize_t Offset; SavedIndir(GenTreeIndir* indir, GenTreeLclVar* addrBase, target_ssize_t offset) - : Indir(indir), AddrBase(addrBase), Offset(offset) + : Indir(indir) + , AddrBase(addrBase) + , Offset(offset) { } }; diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index b066a4f4c23b7e..d8bbce5ae68960 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1088,8 +1088,7 @@ void Lowering::LowerHWIntrinsicFusedMultiplyAddScalar(GenTreeHWIntrinsic* node) GenTree* op2 = node->Op(2); GenTree* op3 = node->Op(3); - auto lowerOperand = [this](GenTree* op) - { + auto lowerOperand = [this](GenTree* op) { bool wasNegated = false; if (op->OperIsHWIntrinsic() && diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index e8b3a5c638e83e..ff59968742c2b1 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -6188,14 +6188,12 @@ bool Lowering::IsRMWIndirCandidate(GenTree* operand, GenTree* storeInd) return false; } - node->VisitOperands( - [&markCount](GenTree* nodeOperand) -> GenTree::VisitResult - { - assert((nodeOperand->gtLIRFlags & LIR::Flags::Mark) == 0); - nodeOperand->gtLIRFlags |= LIR::Flags::Mark; - markCount++; - return GenTree::VisitResult::Continue; - }); + node->VisitOperands([&markCount](GenTree* nodeOperand) -> GenTree::VisitResult { + assert((nodeOperand->gtLIRFlags & LIR::Flags::Mark) == 0); + nodeOperand->gtLIRFlags |= LIR::Flags::Mark; + markCount++; + return GenTree::VisitResult::Continue; + }); } } diff --git a/src/coreclr/jit/lsra.cpp b/src/coreclr/jit/lsra.cpp index b9edf935919698..50652ca075254d 100644 --- a/src/coreclr/jit/lsra.cpp +++ b/src/coreclr/jit/lsra.cpp @@ -9952,7 +9952,7 @@ const char* LinearScan::getStatName(unsigned stat) #define LSRA_STAT_DEF(stat, name) name, #include "lsra_stats.h" #undef LSRA_STAT_DEF -#define REG_SEL_DEF(stat, value, shortname, orderSeqId) #stat, +#define REG_SEL_DEF(stat, value, shortname, orderSeqId) #stat, #define BUSY_REG_SEL_DEF(stat, value, shortname, orderSeqId) REG_SEL_DEF(stat, value, shortname, orderSeqId) #include "lsra_score.h" }; diff --git a/src/coreclr/jit/lsra.h b/src/coreclr/jit/lsra.h index 38948e0d350f69..e038b4e8243a57 100644 --- a/src/coreclr/jit/lsra.h +++ b/src/coreclr/jit/lsra.h @@ -34,9 +34,9 @@ const unsigned int RegisterTypeCount = 2; *****************************************************************************/ typedef var_types RegisterType; -#define IntRegisterType TYP_INT +#define IntRegisterType TYP_INT #define FloatRegisterType TYP_FLOAT -#define MaskRegisterType TYP_MASK +#define MaskRegisterType TYP_MASK //------------------------------------------------------------------------ // regType: Return the RegisterType to use for a given type @@ -83,10 +83,16 @@ struct RefInfo RefPosition* ref; GenTree* treeNode; - RefInfo(RefPosition* r, GenTree* t) : ref(r), treeNode(t) {} + RefInfo(RefPosition* r, GenTree* t) + : ref(r) + , treeNode(t) + { + } // default constructor for data structures - RefInfo() {} + RefInfo() + { + } }; //------------------------------------------------------------------------ @@ -103,7 +109,10 @@ class RefInfoListNode final : public RefInfo RefInfoListNode* m_next; // The next node in the list public: - RefInfoListNode(RefPosition* r, GenTree* t) : RefInfo(r, t) {} + RefInfoListNode(RefPosition* r, GenTree* t) + : RefInfo(r, t) + { + } //------------------------------------------------------------------------ // RefInfoListNode::Next: Returns the next node in the list. @@ -128,9 +137,15 @@ class RefInfoList final RefInfoListNode* m_tail; // The tail of the list public: - RefInfoList() : m_head(nullptr), m_tail(nullptr) {} + RefInfoList() + : m_head(nullptr) + , m_tail(nullptr) + { + } - RefInfoList(RefInfoListNode* node) : m_head(node), m_tail(node) + RefInfoList(RefInfoListNode* node) + : m_head(node) + , m_tail(node) { assert(m_head->m_next == nullptr); } @@ -366,7 +381,7 @@ enum LsraStat #define LSRA_STAT_DEF(enum_name, enum_str) enum_name, #include "lsra_stats.h" #undef LSRA_STAT_DEF -#define REG_SEL_DEF(enum_name, value, short_str, orderSeqId) STAT_##enum_name, +#define REG_SEL_DEF(enum_name, value, short_str, orderSeqId) STAT_##enum_name, #define BUSY_REG_SEL_DEF(enum_name, value, short_str, orderSeqId) REG_SEL_DEF(enum_name, value, short_str, orderSeqId) #include "lsra_score.h" COUNT @@ -379,11 +394,11 @@ struct LsraBlockInfo // 0 for fgFirstBB. unsigned int predBBNum; weight_t weight; - bool hasCriticalInEdge : 1; + bool hasCriticalInEdge : 1; bool hasCriticalOutEdge : 1; - bool hasEHBoundaryIn : 1; - bool hasEHBoundaryOut : 1; - bool hasEHPred : 1; + bool hasEHBoundaryIn : 1; + bool hasEHBoundaryOut : 1; + bool hasEHPred : 1; #if TRACK_LSRA_STATS // Per block maintained LSRA statistics. @@ -393,7 +408,7 @@ struct LsraBlockInfo enum RegisterScore { -#define REG_SEL_DEF(enum_name, value, short_str, orderSeqId) enum_name = value, +#define REG_SEL_DEF(enum_name, value, short_str, orderSeqId) enum_name = value, #define BUSY_REG_SEL_DEF(enum_name, value, short_str, orderSeqId) REG_SEL_DEF(enum_name, value, short_str, orderSeqId) #include "lsra_score.h" NONE = 0 @@ -808,8 +823,14 @@ class LinearScan : public LinearScanInterface // This controls the heuristics used to select registers // These can be combined. - enum LsraSelect{LSRA_SELECT_DEFAULT = 0, LSRA_SELECT_REVERSE_HEURISTICS = 0x04, - LSRA_SELECT_REVERSE_CALLER_CALLEE = 0x08, LSRA_SELECT_NEAREST = 0x10, LSRA_SELECT_MASK = 0x1c}; + enum LsraSelect + { + LSRA_SELECT_DEFAULT = 0, + LSRA_SELECT_REVERSE_HEURISTICS = 0x04, + LSRA_SELECT_REVERSE_CALLER_CALLEE = 0x08, + LSRA_SELECT_NEAREST = 0x10, + LSRA_SELECT_MASK = 0x1c + }; LsraSelect getSelectionHeuristics() { return (LsraSelect)(lsraStressMask & LSRA_SELECT_MASK); @@ -828,9 +849,14 @@ class LinearScan : public LinearScanInterface } // This controls the order in which basic blocks are visited during allocation - enum LsraTraversalOrder{LSRA_TRAVERSE_LAYOUT = 0x20, LSRA_TRAVERSE_PRED_FIRST = 0x40, - LSRA_TRAVERSE_RANDOM = 0x60, // NYI - LSRA_TRAVERSE_DEFAULT = LSRA_TRAVERSE_PRED_FIRST, LSRA_TRAVERSE_MASK = 0x60}; + enum LsraTraversalOrder + { + LSRA_TRAVERSE_LAYOUT = 0x20, + LSRA_TRAVERSE_PRED_FIRST = 0x40, + LSRA_TRAVERSE_RANDOM = 0x60, // NYI + LSRA_TRAVERSE_DEFAULT = LSRA_TRAVERSE_PRED_FIRST, + LSRA_TRAVERSE_MASK = 0x60 + }; LsraTraversalOrder getLsraTraversalOrder() { if ((lsraStressMask & LSRA_TRAVERSE_MASK) == 0) @@ -850,7 +876,12 @@ class LinearScan : public LinearScanInterface // This controls whether lifetimes should be extended to the entire method. // Note that this has no effect under MinOpts - enum LsraExtendLifetimes{LSRA_DONT_EXTEND = 0, LSRA_EXTEND_LIFETIMES = 0x80, LSRA_EXTEND_LIFETIMES_MASK = 0x80}; + enum LsraExtendLifetimes + { + LSRA_DONT_EXTEND = 0, + LSRA_EXTEND_LIFETIMES = 0x80, + LSRA_EXTEND_LIFETIMES_MASK = 0x80 + }; LsraExtendLifetimes getLsraExtendLifeTimes() { return (LsraExtendLifetimes)(lsraStressMask & LSRA_EXTEND_LIFETIMES_MASK); @@ -863,8 +894,13 @@ class LinearScan : public LinearScanInterface // This controls whether variables locations should be set to the previous block in layout order // (LSRA_BLOCK_BOUNDARY_LAYOUT), or to that of the highest-weight predecessor (LSRA_BLOCK_BOUNDARY_PRED - // the default), or rotated (LSRA_BLOCK_BOUNDARY_ROTATE). - enum LsraBlockBoundaryLocations{LSRA_BLOCK_BOUNDARY_PRED = 0, LSRA_BLOCK_BOUNDARY_LAYOUT = 0x100, - LSRA_BLOCK_BOUNDARY_ROTATE = 0x200, LSRA_BLOCK_BOUNDARY_MASK = 0x300}; + enum LsraBlockBoundaryLocations + { + LSRA_BLOCK_BOUNDARY_PRED = 0, + LSRA_BLOCK_BOUNDARY_LAYOUT = 0x100, + LSRA_BLOCK_BOUNDARY_ROTATE = 0x200, + LSRA_BLOCK_BOUNDARY_MASK = 0x300 + }; LsraBlockBoundaryLocations getLsraBlockBoundaryLocations() { return (LsraBlockBoundaryLocations)(lsraStressMask & LSRA_BLOCK_BOUNDARY_MASK); @@ -873,7 +909,12 @@ class LinearScan : public LinearScanInterface // This controls whether we always insert a GT_RELOAD instruction after a spill // Note that this can be combined with LSRA_SPILL_ALWAYS (or not) - enum LsraReload{LSRA_NO_RELOAD_IF_SAME = 0, LSRA_ALWAYS_INSERT_RELOAD = 0x400, LSRA_RELOAD_MASK = 0x400}; + enum LsraReload + { + LSRA_NO_RELOAD_IF_SAME = 0, + LSRA_ALWAYS_INSERT_RELOAD = 0x400, + LSRA_RELOAD_MASK = 0x400 + }; LsraReload getLsraReload() { return (LsraReload)(lsraStressMask & LSRA_RELOAD_MASK); @@ -884,7 +925,12 @@ class LinearScan : public LinearScanInterface } // This controls whether we spill everywhere - enum LsraSpill{LSRA_DONT_SPILL_ALWAYS = 0, LSRA_SPILL_ALWAYS = 0x800, LSRA_SPILL_MASK = 0x800}; + enum LsraSpill + { + LSRA_DONT_SPILL_ALWAYS = 0, + LSRA_SPILL_ALWAYS = 0x800, + LSRA_SPILL_MASK = 0x800 + }; LsraSpill getLsraSpill() { return (LsraSpill)(lsraStressMask & LSRA_SPILL_MASK); @@ -896,8 +942,12 @@ class LinearScan : public LinearScanInterface // This controls whether RefPositions that lower/codegen indicated as reg optional be // allocated a reg at all. - enum LsraRegOptionalControl{LSRA_REG_OPTIONAL_DEFAULT = 0, LSRA_REG_OPTIONAL_NO_ALLOC = 0x1000, - LSRA_REG_OPTIONAL_MASK = 0x1000}; + enum LsraRegOptionalControl + { + LSRA_REG_OPTIONAL_DEFAULT = 0, + LSRA_REG_OPTIONAL_NO_ALLOC = 0x1000, + LSRA_REG_OPTIONAL_MASK = 0x1000 + }; LsraRegOptionalControl getLsraRegOptionalControl() { @@ -1343,7 +1393,7 @@ class LinearScan : public LinearScanInterface FORCEINLINE void reset(Interval* interval, RefPosition* refPosition); FORCEINLINE void resetMinimal(Interval* interval, RefPosition* refPosition); -#define REG_SEL_DEF(stat, value, shortname, orderSeqId) FORCEINLINE void try_##stat(); +#define REG_SEL_DEF(stat, value, shortname, orderSeqId) FORCEINLINE void try_##stat(); #define BUSY_REG_SEL_DEF(stat, value, shortname, orderSeqId) REG_SEL_DEF(stat, value, shortname, orderSeqId) #include "lsra_score.h" }; @@ -1431,7 +1481,12 @@ class LinearScan : public LinearScanInterface // - In LSRA_DUMP_POST, which is after register allocation, the registers are // shown. - enum LsraTupleDumpMode{LSRA_DUMP_PRE, LSRA_DUMP_REFPOS, LSRA_DUMP_POST}; + enum LsraTupleDumpMode + { + LSRA_DUMP_PRE, + LSRA_DUMP_REFPOS, + LSRA_DUMP_POST + }; void lsraGetOperandString(GenTree* tree, LsraTupleDumpMode mode, char* operandString, unsigned operandStringLength); void lsraDispNode(GenTree* tree, LsraTupleDumpMode mode, bool hasDest); void DumpOperandDefs( @@ -1490,7 +1545,8 @@ class LinearScan : public LinearScanInterface void dumpIntervalName(Interval* interval); // Events during the allocation phase that cause some dump output - enum LsraDumpEvent{ + enum LsraDumpEvent + { // Conflicting def/use LSRA_EVENT_DEFUSE_CONFLICT, LSRA_EVENT_DEFUSE_FIXED_DELAY_USE, @@ -2503,8 +2559,8 @@ class RefPosition // we need an explicit move. // - copyReg and moveReg must not exist with each other. - unsigned char reload : 1; - unsigned char spillAfter : 1; + unsigned char reload : 1; + unsigned char spillAfter : 1; unsigned char singleDefSpill : 1; unsigned char writeThru : 1; // true if this var is defined in a register and also spilled. spillAfter must NOT be // set. @@ -2512,7 +2568,7 @@ class RefPosition unsigned char copyReg : 1; unsigned char moveReg : 1; // true if this var is moved to a new register - unsigned char isPhysRegRef : 1; // true if 'referent' points of a RegRecord, false if it points to an Interval + unsigned char isPhysRegRef : 1; // true if 'referent' points of a RegRecord, false if it points to an Interval unsigned char isFixedRegRef : 1; unsigned char isLocalDefUse : 1; diff --git a/src/coreclr/jit/lsrabuild.cpp b/src/coreclr/jit/lsrabuild.cpp index af5de253de8913..a0cab145dc9203 100644 --- a/src/coreclr/jit/lsrabuild.cpp +++ b/src/coreclr/jit/lsrabuild.cpp @@ -78,7 +78,8 @@ RefInfoListNode* RefInfoList::removeListNode(GenTree* node, unsigned multiRegIdx // compiler - The compiler context. // preallocate - The number of nodes to preallocate. // -RefInfoListNodePool::RefInfoListNodePool(Compiler* compiler, unsigned preallocate) : m_compiler(compiler) +RefInfoListNodePool::RefInfoListNodePool(Compiler* compiler, unsigned preallocate) + : m_compiler(compiler) { if (preallocate > 0) { @@ -2603,21 +2604,19 @@ void LinearScan::buildIntervals() VarSetOps::DiffD(compiler, expUseSet, nextBlock->bbLiveIn); } - block->VisitAllSuccs(compiler, - [=, &expUseSet](BasicBlock* succ) - { - if (VarSetOps::IsEmpty(compiler, expUseSet)) - { - return BasicBlockVisit::Abort; - } - - if (!isBlockVisited(succ)) - { - VarSetOps::DiffD(compiler, expUseSet, succ->bbLiveIn); - } - - return BasicBlockVisit::Continue; - }); + block->VisitAllSuccs(compiler, [=, &expUseSet](BasicBlock* succ) { + if (VarSetOps::IsEmpty(compiler, expUseSet)) + { + return BasicBlockVisit::Abort; + } + + if (!isBlockVisited(succ)) + { + VarSetOps::DiffD(compiler, expUseSet, succ->bbLiveIn); + } + + return BasicBlockVisit::Continue; + }); if (!VarSetOps::IsEmpty(compiler, expUseSet)) { diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 75036487fc7dcd..6bd3ede0cc4951 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -3615,8 +3615,9 @@ GenTree* Compiler::fgMorphMultiregStructArg(CallArg* arg) { assert(structSize <= MAX_ARG_REG_COUNT * TARGET_POINTER_SIZE); - auto getSlotType = [layout](unsigned inx) - { return (layout != nullptr) ? layout->GetGCPtrType(inx) : TYP_I_IMPL; }; + auto getSlotType = [layout](unsigned inx) { + return (layout != nullptr) ? layout->GetGCPtrType(inx) : TYP_I_IMPL; + }; // Here, we will set the sizes "rounded up" and then adjust the type of the last element below. for (unsigned inx = 0, offset = 0; inx < elemCount; inx++) @@ -3963,21 +3964,19 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg) // We do not reuse within a statement. if (!opts.MinOpts()) { - found = ForEachHbvBitSet(*fgAvailableOutgoingArgTemps, - [&](indexType lclNum) - { - LclVarDsc* varDsc = lvaGetDesc((unsigned)lclNum); - ClassLayout* layout = varDsc->GetLayout(); - if (!layout->IsBlockLayout() && (layout->GetClassHandle() == copyBlkClass)) - { - tmp = (unsigned)lclNum; - JITDUMP("reusing outgoing struct arg V%02u\n", tmp); - fgAvailableOutgoingArgTemps->clearBit(lclNum); - return HbvWalk::Abort; - } + found = ForEachHbvBitSet(*fgAvailableOutgoingArgTemps, [&](indexType lclNum) { + LclVarDsc* varDsc = lvaGetDesc((unsigned)lclNum); + ClassLayout* layout = varDsc->GetLayout(); + if (!layout->IsBlockLayout() && (layout->GetClassHandle() == copyBlkClass)) + { + tmp = (unsigned)lclNum; + JITDUMP("reusing outgoing struct arg V%02u\n", tmp); + fgAvailableOutgoingArgTemps->clearBit(lclNum); + return HbvWalk::Abort; + } - return HbvWalk::Continue; - }) == HbvWalk::Abort; + return HbvWalk::Continue; + }) == HbvWalk::Abort; } // Create the CopyBlk tree and insert it. @@ -5337,8 +5336,7 @@ bool Compiler::fgCanFastTailCall(GenTreeCall* callee, const char** failReason) unsigned calleeArgStackSize = 0; unsigned callerArgStackSize = info.compArgStackSize; - auto reportFastTailCallDecision = [&](const char* thisFailReason) - { + auto reportFastTailCallDecision = [&](const char* thisFailReason) { if (failReason != nullptr) { *failReason = thisFailReason; @@ -5667,8 +5665,7 @@ GenTree* Compiler::fgMorphPotentialTailCall(GenTreeCall* call) // It cannot be an inline candidate assert(!call->IsInlineCandidate()); - auto failTailCall = [&](const char* reason, unsigned lclNum = BAD_VAR_NUM) - { + auto failTailCall = [&](const char* reason, unsigned lclNum = BAD_VAR_NUM) { #ifdef DEBUG if (verbose) { @@ -6320,7 +6317,10 @@ void Compiler::fgValidateIRForTailCall(GenTreeCall* call) }; TailCallIRValidatorVisitor(Compiler* comp, GenTreeCall* tailcall) - : GenTreeVisitor(comp), m_tailcall(tailcall), m_lclNum(BAD_VAR_NUM), m_active(false) + : GenTreeVisitor(comp) + , m_tailcall(tailcall) + , m_lclNum(BAD_VAR_NUM) + , m_active(false) { } @@ -6863,8 +6863,7 @@ GenTree* Compiler::getRuntimeLookupTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, ArrayStack stmts(getAllocator(CMK_ArrayStack)); - auto cloneTree = [&](GenTree** tree DEBUGARG(const char* reason)) -> GenTree* - { + auto cloneTree = [&](GenTree** tree DEBUGARG(const char* reason)) -> GenTree* { if (!((*tree)->gtFlags & GTF_GLOB_EFFECT)) { GenTree* clone = gtClone(*tree, true); @@ -7783,8 +7782,7 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call) } #ifdef DEBUG - auto resetMorphedFlag = [](GenTree** slot, fgWalkData* data) -> fgWalkResult - { + auto resetMorphedFlag = [](GenTree** slot, fgWalkData* data) -> fgWalkResult { (*slot)->gtDebugFlags &= ~GTF_DEBUG_NODE_MORPHED; return WALK_CONTINUE; }; @@ -11334,8 +11332,7 @@ GenTree* Compiler::fgOptimizeRelationalComparisonWithCasts(GenTreeOp* cmp) return cmp; } - auto supportedOp = [](GenTree* op) - { + auto supportedOp = [](GenTree* op) { if (op->IsIntegralConst()) { return true; @@ -11365,8 +11362,7 @@ GenTree* Compiler::fgOptimizeRelationalComparisonWithCasts(GenTreeOp* cmp) return cmp; } - auto isUpperZero = [this](GenTree* op) - { + auto isUpperZero = [this](GenTree* op) { if (op->IsIntegralConst()) { int64_t lng = op->AsIntConCommon()->LngValue(); @@ -11392,8 +11388,7 @@ GenTree* Compiler::fgOptimizeRelationalComparisonWithCasts(GenTreeOp* cmp) cmp->SetUnsigned(); - auto transform = [this](GenTree** use) - { + auto transform = [this](GenTree** use) { if ((*use)->IsIntegralConst()) { (*use)->BashToConst(static_cast((*use)->AsIntConCommon()->LngValue())); @@ -12885,8 +12880,7 @@ void Compiler::fgAssertionGen(GenTree* tree) // Helper to note when an existing assertion has been // brought back to life. // - auto announce = [&](AssertionIndex apIndex, const char* condition) - { + auto announce = [&](AssertionIndex apIndex, const char* condition) { #ifdef DEBUG if (verbose) { @@ -13508,7 +13502,10 @@ void Compiler::fgMorphStmtBlockOps(BasicBlock* block, Statement* stmt) DoPostOrder = true, }; - Visitor(Compiler* comp) : GenTreeVisitor(comp) {} + Visitor(Compiler* comp) + : GenTreeVisitor(comp) + { + } fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { @@ -14982,7 +14979,10 @@ PhaseStatus Compiler::fgMarkImplicitByRefCopyOmissionCandidates() UseExecutionOrder = true, }; - Visitor(Compiler* comp) : GenTreeVisitor(comp) {} + Visitor(Compiler* comp) + : GenTreeVisitor(comp) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -15565,7 +15565,10 @@ bool Compiler::fgMorphArrayOpsStmt(MorphMDArrayTempCache* pTempCache, BasicBlock }; MorphMDArrayVisitor(Compiler* compiler, BasicBlock* block, MorphMDArrayTempCache* pTempCache) - : GenTreeVisitor(compiler), m_changed(false), m_block(block), m_pTempCache(pTempCache) + : GenTreeVisitor(compiler) + , m_changed(false) + , m_block(block) + , m_pTempCache(pTempCache) { } diff --git a/src/coreclr/jit/morphblock.cpp b/src/coreclr/jit/morphblock.cpp index ede7c64ad2bcaa..84c30e64621a2f 100644 --- a/src/coreclr/jit/morphblock.cpp +++ b/src/coreclr/jit/morphblock.cpp @@ -92,7 +92,8 @@ GenTree* MorphInitBlockHelper::MorphInitBlock(Compiler* comp, GenTree* tree) // Most class members are initialized via in-class member initializers. // MorphInitBlockHelper::MorphInitBlockHelper(Compiler* comp, GenTree* store, bool initBlock = true) - : m_comp(comp), m_initBlock(initBlock) + : m_comp(comp) + , m_initBlock(initBlock) { assert(store->OperIsStore()); assert((m_initBlock == store->OperIsInitBlkOp()) && (!m_initBlock == store->OperIsCopyBlkOp())); @@ -531,14 +532,12 @@ GenTree* MorphInitBlockHelper::EliminateCommas(GenTree** commaPool) *commaPool = nullptr; GenTree* sideEffects = nullptr; - auto addSideEffect = [&sideEffects](GenTree* sideEff) - { + auto addSideEffect = [&sideEffects](GenTree* sideEff) { sideEff->gtNext = sideEffects; sideEffects = sideEff; }; - auto addComma = [commaPool, &addSideEffect](GenTree* comma) - { + auto addComma = [commaPool, &addSideEffect](GenTree* comma) { addSideEffect(comma->gtGetOp1()); comma->gtNext = *commaPool; *commaPool = comma; @@ -647,7 +646,10 @@ GenTree* MorphCopyBlockHelper::MorphCopyBlock(Compiler* comp, GenTree* tree) // Notes: // Most class members are initialized via in-class member initializers. // -MorphCopyBlockHelper::MorphCopyBlockHelper(Compiler* comp, GenTree* store) : MorphInitBlockHelper(comp, store, false) {} +MorphCopyBlockHelper::MorphCopyBlockHelper(Compiler* comp, GenTree* store) + : MorphInitBlockHelper(comp, store, false) +{ +} //------------------------------------------------------------------------ // PrepareSrc: Initialize member fields with information about the store's @@ -1042,8 +1044,7 @@ void MorphCopyBlockHelper::TryPrimitiveCopy() return; } - auto doRetypeNode = [storeType](GenTree* op, LclVarDsc* varDsc, bool isUse) - { + auto doRetypeNode = [storeType](GenTree* op, LclVarDsc* varDsc, bool isUse) { if (op->OperIsIndir()) { op->SetOper(isUse ? GT_IND : GT_STOREIND); @@ -1183,8 +1184,7 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField() addrSpillStore = m_comp->gtNewTempStore(addrSpillTemp, addrSpill); } - auto grabAddr = [=, &result](unsigned offs) - { + auto grabAddr = [=, &result](unsigned offs) { GenTree* addrClone = nullptr; // Need address of the source. if (addrSpill) diff --git a/src/coreclr/jit/objectalloc.cpp b/src/coreclr/jit/objectalloc.cpp index 16847c29ee74f5..0af5f4ba7a9929 100644 --- a/src/coreclr/jit/objectalloc.cpp +++ b/src/coreclr/jit/objectalloc.cpp @@ -163,7 +163,8 @@ void ObjectAllocator::MarkEscapingVarsAndBuildConnGraph() }; BuildConnGraphVisitor(ObjectAllocator* allocator) - : GenTreeVisitor(allocator->comp), m_allocator(allocator) + : GenTreeVisitor(allocator->comp) + , m_allocator(allocator) { } @@ -766,7 +767,8 @@ void ObjectAllocator::RewriteUses() }; RewriteUsesVisitor(ObjectAllocator* allocator) - : GenTreeVisitor(allocator->comp), m_allocator(allocator) + : GenTreeVisitor(allocator->comp) + , m_allocator(allocator) { } diff --git a/src/coreclr/jit/optcse.cpp b/src/coreclr/jit/optcse.cpp index ad58b44b966f43..acaed299aad42a 100644 --- a/src/coreclr/jit/optcse.cpp +++ b/src/coreclr/jit/optcse.cpp @@ -204,7 +204,11 @@ void Compiler::optCSE_GetMaskData(GenTree* tree, optCSE_MaskData* pMaskData) DoPreOrder = true, }; - MaskDataWalker(Compiler* comp, optCSE_MaskData* maskData) : GenTreeVisitor(comp), m_maskData(maskData) {} + MaskDataWalker(Compiler* comp, optCSE_MaskData* maskData) + : GenTreeVisitor(comp) + , m_maskData(maskData) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -394,7 +398,9 @@ void CSEdsc::ComputeNumLocals(Compiler* compiler) }; LocalCountingVisitor(Compiler* compiler) - : GenTreeVisitor(compiler), m_count(0), m_occurrences(0) + : GenTreeVisitor(compiler) + , m_count(0) + , m_occurrences(0) { } @@ -1184,7 +1190,11 @@ class CSE_DataFlow EXPSET_TP m_preMergeOut; public: - CSE_DataFlow(Compiler* pCompiler) : m_comp(pCompiler), m_preMergeOut(BitVecOps::UninitVal()) {} + CSE_DataFlow(Compiler* pCompiler) + : m_comp(pCompiler) + , m_preMergeOut(BitVecOps::UninitVal()) + { + } // At the start of the merge function of the dataflow equations, initialize premerge state (to detect changes.) void StartMerge(BasicBlock* block) @@ -1738,7 +1748,8 @@ void Compiler::optValnumCSE_Availability() // Notes: // This creates the basic CSE heuristic. It never does any CSEs. // -CSE_HeuristicCommon::CSE_HeuristicCommon(Compiler* pCompiler) : m_pCompiler(pCompiler) +CSE_HeuristicCommon::CSE_HeuristicCommon(Compiler* pCompiler) + : m_pCompiler(pCompiler) { m_addCSEcount = 0; /* Count of the number of LclVars for CSEs that we added */ sortTab = nullptr; @@ -2070,7 +2081,8 @@ void CSE_HeuristicCommon::DumpMetrics() // This creates the random CSE heuristic. It does CSEs randomly, with some // predetermined likelihood (set by config or by stress). // -CSE_HeuristicRandom::CSE_HeuristicRandom(Compiler* pCompiler) : CSE_HeuristicCommon(pCompiler) +CSE_HeuristicRandom::CSE_HeuristicRandom(Compiler* pCompiler) + : CSE_HeuristicCommon(pCompiler) { m_cseRNG.Init(m_pCompiler->info.compMethodHash() ^ JitConfig.JitRandomCSE()); } @@ -2196,7 +2208,10 @@ void CSE_HeuristicRandom::ConsiderCandidates() // This creates the replay CSE heuristic. It does CSEs specifed by // the ArrayConfig parsing of JitReplayCSE. // -CSE_HeuristicReplay::CSE_HeuristicReplay(Compiler* pCompiler) : CSE_HeuristicCommon(pCompiler) {} +CSE_HeuristicReplay::CSE_HeuristicReplay(Compiler* pCompiler) + : CSE_HeuristicCommon(pCompiler) +{ +} //------------------------------------------------------------------------ // Announce: describe heuristic in jit dump @@ -2286,7 +2301,8 @@ double CSE_HeuristicParameterized::s_defaultParameters[CSE_HeuristicParameterize // Arguments; // pCompiler - compiler instance // -CSE_HeuristicParameterized::CSE_HeuristicParameterized(Compiler* pCompiler) : CSE_HeuristicCommon(pCompiler) +CSE_HeuristicParameterized::CSE_HeuristicParameterized(Compiler* pCompiler) + : CSE_HeuristicCommon(pCompiler) { // Default parameter values... // @@ -2980,7 +2996,10 @@ void CSE_HeuristicParameterized::DumpChoices(ArrayStack& choices, CSEdsc // Uses parameters from JitRLCSE to drive a deterministic greedy policy // CSE_HeuristicRL::CSE_HeuristicRL(Compiler* pCompiler) - : CSE_HeuristicParameterized(pCompiler), m_alpha(0.0), m_updateParameters(false), m_greedy(false) + : CSE_HeuristicParameterized(pCompiler) + , m_alpha(0.0) + , m_updateParameters(false) + , m_greedy(false) { // Set up the random state // @@ -3650,7 +3669,8 @@ CSE_HeuristicRL::Choice* CSE_HeuristicRL::FindChoice(CSEdsc* dsc, ArrayStack cns" -> "X >= cns + 1" diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index 182ddaff022fea..289e37b16fc4e8 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -37,7 +37,10 @@ void Compiler::optInit() optCSEunmarks = 0; } -DataFlow::DataFlow(Compiler* pCompiler) : m_pCompiler(pCompiler) {} +DataFlow::DataFlow(Compiler* pCompiler) + : m_pCompiler(pCompiler) +{ +} //------------------------------------------------------------------------ // optSetBlockWeights: adjust block weights, as follows: @@ -219,8 +222,7 @@ void Compiler::optScaleLoopBlocks(BasicBlock* begBlk, BasicBlock* endBlk) // At least one backedge must have been found (the one from endBlk). noway_assert(backedgeList); - auto reportBlockWeight = [&](BasicBlock* blk, const char* message) - { + auto reportBlockWeight = [&](BasicBlock* blk, const char* message) { #ifdef DEBUG if (verbose) { @@ -1549,17 +1551,15 @@ bool Compiler::optTryUnrollLoop(FlowGraphNaturalLoop* loop, bool* changedIR) ClrSafeInt loopCostSz; // Cost is size of one iteration - loop->VisitLoopBlocksReversePostOrder( - [=, &loopCostSz](BasicBlock* block) + loop->VisitLoopBlocksReversePostOrder([=, &loopCostSz](BasicBlock* block) { + for (Statement* const stmt : block->Statements()) { - for (Statement* const stmt : block->Statements()) - { - gtSetStmtInfo(stmt); - loopCostSz += stmt->GetCostSz(); - } + gtSetStmtInfo(stmt); + loopCostSz += stmt->GetCostSz(); + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); #ifdef DEBUG // Today we will never see any BBJ_RETURN blocks because we cannot @@ -1569,12 +1569,10 @@ bool Compiler::optTryUnrollLoop(FlowGraphNaturalLoop* loop, bool* changedIR) // flow can reach the header, but that would require the handler to also be // part of the loop, which guarantees that the loop contains two distinct // EH regions. - loop->VisitLoopBlocks( - [](BasicBlock* block) - { - assert(!block->KindIs(BBJ_RETURN)); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks([](BasicBlock* block) { + assert(!block->KindIs(BBJ_RETURN)); + return BasicBlockVisit::Continue; + }); #endif // Compute the estimated increase in code size for the unrolled loop. @@ -1649,12 +1647,10 @@ bool Compiler::optTryUnrollLoop(FlowGraphNaturalLoop* loop, bool* changedIR) loop->Duplicate(&insertAfter, &blockMap, scaleWeight); // Replace all uses of the loop iterator with the current value. - loop->VisitLoopBlocks( - [=, &blockMap](BasicBlock* block) - { - optReplaceScalarUsesWithConst(blockMap[block], lvar, lval); - return BasicBlockVisit::Continue; - }); + loop->VisitLoopBlocks([=, &blockMap](BasicBlock* block) { + optReplaceScalarUsesWithConst(blockMap[block], lvar, lval); + return BasicBlockVisit::Continue; + }); // Remove the test we created in the duplicate; we're doing a full unroll. BasicBlock* testBlock = blockMap[iterInfo.TestBlock]; @@ -1800,7 +1796,9 @@ void Compiler::optReplaceScalarUsesWithConst(BasicBlock* block, unsigned lclNum, bool MadeChanges = false; ReplaceVisitor(Compiler* comp, unsigned lclNum, ssize_t cnsVal) - : GenTreeVisitor(comp), m_lclNum(lclNum), m_cnsVal(cnsVal) + : GenTreeVisitor(comp) + , m_lclNum(lclNum) + , m_cnsVal(cnsVal) { } @@ -1846,7 +1844,10 @@ Compiler::OptInvertCountTreeInfoType Compiler::optInvertCountTreeInfo(GenTree* t Compiler::OptInvertCountTreeInfoType Result = {}; - CountTreeInfoVisitor(Compiler* comp) : GenTreeVisitor(comp) {} + CountTreeInfoVisitor(Compiler* comp) + : GenTreeVisitor(comp) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -3129,16 +3130,14 @@ bool Compiler::optCanonicalizeExits(FlowGraphNaturalLoop* loop) // destination block of the exit edge may no longer be right, so we // cannot use VisitRegularExitBlocks. The canonicalization here works // despite this. - edge->getSourceBlock()->VisitRegularSuccs(this, - [=, &changed](BasicBlock* succ) - { - if (!loop->ContainsBlock(succ)) - { - changed |= optCanonicalizeExit(loop, succ); - } + edge->getSourceBlock()->VisitRegularSuccs(this, [=, &changed](BasicBlock* succ) { + if (!loop->ContainsBlock(succ)) + { + changed |= optCanonicalizeExit(loop, succ); + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } return changed; @@ -3265,23 +3264,21 @@ weight_t Compiler::optEstimateEdgeLikelihood(BasicBlock* from, BasicBlock* to, b if (useEdgeWeights) { - from->VisitRegularSuccs(this, - [&, to](BasicBlock* succ) - { - *fromProfile &= succ->hasProfileWeight(); - FlowEdge* edge = fgGetPredForBlock(succ, from); - weight_t edgeWeight = (edge->edgeWeightMin() + edge->edgeWeightMax()) / 2.0; + from->VisitRegularSuccs(this, [&, to](BasicBlock* succ) { + *fromProfile &= succ->hasProfileWeight(); + FlowEdge* edge = fgGetPredForBlock(succ, from); + weight_t edgeWeight = (edge->edgeWeightMin() + edge->edgeWeightMax()) / 2.0; - if (succ == to) - { - takenCount += edgeWeight; - } - else - { - notTakenCount += edgeWeight; - } - return BasicBlockVisit::Continue; - }); + if (succ == to) + { + takenCount += edgeWeight; + } + else + { + notTakenCount += edgeWeight; + } + return BasicBlockVisit::Continue; + }); // Watch out for cases where edge weights were not properly maintained // so that it appears no profile flow goes to 'to'. @@ -3294,21 +3291,19 @@ weight_t Compiler::optEstimateEdgeLikelihood(BasicBlock* from, BasicBlock* to, b takenCount = 0; notTakenCount = 0; - from->VisitRegularSuccs(this, - [&, to](BasicBlock* succ) - { - *fromProfile &= succ->hasProfileWeight(); - if (succ == to) - { - takenCount += succ->bbWeight; - } - else - { - notTakenCount += succ->bbWeight; - } + from->VisitRegularSuccs(this, [&, to](BasicBlock* succ) { + *fromProfile &= succ->hasProfileWeight(); + if (succ == to) + { + takenCount += succ->bbWeight; + } + else + { + notTakenCount += succ->bbWeight; + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } if (!*fromProfile) @@ -3784,7 +3779,8 @@ void Compiler::optRecordSsaUses(GenTree* tree, BasicBlock* block) }; SsaRecordingVisitor(Compiler* compiler, BasicBlock* block) - : GenTreeVisitor(compiler), m_block(block) + : GenTreeVisitor(compiler) + , m_block(block) { } @@ -4621,7 +4617,11 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop, const char* m_failReason; #endif - Value(GenTree* node) : m_node(node), m_hoistable(false), m_cctorDependent(false), m_invariant(false) + Value(GenTree* node) + : m_node(node) + , m_hoistable(false) + , m_cctorDependent(false) + , m_invariant(false) { #ifdef DEBUG m_failReason = "unset"; @@ -5476,7 +5476,9 @@ PhaseStatus Compiler::fgCanonicalizeFirstBB() return PhaseStatus::MODIFIED_EVERYTHING; } -LoopSideEffects::LoopSideEffects() : VarInOut(VarSetOps::UninitVal()), VarUseDef(VarSetOps::UninitVal()) +LoopSideEffects::LoopSideEffects() + : VarInOut(VarSetOps::UninitVal()) + , VarUseDef(VarSetOps::UninitVal()) { for (MemoryKind mk : allMemoryKinds()) { @@ -5508,15 +5510,13 @@ void Compiler::optComputeLoopSideEffects() // The side effect code benefits from seeing things in RPO as it has some // limited treatment assignments it has seen the value of. - loop->VisitLoopBlocksReversePostOrder( - [=](BasicBlock* loopBlock) - { - FlowGraphNaturalLoop* loop = m_blockToLoop->GetLoop(loopBlock); - assert(loop != nullptr); - optComputeLoopSideEffectsOfBlock(loopBlock, loop); + loop->VisitLoopBlocksReversePostOrder([=](BasicBlock* loopBlock) { + FlowGraphNaturalLoop* loop = m_blockToLoop->GetLoop(loopBlock); + assert(loop != nullptr); + optComputeLoopSideEffectsOfBlock(loopBlock, loop); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } } diff --git a/src/coreclr/jit/patchpoint.cpp b/src/coreclr/jit/patchpoint.cpp index daff2cb4a56aaf..71622ecfc3d759 100644 --- a/src/coreclr/jit/patchpoint.cpp +++ b/src/coreclr/jit/patchpoint.cpp @@ -34,7 +34,11 @@ class PatchpointTransformer Compiler* compiler; public: - PatchpointTransformer(Compiler* compiler) : ppCounterLclNum(BAD_VAR_NUM), compiler(compiler) {} + PatchpointTransformer(Compiler* compiler) + : ppCounterLclNum(BAD_VAR_NUM) + , compiler(compiler) + { + } //------------------------------------------------------------------------ // Run: run transformation for each block. diff --git a/src/coreclr/jit/phase.h b/src/coreclr/jit/phase.h index 12adf0bd70d36a..0f3d461c2b13f1 100644 --- a/src/coreclr/jit/phase.h +++ b/src/coreclr/jit/phase.h @@ -34,7 +34,10 @@ class Phase virtual void Run(); protected: - Phase(Compiler* _compiler, Phases _phase) : comp(_compiler), m_name(nullptr), m_phase(_phase) + Phase(Compiler* _compiler, Phases _phase) + : comp(_compiler) + , m_name(nullptr) + , m_phase(_phase) { m_name = PhaseNames[_phase]; } @@ -54,7 +57,11 @@ template class ActionPhase final : public Phase { public: - ActionPhase(Compiler* _compiler, Phases _phase, A _action) : Phase(_compiler, _phase), action(_action) {} + ActionPhase(Compiler* _compiler, Phases _phase, A _action) + : Phase(_compiler, _phase) + , action(_action) + { + } protected: virtual PhaseStatus DoPhase() override @@ -82,7 +89,8 @@ class CompilerPhase final : public Phase { public: CompilerPhase(Compiler* _compiler, Phases _phase, void (Compiler::*_action)()) - : Phase(_compiler, _phase), action(_action) + : Phase(_compiler, _phase) + , action(_action) { } @@ -112,7 +120,8 @@ class CompilerPhaseWithStatus final : public Phase { public: CompilerPhaseWithStatus(Compiler* _compiler, Phases _phase, PhaseStatus (Compiler::*_action)()) - : Phase(_compiler, _phase), action(_action) + : Phase(_compiler, _phase) + , action(_action) { } diff --git a/src/coreclr/jit/promotion.cpp b/src/coreclr/jit/promotion.cpp index 3c8ef9a45cc1d3..e02a5f0e06bab3 100644 --- a/src/coreclr/jit/promotion.cpp +++ b/src/coreclr/jit/promotion.cpp @@ -80,7 +80,9 @@ struct Access #endif Access(unsigned offset, var_types accessType, ClassLayout* layout) - : Layout(layout), Offset(offset), AccessType(accessType) + : Layout(layout) + , Offset(offset) + , AccessType(accessType) { } @@ -220,7 +222,8 @@ bool AggregateInfo::OverlappingReplacements(unsigned offset, // numLocals - Number of locals to support in the map // AggregateInfoMap::AggregateInfoMap(CompAllocator allocator, unsigned numLocals) - : m_aggregates(allocator), m_numLocals(numLocals) + : m_aggregates(allocator) + , m_numLocals(numLocals) { m_lclNumToAggregateIndex = new (allocator) unsigned[numLocals]; for (unsigned i = 0; i < numLocals; i++) @@ -277,7 +280,11 @@ struct PrimitiveAccess unsigned Offset; var_types AccessType; - PrimitiveAccess(unsigned offset, var_types accessType) : Offset(offset), AccessType(accessType) {} + PrimitiveAccess(unsigned offset, var_types accessType) + : Offset(offset) + , AccessType(accessType) + { + } }; // Tracks all the accesses into one particular struct local. @@ -288,7 +295,8 @@ class LocalUses public: LocalUses(Compiler* comp) - : m_accesses(comp->getAllocator(CMK_Promotion)), m_inducedAccesses(comp->getAllocator(CMK_Promotion)) + : m_accesses(comp->getAllocator(CMK_Promotion)) + , m_inducedAccesses(comp->getAllocator(CMK_Promotion)) { } @@ -2267,7 +2275,11 @@ void ReplaceVisitor::InsertPreStatementWriteBacks() DoPreOrder = true, }; - Visitor(Compiler* comp, ReplaceVisitor* replacer) : GenTreeVisitor(comp), m_replacer(replacer) {} + Visitor(Compiler* comp, ReplaceVisitor* replacer) + : GenTreeVisitor(comp) + , m_replacer(replacer) + { + } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { @@ -2676,22 +2688,19 @@ void ReplaceVisitor::CheckForwardSubForLastUse(unsigned lclNum) // void ReplaceVisitor::WriteBackBeforeCurrentStatement(unsigned lcl, unsigned offs, unsigned size) { - VisitOverlappingReplacements(lcl, offs, size, - [this, lcl](Replacement& rep) - { - if (!rep.NeedsWriteBack) - { - return; - } - - GenTree* readBack = Promotion::CreateWriteBack(m_compiler, lcl, rep); - Statement* stmt = m_compiler->fgNewStmtFromTree(readBack); - JITDUMP("Writing back %s before " FMT_STMT "\n", rep.Description, - m_currentStmt->GetID()); - DISPSTMT(stmt); - m_compiler->fgInsertStmtBefore(m_currentBlock, m_currentStmt, stmt); - ClearNeedsWriteBack(rep); - }); + VisitOverlappingReplacements(lcl, offs, size, [this, lcl](Replacement& rep) { + if (!rep.NeedsWriteBack) + { + return; + } + + GenTree* readBack = Promotion::CreateWriteBack(m_compiler, lcl, rep); + Statement* stmt = m_compiler->fgNewStmtFromTree(readBack); + JITDUMP("Writing back %s before " FMT_STMT "\n", rep.Description, m_currentStmt->GetID()); + DISPSTMT(stmt); + m_compiler->fgInsertStmtBefore(m_currentBlock, m_currentStmt, stmt); + ClearNeedsWriteBack(rep); + }); } //------------------------------------------------------------------------ @@ -2707,24 +2716,20 @@ void ReplaceVisitor::WriteBackBeforeCurrentStatement(unsigned lcl, unsigned offs // void ReplaceVisitor::WriteBackBeforeUse(GenTree** use, unsigned lcl, unsigned offs, unsigned size) { - VisitOverlappingReplacements(lcl, offs, size, - [this, &use, lcl](Replacement& rep) - { - if (!rep.NeedsWriteBack) - { - return; - } - - GenTreeOp* comma = - m_compiler->gtNewOperNode(GT_COMMA, (*use)->TypeGet(), - Promotion::CreateWriteBack(m_compiler, lcl, rep), - *use); - *use = comma; - use = &comma->gtOp2; - - ClearNeedsWriteBack(rep); - m_madeChanges = true; - }); + VisitOverlappingReplacements(lcl, offs, size, [this, &use, lcl](Replacement& rep) { + if (!rep.NeedsWriteBack) + { + return; + } + + GenTreeOp* comma = m_compiler->gtNewOperNode(GT_COMMA, (*use)->TypeGet(), + Promotion::CreateWriteBack(m_compiler, lcl, rep), *use); + *use = comma; + use = &comma->gtOp2; + + ClearNeedsWriteBack(rep); + m_madeChanges = true; + }); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/promotion.h b/src/coreclr/jit/promotion.h index f0a87783da87ea..89097d78cd1061 100644 --- a/src/coreclr/jit/promotion.h +++ b/src/coreclr/jit/promotion.h @@ -31,7 +31,11 @@ struct Replacement const char* Description = ""; #endif - Replacement(unsigned offset, var_types accessType) : Offset(offset), AccessType(accessType) {} + Replacement(unsigned offset, var_types accessType) + : Offset(offset) + , AccessType(accessType) + { + } bool Overlaps(unsigned otherStart, unsigned otherSize) const; }; @@ -49,9 +53,15 @@ class StructSegments unsigned Start = 0; unsigned End = 0; - Segment() {} + Segment() + { + } - Segment(unsigned start, unsigned end) : Start(start), End(end) {} + Segment(unsigned start, unsigned end) + : Start(start) + , End(end) + { + } bool IntersectsOrAdjacent(const Segment& other) const; bool Intersects(const Segment& other) const; @@ -63,7 +73,10 @@ class StructSegments jitstd::vector m_segments; public: - explicit StructSegments(CompAllocator allocator) : m_segments(allocator) {} + explicit StructSegments(CompAllocator allocator) + : m_segments(allocator) + { + } void Add(const Segment& segment); void Subtract(const Segment& segment); @@ -88,7 +101,12 @@ struct AggregateInfo // Max offset in the struct local of the unpromoted part. unsigned UnpromotedMax = 0; - AggregateInfo(CompAllocator alloc, unsigned lclNum) : Replacements(alloc), LclNum(lclNum), Unpromoted(alloc) {} + AggregateInfo(CompAllocator alloc, unsigned lclNum) + : Replacements(alloc) + , LclNum(lclNum) + , Unpromoted(alloc) + { + } bool OverlappingReplacements(unsigned offset, unsigned size, @@ -192,7 +210,10 @@ class Promotion static GenTree* EffectiveUser(Compiler::GenTreeStack& ancestors); public: - explicit Promotion(Compiler* compiler) : m_compiler(compiler) {} + explicit Promotion(Compiler* compiler) + : m_compiler(compiler) + { + } PhaseStatus Run(); }; @@ -206,10 +227,17 @@ class StructDeaths friend class PromotionLiveness; private: - StructDeaths(BitVec deaths, AggregateInfo* agg) : m_deaths(deaths), m_aggregate(agg) {} + StructDeaths(BitVec deaths, AggregateInfo* agg) + : m_deaths(deaths) + , m_aggregate(agg) + { + } public: - StructDeaths() : m_deaths(BitVecOps::UninitVal()) {} + StructDeaths() + : m_deaths(BitVecOps::UninitVal()) + { + } bool IsRemainderDying() const; bool IsReplacementDying(unsigned index) const; @@ -233,7 +261,9 @@ class PromotionLiveness public: PromotionLiveness(Compiler* compiler, AggregateInfoMap& aggregates) - : m_compiler(compiler), m_aggregates(aggregates), m_aggDeaths(compiler->getAllocator(CMK_Promotion)) + : m_compiler(compiler) + , m_aggregates(aggregates) + , m_aggDeaths(compiler->getAllocator(CMK_Promotion)) { } @@ -281,7 +311,10 @@ class ReplaceVisitor : public GenTreeVisitor }; ReplaceVisitor(Promotion* prom, AggregateInfoMap& aggregates, PromotionLiveness* liveness) - : GenTreeVisitor(prom->m_compiler), m_promotion(prom), m_aggregates(aggregates), m_liveness(liveness) + : GenTreeVisitor(prom->m_compiler) + , m_promotion(prom) + , m_aggregates(aggregates) + , m_liveness(liveness) { } diff --git a/src/coreclr/jit/promotiondecomposition.cpp b/src/coreclr/jit/promotiondecomposition.cpp index 76a64e1ddf3f11..d4f71b99835208 100644 --- a/src/coreclr/jit/promotiondecomposition.cpp +++ b/src/coreclr/jit/promotiondecomposition.cpp @@ -275,7 +275,9 @@ class DecompositionPlan var_types PrimitiveType; RemainderStrategy(int type, unsigned primitiveOffset = 0, var_types primitiveType = TYP_UNDEF) - : Type(type), PrimitiveOffset(primitiveOffset), PrimitiveType(primitiveType) + : Type(type) + , PrimitiveOffset(primitiveOffset) + , PrimitiveType(primitiveType) { } }; diff --git a/src/coreclr/jit/promotionliveness.cpp b/src/coreclr/jit/promotionliveness.cpp index dc2fe43a0bece4..174388ecb129fe 100644 --- a/src/coreclr/jit/promotionliveness.cpp +++ b/src/coreclr/jit/promotionliveness.cpp @@ -343,13 +343,11 @@ bool PromotionLiveness::PerBlockLiveness(BasicBlock* block) BasicBlockLiveness& bbInfo = m_bbInfo[block->bbNum]; BitVecOps::ClearD(m_bvTraits, bbInfo.LiveOut); - block->VisitRegularSuccs(m_compiler, - [=, &bbInfo](BasicBlock* succ) - { - BitVecOps::UnionD(m_bvTraits, bbInfo.LiveOut, m_bbInfo[succ->bbNum].LiveIn); - m_hasPossibleBackEdge |= succ->bbNum <= block->bbNum; - return BasicBlockVisit::Continue; - }); + block->VisitRegularSuccs(m_compiler, [=, &bbInfo](BasicBlock* succ) { + BitVecOps::UnionD(m_bvTraits, bbInfo.LiveOut, m_bbInfo[succ->bbNum].LiveIn); + m_hasPossibleBackEdge |= succ->bbNum <= block->bbNum; + return BasicBlockVisit::Continue; + }); BitVecOps::LivenessD(m_bvTraits, m_liveIn, bbInfo.VarDef, bbInfo.VarUse, bbInfo.LiveOut); @@ -388,12 +386,10 @@ void PromotionLiveness::AddHandlerLiveVars(BasicBlock* block, BitVec& ehLiveVars { assert(block->HasPotentialEHSuccs(m_compiler)); - block->VisitEHSuccs(m_compiler, - [=, &ehLiveVars](BasicBlock* succ) - { - BitVecOps::UnionD(m_bvTraits, ehLiveVars, m_bbInfo[succ->bbNum].LiveIn); - return BasicBlockVisit::Continue; - }); + block->VisitEHSuccs(m_compiler, [=, &ehLiveVars](BasicBlock* succ) { + BitVecOps::UnionD(m_bvTraits, ehLiveVars, m_bbInfo[succ->bbNum].LiveIn); + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/rangecheck.cpp b/src/coreclr/jit/rangecheck.cpp index fc508bc6e06215..eae6d627935837 100644 --- a/src/coreclr/jit/rangecheck.cpp +++ b/src/coreclr/jit/rangecheck.cpp @@ -461,7 +461,9 @@ bool RangeCheck::IsMonotonicallyIncreasing(GenTree* expr, bool rejectNegativeCon } // Remove hashtable entry for expr when we exit the present scope. - auto code = [this, expr] { m_pSearchPath->Remove(expr); }; + auto code = [this, expr] { + m_pSearchPath->Remove(expr); + }; jitstd::utility::scoped_code finally(code); if (m_pSearchPath->GetCount() > MAX_SEARCH_DEPTH) @@ -1566,7 +1568,12 @@ struct MapMethodDefsData BasicBlock* block; Statement* stmt; - MapMethodDefsData(RangeCheck* rc, BasicBlock* block, Statement* stmt) : rc(rc), block(block), stmt(stmt) {} + MapMethodDefsData(RangeCheck* rc, BasicBlock* block, Statement* stmt) + : rc(rc) + , block(block) + , stmt(stmt) + { + } }; Compiler::fgWalkResult MapMethodDefsVisitor(GenTree** ptr, Compiler::fgWalkData* data) diff --git a/src/coreclr/jit/rangecheck.h b/src/coreclr/jit/rangecheck.h index e98adceabd9568..cd4193f1e2fb73 100644 --- a/src/coreclr/jit/rangecheck.h +++ b/src/coreclr/jit/rangecheck.h @@ -83,16 +83,28 @@ struct Limit keUnknown, // The limit could not be determined. }; - Limit() : type(keUndef) {} + Limit() + : type(keUndef) + { + } - Limit(LimitType type) : type(type) {} + Limit(LimitType type) + : type(type) + { + } - Limit(LimitType type, int cns) : cns(cns), vn(ValueNumStore::NoVN), type(type) + Limit(LimitType type, int cns) + : cns(cns) + , vn(ValueNumStore::NoVN) + , type(type) { assert(type == keConstant); } - Limit(LimitType type, ValueNum vn, int cns) : cns(cns), vn(vn), type(type) + Limit(LimitType type, ValueNum vn, int cns) + : cns(cns) + , vn(vn) + , type(type) { assert(type == keBinOpArray); } @@ -238,9 +250,17 @@ struct Range Limit uLimit; Limit lLimit; - Range(const Limit& limit) : uLimit(limit), lLimit(limit) {} + Range(const Limit& limit) + : uLimit(limit) + , lLimit(limit) + { + } - Range(const Limit& lLimit, const Limit& uLimit) : uLimit(uLimit), lLimit(lLimit) {} + Range(const Limit& lLimit, const Limit& uLimit) + : uLimit(uLimit) + , lLimit(lLimit) + { + } Limit& UpperLimit() { @@ -578,7 +598,10 @@ class RangeCheck BasicBlock* block; Statement* stmt; GenTreeLclVarCommon* tree; - Location(BasicBlock* block, Statement* stmt, GenTreeLclVarCommon* tree) : block(block), stmt(stmt), tree(tree) + Location(BasicBlock* block, Statement* stmt, GenTreeLclVarCommon* tree) + : block(block) + , stmt(stmt) + , tree(tree) { } diff --git a/src/coreclr/jit/rationalize.cpp b/src/coreclr/jit/rationalize.cpp index cb54b617a6a9c8..d9b69b8df5aa27 100644 --- a/src/coreclr/jit/rationalize.cpp +++ b/src/coreclr/jit/rationalize.cpp @@ -383,7 +383,8 @@ PhaseStatus Rationalizer::DoPhase() }; RationalizeVisitor(Rationalizer& rationalizer) - : GenTreeVisitor(rationalizer.comp), m_rationalizer(rationalizer) + : GenTreeVisitor(rationalizer.comp) + , m_rationalizer(rationalizer) { } diff --git a/src/coreclr/jit/rationalize.h b/src/coreclr/jit/rationalize.h index f2965be8cef8f9..a8651b2e5b8c79 100644 --- a/src/coreclr/jit/rationalize.h +++ b/src/coreclr/jit/rationalize.h @@ -55,6 +55,9 @@ class Rationalizer final : public Phase Compiler::fgWalkResult RewriteNode(GenTree** useEdge, Compiler::GenTreeStack& parents); }; -inline Rationalizer::Rationalizer(Compiler* _comp) : Phase(_comp, PHASE_RATIONALIZE) {} +inline Rationalizer::Rationalizer(Compiler* _comp) + : Phase(_comp, PHASE_RATIONALIZE) +{ +} #endif diff --git a/src/coreclr/jit/redundantbranchopts.cpp b/src/coreclr/jit/redundantbranchopts.cpp index dc0992e282d8f8..e7569e86c2ed33 100644 --- a/src/coreclr/jit/redundantbranchopts.cpp +++ b/src/coreclr/jit/redundantbranchopts.cpp @@ -24,9 +24,15 @@ PhaseStatus Compiler::optRedundantBranches() public: bool madeChanges; - OptRedundantBranchesDomTreeVisitor(Compiler* compiler) : DomTreeVisitor(compiler), madeChanges(false) {} + OptRedundantBranchesDomTreeVisitor(Compiler* compiler) + : DomTreeVisitor(compiler) + , madeChanges(false) + { + } - void PreOrderVisit(BasicBlock* block) {} + void PreOrderVisit(BasicBlock* block) + { + } void PostOrderVisit(BasicBlock* block) { @@ -204,8 +210,7 @@ RelopResult IsCmp2ImpliedByCmp1(genTreeOps oper1, target_ssize_t bound1, genTree IntegralRange range2 = {minValue, maxValue}; // Update ranges based on inputs - auto setRange = [](genTreeOps oper, target_ssize_t bound, IntegralRange* range) -> bool - { + auto setRange = [](genTreeOps oper, target_ssize_t bound, IntegralRange* range) -> bool { switch (oper) { case GT_LT: @@ -2183,26 +2188,22 @@ bool Compiler::optReachable(BasicBlock* const fromBlock, BasicBlock* const toBlo continue; } - BasicBlockVisit result = - nextBlock->VisitAllSuccs(this, - [this, toBlock, &stack](BasicBlock* succ) - { - if (succ == toBlock) - { - return BasicBlockVisit::Abort; - } - - if (BitVecOps::IsMember(optReachableBitVecTraits, optReachableBitVec, - succ->bbNum)) - { - return BasicBlockVisit::Continue; - } - - BitVecOps::AddElemD(optReachableBitVecTraits, optReachableBitVec, succ->bbNum); - - stack.Push(succ); - return BasicBlockVisit::Continue; - }); + BasicBlockVisit result = nextBlock->VisitAllSuccs(this, [this, toBlock, &stack](BasicBlock* succ) { + if (succ == toBlock) + { + return BasicBlockVisit::Abort; + } + + if (BitVecOps::IsMember(optReachableBitVecTraits, optReachableBitVec, succ->bbNum)) + { + return BasicBlockVisit::Continue; + } + + BitVecOps::AddElemD(optReachableBitVecTraits, optReachableBitVec, succ->bbNum); + + stack.Push(succ); + return BasicBlockVisit::Continue; + }); if (result == BasicBlockVisit::Abort) { diff --git a/src/coreclr/jit/regset.cpp b/src/coreclr/jit/regset.cpp index 28b49133370232..5f5c80a4a19d6c 100644 --- a/src/coreclr/jit/regset.cpp +++ b/src/coreclr/jit/regset.cpp @@ -233,7 +233,9 @@ void RegSet::SetMaskVars(regMaskTP newMaskVars) /*****************************************************************************/ -RegSet::RegSet(Compiler* compiler, GCInfo& gcInfo) : m_rsCompiler(compiler), m_rsGCInfo(gcInfo) +RegSet::RegSet(Compiler* compiler, GCInfo& gcInfo) + : m_rsCompiler(compiler) + , m_rsGCInfo(gcInfo) { /* Initialize the spill logic */ @@ -1064,6 +1066,8 @@ void RegSet::rsSpillChk() #else // inline -void RegSet::rsSpillChk() {} +void RegSet::rsSpillChk() +{ +} #endif diff --git a/src/coreclr/jit/scev.cpp b/src/coreclr/jit/scev.cpp index 925801f0600834..491ee4ab06f049 100644 --- a/src/coreclr/jit/scev.cpp +++ b/src/coreclr/jit/scev.cpp @@ -206,7 +206,9 @@ void Scev::Dump(Compiler* comp) // ResetForLoop. // ScalarEvolutionContext::ScalarEvolutionContext(Compiler* comp) - : m_comp(comp), m_cache(comp->getAllocator(CMK_LoopIVOpts)), m_ephemeralCache(comp->getAllocator(CMK_LoopIVOpts)) + : m_comp(comp) + , m_cache(comp->getAllocator(CMK_LoopIVOpts)) + , m_ephemeralCache(comp->getAllocator(CMK_LoopIVOpts)) { } @@ -722,16 +724,14 @@ Scev* ScalarEvolutionContext::MakeAddRecFromRecursiveScev(Scev* startScev, Scev* } else { - ScevVisit result = addOperand->Visit( - [=](Scev* node) + ScevVisit result = addOperand->Visit([=](Scev* node) { + if (node == recursiveScev) { - if (node == recursiveScev) - { - return ScevVisit::Abort; - } + return ScevVisit::Abort; + } - return ScevVisit::Continue; - }); + return ScevVisit::Continue; + }); if (result == ScevVisit::Abort) { diff --git a/src/coreclr/jit/scev.h b/src/coreclr/jit/scev.h index 33b6ab467eaa71..1aab39e3d3a5de 100644 --- a/src/coreclr/jit/scev.h +++ b/src/coreclr/jit/scev.h @@ -48,7 +48,11 @@ struct Scev const ScevOper Oper; const var_types Type; - Scev(ScevOper oper, var_types type) : Oper(oper), Type(type) {} + Scev(ScevOper oper, var_types type) + : Oper(oper) + , Type(type) + { + } template bool OperIs(Args... opers) @@ -72,7 +76,11 @@ struct Scev struct ScevConstant : Scev { - ScevConstant(var_types type, int64_t value) : Scev(ScevOper::Constant, type), Value(value) {} + ScevConstant(var_types type, int64_t value) + : Scev(ScevOper::Constant, type) + , Value(value) + { + } int64_t Value; }; @@ -80,7 +88,9 @@ struct ScevConstant : Scev struct ScevLocal : Scev { ScevLocal(var_types type, unsigned lclNum, unsigned ssaNum) - : Scev(ScevOper::Local, type), LclNum(lclNum), SsaNum(ssaNum) + : Scev(ScevOper::Local, type) + , LclNum(lclNum) + , SsaNum(ssaNum) { } @@ -92,14 +102,22 @@ struct ScevLocal : Scev struct ScevUnop : Scev { - ScevUnop(ScevOper oper, var_types type, Scev* op1) : Scev(oper, type), Op1(op1) {} + ScevUnop(ScevOper oper, var_types type, Scev* op1) + : Scev(oper, type) + , Op1(op1) + { + } Scev* const Op1; }; struct ScevBinop : ScevUnop { - ScevBinop(ScevOper oper, var_types type, Scev* op1, Scev* op2) : ScevUnop(oper, type, op1), Op2(op2) {} + ScevBinop(ScevOper oper, var_types type, Scev* op1, Scev* op2) + : ScevUnop(oper, type, op1) + , Op2(op2) + { + } Scev* const Op2; }; @@ -110,7 +128,9 @@ struct ScevBinop : ScevUnop struct ScevAddRec : Scev { ScevAddRec(var_types type, Scev* start, Scev* step DEBUGARG(FlowGraphNaturalLoop* loop)) - : Scev(ScevOper::AddRec, type), Start(start), Step(step) DEBUGARG(Loop(loop)) + : Scev(ScevOper::AddRec, type) + , Start(start) + , Step(step) DEBUGARG(Loop(loop)) { } diff --git a/src/coreclr/jit/scopeinfo.cpp b/src/coreclr/jit/scopeinfo.cpp index d7dc6ff9cc3a0f..ddb766e94a0de9 100644 --- a/src/coreclr/jit/scopeinfo.cpp +++ b/src/coreclr/jit/scopeinfo.cpp @@ -1889,9 +1889,8 @@ void CodeGen::genSetScopeInfoUsingVariableRanges() continue; } - auto reportRange = - [this, varDsc, varNum, &liveRangeIndex](siVarLoc* loc, UNATIVE_OFFSET start, UNATIVE_OFFSET end) - { + auto reportRange = [this, varDsc, varNum, &liveRangeIndex](siVarLoc* loc, UNATIVE_OFFSET start, + UNATIVE_OFFSET end) { if (varDsc->lvIsParam && (start == end)) { // If the length is zero, it means that the prolog is empty. In that case, diff --git a/src/coreclr/jit/sideeffects.cpp b/src/coreclr/jit/sideeffects.cpp index 049eb8c86cde48..4a9b1899b24b84 100644 --- a/src/coreclr/jit/sideeffects.cpp +++ b/src/coreclr/jit/sideeffects.cpp @@ -8,7 +8,12 @@ #include "sideeffects.h" -LclVarSet::LclVarSet() : m_bitVector(nullptr), m_hasAnyLcl(false), m_hasBitVector(false) {} +LclVarSet::LclVarSet() + : m_bitVector(nullptr) + , m_hasAnyLcl(false) + , m_hasBitVector(false) +{ +} //------------------------------------------------------------------------ // LclVarSet::Add: @@ -119,7 +124,10 @@ void LclVarSet::Clear() } AliasSet::AliasSet() - : m_lclVarReads(), m_lclVarWrites(), m_readsAddressableLocation(false), m_writesAddressableLocation(false) + : m_lclVarReads() + , m_lclVarWrites() + , m_readsAddressableLocation(false) + , m_writesAddressableLocation(false) { } @@ -134,7 +142,11 @@ AliasSet::AliasSet() // node - The node in question. // AliasSet::NodeInfo::NodeInfo(Compiler* compiler, GenTree* node) - : m_compiler(compiler), m_node(node), m_flags(0), m_lclNum(0), m_lclOffs(0) + : m_compiler(compiler) + , m_node(node) + , m_flags(0) + , m_lclNum(0) + , m_lclOffs(0) { if (node->IsCall()) { @@ -272,25 +284,23 @@ void AliasSet::AddNode(Compiler* compiler, GenTree* node) { // First, add all lclVar uses associated with the node to the set. This is necessary because the lclVar reads occur // at the position of the user, not at the position of the GenTreeLclVar node. - node->VisitOperands( - [compiler, this](GenTree* operand) -> GenTree::VisitResult + node->VisitOperands([compiler, this](GenTree* operand) -> GenTree::VisitResult { + if (operand->OperIsLocalRead()) { - if (operand->OperIsLocalRead()) + const unsigned lclNum = operand->AsLclVarCommon()->GetLclNum(); + if (compiler->lvaTable[lclNum].IsAddressExposed()) { - const unsigned lclNum = operand->AsLclVarCommon()->GetLclNum(); - if (compiler->lvaTable[lclNum].IsAddressExposed()) - { - m_readsAddressableLocation = true; - } - - m_lclVarReads.Add(compiler, lclNum); + m_readsAddressableLocation = true; } - if (operand->isContained()) - { - AddNode(compiler, operand); - } - return GenTree::VisitResult::Continue; - }); + + m_lclVarReads.Add(compiler, lclNum); + } + if (operand->isContained()) + { + AddNode(compiler, operand); + } + return GenTree::VisitResult::Continue; + }); NodeInfo nodeInfo(compiler, node); if (nodeInfo.ReadsAddressableLocation()) @@ -444,7 +454,11 @@ void AliasSet::Clear() m_lclVarWrites.Clear(); } -SideEffectSet::SideEffectSet() : m_sideEffectFlags(0), m_aliasSet() {} +SideEffectSet::SideEffectSet() + : m_sideEffectFlags(0) + , m_aliasSet() +{ +} //------------------------------------------------------------------------ // SideEffectSet::SideEffectSet: @@ -458,7 +472,9 @@ SideEffectSet::SideEffectSet() : m_sideEffectFlags(0), m_aliasSet() {} // compiler - The compiler context. // node - The node to use for initialization. // -SideEffectSet::SideEffectSet(Compiler* compiler, GenTree* node) : m_sideEffectFlags(0), m_aliasSet() +SideEffectSet::SideEffectSet(Compiler* compiler, GenTree* node) + : m_sideEffectFlags(0) + , m_aliasSet() { AddNode(compiler, node); } diff --git a/src/coreclr/jit/smallhash.h b/src/coreclr/jit/smallhash.h index 1666ceb6f0b22b..5bbf58e99a4bd9 100644 --- a/src/coreclr/jit/smallhash.h +++ b/src/coreclr/jit/smallhash.h @@ -338,7 +338,10 @@ class HashTableBase protected: HashTableBase(TAllocator alloc, Bucket* buckets, unsigned numBuckets) - : m_alloc(alloc), m_buckets(buckets), m_numBuckets(numBuckets), m_numFullBuckets(0) + : m_alloc(alloc) + , m_buckets(buckets) + , m_numBuckets(numBuckets) + , m_numFullBuckets(0) { if (numBuckets > 0) { @@ -359,13 +362,17 @@ class HashTableBase Bucket* m_bucket; - KeyValuePair(Bucket* bucket) : m_bucket(bucket) + KeyValuePair(Bucket* bucket) + : m_bucket(bucket) { assert(m_bucket != nullptr); } public: - KeyValuePair() : m_bucket(nullptr) {} + KeyValuePair() + : m_bucket(nullptr) + { + } inline TKey& Key() { @@ -390,7 +397,9 @@ class HashTableBase unsigned m_index; Iterator(Bucket* buckets, unsigned numBuckets, unsigned index) - : m_buckets(buckets), m_numBuckets(numBuckets), m_index(index) + : m_buckets(buckets) + , m_numBuckets(numBuckets) + , m_index(index) { assert((buckets != nullptr) || (numBuckets == 0)); assert(index <= numBuckets); @@ -403,7 +412,12 @@ class HashTableBase } public: - Iterator() : m_buckets(nullptr), m_numBuckets(0), m_index(0) {} + Iterator() + : m_buckets(nullptr) + , m_numBuckets(0) + , m_index(0) + { + } KeyValuePair operator*() const { @@ -632,7 +646,10 @@ class HashTable final : public HashTableBase } public: - HashTable(TAllocator alloc) : TBase(alloc, nullptr, 0) {} + HashTable(TAllocator alloc) + : TBase(alloc, nullptr, 0) + { + } HashTable(TAllocator alloc, unsigned initialSize) : TBase(alloc, alloc.template allocate(RoundUp(initialSize)), RoundUp(initialSize)) @@ -664,7 +681,10 @@ class SmallHashTable final : public HashTableBaselvaTable[lclNum].lvVarIndex; - block->VisitEHSuccs(m_pCompiler, - [=](BasicBlock* succ) - { - // Is "lclNum" live on entry to the handler? - if (!VarSetOps::IsMember(m_pCompiler, succ->bbLiveIn, lclIndex)) - { - return BasicBlockVisit::Continue; - } + block->VisitEHSuccs(m_pCompiler, [=](BasicBlock* succ) { + // Is "lclNum" live on entry to the handler? + if (!VarSetOps::IsMember(m_pCompiler, succ->bbLiveIn, lclIndex)) + { + return BasicBlockVisit::Continue; + } #ifdef DEBUG - bool phiFound = false; + bool phiFound = false; #endif - // A prefix of blocks statements will be SSA definitions. Search those for "lclNum". - for (Statement* const stmt : succ->Statements()) - { - // If the tree is not an SSA def, break out of the loop: we're done. - if (!stmt->IsPhiDefnStmt()) - { - break; - } - - GenTreeLclVar* phiDef = stmt->GetRootNode()->AsLclVar(); - assert(phiDef->IsPhiDefn()); - - if (phiDef->GetLclNum() == lclNum) - { - // It's the definition for the right local. Add "ssaNum" to the RHS. - AddPhiArg(succ, stmt, phiDef->Data()->AsPhi(), lclNum, ssaNum, block); + // A prefix of blocks statements will be SSA definitions. Search those for "lclNum". + for (Statement* const stmt : succ->Statements()) + { + // If the tree is not an SSA def, break out of the loop: we're done. + if (!stmt->IsPhiDefnStmt()) + { + break; + } + + GenTreeLclVar* phiDef = stmt->GetRootNode()->AsLclVar(); + assert(phiDef->IsPhiDefn()); + + if (phiDef->GetLclNum() == lclNum) + { + // It's the definition for the right local. Add "ssaNum" to the RHS. + AddPhiArg(succ, stmt, phiDef->Data()->AsPhi(), lclNum, ssaNum, block); #ifdef DEBUG - phiFound = true; + phiFound = true; #endif - break; - } - } - assert(phiFound); + break; + } + } + assert(phiFound); - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } void SsaBuilder::AddMemoryDefToEHSuccessorPhis(MemoryKind memoryKind, BasicBlock* block, unsigned ssaNum) @@ -803,60 +801,58 @@ void SsaBuilder::AddMemoryDefToEHSuccessorPhis(MemoryKind memoryKind, BasicBlock " has potential EH successors; adding as phi arg to EH successors.\n", memoryKindNames[memoryKind], ssaNum, block->bbNum); - block->VisitEHSuccs(m_pCompiler, - [=](BasicBlock* succ) - { - // Is memoryKind live on entry to the handler? - if ((succ->bbMemoryLiveIn & memoryKindSet(memoryKind)) == 0) - { - return BasicBlockVisit::Continue; - } + block->VisitEHSuccs(m_pCompiler, [=](BasicBlock* succ) { + // Is memoryKind live on entry to the handler? + if ((succ->bbMemoryLiveIn & memoryKindSet(memoryKind)) == 0) + { + return BasicBlockVisit::Continue; + } - // Add "ssaNum" to the phi args of memoryKind. - BasicBlock::MemoryPhiArg*& handlerMemoryPhi = succ->bbMemorySsaPhiFunc[memoryKind]; + // Add "ssaNum" to the phi args of memoryKind. + BasicBlock::MemoryPhiArg*& handlerMemoryPhi = succ->bbMemorySsaPhiFunc[memoryKind]; #if DEBUG - if (m_pCompiler->byrefStatesMatchGcHeapStates) - { - // When sharing phis for GcHeap and ByrefExposed, callers should ask to add phis - // for ByrefExposed only. - assert(memoryKind != GcHeap); - if (memoryKind == ByrefExposed) - { - // The GcHeap and ByrefExposed phi funcs should always be in sync. - assert(handlerMemoryPhi == succ->bbMemorySsaPhiFunc[GcHeap]); - } - } + if (m_pCompiler->byrefStatesMatchGcHeapStates) + { + // When sharing phis for GcHeap and ByrefExposed, callers should ask to add phis + // for ByrefExposed only. + assert(memoryKind != GcHeap); + if (memoryKind == ByrefExposed) + { + // The GcHeap and ByrefExposed phi funcs should always be in sync. + assert(handlerMemoryPhi == succ->bbMemorySsaPhiFunc[GcHeap]); + } + } #endif - if (handlerMemoryPhi == BasicBlock::EmptyMemoryPhiDef) - { - handlerMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum); - } - else - { + if (handlerMemoryPhi == BasicBlock::EmptyMemoryPhiDef) + { + handlerMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum); + } + else + { #ifdef DEBUG - BasicBlock::MemoryPhiArg* curArg = succ->bbMemorySsaPhiFunc[memoryKind]; - while (curArg != nullptr) - { - assert(curArg->GetSsaNum() != ssaNum); - curArg = curArg->m_nextArg; - } + BasicBlock::MemoryPhiArg* curArg = succ->bbMemorySsaPhiFunc[memoryKind]; + while (curArg != nullptr) + { + assert(curArg->GetSsaNum() != ssaNum); + curArg = curArg->m_nextArg; + } #endif // DEBUG - handlerMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum, handlerMemoryPhi); - } + handlerMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum, handlerMemoryPhi); + } - DBG_SSA_JITDUMP(" Added phi arg u:%d for %s to phi defn in handler block " FMT_BB ".\n", - ssaNum, memoryKindNames[memoryKind], memoryKind, succ->bbNum); + DBG_SSA_JITDUMP(" Added phi arg u:%d for %s to phi defn in handler block " FMT_BB ".\n", ssaNum, + memoryKindNames[memoryKind], memoryKind, succ->bbNum); - if ((memoryKind == ByrefExposed) && m_pCompiler->byrefStatesMatchGcHeapStates) - { - // Share the phi between GcHeap and ByrefExposed. - succ->bbMemorySsaPhiFunc[GcHeap] = handlerMemoryPhi; - } + if ((memoryKind == ByrefExposed) && m_pCompiler->byrefStatesMatchGcHeapStates) + { + // Share the phi between GcHeap and ByrefExposed. + succ->bbMemorySsaPhiFunc[GcHeap] = handlerMemoryPhi; + } - return BasicBlockVisit::Continue; - }); + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ @@ -965,140 +961,133 @@ void SsaBuilder::BlockRenameVariables(BasicBlock* block) // void SsaBuilder::AddPhiArgsToSuccessors(BasicBlock* block) { - block->VisitAllSuccs(m_pCompiler, - [this, block](BasicBlock* succ) - { - // Walk the statements for phi nodes. - for (Statement* const stmt : succ->Statements()) - { - // A prefix of the statements of the block are phi definition nodes. If we complete - // processing that prefix, exit. - if (!stmt->IsPhiDefnStmt()) - { - break; - } - - GenTreeLclVar* store = stmt->GetRootNode()->AsLclVar(); - GenTreePhi* phi = store->Data()->AsPhi(); - unsigned lclNum = store->GetLclNum(); - unsigned ssaNum = m_renameStack.Top(lclNum); - - AddPhiArg(succ, stmt, phi, lclNum, ssaNum, block); - } - - // Now handle memory. - for (MemoryKind memoryKind : allMemoryKinds()) - { - BasicBlock::MemoryPhiArg*& succMemoryPhi = succ->bbMemorySsaPhiFunc[memoryKind]; - if (succMemoryPhi != nullptr) - { - if ((memoryKind == GcHeap) && m_pCompiler->byrefStatesMatchGcHeapStates) - { - // We've already propagated the "out" number to the phi shared with - // ByrefExposed, but still need to update bbMemorySsaPhiFunc to be in sync - // between GcHeap and ByrefExposed. - assert(memoryKind > ByrefExposed); - assert(block->bbMemorySsaNumOut[memoryKind] == - block->bbMemorySsaNumOut[ByrefExposed]); - assert((succ->bbMemorySsaPhiFunc[ByrefExposed] == succMemoryPhi) || - (succ->bbMemorySsaPhiFunc[ByrefExposed]->m_nextArg == - (succMemoryPhi == BasicBlock::EmptyMemoryPhiDef ? nullptr - : succMemoryPhi))); - succMemoryPhi = succ->bbMemorySsaPhiFunc[ByrefExposed]; - - continue; - } - - if (succMemoryPhi == BasicBlock::EmptyMemoryPhiDef) - { - succMemoryPhi = new (m_pCompiler) - BasicBlock::MemoryPhiArg(block->bbMemorySsaNumOut[memoryKind]); - } - else - { - BasicBlock::MemoryPhiArg* curArg = succMemoryPhi; - unsigned ssaNum = block->bbMemorySsaNumOut[memoryKind]; - bool found = false; - // This is a quadratic algorithm. We might need to consider some switch over - // to a hash table representation for the arguments of a phi node, to make this - // linear. - while (curArg != nullptr) - { - if (curArg->m_ssaNum == ssaNum) - { - found = true; - break; - } - curArg = curArg->m_nextArg; - } - if (!found) - { - succMemoryPhi = - new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum, succMemoryPhi); - } - } - DBG_SSA_JITDUMP(" Added phi arg for %s u:%d from " FMT_BB " in " FMT_BB ".\n", - memoryKindNames[memoryKind], block->bbMemorySsaNumOut[memoryKind], - block->bbNum, succ->bbNum); - } - } - - // If "succ" is the first block of a try block (and "block" is not also in that try block) - // then we must look at the vars that have phi defs in the corresponding handler; - // the current SSA name for such vars must be included as an argument to that phi. - if (m_pCompiler->bbIsTryBeg(succ)) - { - assert(succ->hasTryIndex()); - unsigned tryInd = succ->getTryIndex(); - - while (tryInd != EHblkDsc::NO_ENCLOSING_INDEX) - { - // Check if the predecessor "block" is within the same try block. - if (block->hasTryIndex()) - { - for (unsigned blockTryInd = block->getTryIndex(); - blockTryInd != EHblkDsc::NO_ENCLOSING_INDEX; - blockTryInd = m_pCompiler->ehGetEnclosingTryIndex(blockTryInd)) - { - if (blockTryInd == tryInd) - { - // It is; don't execute the loop below. - tryInd = EHblkDsc::NO_ENCLOSING_INDEX; - break; - } - } - - // The loop just above found that the predecessor "block" is within the same - // try block as "succ." So we don't need to process this try, or any - // further outer try blocks here, since they would also contain both "succ" - // and "block". - if (tryInd == EHblkDsc::NO_ENCLOSING_INDEX) - { - break; - } - } - - EHblkDsc* succTry = m_pCompiler->ehGetDsc(tryInd); - // This is necessarily true on the first iteration, but not - // necessarily on the second and subsequent. - if (succTry->ebdTryBeg != succ) - { - break; - } - - if (succTry->HasFilter()) - { - AddPhiArgsToNewlyEnteredHandler(block, succ, succTry->ebdFilter); - } - - AddPhiArgsToNewlyEnteredHandler(block, succ, succTry->ebdHndBeg); - - tryInd = succTry->ebdEnclosingTryIndex; - } - } - - return BasicBlockVisit::Continue; - }); + block->VisitAllSuccs(m_pCompiler, [this, block](BasicBlock* succ) { + // Walk the statements for phi nodes. + for (Statement* const stmt : succ->Statements()) + { + // A prefix of the statements of the block are phi definition nodes. If we complete + // processing that prefix, exit. + if (!stmt->IsPhiDefnStmt()) + { + break; + } + + GenTreeLclVar* store = stmt->GetRootNode()->AsLclVar(); + GenTreePhi* phi = store->Data()->AsPhi(); + unsigned lclNum = store->GetLclNum(); + unsigned ssaNum = m_renameStack.Top(lclNum); + + AddPhiArg(succ, stmt, phi, lclNum, ssaNum, block); + } + + // Now handle memory. + for (MemoryKind memoryKind : allMemoryKinds()) + { + BasicBlock::MemoryPhiArg*& succMemoryPhi = succ->bbMemorySsaPhiFunc[memoryKind]; + if (succMemoryPhi != nullptr) + { + if ((memoryKind == GcHeap) && m_pCompiler->byrefStatesMatchGcHeapStates) + { + // We've already propagated the "out" number to the phi shared with + // ByrefExposed, but still need to update bbMemorySsaPhiFunc to be in sync + // between GcHeap and ByrefExposed. + assert(memoryKind > ByrefExposed); + assert(block->bbMemorySsaNumOut[memoryKind] == block->bbMemorySsaNumOut[ByrefExposed]); + assert((succ->bbMemorySsaPhiFunc[ByrefExposed] == succMemoryPhi) || + (succ->bbMemorySsaPhiFunc[ByrefExposed]->m_nextArg == + (succMemoryPhi == BasicBlock::EmptyMemoryPhiDef ? nullptr : succMemoryPhi))); + succMemoryPhi = succ->bbMemorySsaPhiFunc[ByrefExposed]; + + continue; + } + + if (succMemoryPhi == BasicBlock::EmptyMemoryPhiDef) + { + succMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(block->bbMemorySsaNumOut[memoryKind]); + } + else + { + BasicBlock::MemoryPhiArg* curArg = succMemoryPhi; + unsigned ssaNum = block->bbMemorySsaNumOut[memoryKind]; + bool found = false; + // This is a quadratic algorithm. We might need to consider some switch over + // to a hash table representation for the arguments of a phi node, to make this + // linear. + while (curArg != nullptr) + { + if (curArg->m_ssaNum == ssaNum) + { + found = true; + break; + } + curArg = curArg->m_nextArg; + } + if (!found) + { + succMemoryPhi = new (m_pCompiler) BasicBlock::MemoryPhiArg(ssaNum, succMemoryPhi); + } + } + DBG_SSA_JITDUMP(" Added phi arg for %s u:%d from " FMT_BB " in " FMT_BB ".\n", + memoryKindNames[memoryKind], block->bbMemorySsaNumOut[memoryKind], block->bbNum, + succ->bbNum); + } + } + + // If "succ" is the first block of a try block (and "block" is not also in that try block) + // then we must look at the vars that have phi defs in the corresponding handler; + // the current SSA name for such vars must be included as an argument to that phi. + if (m_pCompiler->bbIsTryBeg(succ)) + { + assert(succ->hasTryIndex()); + unsigned tryInd = succ->getTryIndex(); + + while (tryInd != EHblkDsc::NO_ENCLOSING_INDEX) + { + // Check if the predecessor "block" is within the same try block. + if (block->hasTryIndex()) + { + for (unsigned blockTryInd = block->getTryIndex(); blockTryInd != EHblkDsc::NO_ENCLOSING_INDEX; + blockTryInd = m_pCompiler->ehGetEnclosingTryIndex(blockTryInd)) + { + if (blockTryInd == tryInd) + { + // It is; don't execute the loop below. + tryInd = EHblkDsc::NO_ENCLOSING_INDEX; + break; + } + } + + // The loop just above found that the predecessor "block" is within the same + // try block as "succ." So we don't need to process this try, or any + // further outer try blocks here, since they would also contain both "succ" + // and "block". + if (tryInd == EHblkDsc::NO_ENCLOSING_INDEX) + { + break; + } + } + + EHblkDsc* succTry = m_pCompiler->ehGetDsc(tryInd); + // This is necessarily true on the first iteration, but not + // necessarily on the second and subsequent. + if (succTry->ebdTryBeg != succ) + { + break; + } + + if (succTry->HasFilter()) + { + AddPhiArgsToNewlyEnteredHandler(block, succ, succTry->ebdFilter); + } + + AddPhiArgsToNewlyEnteredHandler(block, succ, succTry->ebdHndBeg); + + tryInd = succTry->ebdEnclosingTryIndex; + } + } + + return BasicBlockVisit::Continue; + }); } //------------------------------------------------------------------------ @@ -1255,7 +1244,9 @@ void SsaBuilder::RenameVariables() public: SsaRenameDomTreeVisitor(Compiler* compiler, SsaBuilder* builder, SsaRenameState* renameStack) - : DomTreeVisitor(compiler), m_builder(builder), m_renameStack(renameStack) + : DomTreeVisitor(compiler) + , m_builder(builder) + , m_renameStack(renameStack) { } diff --git a/src/coreclr/jit/ssarenamestate.cpp b/src/coreclr/jit/ssarenamestate.cpp index 369c8f190359d1..257bb84d66167f 100644 --- a/src/coreclr/jit/ssarenamestate.cpp +++ b/src/coreclr/jit/ssarenamestate.cpp @@ -13,7 +13,10 @@ // lvaCount - The number of local variables // SsaRenameState::SsaRenameState(CompAllocator alloc, unsigned lvaCount) - : m_alloc(alloc), m_lvaCount(lvaCount), m_stacks(nullptr), m_stackListTail(nullptr) + : m_alloc(alloc) + , m_lvaCount(lvaCount) + , m_stacks(nullptr) + , m_stackListTail(nullptr) { } diff --git a/src/coreclr/jit/ssarenamestate.h b/src/coreclr/jit/ssarenamestate.h index 609d9b89f9b160..a71fe33a370c7b 100644 --- a/src/coreclr/jit/ssarenamestate.h +++ b/src/coreclr/jit/ssarenamestate.h @@ -12,7 +12,10 @@ class SsaRenameState StackNode* m_top; public: - Stack() : m_top(nullptr) {} + Stack() + : m_top(nullptr) + { + } StackNode* Top() { @@ -45,7 +48,9 @@ class SsaRenameState unsigned m_ssaNum; StackNode(Stack* listPrev, BasicBlock* block, unsigned ssaNum) - : m_listPrev(listPrev), m_block(block), m_ssaNum(ssaNum) + : m_listPrev(listPrev) + , m_block(block) + , m_ssaNum(ssaNum) { } }; diff --git a/src/coreclr/jit/switchrecognition.cpp b/src/coreclr/jit/switchrecognition.cpp index 3f975416f93a99..747d046699340e 100644 --- a/src/coreclr/jit/switchrecognition.cpp +++ b/src/coreclr/jit/switchrecognition.cpp @@ -9,7 +9,7 @@ // We mainly rely on TryLowerSwitchToBitTest in these heuristics, but jump tables can be useful // even without conversion to a bitmap test. #define SWITCH_MAX_DISTANCE ((TARGET_POINTER_SIZE * BITS_PER_BYTE) - 1) -#define SWITCH_MIN_TESTS 3 +#define SWITCH_MIN_TESTS 3 //----------------------------------------------------------------------------- // optSwitchRecognition: Optimize range check for `x == cns1 || x == cns2 || x == cns3 ...` diff --git a/src/coreclr/jit/target.h b/src/coreclr/jit/target.h index cac9b3968a230c..4b1461efde0fe3 100644 --- a/src/coreclr/jit/target.h +++ b/src/coreclr/jit/target.h @@ -68,27 +68,27 @@ inline bool compUnixX86Abi() // The following are intended to capture only those #defines that cannot be replaced // with static const members of Target #if defined(TARGET_AMD64) -#define REGMASK_BITS 64 +#define REGMASK_BITS 64 #define CSE_CONST_SHARED_LOW_BITS 16 #elif defined(TARGET_X86) -#define REGMASK_BITS 32 +#define REGMASK_BITS 32 #define CSE_CONST_SHARED_LOW_BITS 16 #elif defined(TARGET_ARM) -#define REGMASK_BITS 64 +#define REGMASK_BITS 64 #define CSE_CONST_SHARED_LOW_BITS 12 #elif defined(TARGET_ARM64) -#define REGMASK_BITS 64 +#define REGMASK_BITS 64 #define CSE_CONST_SHARED_LOW_BITS 12 #elif defined(TARGET_LOONGARCH64) -#define REGMASK_BITS 64 +#define REGMASK_BITS 64 #define CSE_CONST_SHARED_LOW_BITS 12 #elif defined(TARGET_RISCV64) -#define REGMASK_BITS 64 +#define REGMASK_BITS 64 #define CSE_CONST_SHARED_LOW_BITS 12 #else @@ -110,7 +110,7 @@ inline bool compUnixX86Abi() enum _regNumber_enum : unsigned { #define REGDEF(name, rnum, mask, sname) REG_##name = rnum, -#define REGALIAS(alias, realname) REG_##alias = REG_##realname, +#define REGALIAS(alias, realname) REG_##alias = REG_##realname, #include "register.h" REG_COUNT, @@ -122,7 +122,7 @@ enum _regMask_enum : unsigned __int64 { RBM_NONE = 0, #define REGDEF(name, rnum, mask, sname) RBM_##name = mask, -#define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, +#define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, #include "register.h" }; @@ -131,7 +131,7 @@ enum _regMask_enum : unsigned __int64 enum _regNumber_enum : unsigned { #define REGDEF(name, rnum, mask, xname, wname) REG_##name = rnum, -#define REGALIAS(alias, realname) REG_##alias = REG_##realname, +#define REGALIAS(alias, realname) REG_##alias = REG_##realname, #include "register.h" REG_COUNT, @@ -143,7 +143,7 @@ enum _regMask_enum : unsigned __int64 { RBM_NONE = 0, #define REGDEF(name, rnum, mask, xname, wname) RBM_##name = mask, -#define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, +#define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, #include "register.h" }; @@ -152,7 +152,7 @@ enum _regMask_enum : unsigned __int64 enum _regNumber_enum : unsigned { #define REGDEF(name, rnum, mask, sname) REG_##name = rnum, -#define REGALIAS(alias, realname) REG_##alias = REG_##realname, +#define REGALIAS(alias, realname) REG_##alias = REG_##realname, #include "register.h" REG_COUNT, @@ -165,9 +165,8 @@ enum _regMask_enum : uint64_t RBM_NONE = 0, #define REGDEF(name, rnum, mask, sname) RBM_##name = mask, -#define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, +#define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, #include "register.h" - }; #elif defined(TARGET_X86) @@ -175,7 +174,7 @@ enum _regMask_enum : uint64_t enum _regNumber_enum : unsigned { #define REGDEF(name, rnum, mask, sname) REG_##name = rnum, -#define REGALIAS(alias, realname) REG_##alias = REG_##realname, +#define REGALIAS(alias, realname) REG_##alias = REG_##realname, #include "register.h" REG_COUNT, @@ -188,7 +187,7 @@ enum _regMask_enum : unsigned RBM_NONE = 0, #define REGDEF(name, rnum, mask, sname) RBM_##name = mask, -#define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, +#define REGALIAS(alias, realname) RBM_##alias = RBM_##realname, #include "register.h" }; @@ -239,9 +238,9 @@ typedef unsigned char regNumberSmall; /*****************************************************************************/ #ifdef DEBUG -#define DSP_SRC_OPER_LEFT 0 +#define DSP_SRC_OPER_LEFT 0 #define DSP_SRC_OPER_RIGHT 1 -#define DSP_DST_OPER_LEFT 1 +#define DSP_DST_OPER_LEFT 1 #define DSP_DST_OPER_RIGHT 0 #endif diff --git a/src/coreclr/jit/targetamd64.cpp b/src/coreclr/jit/targetamd64.cpp index 576a152d4b8161..85b1ba6ef19a23 100644 --- a/src/coreclr/jit/targetamd64.cpp +++ b/src/coreclr/jit/targetamd64.cpp @@ -39,7 +39,8 @@ const regMaskTP fltArgMasks[] = { RBM_XMM0, RBM_XMM1, RBM_XMM2, RBM_XMM3 }; // info - Info about the method being classified. // SysVX64Classifier::SysVX64Classifier(const ClassifierInfo& info) - : m_intRegs(intArgRegs, ArrLen(intArgRegs)), m_floatRegs(fltArgRegs, ArrLen(fltArgRegs)) + : m_intRegs(intArgRegs, ArrLen(intArgRegs)) + , m_floatRegs(fltArgRegs, ArrLen(fltArgRegs)) { } @@ -141,7 +142,8 @@ ABIPassingInformation SysVX64Classifier::Classify(Compiler* comp, // info - Info about the method being classified. // WinX64Classifier::WinX64Classifier(const ClassifierInfo& info) - : m_intRegs(intArgRegs, ArrLen(intArgRegs)), m_floatRegs(fltArgRegs, ArrLen(fltArgRegs)) + : m_intRegs(intArgRegs, ArrLen(intArgRegs)) + , m_floatRegs(fltArgRegs, ArrLen(fltArgRegs)) { } diff --git a/src/coreclr/jit/targetarm.cpp b/src/coreclr/jit/targetarm.cpp index 7816880dd21967..037578fa67b85c 100644 --- a/src/coreclr/jit/targetarm.cpp +++ b/src/coreclr/jit/targetarm.cpp @@ -33,7 +33,10 @@ static_assert_no_msg(RBM_ALLDOUBLE == (RBM_ALLDOUBLE_HIGH >> 1)); // Parameters: // info - Info about the method being classified. // -Arm32Classifier::Arm32Classifier(const ClassifierInfo& info) : m_info(info) {} +Arm32Classifier::Arm32Classifier(const ClassifierInfo& info) + : m_info(info) +{ +} //----------------------------------------------------------------------------- // Classify: diff --git a/src/coreclr/jit/targetarm64.cpp b/src/coreclr/jit/targetarm64.cpp index f48cfae542cd34..cef1e95780695b 100644 --- a/src/coreclr/jit/targetarm64.cpp +++ b/src/coreclr/jit/targetarm64.cpp @@ -32,7 +32,9 @@ const regMaskTP fltArgMasks[] = {RBM_V0, RBM_V1, RBM_V2, RBM_V3, RBM_V4, RBM_V5, // info - Info about the method being classified. // Arm64Classifier::Arm64Classifier(const ClassifierInfo& info) - : m_info(info), m_intRegs(intArgRegs, ArrLen(intArgRegs)), m_floatRegs(fltArgRegs, ArrLen(fltArgRegs)) + : m_info(info) + , m_intRegs(intArgRegs, ArrLen(intArgRegs)) + , m_floatRegs(fltArgRegs, ArrLen(fltArgRegs)) { } diff --git a/src/coreclr/jit/targetx86.cpp b/src/coreclr/jit/targetx86.cpp index 1c3e91be1bd2ff..5c2702d4728893 100644 --- a/src/coreclr/jit/targetx86.cpp +++ b/src/coreclr/jit/targetx86.cpp @@ -28,7 +28,8 @@ const regMaskTP intArgMasks[] = {RBM_ECX, RBM_EDX}; // Parameters: // info - Info about the method being classified. // -X86Classifier::X86Classifier(const ClassifierInfo& info) : m_regs(nullptr, 0) +X86Classifier::X86Classifier(const ClassifierInfo& info) + : m_regs(nullptr, 0) { switch (info.CallConv) { diff --git a/src/coreclr/jit/typelist.h b/src/coreclr/jit/typelist.h index 1a9a8c4072f6bf..bf5acb5ee014a5 100644 --- a/src/coreclr/jit/typelist.h +++ b/src/coreclr/jit/typelist.h @@ -4,7 +4,7 @@ #define GCS EA_GCREF #define BRS EA_BYREF #define EPS EA_PTRSIZE -#define PS TARGET_POINTER_SIZE +#define PS TARGET_POINTER_SIZE #define PST (TARGET_POINTER_SIZE / sizeof(int)) #ifdef TARGET_64BIT diff --git a/src/coreclr/jit/unwind.h b/src/coreclr/jit/unwind.h index f5609c1842d2b9..8b7fcaa5a103dc 100644 --- a/src/coreclr/jit/unwind.h +++ b/src/coreclr/jit/unwind.h @@ -21,36 +21,36 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #if defined(TARGET_ARM) const unsigned MAX_PROLOG_SIZE_BYTES = 44; const unsigned MAX_EPILOG_SIZE_BYTES = 44; -#define UWC_END 0xFF // "end" unwind code +#define UWC_END 0xFF // "end" unwind code #define UW_MAX_FRAGMENT_SIZE_BYTES (1U << 19) -#define UW_MAX_CODE_WORDS_COUNT 15 // Max number that can be encoded in the "Code Words" field of the .pdata record +#define UW_MAX_CODE_WORDS_COUNT 15 // Max number that can be encoded in the "Code Words" field of the .pdata record #define UW_MAX_EPILOG_START_INDEX \ 0xFFU // Max number that can be encoded in the "Epilog Start Index" field // of the .pdata record #elif defined(TARGET_ARM64) const unsigned MAX_PROLOG_SIZE_BYTES = 100; const unsigned MAX_EPILOG_SIZE_BYTES = 100; -#define UWC_END 0xE4 // "end" unwind code -#define UWC_END_C 0xE5 // "end_c" unwind code +#define UWC_END 0xE4 // "end" unwind code +#define UWC_END_C 0xE5 // "end_c" unwind code #define UW_MAX_FRAGMENT_SIZE_BYTES (1U << 20) -#define UW_MAX_CODE_WORDS_COUNT 31 -#define UW_MAX_EPILOG_START_INDEX 0x3FFU +#define UW_MAX_CODE_WORDS_COUNT 31 +#define UW_MAX_EPILOG_START_INDEX 0x3FFU #elif defined(TARGET_LOONGARCH64) const unsigned MAX_PROLOG_SIZE_BYTES = 200; const unsigned MAX_EPILOG_SIZE_BYTES = 200; -#define UWC_END 0xE4 // "end" unwind code -#define UWC_END_C 0xE5 // "end_c" unwind code +#define UWC_END 0xE4 // "end" unwind code +#define UWC_END_C 0xE5 // "end_c" unwind code #define UW_MAX_FRAGMENT_SIZE_BYTES (1U << 20) -#define UW_MAX_CODE_WORDS_COUNT 31 -#define UW_MAX_EPILOG_START_INDEX 0x3FFU +#define UW_MAX_CODE_WORDS_COUNT 31 +#define UW_MAX_EPILOG_START_INDEX 0x3FFU #elif defined(TARGET_RISCV64) const unsigned MAX_PROLOG_SIZE_BYTES = 200; const unsigned MAX_EPILOG_SIZE_BYTES = 200; -#define UWC_END 0xE4 // "end" unwind code -#define UWC_END_C 0xE5 // "end_c" unwind code +#define UWC_END 0xE4 // "end" unwind code +#define UWC_END_C 0xE5 // "end_c" unwind code #define UW_MAX_FRAGMENT_SIZE_BYTES (1U << 20) -#define UW_MAX_CODE_WORDS_COUNT 31 -#define UW_MAX_EPILOG_START_INDEX 0x3FFU +#define UW_MAX_CODE_WORDS_COUNT 31 +#define UW_MAX_EPILOG_START_INDEX 0x3FFU #endif // TARGET_RISCV64 @@ -90,10 +90,17 @@ class UnwindInfo; class UnwindBase { protected: - UnwindBase(Compiler* comp) : uwiComp(comp) {} + UnwindBase(Compiler* comp) + : uwiComp(comp) + { + } - UnwindBase() {} - ~UnwindBase() {} + UnwindBase() + { + } + ~UnwindBase() + { + } Compiler* uwiComp; }; @@ -138,7 +145,9 @@ class UnwindCodesBase // information for a function, including unwind info header, the prolog codes, // and any epilog codes. -class UnwindPrologCodes : public UnwindBase, public UnwindCodesBase +class UnwindPrologCodes + : public UnwindBase + , public UnwindCodesBase { // UPC_LOCAL_COUNT is the amount of memory local to this class. For ARM CoreLib, the maximum size is 34. // Here is a histogram of other interesting sizes: @@ -251,8 +260,12 @@ class UnwindPrologCodes : public UnwindBase, public UnwindCodesBase // Copy the prolog codes from another prolog void CopyFrom(UnwindPrologCodes* pCopyFrom); - UnwindPrologCodes() {} - ~UnwindPrologCodes() {} + UnwindPrologCodes() + { + } + ~UnwindPrologCodes() + { + } #ifdef DEBUG void Dump(int indent = 0); @@ -298,7 +311,9 @@ class UnwindPrologCodes : public UnwindBase, public UnwindCodesBase // Epilog unwind codes arrive in the order they will be emitted. Store them as an array, // adding new ones to the end of the array. -class UnwindEpilogCodes : public UnwindBase, public UnwindCodesBase +class UnwindEpilogCodes + : public UnwindBase + , public UnwindCodesBase { // UEC_LOCAL_COUNT is the amount of memory local to this class. For ARM CoreLib, the maximum size is 6, // while 89% of epilogs fit in 4. So, set it to 4 to maintain array alignment and hit most cases. @@ -421,8 +436,12 @@ class UnwindEpilogCodes : public UnwindBase, public UnwindCodesBase #endif // !TARGET_RISCV64 } - UnwindEpilogCodes() {} - ~UnwindEpilogCodes() {} + UnwindEpilogCodes() + { + } + ~UnwindEpilogCodes() + { + } #ifdef DEBUG void Dump(int indent = 0); @@ -530,8 +549,12 @@ class UnwindEpilogInfo : public UnwindBase // Match the codes to a set of epilog codes int Match(UnwindEpilogInfo* pEpi); - UnwindEpilogInfo() {} - ~UnwindEpilogInfo() {} + UnwindEpilogInfo() + { + } + ~UnwindEpilogInfo() + { + } #ifdef DEBUG void Dump(int indent = 0); @@ -646,8 +669,12 @@ class UnwindFragmentInfo : public UnwindBase void Allocate( CorJitFuncKind funKind, void* pHotCode, void* pColdCode, UNATIVE_OFFSET funcEndOffset, bool isHotCode); - UnwindFragmentInfo() {} - ~UnwindFragmentInfo() {} + UnwindFragmentInfo() + { + } + ~UnwindFragmentInfo() + { + } #ifdef DEBUG void Dump(int indent = 0); @@ -776,8 +803,12 @@ class UnwindInfo : public UnwindBase void CaptureLocation(); - UnwindInfo() {} - ~UnwindInfo() {} + UnwindInfo() + { + } + ~UnwindInfo() + { + } #ifdef DEBUG @@ -786,7 +817,9 @@ class UnwindInfo : public UnwindBase // the last instruction added in the emitter. void CheckOpsize(BYTE b1); #elif defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) - void CheckOpsize(BYTE b1) {} // nothing to do; all instructions are 4 bytes + void CheckOpsize(BYTE b1) + { + } // nothing to do; all instructions are 4 bytes #endif // defined(TARGET_ARM64) void Dump(bool isHotCode, int indent = 0); diff --git a/src/coreclr/jit/unwindx86.cpp b/src/coreclr/jit/unwindx86.cpp index 1889c1f116f58e..32d077429af6a1 100644 --- a/src/coreclr/jit/unwindx86.cpp +++ b/src/coreclr/jit/unwindx86.cpp @@ -30,21 +30,37 @@ short Compiler::mapRegNumToDwarfReg(regNumber reg) } #endif // FEATURE_CFI_SUPPORT -void Compiler::unwindBegProlog() {} +void Compiler::unwindBegProlog() +{ +} -void Compiler::unwindEndProlog() {} +void Compiler::unwindEndProlog() +{ +} -void Compiler::unwindBegEpilog() {} +void Compiler::unwindBegEpilog() +{ +} -void Compiler::unwindEndEpilog() {} +void Compiler::unwindEndEpilog() +{ +} -void Compiler::unwindPush(regNumber reg) {} +void Compiler::unwindPush(regNumber reg) +{ +} -void Compiler::unwindAllocStack(unsigned size) {} +void Compiler::unwindAllocStack(unsigned size) +{ +} -void Compiler::unwindSetFrameReg(regNumber reg, unsigned offset) {} +void Compiler::unwindSetFrameReg(regNumber reg, unsigned offset) +{ +} -void Compiler::unwindSaveReg(regNumber reg, unsigned offset) {} +void Compiler::unwindSaveReg(regNumber reg, unsigned offset) +{ +} //------------------------------------------------------------------------ // Compiler::unwindReserve: Ask the VM to reserve space for the unwind information diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index 33d46bf1acd7c3..23b8d0000b800d 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -1107,7 +1107,8 @@ void Counter::dump(FILE* output) * Histogram class. */ -Histogram::Histogram(const unsigned* const sizeTable) : m_sizeTable(sizeTable) +Histogram::Histogram(const unsigned* const sizeTable) + : m_sizeTable(sizeTable) { unsigned sizeCount = 0; do @@ -1190,21 +1191,19 @@ void NodeCounts::dump(FILE* output) sorted[i].count = static_cast(m_counts[i]); } - jitstd::sort(sorted, sorted + ArrLen(sorted), - [](const Entry& lhs, const Entry& rhs) - { - if (lhs.count > rhs.count) - { - return true; - } + jitstd::sort(sorted, sorted + ArrLen(sorted), [](const Entry& lhs, const Entry& rhs) { + if (lhs.count > rhs.count) + { + return true; + } - if (lhs.count < rhs.count) - { - return false; - } + if (lhs.count < rhs.count) + { + return false; + } - return static_cast(lhs.oper) < static_cast(rhs.oper); - }); + return static_cast(lhs.oper) < static_cast(rhs.oper); + }); for (const Entry& entry : sorted) { @@ -1841,7 +1840,8 @@ void HelperCallProperties::init() // // You must use ';' as a separator; whitespace no longer works -AssemblyNamesList2::AssemblyNamesList2(const WCHAR* list, HostAllocator alloc) : m_alloc(alloc) +AssemblyNamesList2::AssemblyNamesList2(const WCHAR* list, HostAllocator alloc) + : m_alloc(alloc) { WCHAR prevChar = '?'; // dummy LPWSTR nameStart = nullptr; // start of the name currently being processed. nullptr if no current name @@ -1928,7 +1928,9 @@ bool AssemblyNamesList2::IsInList(const char* assemblyName) // MethodSet //============================================================================= -MethodSet::MethodSet(const WCHAR* filename, HostAllocator alloc) : m_pInfos(nullptr), m_alloc(alloc) +MethodSet::MethodSet(const WCHAR* filename, HostAllocator alloc) + : m_pInfos(nullptr) + , m_alloc(alloc) { FILE* methodSetFile = _wfopen(filename, W("r")); if (methodSetFile == nullptr) @@ -2157,7 +2159,10 @@ double CachedCyclesPerSecond() } #ifdef FEATURE_JIT_METHOD_PERF -CycleCount::CycleCount() : cps(CachedCyclesPerSecond()) {} +CycleCount::CycleCount() + : cps(CachedCyclesPerSecond()) +{ +} bool CycleCount::GetCycles(unsigned __int64* time) { diff --git a/src/coreclr/jit/utils.h b/src/coreclr/jit/utils.h index 17406cb6bfabe6..39001f32215ef5 100644 --- a/src/coreclr/jit/utils.h +++ b/src/coreclr/jit/utils.h @@ -88,7 +88,11 @@ class IteratorPair TIterator m_end; public: - IteratorPair(TIterator begin, TIterator end) : m_begin(begin), m_end(end) {} + IteratorPair(TIterator begin, TIterator end) + : m_begin(begin) + , m_end(end) + { + } inline TIterator begin() { @@ -114,7 +118,8 @@ struct ConstLog2 { enum { - value = ConstLog2::value + value = ConstLog2 < val / 2, + acc + 1 > ::value }; }; @@ -244,7 +249,11 @@ class ConfigMethodRange class ConfigIntArray { public: - ConfigIntArray() : m_values(nullptr), m_length(0) {} + ConfigIntArray() + : m_values(nullptr) + , m_length(0) + { + } // Ensure the string has been parsed. void EnsureInit(const WCHAR* str) @@ -276,7 +285,11 @@ class ConfigIntArray class ConfigDoubleArray { public: - ConfigDoubleArray() : m_values(nullptr), m_length(0) {} + ConfigDoubleArray() + : m_values(nullptr) + , m_length(0) + { + } // Ensure the string has been parsed. void EnsureInit(const WCHAR* str) @@ -398,7 +411,8 @@ template class ScopedSetVariable { public: - ScopedSetVariable(T* pVariable, T value) : m_pVariable(pVariable) + ScopedSetVariable(T* pVariable, T value) + : m_pVariable(pVariable) { m_oldValue = *m_pVariable; *m_pVariable = value; @@ -436,7 +450,8 @@ class PhasedVar public: PhasedVar() #ifdef DEBUG - : m_initialized(false), m_writePhase(true) + : m_initialized(false) + , m_writePhase(true) #endif // DEBUG { } @@ -698,7 +713,9 @@ class MethodSet MethodInfo* m_next; MethodInfo(char* methodName, int methodHash) - : m_MethodName(methodName), m_MethodHash(methodHash), m_next(nullptr) + : m_MethodName(methodName) + , m_MethodHash(methodHash) + , m_next(nullptr) { } }; @@ -1023,7 +1040,8 @@ class CritSecObject class CritSecHolder { public: - CritSecHolder(CritSecObject& critSec) : m_CritSec(critSec) + CritSecHolder(CritSecObject& critSec) + : m_CritSec(critSec) { ClrEnterCriticalSection(m_CritSec.Val()); } diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index a255e0cf146fba..889e0227e992d9 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -1647,7 +1647,11 @@ bool ValueNumStore::IsSharedStatic(ValueNum vn) } ValueNumStore::Chunk::Chunk(CompAllocator alloc, ValueNum* pNextBaseVN, var_types typ, ChunkExtraAttribs attribs) - : m_defs(nullptr), m_numUsed(0), m_baseVN(*pNextBaseVN), m_typ(typ), m_attribs(attribs) + : m_defs(nullptr) + , m_numUsed(0) + , m_baseVN(*pNextBaseVN) + , m_typ(typ) + , m_attribs(attribs) { // Allocate "m_defs" here, according to the typ/attribs pair. switch (attribs) @@ -3073,9 +3077,9 @@ ValueNum ValueNumStore::VNForMapSelectInner(ValueNumKind vnk, var_types type, Va FlowGraphNaturalLoop* loop = m_pComp->m_blockToLoop->GetLoop(m_pComp->compCurBB); if (loop != nullptr) { - memoryDependencies.ForEach( - [this](ValueNum vn) - { m_pComp->optRecordLoopMemoryDependence(m_pComp->compCurTree, m_pComp->compCurBB, vn); }); + memoryDependencies.ForEach([this](ValueNum vn) { + m_pComp->optRecordLoopMemoryDependence(m_pComp->compCurTree, m_pComp->compCurBB, vn); + }); } } @@ -3106,12 +3110,10 @@ void ValueNumStore::MapSelectWorkCacheEntry::SetMemoryDependencies(Compiler* com } size_t i = 0; - set.ForEach( - [&i, arr](ValueNum vn) - { - arr[i] = vn; - i++; - }); + set.ForEach([&i, arr](ValueNum vn) { + arr[i] = vn; + i++; + }); } //------------------------------------------------------------------------------ @@ -3452,8 +3454,9 @@ ValueNum ValueNumStore::VNForMapSelectWork(ValueNumKind vnk, GetMapSelectWorkCache()->Set(fstruct, entry); } - recMemoryDependencies.ForEach([this, &memoryDependencies](ValueNum vn) - { memoryDependencies.Add(m_pComp, vn); }); + recMemoryDependencies.ForEach([this, &memoryDependencies](ValueNum vn) { + memoryDependencies.Add(m_pComp, vn); + }); return sameSelResult; } @@ -3488,7 +3491,9 @@ ValueNum ValueNumStore::VNForMapSelectWork(ValueNumKind vnk, GetMapSelectWorkCache()->Set(fstruct, entry); } - recMemoryDependencies.ForEach([this, &memoryDependencies](ValueNum vn) { memoryDependencies.Add(m_pComp, vn); }); + recMemoryDependencies.ForEach([this, &memoryDependencies](ValueNum vn) { + memoryDependencies.Add(m_pComp, vn); + }); return entry.Result; } @@ -4821,8 +4826,7 @@ ValueNum ValueNumStore::EvalUsingMathIdentity(var_types typ, VNFunc func, ValueN // (0 + x) == x // (x + 0) == x // This identity does not apply for floating point (when x == -0.0). - auto identityForAddition = [=]() -> ValueNum - { + auto identityForAddition = [=]() -> ValueNum { if (!varTypeIsFloating(typ)) { ValueNum ZeroVN = VNZeroForType(typ); @@ -4842,8 +4846,7 @@ ValueNum ValueNumStore::EvalUsingMathIdentity(var_types typ, VNFunc func, ValueN // (x - 0) == x // (x - x) == 0 // This identity does not apply for floating point (when x == -0.0). - auto identityForSubtraction = [=](bool ovf) -> ValueNum - { + auto identityForSubtraction = [=](bool ovf) -> ValueNum { if (!varTypeIsFloating(typ)) { ValueNum ZeroVN = VNZeroForType(typ); @@ -4894,8 +4897,7 @@ ValueNum ValueNumStore::EvalUsingMathIdentity(var_types typ, VNFunc func, ValueN }; // These identities do not apply for floating point. - auto identityForMultiplication = [=]() -> ValueNum - { + auto identityForMultiplication = [=]() -> ValueNum { if (!varTypeIsFloating(typ)) { // (0 * x) == 0 @@ -5657,9 +5659,8 @@ void Compiler::fgValueNumberLocalStore(GenTree* storeNode, // Should not have been recorded as updating the GC heap. assert(!GetMemorySsaMap(GcHeap)->Lookup(storeNode)); - auto processDef = - [=](unsigned defLclNum, unsigned defSsaNum, ssize_t defOffset, unsigned defSize, ValueNumPair defValue) - { + auto processDef = [=](unsigned defLclNum, unsigned defSsaNum, ssize_t defOffset, unsigned defSize, + ValueNumPair defValue) { LclVarDsc* defVarDsc = lvaGetDesc(defLclNum); if (defSsaNum != SsaConfig::RESERVED_SSA_NUM) @@ -11157,8 +11158,7 @@ bool Compiler::fgValueNumberConstLoad(GenTreeIndir* tree) } // Is given VN representing a frozen object handle - auto isCnsObjHandle = [](ValueNumStore* vnStore, ValueNum vn, CORINFO_OBJECT_HANDLE* handle) -> bool - { + auto isCnsObjHandle = [](ValueNumStore* vnStore, ValueNum vn, CORINFO_OBJECT_HANDLE* handle) -> bool { if (vnStore->IsVNObjHandle(vn)) { *handle = vnStore->ConstantObjHandle(vn); @@ -12003,8 +12003,7 @@ void Compiler::fgValueNumberHWIntrinsic(GenTreeHWIntrinsic* tree) JITDUMP("\n"); } - auto getOperandVNs = [this, addr](GenTree* operand, ValueNumPair* pNormVNPair, ValueNumPair* pExcVNPair) - { + auto getOperandVNs = [this, addr](GenTree* operand, ValueNumPair* pNormVNPair, ValueNumPair* pExcVNPair) { vnStore->VNPUnpackExc(operand->gtVNPair, pNormVNPair, pExcVNPair); // If we have a load operation we will use the fgValueNumberByrefExposedLoad @@ -13749,17 +13748,14 @@ void Compiler::fgDebugCheckExceptionSets() assert(tree->gtVNPair.BothDefined() || tree->OperIs(GT_PHI_ARG)); ValueNumPair operandsExcSet = vnStore->VNPForEmptyExcSet(); - tree->VisitOperands( - [&](GenTree* operand) -> GenTree::VisitResult - { - CheckTree(operand, vnStore); + tree->VisitOperands([&](GenTree* operand) -> GenTree::VisitResult { + CheckTree(operand, vnStore); - ValueNumPair operandVNP = - operand->gtVNPair.BothDefined() ? operand->gtVNPair : vnStore->VNPForVoid(); - operandsExcSet = vnStore->VNPUnionExcSet(operandVNP, operandsExcSet); + ValueNumPair operandVNP = operand->gtVNPair.BothDefined() ? operand->gtVNPair : vnStore->VNPForVoid(); + operandsExcSet = vnStore->VNPUnionExcSet(operandVNP, operandsExcSet); - return GenTree::VisitResult::Continue; - }); + return GenTree::VisitResult::Continue; + }); // Currently, we fail to properly maintain the exception sets for trees with user calls. if ((tree->gtFlags & GTF_CALL) != 0) @@ -13941,7 +13937,11 @@ void Compiler::vnPrint(ValueNum vn, unsigned level) #endif // DEBUG // Methods of ValueNumPair. -ValueNumPair::ValueNumPair() : m_liberal(ValueNumStore::NoVN), m_conservative(ValueNumStore::NoVN) {} +ValueNumPair::ValueNumPair() + : m_liberal(ValueNumStore::NoVN) + , m_conservative(ValueNumStore::NoVN) +{ +} bool ValueNumPair::BothDefined() const { diff --git a/src/coreclr/jit/valuenum.h b/src/coreclr/jit/valuenum.h index 7f437496917cf7..1f9171e13cef21 100644 --- a/src/coreclr/jit/valuenum.h +++ b/src/coreclr/jit/valuenum.h @@ -238,7 +238,10 @@ class ValueNumStore class VNMap : public JitHashTable { public: - VNMap(CompAllocator alloc) : JitHashTable(alloc) {} + VNMap(CompAllocator alloc) + : JitHashTable(alloc) + { + } bool Set(fromType k, ValueNum val) { @@ -914,7 +917,12 @@ class ValueNumStore ValueNum vnIdx; ValueNum vnBound; - UnsignedCompareCheckedBoundInfo() : cmpOper(GT_NONE), vnIdx(NoVN), vnBound(NoVN) {} + UnsignedCompareCheckedBoundInfo() + : cmpOper(GT_NONE) + , vnIdx(NoVN) + , vnBound(NoVN) + { + } }; struct CompareCheckedBoundArithInfo @@ -926,7 +934,14 @@ class ValueNumStore ValueNum arrOp; unsigned cmpOper; ValueNum cmpOp; - CompareCheckedBoundArithInfo() : vnBound(NoVN), arrOper(GT_NONE), arrOp(NoVN), cmpOper(GT_NONE), cmpOp(NoVN) {} + CompareCheckedBoundArithInfo() + : vnBound(NoVN) + , arrOper(GT_NONE) + , arrOp(NoVN) + , cmpOper(GT_NONE) + , cmpOp(NoVN) + { + } #ifdef DEBUG void dump(ValueNumStore* vnStore) { @@ -952,7 +967,13 @@ class ValueNumStore ValueNum cmpOpVN; bool isUnsigned; - ConstantBoundInfo() : constVal(0), cmpOper(GT_NONE), cmpOpVN(NoVN), isUnsigned(false) {} + ConstantBoundInfo() + : constVal(0) + , cmpOper(GT_NONE) + , cmpOpVN(NoVN) + , isUnsigned(false) + { + } #ifdef DEBUG void dump(ValueNumStore* vnStore) @@ -1299,7 +1320,8 @@ class ValueNumStore VNFunc m_func; ValueNum m_args[NumArgs]; - VNDefFuncApp() : m_func(VNF_COUNT) + VNDefFuncApp() + : m_func(VNF_COUNT) { for (size_t i = 0; i < NumArgs; i++) { @@ -1308,7 +1330,9 @@ class ValueNumStore } template - VNDefFuncApp(VNFunc func, VNs... vns) : m_func(func), m_args{vns...} + VNDefFuncApp(VNFunc func, VNs... vns) + : m_func(func) + , m_args{vns...} { static_assert_no_msg(NumArgs == sizeof...(VNs)); } @@ -1479,7 +1503,11 @@ class ValueNumStore { ValueNum vn; ValueNumList* next; - ValueNumList(const ValueNum& v, ValueNumList* n = nullptr) : vn(v), next(n) {} + ValueNumList(const ValueNum& v, ValueNumList* n = nullptr) + : vn(v) + , next(n) + { + } }; // Keeps track of value numbers that are integer constants and also handles (GTG_ICON_HDL_MASK.) diff --git a/src/coreclr/jit/valuenumtype.h b/src/coreclr/jit/valuenumtype.h index 1b36d19fb9ca54..e41db972675434 100644 --- a/src/coreclr/jit/valuenumtype.h +++ b/src/coreclr/jit/valuenumtype.h @@ -115,7 +115,11 @@ struct ValueNumPair // Initializes both elements to "NoVN". Defined in ValueNum.cpp. ValueNumPair(); - ValueNumPair(ValueNum lib, ValueNum cons) : m_liberal(lib), m_conservative(cons) {} + ValueNumPair(ValueNum lib, ValueNum cons) + : m_liberal(lib) + , m_conservative(cons) + { + } // True iff neither element is "NoVN". Defined in ValueNum.cpp. bool BothDefined() const; From d780156ded2ae4ffccd8949aec1e94f4c279b08b Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 8 Apr 2024 16:11:24 -0700 Subject: [PATCH 18/47] Handle all the conditions correctly --- src/coreclr/jit/hwintrinsic.cpp | 11 +++ src/coreclr/jit/hwintrinsic.h | 10 ++- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 93 ++++++++++++--------- src/coreclr/jit/hwintrinsiclistarm64sve.h | 6 +- src/coreclr/jit/lowerarmarch.cpp | 88 ++++++++++++++++--- 5 files changed, 148 insertions(+), 60 deletions(-) diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index f0c35d0d056ac8..3224654382c3fb 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1606,6 +1606,17 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, } #if defined(TARGET_ARM64) + if (HWIntrinsicInfo::IsExplicitMaskedOperation(intrinsic)) + { + assert(numArgs > 0); + GenTree* op1 = retNode->AsHWIntrinsic()->Op(1); + if (!varTypeIsMask(op1)) + { + // Op1 input is a vector. HWInstrinsic requires a mask. + retNode->AsHWIntrinsic()->Op(1) = gtNewSimdConvertVectorToMaskNode(retType, op1, simdBaseJitType, simdSize); + } + } + if (retType != nodeRetType) { // HWInstrinsic returns a mask, but all returns must be vectors, so convert mask to vector. diff --git a/src/coreclr/jit/hwintrinsic.h b/src/coreclr/jit/hwintrinsic.h index b95f9fc85e946f..b3006755818007 100644 --- a/src/coreclr/jit/hwintrinsic.h +++ b/src/coreclr/jit/hwintrinsic.h @@ -186,7 +186,7 @@ enum HWIntrinsicFlag : unsigned int HW_Flag_ReturnsPerElementMask = 0x10000, // The intrinsic uses a mask in arg1 to select elements present in the result - HW_Flag_MaskedOperation = 0x20000, + HW_Flag_ExplicitMaskedOperation = 0x20000, // The intrinsic uses a mask in arg1 to select elements present in the result, and must use a low register. HW_Flag_LowMaskedOperation = 0x40000, @@ -875,7 +875,7 @@ struct HWIntrinsicInfo static bool IsMaskedOperation(NamedIntrinsic id) { const HWIntrinsicFlag flags = lookupFlags(id); - return ((flags & HW_Flag_MaskedOperation) != 0) || IsLowMaskedOperation(id) || IsEmbeddedMaskedOperation(id); + return IsLowMaskedOperation(id) || IsEmbeddedMaskedOperation(id) || IsExplicitMaskedOperation(id); } static bool IsLowMaskedOperation(NamedIntrinsic id) @@ -890,6 +890,12 @@ struct HWIntrinsicInfo return (flags & HW_Flag_EmbeddedMaskedOperation) != 0; } + static bool IsExplicitMaskedOperation(NamedIntrinsic id) + { + const HWIntrinsicFlag flags = lookupFlags(id); + return (flags & HW_Flag_ExplicitMaskedOperation) != 0; + } + #endif // TARGET_ARM64 static bool HasSpecialSideEffect(NamedIntrinsic id) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 816e41862d6277..de7e902677f6b2 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -404,63 +404,74 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) else if (intrin.numOperands >= 2 && intrin.op2->IsEmbMaskOp()) { // Handle case where op2 is operation that needs embedded mask - GenTree* op2 = intrin.op2; - const HWIntrinsic intrinOp2(op2->AsHWIntrinsic()); - instruction insOp2 = HWIntrinsicInfo::lookupIns(intrinOp2.id, intrinOp2.baseType); - + GenTree* op2 = intrin.op2; assert(intrin.id == NI_Sve_ConditionalSelect); assert(op2->isContained()); assert(op2->OperIsHWIntrinsic()); - // if (isRMW) - //{ - // op1Reg contains a mask, op2Reg contains the RMW register. + // Get the registers and intrinsics that needs embedded mask + const HWIntrinsic intrinOp2(op2->AsHWIntrinsic()); + instruction insOp2 = HWIntrinsicInfo::lookupIns(intrinOp2.id, intrinOp2.baseType); + const bool instrIsRMW = op2->isRMWHWIntrinsic(compiler); + + regNumber maskReg = op1Reg; + regNumber instrOp1Reg = REG_NA; + regNumber instrOp2Reg = REG_NA; + regNumber falseReg = op3Reg; - if (targetReg != op1Reg) + switch (intrinOp2.numOperands) { - assert(targetReg != op3Reg); - GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); + case 2: + assert(intrinOp2.op2 != nullptr); + instrOp2Reg = intrinOp2.op2->GetRegNum(); + FALLTHROUGH; + + case 1: + assert(intrinOp2.op1 != nullptr); + instrOp1Reg = intrinOp2.op1->GetRegNum(); + break; + + default: + unreached(); } - switch (intrin.numOperands) + switch (intrinOp2.numOperands) { - case 2: - GetEmitter()->emitIns_R_R(insOp2, emitSize, targetReg, op1Reg, opt); + case 1: + GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, maskReg, instrOp1Reg, opt); break; - case 3: - assert(targetReg != op3Reg); - GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, op1Reg, op3Reg, opt); + case 2: + + assert(instrIsRMW); + if (targetReg != falseReg) + { + assert(targetReg != instrOp1Reg); + assert(targetReg != instrOp2Reg); + + if (!intrin.op3->IsVectorZero()) + { + // If the `falseValue` of conditional-select is non-zero, then we start with that in the + // destination followed by `movprfx` (see below) of the relevant bits of the first operand + // of `insOp2` based upon the value of predicate `cond`. + GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, falseReg, + /* canSkip */ true); + } + } + + // Move the first operand of `insOp2` in the destination. If `falseValue` was zero, then we can just + // use /Z during the move, otherwise merge using /M into the destination. + GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, instrOp1Reg, opt, + intrin.op3->IsVectorZero() ? INS_SCALABLE_OPTS_NONE : INS_SCALABLE_OPTS_PREDICATE_MERGE); + + // Finally, perform the actual operation so that `targetReg` is the first operand and `instrOp2Reg` having + // the second operand. + GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, maskReg, instrOp2Reg, opt); break; default: unreached(); } - //} - // else - //{ - //// op1Reg contains the RMW register. - // if (targetReg != op1Reg) - //{ - // assert(targetReg != op2Reg); - // assert(targetReg != op3Reg); - // GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, op1Reg, /* canSkip */ true); - // } - - // switch (intrin.numOperands) - //{ - // case 2: - // GetEmitter()->emitIns_R_R(ins, emitSize, targetReg, op2Reg, opt); - // break; - - // case 3: - // GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op2Reg, op3Reg, opt); - // break; - - // default: - // unreached(); - //} - //} } else { diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index f5f304b546a109..b1f0bc07092867 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -18,9 +18,8 @@ // Sve HARDWARE_INTRINSIC(Sve, Abs, -1, -1, false, {INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_fabs, INS_sve_fabs}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation) - HARDWARE_INTRINSIC(Sve, Add, -1, -1, false, {INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_fadd, INS_sve_fadd}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation) - +HARDWARE_INTRINSIC(Sve, ConditionalSelect, -1, 3, true, {INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_SupportsContainment) HARDWARE_INTRINSIC(Sve, CreateTrueMaskByte, -1, 1, false, {INS_invalid, INS_sve_ptrue, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) HARDWARE_INTRINSIC(Sve, CreateTrueMaskDouble, -1, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_ptrue}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) HARDWARE_INTRINSIC(Sve, CreateTrueMaskInt16, -1, 1, false, {INS_invalid, INS_invalid, INS_sve_ptrue, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) @@ -43,8 +42,7 @@ HARDWARE_INTRINSIC(Sve, LoadVector, // Special intrinsics that are generated during importing or lowering 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, ConditionalSelect, -1, 3, true, {INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_MaskedOperation|HW_Flag_SupportsContainment) -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_MaskedOperation) +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) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 3adad8ba405dcb..ea319d97a1d5c7 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1208,6 +1208,54 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) LowerHWIntrinsicFusedMultiplyAddScalar(node); break; + case NI_Sve_ConditionalSelect: + { + GenTree* op1 = node->Op(1); + if (op1->OperIsHWIntrinsic(NI_Sve_ConvertVectorToMask)) + { + // For cases where conditional-select is used in the user code explicitly, + // select one of the true/false value, see if the `cond == 0` and if yes, + // just pick the `falseValue` and if `cond == 1`, pick the `trueValue` + // without having to do the condition. + + assert(varTypeIsMask(op1)); + + GenTreeHWIntrinsic* vectorToMask = op1->AsHWIntrinsic(); + GenTree* maskValue = vectorToMask->Op(2); + + GenTree* op2 = node->Op(2); + GenTree* op3 = node->Op(3); + GenTree* result = nullptr; + if (maskValue->IsVectorZero()) + { + result = op3; + } + else if (maskValue->IsVectorAllBitsSet()) + { + result = op2; + } + + if (result != nullptr) + { + result = comp->gtCloneExpr(result); + + LIR::Use use; + if (BlockRange().TryGetUse(node, &use)) + { + BlockRange().InsertBefore(node, result); + use.ReplaceWith(result); + } + else + { + result->SetUnusedValue(); + } + BlockRange().Remove(node, true); + return result; + } + } + break; + } + case NI_Sve_Abs: { assert(HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsicId)); @@ -1216,15 +1264,15 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) unsigned simdSize = node->GetSimdSize(); var_types simdType = Compiler::getSIMDTypeForSize(simdSize); - GenTree* trueMaskAllNode = comp->gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); - GenTree* trueVal = node; - GenTree* falseVal = comp->gtNewZeroConNode(simdType); + GenTree* trueMask = comp->gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); + GenTree* trueVal = node; + GenTree* falseVal = comp->gtNewZeroConNode(simdType); GenTreeHWIntrinsic* condSelNode = - comp->gtNewSimdHWIntrinsicNode(simdType, trueMaskAllNode, trueVal, falseVal, NI_Sve_ConditionalSelect, - simdBaseJitType, simdSize); + comp->gtNewSimdHWIntrinsicNode(simdType, trueMask, trueVal, falseVal, + NI_Sve_ConditionalSelect, simdBaseJitType, simdSize); - BlockRange().InsertBefore(node, trueMaskAllNode); + BlockRange().InsertBefore(node, trueMask); BlockRange().InsertBefore(node, falseVal); LIR::Use use; @@ -1237,6 +1285,7 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) { condSelNode->SetUnusedValue(); } + break; } @@ -3244,6 +3293,17 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) assert(intrin.numOperands == 3); GenTree* op1 = intrin.op1; GenTree* op2 = intrin.op2; + GenTree* op3 = intrin.op3; + + // Handle op1 + if (op1->IsVectorZero()) + { + // When we are merging with zero, we can specialize + // and avoid instantiating the vector constant. + MakeSrcContained(node, op1); + } + + // Handle op2 if (op2->OperIsHWIntrinsic()) { uint32_t maskSize = genTypeSize(node->GetSimdBaseType()); @@ -3253,15 +3313,17 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) { MakeSrcContained(node, op2); op2->MakeEmbMaskOp(); - - if (op1->IsVectorZero()) - { - // When we are merging with zero, we can specialize - // and avoid instantiating the vector constant. - MakeSrcContained(node, op1); - } } } + + // Handle op3 + if (op3->IsVectorZero()) + { + // When we are merging with zero, we can specialize + // and avoid instantiating the vector constant. + MakeSrcContained(node, op3); + } + break; } From eb4d1dce58914bc7168ad2a41c90c78a1c807b85 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 8 Apr 2024 17:13:47 -0700 Subject: [PATCH 19/47] jit format --- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 15 ++++++++------- src/coreclr/jit/lowerarmarch.cpp | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index de7e902677f6b2..488632b42b153a 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -414,10 +414,10 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) instruction insOp2 = HWIntrinsicInfo::lookupIns(intrinOp2.id, intrinOp2.baseType); const bool instrIsRMW = op2->isRMWHWIntrinsic(compiler); - regNumber maskReg = op1Reg; - regNumber instrOp1Reg = REG_NA; - regNumber instrOp2Reg = REG_NA; - regNumber falseReg = op3Reg; + regNumber maskReg = op1Reg; + regNumber instrOp1Reg = REG_NA; + regNumber instrOp2Reg = REG_NA; + regNumber falseReg = op3Reg; switch (intrinOp2.numOperands) { @@ -462,10 +462,11 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) // Move the first operand of `insOp2` in the destination. If `falseValue` was zero, then we can just // use /Z during the move, otherwise merge using /M into the destination. GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, instrOp1Reg, opt, - intrin.op3->IsVectorZero() ? INS_SCALABLE_OPTS_NONE : INS_SCALABLE_OPTS_PREDICATE_MERGE); + intrin.op3->IsVectorZero() ? INS_SCALABLE_OPTS_NONE + : INS_SCALABLE_OPTS_PREDICATE_MERGE); - // Finally, perform the actual operation so that `targetReg` is the first operand and `instrOp2Reg` having - // the second operand. + // Finally, perform the actual operation so that `targetReg` is the first operand and `instrOp2Reg` + // having the second operand. GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, maskReg, instrOp2Reg, opt); break; diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index ea319d97a1d5c7..61c0c589d02236 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1210,7 +1210,7 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) case NI_Sve_ConditionalSelect: { - GenTree* op1 = node->Op(1); + GenTree* op1 = node->Op(1); if (op1->OperIsHWIntrinsic(NI_Sve_ConvertVectorToMask)) { // For cases where conditional-select is used in the user code explicitly, @@ -1269,8 +1269,8 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) GenTree* falseVal = comp->gtNewZeroConNode(simdType); GenTreeHWIntrinsic* condSelNode = - comp->gtNewSimdHWIntrinsicNode(simdType, trueMask, trueVal, falseVal, - NI_Sve_ConditionalSelect, simdBaseJitType, simdSize); + comp->gtNewSimdHWIntrinsicNode(simdType, trueMask, trueVal, falseVal, NI_Sve_ConditionalSelect, + simdBaseJitType, simdSize); BlockRange().InsertBefore(node, trueMask); BlockRange().InsertBefore(node, falseVal); From 00aacabbc2d4b80b4a01be90c4ea1a4309aa0a36 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Tue, 9 Apr 2024 08:53:34 -0700 Subject: [PATCH 20/47] fix some spacing --- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 2 +- src/coreclr/jit/hwintrinsiclistarm64sve.h | 2 +- .../src/System/Runtime/Intrinsics/Arm/Sve.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 488632b42b153a..b7bcffaa1b9558 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -495,7 +495,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) else if (HWIntrinsicInfo::IsScalable(intrin.id)) { assert(!node->IsEmbMaskOp()); - // This generates unpredicated version + // This generates an unpredicated version // Predicated should be taken care above `intrin.op2->IsEmbMaskOp()` GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, opt, INS_SCALABLE_OPTS_UNPREDICATED); diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index b1f0bc07092867..7e7c647a9f279a 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -41,9 +41,9 @@ HARDWARE_INTRINSIC(Sve, LoadVector, // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** // Special intrinsics that are generated during importing or lowering -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, 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) #endif // FEATURE_HW_INTRINSIC 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 f15835fafe3335..a13957916f49a7 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 @@ -75,7 +75,7 @@ internal Arm64() { } /// ABS Ztied.D, Pg/M, Ztied.D /// MOVPRFX Zresult, Zop; ABS Zresult.D, Pg/M, Zop.D /// svint64_t svabs[_s64]_z(svbool_t pg, svint64_t op) - /// MOVPRFX Zresult.D, Pg/Z, Zop.D; ABS Zresult.D, Pg/M, Zop.D + /// MOVPRFX Zresult.D, Pg/Z, Zop.D; ABS Zresult.D, Pg/M, Zop.D /// public static unsafe Vector Abs(Vector value) => Abs(value); From f716958fa7cfc03988426a5ac28c93311e8421e5 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Tue, 9 Apr 2024 09:21:51 -0700 Subject: [PATCH 21/47] Removed the assert --- src/coreclr/jit/hwintrinsic.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index 3224654382c3fb..3d59986fe544ea 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1410,7 +1410,6 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, op3 = getArgForHWIntrinsic(sigReader.GetOp3Type(), sigReader.op3ClsHnd); op2 = getArgForHWIntrinsic(sigReader.GetOp2Type(), sigReader.op2ClsHnd); op1 = getArgForHWIntrinsic(sigReader.GetOp1Type(), sigReader.op1ClsHnd); - assert(addRangeCheckIfNeeded(intrinsic, op3, mustExpand, immLowerBound, immUpperBound) == op3); break; case 2: From 5eadcf9c0e76bfc8bf6d182266ed03f36fd9a6dd Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Tue, 9 Apr 2024 15:07:01 -0700 Subject: [PATCH 22/47] fix the largest vector size to 64 to fix #100366 --- .../GenerateHWIntrinsicTests_Arm.cs | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index 1f50f6dee2fea2..02f88ced05bb68 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -2889,45 +2889,45 @@ (string templateFileName, Dictionary templateData)[] SveInputs = new [] { - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(sbyte)-TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)-TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(long)Helpers.Abs(firstOp[i]) != (long)result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(sbyte)-TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(short)-TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(long)Helpers.Abs(firstOp[i]) != (long)result[i]"}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(sbyte)TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(short)TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "(byte)TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(sbyte)TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(short)TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(byte)TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_sbyte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_short", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_int", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_long", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_byte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ushort", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_uint", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), - ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ulong", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_sbyte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_short", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_int", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_long", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_byte", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ushort", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_uint", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), + ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_ulong", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), }; From bc6e58d7d5f2010e280461eb567b7ef65949c487 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Wed, 10 Apr 2024 22:38:54 -0700 Subject: [PATCH 23/47] review feedback --- src/coreclr/jit/gentree.cpp | 17 +++++++---------- src/coreclr/jit/gentree.h | 4 ++-- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 6 +++++- src/coreclr/jit/lowerxarch.cpp | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 046a3679ffc373..0ff4acc0c211bb 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -18008,11 +18008,7 @@ bool GenTree::canBeContained() const } else if (OperIsHWIntrinsic() && !isContainableHWIntrinsic()) { -#ifdef TARGET_XARCH - return isEvexEmbeddedMaskingCompatibleHWIntrinsic(); -#elif TARGET_ARM64 - return HWIntrinsicInfo::IsEmbeddedMaskedOperation(AsHWIntrinsic()->GetHWIntrinsicId()); -#endif + return isEmbeddedMaskingCompatibleHWIntrinsic(); } return true; @@ -19909,24 +19905,25 @@ bool GenTree::isEvexCompatibleHWIntrinsic() const } //------------------------------------------------------------------------ -// isEvexEmbeddedMaskingCompatibleHWIntrinsic: Checks if the intrinsic is compatible +// isEmbeddedMaskingCompatibleHWIntrinsic : Checks if the intrinsic is compatible // with the EVEX embedded masking form for its intended lowering instruction. // // Return Value: // true if the intrisic node lowering instruction has an EVEX embedded masking // -bool GenTree::isEvexEmbeddedMaskingCompatibleHWIntrinsic() const +bool GenTree::isEmbeddedMaskingCompatibleHWIntrinsic() const { -#if defined(TARGET_XARCH) if (OperIsHWIntrinsic()) { +#if defined(TARGET_XARCH) // TODO-AVX512F-CQ: Expand this to the full set of APIs and make it table driven // using IsEmbMaskingCompatible. For now, however, limit it to some explicit ids // for prototyping purposes. return (AsHWIntrinsic()->GetHWIntrinsicId() == NI_AVX512F_Add); +#elif defined(TARGET_ARM64) + return HWIntrinsicInfo::IsEmbeddedMaskedOperation(AsHWIntrinsic()->GetHWIntrinsicId()); +#endif } -#endif // TARGET_XARCH - return false; } diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 849f2a142ef866..f5a15ca8537fd8 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -1465,7 +1465,7 @@ struct GenTree bool isContainableHWIntrinsic() const; bool isRMWHWIntrinsic(Compiler* comp); bool isEvexCompatibleHWIntrinsic() const; - bool isEvexEmbeddedMaskingCompatibleHWIntrinsic() const; + bool isEmbeddedMaskingCompatibleHWIntrinsic() const; #else bool isCommutativeHWIntrinsic() const { @@ -1487,7 +1487,7 @@ struct GenTree return false; } - bool isEvexEmbeddedMaskingCompatibleHWIntrinsic() const + bool isEmbeddedMaskingCompatibleHWIntrinsic() const { return false; } diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index b7bcffaa1b9558..f7bddb229ddc87 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -438,6 +438,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) switch (intrinOp2.numOperands) { case 1: + assert(!instrIsRMW); GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, maskReg, instrOp1Reg, opt); break; @@ -449,11 +450,14 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) assert(targetReg != instrOp1Reg); assert(targetReg != instrOp2Reg); - if (!intrin.op3->IsVectorZero()) + if (!intrin.op3->IsVectorZero() && (instrOp1Reg != falseReg)) { // If the `falseValue` of conditional-select is non-zero, then we start with that in the // destination followed by `movprfx` (see below) of the relevant bits of the first operand // of `insOp2` based upon the value of predicate `cond`. + + // Also, if `instrOp1Reg == falseReg`, we will move the `instrOp1Reg` using `movprfx` and + // so, no need to move it separately here. GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, falseReg, /* canSkip */ true); } diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index d3b4f49534bbb9..0e18c5685066fc 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -10137,7 +10137,7 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) // contained and not a memory operand and know to invoke the special handling // so that the embedded masking can work as expected. - if (op2->isEvexEmbeddedMaskingCompatibleHWIntrinsic()) + if (op2->isEmbeddedMaskingCompatibleHWIntrinsic()) { uint32_t maskSize = genTypeSize(simdBaseType); uint32_t operSize = genTypeSize(op2->AsHWIntrinsic()->GetSimdBaseType()); From 19ec4b6a93e1d9c62ee8db9ae71096912339b70e Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Apr 2024 12:36:31 -0700 Subject: [PATCH 24/47] wip --- src/coreclr/jit/lowerarmarch.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 61c0c589d02236..9609d73f9463e2 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1253,6 +1253,12 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) return result; } } + + JITDUMP("after\n"); + if (comp->verbose) + { + comp->fgDumpBlock(m_block); + } break; } From ed7c781be36f68c95b2acfcaefb88facea954015 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Apr 2024 13:34:37 -0700 Subject: [PATCH 25/47] Add SVE feature detection for Windows --- src/native/minipal/cpufeatures.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/native/minipal/cpufeatures.c b/src/native/minipal/cpufeatures.c index 89b30724aafd10..c06d40000f0db7 100644 --- a/src/native/minipal/cpufeatures.c +++ b/src/native/minipal/cpufeatures.c @@ -65,6 +65,10 @@ static uint32_t xmmYmmStateSupport() #define XSTATE_MASK_AVX512 (0xE0) /* 0b1110_0000 */ #endif // XSTATE_MASK_AVX512 +#ifndef PF_ARM_SVE_INSTRUCTIONS_AVAILABLE +#define PF_ARM_SVE_INSTRUCTIONS_AVAILABLE (46) +#endif + static uint32_t avx512StateSupport() { #if defined(HOST_APPLE) @@ -458,6 +462,11 @@ int minipal_getcpufeatures(void) // TODO: IsProcessorFeaturePresent doesn't support LRCPC2 yet. + if (IsProcessorFeaturePresent(PF_ARM_SVE_INSTRUCTIONS_AVAILABLE)) + { + result |= ARM64IntrinsicConstants_Sve; + } + #endif // HOST_WINDOWS #endif // HOST_ARM64 From f966b5e4e293e21095ac59d5f2592a9471ce18b2 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Apr 2024 14:50:54 -0700 Subject: [PATCH 26/47] fix the check for invalid alignment --- .../Arm/Shared/SveConditionalSelect.template | 4 ++-- .../Arm/Shared/SveLoadMaskedUnOpTest.template | 4 ++-- .../Arm/Shared/_SveBinaryOpTestTemplate.template | 4 ++-- .../Arm/Shared/_SveUnaryOpTestTemplate.template | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveConditionalSelect.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveConditionalSelect.template index 6a4ccfe3aa6064..963fa1713eec3b 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveConditionalSelect.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveConditionalSelect.template @@ -86,9 +86,9 @@ namespace JIT.HardwareIntrinsics.Arm int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<{Op2BaseType}>(); int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<{Op3BaseType}>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); - if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray) + if ((alignment != 64 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray) { - throw new ArgumentException("Invalid value of alignment"); + throw new ArgumentException($"Invalid value of alignment: {alignment}, sizeOfinArray1: {sizeOfinArray1}, sizeOfinArray2: {sizeOfinArray2}, sizeOfinArray3: {sizeOfinArray3}, sizeOfoutArray: {sizeOfoutArray}"); } this.inArray1 = new byte[alignment * 2]; diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveLoadMaskedUnOpTest.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveLoadMaskedUnOpTest.template index 09aaf2f442e136..d5a62e5cda1cf6 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveLoadMaskedUnOpTest.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveLoadMaskedUnOpTest.template @@ -64,9 +64,9 @@ namespace JIT.HardwareIntrinsics.Arm { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op2BaseType}>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); - if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray) + if ((alignment != 64 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray) { - throw new ArgumentException("Invalid value of alignment"); + throw new ArgumentException($"Invalid value of alignment: {alignment}, sizeOfinArray1: {sizeOfinArray1}, sizeOfoutArray: {sizeOfoutArray}"); } this.inArray1 = new byte[alignment * 2]; diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template index 48b124734ef946..c937e06494215d 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template @@ -83,9 +83,9 @@ namespace JIT.HardwareIntrinsics.Arm int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<{Op2BaseType}>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); - if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) + if ((alignment != 64 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { - throw new ArgumentException("Invalid value of alignment"); + throw new ArgumentException($"Invalid value of alignment: {alignment}, sizeOfinArray1: {sizeOfinArray1}, sizeOfinArray2: {sizeOfinArray2}, sizeOfoutArray: {sizeOfoutArray}"); } this.inArray1 = new byte[alignment * 2]; diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template index eb3dd48b9dfcf4..2a9f42a147b2ac 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template @@ -80,9 +80,9 @@ namespace JIT.HardwareIntrinsics.Arm { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<{Op1BaseType}>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<{RetBaseType}>(); - if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray) + if ((alignment != 64 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray) { - throw new ArgumentException("Invalid value of alignment"); + throw new ArgumentException($"Invalid value of alignment: {alignment}, sizeOfinArray1: {sizeOfinArray1}, sizeOfoutArray: {sizeOfoutArray}"); } this.inArray1 = new byte[alignment * 2]; From f0c81f1b89feb28085d8b19a843c3f2302568312 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Apr 2024 14:51:02 -0700 Subject: [PATCH 27/47] Revert "Add SVE feature detection for Windows" This reverts commit ed7c781be36f68c95b2acfcaefb88facea954015. --- src/native/minipal/cpufeatures.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/native/minipal/cpufeatures.c b/src/native/minipal/cpufeatures.c index c06d40000f0db7..89b30724aafd10 100644 --- a/src/native/minipal/cpufeatures.c +++ b/src/native/minipal/cpufeatures.c @@ -65,10 +65,6 @@ static uint32_t xmmYmmStateSupport() #define XSTATE_MASK_AVX512 (0xE0) /* 0b1110_0000 */ #endif // XSTATE_MASK_AVX512 -#ifndef PF_ARM_SVE_INSTRUCTIONS_AVAILABLE -#define PF_ARM_SVE_INSTRUCTIONS_AVAILABLE (46) -#endif - static uint32_t avx512StateSupport() { #if defined(HOST_APPLE) @@ -462,11 +458,6 @@ int minipal_getcpufeatures(void) // TODO: IsProcessorFeaturePresent doesn't support LRCPC2 yet. - if (IsProcessorFeaturePresent(PF_ARM_SVE_INSTRUCTIONS_AVAILABLE)) - { - result |= ARM64IntrinsicConstants_Sve; - } - #endif // HOST_WINDOWS #endif // HOST_ARM64 From 89ede7da905d372e19424f565ebc4d355a7845b6 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Apr 2024 15:16:23 -0700 Subject: [PATCH 28/47] Handle case where Abs() is wrapped in another conditionalSelect --- src/coreclr/jit/lowerarmarch.cpp | 37 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 9609d73f9463e2..5f8f35d5fce7ba 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1253,23 +1253,31 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) return result; } } - - JITDUMP("after\n"); - if (comp->verbose) - { - comp->fgDumpBlock(m_block); - } break; } case NI_Sve_Abs: { assert(HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsicId)); + + LIR::Use use; + if (BlockRange().TryGetUse(node, &use)) + { + GenTree* user = use.User(); + if (user->OperIsHWIntrinsic() && user->AsHWIntrinsic()->GetHWIntrinsicId() == NI_Sve_ConditionalSelect) + { + // No need to wrap it if it is already inside a conditional + break; + } + } + else + { + break; + } + CorInfoType simdBaseJitType = node->GetSimdBaseJitType(); - var_types simdBaseType = node->GetSimdBaseType(); unsigned simdSize = node->GetSimdSize(); var_types simdType = Compiler::getSIMDTypeForSize(simdSize); - GenTree* trueMask = comp->gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); GenTree* trueVal = node; GenTree* falseVal = comp->gtNewZeroConNode(simdType); @@ -1280,17 +1288,8 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) BlockRange().InsertBefore(node, trueMask); BlockRange().InsertBefore(node, falseVal); - - LIR::Use use; - if (BlockRange().TryGetUse(node, &use)) - { - BlockRange().InsertAfter(node, condSelNode); - use.ReplaceWith(condSelNode); - } - else - { - condSelNode->SetUnusedValue(); - } + BlockRange().InsertAfter(node, condSelNode); + use.ReplaceWith(condSelNode); break; } From 1f44b2fd8dccbd381bf25c53b4da3450f4f06694 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Apr 2024 22:43:23 -0700 Subject: [PATCH 29/47] jit format --- src/coreclr/jit/lowerarmarch.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 5f8f35d5fce7ba..edbb6f1ace5487 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1278,9 +1278,9 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) CorInfoType simdBaseJitType = node->GetSimdBaseJitType(); unsigned simdSize = node->GetSimdSize(); var_types simdType = Compiler::getSIMDTypeForSize(simdSize); - GenTree* trueMask = comp->gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); - GenTree* trueVal = node; - GenTree* falseVal = comp->gtNewZeroConNode(simdType); + GenTree* trueMask = comp->gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); + GenTree* trueVal = node; + GenTree* falseVal = comp->gtNewZeroConNode(simdType); GenTreeHWIntrinsic* condSelNode = comp->gtNewSimdHWIntrinsicNode(simdType, trueMask, trueVal, falseVal, NI_Sve_ConditionalSelect, From 9712a16f5de529cd7f29cedfa3692e3a3567ae6e Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Apr 2024 22:45:28 -0700 Subject: [PATCH 30/47] fix the size comparison --- src/coreclr/jit/lsrabuild.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/lsrabuild.cpp b/src/coreclr/jit/lsrabuild.cpp index 3673a5ab831843..82be06514a8f1a 100644 --- a/src/coreclr/jit/lsrabuild.cpp +++ b/src/coreclr/jit/lsrabuild.cpp @@ -3427,7 +3427,7 @@ int LinearScan::BuildOperandUses(GenTree* node, regMaskTP candidates) #ifdef TARGET_ARM64 if (HWIntrinsicInfo::IsScalable(hwintrinsic->GetHWIntrinsicId())) { - for (int argNum = 1; argNum <= numArgs; argNum++) + for (size_t argNum = 1; argNum <= numArgs; argNum++) { BuildOperandUses(hwintrinsic->Op(argNum), candidates); } From 0ad2e64163cb6c6e902ae7f53a9f9a122cfde244 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Apr 2024 22:58:15 -0700 Subject: [PATCH 31/47] HW_Flag_MaskedPredicatedOnlyOperation --- src/coreclr/jit/hwintrinsic.h | 10 ++++ src/coreclr/jit/hwintrinsiclistarm64sve.h | 2 +- src/coreclr/jit/lowerarmarch.cpp | 64 ++++++++++------------- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/coreclr/jit/hwintrinsic.h b/src/coreclr/jit/hwintrinsic.h index b3006755818007..fd50886858832d 100644 --- a/src/coreclr/jit/hwintrinsic.h +++ b/src/coreclr/jit/hwintrinsic.h @@ -194,6 +194,10 @@ enum HWIntrinsicFlag : unsigned int // The intrinsic uses a mask in arg1 to select elements present in the result, which is not present in the API call HW_Flag_EmbeddedMaskedOperation = 0x80000, + // The intrinsic uses a mask in arg1 to select elements present in the result, which is not present in the API call + // and only has predicated version of the instruction + HW_Flag_MaskedPredicatedOnlyOperation = 0x100000, + #else #error Unsupported platform #endif @@ -890,6 +894,12 @@ struct HWIntrinsicInfo return (flags & HW_Flag_EmbeddedMaskedOperation) != 0; } + static bool IsMaskedPredicatedOnlyOperation(NamedIntrinsic id) + { + const HWIntrinsicFlag flags = lookupFlags(id); + return (flags & HW_Flag_MaskedPredicatedOnlyOperation) != 0; + } + static bool IsExplicitMaskedOperation(NamedIntrinsic id) { const HWIntrinsicFlag flags = lookupFlags(id); diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index 7e7c647a9f279a..cd85d40e47dc6a 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -17,7 +17,7 @@ // SVE Intrinsics // Sve -HARDWARE_INTRINSIC(Sve, Abs, -1, -1, false, {INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_fabs, INS_sve_fabs}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation) +HARDWARE_INTRINSIC(Sve, Abs, -1, -1, false, {INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_fabs, INS_sve_fabs}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_MaskedPredicatedOnlyOperation) HARDWARE_INTRINSIC(Sve, Add, -1, -1, false, {INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_fadd, INS_sve_fadd}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation) HARDWARE_INTRINSIC(Sve, ConditionalSelect, -1, 3, true, {INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_SupportsContainment) HARDWARE_INTRINSIC(Sve, CreateTrueMaskByte, -1, 1, false, {INS_invalid, INS_sve_ptrue, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index edbb6f1ace5487..e4bfa190911b4f 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1256,46 +1256,38 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) break; } - case NI_Sve_Abs: - { - assert(HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsicId)); + default: + break; + } - LIR::Use use; - if (BlockRange().TryGetUse(node, &use)) - { - GenTree* user = use.User(); - if (user->OperIsHWIntrinsic() && user->AsHWIntrinsic()->GetHWIntrinsicId() == NI_Sve_ConditionalSelect) - { - // No need to wrap it if it is already inside a conditional - break; - } - } - else + if (HWIntrinsicInfo::IsMaskedPredicatedOnlyOperation(intrinsicId)) + { + assert(HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsicId)); + + LIR::Use use; + if (BlockRange().TryGetUse(node, &use)) + { + GenTree* user = use.User(); + // Wrap the intrinsic in ConditionalSelect only if it is not already inside another ConditionalSelect + if (user->OperIsHWIntrinsic() && user->AsHWIntrinsic()->GetHWIntrinsicId() != NI_Sve_ConditionalSelect) { - break; + CorInfoType simdBaseJitType = node->GetSimdBaseJitType(); + unsigned simdSize = node->GetSimdSize(); + var_types simdType = Compiler::getSIMDTypeForSize(simdSize); + GenTree* trueMask = comp->gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); + GenTree* trueVal = node; + GenTree* falseVal = comp->gtNewZeroConNode(simdType); + + GenTreeHWIntrinsic* condSelNode = + comp->gtNewSimdHWIntrinsicNode(simdType, trueMask, trueVal, falseVal, NI_Sve_ConditionalSelect, + simdBaseJitType, simdSize); + + BlockRange().InsertBefore(node, trueMask); + BlockRange().InsertBefore(node, falseVal); + BlockRange().InsertAfter(node, condSelNode); + use.ReplaceWith(condSelNode); } - - CorInfoType simdBaseJitType = node->GetSimdBaseJitType(); - unsigned simdSize = node->GetSimdSize(); - var_types simdType = Compiler::getSIMDTypeForSize(simdSize); - GenTree* trueMask = comp->gtNewSimdAllTrueMaskNode(simdBaseJitType, simdSize); - GenTree* trueVal = node; - GenTree* falseVal = comp->gtNewZeroConNode(simdType); - - GenTreeHWIntrinsic* condSelNode = - comp->gtNewSimdHWIntrinsicNode(simdType, trueMask, trueVal, falseVal, NI_Sve_ConditionalSelect, - simdBaseJitType, simdSize); - - BlockRange().InsertBefore(node, trueMask); - BlockRange().InsertBefore(node, falseVal); - BlockRange().InsertAfter(node, condSelNode); - use.ReplaceWith(condSelNode); - - break; } - - default: - break; } ContainCheckHWIntrinsic(node); From f76e324fa2ad1ce76b03ffbba215b8630eea4186 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Fri, 12 Apr 2024 11:54:47 -0700 Subject: [PATCH 32/47] Revert the change in emitarm64.cpp around INS_sve_ldr_mask/INS_sve_str_mask --- src/coreclr/jit/emitarm64.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index 8c1352990fb765..181b9706e41611 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -7875,7 +7875,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va // TODO-SVE: Don't assume 128bit vectors // Predicate size is vector length / 8 - scale = 2; + scale = NaturalScale_helper(EA_2BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) @@ -8154,7 +8154,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va // TODO-SVE: Don't assume 128bit vectors // Predicate size is vector length / 8 - scale = 2; + scale = NaturalScale_helper(EA_2BYTE); ssize_t mask = (1 << scale) - 1; // the mask of low bits that must be zero to encode the immediate if (((imm & mask) == 0) && (isValidSimm<9>(imm >> scale))) From 8af710838a1611dd55d45df7a5bb18ec0a7200b7 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Sun, 14 Apr 2024 08:06:39 -0700 Subject: [PATCH 33/47] Fix the condition for lowering --- src/coreclr/jit/lowerarmarch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index e4bfa190911b4f..02d66a15aa4bdf 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1269,7 +1269,7 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) { GenTree* user = use.User(); // Wrap the intrinsic in ConditionalSelect only if it is not already inside another ConditionalSelect - if (user->OperIsHWIntrinsic() && user->AsHWIntrinsic()->GetHWIntrinsicId() != NI_Sve_ConditionalSelect) + if (!user->OperIsHWIntrinsic() || (user->AsHWIntrinsic()->GetHWIntrinsicId() != NI_Sve_ConditionalSelect)) { CorInfoType simdBaseJitType = node->GetSimdBaseJitType(); unsigned simdSize = node->GetSimdSize(); From e934e26d0c71098abfe5929d23d4cd50e9deb7b5 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 12:53:22 -0700 Subject: [PATCH 34/47] address review feedback for movprfx --- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 89 ++++++++++++++------- 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index f7bddb229ddc87..cfdc6bf7d78cc2 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -410,68 +410,97 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) assert(op2->OperIsHWIntrinsic()); // Get the registers and intrinsics that needs embedded mask - const HWIntrinsic intrinOp2(op2->AsHWIntrinsic()); - instruction insOp2 = HWIntrinsicInfo::lookupIns(intrinOp2.id, intrinOp2.baseType); + const HWIntrinsic intrinEmbMask(op2->AsHWIntrinsic()); + instruction insEmbMask = HWIntrinsicInfo::lookupIns(intrinEmbMask.id, intrinEmbMask.baseType); const bool instrIsRMW = op2->isRMWHWIntrinsic(compiler); regNumber maskReg = op1Reg; - regNumber instrOp1Reg = REG_NA; - regNumber instrOp2Reg = REG_NA; + regNumber embMaskOp1Reg = REG_NA; + regNumber embMaskOp2Reg = REG_NA; regNumber falseReg = op3Reg; - switch (intrinOp2.numOperands) + switch (intrinEmbMask.numOperands) { case 2: - assert(intrinOp2.op2 != nullptr); - instrOp2Reg = intrinOp2.op2->GetRegNum(); + assert(intrinEmbMask.op2 != nullptr); + embMaskOp2Reg = intrinEmbMask.op2->GetRegNum(); FALLTHROUGH; case 1: - assert(intrinOp2.op1 != nullptr); - instrOp1Reg = intrinOp2.op1->GetRegNum(); + assert(intrinEmbMask.op1 != nullptr); + embMaskOp1Reg = intrinEmbMask.op1->GetRegNum(); break; default: unreached(); } - switch (intrinOp2.numOperands) + switch (intrinEmbMask.numOperands) { case 1: assert(!instrIsRMW); - GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, maskReg, instrOp1Reg, opt); + GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp1Reg, opt); break; case 2: assert(instrIsRMW); - if (targetReg != falseReg) + + if (intrin.op3->IsVectorZero()) + { + // If `falseReg` is zero, then move the first operand of `intrinEmbMask` in the + // destination using /Z. + GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, embMaskOp1Reg, opt); + } + else if (targetReg != falseReg) { - assert(targetReg != instrOp1Reg); - assert(targetReg != instrOp2Reg); + // Since `falseReg` is non-zero and it is not the same as targetReg, we want to + // move it to the `targetReg` using `movprfx`. However, do this only if one of + // of the operands of `intrinEmbMask` is same as targetReg. - if (!intrin.op3->IsVectorZero() && (instrOp1Reg != falseReg)) + regNumber instrOperandReg = REG_NA; + if (targetReg == embMaskOp1Reg) + { + instrOperandReg = embMaskOp1Reg; + } + else if (targetReg == embMaskOp2Reg) + { + instrOperandReg = embMaskOp2Reg; + } + else { - // If the `falseValue` of conditional-select is non-zero, then we start with that in the - // destination followed by `movprfx` (see below) of the relevant bits of the first operand - // of `insOp2` based upon the value of predicate `cond`. + // If none of the operands are same, then we just perform the unpredicated + // version of the instruction and then use `sel` to retrieve the active elements + // from the result. + GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, embMaskOp1Reg, embMaskOp2Reg, opt, + INS_SCALABLE_OPTS_UNPREDICATED); + GetEmitter()->emitIns_R_R_R_R(INS_sve_sel, emitSize, targetReg, maskReg, targetReg, + falseReg, opt, INS_SCALABLE_OPTS_UNPREDICATED); + + break; + } - // Also, if `instrOp1Reg == falseReg`, we will move the `instrOp1Reg` using `movprfx` and - // so, no need to move it separately here. - GetEmitter()->emitIns_Mov(INS_mov, emitTypeSize(node), targetReg, falseReg, - /* canSkip */ true); + if (instrOperandReg != REG_NA) + { + if (falseReg == instrOperandReg) + { + // If falseReg is same as one of the operand register, then use the unpredicated + // version of `movprfx`. + GetEmitter()->emitIns_R_R(INS_sve_movprfx, EA_SCALABLE, targetReg, falseReg, opt); + } + else + { + // Otherwise, use predicated version of `movprfx`, so we can just "merge" the + // active elements from `falseReg` into the `targetReg`. + GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, falseReg, + opt, INS_SCALABLE_OPTS_PREDICATE_MERGE); + } } } - // Move the first operand of `insOp2` in the destination. If `falseValue` was zero, then we can just - // use /Z during the move, otherwise merge using /M into the destination. - GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, instrOp1Reg, opt, - intrin.op3->IsVectorZero() ? INS_SCALABLE_OPTS_NONE - : INS_SCALABLE_OPTS_PREDICATE_MERGE); - - // Finally, perform the actual operation so that `targetReg` is the first operand and `instrOp2Reg` + // Finally, perform the actual "predicated" operation so that `targetReg` is the first operand and `embMaskOp2Reg` // having the second operand. - GetEmitter()->emitIns_R_R_R(insOp2, emitSize, targetReg, maskReg, instrOp2Reg, opt); + GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp2Reg, opt); break; default: From 0daeac7831dbd8b71ba87afc43644aa2848e32d7 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 13:58:12 -0700 Subject: [PATCH 35/47] Move the special handling of Vector<>.Zero from lowerer to importer --- src/coreclr/jit/hwintrinsic.cpp | 12 ++++++++ src/coreclr/jit/lowerarmarch.cpp | 48 -------------------------------- 2 files changed, 12 insertions(+), 48 deletions(-) diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index 3d59986fe544ea..402cae99b3f631 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1609,6 +1609,18 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, { assert(numArgs > 0); GenTree* op1 = retNode->AsHWIntrinsic()->Op(1); + if (intrinsic == NI_Sve_ConditionalSelect) + { + if (op1->IsVectorAllBitsSet()) + { + return retNode->AsHWIntrinsic()->Op(2); + } + else if (op1->IsVectorZero()) + { + return retNode->AsHWIntrinsic()->Op(3); + } + } + if (!varTypeIsMask(op1)) { // Op1 input is a vector. HWInstrinsic requires a mask. diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 02d66a15aa4bdf..45cb13e37e8dca 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1208,54 +1208,6 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) LowerHWIntrinsicFusedMultiplyAddScalar(node); break; - case NI_Sve_ConditionalSelect: - { - GenTree* op1 = node->Op(1); - if (op1->OperIsHWIntrinsic(NI_Sve_ConvertVectorToMask)) - { - // For cases where conditional-select is used in the user code explicitly, - // select one of the true/false value, see if the `cond == 0` and if yes, - // just pick the `falseValue` and if `cond == 1`, pick the `trueValue` - // without having to do the condition. - - assert(varTypeIsMask(op1)); - - GenTreeHWIntrinsic* vectorToMask = op1->AsHWIntrinsic(); - GenTree* maskValue = vectorToMask->Op(2); - - GenTree* op2 = node->Op(2); - GenTree* op3 = node->Op(3); - GenTree* result = nullptr; - if (maskValue->IsVectorZero()) - { - result = op3; - } - else if (maskValue->IsVectorAllBitsSet()) - { - result = op2; - } - - if (result != nullptr) - { - result = comp->gtCloneExpr(result); - - LIR::Use use; - if (BlockRange().TryGetUse(node, &use)) - { - BlockRange().InsertBefore(node, result); - use.ReplaceWith(result); - } - else - { - result->SetUnusedValue(); - } - BlockRange().Remove(node, true); - return result; - } - } - break; - } - default: break; } From 635a7d7fceffaa0c2c0149cf200b697c4e79fd8a Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 15:11:16 -0700 Subject: [PATCH 36/47] Rename IsEmbeddedMaskedOperation/IsOptionalEmbeddedMaskedOperation --- src/coreclr/jit/gentree.cpp | 3 ++- src/coreclr/jit/hwintrinsic.h | 17 ++++++++--------- src/coreclr/jit/hwintrinsiclistarm64sve.h | 4 ++-- src/coreclr/jit/lowerarmarch.cpp | 4 +--- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 0ff4acc0c211bb..a52a12be610417 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -19921,7 +19921,8 @@ bool GenTree::isEmbeddedMaskingCompatibleHWIntrinsic() const // for prototyping purposes. return (AsHWIntrinsic()->GetHWIntrinsicId() == NI_AVX512F_Add); #elif defined(TARGET_ARM64) - return HWIntrinsicInfo::IsEmbeddedMaskedOperation(AsHWIntrinsic()->GetHWIntrinsicId()); + return HWIntrinsicInfo::IsEmbeddedMaskedOperation(AsHWIntrinsic()->GetHWIntrinsicId()) || + HWIntrinsicInfo::IsOptionalEmbeddedMaskedOperation(AsHWIntrinsic()->GetHWIntrinsicId()); #endif } return false; diff --git a/src/coreclr/jit/hwintrinsic.h b/src/coreclr/jit/hwintrinsic.h index fd50886858832d..5c885a9d28a399 100644 --- a/src/coreclr/jit/hwintrinsic.h +++ b/src/coreclr/jit/hwintrinsic.h @@ -191,12 +191,11 @@ enum HWIntrinsicFlag : unsigned int // The intrinsic uses a mask in arg1 to select elements present in the result, and must use a low register. HW_Flag_LowMaskedOperation = 0x40000, - // The intrinsic uses a mask in arg1 to select elements present in the result, which is not present in the API call - HW_Flag_EmbeddedMaskedOperation = 0x80000, + // The intrinsic can optionally use a mask in arg1 to select elements present in the result, which is not present in the API call + HW_Flag_OptionalEmbeddedMaskedOperation = 0x80000, // The intrinsic uses a mask in arg1 to select elements present in the result, which is not present in the API call - // and only has predicated version of the instruction - HW_Flag_MaskedPredicatedOnlyOperation = 0x100000, + HW_Flag_EmbeddedMaskedOperation = 0x100000, #else #error Unsupported platform @@ -879,7 +878,7 @@ struct HWIntrinsicInfo static bool IsMaskedOperation(NamedIntrinsic id) { const HWIntrinsicFlag flags = lookupFlags(id); - return IsLowMaskedOperation(id) || IsEmbeddedMaskedOperation(id) || IsExplicitMaskedOperation(id); + return IsLowMaskedOperation(id) || IsOptionalEmbeddedMaskedOperation(id) || IsExplicitMaskedOperation(id); } static bool IsLowMaskedOperation(NamedIntrinsic id) @@ -888,16 +887,16 @@ struct HWIntrinsicInfo return (flags & HW_Flag_LowMaskedOperation) != 0; } - static bool IsEmbeddedMaskedOperation(NamedIntrinsic id) + static bool IsOptionalEmbeddedMaskedOperation(NamedIntrinsic id) { const HWIntrinsicFlag flags = lookupFlags(id); - return (flags & HW_Flag_EmbeddedMaskedOperation) != 0; + return (flags & HW_Flag_OptionalEmbeddedMaskedOperation) != 0; } - static bool IsMaskedPredicatedOnlyOperation(NamedIntrinsic id) + static bool IsEmbeddedMaskedOperation(NamedIntrinsic id) { const HWIntrinsicFlag flags = lookupFlags(id); - return (flags & HW_Flag_MaskedPredicatedOnlyOperation) != 0; + return (flags & HW_Flag_EmbeddedMaskedOperation) != 0; } static bool IsExplicitMaskedOperation(NamedIntrinsic id) diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index cd85d40e47dc6a..21ff4e5c8e141c 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -17,8 +17,8 @@ // SVE Intrinsics // Sve -HARDWARE_INTRINSIC(Sve, Abs, -1, -1, false, {INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_fabs, INS_sve_fabs}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_MaskedPredicatedOnlyOperation) -HARDWARE_INTRINSIC(Sve, Add, -1, -1, false, {INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_fadd, INS_sve_fadd}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation) +HARDWARE_INTRINSIC(Sve, Abs, -1, -1, false, {INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_fabs, INS_sve_fabs}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation) +HARDWARE_INTRINSIC(Sve, Add, -1, -1, false, {INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_fadd, INS_sve_fadd}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_OptionalEmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation) HARDWARE_INTRINSIC(Sve, ConditionalSelect, -1, 3, true, {INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_SupportsContainment) HARDWARE_INTRINSIC(Sve, CreateTrueMaskByte, -1, 1, false, {INS_invalid, INS_sve_ptrue, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) HARDWARE_INTRINSIC(Sve, CreateTrueMaskDouble, -1, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_ptrue}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 45cb13e37e8dca..c3721e20bb9579 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -1212,10 +1212,8 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) break; } - if (HWIntrinsicInfo::IsMaskedPredicatedOnlyOperation(intrinsicId)) + if (HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsicId)) { - assert(HWIntrinsicInfo::IsEmbeddedMaskedOperation(intrinsicId)); - LIR::Use use; if (BlockRange().TryGetUse(node, &use)) { From 19da9829787ca0544f3bbbe15e0c46a244f4941f Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 16:42:43 -0700 Subject: [PATCH 37/47] Add more test coverage for conditionalSelect --- .../GenerateHWIntrinsicTests_Arm.cs | 52 ++++++----- .../Shared/_SveBinaryOpTestTemplate.template | 87 +++++++++++++++++++ 2 files changed, 118 insertions(+), 21 deletions(-) diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index 02f88ced05bb68..739bf7fe7aadf3 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -47,6 +47,16 @@ } }"; +const string SimpleVecOpTest_ValidationLogicForCndSel = @"for (var i = 0; i < RetElementCount; i++) + { + var iterResult = (mask[i] != 0) ? {GetIterResult} : falseVal[i]; + if (iterResult != result[i]) + { + succeeded = false; + break; + } + }"; + const string VecPairBinOpTest_ValidationLogic = @" int index = 0; int half = RetElementCount / 2; @@ -109,7 +119,7 @@ ("_BinaryOpTestTemplate.template", "SecureHashBinOpTest.template", new Dictionary { ["TemplateName"] = "SecureHash", ["TemplateValidationLogic"] = SecureHashOpTest_ValidationLogic }), ("_TernaryOpTestTemplate.template", "SecureHashTernOpTest.template", new Dictionary { ["TemplateName"] = "SecureHash", ["TemplateValidationLogic"] = SecureHashOpTest_ValidationLogic }), ("_SveUnaryOpTestTemplate.template", "SveSimpleVecOpTest.template", new Dictionary { ["TemplateName"] = "Simple", ["TemplateValidationLogic"] = SimpleVecOpTest_ValidationLogic }), - ("_SveBinaryOpTestTemplate.template", "SveVecBinOpTest.template", new Dictionary { ["TemplateName"] = "Simple", ["TemplateValidationLogic"] = SimpleVecOpTest_ValidationLogic }), + ("_SveBinaryOpTestTemplate.template", "SveVecBinOpTest.template", new Dictionary { ["TemplateName"] = "Simple", ["TemplateValidationLogic"] = SimpleVecOpTest_ValidationLogic, ["TemplateValidationLogicForCndSel"] = SimpleVecOpTest_ValidationLogicForCndSel }), }; (string templateFileName, Dictionary templateData)[] AdvSimdInputs = new [] @@ -2896,27 +2906,27 @@ ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(long)Helpers.Abs(firstOp[i]) != (long)result[i]"}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(sbyte)TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(short)TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(byte)TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), - ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]",}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(sbyte)TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(short)TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(byte)TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), + ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), - ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "(firstOp[i] == 0 ? (result[i] == secondOp[i]) : (result[i] == thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Int64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_byte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Byte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetByte()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt16", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt32", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "UInt64", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp3"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), ("SveLoadMaskedUnOpTest.template", new Dictionary { ["TestName"] = "SveLoadVector_double", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}), diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template index c937e06494215d..1c493329c64060 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template @@ -50,6 +50,15 @@ namespace JIT.HardwareIntrinsics.Arm // Validates passing an instance member of a struct works test.RunStructFldScenario(); + + // Validates executing the test inside conditional, with op1 as falseValue + test.ConditionalSelect_Op1(); + + // Validates executing the test inside conditional, with op2 as falseValue + test.ConditionalSelect_Op2(); + + // Validates executing the test inside conditional, with op3 as falseValue + test.ConditionalSelect_Op3(); } else { @@ -151,11 +160,14 @@ namespace JIT.HardwareIntrinsics.Arm private static readonly int Op2ElementCount = Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>() / sizeof({Op2BaseType}); private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); + private static {Op1BaseType}[] _maskData = new {Op1BaseType}[Op1ElementCount]; private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; private static {Op2BaseType}[] _data2 = new {Op2BaseType}[Op2ElementCount]; + private {Op1VectorType}<{Op1BaseType}> _mask; private {Op1VectorType}<{Op1BaseType}> _fld1; private {Op2VectorType}<{Op2BaseType}> _fld2; + private {Op2VectorType}<{Op2BaseType}> _falseFld; private DataTable _dataTable; @@ -163,10 +175,13 @@ namespace JIT.HardwareIntrinsics.Arm { Succeeded = true; + for (var i = 0; i < Op1ElementCount; i++) { _maskData[i] = ({Op1BaseType})({NextValueOp1} % 2); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _mask), ref Unsafe.As<{Op1BaseType}, byte>(ref _maskData[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref _fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref _falseFld), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } @@ -260,6 +275,46 @@ namespace JIT.HardwareIntrinsics.Arm test.RunStructFldScenario(this); } + public void ConditionalSelect_Op1() + { + TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_Op1)); + ConditionalSelectScenario(_mask, _fld1, _fld2, _fld1); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld2, _fld1); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld2, _fld1); + } + + public void ConditionalSelect_Op2() + { + TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_Op2)); + ConditionalSelectScenario(_mask, _fld1, _fld2, _fld2); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld2, _fld2); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld2, _fld2); + } + + public void ConditionalSelect_Op3() + { + TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_Op3)); + ConditionalSelectScenario(_mask, _fld1, _fld2, _falseFld); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld2, _falseFld); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld2, _falseFld); + } + + + [method: MethodImpl(MethodImplOptions.AggressiveInlining)] + private void ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}> mask, {Op1VectorType}<{Op1BaseType}> op1, {Op1VectorType}<{Op1BaseType}> op2, {Op1VectorType}<{Op1BaseType}> falseOp) + { + var result = Sve.ConditionalSelect(mask, {Isa}.{Method}(op1, op2), falseOp); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateConditionalSelectResult(mask, op1, op2, falseOp, _dataTable.outArrayPtr); + } + public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); @@ -281,6 +336,38 @@ namespace JIT.HardwareIntrinsics.Arm } } + private void ValidateConditionalSelectResult({Op1VectorType}<{Op1BaseType}> maskOp, {Op1VectorType}<{Op1BaseType}> leftOp, {Op1VectorType}<{Op1BaseType}> rightOp, {Op1VectorType}<{Op1BaseType}> falseOp, void* output, [CallerMemberName] string method = "") + { + {Op1BaseType}[] mask = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] left = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] right = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] falseVal = new {Op1BaseType}[Op1ElementCount]; + {RetBaseType}[] result = new {RetBaseType}[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref mask[0]), maskOp); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref left[0]), leftOp); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref right[0]), rightOp); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref falseVal[0]), falseOp); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref result[0]), ref Unsafe.AsRef(output), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + + bool succeeded = true; + + {TemplateValidationLogicForCndSel} + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>, {Op2VectorType}<{Op2BaseType}>): {method} failed:"); + TestLibrary.TestFramework.LogInformation($" mask: ({string.Join(", ", mask)})"); + TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); + TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); + TestLibrary.TestFramework.LogInformation($" falseOp: ({string.Join(", ", falseVal)})"); + TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + Succeeded = false; + } + } + private void ValidateResult({Op1VectorType}<{Op1BaseType}> op1, {Op2VectorType}<{Op2BaseType}> op2, void* result, [CallerMemberName] string method = "") { {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; From f1b8b17d15be410d8a9ae2051b3d19545d5189b7 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 17:04:20 -0700 Subject: [PATCH 38/47] Rename test method name --- .../Arm/Shared/_SveBinaryOpTestTemplate.template | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template index 1c493329c64060..6c9c942cd02c75 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template @@ -58,7 +58,7 @@ namespace JIT.HardwareIntrinsics.Arm test.ConditionalSelect_Op2(); // Validates executing the test inside conditional, with op3 as falseValue - test.ConditionalSelect_Op3(); + test.ConditionalSelect_FalseOp(); } else { @@ -295,9 +295,9 @@ namespace JIT.HardwareIntrinsics.Arm ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld2, _fld2); } - public void ConditionalSelect_Op3() + public void ConditionalSelect_FalseOp() { - TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_Op3)); + TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_FalseOp)); ConditionalSelectScenario(_mask, _fld1, _fld2, _falseFld); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld2, _falseFld); From 409a03907675129e190493d52b939403cf7faf22 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 17:05:06 -0700 Subject: [PATCH 39/47] Add more test coverage for conditionalSelect:Abs --- .../GenerateHWIntrinsicTests_Arm.cs | 16 ++--- .../Shared/_SveUnaryOpTestTemplate.template | 70 +++++++++++++++++++ 2 files changed, 78 insertions(+), 8 deletions(-) diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index 739bf7fe7aadf3..7b9a46bd2e3762 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -49,7 +49,7 @@ const string SimpleVecOpTest_ValidationLogicForCndSel = @"for (var i = 0; i < RetElementCount; i++) { - var iterResult = (mask[i] != 0) ? {GetIterResult} : falseVal[i]; + {Op1BaseType} iterResult = (mask[i] != 0) ? {GetIterResult} : falseVal[i]; if (iterResult != result[i]) { succeeded = false; @@ -118,7 +118,7 @@ ("_UnaryOpTestTemplate.template", "SecureHashUnOpTest.template", new Dictionary { ["TemplateName"] = "SecureHash", ["TemplateValidationLogic"] = SecureHashOpTest_ValidationLogic }), ("_BinaryOpTestTemplate.template", "SecureHashBinOpTest.template", new Dictionary { ["TemplateName"] = "SecureHash", ["TemplateValidationLogic"] = SecureHashOpTest_ValidationLogic }), ("_TernaryOpTestTemplate.template", "SecureHashTernOpTest.template", new Dictionary { ["TemplateName"] = "SecureHash", ["TemplateValidationLogic"] = SecureHashOpTest_ValidationLogic }), - ("_SveUnaryOpTestTemplate.template", "SveSimpleVecOpTest.template", new Dictionary { ["TemplateName"] = "Simple", ["TemplateValidationLogic"] = SimpleVecOpTest_ValidationLogic }), + ("_SveUnaryOpTestTemplate.template", "SveSimpleVecOpTest.template", new Dictionary { ["TemplateName"] = "Simple", ["TemplateValidationLogic"] = SimpleVecOpTest_ValidationLogic, ["TemplateValidationLogicForCndSel"] = SimpleVecOpTest_ValidationLogicForCndSel }), ("_SveBinaryOpTestTemplate.template", "SveVecBinOpTest.template", new Dictionary { ["TemplateName"] = "Simple", ["TemplateValidationLogic"] = SimpleVecOpTest_ValidationLogic, ["TemplateValidationLogicForCndSel"] = SimpleVecOpTest_ValidationLogicForCndSel }), }; @@ -2899,12 +2899,12 @@ (string templateFileName, Dictionary templateData)[] SveInputs = new [] { - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(sbyte)-TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(short)-TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]"}), - ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(long)Helpers.Abs(firstOp[i]) != (long)result[i]"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]", ["GetIterResult"] = "Helpers.Abs(leftOp[i])"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]", ["GetIterResult"] = "Helpers.Abs(leftOp[i])"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(sbyte)-TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]", ["GetIterResult"] = "(sbyte)Helpers.Abs(leftOp[i])"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_short", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "(short)-TestLibrary.Generator.GetInt16()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]", ["GetIterResult"] = "(short)Helpers.Abs(leftOp[i])"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_int", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt32()", ["ValidateIterResult"] = "Helpers.Abs(firstOp[i]) != result[i]", ["GetIterResult"] = "(int)Helpers.Abs(leftOp[i])"}), + ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_Abs_long", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Abs", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "-TestLibrary.Generator.GetInt64()", ["ValidateIterResult"] = "(long)Helpers.Abs(firstOp[i]) != (long)result[i]", ["GetIterResult"] = "(long)Helpers.Abs(leftOp[i])"}), ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), ("SveVecBinOpTest.template", new Dictionary { ["TestName"] = "Sve_Add_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "Add", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.Add(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.Add(left[i], right[i])"}), diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template index 2a9f42a147b2ac..1157c08281c722 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template @@ -50,6 +50,12 @@ namespace JIT.HardwareIntrinsics.Arm // Validates passing an instance member of a struct works test.RunStructFldScenario(); + + // Validates executing the test inside conditional, with op1 as falseValue + test.ConditionalSelect_Op1(); + + // Validates executing the test inside conditional, with op3 as falseValue + test.ConditionalSelect_FalseOp(); } else { @@ -139,9 +145,12 @@ namespace JIT.HardwareIntrinsics.Arm private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); + private static {Op1BaseType}[] _maskData = new {Op1BaseType}[Op1ElementCount]; private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; + private {Op1VectorType}<{Op1BaseType}> _mask; private {Op1VectorType}<{Op1BaseType}> _fld1; + private {Op1VectorType}<{Op1BaseType}> _falseFld; private DataTable _dataTable; @@ -149,8 +158,11 @@ namespace JIT.HardwareIntrinsics.Arm { Succeeded = true; + for (var i = 0; i < Op1ElementCount; i++) { _maskData[i] = ({Op1BaseType})({NextValueOp1} % 2); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _mask), ref Unsafe.As<{Op1BaseType}, byte>(ref _maskData[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _falseFld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } _dataTable = new DataTable(_data1, new {RetBaseType}[RetElementCount], LargestVectorSize); @@ -239,6 +251,35 @@ namespace JIT.HardwareIntrinsics.Arm test.RunStructFldScenario(this); } + public void ConditionalSelect_Op1() + { + TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_Op1)); + ConditionalSelectScenario(_mask, _fld1, _fld1); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld1); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld1); + } + + public void ConditionalSelect_FalseOp() + { + TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_FalseOp)); + ConditionalSelectScenario(_mask, _fld1, _falseFld); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _falseFld); + + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _falseFld); + } + + [method: MethodImpl(MethodImplOptions.AggressiveInlining)] + private void ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}> mask, {Op1VectorType}<{Op1BaseType}> op1, {Op1VectorType}<{Op1BaseType}> falseOp) + { + var result = Sve.ConditionalSelect(mask, {Isa}.{Method}(op1), falseOp); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateConditionalSelectResult(mask, op1, falseOp, _dataTable.outArrayPtr); + } + public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); @@ -260,6 +301,35 @@ namespace JIT.HardwareIntrinsics.Arm } } + private void ValidateConditionalSelectResult({Op1VectorType}<{Op1BaseType}> maskOp, {Op1VectorType}<{Op1BaseType}> leftOp, {Op1VectorType}<{Op1BaseType}> falseOp, void* output, [CallerMemberName] string method = "") + { + {Op1BaseType}[] mask = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] left = new {Op1BaseType}[Op1ElementCount]; + {Op1BaseType}[] falseVal = new {Op1BaseType}[Op1ElementCount]; + {RetBaseType}[] result = new {RetBaseType}[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref mask[0]), maskOp); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref left[0]), leftOp); + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref falseVal[0]), falseOp); + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref result[0]), ref Unsafe.AsRef(output), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + + bool succeeded = true; + + {TemplateValidationLogicForCndSel} + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>, {Op1VectorType}<{Op1BaseType}>): {method} failed:"); + TestLibrary.TestFramework.LogInformation($" mask: ({string.Join(", ", mask)})"); + TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); + TestLibrary.TestFramework.LogInformation($" falseOp: ({string.Join(", ", falseVal)})"); + TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + Succeeded = false; + } + } + private void ValidateResult({Op1VectorType}<{Op1BaseType}> op1, void* result, [CallerMemberName] string method = "") { {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; From 0c8a14d3ec58043cb2b9a4038d23cbe53d9a524f Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 20:52:01 -0700 Subject: [PATCH 40/47] jit format --- src/coreclr/jit/gentree.cpp | 2 +- src/coreclr/jit/hwintrinsic.h | 3 ++- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index a52a12be610417..970e09ae8e2d5a 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -19922,7 +19922,7 @@ bool GenTree::isEmbeddedMaskingCompatibleHWIntrinsic() const return (AsHWIntrinsic()->GetHWIntrinsicId() == NI_AVX512F_Add); #elif defined(TARGET_ARM64) return HWIntrinsicInfo::IsEmbeddedMaskedOperation(AsHWIntrinsic()->GetHWIntrinsicId()) || - HWIntrinsicInfo::IsOptionalEmbeddedMaskedOperation(AsHWIntrinsic()->GetHWIntrinsicId()); + HWIntrinsicInfo::IsOptionalEmbeddedMaskedOperation(AsHWIntrinsic()->GetHWIntrinsicId()); #endif } return false; diff --git a/src/coreclr/jit/hwintrinsic.h b/src/coreclr/jit/hwintrinsic.h index 5c885a9d28a399..e7bd08d5cb33dc 100644 --- a/src/coreclr/jit/hwintrinsic.h +++ b/src/coreclr/jit/hwintrinsic.h @@ -191,7 +191,8 @@ enum HWIntrinsicFlag : unsigned int // The intrinsic uses a mask in arg1 to select elements present in the result, and must use a low register. HW_Flag_LowMaskedOperation = 0x40000, - // The intrinsic can optionally use a mask in arg1 to select elements present in the result, which is not present in the API call + // The intrinsic can optionally use a mask in arg1 to select elements present in the result, which is not present in + // the API call HW_Flag_OptionalEmbeddedMaskedOperation = 0x80000, // The intrinsic uses a mask in arg1 to select elements present in the result, which is not present in the API call diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index cfdc6bf7d78cc2..236171e34010d1 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -411,13 +411,13 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) // Get the registers and intrinsics that needs embedded mask const HWIntrinsic intrinEmbMask(op2->AsHWIntrinsic()); - instruction insEmbMask = HWIntrinsicInfo::lookupIns(intrinEmbMask.id, intrinEmbMask.baseType); + instruction insEmbMask = HWIntrinsicInfo::lookupIns(intrinEmbMask.id, intrinEmbMask.baseType); const bool instrIsRMW = op2->isRMWHWIntrinsic(compiler); - regNumber maskReg = op1Reg; + regNumber maskReg = op1Reg; regNumber embMaskOp1Reg = REG_NA; regNumber embMaskOp2Reg = REG_NA; - regNumber falseReg = op3Reg; + regNumber falseReg = op3Reg; switch (intrinEmbMask.numOperands) { @@ -472,8 +472,8 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) // If none of the operands are same, then we just perform the unpredicated // version of the instruction and then use `sel` to retrieve the active elements // from the result. - GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, embMaskOp1Reg, embMaskOp2Reg, opt, - INS_SCALABLE_OPTS_UNPREDICATED); + GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, embMaskOp1Reg, embMaskOp2Reg, + opt, INS_SCALABLE_OPTS_UNPREDICATED); GetEmitter()->emitIns_R_R_R_R(INS_sve_sel, emitSize, targetReg, maskReg, targetReg, falseReg, opt, INS_SCALABLE_OPTS_UNPREDICATED); @@ -498,8 +498,8 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) } } - // Finally, perform the actual "predicated" operation so that `targetReg` is the first operand and `embMaskOp2Reg` - // having the second operand. + // Finally, perform the actual "predicated" operation so that `targetReg` is the first operand and + // `embMaskOp2Reg` having the second operand. GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp2Reg, opt); break; From 53c5eb31481b45845d030f3df4f6c76ea6e39492 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 20:54:13 -0700 Subject: [PATCH 41/47] Add logging on test methods --- .../Arm/Shared/_SveBinaryOpTestTemplate.template | 12 +++++++++--- .../Arm/Shared/_SveUnaryOpTestTemplate.template | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template index 6c9c942cd02c75..6faea852f35b58 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template @@ -277,31 +277,37 @@ namespace JIT.HardwareIntrinsics.Arm public void ConditionalSelect_Op1() { - TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_Op1)); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_Op1_mask"); ConditionalSelectScenario(_mask, _fld1, _fld2, _fld1); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_Op1_zero"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld2, _fld1); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_Op1_all"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld2, _fld1); } public void ConditionalSelect_Op2() { - TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_Op2)); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_Op2_mask"); ConditionalSelectScenario(_mask, _fld1, _fld2, _fld2); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_Op2_zero"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld2, _fld2); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_Op2_all"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld2, _fld2); } public void ConditionalSelect_FalseOp() { - TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_FalseOp)); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_FalseOp_mask"); ConditionalSelectScenario(_mask, _fld1, _fld2, _falseFld); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_FalseOp_zero"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld2, _falseFld); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_FalseOp_all"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld2, _falseFld); } diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template index 1157c08281c722..ba5b267cf5c022 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template @@ -253,11 +253,13 @@ namespace JIT.HardwareIntrinsics.Arm public void ConditionalSelect_Op1() { - TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_Op1)); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_Op1_mask"); ConditionalSelectScenario(_mask, _fld1, _fld1); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_Op1_zero"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld1); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_Op1_all"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld1); } @@ -266,8 +268,10 @@ namespace JIT.HardwareIntrinsics.Arm TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_FalseOp)); ConditionalSelectScenario(_mask, _fld1, _falseFld); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_FalseOp_zero"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _falseFld); + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_FalseOp_all"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _falseFld); } From 9ae3c7864b5f923d98875f00825cf999f5e05c56 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 23:44:22 -0700 Subject: [PATCH 42/47] Add the missing movprfx for abs --- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 236171e34010d1..bf3937e67d5e04 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -439,6 +439,10 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) { case 1: assert(!instrIsRMW); + if (targetReg != falseReg) + { + GetEmitter()->emitIns_R_R(INS_sve_movprfx, EA_SCALABLE, targetReg, falseReg); + } GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp1Reg, opt); break; From c8244eb44378a8e8d1df284dc2b90cc93f78d640 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 22 Apr 2024 23:45:46 -0700 Subject: [PATCH 43/47] Add few more scenarios where falseVal is zero --- .../Arm/Shared/_SveBinaryOpTestTemplate.template | 16 +++++++++++++++- .../Arm/Shared/_SveUnaryOpTestTemplate.template | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template index 6faea852f35b58..bd15acab428a09 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveBinaryOpTestTemplate.template @@ -59,6 +59,9 @@ namespace JIT.HardwareIntrinsics.Arm // Validates executing the test inside conditional, with op3 as falseValue test.ConditionalSelect_FalseOp(); + + // Validates executing the test inside conditional, with op3 as zero + test.ConditionalSelect_ZeroOp(); } else { @@ -309,8 +312,19 @@ namespace JIT.HardwareIntrinsics.Arm TestLibrary.TestFramework.BeginScenario("ConditionalSelect_FalseOp_all"); ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld2, _falseFld); - } + } + public void ConditionalSelect_ZeroOp() + { + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_ZeroOp_mask"); + ConditionalSelectScenario(_mask, _fld1, _fld2, {Op1VectorType}<{Op1BaseType}>.Zero); + + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_ZeroOp_zero"); + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, _fld2, {Op1VectorType}<{Op1BaseType}>.Zero); + + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_ZeroOp_all"); + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _fld2, {Op1VectorType}<{Op1BaseType}>.Zero); + } [method: MethodImpl(MethodImplOptions.AggressiveInlining)] private void ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}> mask, {Op1VectorType}<{Op1BaseType}> op1, {Op1VectorType}<{Op1BaseType}> op2, {Op1VectorType}<{Op1BaseType}> falseOp) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template index ba5b267cf5c022..557442de4cf0be 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveUnaryOpTestTemplate.template @@ -56,6 +56,9 @@ namespace JIT.HardwareIntrinsics.Arm // Validates executing the test inside conditional, with op3 as falseValue test.ConditionalSelect_FalseOp(); + + // Validates executing the test inside conditional, with op3 as zero + test.ConditionalSelect_ZeroOp(); } else { @@ -275,6 +278,18 @@ namespace JIT.HardwareIntrinsics.Arm ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, _falseFld); } + public void ConditionalSelect_ZeroOp() + { + TestLibrary.TestFramework.BeginScenario(nameof(ConditionalSelect_ZeroOp)); + ConditionalSelectScenario(_mask, _fld1, {Op1VectorType}<{Op1BaseType}>.Zero); + + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_ZeroOp_zero"); + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.Zero, _fld1, {Op1VectorType}<{Op1BaseType}>.Zero); + + TestLibrary.TestFramework.BeginScenario("ConditionalSelect_ZeroOp_all"); + ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}>.AllBitsSet, _fld1, {Op1VectorType}<{Op1BaseType}>.Zero); + } + [method: MethodImpl(MethodImplOptions.AggressiveInlining)] private void ConditionalSelectScenario({Op1VectorType}<{Op1BaseType}> mask, {Op1VectorType}<{Op1BaseType}> op1, {Op1VectorType}<{Op1BaseType}> falseOp) { From f6eb1feaa59cbbe7b73d5b6f6f86cc0b8828810a Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Tue, 23 Apr 2024 12:56:32 -0700 Subject: [PATCH 44/47] Make sure LoadVector is marked as explicit needing mask --- src/coreclr/jit/hwintrinsiclistarm64sve.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index 21ff4e5c8e141c..14b880c8e570e4 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -31,7 +31,7 @@ HARDWARE_INTRINSIC(Sve, CreateTrueMaskUInt16, HARDWARE_INTRINSIC(Sve, CreateTrueMaskUInt32, -1, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_ptrue, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) HARDWARE_INTRINSIC(Sve, CreateTrueMaskUInt64, -1, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_ptrue, INS_invalid, INS_invalid}, HW_Category_EnumPattern, HW_Flag_Scalable|HW_Flag_HasImmediateOperand|HW_Flag_ReturnsPerElementMask) -HARDWARE_INTRINSIC(Sve, LoadVector, -1, 2, true, {INS_sve_ld1b, INS_sve_ld1b, INS_sve_ld1h, INS_sve_ld1h, INS_sve_ld1w, INS_sve_ld1w, INS_sve_ld1d, INS_sve_ld1d, INS_sve_ld1w, INS_sve_ld1d}, HW_Category_MemoryLoad, HW_Flag_Scalable|HW_Flag_LowMaskedOperation) +HARDWARE_INTRINSIC(Sve, LoadVector, -1, 2, true, {INS_sve_ld1b, INS_sve_ld1b, INS_sve_ld1h, INS_sve_ld1h, INS_sve_ld1w, INS_sve_ld1w, INS_sve_ld1d, INS_sve_ld1d, INS_sve_ld1w, INS_sve_ld1d}, HW_Category_MemoryLoad, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_LowMaskedOperation) From 83e1b1b3c3639786888025204246af653b597050 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Tue, 23 Apr 2024 23:50:28 -0700 Subject: [PATCH 45/47] revisit the codegen logic --- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 88 ++++++++++++++------- 1 file changed, 60 insertions(+), 28 deletions(-) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index bf3937e67d5e04..f5f74186c8617c 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -455,51 +455,83 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) // If `falseReg` is zero, then move the first operand of `intrinEmbMask` in the // destination using /Z. GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, embMaskOp1Reg, opt); + + // Finally, perform the actual "predicated" operation so that `targetReg` is the first operand + // and + // `embMaskOp2Reg` having the second operand. + GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp2Reg, opt); } else if (targetReg != falseReg) { - // Since `falseReg` is non-zero and it is not the same as targetReg, we want to - // move it to the `targetReg` using `movprfx`. However, do this only if one of - // of the operands of `intrinEmbMask` is same as targetReg. - - regNumber instrOperandReg = REG_NA; - if (targetReg == embMaskOp1Reg) - { - instrOperandReg = embMaskOp1Reg; - } - else if (targetReg == embMaskOp2Reg) - { - instrOperandReg = embMaskOp2Reg; - } - else + if (falseReg != embMaskOp1Reg) { - // If none of the operands are same, then we just perform the unpredicated - // version of the instruction and then use `sel` to retrieve the active elements - // from the result. + // 3 and 6 GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, embMaskOp1Reg, embMaskOp2Reg, opt, INS_SCALABLE_OPTS_UNPREDICATED); GetEmitter()->emitIns_R_R_R_R(INS_sve_sel, emitSize, targetReg, maskReg, targetReg, falseReg, opt, INS_SCALABLE_OPTS_UNPREDICATED); - break; } - - if (instrOperandReg != REG_NA) + else { - if (falseReg == instrOperandReg) + if (targetReg != embMaskOp1Reg) { + // 5 // If falseReg is same as one of the operand register, then use the unpredicated // version of `movprfx`. GetEmitter()->emitIns_R_R(INS_sve_movprfx, EA_SCALABLE, targetReg, falseReg, opt); } - else - { - // Otherwise, use predicated version of `movprfx`, so we can just "merge" the - // active elements from `falseReg` into the `targetReg`. - GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, falseReg, - opt, INS_SCALABLE_OPTS_PREDICATE_MERGE); - } + + // 5 and 6 + + // Finally, perform the actual "predicated" operation so that `targetReg` is the first + // operand and + // `embMaskOp2Reg` having the second operand. + GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp2Reg, opt); } + + //// Since `falseReg` is non-zero and it is not the same as targetReg, we want to + //// move it to the `targetReg` using `movprfx`. However, do this only if one of + //// of the operands of `intrinEmbMask` is same as targetReg. + + //regNumber instrOperandReg = REG_NA; + //if (targetReg == embMaskOp1Reg) + //{ + // instrOperandReg = embMaskOp1Reg; + //} + //else if (targetReg == embMaskOp2Reg) + //{ + // instrOperandReg = embMaskOp2Reg; + //} + //else + //{ + // // If none of the operands are same, then we just perform the unpredicated + // // version of the instruction and then use `sel` to retrieve the active elements + // // from the result. + // GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, embMaskOp1Reg, embMaskOp2Reg, + // opt, INS_SCALABLE_OPTS_UNPREDICATED); + // GetEmitter()->emitIns_R_R_R_R(INS_sve_sel, emitSize, targetReg, maskReg, targetReg, + // falseReg, opt, INS_SCALABLE_OPTS_UNPREDICATED); + + // break; + //} + + //if (instrOperandReg != REG_NA) + //{ + // if (falseReg == instrOperandReg) + // { + // // If falseReg is same as one of the operand register, then use the unpredicated + // // version of `movprfx`. + // GetEmitter()->emitIns_R_R(INS_sve_movprfx, EA_SCALABLE, targetReg, falseReg, opt); + // } + // else + // { + // // Otherwise, use predicated version of `movprfx`, so we can just "merge" the + // // active elements from `falseReg` into the `targetReg`. + // GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, falseReg, + // opt, INS_SCALABLE_OPTS_PREDICATE_MERGE); + // } + //} } // Finally, perform the actual "predicated" operation so that `targetReg` is the first operand and From c78e0c7e471a7451bd380480bb585b3101da024c Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Wed, 24 Apr 2024 00:03:08 -0700 Subject: [PATCH 46/47] Remove commented code and add some other comments --- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 79 ++++----------------- 1 file changed, 15 insertions(+), 64 deletions(-) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index f5f74186c8617c..e4d07e65b84dab 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -457,86 +457,37 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, embMaskOp1Reg, opt); // Finally, perform the actual "predicated" operation so that `targetReg` is the first operand - // and - // `embMaskOp2Reg` having the second operand. + // and `embMaskOp2Reg` is the second operand. GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp2Reg, opt); } else if (targetReg != falseReg) { + // If `targetReg` and `falseReg` are not same, then we need to move it to `targetReg` first + // so the `insEmbMask` operation can be merged on top of it. + if (falseReg != embMaskOp1Reg) { - // 3 and 6 + // None of targetReg, embMaskOp1Reg and falseReg are same. In such case, use the "unpredicated" + // version of the instruction and then use "sel" to select the active lanes. + GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, embMaskOp1Reg, embMaskOp2Reg, opt, INS_SCALABLE_OPTS_UNPREDICATED); GetEmitter()->emitIns_R_R_R_R(INS_sve_sel, emitSize, targetReg, maskReg, targetReg, falseReg, opt, INS_SCALABLE_OPTS_UNPREDICATED); break; } - else - { - if (targetReg != embMaskOp1Reg) - { - // 5 - // If falseReg is same as one of the operand register, then use the unpredicated - // version of `movprfx`. - GetEmitter()->emitIns_R_R(INS_sve_movprfx, EA_SCALABLE, targetReg, falseReg, opt); - } - - // 5 and 6 - - // Finally, perform the actual "predicated" operation so that `targetReg` is the first - // operand and - // `embMaskOp2Reg` having the second operand. - GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp2Reg, opt); + else if (targetReg != embMaskOp1Reg) + { + // embMaskOp1Reg is same as `falseReg`, but not same as `targetReg`. Move the `embMaskOp1Reg` i.e. `falseReg` in `targetReg`, + // using "unpredicated movprfx", so the subsequent `insEmbMask` operation can be merged on top of it. + GetEmitter()->emitIns_R_R(INS_sve_movprfx, EA_SCALABLE, targetReg, falseReg, opt); } - //// Since `falseReg` is non-zero and it is not the same as targetReg, we want to - //// move it to the `targetReg` using `movprfx`. However, do this only if one of - //// of the operands of `intrinEmbMask` is same as targetReg. - - //regNumber instrOperandReg = REG_NA; - //if (targetReg == embMaskOp1Reg) - //{ - // instrOperandReg = embMaskOp1Reg; - //} - //else if (targetReg == embMaskOp2Reg) - //{ - // instrOperandReg = embMaskOp2Reg; - //} - //else - //{ - // // If none of the operands are same, then we just perform the unpredicated - // // version of the instruction and then use `sel` to retrieve the active elements - // // from the result. - // GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, embMaskOp1Reg, embMaskOp2Reg, - // opt, INS_SCALABLE_OPTS_UNPREDICATED); - // GetEmitter()->emitIns_R_R_R_R(INS_sve_sel, emitSize, targetReg, maskReg, targetReg, - // falseReg, opt, INS_SCALABLE_OPTS_UNPREDICATED); - - // break; - //} - - //if (instrOperandReg != REG_NA) - //{ - // if (falseReg == instrOperandReg) - // { - // // If falseReg is same as one of the operand register, then use the unpredicated - // // version of `movprfx`. - // GetEmitter()->emitIns_R_R(INS_sve_movprfx, EA_SCALABLE, targetReg, falseReg, opt); - // } - // else - // { - // // Otherwise, use predicated version of `movprfx`, so we can just "merge" the - // // active elements from `falseReg` into the `targetReg`. - // GetEmitter()->emitIns_R_R_R(INS_sve_movprfx, emitSize, targetReg, maskReg, falseReg, - // opt, INS_SCALABLE_OPTS_PREDICATE_MERGE); - // } - //} + // Finally, perform the actual "predicated" operation so that `targetReg` is the first operand + // and `embMaskOp2Reg` is the second operand. + GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp2Reg, opt); } - // Finally, perform the actual "predicated" operation so that `targetReg` is the first operand and - // `embMaskOp2Reg` having the second operand. - GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp2Reg, opt); break; default: From 6aa23864272794201589cebcce5975cd9f6d426d Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Wed, 24 Apr 2024 00:03:56 -0700 Subject: [PATCH 47/47] jit format --- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index e4d07e65b84dab..c5ea702c1c4be7 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -467,8 +467,8 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) if (falseReg != embMaskOp1Reg) { - // None of targetReg, embMaskOp1Reg and falseReg are same. In such case, use the "unpredicated" - // version of the instruction and then use "sel" to select the active lanes. + // None of targetReg, embMaskOp1Reg and falseReg are same. In such case, use the + // "unpredicated" version of the instruction and then use "sel" to select the active lanes. GetEmitter()->emitIns_R_R_R(insEmbMask, emitSize, targetReg, embMaskOp1Reg, embMaskOp2Reg, opt, INS_SCALABLE_OPTS_UNPREDICATED); @@ -476,10 +476,11 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) falseReg, opt, INS_SCALABLE_OPTS_UNPREDICATED); break; } - else if (targetReg != embMaskOp1Reg) - { - // embMaskOp1Reg is same as `falseReg`, but not same as `targetReg`. Move the `embMaskOp1Reg` i.e. `falseReg` in `targetReg`, - // using "unpredicated movprfx", so the subsequent `insEmbMask` operation can be merged on top of it. + else if (targetReg != embMaskOp1Reg) + { + // embMaskOp1Reg is same as `falseReg`, but not same as `targetReg`. Move the + // `embMaskOp1Reg` i.e. `falseReg` in `targetReg`, using "unpredicated movprfx", so the + // subsequent `insEmbMask` operation can be merged on top of it. GetEmitter()->emitIns_R_R(INS_sve_movprfx, EA_SCALABLE, targetReg, falseReg, opt); }