From 5791257835c53c3583af4403da81fd61e58a660b Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Thu, 29 May 2008 02:17:58 +0000
Subject: [PATCH] Add function SMPTypeMeet().

---
 SMPDataFlowAnalysis.cpp | 24 ++++++++++++++++++++++++
 SMPDataFlowAnalysis.h   |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/SMPDataFlowAnalysis.cpp b/SMPDataFlowAnalysis.cpp
index b52a49de..cf9a53a7 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 098a1deb..90403ebe 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 {
-- 
GitLab