LLVM: lib/CodeGen/SplitKit.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_LIB_CODEGEN_SPLITKIT_H
15#define LLVM_LIB_CODEGEN_SPLITKIT_H
16
31#include
32
33namespace llvm {
34
47
48
49
51private:
53
54
55
56
57
59
62
63public:
65
66
69 unsigned Num = MBB.getNumber();
70
71 if (LastInsertPoint[Num].first.isValid() &&
72 !LastInsertPoint[Num].second.isValid())
73 return LastInsertPoint[Num].first;
74 return computeLastInsertPoint(CurLI, MBB);
75 }
76
77
80
81
84 if (.empty()) {
86 if (MII != MBB.end())
87 Res = LIS.getInstructionIndex(*MII);
88 }
89 return Res;
90 }
91
92};
93
94
95
97public:
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
138
139private:
140
142
143
145
146
148
149
151
152
153
154 unsigned NumGapBlocks = 0u;
155
156
158
159
160 unsigned NumThroughBlocks = 0u;
161
162
163
164 bool LooksLikeLoopIV = false;
165
166
167 void analyzeUses();
168
169
170 void calcLiveBlockInfo();
171
172public:
175
176
177
179
180
181
182 void clear();
183
184
186
187
188
189
190
191
192 bool isOriginalEndpoint(SlotIndex Idx) const;
193
194
195
197
198
199
201
202
204
205
207
208
210
211
215
217
218
219
220
221 unsigned countLiveBlocks(const LiveInterval *li) const;
222
224
225
226
227
228
229
230
231
232
234
236 return IPA.getLastInsertPoint(*CurLI, *MF.getBlockNumbered(Num));
237 }
238
240 return IPA.getLastInsertPoint(*CurLI, *BB);
241 }
242
244 return IPA.getLastInsertPointIter(*CurLI, *BB);
245 }
246
248 return IPA.getFirstInsertPoint(*MF.getBlockNumbered(Num));
249 }
250};
251
252
253
254
255
256
257
258
259
260
261
262
273
274public:
275
276
277
278
279
280
282
283
284
285
287
288
289
290
291
292
294
295
296
297
299 };
300
301private:
302
304
305
306
307
308 unsigned OpenIdx = 0;
309
310
311 ComplementSpillMode SpillMode = SM_Partition;
312
314
315
316
317 RegAssignMap::Allocator Allocator;
318
319
320
321
322 RegAssignMap RegAssign;
323
326
327
328
329
330
331
332
333
334
335
336
337
338
340
341
342
343
345
346
347
348
350 return LICalc[SpillMode != SM_Partition && RegIdx != 0];
351 }
352
353
354
355
356
357
358
359 void addDeadDef(LiveInterval &LI, VNInfo *VNI, bool Original);
360
361
362
363
364
365
366
367
368
369 VNInfo *defValue(unsigned RegIdx, const VNInfo *ParentVNI, SlotIndex Idx,
370 bool Original);
371
372
373
374
375
376 void forceRecompute(unsigned RegIdx, const VNInfo &ParentVNI);
377
378
379
380 void forceRecomputeVNI(const VNInfo &ParentVNI);
381
382
383
384 bool rematWillIncreaseRestriction(const MachineInstr *DefMI,
385 MachineBasicBlock &MBB,
386 SlotIndex UseIdx) const;
387
388
389
390 VNInfo *defFromParent(unsigned RegIdx, const VNInfo *ParentVNI,
391 SlotIndex UseIdx, MachineBasicBlock &MBB,
392 MachineBasicBlock::iterator I);
393
394
395
396 void removeBackCopies(SmallVectorImpl<VNInfo*> &Copies);
397
398
399
400 MachineBasicBlock *findShallowDominator(MachineBasicBlock *MBB,
401 MachineBasicBlock *DefMBB);
402
403
404 void computeRedundantBackCopies(DenseSet &NotToHoistSet,
405 SmallVectorImpl<VNInfo *> &BackCopies);
406
407
408
409
410 void hoistCopies();
411
412
413
414 bool transferValues();
415
416
417
418
419
420
421 void extendPHIRange(MachineBasicBlock &B, LiveIntervalCalc &LIC,
423 ArrayRef Undefs);
424
425
426
427 void extendPHIKillRanges();
428
429
430 void rewriteAssigned(bool ExtendRanges);
431
432
433 void deleteRematVictims();
434
435
436
437
438 SlotIndex buildCopy(Register FromReg, Register ToReg, LaneBitmask LaneMask,
439 MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore,
440 bool Late, unsigned RegIdx);
441
442 SlotIndex buildSingleSubRegCopy(Register FromReg, Register ToReg,
443 MachineBasicBlock &MB,
444 MachineBasicBlock::iterator InsertBefore,
445 unsigned SubIdx, LiveInterval &DestLI,
446 bool Late, SlotIndex Def,
447 const MCInstrDesc &Desc);
448
449public:
450
451
452 SplitEditor(SplitAnalysis &SA, LiveIntervals &LIS, VirtRegMap &VRM,
453 MachineDominatorTree &MDT, MachineBlockFrequencyInfo &MBFI,
454 VirtRegAuxInfo &VRAI);
455
456
457 void reset(LiveRangeEdit&, ComplementSpillMode = SM_Partition);
458
459
460
461
462 unsigned openIntv();
463
464
466
467
468 void selectIntv(unsigned Idx);
469
470
471
472
474
475
476
478
479
480
481
483
484
486
487
489
490
491
493
494
495
497
498
499
500
502
503
504
505
506
507
508
509
510
511
512
513
515
516
517
518
519
520
522
523
524 void dump() const;
525
526
527
528
529
530
532
533
534
535
536
537
538
539
540
541
542 void splitLiveThroughBlock(unsigned MBBNum,
543 unsigned IntvIn, SlotIndex LeaveBefore,
544 unsigned IntvOut, SlotIndex EnterAfter);
545
546
547
548
549
550
551
552
553
555 unsigned IntvIn, SlotIndex LeaveBefore);
556
557
558
559
560
561
562
563
564
565
567 unsigned IntvOut, SlotIndex EnterAfter);
568};
569
570}
571
572#endif
MachineInstrBuilder MachineInstrBuilder & DefMI
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
This file implements the BitVector class.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_LIBRARY_VISIBILITY
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file implements a coalescing interval map for small objects.
Promote Memory to Register
This file defines the PointerIntPair class.
SI Optimize VGPR LiveRange
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Determines the latest safe point in a block in which we can insert a split, spill or other instructio...
Definition SplitKit.h:50
SlotIndex getLastInsertPoint(const LiveInterval &CurLI, const MachineBasicBlock &MBB)
Return the base index of the last valid insert point for \pCurLI in \pMBB.
Definition SplitKit.h:67
InsertPointAnalysis(const LiveIntervals &lis, unsigned BBNum)
SlotIndex getFirstInsertPoint(MachineBasicBlock &MBB)
Return the base index of the first insert point in \pMBB.
Definition SplitKit.h:82
LiveInterval - This class represents the liveness of a register, or stack slot.
This class represents the liveness of a register, stack slot, etc.
MachineInstrBundleIterator< MachineInstr > iterator
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
PointerIntPair - This class implements a pair of a pointer and small integer.
SlotIndex - An opaque wrapper around machine indexes.
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
SplitAnalysis - Analyze a LiveInterval, looking for live range splitting opportunities.
Definition SplitKit.h:96
SplitAnalysis(const VirtRegMap &vrm, const LiveIntervals &lis, const MachineLoopInfo &mli)
const MachineFunction & MF
Definition SplitKit.h:98
MachineBasicBlock::iterator getLastSplitPointIter(MachineBasicBlock *BB)
Definition SplitKit.h:243
ArrayRef< BlockInfo > getUseBlocks() const
getUseBlocks - Return an array of BlockInfo objects for the basic blocks where CurLI has uses.
Definition SplitKit.h:200
ArrayRef< SlotIndex > getUseSlots() const
getUseSlots - Return an array of SlotIndexes of instructions using CurLI.
Definition SplitKit.h:196
unsigned getNumThroughBlocks() const
getNumThroughBlocks - Return the number of through blocks.
Definition SplitKit.h:203
SlotIndex getLastSplitPoint(unsigned Num)
Definition SplitKit.h:235
const LiveInterval & getParent() const
getParent - Return the last analyzed interval.
Definition SplitKit.h:185
bool looksLikeLoopIV() const
Definition SplitKit.h:216
const LiveIntervals & LIS
Definition SplitKit.h:100
SmallPtrSet< const MachineBasicBlock *, 16 > BlockPtrSet
Definition SplitKit.h:223
const BitVector & getThroughBlocks() const
getThroughBlocks - Return the set of through blocks.
Definition SplitKit.h:209
const MachineLoopInfo & Loops
Definition SplitKit.h:101
const TargetInstrInfo & TII
Definition SplitKit.h:102
unsigned getNumLiveBlocks() const
getNumLiveBlocks - Return the number of blocks where CurLI is live.
Definition SplitKit.h:212
SlotIndex getLastSplitPoint(MachineBasicBlock *BB)
Definition SplitKit.h:239
const VirtRegMap & VRM
Definition SplitKit.h:99
bool isThroughBlock(unsigned MBB) const
isThroughBlock - Return true if CurLI is live through MBB without uses.
Definition SplitKit.h:206
bool shouldSplitSingleBlock(const BlockInfo &BI, bool SingleInstrs) const
shouldSplitSingleBlock - Returns true if it would help to create a local live range for the instructi...
SlotIndex getFirstSplitPoint(unsigned Num)
Definition SplitKit.h:247
SplitEditor(SplitAnalysis &SA, LiveIntervals &LIS, VirtRegMap &VRM, MachineDominatorTree &MDT, MachineBlockFrequencyInfo &MBFI, VirtRegAuxInfo &VRAI)
Create a new SplitEditor for editing the LiveInterval analyzed by SA.
unsigned currentIntv() const
currentIntv - Return the current interval index.
Definition SplitKit.h:465
ComplementSpillMode
ComplementSpillMode - Select how the complement live range should be created.
Definition SplitKit.h:281
@ SM_Partition
SM_Partition(Default) - Try to create the complement interval so it doesn't overlap any other interva...
Definition SplitKit.h:286
@ SM_Speed
SM_Speed - Overlap intervals to minimize the expected execution frequency of the inserted copies.
Definition SplitKit.h:298
@ SM_Size
SM_Size - Overlap intervals to minimize the number of inserted COPY instructions.
Definition SplitKit.h:293
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Calculate auxiliary information for a virtual register such as its spill weight and allocation hint.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
Additional information about basic blocks where the current variable is live.
Definition SplitKit.h:121
SlotIndex FirstDef
First non-phi valno->def, or SlotIndex().
Definition SplitKit.h:125
bool LiveOut
Current reg is live out.
Definition SplitKit.h:127
bool LiveIn
Current reg is live in.
Definition SplitKit.h:126
bool isOneInstr() const
isOneInstr - Returns true when this BlockInfo describes a single instruction.
Definition SplitKit.h:131
MachineBasicBlock * MBB
Definition SplitKit.h:122
SlotIndex LastInstr
Last instr accessing current reg.
Definition SplitKit.h:124
SlotIndex FirstInstr
First instr accessing current reg.
Definition SplitKit.h:123