18 #define DEBUG_TYPE "msp430-branch-select"
28 STATISTIC(NumExpanded,
"Number of branches expanded to long format");
36 std::vector<unsigned> BlockSizes;
40 virtual const char *getPassName()
const {
41 return "MSP430 Branch Selector";
51 return new MSP430BSel();
62 unsigned FuncSize = 0;
67 unsigned BlockSize = 0;
73 FuncSize += BlockSize;
79 if (FuncSize < (1 << 9)) {
93 bool MadeChange =
true;
94 bool EverMadeChange =
false;
102 unsigned MBBStartOffset = 0;
105 if ((
I->getOpcode() != MSP430::JCC ||
I->getOperand(0).isImm()) &&
106 I->getOpcode() != MSP430::JMP) {
120 BranchSize = MBBStartOffset;
123 BranchSize += BlockSizes[i];
127 BranchSize = -MBBStartOffset;
130 BranchSize += BlockSizes[i];
134 if (isInt<10>(BranchSize)) {
144 if (
I->getOpcode() == MSP430::JMP) {
155 BuildMI(MBB,
I, dl, TII->get(MSP430::JCC))
161 I =
BuildMI(MBB,
I, dl, TII->get(MSP430::Bi)).addMBB(Dest);
168 BlockSizes[MBB.
getNumber()] += NewSize-2;
169 MBBStartOffset += NewSize;
175 EverMadeChange |= MadeChange;
void push_back(const T &Elt)
unsigned getNumBlockIDs() const
const HexagonInstrInfo * TII
ID
LLVM Calling Convention Representation.
void RenumberBlocks(MachineBasicBlock *MBBFrom=0)
bool ReverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const
bundle_iterator< MachineInstr, instr_iterator > iterator
unsigned GetInstSizeInBytes(const MachineInstr *MI) const
FunctionPass * createMSP430BranchSelectionPass()
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
virtual const TargetInstrInfo * getInstrInfo() const
const TargetMachine & getTarget() const
const MachineInstrBuilder & addOperand(const MachineOperand &MO) const
BasicBlockListType::iterator iterator
DebugLoc getDebugLoc() const
STATISTIC(NumExpanded,"Number of branches expanded to long format")