#define DEBUG_TYPE …
#include "HexagonTargetMachine.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
#include "llvm/CodeGen/SchedulerRegistry.h"
#include "llvm/Support/Debug.h"
usingnamespacellvm;
static cl::opt<bool>
DisableLoopAlign("disable-hexagon-loop-align", cl::Hidden,
cl::desc("Disable Hexagon loop alignment pass"));
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<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>
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>
LoopBndlAlignLimit("hexagon-loop-bundle-align-limit", cl::Hidden,
cl::init(4),
cl::desc("Set hexagon loop align bundle 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"));
static cl::opt<uint32_t>
LoopEdgeThreshold("hexagon-loop-edge-threshold", cl::Hidden, cl::init(7500),
cl::desc("Set hexagon loop align edge theshold"));
namespace llvm {
FunctionPass *createHexagonLoopAlign();
void initializeHexagonLoopAlignPass(PassRegistry &);
}
namespace {
class HexagonLoopAlign : public MachineFunctionPass { … };
char HexagonLoopAlign::ID = …;
bool HexagonLoopAlign::shouldBalignLoop(MachineBasicBlock &BB,
bool AboveThres) { … }
bool HexagonLoopAlign::isSingleLoop(MachineBasicBlock &MBB) { … }
bool HexagonLoopAlign::attemptToBalignSmallLoop(MachineFunction &MF,
MachineBasicBlock &MBB) { … }
bool HexagonLoopAlign::runOnMachineFunction(MachineFunction &MF) { … }
}
INITIALIZE_PASS(…)
FunctionPass *llvm::createHexagonLoopAlign() { … }