diff --git a/SMPDataFlowAnalysis.cpp b/SMPDataFlowAnalysis.cpp index b52a49de27cc5ec44471d12c19b7f095f3b8cb6b..cf9a53a72ca817b0952603af29c9cf1a780b5522 100644 --- a/SMPDataFlowAnalysis.cpp +++ b/SMPDataFlowAnalysis.cpp @@ -421,6 +421,30 @@ bool MDKnownOperandType(op_t TempOp) { return GoodOpType; } +// Meet function over any two types in the type lattice. +SMPOperandType SMPTypeMeet(SMPOperandType Type1, SMPOperandType Type2) { + SMPOperandType MeetType = UNKNOWN; + bool ProfDerived = IsProfDerived(Type1) || IsProfDerived(Type2); + if (IsEqType(UNINIT, Type1)) + MeetType = Type2; + else if (IsEqType(UNINIT, Type2) || IsEqType(Type1, Type2) + || IsUnknown(Type1)) + MeetType = Type1; + else if (IsNumeric(Type1)) { + if (IsNumeric(Type2)) // one is NUMERIC, one is CODEPTR + MeetType = NUMERIC; + else if (IsDataPtr(Type2) || IsUnknown(Type2)) + MeetType = UNKNOWN; + } + else if (IsDataPtr(Type1)) { + if (IsDataPtr(Type2)) // two different POINTER subtypes + MeetType = POINTER; + else if (IsNumeric(Type2) || IsUnknown(Type2)) + MeetType = UNKNOWN; + } + return MeetType; +} // end of SMPTypeMeet() + // ***************************************************************** // Class DefOrUse // ***************************************************************** diff --git a/SMPDataFlowAnalysis.h b/SMPDataFlowAnalysis.h index 098a1deb71eefd12448a3907bb1954c08aaa6092..90403ebec58fc3dbcf00244349a42d326dbda47e 100644 --- a/SMPDataFlowAnalysis.h +++ b/SMPDataFlowAnalysis.h @@ -174,6 +174,9 @@ enum SMPOperandType { // What type is a given register or memory operand? // Make OpType into its equivalent profile derived type. #define MakeProfDerived(OpType) ((SMPOperandType)(OpType | PROF_BASE)) +// Meet function over any two types in the type lattice. +SMPOperandType SMPTypeMeet(SMPOperandType Type1, SMPOperandType Type2); + // Enumeration to keep track of whether the metadata for each DEF is // used, unused, redundant, etc. enum SMPMetadataType {