On 2/28/11 4:43 PM, Devang Patel wrote:> > On Feb 28, 2011, at 2:35 PM, Naznin Fauzia wrote: > >> Hi all, >> >> How Can I get the Loops around an Instruction? >> >> I know I can get the basic block of an instruction using >> inst.getParent() which returns a BasicBlock*. Now I want to use the >> getLoopFor(BasicBlock) method of the class LoopInfo. >> But I dont know how to get the LoopInfo. >> >> BasicBlock* bb = inst.getParent(); >> >> (... what should I add here?) >> >> Loop* innerloop = LI -> getLoopFor(bb): >> > > Two steps: > 1) In your pass's getAnalysisUsage(), request LoopInfo. > > virtual void getAnalysisUsage(AnalysisUsage &AU) const { > AU.addRequired<LoopInfo>(); > } > > 2) In your runOnLoop() method get the analysis. > > LoopPass *LI = &getAnalysis<LoopInfo>(); > > Now, you can do LI->getLoopFor(...)To add to what Devang has said, you may find the doxygen docs on LoopInfo helpful: http://llvm.org/doxygen/classllvm_1_1LoopInfo.html -- John T.> > - > Devang > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110228/f134922d/attachment.html>
Thanks Devang and John. My pass is actually a loop pass, not a function pass. So, I couldnt override the getAnalysisUsage. I am in a loop pass, I know the outermost loop. Now How can I get the loopInfo from here? I couldn't find helpful methods in the LoopInfo class documents. On Mon, Feb 28, 2011 at 5:52 PM, John Criswell <criswell at illinois.edu>wrote:> On 2/28/11 4:43 PM, Devang Patel wrote: > > > On Feb 28, 2011, at 2:35 PM, Naznin Fauzia wrote: > > Hi all, > > How Can I get the Loops around an Instruction? > > I know I can get the basic block of an instruction using inst.getParent() > which returns a BasicBlock*. Now I want to use the getLoopFor(BasicBlock) > method of the class LoopInfo. > But I dont know how to get the LoopInfo. > > BasicBlock* bb = inst.getParent(); > > (... what should I add here?) > > Loop* innerloop = LI -> getLoopFor(bb): > > > Two steps: > 1) In your pass's getAnalysisUsage(), request LoopInfo. > > virtual void getAnalysisUsage(AnalysisUsage &AU) const { > AU.addRequired<LoopInfo>(); > } > > 2) In your runOnLoop() method get the analysis. > > LoopPass *LI = &getAnalysis<LoopInfo>(); > > Now, you can do LI->getLoopFor(...) > > > To add to what Devang has said, you may find the doxygen docs on LoopInfo > helpful: > > http://llvm.org/doxygen/classllvm_1_1LoopInfo.html > > -- John T. > > > > - > Devang > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110228/b8061c64/attachment.html>
On Mon, Feb 28, 2011 at 6:04 PM, Naznin Fauzia <laboni14 at gmail.com> wrote:> Thanks Devang and John. My pass is actually a loop pass, not a function > pass. So, I couldnt override the getAnalysisUsage. >A LoopPass is no different from a FunctionPass here. You can use getAnalysisUsage and getAnalysis in a LoopPass.> I am in a loop pass, I know the outermost loop. Now How can I get the > loopInfo from here? I couldn't find helpful methods in the LoopInfo class > documents. > > > On Mon, Feb 28, 2011 at 5:52 PM, John Criswell <criswell at illinois.edu>wrote: > >> On 2/28/11 4:43 PM, Devang Patel wrote: >> >> >> On Feb 28, 2011, at 2:35 PM, Naznin Fauzia wrote: >> >> Hi all, >> >> How Can I get the Loops around an Instruction? >> >> I know I can get the basic block of an instruction using inst.getParent() >> which returns a BasicBlock*. Now I want to use the getLoopFor(BasicBlock) >> method of the class LoopInfo. >> But I dont know how to get the LoopInfo. >> >> BasicBlock* bb = inst.getParent(); >> >> (... what should I add here?) >> >> Loop* innerloop = LI -> getLoopFor(bb): >> >> >> Two steps: >> 1) In your pass's getAnalysisUsage(), request LoopInfo. >> >> virtual void getAnalysisUsage(AnalysisUsage &AU) const { >> AU.addRequired<LoopInfo>(); >> } >> >> 2) In your runOnLoop() method get the analysis. >> >> LoopPass *LI = &getAnalysis<LoopInfo>(); >> >> Now, you can do LI->getLoopFor(...) >> >> >> To add to what Devang has said, you may find the doxygen docs on LoopInfo >> helpful: >> >> http://llvm.org/doxygen/classllvm_1_1LoopInfo.html >> >> -- John T. >> >> >> >> - >> Devang >> >> >> >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110228/595b03a3/attachment.html>