Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: src/IceRegAlloc.cpp

Issue 1868543002: Subzero: Dump register numbers as signed quantities. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Use "NA" instead of "-1" for NoRegisterValue Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /// \file 10 /// \file
11 /// \brief Implements the LinearScan class, which performs the linear-scan 11 /// \brief Implements the LinearScan class, which performs the linear-scan
12 /// register allocation after liveness analysis has been performed. 12 /// register allocation after liveness analysis has been performed.
13 /// 13 ///
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #include "IceRegAlloc.h" 16 #include "IceRegAlloc.h"
17 17
18 #include "IceBitVector.h" 18 #include "IceBitVector.h"
19 #include "IceCfg.h" 19 #include "IceCfg.h"
20 #include "IceCfgNode.h" 20 #include "IceCfgNode.h"
21 #include "IceInst.h" 21 #include "IceInst.h"
22 #include "IceInstVarIter.h" 22 #include "IceInstVarIter.h"
23 #include "IceOperand.h" 23 #include "IceOperand.h"
24 #include "IceTargetLowering.h" 24 #include "IceTargetLowering.h"
25 25
26 #include "llvm/Support/Format.h"
27
26 namespace Ice { 28 namespace Ice {
27 29
28 namespace { 30 namespace {
29 31
30 // Returns true if Var has any definitions within Item's live range. 32 // Returns true if Var has any definitions within Item's live range.
31 // TODO(stichnot): Consider trimming the Definitions list similar to how the 33 // TODO(stichnot): Consider trimming the Definitions list similar to how the
32 // live ranges are trimmed, since all the overlapsDefs() tests are whether some 34 // live ranges are trimmed, since all the overlapsDefs() tests are whether some
33 // variable's definitions overlap Cur, and trimming is with respect Cur.start. 35 // variable's definitions overlap Cur, and trimming is with respect Cur.start.
34 // Initial tests show no measurable performance difference, so we'll keep the 36 // Initial tests show no measurable performance difference, so we'll keep the
35 // code simple for now. 37 // code simple for now.
(...skipping 27 matching lines...) Expand all
63 for (size_t i = 0; i < Defs.size(); ++i) { 65 for (size_t i = 0; i < Defs.size(); ++i) {
64 Str << "," << Defs[i]->getNumber(); 66 Str << "," << Defs[i]->getNumber();
65 } 67 }
66 Str << "\n"; 68 Str << "\n";
67 } 69 }
68 70
69 void dumpLiveRange(const Variable *Var, const Cfg *Func) { 71 void dumpLiveRange(const Variable *Var, const Cfg *Func) {
70 if (!BuildDefs::dump()) 72 if (!BuildDefs::dump())
71 return; 73 return;
72 Ostream &Str = Func->getContext()->getStrDump(); 74 Ostream &Str = Func->getContext()->getStrDump();
73 char buf[30]; 75 Str << "R=";
74 snprintf(buf, llvm::array_lengthof(buf), "%2u", 76 if (Var->hasRegTmp()) {
75 unsigned(Var->getRegNumTmp())); 77 Str << llvm::format("%2d", Var->getRegNumTmp());
76 Str << "R=" << buf << " V="; 78 } else {
79 Str << "NA";
80 }
81 Str << " V=";
77 Var->dump(Func); 82 Var->dump(Func);
78 Str << " Range=" << Var->getLiveRange(); 83 Str << " Range=" << Var->getLiveRange();
79 } 84 }
80 85
81 int32_t findMinWeightIndex( 86 int32_t findMinWeightIndex(
82 const SmallBitVector &RegMask, 87 const SmallBitVector &RegMask,
83 const llvm::SmallVector<RegWeight, LinearScan::REGS_SIZE> &Weights) { 88 const llvm::SmallVector<RegWeight, LinearScan::REGS_SIZE> &Weights) {
84 int MinWeightIndex = -1; 89 int MinWeightIndex = -1;
85 for (RegNumT i : RegNumBVIter(RegMask)) { 90 for (RegNumT i : RegNumBVIter(RegMask)) {
86 if (MinWeightIndex < 0 || Weights[i] < Weights[MinWeightIndex]) 91 if (MinWeightIndex < 0 || Weights[i] < Weights[MinWeightIndex])
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 Str << "\n"; 1014 Str << "\n";
1010 } 1015 }
1011 Str << "++++++ Inactive:\n"; 1016 Str << "++++++ Inactive:\n";
1012 for (const Variable *Item : Inactive) { 1017 for (const Variable *Item : Inactive) {
1013 dumpLiveRange(Item, Func); 1018 dumpLiveRange(Item, Func);
1014 Str << "\n"; 1019 Str << "\n";
1015 } 1020 }
1016 } 1021 }
1017 1022
1018 } // end of namespace Ice 1023 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698