Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • opensrc/SMPStaticAnalyzer
1 result
Show changes
Commits on Source (2)
......@@ -271,8 +271,8 @@ public:
STARSOpndTypePtr GetRightOperand(void) const;
STARSOpndTypePtr GetLeftOperandNoNorm(void) const { return LeftOperand; }; // don't normalize stack ops; for SPARK translation
STARSOpndTypePtr GetRightOperandNoNorm(void) const { return RightOperand; }; // don't normalize stack ops; for SPARK translation
inline const STARSOpndTypePtr &GetConstLeftOperandNoNorm(void) { return LeftOperand; };
inline const STARSOpndTypePtr &GetConstRightOperandNoNorm(void) { return RightOperand; };
inline const STARSOpndTypePtr &GetConstLeftOperandNoNorm(void) const { return LeftOperand; };
inline const STARSOpndTypePtr &GetConstRightOperandNoNorm(void) const { return RightOperand; };
inline SMPRegTransfer *GetRightTree(void) const { return RightRT; };
inline SMPGuard *GetGuard(void) const { return Guard; };
inline SMPInstr *GetParentInst(void) const { return ParentInst; };
......@@ -337,15 +337,20 @@ public:
// Constructors and destructors.
SMPRTL();
~SMPRTL();
// Get methods
inline std::size_t GetCount(void) const { return RTCount; };
SMPRegTransfer *GetRT(std::size_t index) const;
// Set methods
void push_back(SMPRegTransfer *NewEffect);
// Printing methods
void Dump(void) const;
// Analysis methods.
STARS_sval_t TotalStackPointerAlteration(bool IsLeaveInstr, STARS_sval_t IncomingDelta, STARS_sval_t FramePtrDelta); // sum across all RTs in RTL
// Public data for ease of use.
std::vector<STARSOpndTypePtr> ExtraKills; // kills other than left operands
private:
......@@ -492,7 +497,7 @@ private:
bool ElevateLeftSide(STARSExpression *ParentExpr); // Expr simplifies to LeftExpr or LeftOperand, so raise it into ParentExpr; return true if LeftOperand
bool ExpandOperand(std::size_t LoopIndex, bool Left, bool StopOnIV, STARS_ea_t UseAddr, bool StopOnLoopBoundary, bool RecordLoopRegs, bool InitCase,
std::set<int> &LoopRegHashes, bool &StoppedOnIV, bool &changed, std::set<STARS_ea_t> &StackPtrCopySet, int &DepthCounter); // return false if expansion is forced to stop before constant DEF or InArg DEF or IndVAr.
bool ExpandOperandHelper(STARS_ea_t DefAddr, STARSOpndTypePtr &SearchOp, std::size_t LoopIndex, bool Left, bool StopOnIV, bool StopOnLoopBoundary, bool RecordLoopRegs, bool InitCase,
bool ExpandOperandHelper(STARS_ea_t DefAddr, const STARSOpndTypePtr &SearchOp, std::size_t LoopIndex, bool Left, bool StopOnIV, bool StopOnLoopBoundary, bool RecordLoopRegs, bool InitCase,
std::set<int> &LoopRegHashes, bool &StoppedOnIV, bool &changed, std::set<STARS_ea_t> &StackPtrCopySet, int &DepthCounter); // recursive helper for ExpandOperand()
void PrintSPARKArgLocationStringsHelper(FILE *OutputFile, bool LoopInvariant, std::size_t &OutputCount, const STARSOpndTypePtr &LeafOp, STARS_ea_t PreLoopDefAddr);
......@@ -648,7 +653,7 @@ public:
inline STARS_InstructionID_t GetInstID(void) const { return STARS_ID; };
inline uint16_t GetIDAOpcode(void) const { return STARSInstPtr->GetIDAOpcode(); };
inline STARS_ea_t GetCallTarget(void) const { return IsFixedCallJump() ? GetJumpTarget() : CallTarget; };
inline STARSOpndTypePtr GetControlFlowTarget(void) const { return RTL.GetRT(0)->GetRightOperand(); };
inline const STARSOpndTypePtr &GetControlFlowTarget(void) const { return RTL.GetRT(0)->GetConstRightOperandNoNorm(); };
char *GetDisasm(void) const;
inline SMPBasicBlock *GetBlock(void) const { return BasicBlock; };
inline std::set<DefOrUse, LessDefUse>::iterator GetFirstUse(void) { return Uses.GetFirstRef(); };
......@@ -936,7 +941,7 @@ public:
void EmitSPARKAda(FILE *OutFile); // Emit SPARK-Ada translation of instruction
// Analysis methods
STARSOpndTypePtr GetSourceOnlyOperand(void); // return non-flags-reg non-dest source operand
STARSOpndTypePtr GetSourceOnlyOperand(void) const; // return non-flags-reg non-dest source operand
std::set<DefOrUse, LessDefUse>::iterator GetPointerAddressReg(const STARSOpndTypePtr &MemOp);
bool FillCmd(void); // Fetch "cmd" instruction description from disassembler.
void Analyze(void); // Fill in basic data for instruction.
......
......@@ -593,7 +593,7 @@ void SMPBasicBlock::EmitSPARKAdaForExpression(FILE *BodyFile) {
CompareRT = CompareRT->GetRightTree();
SMPoperator CompareOperator = CompareRT->GetOperator();
bool SignedCompareCase = (SMP_S_COMPARE == CompareOperator);
bool UnsignedSelfCompareCase = ((SMP_U_COMPARE == CompareOperator) && IsEqOp(CompareRT->GetRightOperandNoNorm(), CompareRT->GetLeftOperandNoNorm()));
bool UnsignedSelfCompareCase = ((SMP_U_COMPARE == CompareOperator) && IsEqOp(CompareRT->GetConstRightOperandNoNorm(), CompareRT->GetConstLeftOperandNoNorm()));
// Emit the SPARK Ada for the left operand of the comparison.
STARSOpndTypePtr LeftOp = CompareRT->GetLeftOperand();
......@@ -697,7 +697,7 @@ bool SMPBasicBlock::EmitSPARKAdaForExprUse(FILE *BodyFile, vector<SMPInstr *>::c
}
else {
SMPRegTransfer *DefRT = CurrInst->GetRT(0);
assert(IsEqOp(DefRT->GetLeftOperandNoNorm(), UseOp));
assert(IsEqOp(DefRT->GetConstLeftOperandNoNorm(), UseOp));
assert(SMP_ASSIGN == DefRT->GetOperator());
assert(DefRT->HasRightSubTree());
DefRT = DefRT->GetRightTree();
......@@ -705,7 +705,7 @@ bool SMPBasicBlock::EmitSPARKAdaForExprUse(FILE *BodyFile, vector<SMPInstr *>::c
string OperatorString;
bool OperatorIsProcCall = false;
bool PrefixUnaryOperator = false;
bool ConstFollows = (!DefRT->HasRightSubTree()) && DefRT->GetRightOperandNoNorm()->IsImmedOp();
bool ConstFollows = (!DefRT->HasRightSubTree()) && DefRT->GetConstRightOperandNoNorm()->IsImmedOp();
PrintSPARKAdaOperator(DefRT->GetOperator(), OperatorString, OperatorIsProcCall, PrefixUnaryOperator, ConstFollows);
if (OperatorIsProcCall) {
SMP_fprintf(BodyFile, "ERROR ");
......@@ -733,7 +733,7 @@ bool SMPBasicBlock::EmitSPARKAdaForExprUse(FILE *BodyFile, vector<SMPInstr *>::c
}
else {
SMP_fprintf(BodyFile, " %s ", OperatorString.c_str());
STARSOpndTypePtr DefRightOp = DefRT->GetRightOperandNoNorm();
const STARSOpndTypePtr DefRightOp = DefRT->GetConstRightOperandNoNorm();
// NOTE: Should handle RightTree possibility.
if (DefRightOp->IsImmedOp()) {
CurrInst->PrintSPARKAdaOperand(DefRightOp, BodyFile, false, false, true, false);
......
......@@ -6205,7 +6205,7 @@ void SMPFunction::AuditSCCPForIndirectTargets(void) {
SMPInstr *CurrInst = (*InstIter);
SMPitype CurrDataFlow = CurrInst->GetDataFlowType();
if (((CurrDataFlow == INDIR_CALL) || (CurrDataFlow == INDIR_JUMP)) && (!CurrInst->IsInterruptCall())) {
STARSOpndTypePtr TargetOp = CurrInst->GetControlFlowTarget();
const STARSOpndTypePtr &TargetOp = CurrInst->GetControlFlowTarget();
STARSOpndTypePtr SearchOp = CloneIfSubwordReg(TargetOp);
CanonicalizeOpnd(SearchOp);
if (TargetOp->IsRegOp()) { // can only find SCCP constant values for regs
......@@ -13248,8 +13248,11 @@ void SMPFunction::AnalyzeLoopIterations(void) {
int InstSize = MemWriteInst->GetSize();
STARS_uval_t LowerBoundVal = MemWriteLowerBoundExpanded->GetConstLeftOperand()->GetImmedValue();
STARS_uval_t UpperBoundVal = (STARS_uval_t) 0xfffffffffffffffe; // Code for unknown limit value
if (LimitSuccess && (nullptr != MemWriteUpperBoundExpanded->GetConstLeftOperand()))
if (LimitSuccess
&& (nullptr != MemWriteUpperBoundExpanded->GetConstLeftOperand())
&& (MemWriteUpperBoundExpanded->GetConstLeftOperand()->IsImmedOp())) {
UpperBoundVal = MemWriteUpperBoundExpanded->GetConstLeftOperand()->GetImmedValue();
}
FILE *InfoAnnotFile = global_STARS_program->GetInfoAnnotFile();
SMP_fprintf(InfoAnnotFile, "%18llx %6zu INSTR STATICMEMWRITE MIN ", (uint64_t)MemWriteAddr, InstSize);
if (LowerBoundVal == UpperBoundVal) {
......
......@@ -1362,16 +1362,11 @@ bool SMPRegTransfer::OperandTransfersHelper(const STARSOpndTypePtr &UseOp) const
// Does RTL show LeftOp has smaller bitwidth than the right hand side operands?
bool SMPRegTransfer::IsTruncatedWidthRTL(std::size_t &LeftBitWidth, std::size_t &RightBitWidth) const {
bool TruncatedWidth = false;
STARSOpndTypePtr LeftOp = this->GetLeftOperandNoNorm();
const STARSOpndTypePtr LeftOp = this->GetConstLeftOperandNoNorm();
std::size_t LeftOpByteWidth = (std::size_t) LeftOp->GetByteWidth();
std::size_t RightOpByteWidth = 0;
STARSOpndTypePtr RightOp = nullptr;
if (this->HasRightSubTree()) {
RightOp = this->GetRightTree()->GetLeftOperandNoNorm();
}
else {
RightOp = this->GetRightOperandNoNorm();
}
const STARSOpndTypePtr RightOp = (this->HasRightSubTree()) ? this->GetRightTree()->GetConstLeftOperandNoNorm()
: this->GetConstRightOperandNoNorm();
if (nullptr != RightOp) {
RightOpByteWidth = RightOp->GetByteWidth();
}
......@@ -1389,17 +1384,12 @@ bool SMPRegTransfer::IsTruncatedWidthRTL(std::size_t &LeftBitWidth, std::size_t
// Does RTL show LeftOp has larger bitwidth than the right hand side operands?
bool SMPRegTransfer::IsExpandedWidthRTL(std::size_t &LeftBitWidth, std::size_t &RightBitWidth) const {
bool ExpandedWidth = false;
STARSOpndTypePtr LeftOp = this->GetLeftOperandNoNorm();
const STARSOpndTypePtr LeftOp = this->GetConstLeftOperandNoNorm();
std::size_t LeftOpByteWidth = (std::size_t) LeftOp->GetByteWidth();
if (LeftOpByteWidth > global_STARS_program->GetSTARS_ISA_Bytewidth()) { // Forget it unless LeftOp is wide, e.g. FP stack.
// Search right hand side for narrower operands.
STARSOpndTypePtr RightOp = nullptr;
if (this->HasRightSubTree()) {
RightOp = this->GetRightTree()->GetLeftOperandNoNorm();
}
else {
RightOp = this->GetRightOperandNoNorm();
}
const STARSOpndTypePtr RightOp = (this->HasRightSubTree()) ? this->GetRightTree()->GetConstLeftOperandNoNorm()
: this->GetConstRightOperandNoNorm();
size_t RightOpByteWidth = RightOp->GetByteWidth();
if (nullptr != RightOp) {
ExpandedWidth = ((RightOpByteWidth < LeftOpByteWidth) && (RightOp->IsRegOp() || RightOp->IsMemOp() || RightOp->IsFloatingPointRegOp()));
......@@ -1413,7 +1403,7 @@ bool SMPRegTransfer::IsExpandedWidthRTL(std::size_t &LeftBitWidth, std::size_t &
 
// fix machine-specific FP reg encodings
void SMPRegTransfer::MDFixFloatingPointRTL(void) {
STARSOpndTypePtr LeftOp = this->GetLeftOperandNoNorm();
const STARSOpndTypePtr LeftOp = this->GetConstLeftOperandNoNorm();
if ((nullptr != LeftOp) && LeftOp->IsFloatingPointRegOp()) {
STARS_regnum_t FPRegNum = LeftOp->GetReg();
if (FPRegNum < STARS_x86_R_st0) {
......@@ -1427,7 +1417,7 @@ void SMPRegTransfer::MDFixFloatingPointRTL(void) {
this->GetRightTree()->MDFixFloatingPointRTL(); // recurse into right tree
}
else {
STARSOpndTypePtr RightOp = this->GetRightOperandNoNorm();
const STARSOpndTypePtr RightOp = this->GetConstRightOperandNoNorm();
if ((nullptr != RightOp) && RightOp->IsFloatingPointRegOp()) {
STARS_regnum_t FPRegNum = RightOp->GetReg();
if (FPRegNum < STARS_x86_R_st0) {
......@@ -1778,7 +1768,7 @@ bool SMPRegTransfer::IsStackPtrUsedInRT(bool UseFP) const {
// Is RT a move of a const or subreg into a subreg?
bool SMPRegTransfer::IsSubregMove(void) const {
bool SubregMove = false;
STARSOpndTypePtr LeftOp = this->GetLeftOperandNoNorm();
const STARSOpndTypePtr LeftOp = this->GetConstLeftOperandNoNorm();
if ((nullptr != LeftOp) && (LeftOp->IsRegOp())) {
bool SubregDest = (LeftOp->GetByteWidth() < 4); // move into EAX zeroes out upper RAX, but move into AX does not.
SubregMove = (SubregDest && (!this->HasRightSubTree()) && (SMP_ASSIGN == this->GetOperator()));
......@@ -1820,14 +1810,14 @@ bool SMPRegTransfer::RightTreeNeedsWidthCast(FILE *OutFile, std::size_t LeftBitW
assert(NULL != RightRT);
// Initial cases: zero-extension and sign-extension; add more cases as required
if (SMP_ZERO_EXTEND == RightRT->GetOperator()) {
STARSOpndTypePtr RightLeftOp = RightRT->GetLeftOperandNoNorm();
const STARSOpndTypePtr RightLeftOp = RightRT->GetConstLeftOperandNoNorm();
RightBitWidth = RightLeftOp->GetByteWidth() * 8;
if (LeftBitWidth != RightBitWidth) {
SMP_fprintf(OutFile, "Unsigned%u(", LeftBitWidth);
}
}
else if (SMP_SIGN_EXTEND == RightRT->GetOperator()) {
STARSOpndTypePtr RightLeftOp = RightRT->GetLeftOperandNoNorm();
const STARSOpndTypePtr RightLeftOp = RightRT->GetConstLeftOperandNoNorm();
RightBitWidth = RightLeftOp->GetByteWidth() * 8;
if (LeftBitWidth != RightBitWidth) {
SMP_fprintf(OutFile, "X86.SignExtend%uTo%u(", RightBitWidth, LeftBitWidth);
......@@ -1849,8 +1839,8 @@ bool SMPRegTransfer::IsSPARKAdaNop(void) const {
SPARKNop = this->GetRightTree()->IsSPARKAdaNop();
}
if (!SPARKNop && (SMP_ASSIGN == CurrOperator)) {
STARSOpndTypePtr LeftOp = this->GetLeftOperandNoNorm();
STARSOpndTypePtr RightOp = this->GetRightOperandNoNorm();
const STARSOpndTypePtr LeftOp = this->GetConstLeftOperandNoNorm();
const STARSOpndTypePtr RightOp = this->GetConstRightOperandNoNorm();
if ((nullptr != LeftOp) && (nullptr != RightOp) && LeftOp->IsFloatingPointRegOp() && RightOp->IsFloatingPointRegOp()) {
SPARKNop = (LeftOp->GetReg() == RightOp->GetReg()); // e.g. fld st just duplicates top of stack
}
......@@ -1910,7 +1900,7 @@ void SMPRegTransfer::EmitSPARKAdaForRHS(FILE *OutFile, bool RecursiveCall) const
}
if (this->HasRightSubTree()) { // NOTE: Handle operators like Shift_right() !!!!****!!!!
SMPRegTransfer *RightRT = this->GetRightTree();
size_t LeftByteWidth = this->GetLeftOperandNoNorm()->GetByteWidth();
size_t LeftByteWidth = this->GetConstLeftOperandNoNorm()->GetByteWidth();
LeftOpBitWidth = LeftByteWidth * 8;
bool ShortLeftWidth = (ISA_ByteWidth > LeftByteWidth);
 
......@@ -1921,9 +1911,9 @@ void SMPRegTransfer::EmitSPARKAdaForRHS(FILE *OutFile, bool RecursiveCall) const
bool PrefixUnaryOperator = false;
SMP_fprintf(OutFile, "(");
SMPoperator CurrOper = RightRT->GetOperator();
bool ConstFollows = (!RightRT->HasRightSubTree()) && RightRT->GetRightOperandNoNorm()->IsImmedOp();
bool ConstFollows = (!RightRT->HasRightSubTree()) && RightRT->GetConstRightOperandNoNorm()->IsImmedOp();
PrintSPARKAdaOperator(CurrOper, OperatorString, OperatorIsProcCall, PrefixUnaryOperator, ConstFollows);
STARSOpndTypePtr LeftOp = RightRT->GetLeftOperandNoNorm();
const STARSOpndTypePtr LeftOp = RightRT->GetConstLeftOperandNoNorm();
if (!OperatorIsProcCall) {
if (!PrefixUnaryOperator) {
this->ParentInst->PrintSPARKAdaOperand(LeftOp, OutFile, false, UseFP, true, false);
......@@ -1953,7 +1943,7 @@ void SMPRegTransfer::EmitSPARKAdaForRHS(FILE *OutFile, bool RecursiveCall) const
SMP_fprintf(OutFile, ")");
}
else {
STARSOpndTypePtr RightOp = this->GetRightOperandNoNorm();
const STARSOpndTypePtr RightOp = this->GetConstRightOperandNoNorm();
this->ParentInst->PrintSPARKAdaOperand(RightOp, OutFile, false, UseFP, true, false);
}
if (!RecursiveCall && Truncated) {
......@@ -1965,7 +1955,7 @@ void SMPRegTransfer::EmitSPARKAdaForRHS(FILE *OutFile, bool RecursiveCall) const
 
// Emit SPARK-Ada translation of RT
void SMPRegTransfer::EmitSPARKAda(FILE *OutFile) {
STARSOpndTypePtr LeftOp = this->GetLeftOperandNoNorm();
const STARSOpndTypePtr LeftOp = this->GetConstLeftOperandNoNorm();
if ((nullptr == LeftOp) || this->IsSPARKAdaNop()) {
PrintSPARKIndentTabs(OutFile);
SMP_fprintf(OutFile, "null;\n"); // Ada no-op
......@@ -4081,7 +4071,7 @@ bool STARSExpression::ExpandOperand(std::size_t LoopIndex, bool Left, bool StopO
} // end of STARSExpression::ExpandOperand()
 
// recursive helper for ExpandOperand()
bool STARSExpression::ExpandOperandHelper(STARS_ea_t DefAddr, STARSOpndTypePtr &SearchOp, size_t LoopIndex, bool Left, bool StopOnIV, bool StopOnLoopBoundary, bool RecordLoopRegs, bool InitCase,
bool STARSExpression::ExpandOperandHelper(STARS_ea_t DefAddr, const STARSOpndTypePtr &SearchOp, size_t LoopIndex, bool Left, bool StopOnIV, bool StopOnLoopBoundary, bool RecordLoopRegs, bool InitCase,
set<int> &LoopRegHashes, bool &StoppedOnIV, bool &changed, set<STARS_ea_t> &StackPtrCopySet, int &DepthCounter) {
bool success = true;
bool UseFP = this->GetParentFunc()->UsesFramePointer();
......@@ -4252,15 +4242,15 @@ bool STARSExpression::ExpandOperandHelper(STARS_ea_t DefAddr, STARSOpndTypePtr &
SMP_msg("\nINFO: SPARK: ExpandOperandHelper() hit non-DataFlow UseOp at %llx\n", (uint64_t) DefAddr);
}
else {
STARSOpndTypePtr SearchOp = CloneIfSubwordReg(UseOp);
CanonicalizeOpnd(SearchOp);
STARSOpndTypePtr SearchOp2 = CloneIfSubwordReg(UseOp);
CanonicalizeOpnd(SearchOp2);
if (!ConstUse) {
STARSDefUseIter UseIter = DefInst->FindUse(SearchOp);
STARSDefUseIter UseIter = DefInst->FindUse(SearchOp2);
assert(UseIter != DefInst->GetLastUse());
int UseSSANum = UseIter->GetSSANum();
// Until we have alias analysis, cannot trace non-stack memory
// operands, which will not be SSA numbered.
if (SearchOp->IsMemOp() && (-1 == UseSSANum)) {
if (SearchOp2->IsMemOp() && (-1 == UseSSANum)) {
--DepthCounter;
return true;
}
......@@ -4271,7 +4261,7 @@ bool STARSExpression::ExpandOperandHelper(STARS_ea_t DefAddr, STARSOpndTypePtr &
this->SetRightSSANum(UseSSANum);
this->ParentInst = DefInst;
if (!WentBeforeLoop && RecordLoopRegs && UseOp->IsRegOp()) {
int RegHash = HashGlobalNameAndSSA(SearchOp, UseSSANum);
int RegHash = HashGlobalNameAndSSA(SearchOp2, UseSSANum);
pair<set<int>::iterator, bool> InsertResult = LoopRegHashes.insert(RegHash);
#if 1
if (InsertResult.second) {
......@@ -5701,8 +5691,8 @@ void SMPInstr::MDEmitSPARKAdaCompareOrTest(FILE *OutFile) {
SMPRegTransfer *CurrRT = this->RTL.GetRT(0);
assert(CurrRT->HasRightSubTree());
CurrRT = CurrRT->GetRightTree();
STARSOpndTypePtr LeftOp = CurrRT->GetLeftOperandNoNorm();
STARSOpndTypePtr RightOp = CurrRT->GetRightOperandNoNorm();
const STARSOpndTypePtr LeftOp = CurrRT->GetConstLeftOperandNoNorm();
const STARSOpndTypePtr RightOp = CurrRT->GetConstRightOperandNoNorm();
bool ReflexiveOperation = IsEqOp(LeftOp, RightOp);
std::size_t LeftBitWidth = 8 * LeftOp->GetByteWidth();
 
......@@ -5799,8 +5789,8 @@ void SMPInstr::MDEmitSPARKAdaArithmeticSetsCondCodes(FILE *OutFile) {
bool UseFP = this->GetBlock()->GetFunc()->UsesFramePointer();
bool PrefixProcCall = false;
bool PrefixUnary = false;
STARSOpndTypePtr LeftOp = CurrRT->GetLeftOperandNoNorm();
STARSOpndTypePtr RightOp = CurrRT->GetRightTree()->GetRightOperandNoNorm();
const STARSOpndTypePtr LeftOp = CurrRT->GetConstLeftOperandNoNorm();
const STARSOpndTypePtr RightOp = CurrRT->GetRightTree()->GetConstRightOperandNoNorm();
assert((nullptr != LeftOp) && (nullptr != RightOp));
std::size_t LeftBitWidth = 8 * LeftOp->GetByteWidth();
bool ConstFollows = RightOp->IsImmedOp();
......@@ -5956,7 +5946,7 @@ void SMPInstr::MDEmitSPARKAdaArithmeticSetsCondCodes(FILE *OutFile) {
void SMPInstr::MDEmitSPARKAdaSetCondCodeIntoReg(FILE *OutFile) {
bool ErrorFound = false;
SMPRegTransfer *CurrRT = this->RTL.GetRT(0);
STARSOpndTypePtr LeftOp = CurrRT->GetLeftOperandNoNorm();
const STARSOpndTypePtr LeftOp = CurrRT->GetConstLeftOperandNoNorm();
std::size_t LeftOpndByteWidth = LeftOp->GetByteWidth();
bool LeftSubwordWidth = (global_STARS_program->GetSTARS_ISA_Bytewidth() > LeftOpndByteWidth);
bool UseFP = this->GetBlock()->GetFunc()->UsesFramePointer();
......@@ -6782,7 +6772,7 @@ void SMPInstr::EmitSPARKAda(FILE *OutFile) {
// Start switch table translation.
PrintSPARKIndentTabs(OutFile);
SMP_fprintf(OutFile, "case ");
this->PrintSPARKAdaOperand(this->RTL.GetRT(0)->GetRightOperandNoNorm(), OutFile, false, UseFP, true, false);
this->PrintSPARKAdaOperand(this->RTL.GetRT(0)->GetConstRightOperandNoNorm(), OutFile, false, UseFP, true, false);
SMP_fprintf(OutFile, " is\n");
++STARS_SPARK_IndentCount;
break;
......@@ -7182,7 +7172,7 @@ bool SMPInstr::MDIsUpperBitsClear(void) {
// Correct the RTL. reg1 := reg2 becomes reg1 := (zero-extend reg2)
SMPRegTransfer *TempRT = new SMPRegTransfer;
TempRT->SetParentInst(this);
TempRT->SetLeftOperand(this->RTL.GetRT(0)->GetRightOperandNoNorm());
TempRT->SetLeftOperand(this->RTL.GetRT(0)->GetConstRightOperandNoNorm());
TempRT->SetOperator(SMP_ZERO_EXTEND);
STARSOpndTypePtr VoidOp = this->STARSInstPtr->MakeVoidOpnd();
TempRT->SetRightOperand(VoidOp);
......@@ -7626,7 +7616,7 @@ bool SMPInstr::IsJumpOrBranchInstr(void) const {
// A jump is IP := address; a conditional branch is the same with a Guard RT.
SMPRegTransfer *RT = this->GetRT(0);
return ((1 == this->RTL.GetCount()) && (!RT->HasRightSubTree())
&& RT->GetLeftOperandNoNorm()->MatchesReg(MD_INSTRUCTION_POINTER_REG));
&& RT->GetConstLeftOperandNoNorm()->MatchesReg(MD_INSTRUCTION_POINTER_REG));
// return ((STARS_NN_ja <= this->GetIDAOpcode()) && (STARS_NN_jmpshort >= this->GetIDAOpcode()));
}
 
......@@ -7838,7 +7828,7 @@ bool SMPInstr::IsLoadGlobalStaticDataAddress(STARS_uval_t &GlobalAddr) {
bool GlobalFound = false;
if (nullptr != FirstRT) {
if ((SMP_ASSIGN == FirstRT->GetOperator()) && (!FirstRT->HasRightSubTree())) {
STARSOpndTypePtr RightOp = FirstRT->GetRightOperandNoNorm();
const STARSOpndTypePtr RightOp = FirstRT->GetConstRightOperandNoNorm();
if (RightOp->IsImmedOp()) {
GlobalAddr = RightOp->GetImmedValue();
if (IsImmedGlobalAddress((STARS_ea_t)GlobalAddr)) {
......@@ -9413,7 +9403,7 @@ void SMPInstr::MDGetUnnormalizedOp(STARSOpndTypePtr &NormOp) {
} // end of SMPInstr::MDGetUnnormalizedOp()
 
// Find USE-not-DEF operand that is not the flags register.
STARSOpndTypePtr SMPInstr::GetSourceOnlyOperand(void) {
STARSOpndTypePtr SMPInstr::GetSourceOnlyOperand(void) const {
std::size_t OpNum;
// loop through all operands
for (OpNum = 0; OpNum < STARS_UA_MAXOP; ++OpNum) {
......@@ -11475,8 +11465,8 @@ bool SMPInstr::MDIsSystemCall(void) {
SMPRegTransfer *CurrRT = this->RTL.GetRT(0);
assert(NULL != CurrRT);
if (!CurrRT->HasRightSubTree()) {
if (CurrRT->GetRightOperandNoNorm()->IsImmedOp()) {
SystemCall = (0x80 == CurrRT->GetRightOperandNoNorm()->GetImmedValue());
if (CurrRT->GetConstRightOperandNoNorm()->IsImmedOp()) {
SystemCall = (0x80 == CurrRT->GetConstRightOperandNoNorm()->GetImmedValue());
}
}
}
......@@ -12580,9 +12570,9 @@ void SMPInstr::SCCPEvaluateCondBranch(enum STARSBranchConst &BranchEval) {
SMPRegTransfer *CurrRT = this->RTL.GetRT(0);
SMPGuard *BranchCondition = CurrRT->GetGuard();
assert(NULL != BranchCondition);
STARSOpndTypePtr LeftOp = CloneIfSubwordReg(BranchCondition->GetLeftOperand());
STARSOpndTypePtr LeftOp = CloneIfSubwordReg(BranchCondition->GetConstLeftOperand());
CanonicalizeOpnd(LeftOp);
STARSOpndTypePtr RightOp = CloneIfSubwordReg(BranchCondition->GetRightOperand());
STARSOpndTypePtr RightOp = CloneIfSubwordReg(BranchCondition->GetConstRightOperand());
CanonicalizeOpnd(RightOp);
STARS_SCCP_Const_Struct LeftValue, RightValue;
this->SCCPFetchConstUseValue(LeftOp, LeftValue);