aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-10-20 04:16:37 +0000
committerDan Gohman <gohman@apple.com>2009-10-20 04:16:37 +0000
commit81b16a3558514481c61e7c68d19f84d7a69352cb (patch)
tree8a389b6896953c690b4842840dccf7fc7c11dccf /lib
parent13555eae17991ab1080774947c35af9f4cc62cea (diff)
downloadexternal_llvm-81b16a3558514481c61e7c68d19f84d7a69352cb.zip
external_llvm-81b16a3558514481c61e7c68d19f84d7a69352cb.tar.gz
external_llvm-81b16a3558514481c61e7c68d19f84d7a69352cb.tar.bz2
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
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/MachineLoopInfo.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineLoopInfo.cpp b/lib/CodeGen/MachineLoopInfo.cpp
index 2da8e37..db77d19 100644
--- a/lib/CodeGen/MachineLoopInfo.cpp
+++ b/lib/CodeGen/MachineLoopInfo.cpp
@@ -43,3 +43,31 @@ void MachineLoopInfo::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<MachineDominatorTree>();
MachineFunctionPass::getAnalysisUsage(AU);
}
+
+MachineBasicBlock *MachineLoop::getTopBlock() {
+ MachineBasicBlock *TopMBB = getHeader();
+ MachineFunction::iterator Begin = TopMBB->getParent()->begin();
+ if (TopMBB != Begin) {
+ MachineBasicBlock *PriorMBB = prior(MachineFunction::iterator(TopMBB));
+ while (contains(PriorMBB)) {
+ TopMBB = PriorMBB;
+ if (TopMBB == Begin) break;
+ PriorMBB = prior(MachineFunction::iterator(TopMBB));
+ }
+ }
+ return TopMBB;
+}
+
+MachineBasicBlock *MachineLoop::getBottomBlock() {
+ MachineBasicBlock *BotMBB = getHeader();
+ MachineFunction::iterator End = BotMBB->getParent()->end();
+ if (BotMBB != prior(End)) {
+ MachineBasicBlock *NextMBB = next(MachineFunction::iterator(BotMBB));
+ while (contains(NextMBB)) {
+ BotMBB = NextMBB;
+ if (BotMBB == next(MachineFunction::iterator(BotMBB))) break;
+ NextMBB = next(MachineFunction::iterator(BotMBB));
+ }
+ }
+ return BotMBB;
+}