@@ -87,8 +87,8 @@ static unsigned copyHint(const MachineInstr *mi, unsigned reg,
87
87
}
88
88
89
89
void VirtRegAuxInfo::CalculateWeightAndHint (LiveInterval &li) {
90
- MachineRegisterInfo &mri = mf_ .getRegInfo ();
91
- const TargetRegisterInfo &tri = *mf_ .getTarget ().getRegisterInfo ();
90
+ MachineRegisterInfo &mri = MF .getRegInfo ();
91
+ const TargetRegisterInfo &tri = *MF .getTarget ().getRegisterInfo ();
92
92
MachineBasicBlock *mbb = 0 ;
93
93
MachineLoop *loop = 0 ;
94
94
unsigned loopDepth = 0 ;
@@ -118,7 +118,7 @@ void VirtRegAuxInfo::CalculateWeightAndHint(LiveInterval &li) {
118
118
// Get loop info for mi.
119
119
if (mi->getParent () != mbb) {
120
120
mbb = mi->getParent ();
121
- loop = loops_ .getLoopFor (mbb);
121
+ loop = Loops .getLoopFor (mbb);
122
122
loopDepth = loop ? loop->getLoopDepth () : 0 ;
123
123
isExiting = loop ? loop->isLoopExiting (mbb) : false ;
124
124
}
@@ -129,7 +129,7 @@ void VirtRegAuxInfo::CalculateWeightAndHint(LiveInterval &li) {
129
129
weight = LiveIntervals::getSpillWeight (writes, reads, loopDepth);
130
130
131
131
// Give extra weight to what looks like a loop induction variable update.
132
- if (writes && isExiting && lis_ .isLiveOutOfMBB (li, mbb))
132
+ if (writes && isExiting && LIS .isLiveOutOfMBB (li, mbb))
133
133
weight *= 3 ;
134
134
135
135
totalWeight += weight;
@@ -141,17 +141,17 @@ void VirtRegAuxInfo::CalculateWeightAndHint(LiveInterval &li) {
141
141
unsigned hint = copyHint (mi, li.reg , tri, mri);
142
142
if (!hint)
143
143
continue ;
144
- float hweight = hint_ [hint] += weight;
144
+ float hweight = Hint [hint] += weight;
145
145
if (TargetRegisterInfo::isPhysicalRegister (hint)) {
146
- if (hweight > bestPhys && lis_ .isAllocatable (hint))
146
+ if (hweight > bestPhys && LIS .isAllocatable (hint))
147
147
bestPhys = hweight, hintPhys = hint;
148
148
} else {
149
149
if (hweight > bestVirt)
150
150
bestVirt = hweight, hintVirt = hint;
151
151
}
152
152
}
153
153
154
- hint_ .clear ();
154
+ Hint .clear ();
155
155
156
156
// Always prefer the physreg hint.
157
157
if (unsigned hint = hintPhys ? hintPhys : hintVirt) {
@@ -176,7 +176,7 @@ void VirtRegAuxInfo::CalculateWeightAndHint(LiveInterval &li) {
176
176
// FIXME: this gets much more complicated once we support non-trivial
177
177
// re-materialization.
178
178
bool isLoad = false ;
179
- if (lis_ .isReMaterializable (li, 0 , isLoad)) {
179
+ if (LIS .isReMaterializable (li, 0 , isLoad)) {
180
180
if (isLoad)
181
181
totalWeight *= 0 .9F ;
182
182
else
@@ -187,50 +187,29 @@ void VirtRegAuxInfo::CalculateWeightAndHint(LiveInterval &li) {
187
187
}
188
188
189
189
void VirtRegAuxInfo::CalculateRegClass (unsigned reg) {
190
- MachineRegisterInfo &mri = mf_.getRegInfo ();
191
- const TargetRegisterInfo *tri = mf_.getTarget ().getRegisterInfo ();
192
- const TargetRegisterClass *orc = mri.getRegClass (reg);
193
- SmallPtrSet<const TargetRegisterClass*,8 > rcs;
194
-
195
- for (MachineRegisterInfo::reg_nodbg_iterator I = mri.reg_nodbg_begin (reg),
196
- E = mri.reg_nodbg_end (); I != E; ++I) {
197
- // The targets don't have accurate enough regclass descriptions that we can
198
- // handle subregs. We need something similar to
199
- // TRI::getMatchingSuperRegClass, but returning a super class instead of a
200
- // sub class.
201
- if (I.getOperand ().getSubReg ()) {
202
- DEBUG (dbgs () << " Cannot handle subregs: " << I.getOperand () << ' \n ' );
203
- return ;
204
- }
205
- if (const TargetRegisterClass *rc =
206
- I->getDesc ().getRegClass (I.getOperandNo (), tri))
207
- rcs.insert (rc);
208
- }
190
+ MachineRegisterInfo &MRI = MF.getRegInfo ();
191
+ const TargetRegisterInfo *TRI = MF.getTarget ().getRegisterInfo ();
192
+ const TargetRegisterClass *OldRC = MRI.getRegClass (reg);
193
+ const TargetRegisterClass *NewRC = TRI->getLargestLegalSuperClass (OldRC);
209
194
210
- // If we found no regclass constraints, just leave reg as is.
211
- // In theory, we could inflate to the largest superclass of reg's existing
212
- // class, but that might not be legal for the current cpu setting.
213
- // This could happen if reg is only used by COPY instructions, so we may need
214
- // to improve on this.
215
- if (rcs.empty ()) {
195
+ // Stop early if there is no room to grow.
196
+ if (NewRC == OldRC)
216
197
return ;
217
- }
218
198
219
- // Compute the intersection of all classes in rcs.
220
- // This ought to be independent of iteration order, but if the target register
221
- // classes don't form a proper algebra, it is possible to get different
222
- // results. The solution is to make sure the intersection of any two register
223
- // classes is also a register class or the null set.
224
- const TargetRegisterClass *rc = 0 ;
225
- for (SmallPtrSet<const TargetRegisterClass*,8 >::iterator I = rcs.begin (),
226
- E = rcs.end (); I != E; ++I) {
227
- rc = rc ? getCommonSubClass (rc, *I) : *I;
228
- assert (rc && " Incompatible regclass constraints found" );
199
+ // Accumulate constraints from all uses.
200
+ for (MachineRegisterInfo::reg_nodbg_iterator I = MRI.reg_nodbg_begin (reg),
201
+ E = MRI.reg_nodbg_end (); I != E; ++I) {
202
+ // TRI doesn't have accurate enough information to model this yet.
203
+ if (I.getOperand ().getSubReg ())
204
+ return ;
205
+ const TargetRegisterClass *OpRC =
206
+ I->getDesc ().getRegClass (I.getOperandNo (), TRI);
207
+ if (OpRC)
208
+ NewRC = getCommonSubClass (NewRC, OpRC);
209
+ if (!NewRC || NewRC == OldRC)
210
+ return ;
229
211
}
230
-
231
- if (rc == orc)
232
- return ;
233
- DEBUG (dbgs () << " Inflating " << orc->getName () << ' :' << PrintReg (reg)
234
- << " to " << rc->getName () <<" .\n " );
235
- mri.setRegClass (reg, rc);
212
+ DEBUG (dbgs () << " Inflating " << OldRC->getName () << ' :' << PrintReg (reg)
213
+ << " to " << NewRC->getName () <<" .\n " );
214
+ MRI.setRegClass (reg, NewRC);
236
215
}
0 commit comments