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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 auto *V = new (CfgLocalAllocator<Variable>().allocate(One)) | 201 auto *V = new (CfgLocalAllocator<Variable>().allocate(One)) |
202 Variable(Func, kVariable, Ty, Number); | 202 Variable(Func, kVariable, Ty, Number); |
203 V->Name = Name; | 203 V->Name = Name; |
204 V->RegNum = NewRegNum.hasValue() ? NewRegNum : RegNum; | 204 V->RegNum = NewRegNum.hasValue() ? NewRegNum : RegNum; |
205 V->StackOffset = StackOffset; | 205 V->StackOffset = StackOffset; |
206 V->LinkedTo = LinkedTo; | 206 V->LinkedTo = LinkedTo; |
207 return V; | 207 return V; |
208 } | 208 } |
209 | 209 |
210 RegWeight Variable::getWeight(const Cfg *Func) const { | 210 RegWeight Variable::getWeight(const Cfg *Func) const { |
211 VariablesMetadata *VMetadata = Func->getVMetadata(); | 211 if (mustHaveReg()) |
212 return mustHaveReg() ? RegWeight(RegWeight::Inf) | 212 return RegWeight(RegWeight::Inf); |
213 : mustNotHaveReg() ? RegWeight(RegWeight::Zero) | 213 if (mustNotHaveReg()) |
214 : VMetadata->getUseWeight(this); | 214 return RegWeight(RegWeight::Zero); |
| 215 return Func->getVMetadata()->getUseWeight(this); |
215 } | 216 } |
216 | 217 |
217 void VariableTracking::markUse(MetadataKind TrackingKind, const Inst *Instr, | 218 void VariableTracking::markUse(MetadataKind TrackingKind, const Inst *Instr, |
218 CfgNode *Node, bool IsImplicit) { | 219 CfgNode *Node, bool IsImplicit) { |
219 (void)TrackingKind; | 220 (void)TrackingKind; |
220 | 221 |
221 // Increment the use weight depending on the loop nest depth. The weight is | 222 // Increment the use weight depending on the loop nest depth. The weight is |
222 // exponential in the nest depth as inner loops are expected to be executed | 223 // exponential in the nest depth as inner loops are expected to be executed |
223 // an exponentially greater number of times. | 224 // an exponentially greater number of times. |
224 constexpr uint32_t LogLoopTripCountEstimate = 2; // 2^2 = 4 | 225 constexpr uint32_t LogLoopTripCountEstimate = 2; // 2^2 = 4 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 void Variable::dump(const Cfg *Func, Ostream &Str) const { | 534 void Variable::dump(const Cfg *Func, Ostream &Str) const { |
534 if (!BuildDefs::dump()) | 535 if (!BuildDefs::dump()) |
535 return; | 536 return; |
536 if (Func == nullptr) { | 537 if (Func == nullptr) { |
537 Str << "%" << getName(); | 538 Str << "%" << getName(); |
538 return; | 539 return; |
539 } | 540 } |
540 if (Func->isVerbose(IceV_RegOrigins) || | 541 if (Func->isVerbose(IceV_RegOrigins) || |
541 (!hasReg() && !Func->getTarget()->hasComputedFrame())) { | 542 (!hasReg() && !Func->getTarget()->hasComputedFrame())) { |
542 Str << "%" << getName(); | 543 Str << "%" << getName(); |
543 if (getLinkedTo() != nullptr) | 544 for (Variable *Link = getLinkedTo(); Link != nullptr; |
544 Str << ":%" << getLinkedTo()->getName(); | 545 Link = Link->getLinkedTo()) { |
| 546 Str << ":%" << Link->getName(); |
| 547 } |
545 } | 548 } |
546 if (hasReg()) { | 549 if (hasReg()) { |
547 if (Func->isVerbose(IceV_RegOrigins)) | 550 if (Func->isVerbose(IceV_RegOrigins)) |
548 Str << ":"; | 551 Str << ":"; |
549 Str << Func->getTarget()->getRegName(RegNum, getType()); | 552 Str << Func->getTarget()->getRegName(RegNum, getType()); |
550 } else if (Func->getTarget()->hasComputedFrame()) { | 553 } else if (Func->getTarget()->hasComputedFrame()) { |
551 if (Func->isVerbose(IceV_RegOrigins)) | 554 if (Func->isVerbose(IceV_RegOrigins)) |
552 Str << ":"; | 555 Str << ":"; |
553 const auto BaseRegisterNumber = | 556 const auto BaseRegisterNumber = |
554 hasReg() ? getBaseRegNum() : Func->getTarget()->getFrameOrStackReg(); | 557 hasReg() ? getBaseRegNum() : Func->getTarget()->getFrameOrStackReg(); |
555 Str << "[" | 558 Str << "[" |
556 << Func->getTarget()->getRegName(BaseRegisterNumber, IceType_i32); | 559 << Func->getTarget()->getRegName(BaseRegisterNumber, IceType_i32); |
557 if (hasStackOffset()) { | 560 if (hasKnownStackOffset()) { |
558 int32_t Offset = getStackOffset(); | 561 int32_t Offset = getStackOffset(); |
559 if (Offset) { | 562 if (Offset) { |
560 if (Offset > 0) | 563 if (Offset > 0) |
561 Str << "+"; | 564 Str << "+"; |
562 Str << Offset; | 565 Str << Offset; |
563 } | 566 } |
564 } | 567 } |
565 Str << "]"; | 568 Str << "]"; |
566 } | 569 } |
567 } | 570 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 if (getType() != IceType_i32 && getType() != IceType_i16 && | 652 if (getType() != IceType_i32 && getType() != IceType_i16 && |
650 getType() != IceType_i8) | 653 getType() != IceType_i8) |
651 return false; | 654 return false; |
652 // The Following checks if the signed representation of Value is between | 655 // The Following checks if the signed representation of Value is between |
653 // -Threshold/2 and +Threshold/2 | 656 // -Threshold/2 and +Threshold/2 |
654 bool largerThanThreshold = Threshold / 2 + Value >= Threshold; | 657 bool largerThanThreshold = Threshold / 2 + Value >= Threshold; |
655 return largerThanThreshold; | 658 return largerThanThreshold; |
656 } | 659 } |
657 | 660 |
658 } // end of namespace Ice | 661 } // end of namespace Ice |
OLD | NEW |