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 RegNumT::BaseType RegNumT::Limit = 0; |
| 90 |
89 bool operator<(const RegWeight &A, const RegWeight &B) { | 91 bool operator<(const RegWeight &A, const RegWeight &B) { |
90 return A.getWeight() < B.getWeight(); | 92 return A.getWeight() < B.getWeight(); |
91 } | 93 } |
92 bool operator<=(const RegWeight &A, const RegWeight &B) { return !(B < A); } | 94 bool operator<=(const RegWeight &A, const RegWeight &B) { return !(B < A); } |
93 bool operator==(const RegWeight &A, const RegWeight &B) { | 95 bool operator==(const RegWeight &A, const RegWeight &B) { |
94 return !(B < A) && !(A < B); | 96 return !(B < A) && !(A < B); |
95 } | 97 } |
96 | 98 |
97 void LiveRange::addSegment(InstNumberT Start, InstNumberT End) { | 99 void LiveRange::addSegment(InstNumberT Start, InstNumberT End) { |
98 if (!Range.empty()) { | 100 if (!Range.empty()) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 while (TrimmedBegin != Range.end() && TrimmedBegin->second <= Lower) | 185 while (TrimmedBegin != Range.end() && TrimmedBegin->second <= Lower) |
184 ++TrimmedBegin; | 186 ++TrimmedBegin; |
185 } | 187 } |
186 | 188 |
187 IceString Variable::getName(const Cfg *Func) const { | 189 IceString Variable::getName(const Cfg *Func) const { |
188 if (Func && NameIndex >= 0) | 190 if (Func && NameIndex >= 0) |
189 return Func->getIdentifierName(NameIndex); | 191 return Func->getIdentifierName(NameIndex); |
190 return "__" + std::to_string(getIndex()); | 192 return "__" + std::to_string(getIndex()); |
191 } | 193 } |
192 | 194 |
193 const Variable *Variable::asType(Type Ty, int32_t NewRegNum) const { | 195 const Variable *Variable::asType(Type Ty, RegNumT NewRegNum) const { |
194 // Note: This returns a Variable, even if the "this" object is a subclass of | 196 // Note: This returns a Variable, even if the "this" object is a subclass of |
195 // Variable. | 197 // Variable. |
196 if (!BuildDefs::dump() || getType() == Ty) | 198 if (!BuildDefs::dump() || getType() == Ty) |
197 return this; | 199 return this; |
198 Variable *V = new (getCurrentCfgAllocator()->Allocate<Variable>()) | 200 Variable *V = new (getCurrentCfgAllocator()->Allocate<Variable>()) |
199 Variable(kVariable, Ty, Number); | 201 Variable(kVariable, Ty, Number); |
200 V->NameIndex = NameIndex; | 202 V->NameIndex = NameIndex; |
201 V->RegNum = NewRegNum == NoRegister ? RegNum : NewRegNum; | 203 V->RegNum = NewRegNum == RegNumT::NoRegister ? RegNum : NewRegNum; |
202 V->StackOffset = StackOffset; | 204 V->StackOffset = StackOffset; |
203 return V; | 205 return V; |
204 } | 206 } |
205 | 207 |
206 RegWeight Variable::getWeight(const Cfg *Func) const { | 208 RegWeight Variable::getWeight(const Cfg *Func) const { |
207 VariablesMetadata *VMetadata = Func->getVMetadata(); | 209 VariablesMetadata *VMetadata = Func->getVMetadata(); |
208 return mustHaveReg() ? RegWeight(RegWeight::Inf) | 210 return mustHaveReg() ? RegWeight(RegWeight::Inf) |
209 : mustNotHaveReg() ? RegWeight(RegWeight::Zero) | 211 : mustNotHaveReg() ? RegWeight(RegWeight::Zero) |
210 : VMetadata->getUseWeight(this); | 212 : VMetadata->getUseWeight(this); |
211 } | 213 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 if (Func->isVerbose(IceV_RegOrigins) || | 506 if (Func->isVerbose(IceV_RegOrigins) || |
505 (!hasReg() && !Func->getTarget()->hasComputedFrame())) | 507 (!hasReg() && !Func->getTarget()->hasComputedFrame())) |
506 Str << "%" << getName(Func); | 508 Str << "%" << getName(Func); |
507 if (hasReg()) { | 509 if (hasReg()) { |
508 if (Func->isVerbose(IceV_RegOrigins)) | 510 if (Func->isVerbose(IceV_RegOrigins)) |
509 Str << ":"; | 511 Str << ":"; |
510 Str << Func->getTarget()->getRegName(RegNum, getType()); | 512 Str << Func->getTarget()->getRegName(RegNum, getType()); |
511 } else if (Func->getTarget()->hasComputedFrame()) { | 513 } else if (Func->getTarget()->hasComputedFrame()) { |
512 if (Func->isVerbose(IceV_RegOrigins)) | 514 if (Func->isVerbose(IceV_RegOrigins)) |
513 Str << ":"; | 515 Str << ":"; |
514 int32_t BaseRegisterNumber = getBaseRegNum(); | 516 auto BaseRegisterNumber = getBaseRegNum(); |
515 if (BaseRegisterNumber == NoRegister) | 517 if (BaseRegisterNumber == RegNumT::NoRegister) |
516 BaseRegisterNumber = Func->getTarget()->getFrameOrStackReg(); | 518 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 << "]"; |
(...skipping 85 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 |