diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
commit | 01095a5d43bbfde13731688ddcf6048ebb8b7721 (patch) | |
tree | 4def12e759965de927d963ac65840d663ef9d1ea /lib/Target/MSP430/MSP430BranchSelector.cpp | |
parent | f0f4822ed4b66e3579e92a89f368f8fb860e218e (diff) |
Diffstat (limited to 'lib/Target/MSP430/MSP430BranchSelector.cpp')
-rw-r--r-- | lib/Target/MSP430/MSP430BranchSelector.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/Target/MSP430/MSP430BranchSelector.cpp b/lib/Target/MSP430/MSP430BranchSelector.cpp index 606abc250d98f..511e5bcdec0d2 100644 --- a/lib/Target/MSP430/MSP430BranchSelector.cpp +++ b/lib/Target/MSP430/MSP430BranchSelector.cpp @@ -39,6 +39,11 @@ namespace { bool runOnMachineFunction(MachineFunction &Fn) override; + MachineFunctionProperties getRequiredProperties() const override { + return MachineFunctionProperties().set( + MachineFunctionProperties::Property::AllVRegsAllocated); + } + const char *getPassName() const override { return "MSP430 Branch Selector"; } @@ -62,16 +67,12 @@ bool MSP430BSel::runOnMachineFunction(MachineFunction &Fn) { // Measure each MBB and compute a size for the entire function. unsigned FuncSize = 0; - for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; - ++MFI) { - MachineBasicBlock *MBB = &*MFI; - + for (MachineBasicBlock &MBB : Fn) { unsigned BlockSize = 0; - for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end(); - MBBI != EE; ++MBBI) - BlockSize += TII->GetInstSizeInBytes(MBBI); + for (MachineInstr &MI : MBB) + BlockSize += TII->GetInstSizeInBytes(MI); - BlockSizes[MBB->getNumber()] = BlockSize; + BlockSizes[MBB.getNumber()] = BlockSize; FuncSize += BlockSize; } @@ -106,7 +107,7 @@ bool MSP430BSel::runOnMachineFunction(MachineFunction &Fn) { I != E; ++I) { if ((I->getOpcode() != MSP430::JCC || I->getOperand(0).isImm()) && I->getOpcode() != MSP430::JMP) { - MBBStartOffset += TII->GetInstSizeInBytes(I); + MBBStartOffset += TII->GetInstSizeInBytes(*I); continue; } @@ -140,8 +141,8 @@ bool MSP430BSel::runOnMachineFunction(MachineFunction &Fn) { // Otherwise, we have to expand it to a long branch. unsigned NewSize; - MachineInstr *OldBranch = I; - DebugLoc dl = OldBranch->getDebugLoc(); + MachineInstr &OldBranch = *I; + DebugLoc dl = OldBranch.getDebugLoc(); if (I->getOpcode() == MSP430::JMP) { NewSize = 4; @@ -163,7 +164,7 @@ bool MSP430BSel::runOnMachineFunction(MachineFunction &Fn) { I = BuildMI(MBB, I, dl, TII->get(MSP430::Bi)).addMBB(Dest); // Remove the old branch from the function. - OldBranch->eraseFromParent(); + OldBranch.eraseFromParent(); // Remember that this instruction is NewSize bytes, increase the size of the // block by NewSize-2, remember to iterate. |