LoopExtractor.cpp (208954) | LoopExtractor.cpp (212904) |
---|---|
1//===- LoopExtractor.cpp - Extract each loop into a new function ----------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 23 unchanged lines hidden (view full) --- 32STATISTIC(NumExtracted, "Number of loops extracted"); 33 34namespace { 35 struct LoopExtractor : public LoopPass { 36 static char ID; // Pass identification, replacement for typeid 37 unsigned NumLoops; 38 39 explicit LoopExtractor(unsigned numLoops = ~0) | 1//===- LoopExtractor.cpp - Extract each loop into a new function ----------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 23 unchanged lines hidden (view full) --- 32STATISTIC(NumExtracted, "Number of loops extracted"); 33 34namespace { 35 struct LoopExtractor : public LoopPass { 36 static char ID; // Pass identification, replacement for typeid 37 unsigned NumLoops; 38 39 explicit LoopExtractor(unsigned numLoops = ~0) |
40 : LoopPass(&ID), NumLoops(numLoops) {} | 40 : LoopPass(ID), NumLoops(numLoops) {} |
41 42 virtual bool runOnLoop(Loop *L, LPPassManager &LPM); 43 44 virtual void getAnalysisUsage(AnalysisUsage &AU) const { 45 AU.addRequiredID(BreakCriticalEdgesID); 46 AU.addRequiredID(LoopSimplifyID); 47 AU.addRequired<DominatorTree>(); 48 } 49 }; 50} 51 52char LoopExtractor::ID = 0; | 41 42 virtual bool runOnLoop(Loop *L, LPPassManager &LPM); 43 44 virtual void getAnalysisUsage(AnalysisUsage &AU) const { 45 AU.addRequiredID(BreakCriticalEdgesID); 46 AU.addRequiredID(LoopSimplifyID); 47 AU.addRequired<DominatorTree>(); 48 } 49 }; 50} 51 52char LoopExtractor::ID = 0; |
53static RegisterPass<LoopExtractor> 54X("loop-extract", "Extract loops into new functions"); | 53INITIALIZE_PASS(LoopExtractor, "loop-extract", 54 "Extract loops into new functions", false, false); |
55 56namespace { 57 /// SingleLoopExtractor - For bugpoint. 58 struct SingleLoopExtractor : public LoopExtractor { 59 static char ID; // Pass identification, replacement for typeid 60 SingleLoopExtractor() : LoopExtractor(1) {} 61 }; 62} // End anonymous namespace 63 64char SingleLoopExtractor::ID = 0; | 55 56namespace { 57 /// SingleLoopExtractor - For bugpoint. 58 struct SingleLoopExtractor : public LoopExtractor { 59 static char ID; // Pass identification, replacement for typeid 60 SingleLoopExtractor() : LoopExtractor(1) {} 61 }; 62} // End anonymous namespace 63 64char SingleLoopExtractor::ID = 0; |
65static RegisterPass<SingleLoopExtractor> 66Y("loop-extract-single", "Extract at most one loop into a new function"); | 65INITIALIZE_PASS(SingleLoopExtractor, "loop-extract-single", 66 "Extract at most one loop into a new function", false, false); |
67 68// createLoopExtractorPass - This pass extracts all natural loops from the 69// program into a function if it can. 70// 71Pass *llvm::createLoopExtractorPass() { return new LoopExtractor(); } 72 73bool LoopExtractor::runOnLoop(Loop *L, LPPassManager &LPM) { 74 // Only visit top-level loops. --- 67 unchanged lines hidden (view full) --- 142 /// BlocksToNotExtract list. 143 class BlockExtractorPass : public ModulePass { 144 void LoadFile(const char *Filename); 145 146 std::vector<BasicBlock*> BlocksToNotExtract; 147 std::vector<std::pair<std::string, std::string> > BlocksToNotExtractByName; 148 public: 149 static char ID; // Pass identification, replacement for typeid | 67 68// createLoopExtractorPass - This pass extracts all natural loops from the 69// program into a function if it can. 70// 71Pass *llvm::createLoopExtractorPass() { return new LoopExtractor(); } 72 73bool LoopExtractor::runOnLoop(Loop *L, LPPassManager &LPM) { 74 // Only visit top-level loops. --- 67 unchanged lines hidden (view full) --- 142 /// BlocksToNotExtract list. 143 class BlockExtractorPass : public ModulePass { 144 void LoadFile(const char *Filename); 145 146 std::vector<BasicBlock*> BlocksToNotExtract; 147 std::vector<std::pair<std::string, std::string> > BlocksToNotExtractByName; 148 public: 149 static char ID; // Pass identification, replacement for typeid |
150 explicit BlockExtractorPass(const std::vector<BasicBlock*> &B) 151 : ModulePass(&ID), BlocksToNotExtract(B) { | 150 BlockExtractorPass() : ModulePass(ID) { |
152 if (!BlockFile.empty()) 153 LoadFile(BlockFile.c_str()); 154 } | 151 if (!BlockFile.empty()) 152 LoadFile(BlockFile.c_str()); 153 } |
155 BlockExtractorPass() : ModulePass(&ID) {} | |
156 157 bool runOnModule(Module &M); 158 }; 159} 160 161char BlockExtractorPass::ID = 0; | 154 155 bool runOnModule(Module &M); 156 }; 157} 158 159char BlockExtractorPass::ID = 0; |
162static RegisterPass<BlockExtractorPass> 163XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)"); | 160INITIALIZE_PASS(BlockExtractorPass, "extract-blocks", 161 "Extract Basic Blocks From Module (for bugpoint use)", 162 false, false); |
164 165// createBlockExtractorPass - This pass extracts all blocks (except those 166// specified in the argument list) from the functions in the module. 167// | 163 164// createBlockExtractorPass - This pass extracts all blocks (except those 165// specified in the argument list) from the functions in the module. 166// |
168ModulePass *llvm::createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE) | 167ModulePass *llvm::createBlockExtractorPass() |
169{ | 168{ |
170 return new BlockExtractorPass(BTNE); | 169 return new BlockExtractorPass(); |
171} 172 173void BlockExtractorPass::LoadFile(const char *Filename) { 174 // Load the BlockFile... 175 std::ifstream In(Filename); 176 if (!In.good()) { 177 errs() << "WARNING: BlockExtractor couldn't load file '" << Filename 178 << "'!\n"; --- 64 unchanged lines hidden --- | 170} 171 172void BlockExtractorPass::LoadFile(const char *Filename) { 173 // Load the BlockFile... 174 std::ifstream In(Filename); 175 if (!In.good()) { 176 errs() << "WARNING: BlockExtractor couldn't load file '" << Filename 177 << "'!\n"; --- 64 unchanged lines hidden --- |