@@ -8852,7 +8852,65 @@ void ValueNumStore::vnDumpZeroObj(Compiler* comp, VNFuncApp* zeroObj)
88528852#endif // DEBUG
88538853
88548854// Static fields, methods.
8855- static UINT8 vnfOpAttribs[VNF_COUNT];
8855+
8856+ #define ValueNumFuncDef (vnf, arity, commute, knownNonNull, sharedStatic, extra ) \
8857+ static_assert ((arity) >= 0 || !(extra), "valuenumfuncs.h has EncodesExtraTypeArg==true and arity<0 for " #vnf);
8858+ #include " valuenumfuncs.h"
8859+
8860+ #ifdef FEATURE_HW_INTRINSICS
8861+
8862+ #define HARDWARE_INTRINSIC (isa, name, size, argCount, extra, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, category, flag ) \
8863+ static_assert ((size) != 0 || !(extra), \
8864+ "hwintrinsicslist<arch>.h has EncodesExtraTypeArg==true and size==0 for " #isa " " #name);
8865+ #if defined(TARGET_XARCH)
8866+ #include " hwintrinsiclistxarch.h"
8867+ #elif defined(TARGET_ARM64)
8868+ #include " hwintrinsiclistarm64.h"
8869+ #else
8870+ #error Unsupported platform
8871+ #endif
8872+
8873+ #endif // FEATURE_HW_INTRINSICS
8874+
8875+ /* static */ constexpr uint8_t ValueNumStore::GetOpAttribsForArity (genTreeOps oper, GenTreeOperKind kind)
8876+ {
8877+ return ((GenTree::StaticOperIs (oper, GT_SELECT) ? 3 : (((kind & GTK_UNOP) >> 1 ) | ((kind & GTK_BINOP) >> 1 )))
8878+ << VNFOA_ArityShift) &
8879+ VNFOA_ArityMask;
8880+ }
8881+
8882+ /* static */ constexpr uint8_t ValueNumStore::GetOpAttribsForGenTree (genTreeOps oper,
8883+ bool commute,
8884+ bool illegalAsVNFunc,
8885+ GenTreeOperKind kind)
8886+ {
8887+ return GetOpAttribsForArity (oper, kind) | (static_cast <uint8_t >(commute) << VNFOA_CommutativeShift) |
8888+ (static_cast <uint8_t >(illegalAsVNFunc) << VNFOA_IllegalGenTreeOpShift);
8889+ }
8890+
8891+ /* static */ constexpr uint8_t ValueNumStore::GetOpAttribsForFunc (int arity,
8892+ bool commute,
8893+ bool knownNonNull,
8894+ bool sharedStatic)
8895+ {
8896+ return (static_cast <uint8_t >(commute) << VNFOA_CommutativeShift) |
8897+ (static_cast <uint8_t >(knownNonNull) << VNFOA_KnownNonNullShift) |
8898+ (static_cast <uint8_t >(sharedStatic) << VNFOA_SharedStaticShift) |
8899+ ((static_cast <uint8_t >(arity & ~(arity >> 31 )) << VNFOA_ArityShift) & VNFOA_ArityMask);
8900+ }
8901+
8902+ const uint8_t ValueNumStore::s_vnfOpAttribs[VNF_COUNT] = {
8903+ #define GTNODE (en, st, cm, ivn, ok ) \
8904+ GetOpAttribsForGenTree (static_cast <genTreeOps>(GT_##en), cm, ivn, static_cast <GenTreeOperKind>(ok)),
8905+ #include " gtlist.h"
8906+
8907+ 0 , // VNF_Boundary
8908+
8909+ #define ValueNumFuncDef (vnf, arity, commute, knownNonNull, sharedStatic, extra ) \
8910+ GetOpAttribsForFunc ((arity) + static_cast <int >(extra), commute, knownNonNull, sharedStatic),
8911+ #include " valuenumfuncs.h"
8912+ };
8913+
88568914static genTreeOps genTreeOpsIllegalAsVNFunc[] = {GT_IND, // When we do heap memory.
88578915 GT_NULLCHECK, GT_QMARK, GT_COLON, GT_LOCKADD, GT_XADD, GT_XCHG,
88588916 GT_CMPXCHG, GT_LCLHEAP, GT_BOX, GT_XORR, GT_XAND, GT_STORE_DYN_BLK,
@@ -8869,15 +8927,10 @@ static genTreeOps genTreeOpsIllegalAsVNFunc[] = {GT_IND, // When we do heap memo
88698927 // These control-flow operations need no values.
88708928 GT_JTRUE, GT_RETURN, GT_SWITCH, GT_RETFILT, GT_CKFINITE};
88718929
8872- UINT8* ValueNumStore::s_vnfOpAttribs = nullptr ;
8873-
8874- void ValueNumStore::InitValueNumStoreStatics ()
8930+ void ValueNumStore::ValidateValueNumStoreStatics ()
88758931{
8876- // Make sure we have the constants right...
8877- assert (unsigned (VNFOA_Arity1) == (1 << VNFOA_ArityShift));
8878- assert (VNFOA_ArityMask == (VNFOA_MaxArity << VNFOA_ArityShift));
8879-
8880- s_vnfOpAttribs = &vnfOpAttribs[0 ];
8932+ #if DEBUG
8933+ uint8_t arr[VNF_COUNT] = {};
88818934 for (unsigned i = 0 ; i < GT_COUNT; i++)
88828935 {
88838936 genTreeOps gtOper = static_cast <genTreeOps>(i);
@@ -8895,37 +8948,36 @@ void ValueNumStore::InitValueNumStoreStatics()
88958948 arity = 3 ;
88968949 }
88978950
8898- vnfOpAttribs [i] |= ((arity << VNFOA_ArityShift) & VNFOA_ArityMask);
8951+ arr [i] |= ((arity << VNFOA_ArityShift) & VNFOA_ArityMask);
88998952
89008953 if (GenTree::OperIsCommutative (gtOper))
89018954 {
8902- vnfOpAttribs [i] |= VNFOA_Commutative;
8955+ arr [i] |= VNFOA_Commutative;
89038956 }
89048957 }
89058958
89068959 // I so wish this wasn't the best way to do this...
89078960
89088961 int vnfNum = VNF_Boundary + 1 ; // The macro definition below will update this after using it.
89098962
8910- #define ValueNumFuncDef (vnf, arity, commute, knownNonNull, sharedStatic ) \
8963+ #define ValueNumFuncDef (vnf, arity, commute, knownNonNull, sharedStatic, extra ) \
89118964 if (commute) \
8912- vnfOpAttribs [vnfNum] |= VNFOA_Commutative; \
8965+ arr [vnfNum] |= VNFOA_Commutative; \
89138966 if (knownNonNull) \
8914- vnfOpAttribs [vnfNum] |= VNFOA_KnownNonNull; \
8967+ arr [vnfNum] |= VNFOA_KnownNonNull; \
89158968 if (sharedStatic) \
8916- vnfOpAttribs [vnfNum] |= VNFOA_SharedStatic; \
8969+ arr [vnfNum] |= VNFOA_SharedStatic; \
89178970 if (arity > 0 ) \
8918- vnfOpAttribs [vnfNum] |= ((arity << VNFOA_ArityShift) & VNFOA_ArityMask); \
8971+ arr [vnfNum] |= ((arity << VNFOA_ArityShift) & VNFOA_ArityMask); \
89198972 vnfNum++;
89208973
89218974#include " valuenumfuncs.h"
8922- #undef ValueNumFuncDef
89238975
89248976 assert (vnfNum == VNF_COUNT);
89258977
89268978#define ValueNumFuncSetArity (vnfNum, arity ) \
8927- vnfOpAttribs [vnfNum] &= ~VNFOA_ArityMask; /* clear old arity value */ \
8928- vnfOpAttribs [vnfNum] |= ((arity << VNFOA_ArityShift) & VNFOA_ArityMask) /* set the new arity value */
8979+ arr [vnfNum] &= ~VNFOA_ArityMask; /* clear old arity value */ \
8980+ arr [vnfNum] |= ((arity << VNFOA_ArityShift) & VNFOA_ArityMask) /* set the new arity value */
89298981
89308982#ifdef FEATURE_HW_INTRINSICS
89318983
@@ -8939,7 +8991,7 @@ void ValueNumStore::InitValueNumStoreStatics()
89398991 // These HW_Intrinsic's have an extra VNF_SimdType arg.
89408992 //
89418993 VNFunc func = VNFunc (VNF_HWI_FIRST + (id - NI_HW_INTRINSIC_START - 1 ));
8942- unsigned oldArity = VNFuncArity ( func) ;
8994+ unsigned oldArity = (arr[ func] & VNFOA_ArityMask) >> VNFOA_ArityShift ;
89438995 unsigned newArity = oldArity + 1 ;
89448996
89458997 ValueNumFuncSetArity (func, newArity);
@@ -8948,7 +9000,7 @@ void ValueNumStore::InitValueNumStoreStatics()
89489000 if (HWIntrinsicInfo::IsCommutative (id))
89499001 {
89509002 VNFunc func = VNFunc (VNF_HWI_FIRST + (id - NI_HW_INTRINSIC_START - 1 ));
8951- vnfOpAttribs [func] |= VNFOA_Commutative;
9003+ arr [func] |= VNFOA_Commutative;
89529004 }
89539005 }
89549006
@@ -8958,17 +9010,23 @@ void ValueNumStore::InitValueNumStoreStatics()
89589010
89599011 for (unsigned i = 0 ; i < ArrLen (genTreeOpsIllegalAsVNFunc); i++)
89609012 {
8961- vnfOpAttribs [genTreeOpsIllegalAsVNFunc[i]] |= VNFOA_IllegalGenTreeOp;
9013+ arr [genTreeOpsIllegalAsVNFunc[i]] |= VNFOA_IllegalGenTreeOp;
89629014 }
9015+
9016+ assert (ArrLen (arr) == ArrLen (s_vnfOpAttribs));
9017+ for (unsigned i = 0 ; i < ArrLen (arr); i++)
9018+ {
9019+ assert (arr[i] == s_vnfOpAttribs[i]);
9020+ }
9021+ #endif // DEBUG
89639022}
89649023
89659024#ifdef DEBUG
89669025// Define the name array.
8967- #define ValueNumFuncDef (vnf, arity, commute, knownNonNull, sharedStatic ) #vnf,
9026+ #define ValueNumFuncDef (vnf, arity, commute, knownNonNull, sharedStatic, extra ) #vnf,
89689027
89699028const char * ValueNumStore::VNFuncNameArr[] = {
89709029#include " valuenumfuncs.h"
8971- #undef ValueNumFuncDef
89729030};
89739031
89749032/* static */ const char * ValueNumStore::VNFuncName (VNFunc vnf)
0 commit comments