| OLD | NEW |
| 1 //===- subzero/src/IceOperand.cpp - High-level operand implementation -----===// | 1 //===- subzero/src/IceOperand.cpp - High-level operand implementation -----===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 /// | 9 /// |
| 10 /// \file | 10 /// \file |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 } else if (RelocOffsetA != RelocOffsetB) { | 80 } else if (RelocOffsetA != RelocOffsetB) { |
| 81 // or, if they are undefined, then the RelocOffsets must be the same. | 81 // or, if they are undefined, then the RelocOffsets must be the same. |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 const RegNumT RegNumT::NoRegister(RegNumT::NoRegisterValue); |
| 90 RegNumT::BaseType RegNumT::Limit = 0; |
| 91 |
| 89 bool operator<(const RegWeight &A, const RegWeight &B) { | 92 bool operator<(const RegWeight &A, const RegWeight &B) { |
| 90 return A.getWeight() < B.getWeight(); | 93 return A.getWeight() < B.getWeight(); |
| 91 } | 94 } |
| 92 bool operator<=(const RegWeight &A, const RegWeight &B) { return !(B < A); } | 95 bool operator<=(const RegWeight &A, const RegWeight &B) { return !(B < A); } |
| 93 bool operator==(const RegWeight &A, const RegWeight &B) { | 96 bool operator==(const RegWeight &A, const RegWeight &B) { |
| 94 return !(B < A) && !(A < B); | 97 return !(B < A) && !(A < B); |
| 95 } | 98 } |
| 96 | 99 |
| 97 void LiveRange::addSegment(InstNumberT Start, InstNumberT End) { | 100 void LiveRange::addSegment(InstNumberT Start, InstNumberT End) { |
| 98 if (!Range.empty()) { | 101 if (!Range.empty()) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 while (TrimmedBegin != Range.end() && TrimmedBegin->second <= Lower) | 186 while (TrimmedBegin != Range.end() && TrimmedBegin->second <= Lower) |
| 184 ++TrimmedBegin; | 187 ++TrimmedBegin; |
| 185 } | 188 } |
| 186 | 189 |
| 187 IceString Variable::getName(const Cfg *Func) const { | 190 IceString Variable::getName(const Cfg *Func) const { |
| 188 if (Func && NameIndex >= 0) | 191 if (Func && NameIndex >= 0) |
| 189 return Func->getIdentifierName(NameIndex); | 192 return Func->getIdentifierName(NameIndex); |
| 190 return "__" + std::to_string(getIndex()); | 193 return "__" + std::to_string(getIndex()); |
| 191 } | 194 } |
| 192 | 195 |
| 193 const Variable *Variable::asType(Type Ty, int32_t NewRegNum) const { | 196 const Variable *Variable::asType(Type Ty, RegNumT NewRegNum) const { |
| 194 // Note: This returns a Variable, even if the "this" object is a subclass of | 197 // Note: This returns a Variable, even if the "this" object is a subclass of |
| 195 // Variable. | 198 // Variable. |
| 196 if (!BuildDefs::dump() || getType() == Ty) | 199 if (!BuildDefs::dump() || getType() == Ty) |
| 197 return this; | 200 return this; |
| 198 Variable *V = new (getCurrentCfgAllocator()->Allocate<Variable>()) | 201 Variable *V = new (getCurrentCfgAllocator()->Allocate<Variable>()) |
| 199 Variable(kVariable, Ty, Number); | 202 Variable(kVariable, Ty, Number); |
| 200 V->NameIndex = NameIndex; | 203 V->NameIndex = NameIndex; |
| 201 V->RegNum = NewRegNum == NoRegister ? RegNum : NewRegNum; | 204 V->RegNum = NewRegNum == RegNumT::NoRegister ? RegNum : NewRegNum; |
| 202 V->StackOffset = StackOffset; | 205 V->StackOffset = StackOffset; |
| 203 return V; | 206 return V; |
| 204 } | 207 } |
| 205 | 208 |
| 206 RegWeight Variable::getWeight(const Cfg *Func) const { | 209 RegWeight Variable::getWeight(const Cfg *Func) const { |
| 207 VariablesMetadata *VMetadata = Func->getVMetadata(); | 210 VariablesMetadata *VMetadata = Func->getVMetadata(); |
| 208 return mustHaveReg() ? RegWeight(RegWeight::Inf) | 211 return mustHaveReg() ? RegWeight(RegWeight::Inf) |
| 209 : mustNotHaveReg() ? RegWeight(RegWeight::Zero) | 212 : mustNotHaveReg() ? RegWeight(RegWeight::Zero) |
| 210 : VMetadata->getUseWeight(this); | 213 : VMetadata->getUseWeight(this); |
| 211 } | 214 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 if (Func->isVerbose(IceV_RegOrigins) || | 507 if (Func->isVerbose(IceV_RegOrigins) || |
| 505 (!hasReg() && !Func->getTarget()->hasComputedFrame())) | 508 (!hasReg() && !Func->getTarget()->hasComputedFrame())) |
| 506 Str << "%" << getName(Func); | 509 Str << "%" << getName(Func); |
| 507 if (hasReg()) { | 510 if (hasReg()) { |
| 508 if (Func->isVerbose(IceV_RegOrigins)) | 511 if (Func->isVerbose(IceV_RegOrigins)) |
| 509 Str << ":"; | 512 Str << ":"; |
| 510 Str << Func->getTarget()->getRegName(RegNum, getType()); | 513 Str << Func->getTarget()->getRegName(RegNum, getType()); |
| 511 } else if (Func->getTarget()->hasComputedFrame()) { | 514 } else if (Func->getTarget()->hasComputedFrame()) { |
| 512 if (Func->isVerbose(IceV_RegOrigins)) | 515 if (Func->isVerbose(IceV_RegOrigins)) |
| 513 Str << ":"; | 516 Str << ":"; |
| 514 int32_t BaseRegisterNumber = getBaseRegNum(); | 517 const auto BaseRegisterNumber = |
| 515 if (BaseRegisterNumber == NoRegister) | 518 hasReg() ? getBaseRegNum() : Func->getTarget()->getFrameOrStackReg(); |
| 516 BaseRegisterNumber = Func->getTarget()->getFrameOrStackReg(); | |
| 517 Str << "[" | 519 Str << "[" |
| 518 << Func->getTarget()->getRegName(BaseRegisterNumber, IceType_i32); | 520 << Func->getTarget()->getRegName(BaseRegisterNumber, IceType_i32); |
| 519 int32_t Offset = getStackOffset(); | 521 int32_t Offset = getStackOffset(); |
| 520 if (Offset) { | 522 if (Offset) { |
| 521 if (Offset > 0) | 523 if (Offset > 0) |
| 522 Str << "+"; | 524 Str << "+"; |
| 523 Str << Offset; | 525 Str << Offset; |
| 524 } | 526 } |
| 525 Str << "]"; | 527 Str << "]"; |
| 526 } | 528 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 if (getType() != IceType_i32 && getType() != IceType_i16 && | 613 if (getType() != IceType_i32 && getType() != IceType_i16 && |
| 612 getType() != IceType_i8) | 614 getType() != IceType_i8) |
| 613 return false; | 615 return false; |
| 614 // The Following checks if the signed representation of Value is between | 616 // The Following checks if the signed representation of Value is between |
| 615 // -Threshold/2 and +Threshold/2 | 617 // -Threshold/2 and +Threshold/2 |
| 616 bool largerThanThreshold = Threshold / 2 + Value >= Threshold; | 618 bool largerThanThreshold = Threshold / 2 + Value >= Threshold; |
| 617 return largerThanThreshold; | 619 return largerThanThreshold; |
| 618 } | 620 } |
| 619 | 621 |
| 620 } // end of namespace Ice | 622 } // end of namespace Ice |
| OLD | NEW |