#include "Hexagon.h"
#include "HexagonInstrInfo.h"
#include "HexagonSubtarget.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <iterator>
#define DEBUG_TYPE …
usingnamespacellvm;
static cl::opt<uint32_t>
BranchRelaxSafetyBuffer("branch-relax-safety-buffer", cl::init(200),
cl::Hidden, cl::desc("safety buffer size"));
namespace llvm {
FunctionPass *createHexagonBranchRelaxation();
void initializeHexagonBranchRelaxationPass(PassRegistry&);
}
namespace {
struct HexagonBranchRelaxation : public MachineFunctionPass { … };
char HexagonBranchRelaxation::ID = …;
}
INITIALIZE_PASS(…)
FunctionPass *llvm::createHexagonBranchRelaxation() { … }
bool HexagonBranchRelaxation::runOnMachineFunction(MachineFunction &MF) { … }
void HexagonBranchRelaxation::computeOffset(MachineFunction &MF,
DenseMap<MachineBasicBlock*, unsigned> &OffsetMap) { … }
bool HexagonBranchRelaxation::relaxBranches(MachineFunction &MF) { … }
bool HexagonBranchRelaxation::isJumpOutOfRange(MachineInstr &MI,
DenseMap<MachineBasicBlock*, unsigned> &BlockToInstOffset) { … }
bool HexagonBranchRelaxation::reGenerateBranch(MachineFunction &MF,
DenseMap<MachineBasicBlock*, unsigned> &BlockToInstOffset) { … }