60 #ifndef LLVM_LIB_CODEGEN_MODULOSCHEDULE_H 61 #define LLVM_LIB_CODEGEN_MODULOSCHEDULE_H 72 class MachineBasicBlock;
86 std::vector<MachineInstr *> ScheduledInstrs;
106 std::vector<MachineInstr *> ScheduledInstrs,
109 : Loop(Loop), ScheduledInstrs(ScheduledInstrs), Cycle(
std::move(Cycle)),
110 Stage(
std::move(Stage)) {
112 for (
auto &KV : this->Stage)
113 NumStages =
std::max(NumStages, KV.second);
134 auto I = Stage.
find(MI);
135 return I == Stage.
end() ? -1 :
I->second;
140 auto I = Cycle.
find(MI);
141 return I == Cycle.
end() ? -1 :
I->second;
172 std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
LoopInfo;
178 std::map<unsigned, std::pair<unsigned, bool>> RegToStageDiff;
183 void generatePipelinedLoop();
192 unsigned LastStageNum,
unsigned CurStageNum,
197 unsigned LastStageNum,
unsigned CurStageNum,
bool IsLast);
208 unsigned InstStageNum);
210 unsigned InstStageNum);
211 void updateInstruction(
MachineInstr *NewMI,
bool LastDef,
212 unsigned CurStageNum,
unsigned InstrStageNum,
215 unsigned getPrevMapVal(
unsigned StageNum,
unsigned PhiStage,
unsigned LoopVal,
221 unsigned CurStageNum,
unsigned PhiNum,
223 unsigned NewReg,
unsigned PrevReg = 0);
228 unsigned getStagesForReg(
int Reg,
unsigned CurStage) {
229 std::pair<unsigned, bool> Stages = RegToStageDiff[
Reg];
230 if ((
int)CurStage > Schedule.
getNumStages() - 1 && Stages.first == 0 &&
242 unsigned getStagesForPhi(
int Reg) {
243 std::pair<unsigned, bool> Stages = RegToStageDiff[
Reg];
246 return Stages.first - 1;
257 : Schedule(S), MF(MF), ST(MF.getSubtarget()), MRI(MF.getRegInfo()),
258 TII(ST.getInstrInfo()), LIS(LIS),
259 InstrChanges(
std::move(InstrChanges)) {}
304 std::deque<MachineBasicBlock *> PeeledFront, PeeledBack;
311 : Schedule(S), MF(MF), ST(MF.getSubtarget()), MRI(MF.getRegInfo()),
312 TII(ST.getInstrInfo()), LIS(LIS) {}
318 void validateAgainstModuloScheduleExpander();
323 void rewriteKernel();
338 void peelPrologAndEpilogs();
346 void fixupBranches();
353 if (CanonicalMIs.
count(MI))
354 MI = CanonicalMIs[MI];
361 std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
Info;
384 #endif // LLVM_LIB_CODEGEN_MODULOSCHEDULE_H
MachineLoop * getLoop() const
Return the single-block loop being scheduled.
This class represents lattice values for constants.
A reimplementation of ModuloScheduleExpander.
The ModuloScheduleExpander takes a ModuloSchedule and expands it in-place, rewriting the old loop and...
Represents a schedule for a single-block loop.
Expander that simply annotates each scheduled instruction with a post-instr symbol that can be consum...
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
const HexagonInstrInfo * TII
int getFirstCycle()
Return the first cycle in the schedule, which is the cycle index of the first instruction.
void print(raw_ostream &OS)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
ModuloScheduleTestAnnotater(MachineFunction &MF, ModuloSchedule &S)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Analysis containing CSE Info
TargetInstrInfo - Interface to description of machine instruction set.
iterator find(const_arg_type_t< KeyT > Val)
int getNumStages() const
Return the number of stages contained in this schedule, which is the largest stage index + 1...
unsigned const MachineRegisterInfo * MRI
static int64_t computeDelta(SectionEntry *A, SectionEntry *B)
static Expected< BitVector > expand(StringRef S, StringRef Original)
ArrayRef< MachineInstr * > getInstructions()
Return the rescheduled instructions in order.
ModuloScheduleExpander(MachineFunction &MF, ModuloSchedule &S, LiveIntervals &LIS, InstrChangesTy InstrChanges)
Create a new ModuloScheduleExpander.
int getCycle(MachineInstr *MI)
Return the cycle that MI is scheduled at, or -1.
MachineBasicBlock * getRewrittenKernel()
Returns the newly rewritten kernel block, or nullptr if this was optimized away.
Align max(MaybeAlign Lhs, Align Rhs)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
int getStage(MachineInstr *MI)
Return the stage that MI is scheduled in, or -1.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
int getFinalCycle()
Return the final cycle in the schedule, which is the cycle index of the last instruction.
ModuloSchedule(MachineFunction &MF, MachineLoop *Loop, std::vector< MachineInstr *> ScheduledInstrs, DenseMap< MachineInstr *, int > Cycle, DenseMap< MachineInstr *, int > Stage)
Create a new ModuloSchedule.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
TargetSubtargetInfo - Generic base class for all target subtargets.
Representation of each machine instruction.
Represents a single loop in the control flow graph.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
PeelingModuloScheduleExpander(MachineFunction &MF, ModuloSchedule &S, LiveIntervals *LIS)
This class implements an extremely fast bulk output stream that can only output to a stream...
Wrapper class representing virtual and physical registers.