OLD | NEW |
---|---|
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 Loading... | |
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 void Inst::spliceLastUseInfo(Inst *OrigInst, Inst *SpliceAssn) { | |
131 // Find the bitmask index of SpliceAssn's dest within OrigInst. | |
132 Variable *SpliceDest = SpliceAssn->getDest(); | |
133 SizeT Index = 0; | |
134 for (SizeT I = 0; I < OrigInst->getSrcSize(); ++I) { | |
135 Operand *Src = OrigInst->getSrc(I); | |
136 if (Src == SpliceDest) { | |
137 LREndedBits LeftMask = OrigInst->LiveRangesEnded & ((1 << Index) - 1); | |
138 LREndedBits RightMask = OrigInst->LiveRangesEnded >> (Index + 1); | |
139 LiveRangesEnded = LeftMask | (SpliceAssn->LiveRangesEnded << Index) | | |
140 (RightMask >> (Index + getSrc(I)->getNumVars())); | |
jvoung (off chromium)
2015/06/03 18:18:15
Should this be RightMask << (Index + ...) ?
I not
Jim Stichnoth
2015/06/03 21:06:51
Oops, you're right! Done.
| |
141 return; | |
142 } | |
143 Index += getSrc(I)->getNumVars(); | |
144 } | |
145 llvm::report_fatal_error("Failed to find splice operand"); | |
146 } | |
147 | |
115 void Inst::livenessLightweight(Cfg *Func, LivenessBV &Live) { | 148 void Inst::livenessLightweight(Cfg *Func, LivenessBV &Live) { |
116 assert(!isDeleted()); | 149 assert(!isDeleted()); |
117 resetLastUses(); | 150 resetLastUses(); |
118 VariablesMetadata *VMetadata = Func->getVMetadata(); | 151 VariablesMetadata *VMetadata = Func->getVMetadata(); |
119 SizeT VarIndex = 0; | 152 SizeT VarIndex = 0; |
120 for (SizeT I = 0; I < getSrcSize(); ++I) { | 153 for (SizeT I = 0; I < getSrcSize(); ++I) { |
121 Operand *Src = getSrc(I); | 154 Operand *Src = getSrc(I); |
122 SizeT NumVars = Src->getNumVars(); | 155 SizeT NumVars = Src->getNumVars(); |
123 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) { | 156 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) { |
124 const Variable *Var = Src->getVar(J); | 157 const Variable *Var = Src->getVar(J); |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
883 // preserve these. | 916 // preserve these. |
884 return true; | 917 return true; |
885 } | 918 } |
886 if (!Dest->hasReg() && !SrcVar->hasReg() && | 919 if (!Dest->hasReg() && !SrcVar->hasReg() && |
887 Dest->getStackOffset() == SrcVar->getStackOffset()) | 920 Dest->getStackOffset() == SrcVar->getStackOffset()) |
888 return true; | 921 return true; |
889 return false; | 922 return false; |
890 } | 923 } |
891 | 924 |
892 } // end of namespace Ice | 925 } // end of namespace Ice |
OLD | NEW |