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

Side by Side Diff: src/IceInst.cpp

Issue 1169493002: Subzero: Improve/refactor folding loads into the next instruction. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 5 years, 6 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
OLDNEW
1 //===- subzero/src/IceInst.cpp - High-level instruction implementation ----===// 1 //===- subzero/src/IceInst.cpp - High-level instruction 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 Inst class, primarily the various 10 // This file implements the Inst class, primarily the various
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 Mask >>= 1; 106 Mask >>= 1;
107 if (Mask == 0) 107 if (Mask == 0)
108 return false; // another early-exit optimization 108 return false; // another early-exit optimization
109 } 109 }
110 } 110 }
111 } 111 }
112 return false; 112 return false;
113 } 113 }
114 114
115 // Given an instruction like:
116 // a = b + c + [x,y] + e
117 // which was created from OrigInst:
118 // a = b + c + d + e
119 // with SpliceAssn spliced in:
120 // d = [x,y]
121 //
122 // Reconstruct the LiveRangesEnded bitmask in this instruction by
123 // combining the LiveRangesEnded values of OrigInst and SpliceAssn.
124 // If operands d and [x,y] contain a different number of variables,
125 // then the bitmask position for e may be different in OrigInst and
126 // the current instruction, requiring extra shifts and masks in the
127 // computation. In the example above, OrigInst has variable e in bit
128 // position 3, whereas the current instruction has e in bit position 4
129 // because [x,y] consumes 2 bitmask slots while d only consumed 1.
130 //
131 // Additionally, set HasSideEffects if either OrigInst or SpliceAssn
132 // have HasSideEffects set.
133 void Inst::spliceLivenessInfo(Inst *OrigInst, Inst *SpliceAssn) {
134 HasSideEffects |= OrigInst->HasSideEffects;
135 HasSideEffects |= SpliceAssn->HasSideEffects;
136 // Find the bitmask index of SpliceAssn's dest within OrigInst.
137 Variable *SpliceDest = SpliceAssn->getDest();
138 SizeT Index = 0;
139 for (SizeT I = 0; I < OrigInst->getSrcSize(); ++I) {
140 Operand *Src = OrigInst->getSrc(I);
141 if (Src == SpliceDest) {
142 LREndedBits LeftMask = OrigInst->LiveRangesEnded & ((1 << Index) - 1);
143 LREndedBits RightMask = OrigInst->LiveRangesEnded >> (Index + 1);
144 LiveRangesEnded = LeftMask | (SpliceAssn->LiveRangesEnded << Index) |
145 (RightMask << (Index + getSrc(I)->getNumVars()));
146 return;
147 }
148 Index += getSrc(I)->getNumVars();
149 }
150 llvm::report_fatal_error("Failed to find splice operand");
151 }
152
115 void Inst::livenessLightweight(Cfg *Func, LivenessBV &Live) { 153 void Inst::livenessLightweight(Cfg *Func, LivenessBV &Live) {
116 assert(!isDeleted()); 154 assert(!isDeleted());
117 resetLastUses(); 155 resetLastUses();
118 VariablesMetadata *VMetadata = Func->getVMetadata(); 156 VariablesMetadata *VMetadata = Func->getVMetadata();
119 SizeT VarIndex = 0; 157 SizeT VarIndex = 0;
120 for (SizeT I = 0; I < getSrcSize(); ++I) { 158 for (SizeT I = 0; I < getSrcSize(); ++I) {
121 Operand *Src = getSrc(I); 159 Operand *Src = getSrc(I);
122 SizeT NumVars = Src->getNumVars(); 160 SizeT NumVars = Src->getNumVars();
123 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) { 161 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) {
124 const Variable *Var = Src->getVar(J); 162 const Variable *Var = Src->getVar(J);
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 // preserve these. 921 // preserve these.
884 return true; 922 return true;
885 } 923 }
886 if (!Dest->hasReg() && !SrcVar->hasReg() && 924 if (!Dest->hasReg() && !SrcVar->hasReg() &&
887 Dest->getStackOffset() == SrcVar->getStackOffset()) 925 Dest->getStackOffset() == SrcVar->getStackOffset())
888 return true; 926 return true;
889 return false; 927 return false;
890 } 928 }
891 929
892 } // end of namespace Ice 930 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInst.h ('k') | src/IceTargetLowering.cpp » ('j') | src/IceTargetLoweringX8632.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698