LLVM 24.0.0git
ModuloSchedule.h
Go to the documentation of this file.
1//===- ModuloSchedule.h - Software pipeline schedule expansion ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Software pipelining (SWP) is an instruction scheduling technique for loops
10// that overlaps loop iterations and exploits ILP via compiler transformations.
11//
12// There are multiple methods for analyzing a loop and creating a schedule.
13// An example algorithm is Swing Modulo Scheduling (implemented by the
14// MachinePipeliner). The details of how a schedule is arrived at are irrelevant
15// for the task of actually rewriting a loop to adhere to the schedule, which
16// is what this file does.
17//
18// A schedule is, for every instruction in a block, a Cycle and a Stage. Note
19// that we only support single-block loops, so "block" and "loop" can be used
20// interchangably.
21//
22// The Cycle of an instruction defines a partial order of the instructions in
23// the remapped loop. Instructions within a cycle must not consume the output
24// of any instruction in the same cycle. Cycle information is assumed to have
25// been calculated such that the processor will execute instructions in
26// lock-step (for example in a VLIW ISA).
27//
28// The Stage of an instruction defines the mapping between logical loop
29// iterations and pipelined loop iterations. An example (unrolled) pipeline
30// may look something like:
31//
32// I0[0] Execute instruction I0 of iteration 0
33// I1[0], I0[1] Execute I0 of iteration 1 and I1 of iteration 1
34// I1[1], I0[2]
35// I1[2], I0[3]
36//
37// In the schedule for this unrolled sequence we would say that I0 was scheduled
38// in stage 0 and I1 in stage 1:
39//
40// loop:
41// [stage 0] x = I0
42// [stage 1] I1 x (from stage 0)
43//
44// And to actually generate valid code we must insert a phi:
45//
46// loop:
47// x' = phi(x)
48// x = I0
49// I1 x'
50//
51// This is a simple example; the rules for how to generate correct code given
52// an arbitrary schedule containing loop-carried values are complex.
53//
54// Note that these examples only mention the steady-state kernel of the
55// generated loop; prologs and epilogs must be generated also that prime and
56// flush the pipeline. Doing so is nontrivial.
57//
58//===----------------------------------------------------------------------===//
59
60#ifndef LLVM_CODEGEN_MODULOSCHEDULE_H
61#define LLVM_CODEGEN_MODULOSCHEDULE_H
62
68#include <deque>
69#include <map>
70#include <vector>
71
72namespace llvm {
74class MachineLoop;
76class MachineInstr;
77class LiveIntervals;
78
79/// Represents a schedule for a single-block loop. For every instruction we
80/// maintain a Cycle and Stage.
82private:
83 /// The block containing the loop instructions.
84 MachineLoop *Loop;
85
86 /// The instructions to be generated, in total order. Cycle provides a partial
87 /// order; the total order within cycles has been decided by the schedule
88 /// producer.
89 std::vector<MachineInstr *> ScheduledInstrs;
90
91 /// The cycle for each instruction.
93
94 /// The stage for each instruction.
96
97 /// The number of stages in this schedule (Max(Stage) + 1).
98 int NumStages;
99
100public:
101 /// Create a new ModuloSchedule.
102 /// \arg ScheduledInstrs The new loop instructions, in total resequenced
103 /// order.
104 /// \arg Cycle Cycle index for all instructions in ScheduledInstrs. Cycle does
105 /// not need to start at zero. ScheduledInstrs must be partially ordered by
106 /// Cycle.
107 /// \arg Stage Stage index for all instructions in ScheduleInstrs.
109 std::vector<MachineInstr *> ScheduledInstrs,
112 : Loop(Loop), ScheduledInstrs(ScheduledInstrs), Cycle(std::move(Cycle)),
113 Stage(std::move(Stage)) {
114 NumStages = 0;
115 for (auto &KV : this->Stage)
116 NumStages = std::max(NumStages, KV.second);
117 ++NumStages;
118 }
119
120 /// Return the single-block loop being scheduled.
121 MachineLoop *getLoop() const { return Loop; }
122
123 /// Return the number of stages contained in this schedule, which is the
124 /// largest stage index + 1.
125 int getNumStages() const { return NumStages; }
126
127 /// Return the first cycle in the schedule, which is the cycle index of the
128 /// first instruction.
129 int getFirstCycle() { return Cycle[ScheduledInstrs.front()]; }
130
131 /// Return the final cycle in the schedule, which is the cycle index of the
132 /// last instruction.
133 int getFinalCycle() { return Cycle[ScheduledInstrs.back()]; }
134
135 /// Return the stage that MI is scheduled in, or -1.
137 auto I = Stage.find(MI);
138 return I == Stage.end() ? -1 : I->second;
139 }
140
141 /// Return the cycle that MI is scheduled at, or -1.
143 auto I = Cycle.find(MI);
144 return I == Cycle.end() ? -1 : I->second;
145 }
146
147 /// Set the stage of a newly created instruction.
148 void setStage(MachineInstr *MI, int MIStage) {
149 assert(Stage.count(MI) == 0);
150 Stage[MI] = MIStage;
151 }
152
153 /// Return the rescheduled instructions in order.
154 ArrayRef<MachineInstr *> getInstructions() { return ScheduledInstrs; }
155
156 void dump() { print(dbgs()); }
157 LLVM_ABI void print(raw_ostream &OS);
158};
159
160/// The ModuloScheduleExpander takes a ModuloSchedule and expands it in-place,
161/// rewriting the old loop and inserting prologs and epilogs as required.
163public:
165
166private:
167 using ValueMapTy = DenseMap<Register, Register>;
168 using MBBVectorTy = SmallVectorImpl<MachineBasicBlock *>;
170
171 ModuloSchedule &Schedule;
172 MachineFunction &MF;
173 const TargetSubtargetInfo &ST;
175 const TargetInstrInfo *TII = nullptr;
176 LiveIntervals &LIS;
178
179 MachineBasicBlock *BB = nullptr;
180 MachineBasicBlock *Preheader = nullptr;
181 MachineBasicBlock *NewKernel = nullptr;
182 std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo> LoopInfo;
183
184 /// Map for each register and the max difference between its uses and def.
185 /// The first element in the pair is the max difference in stages. The
186 /// second is true if the register defines a Phi value and loop value is
187 /// scheduled before the Phi.
188 std::map<Register, std::pair<unsigned, bool>> RegToStageDiff;
189
190 /// Instructions to change when emitting the final schedule.
191 InstrChangesTy InstrChanges;
192
193 void generatePipelinedLoop();
194 void generateProlog(unsigned LastStage, MachineBasicBlock *KernelBB,
195 ValueMapTy *VRMap, MBBVectorTy &PrologBBs);
196 void generateEpilog(unsigned LastStage, MachineBasicBlock *KernelBB,
197 MachineBasicBlock *OrigBB, ValueMapTy *VRMap,
198 ValueMapTy *VRMapPhi, MBBVectorTy &EpilogBBs,
199 MBBVectorTy &PrologBBs);
200 void generateExistingPhis(MachineBasicBlock *NewBB, MachineBasicBlock *BB1,
201 MachineBasicBlock *BB2, MachineBasicBlock *KernelBB,
202 ValueMapTy *VRMap, ValueMapTy *VRMapPhi,
203 InstrMapTy &InstrMap, unsigned LastStageNum,
204 unsigned CurStageNum, bool IsLast);
205 void generatePhis(MachineBasicBlock *NewBB, MachineBasicBlock *BB1,
206 MachineBasicBlock *BB2, MachineBasicBlock *KernelBB,
207 ValueMapTy *VRMap, ValueMapTy *VRMapPhi,
208 InstrMapTy &InstrMap, unsigned LastStageNum,
209 unsigned CurStageNum, bool IsLast);
210 void removeDeadInstructions(MachineBasicBlock *KernelBB,
211 MBBVectorTy &EpilogBBs);
212 void splitLifetimes(MachineBasicBlock *KernelBB, MBBVectorTy &EpilogBBs);
213 void addBranches(MachineBasicBlock &PreheaderBB, MBBVectorTy &PrologBBs,
214 MachineBasicBlock *KernelBB, MBBVectorTy &EpilogBBs,
215 ValueMapTy *VRMap);
216 bool computeDelta(MachineInstr &MI, unsigned &Delta);
217 void updateMemOperands(MachineInstr &NewMI, MachineInstr &OldMI,
218 unsigned Num);
219 MachineInstr *cloneInstr(MachineInstr *OldMI, unsigned CurStageNum,
220 unsigned InstStageNum);
221 MachineInstr *cloneAndChangeInstr(MachineInstr *OldMI, unsigned CurStageNum,
222 unsigned InstStageNum);
223 void updateInstruction(MachineInstr *NewMI, bool LastDef,
224 unsigned CurStageNum, unsigned InstrStageNum,
225 ValueMapTy *VRMap);
226 MachineInstr *findDefInLoop(Register Reg);
227 Register getPrevMapVal(unsigned StageNum, unsigned PhiStage, Register LoopVal,
228 unsigned LoopStage, ValueMapTy *VRMap,
230 void rewritePhiValues(MachineBasicBlock *NewBB, unsigned StageNum,
231 ValueMapTy *VRMap, InstrMapTy &InstrMap);
232 void rewriteScheduledInstr(MachineBasicBlock *BB, InstrMapTy &InstrMap,
233 unsigned CurStageNum, unsigned PhiNum,
234 MachineInstr *Phi, Register OldReg,
235 Register NewReg, Register PrevReg = Register());
236 bool isLoopCarried(MachineInstr &Phi);
237
238 // Check if register at StageNum is defined by a new phi instruction generated
239 // in kernel or epilog. If found, return register from VRMapPhi. Else return
240 // register from VRMap.
241 Register getMapPhiReg(ValueMapTy *VRMap, ValueMapTy *VRMapPhi,
242 unsigned StageNum, Register OldReg) {
243 if (Register R = VRMapPhi[StageNum].lookup(OldReg))
244 return R;
245 return VRMap[StageNum].lookup(OldReg);
246 }
247
248 /// Return the max. number of stages/iterations that can occur between a
249 /// register definition and its uses.
250 unsigned getStagesForReg(Register Reg, unsigned CurStage) {
251 std::pair<unsigned, bool> Stages = RegToStageDiff[Reg];
252 if ((int)CurStage > Schedule.getNumStages() - 1 && Stages.first == 0 &&
253 Stages.second)
254 return 1;
255 return Stages.first;
256 }
257
258 /// The number of stages for a Phi is a little different than other
259 /// instructions. The minimum value computed in RegToStageDiff is 1
260 /// because we assume the Phi is needed for at least 1 iteration.
261 /// This is not the case if the loop value is scheduled prior to the
262 /// Phi in the same stage. This function returns the number of stages
263 /// or iterations needed between the Phi definition and any uses.
264 unsigned getStagesForPhi(Register Reg) {
265 std::pair<unsigned, bool> Stages = RegToStageDiff[Reg];
266 if (Stages.second)
267 return Stages.first;
268 return Stages.first - 1;
269 }
270
271public:
272 /// Create a new ModuloScheduleExpander.
273 /// \arg InstrChanges Modifications to make to instructions with memory
274 /// operands.
275 /// FIXME: InstrChanges is opaque and is an implementation detail of an
276 /// optimization in MachinePipeliner that crosses abstraction boundaries.
278 LiveIntervals &LIS, InstrChangesTy InstrChanges,
279 MachineDominatorTree *MDT = nullptr)
280 : Schedule(S), MF(MF), ST(MF.getSubtarget()), MRI(MF.getRegInfo()),
281 TII(ST.getInstrInfo()), LIS(LIS),
282 MDTU(MDT, MachineDomTreeUpdater::UpdateStrategy::Eager),
283 InstrChanges(std::move(InstrChanges)) {}
284
285 /// Performs the actual expansion.
286 LLVM_ABI void expand();
287 /// Performs final cleanup after expansion.
288 LLVM_ABI void cleanup();
289
290 /// Returns the newly rewritten kernel block, or nullptr if this was
291 /// optimized away.
292 MachineBasicBlock *getRewrittenKernel() { return NewKernel; }
293};
294
295/// A reimplementation of ModuloScheduleExpander. It works by generating a
296/// standalone kernel loop and peeling out the prologs and epilogs.
298public:
301 MachineDominatorTree *MDT = nullptr)
302 : Schedule(S), MF(MF), ST(MF.getSubtarget()), MRI(MF.getRegInfo()),
303 TII(ST.getInstrInfo()), LIS(LIS),
304 MDTU(MDT, MachineDomTreeUpdater::UpdateStrategy::Eager) {}
305
306 LLVM_ABI void expand();
307
308 /// Runs ModuloScheduleExpander and treats it as a golden input to validate
309 /// aspects of the code generated by PeelingModuloScheduleExpander.
311
312protected:
317 const TargetInstrInfo *TII = nullptr;
318 LiveIntervals *LIS = nullptr;
320
321 /// The original loop block that gets rewritten in-place.
323 /// The original loop preheader.
325 /// All prolog and epilog blocks.
327 /// For every block, the stages that are produced.
329 /// For every block, the stages that are available. A stage can be available
330 /// but not produced (in the epilog) or produced but not available (in the
331 /// prolog).
333 /// When peeling the epilogue keep track of the distance between the phi
334 /// nodes and the kernel.
336
337 /// CanonicalMIs and BlockMIs form a bidirectional map between any of the
338 /// loop kernel clones.
342
343 /// State passed from peelKernel to peelPrologAndEpilogs().
344 std::deque<MachineBasicBlock *> PeeledFront, PeeledBack;
345 /// Illegal phis that need to be deleted once we re-link stages.
347
348 /// Converts BB from the original loop body to the rewritten, pipelined
349 /// steady-state.
350 LLVM_ABI void rewriteKernel();
351
352 /// Peels one iteration of the rewritten kernel (BB) in the specified
353 /// direction.
355 // Delete instructions whose stage is less than MinStage in the given basic
356 // block.
357 LLVM_ABI void filterInstructions(MachineBasicBlock *MB, int MinStage);
358 // Move instructions of the given stage from sourceBB to DestBB. Remap the phi
359 // instructions to keep a valid IR.
361 MachineBasicBlock *SourceBB,
362 unsigned Stage);
363 /// Peel the kernel forwards and backwards to produce prologs and epilogs,
364 /// and stitch them together.
366 /// All prolog and epilog blocks are clones of the kernel, so any produced
367 /// register in one block has an corollary in all other blocks.
370 /// Change all users of MI, if MI is predicated out
371 /// (LiveStages[MI->getParent()] == false).
373 /// Insert branches between prologs, kernel and epilogs.
374 LLVM_ABI void fixupBranches();
375 /// Create a poor-man's LCSSA by cloning only the PHIs from the kernel block
376 /// to a block dominated by all prologs and epilogs. This allows us to treat
377 /// the loop exiting block as any other kernel clone.
379 /// Helper to get the stage of an instruction in the schedule.
381 if (auto It = CanonicalMIs.find(MI); It != CanonicalMIs.end())
382 MI = It->second;
383 return Schedule.getStage(MI);
384 }
385 /// Helper function to find the right canonical register for a phi instruction
386 /// coming from a peeled out prologue.
388 MachineInstr *Phi);
389 /// Target loop info before kernel peeling.
390 std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo> LoopInfo;
391};
392
393/// Expand the kernel using modulo variable expansion algorithm (MVE).
394/// It unrolls the kernel enough to avoid overlap of register lifetime.
396private:
397 using ValueMapTy = DenseMap<Register, Register>;
398 using MBBVectorTy = SmallVectorImpl<MachineBasicBlock *>;
400
401 ModuloSchedule &Schedule;
402 MachineFunction &MF;
403 const TargetSubtargetInfo &ST;
405 const TargetInstrInfo *TII = nullptr;
406 LiveIntervals &LIS;
408
409 MachineBasicBlock *OrigKernel = nullptr;
410 MachineBasicBlock *OrigPreheader = nullptr;
411 MachineBasicBlock *OrigExit = nullptr;
412 MachineBasicBlock *Check = nullptr;
413 MachineBasicBlock *Prolog = nullptr;
414 MachineBasicBlock *NewKernel = nullptr;
415 MachineBasicBlock *Epilog = nullptr;
416 MachineBasicBlock *NewPreheader = nullptr;
417 MachineBasicBlock *NewExit = nullptr;
418 std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo> LoopInfo;
419
420 /// The number of unroll required to avoid overlap of live ranges.
421 /// NumUnroll = 1 means no unrolling.
422 int NumUnroll;
423
424 void calcNumUnroll();
425 void generatePipelinedLoop();
426 void generateProlog(SmallVectorImpl<ValueMapTy> &VRMap);
427 void generatePhi(MachineInstr *OrigMI, int UnrollNum,
428 SmallVectorImpl<ValueMapTy> &PrologVRMap,
429 SmallVectorImpl<ValueMapTy> &KernelVRMap,
431 void generateKernel(SmallVectorImpl<ValueMapTy> &PrologVRMap,
432 SmallVectorImpl<ValueMapTy> &KernelVRMap,
433 InstrMapTy &LastStage0Insts);
434 void generateEpilog(SmallVectorImpl<ValueMapTy> &KernelVRMap,
435 SmallVectorImpl<ValueMapTy> &EpilogVRMap,
436 InstrMapTy &LastStage0Insts);
437 void mergeRegUsesAfterPipeline(Register OrigReg, Register NewReg);
438
439 MachineInstr *cloneInstr(MachineInstr *OldMI);
440
441 void updateInstrDef(MachineInstr *NewMI, ValueMapTy &VRMap, bool LastDef);
442
443 void updateInstrUse(MachineInstr *MI, int StageNum, int PhaseNum,
445 SmallVectorImpl<ValueMapTy> *PrevVRMap);
446
447 void insertCondBranch(MachineBasicBlock &MBB, int RequiredTC,
448 InstrMapTy &LastStage0Insts,
449 MachineBasicBlock &GreaterThan,
450 MachineBasicBlock &Otherwise);
451
452public:
454 LiveIntervals &LIS,
455 MachineDominatorTree *MDT = nullptr)
456 : Schedule(S), MF(MF), ST(MF.getSubtarget()), MRI(MF.getRegInfo()),
457 TII(ST.getInstrInfo()), LIS(LIS),
458 MDTU(MDT, MachineDomTreeUpdater::UpdateStrategy::Eager) {}
459
460 LLVM_ABI void expand();
461 LLVM_ABI static bool canApply(MachineLoop &L);
462};
463
464/// Expander that simply annotates each scheduled instruction with a post-instr
465/// symbol that can be consumed by the ModuloScheduleTest pass.
466///
467/// The post-instr symbol is a way of annotating an instruction that can be
468/// roundtripped in MIR. The syntax is:
469/// MYINST %0, post-instr-symbol <mcsymbol Stage-1_Cycle-5>
471 MachineFunction &MF;
473
474public:
477
478 /// Performs the annotation.
479 LLVM_ABI void annotate();
480};
481
482} // end namespace llvm
483
484#endif // LLVM_CODEGEN_MODULOSCHEDULE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
#define LLVM_ABI
Definition Compiler.h:211
IRTranslator LLVM IR MI
static bool lookup(const GsymReader &GR, GsymDataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
Promote Memory to Register
Definition Mem2Reg.cpp:110
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
Definition DenseMap.h:793
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
ModuloScheduleExpanderMVE(MachineFunction &MF, ModuloSchedule &S, LiveIntervals &LIS, MachineDominatorTree *MDT=nullptr)
static LLVM_ABI bool canApply(MachineLoop &L)
Check if ModuloScheduleExpanderMVE can be applied to L.
MachineBasicBlock * getRewrittenKernel()
Returns the newly rewritten kernel block, or nullptr if this was optimized away.
LLVM_ABI void cleanup()
Performs final cleanup after expansion.
LLVM_ABI void expand()
Performs the actual expansion.
ModuloScheduleExpander(MachineFunction &MF, ModuloSchedule &S, LiveIntervals &LIS, InstrChangesTy InstrChanges, MachineDominatorTree *MDT=nullptr)
Create a new ModuloScheduleExpander.
DenseMap< MachineInstr *, std::pair< Register, int64_t > > InstrChangesTy
LLVM_ABI void annotate()
Performs the annotation.
ModuloScheduleTestAnnotater(MachineFunction &MF, ModuloSchedule &S)
Represents a schedule for a single-block loop.
int getNumStages() const
Return the number of stages contained in this schedule, which is the largest stage index + 1.
MachineLoop * getLoop() const
Return the single-block loop being scheduled.
ArrayRef< MachineInstr * > getInstructions()
Return the rescheduled instructions in order.
LLVM_ABI void print(raw_ostream &OS)
int getCycle(MachineInstr *MI)
Return the cycle that MI is scheduled at, or -1.
void setStage(MachineInstr *MI, int MIStage)
Set the stage of a newly created instruction.
int getStage(MachineInstr *MI)
Return the stage that MI is scheduled in, or -1.
ModuloSchedule(MachineFunction &MF, MachineLoop *Loop, std::vector< MachineInstr * > ScheduledInstrs, DenseMap< MachineInstr *, int > Cycle, DenseMap< MachineInstr *, int > Stage)
Create a new ModuloSchedule.
int getFirstCycle()
Return the first cycle in the schedule, which is the cycle index of the first instruction.
int getFinalCycle()
Return the final cycle in the schedule, which is the cycle index of the last instruction.
const TargetSubtargetInfo & ST
std::deque< MachineBasicBlock * > PeeledBack
SmallVector< MachineInstr *, 4 > IllegalPhisToDelete
Illegal phis that need to be deleted once we re-link stages.
DenseMap< MachineInstr *, MachineInstr * > CanonicalMIs
CanonicalMIs and BlockMIs form a bidirectional map between any of the loop kernel clones.
SmallVector< MachineBasicBlock *, 4 > Prologs
All prolog and epilog blocks.
LLVM_ABI MachineBasicBlock * peelKernel(LoopPeelDirection LPD)
Peels one iteration of the rewritten kernel (BB) in the specified direction.
PeelingModuloScheduleExpander(MachineFunction &MF, ModuloSchedule &S, LiveIntervals *LIS, MachineDominatorTree *MDT=nullptr)
std::deque< MachineBasicBlock * > PeeledFront
State passed from peelKernel to peelPrologAndEpilogs().
unsigned getStage(MachineInstr *MI)
Helper to get the stage of an instruction in the schedule.
LLVM_ABI void rewriteUsesOf(MachineInstr *MI)
Change all users of MI, if MI is predicated out (LiveStages[MI->getParent()] == false).
SmallVector< MachineBasicBlock *, 4 > Epilogs
DenseMap< MachineBasicBlock *, BitVector > AvailableStages
For every block, the stages that are available.
std::unique_ptr< TargetInstrInfo::PipelinerLoopInfo > LoopInfo
Target loop info before kernel peeling.
DenseMap< std::pair< MachineBasicBlock *, MachineInstr * >, MachineInstr * > BlockMIs
LLVM_ABI Register getEquivalentRegisterIn(Register Reg, MachineBasicBlock *BB)
All prolog and epilog blocks are clones of the kernel, so any produced register in one block has an c...
MachineBasicBlock * Preheader
The original loop preheader.
LLVM_ABI void rewriteKernel()
Converts BB from the original loop body to the rewritten, pipelined steady-state.
DenseMap< MachineInstr *, unsigned > PhiNodeLoopIteration
When peeling the epilogue keep track of the distance between the phi nodes and the kernel.
DenseMap< MachineBasicBlock *, BitVector > LiveStages
For every block, the stages that are produced.
LLVM_ABI void filterInstructions(MachineBasicBlock *MB, int MinStage)
LLVM_ABI void peelPrologAndEpilogs()
Peel the kernel forwards and backwards to produce prologs and epilogs, and stitch them together.
MachineBasicBlock * BB
The original loop block that gets rewritten in-place.
LLVM_ABI void fixupBranches()
Insert branches between prologs, kernel and epilogs.
LLVM_ABI MachineBasicBlock * CreateLCSSAExitingBlock()
Create a poor-man's LCSSA by cloning only the PHIs from the kernel block to a block dominated by all ...
LLVM_ABI void validateAgainstModuloScheduleExpander()
Runs ModuloScheduleExpander and treats it as a golden input to validate aspects of the code generated...
LLVM_ABI Register getPhiCanonicalReg(MachineInstr *CanonicalPhi, MachineInstr *Phi)
Helper function to find the right canonical register for a phi instruction coming from a peeled out p...
LLVM_ABI void moveStageBetweenBlocks(MachineBasicBlock *DestBB, MachineBasicBlock *SourceBB, unsigned Stage)
Wrapper class representing virtual and physical registers.
Definition Register.h:20
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.
TargetInstrInfo - Interface to description of machine instruction set.
TargetSubtargetInfo - Generic base class for all target subtargets.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1933
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878