llvm.org GIT mirror llvm / 81b16a3
Add getTopBlock and getBottomBlock member functions to MachineLoopInfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84596 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
2 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3737 class MachineLoop : public LoopBase {
3838 public:
3939 MachineLoop();
40
41 /// getTopBlock - Return the "top" block in the loop, which is the first
42 /// block in the linear layout, ignoring any parts of the loop not
43 /// contiguous with the part the contains the header.
44 MachineBasicBlock *getTopBlock();
45
46 /// getBottomBlock - Return the "bottom" block in the loop, which is the last
47 /// block in the linear layout, ignoring any parts of the loop not
48 /// contiguous with the part the contains the header.
49 MachineBasicBlock *getBottomBlock();
50
4051 private:
4152 friend class LoopInfoBase;
4253 explicit MachineLoop(MachineBasicBlock *MBB)
4242 AU.addRequired();
4343 MachineFunctionPass::getAnalysisUsage(AU);
4444 }
45
46 MachineBasicBlock *MachineLoop::getTopBlock() {
47 MachineBasicBlock *TopMBB = getHeader();
48 MachineFunction::iterator Begin = TopMBB->getParent()->begin();
49 if (TopMBB != Begin) {
50 MachineBasicBlock *PriorMBB = prior(MachineFunction::iterator(TopMBB));
51 while (contains(PriorMBB)) {
52 TopMBB = PriorMBB;
53 if (TopMBB == Begin) break;
54 PriorMBB = prior(MachineFunction::iterator(TopMBB));
55 }
56 }
57 return TopMBB;
58 }
59
60 MachineBasicBlock *MachineLoop::getBottomBlock() {
61 MachineBasicBlock *BotMBB = getHeader();
62 MachineFunction::iterator End = BotMBB->getParent()->end();
63 if (BotMBB != prior(End)) {
64 MachineBasicBlock *NextMBB = next(MachineFunction::iterator(BotMBB));
65 while (contains(NextMBB)) {
66 BotMBB = NextMBB;
67 if (BotMBB == next(MachineFunction::iterator(BotMBB))) break;
68 NextMBB = next(MachineFunction::iterator(BotMBB));
69 }
70 }
71 return BotMBB;
72 }