LLVM  11.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::PeelingModuloScheduleExpander Class Reference

A reimplementation of ModuloScheduleExpander. More...

#include "llvm/CodeGen/ModuloSchedule.h"

Collaboration diagram for llvm::PeelingModuloScheduleExpander:
Collaboration graph
[legend]

Public Member Functions

 PeelingModuloScheduleExpander (MachineFunction &MF, ModuloSchedule &S, LiveIntervals *LIS)
 
virtual ~PeelingModuloScheduleExpander ()
 
virtual void expand ()
 
void validateAgainstModuloScheduleExpander ()
 Runs ModuloScheduleExpander and treats it as a golden input to validate aspects of the code generated by PeelingModuloScheduleExpander. More...
 

Protected Member Functions

void rewriteKernel ()
 Converts BB from the original loop body to the rewritten, pipelined steady-state. More...
 
MachineBasicBlockpeelKernel (LoopPeelDirection LPD)
 Peels one iteration of the rewritten kernel (BB) in the specified direction. More...
 
void filterInstructions (MachineBasicBlock *MB, int MinStage)
 
void moveStageBetweenBlocks (MachineBasicBlock *DestBB, MachineBasicBlock *SourceBB, unsigned Stage)
 
void peelPrologAndEpilogs ()
 Peel the kernel forwards and backwards to produce prologs and epilogs, and stitch them together. More...
 
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 corollary in all other blocks. More...
 
void rewriteUsesOf (MachineInstr *MI)
 Change all users of MI, if MI is predicated out (LiveStages[MI->getParent()] == false). More...
 
void fixupBranches ()
 Insert branches between prologs, kernel and epilogs. More...
 
MachineBasicBlockCreateLCSSAExitingBlock ()
 Create a poor-man's LCSSA by cloning only the PHIs from the kernel block to a block dominated by all prologs and epilogs. More...
 
unsigned getStage (MachineInstr *MI)
 Helper to get the stage of an instruction in the schedule. More...
 
Register getPhiCanonicalReg (MachineInstr *CanonicalPhi, MachineInstr *Phi)
 Helper function to find the right canonical register for a phi instruction coming from a peeled out prologue. More...
 

Protected Attributes

ModuloScheduleSchedule
 
MachineFunctionMF
 
const TargetSubtargetInfoST
 
MachineRegisterInfoMRI
 
const TargetInstrInfoTII
 
LiveIntervalsLIS
 
MachineBasicBlockBB
 The original loop block that gets rewritten in-place. More...
 
MachineBasicBlockPreheader
 The original loop preheader. More...
 
SmallVector< MachineBasicBlock *, 4 > Prologs
 All prolog and epilog blocks. More...
 
SmallVector< MachineBasicBlock *, 4 > Epilogs
 
DenseMap< MachineBasicBlock *, BitVectorLiveStages
 For every block, the stages that are produced. More...
 
DenseMap< MachineBasicBlock *, BitVectorAvailableStages
 For every block, the stages that are available. More...
 
DenseMap< MachineInstr *, unsignedPhiNodeLoopIteration
 When peeling the epilogue keep track of the distance between the phi nodes and the kernel. More...
 
DenseMap< MachineInstr *, MachineInstr * > CanonicalMIs
 CanonicalMIs and BlockMIs form a bidirectional map between any of the loop kernel clones. More...
 
DenseMap< std::pair< MachineBasicBlock *, MachineInstr * >, MachineInstr * > BlockMIs
 
std::deque< MachineBasicBlock * > PeeledFront
 State passed from peelKernel to peelPrologAndEpilogs(). More...
 
std::deque< MachineBasicBlock * > PeeledBack
 
SmallVector< MachineInstr *, 4 > IllegalPhisToDelete
 Illegal phis that need to be deleted once we re-link stages. More...
 
std::unique_ptr< TargetInstrInfo::PipelinerLoopInfoLoopInfo
 Target loop info before kernel peeling. More...
 

Detailed Description

A reimplementation of ModuloScheduleExpander.

It works by generating a standalone kernel loop and peeling out the prologs and epilogs.

Definition at line 279 of file ModuloSchedule.h.

Constructor & Destructor Documentation

◆ PeelingModuloScheduleExpander()

llvm::PeelingModuloScheduleExpander::PeelingModuloScheduleExpander ( MachineFunction MF,
ModuloSchedule S,
LiveIntervals LIS 
)
inline

Definition at line 281 of file ModuloSchedule.h.

◆ ~PeelingModuloScheduleExpander()

virtual llvm::PeelingModuloScheduleExpander::~PeelingModuloScheduleExpander ( )
inlinevirtual

Definition at line 285 of file ModuloSchedule.h.

References expand().

Member Function Documentation

◆ CreateLCSSAExitingBlock()

MachineBasicBlock * PeelingModuloScheduleExpander::CreateLCSSAExitingBlock ( )
protected

◆ expand()

void PeelingModuloScheduleExpander::expand ( )
virtual

◆ filterInstructions()

void PeelingModuloScheduleExpander::filterInstructions ( MachineBasicBlock MB,
int  MinStage 
)
protected

◆ fixupBranches()

void PeelingModuloScheduleExpander::fixupBranches ( )
protected

◆ getEquivalentRegisterIn()

Register PeelingModuloScheduleExpander::getEquivalentRegisterIn ( Register  Reg,
MachineBasicBlock BB 
)
protected

All prolog and epilog blocks are clones of the kernel, so any produced register in one block has an corollary in all other blocks.

Definition at line 1888 of file ModuloSchedule.cpp.

References llvm::MachineInstr::findRegisterDefOperandIdx(), MI, and MRI.

◆ getPhiCanonicalReg()

Register PeelingModuloScheduleExpander::getPhiCanonicalReg ( MachineInstr CanonicalPhi,
MachineInstr Phi 
)
protected

Helper function to find the right canonical register for a phi instruction coming from a peeled out prologue.

Definition at line 1710 of file ModuloSchedule.cpp.

References assert(), llvm::MachineOperand::getMBB(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), I, llvm::MachineInstr::isPHI(), MRI, and std::swap().

◆ getStage()

unsigned llvm::PeelingModuloScheduleExpander::getStage ( MachineInstr MI)
inlineprotected

Helper to get the stage of an instruction in the schedule.

Definition at line 358 of file ModuloSchedule.h.

References llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::count(), and llvm::ModuloSchedule::getStage().

◆ moveStageBetweenBlocks()

void PeelingModuloScheduleExpander::moveStageBetweenBlocks ( MachineBasicBlock DestBB,
MachineBasicBlock SourceBB,
unsigned  Stage 
)
protected

◆ peelKernel()

MachineBasicBlock * PeelingModuloScheduleExpander::peelKernel ( LoopPeelDirection  LPD)
protected

Peels one iteration of the rewritten kernel (BB) in the specified direction.

Definition at line 1580 of file ModuloSchedule.cpp.

References llvm::MachineBasicBlock::begin(), I, llvm::LPD_Front, MRI, llvm::PeelSingleBlockLoop(), and TII.

◆ peelPrologAndEpilogs()

void PeelingModuloScheduleExpander::peelPrologAndEpilogs ( )
protected

◆ rewriteKernel()

void PeelingModuloScheduleExpander::rewriteKernel ( )
protected

Converts BB from the original loop body to the rewritten, pipelined steady-state.

Definition at line 1985 of file ModuloSchedule.cpp.

◆ rewriteUsesOf()

void PeelingModuloScheduleExpander::rewriteUsesOf ( MachineInstr MI)
protected

◆ validateAgainstModuloScheduleExpander()

void PeelingModuloScheduleExpander::validateAgainstModuloScheduleExpander ( )

Member Data Documentation

◆ AvailableStages

DenseMap<MachineBasicBlock *, BitVector> llvm::PeelingModuloScheduleExpander::AvailableStages
protected

For every block, the stages that are available.

A stage can be available but not produced (in the epilog) or produced but not available (in the prolog).

Definition at line 312 of file ModuloSchedule.h.

◆ BB

MachineBasicBlock* llvm::PeelingModuloScheduleExpander::BB
protected

The original loop block that gets rewritten in-place.

Definition at line 302 of file ModuloSchedule.h.

◆ BlockMIs

DenseMap<std::pair<MachineBasicBlock *, MachineInstr *>, MachineInstr *> llvm::PeelingModuloScheduleExpander::BlockMIs
protected

Definition at line 321 of file ModuloSchedule.h.

◆ CanonicalMIs

DenseMap<MachineInstr *, MachineInstr *> llvm::PeelingModuloScheduleExpander::CanonicalMIs
protected

CanonicalMIs and BlockMIs form a bidirectional map between any of the loop kernel clones.

Definition at line 319 of file ModuloSchedule.h.

◆ Epilogs

SmallVector<MachineBasicBlock *, 4> llvm::PeelingModuloScheduleExpander::Epilogs
protected

Definition at line 306 of file ModuloSchedule.h.

◆ IllegalPhisToDelete

SmallVector<MachineInstr *, 4> llvm::PeelingModuloScheduleExpander::IllegalPhisToDelete
protected

Illegal phis that need to be deleted once we re-link stages.

Definition at line 326 of file ModuloSchedule.h.

◆ LIS

LiveIntervals* llvm::PeelingModuloScheduleExpander::LIS
protected

Definition at line 299 of file ModuloSchedule.h.

◆ LiveStages

DenseMap<MachineBasicBlock *, BitVector> llvm::PeelingModuloScheduleExpander::LiveStages
protected

For every block, the stages that are produced.

Definition at line 308 of file ModuloSchedule.h.

◆ LoopInfo

std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo> llvm::PeelingModuloScheduleExpander::LoopInfo
protected

Target loop info before kernel peeling.

Definition at line 367 of file ModuloSchedule.h.

◆ MF

MachineFunction& llvm::PeelingModuloScheduleExpander::MF
protected

Definition at line 295 of file ModuloSchedule.h.

◆ MRI

MachineRegisterInfo& llvm::PeelingModuloScheduleExpander::MRI
protected

Definition at line 297 of file ModuloSchedule.h.

◆ PeeledBack

std::deque<MachineBasicBlock *> llvm::PeelingModuloScheduleExpander::PeeledBack
protected

Definition at line 324 of file ModuloSchedule.h.

◆ PeeledFront

std::deque<MachineBasicBlock *> llvm::PeelingModuloScheduleExpander::PeeledFront
protected

State passed from peelKernel to peelPrologAndEpilogs().

Definition at line 324 of file ModuloSchedule.h.

◆ PhiNodeLoopIteration

DenseMap<MachineInstr *, unsigned> llvm::PeelingModuloScheduleExpander::PhiNodeLoopIteration
protected

When peeling the epilogue keep track of the distance between the phi nodes and the kernel.

Definition at line 315 of file ModuloSchedule.h.

◆ Preheader

MachineBasicBlock* llvm::PeelingModuloScheduleExpander::Preheader
protected

The original loop preheader.

Definition at line 304 of file ModuloSchedule.h.

◆ Prologs

SmallVector<MachineBasicBlock *, 4> llvm::PeelingModuloScheduleExpander::Prologs
protected

All prolog and epilog blocks.

Definition at line 306 of file ModuloSchedule.h.

◆ Schedule

ModuloSchedule& llvm::PeelingModuloScheduleExpander::Schedule
protected

Definition at line 294 of file ModuloSchedule.h.

◆ ST

const TargetSubtargetInfo& llvm::PeelingModuloScheduleExpander::ST
protected

Definition at line 296 of file ModuloSchedule.h.

◆ TII

const TargetInstrInfo* llvm::PeelingModuloScheduleExpander::TII
protected

Definition at line 298 of file ModuloSchedule.h.


The documentation for this class was generated from the following files: