| OLD | NEW |
| 1 //===-- PPCBranchSelector.cpp - Emit long conditional branches ------------===// | 1 //===-- PPCBranchSelector.cpp - Emit long conditional branches ------------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file contains a pass that scans a machine function to determine which | 10 // This file contains a pass that scans a machine function to determine which |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 while (MadeChange) { | 105 while (MadeChange) { |
| 106 // Iteratively expand branches until we reach a fixed point. | 106 // Iteratively expand branches until we reach a fixed point. |
| 107 MadeChange = false; | 107 MadeChange = false; |
| 108 | 108 |
| 109 for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; | 109 for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; |
| 110 ++MFI) { | 110 ++MFI) { |
| 111 MachineBasicBlock &MBB = *MFI; | 111 MachineBasicBlock &MBB = *MFI; |
| 112 unsigned MBBStartOffset = 0; | 112 unsigned MBBStartOffset = 0; |
| 113 for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); | 113 for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); |
| 114 I != E; ++I) { | 114 I != E; ++I) { |
| 115 MachineBasicBlock *Dest = 0; | 115 if (I->getOpcode() != PPC::BCC || I->getOperand(2).isImm()) { |
| 116 if (I->getOpcode() == PPC::BCC && !I->getOperand(2).isImm()) | |
| 117 Dest = I->getOperand(2).getMBB(); | |
| 118 else if ((I->getOpcode() == PPC::BDNZ8 || I->getOpcode() == PPC::BDNZ || | |
| 119 I->getOpcode() == PPC::BDZ8 || I->getOpcode() == PPC::BDZ) && | |
| 120 !I->getOperand(0).isImm()) | |
| 121 Dest = I->getOperand(0).getMBB(); | |
| 122 | |
| 123 if (!Dest) { | |
| 124 MBBStartOffset += TII->GetInstSizeInBytes(I); | 116 MBBStartOffset += TII->GetInstSizeInBytes(I); |
| 125 continue; | 117 continue; |
| 126 } | 118 } |
| 127 | 119 |
| 128 // Determine the offset from the current branch to the destination | 120 // Determine the offset from the current branch to the destination |
| 129 // block. | 121 // block. |
| 122 MachineBasicBlock *Dest = I->getOperand(2).getMBB(); |
| 123 |
| 130 int BranchSize; | 124 int BranchSize; |
| 131 if (Dest->getNumber() <= MBB.getNumber()) { | 125 if (Dest->getNumber() <= MBB.getNumber()) { |
| 132 // If this is a backwards branch, the delta is the offset from the | 126 // If this is a backwards branch, the delta is the offset from the |
| 133 // start of this block to this branch, plus the sizes of all blocks | 127 // start of this block to this branch, plus the sizes of all blocks |
| 134 // from this block to the dest. | 128 // from this block to the dest. |
| 135 BranchSize = MBBStartOffset; | 129 BranchSize = MBBStartOffset; |
| 136 | 130 |
| 137 for (unsigned i = Dest->getNumber(), e = MBB.getNumber(); i != e; ++i) | 131 for (unsigned i = Dest->getNumber(), e = MBB.getNumber(); i != e; ++i) |
| 138 BranchSize += BlockSizes[i]; | 132 BranchSize += BlockSizes[i]; |
| 139 } else { | 133 } else { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 MadeChange = true; | 186 MadeChange = true; |
| 193 } | 187 } |
| 194 } | 188 } |
| 195 EverMadeChange |= MadeChange; | 189 EverMadeChange |= MadeChange; |
| 196 } | 190 } |
| 197 | 191 |
| 198 BlockSizes.clear(); | 192 BlockSizes.clear(); |
| 199 return true; | 193 return true; |
| 200 } | 194 } |
| 201 | 195 |
| OLD | NEW |