diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index ef1c9780fe65992226b09ac528bcab7ffe6073ef..24606f0cf636661430b408f9b19beda5f009da62 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -11956,7 +11956,7 @@ void SMPFunction::InferTypes(bool FirstIter) { // Find counter variables (e.g. init to zero or small constant, then just add or subtract small // constant values. These cannot be POINTER and can be marked as NUMERIC. this->FindCounterVariables(); - } + } // end if (FirstIter) // Iterate until no more changes: set types in DEF and USE lists based on RTL // operators and the instruction category, SSA DEF-USE chains, etc. diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp index 0a6d2d12fcb8e2eb4074bd7b8af6cdb453d97f5b..4a56f203ffc26fa0ca533b957cac0d720ecfad0c 100644 --- a/src/base/SMPInstr.cpp +++ b/src/base/SMPInstr.cpp @@ -2001,11 +2001,13 @@ void SMPRTL::Dump(void) const { for (index = 0; index < this->RTCount; ++index) { this->RTvector[index]->Dump(); } - for (index = 0; index < this->ExtraKills.size(); ++index) { - SMP_msg(" KILL: "); - PrintOperand(this->ExtraKills.at(index)); + if (!this->ExtraKills.empty()) { + for (index = 0; index < this->ExtraKills.size(); ++index) { + SMP_msg(" KILL: "); + PrintOperand(this->ExtraKills.at(index)); + } + SMP_msg("\n"); } - SMP_msg("\n"); } return; } // end of SMPRTL::Dump() @@ -5007,8 +5009,8 @@ void SMPInstr::Dump(void) { this->RTL.Dump(); #if SMP_VERBOSE_DUMP this->PrintOperands(); -#endif SMP_msg("\n"); +#endif SMP_msg("DEFMemOp: "); PrintOperand(this->DEFMemOp); SMP_msg("\n"); SMP_msg("USEMemOp: "); PrintOperand(this->USEMemOp); SMP_msg("\n"); SMP_msg("booleans1: %d booleans2: %d booleans3: %d booleans4: %d booleans5: %d \n", this->booleans1, @@ -12662,11 +12664,14 @@ bool SMPInstr::InferTypes(void) { bool SafeFunc = this->BasicBlock->GetFunc()->IsSafe(); bool IsMemOp; #if SMP_VERBOSE_DEBUG_INFER_TYPES - DebugFlag |= (0 == strcmp("_start", this->BasicBlock->GetFunc()->GetFuncName())); + DebugFlag |= (0 == strcmp("ext_wmatch", this->BasicBlock->GetFunc()->GetFuncName())); +#if 1 if (DebugFlag) { - SMP_msg("opcode: %d TypeCategory: %d\n", opcode, TypeCategory); + SMP_msg("InstAddr: %llx opcode: %d TypeCategory: %d\n", + (uint64_t) this->GetAddr(), opcode, TypeCategory); } +#endif #endif // If we are already finished with all types, return false. @@ -12691,8 +12696,8 @@ bool SMPInstr::InferTypes(void) { bool CallInst = ((DFAType == CALL) || (DFAType == INDIR_CALL) || this->IsTailCall()); #if SMP_VERBOSE_DEBUG_INFER_TYPES if (DebugFlag) { - SMP_msg("DFAType: %d CategoryInferenceComplete: %d\n", - DFAType, this->IsCategoryInferenceComplete()); + SMP_msg("%llx DFAType: %d CategoryInferenceComplete: %d\n", + (uint64_t) this->GetAddr(), DFAType, this->IsCategoryInferenceComplete()); } #endif @@ -12981,21 +12986,21 @@ bool SMPInstr::InferOperatorType(SMPRegTransfer *CurrRT) { set<DefOrUse, LessDefUse>::iterator RightUse; SMPOperandType LeftType = UNINIT; SMPOperandType RightType = UNINIT; - SMPOperandType OperType = UNINIT; + SMPOperandType OperType = CurrRT->GetOperatorType(); STARSOpndTypePtr UseOp = nullptr, DefOp = nullptr, LeftOp = nullptr, RightOp = nullptr; SMPoperator CurrOp = CurrRT->GetOperator(); bool TypeInferenceFinished = false; #if SMP_VERBOSE_DEBUG_INFER_TYPES bool DebugFlag = false; #if 1 - DebugFlag |= (0 == strcmp("_start", this->BasicBlock->GetFunc()->GetFuncName())); + DebugFlag |= (0 == strcmp("ext_wmatch", this->BasicBlock->GetFunc()->GetFuncName())); #endif DebugFlag = DebugFlag || ((this->GetAddr() == 0x806453b) || (this->GetAddr() == 0x806453e)); #endif #if SMP_VERBOSE_DEBUG_INFER_TYPES if (DebugFlag) { - SMP_msg("Entered InferOperatorType for CurrOp: %d at %x\n", CurrOp, this->GetAddr()); + SMP_msg("Entered InferOperatorType for CurrOp: %s at %llx\n", OperatorText[CurrOp], (uint64_t) this->GetAddr()); } #endif @@ -13030,12 +13035,6 @@ bool SMPInstr::InferOperatorType(SMPRegTransfer *CurrRT) { break; case SMP_INPUT: // input from port - if (UNINIT == CurrRT->GetOperatorType()) { - CurrRT->SetOperatorType(NUMERIC, this); - updated = true; - } - break; - case SMP_OUTPUT: // output to port if (UNINIT == CurrRT->GetOperatorType()) { CurrRT->SetOperatorType(NUMERIC, this); @@ -13084,6 +13083,37 @@ bool SMPInstr::InferOperatorType(SMPRegTransfer *CurrRT) { } break; +#if 0 + case SMP_S_COMPARE: // signed compare (subtraction-based) + case SMP_U_COMPARE: // unsigned compare (AND-based) + // not much to do; perhaps propagate LeftType or RightType to the other? + LeftOp = CurrRT->GetLeftOperand(); + RightOp = CurrRT->GetRightOperand(); + assert((nullptr != LeftOp) && (!LeftOp->IsVoidOp())); + assert((nullptr != RightOp) && (!RightOp->IsVoidOp())); + LeftUse = this->FindUse(LeftOp); + RightUse = this->FindUse(RightOp); + if ((LeftUse != this->GetLastUse()) && (RightUse != this->GetLastUse())) { + LeftType = LeftUse->GetType(); + RightType = RightUse->GetType(); + if (((UNINIT == LeftType) || (UNINIT == RightType)) && (LeftType != RightType)) { + // One type is UNINIT, the other is not. Propagate type to the UNINIT side. + if (UNINIT == LeftType) { + this->SetUseType(LeftOp, RightType); + } + else { + this->SetUseType(RightOp, LeftType); + } + updated = true; + } + if ((LeftType == RightType) && (UNINIT == OperType) && (UNINIT != LeftType)) { + CurrRT->SetOperatorType(LeftType, this); + updated = true; + } + } + break; +#endif + case SMP_SIGN_EXTEND: case SMP_ZERO_EXTEND: case SMP_U_LEFT_SHIFT: // unsigned left shift @@ -13101,8 +13131,10 @@ bool SMPInstr::InferOperatorType(SMPRegTransfer *CurrRT) { case SMP_U_REMAINDER: case SMP_BITWISE_XOR: case SMP_BITWISE_AND_NOT: +#if 1 case SMP_S_COMPARE: // signed compare (subtraction-based) case SMP_U_COMPARE: // unsigned compare (AND-based) +#endif case SMP_GENERAL_COMPARE: case SMP_LESS_THAN: // boolean test operators case SMP_GREATER_THAN: @@ -13583,9 +13615,11 @@ bool SMPInstr::InferOperatorType(SMPRegTransfer *CurrRT) { // can be typed. if (UNINIT == RightType) { if (OperPointer) { +#if 0 // PTR := PTR - ?? ==> ?? is NUMERIC Why? ?? could be PTROFFSET CurrRT->GetRightTree()->SetOperatorType(NUMERIC, this); updated = true; +#endif updated |= this->InferOperatorType(CurrRT->GetRightTree()); } else if (OperType == PTROFFSET) { @@ -13879,6 +13913,12 @@ bool SMPInstr::InferOperatorType(SMPRegTransfer *CurrRT) { if (TypeInferenceFinished) { CurrRT->SetTypeInferenceComplete(); } +#if SMP_VERBOSE_DEBUG_INFER_TYPES + if (updated && DebugFlag) { + SMP_msg("INFO: Types updated at %llx Left: %d Operator: %d Right: %d\n", (uint64_t) this->GetAddr(), + LeftType, OperType, RightType); + } +#endif return updated; } // end of SMPInstr::InferOperatorType()