diff options
author | Devang Patel <dpatel@apple.com> | 2007-03-06 19:00:02 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-03-06 19:00:02 +0000 |
commit | ef7ac13406240f20387ced110178e9e05c893a25 (patch) | |
tree | 527db3aae792e35362458d91935a44e09592354c /llvm/lib/Analysis | |
parent | bbd25984b7969e65b98b959224986198b5a054ed (diff) | |
download | bcm5719-llvm-ef7ac13406240f20387ced110178e9e05c893a25.tar.gz bcm5719-llvm-ef7ac13406240f20387ced110178e9e05c893a25.zip |
Add LPPassManager::insertLoop().
llvm-svn: 34979
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/LoopPass.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index 4b41a94c70c..0a29c5dae36 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -97,10 +97,42 @@ void LPPassManager::deleteLoopFromQueue(Loop *L) { } } +// Inset loop into loop nest (LoopInfo) and loop queue (LQ). +void LPPassManager::insertLoop(Loop *L, Loop *ParentLoop) { + + assert (CurrentLoop != L && "Cannot insert CurrentLoop"); + + // Insert into loop nest + if (ParentLoop) + ParentLoop->addChildLoop(L); + else + LI->addTopLevelLoop(L); + + // Insert L into loop queue + if (L == CurrentLoop) + redoLoop(L); + else if (!ParentLoop) + // This is top level loop. + LQ.push_front(L); + else { + // Insert L after ParentLoop + for (std::deque<Loop *>::iterator I = LQ.begin(), + E = LQ.end(); I != E; ++I) { + if (*I == ParentLoop) { + // deque does not support insert after. + ++I; + LQ.insert(I, 1, L); + break; + } + } + } +} + // Reoptimize this loop. LPPassManager will re-insert this loop into the // queue. This allows LoopPass to change loop nest for the loop. This // utility may send LPPassManager into infinite loops so use caution. void LPPassManager::redoLoop(Loop *L) { + assert (CurrentLoop != L && "Can redo only CurrentLoop"); redoThisLoop = true; } |