18#define DEBUG_TYPE "hexagon-loop-align"
24 cl::desc(
"Disable Hexagon loop alignment pass"));
28 cl::desc(
"Set hexagon hvx loop upper bound align limit"));
32 cl::desc(
"Set hexagon tiny-core loop upper bound align limit"));
36 cl::desc(
"Set hexagon loop upper bound align limit"));
40 cl::desc(
"Set hexagon loop lower bound align limit"));
45 cl::desc(
"Set hexagon loop align bundle limit"));
49 cl::desc(
"Set hexagon tiny-core loop align bundle limit"));
53 cl::desc(
"Set hexagon loop align edge threshold"));
65 bool shouldBalignLoop(MachineBasicBlock &BB,
bool AboveThres);
66 bool isSingleLoop(MachineBasicBlock &
MBB);
67 bool attemptToBalignSmallLoop(MachineFunction &MF, MachineBasicBlock &
MBB);
69 void getAnalysisUsage(AnalysisUsage &AU)
const override {
70 AU.
addRequired<MachineBranchProbabilityInfoWrapperPass>();
71 AU.
addRequired<MachineBlockFrequencyInfoWrapperPass>();
75 StringRef getPassName()
const override {
return "Hexagon LoopAlign pass"; }
76 bool runOnMachineFunction(MachineFunction &MF)
override;
79char HexagonLoopAlign::ID = 0;
100 if (
II->isDebugInstr())
109 dbgs() <<
"Bundle Count : " << BndlCnt <<
"\n";
110 dbgs() <<
"Instruction Count : " << InstCnt <<
"\n";
113 unsigned LimitUB = 0;
130 BndlCnt <= LimitBndl;
133bool HexagonLoopAlign::isSingleLoop(MachineBasicBlock &
MBB) {
138bool HexagonLoopAlign::attemptToBalignSmallLoop(MachineFunction &MF,
139 MachineBasicBlock &
MBB) {
140 if (!isSingleLoop(
MBB))
143 const MachineBranchProbabilityInfo *MBPI =
144 &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
145 const MachineBlockFrequencyInfo *MBFI =
146 &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
151 BlockFrequency EdgeFreq = BlockFreq *
BrProb;
153 dbgs() <<
"Loop Align Pass:\n";
158 if (shouldBalignLoop(
MBB, AboveThres)) {
169bool HexagonLoopAlign::runOnMachineFunction(MachineFunction &MF) {
187 if (HTM->
getOptLevel() < CodeGenOptLevel::Aggressive)
193 MBBi != MBBe; ++MBBi) {
194 MachineBasicBlock &
MBB = *MBBi;
203 "Hexagon LoopAlign pass",
false,
false)
static cl::opt< uint32_t > LoopBndlAlignLimit("hexagon-loop-bundle-align-limit", cl::Hidden, cl::init(4), cl::desc("Set hexagon loop align bundle limit"))
static cl::opt< uint32_t > LoopAlignLimitUB("hexagon-loop-align-limit-ub", cl::Hidden, cl::init(8), cl::desc("Set hexagon loop upper bound align limit"))
static cl::opt< uint32_t > LoopAlignLimitLB("hexagon-loop-align-limit-lb", cl::Hidden, cl::init(4), cl::desc("Set hexagon loop lower bound align limit"))
static cl::opt< uint32_t > LoopEdgeThreshold("hexagon-loop-edge-threshold", cl::Hidden, cl::init(7500), cl::desc("Set hexagon loop align edge threshold"))
static cl::opt< uint32_t > HVXLoopAlignLimitUB("hexagon-hvx-loop-align-limit-ub", cl::Hidden, cl::init(16), cl::desc("Set hexagon hvx loop upper bound align limit"))
static cl::opt< bool > DisableLoopAlign("disable-hexagon-loop-align", cl::Hidden, cl::desc("Disable Hexagon loop alignment pass"))
static cl::opt< uint32_t > TinyLoopAlignLimitUB("hexagon-tiny-loop-align-limit-ub", cl::Hidden, cl::init(16), cl::desc("Set hexagon tiny-core loop upper bound align limit"))
static cl::opt< uint32_t > TinyLoopBndlAlignLimit("hexagon-tiny-loop-bundle-align-limit", cl::Hidden, cl::init(8), cl::desc("Set hexagon tiny-core loop align bundle limit"))
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
AnalysisUsage & addRequired()
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
FunctionPass class - This class is used to implement most global optimizations.
bool isHVXVec(const MachineInstr &MI) const
bool isEndLoopN(unsigned Opcode) const
const HexagonInstrInfo * getInstrInfo() const override
instr_iterator instr_begin()
unsigned succ_size() const
void setAlignment(Align A)
Set alignment of the basic block.
Instructions::iterator instr_iterator
instr_iterator instr_end()
LLVM_ABI bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
LLVM_ABI BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
BranchProbability getEdgeProbability(const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
BasicBlockListType::iterator iterator
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Primary interface to the complete machine description for the target machine.
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createHexagonLoopAlign()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.