Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan implementation -----------===// | 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan 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 // This file implements the LinearScan class, which performs the | 10 // This file implements the LinearScan class, which performs the |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 // Returns true if Var has any definitions within Item's live range. | 26 // Returns true if Var has any definitions within Item's live range. |
| 27 // TODO(stichnot): Consider trimming the Definitions list similar to | 27 // TODO(stichnot): Consider trimming the Definitions list similar to |
| 28 // how the live ranges are trimmed, since all the overlapsDefs() tests | 28 // how the live ranges are trimmed, since all the overlapsDefs() tests |
| 29 // are whether some variable's definitions overlap Cur, and trimming | 29 // are whether some variable's definitions overlap Cur, and trimming |
| 30 // is with respect Cur.start. Initial tests show no measurable | 30 // is with respect Cur.start. Initial tests show no measurable |
| 31 // performance difference, so we'll keep the code simple for now. | 31 // performance difference, so we'll keep the code simple for now. |
| 32 bool overlapsDefs(const Cfg *Func, const Variable *Item, const Variable *Var) { | 32 bool overlapsDefs(const Cfg *Func, const Variable *Item, const Variable *Var) { |
| 33 const bool UseTrimmed = true; | 33 const bool UseTrimmed = true; |
| 34 VariablesMetadata *VMetadata = Func->getVMetadata(); | 34 VariablesMetadata *VMetadata = Func->getVMetadata(); |
| 35 const InstDefList &Defs = VMetadata->getDefinitions(Var); | 35 if (const Inst *FirstDef = VMetadata->getFirstDefinition(Var)) |
| 36 if (Item->getLiveRange().overlapsInst(FirstDef->getNumber(), UseTrimmed)) | |
| 37 return true; | |
| 38 const InstDefList &Defs = VMetadata->getLatterDefinitions(Var); | |
| 36 for (size_t i = 0; i < Defs.size(); ++i) { | 39 for (size_t i = 0; i < Defs.size(); ++i) { |
| 37 if (Item->getLiveRange().overlapsInst(Defs[i]->getNumber(), UseTrimmed)) | 40 if (Item->getLiveRange().overlapsInst(Defs[i]->getNumber(), UseTrimmed)) |
| 38 return true; | 41 return true; |
| 39 } | 42 } |
| 40 return false; | 43 return false; |
| 41 } | 44 } |
| 42 | 45 |
| 43 void dumpDisableOverlap(const Cfg *Func, const Variable *Var, | 46 void dumpDisableOverlap(const Cfg *Func, const Variable *Var, |
| 44 const char *Reason) { | 47 const char *Reason) { |
| 45 if (Func->getContext()->isVerbose(IceV_LinearScan)) { | 48 if (Func->getContext()->isVerbose(IceV_LinearScan)) { |
| 46 VariablesMetadata *VMetadata = Func->getVMetadata(); | 49 VariablesMetadata *VMetadata = Func->getVMetadata(); |
| 47 Ostream &Str = Func->getContext()->getStrDump(); | 50 Ostream &Str = Func->getContext()->getStrDump(); |
| 48 Str << "Disabling Overlap due to " << Reason << " " << *Var | 51 Str << "Disabling Overlap due to " << Reason << " " << *Var |
| 49 << " LIVE=" << Var->getLiveRange() << " Defs="; | 52 << " LIVE=" << Var->getLiveRange() << " Defs="; |
| 50 const InstDefList &Defs = VMetadata->getDefinitions(Var); | 53 if (const Inst *FirstDef = VMetadata->getFirstDefinition(Var)) |
| 54 Str << FirstDef->getNumber(); | |
| 55 const InstDefList &Defs = VMetadata->getLatterDefinitions(Var); | |
| 51 for (size_t i = 0; i < Defs.size(); ++i) { | 56 for (size_t i = 0; i < Defs.size(); ++i) { |
|
jvoung (off chromium)
2014/10/15 22:10:37
Might be able to use a range-based for-loop now th
Jim Stichnoth
2014/10/15 22:12:44
Yeah, though I was thinking of making one big pass
| |
| 52 if (i > 0) | 57 Str << "," << Defs[i]->getNumber(); |
| 53 Str << ","; | |
| 54 Str << Defs[i]->getNumber(); | |
| 55 } | 58 } |
| 56 Str << "\n"; | 59 Str << "\n"; |
| 57 } | 60 } |
| 58 } | 61 } |
| 59 | 62 |
| 60 void dumpLiveRange(const Variable *Var, const Cfg *Func) { | 63 void dumpLiveRange(const Variable *Var, const Cfg *Func) { |
| 61 Ostream &Str = Func->getContext()->getStrDump(); | 64 Ostream &Str = Func->getContext()->getStrDump(); |
| 62 const static size_t BufLen = 30; | 65 const static size_t BufLen = 30; |
| 63 char buf[BufLen]; | 66 char buf[BufLen]; |
| 64 snprintf(buf, BufLen, "%2d", Var->getRegNumTmp()); | 67 snprintf(buf, BufLen, "%2d", Var->getRegNumTmp()); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 Str << "\n"; | 572 Str << "\n"; |
| 570 } | 573 } |
| 571 Str << "++++++ Inactive:\n"; | 574 Str << "++++++ Inactive:\n"; |
| 572 for (const Variable *Item : Inactive) { | 575 for (const Variable *Item : Inactive) { |
| 573 dumpLiveRange(Item, Func); | 576 dumpLiveRange(Item, Func); |
| 574 Str << "\n"; | 577 Str << "\n"; |
| 575 } | 578 } |
| 576 } | 579 } |
| 577 | 580 |
| 578 } // end of namespace Ice | 581 } // end of namespace Ice |
| OLD | NEW |