From 6c5b3d870dbd325d37ce6021a71d5fff188e056a Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Tue, 8 Apr 2008 22:55:05 +0000
Subject: [PATCH] Force NUMERIC type for FP, MMX, and XMM regs.

---
 SMPInstr.cpp | 44 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 5 deletions(-)

diff --git a/SMPInstr.cpp b/SMPInstr.cpp
index a783f102..1946d541 100644
--- a/SMPInstr.cpp
+++ b/SMPInstr.cpp
@@ -942,8 +942,8 @@ void SMPInstr::SetImmedTypes(bool UseFP) {
 			}
 		}
 		else if (o_reg == UseOp.type) {
-			if (UseOp.is_reg(X86_FLAGS_REG) || (o_fpreg == UseOp.type)) {
-				if (DebugFlag) msg("Setting reg to NUMERIC\n");
+			if (UseOp.is_reg(X86_FLAGS_REG)) {
+				if (DebugFlag) msg("Setting flags reg to NUMERIC\n");
 				CurrUse = this->SetUseType(UseOp, NUMERIC);
 			}
 #if 1
@@ -953,6 +953,16 @@ void SMPInstr::SetImmedTypes(bool UseFP) {
 			}
 #endif
 		}
+#if 0  // could these registers have pointers in them?
+		else if ((o_trreg == UseOp.type) ||(o_dbreg == UseOp.type) || (o_crreg == UseOp.type)) {
+			if (DebugFlag) msg("Setting special reg to NUMERIC\n");
+			CurrUse = this->SetUseType(UseOp, NUMERIC);
+		}
+#endif
+		else if ((o_fpreg == UseOp.type) || (o_mmxreg == UseOp.type) || (o_xmmreg == UseOp.type)) {
+			if (DebugFlag) msg("Setting floating point reg to NUMERIC\n");
+			CurrUse = this->SetUseType(UseOp, NUMERIC);
+		}
 		++CurrUse;
 	} // end while all USEs via CurrUse
 
@@ -966,8 +976,8 @@ void SMPInstr::SetImmedTypes(bool UseFP) {
 		}
 		if (DebugFlag) msg("FuncName: %s\n", this->BasicBlock->GetFunc()->GetFuncName());
 		if (o_reg == DefOp.type) {
-			if (DefOp.is_reg(X86_FLAGS_REG) || (o_fpreg == DefOp.type)) {
-				if (DebugFlag) msg("Setting reg to NUMERIC\n");
+			if (DefOp.is_reg(X86_FLAGS_REG)) {
+				if (DebugFlag) msg("Setting flags reg DEF to NUMERIC\n");
 				CurrDef = this->SetDefType(DefOp, NUMERIC);
 				if (this->BasicBlock->IsLocalName(DefOp)) {
 					(void) this->BasicBlock->PropagateLocalDefType(DefOp, NUMERIC, this->GetAddr());
@@ -979,7 +989,7 @@ void SMPInstr::SetImmedTypes(bool UseFP) {
 			}
 #if 1
 			else if (DefOp.is_reg(R_sp) || (DefOp.is_reg(R_bp) && UseFP)) {
-				if (DebugFlag) msg("Setting reg to STACKPTR\n");
+				if (DebugFlag) msg("Setting reg DEF to STACKPTR\n");
 				CurrDef = this->SetDefType(DefOp, STACKPTR);
 				assert(CurrDef != this->Defs.GetLastRef());
 				SSANum = CurrDef->GetSSANum();
@@ -998,6 +1008,30 @@ void SMPInstr::SetImmedTypes(bool UseFP) {
 			}
 #endif
 		}
+		else if ((o_fpreg == DefOp.type) || (o_mmxreg == DefOp.type) || (o_xmmreg == DefOp.type)) {
+			if (DebugFlag) msg("Setting floating point reg DEF to NUMERIC\n");
+			CurrDef = this->SetDefType(DefOp, NUMERIC);
+			if (this->BasicBlock->IsLocalName(DefOp)) {
+				(void) this->BasicBlock->PropagateLocalDefType(DefOp, NUMERIC, this->GetAddr());
+			}
+			else { // global name
+				this->BasicBlock->GetFunc()->ResetProcessedBlocks(); // set Processed to false
+				(void) this->BasicBlock->PropagateGlobalDefType(DefOp, NUMERIC, CurrDef->GetSSANum());
+			}
+		}
+#if 0  // could these registers have pointers in them?
+		else if ((o_trreg == DefOp.type) || (o_dbreg == DefOp.type) || (o_crreg == DefOp.type)) {
+			if (DebugFlag) msg("Setting special reg DEF to NUMERIC\n");
+			CurrDef = this->SetDefType(DefOp, NUMERIC);
+			if (this->BasicBlock->IsLocalName(DefOp)) {
+				(void) this->BasicBlock->PropagateLocalDefType(DefOp, NUMERIC, this->GetAddr());
+			}
+			else { // global name
+				this->BasicBlock->GetFunc()->ResetProcessedBlocks(); // set Processed to false
+				(void) this->BasicBlock->PropagateGlobalDefType(DefOp, NUMERIC, CurrDef->GetSSANum());
+			}
+		}
+#endif	
 		++CurrDef;
 	} // end while all DEFs via CurrDef
 	return;
-- 
GitLab