khaled hamidouche
2010-Apr-20 11:22 UTC
[LLVMdev] iterate over loops inside the runOnFunction
Hello I'm wandring to write a Function parser that iterates over loops inside each function and inside each loop iterates over instructions So I found a way to do the Function parser that iterates over BasicBlocks (using the runOnfunction Pass) but I no know how make it iterates over loops ? So my question is there any way to make a loop inside the runOnfunction to iterate over "loops" (just like with the Basicblock loop "for (BasicBlock::iterator i = b->begin(), ie = b->end(); i != ie; ++i) " ) ? Thank you so much for helping me -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100420/5dd87388/attachment.html>
Here is an example. You can also check lib/Scalar/LoopUnroll.cpp. ----------------------------------- void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<LoopInfo>(); AU.addPreserved<LoopInfo>(); ... } virtual bool runOnFunction(Function &F) { LoopInfo &LI = getAnalysis<LoopInfo>(); for (LoopInfo::iterator i = LI.begin(), e LI.end(); i != e; ++i) { //This is for subLoops ... and you can iteratively do it as the same. std::vector<Loop*> subLoops = i->getSubLoops(); } ----------------- } On 20 April 2010 12:22, khaled hamidouche <khaledhamidouche at gmail.com> wrote:> Hello > I'm wandring to write a Function parser that iterates over loops inside each > function and inside each loop iterates over instructions > > So I found a way to do the Function parser that iterates over BasicBlocks > (using the runOnfunction Pass) but I no know how make it iterates over > loops ? > > So my question is there any way to make a loop inside the runOnfunction to > iterate over "loops" (just like with the Basicblock loop "for > (BasicBlock::iterator i = b->begin(), ie = b->end(); i != ie; ++i) " ) ? > > Thank you so much for helping me > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- Best regards, WANG Zheng