OpenASIP  2.0
InnerLoopFinder.hh
Go to the documentation of this file.
1 /**
2  * @file InnerLoopFinder.hh
3  *
4  * LLVM pass for finding loops that can be software pipelined by the TCE
5  * loop scheduler.
6  *
7  * @author Pekka Jääskeläinen
8  */
9 #ifndef HH_INNER_LOOP_FINDER
10 #define HH_INNER_LOOP_FINDER
11 
12 #include <sstream>
13 #include <fstream>
14 #include <string>
15 #include <map>
16 
17 #include <llvm/IR/LegacyPassManager.h>
18 #include <llvm/Analysis/LoopPass.h>
19 #include <llvm/Support/CommandLine.h>
20 
21 #include "tce_config.h"
22 #include <llvm/IR/Module.h>
23 
24 namespace llvm {
25  void initializeInnerLoopFinderPass(llvm::PassRegistry&);
26 }
27 
28 struct InnerLoopFinder : public llvm::LoopPass {
29  static char ID;
30  typedef std::map<std::string, std::ostream*> DumpFileIndex;
31 
32  class InnerLoopInfo {
33  public:
36  int tripCount() const { return tripCount_; }
37  bool isTripCountKnown() const { return tripCount_ > 0; }
38  private:
40  };
41 
42  typedef std::map<const llvm::BasicBlock*, InnerLoopInfo> InnerLoopInfoIndex;
43 
45  bool dump;
46 
49 
50  virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const;
51 
52  std::ostream& out(llvm::Loop* l);
53 
54  virtual std::string loopDescription(llvm::Loop* l);
55  virtual bool runOnLoop(llvm::Loop* l, llvm::LPPassManager &LPM);
56  unsigned getSmallConstantTripCount(llvm::Loop* loop);
57 
59 private:
61 };
62 
63 #endif
InnerLoopFinder::InnerLoopInfo::InnerLoopInfo
InnerLoopInfo()
Definition: InnerLoopFinder.hh:34
llvm
Definition: InlineAsmParser.hh:49
InnerLoopFinder::loopInfos_
InnerLoopInfoIndex loopInfos_
Definition: InnerLoopFinder.hh:60
InnerLoopFinder::InnerLoopInfo::isTripCountKnown
bool isTripCountKnown() const
Definition: InnerLoopFinder.hh:37
InnerLoopFinder::innerLoopInfo
InnerLoopInfoIndex innerLoopInfo()
Definition: InnerLoopFinder.hh:58
InnerLoopFinder::InnerLoopFinder
InnerLoopFinder()
Definition: InnerLoopFinder.cc:93
llvm::initializeInnerLoopFinderPass
void initializeInnerLoopFinderPass(llvm::PassRegistry &)
InnerLoopFinder::dump
bool dump
Definition: InnerLoopFinder.hh:45
InnerLoopFinder
Definition: InnerLoopFinder.hh:28
InnerLoopFinder::getSmallConstantTripCount
unsigned getSmallConstantTripCount(llvm::Loop *loop)
Definition: InnerLoopFinder.cc:254
InnerLoopFinder::InnerLoopInfo
Definition: InnerLoopFinder.hh:32
InnerLoopFinder::ID
static char ID
Definition: InnerLoopFinder.hh:29
InnerLoopFinder::runOnLoop
virtual bool runOnLoop(llvm::Loop *l, llvm::LPPassManager &LPM)
Definition: InnerLoopFinder.cc:170
InnerLoopFinder::InnerLoopInfoIndex
std::map< const llvm::BasicBlock *, InnerLoopInfo > InnerLoopInfoIndex
Definition: InnerLoopFinder.hh:42
InnerLoopFinder::getAnalysisUsage
virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const
Definition: InnerLoopFinder.cc:99
InnerLoopFinder::InnerLoopInfo::tripCount_
int tripCount_
Definition: InnerLoopFinder.hh:39
InnerLoopFinder::loopDescription
virtual std::string loopDescription(llvm::Loop *l)
Definition: InnerLoopFinder.cc:152
InnerLoopFinder::dumpFiles
DumpFileIndex dumpFiles
Definition: InnerLoopFinder.hh:44
InnerLoopFinder::~InnerLoopFinder
~InnerLoopFinder()
Definition: InnerLoopFinder.cc:110
InnerLoopFinder::InnerLoopInfo::tripCount
int tripCount() const
Definition: InnerLoopFinder.hh:36
InnerLoopFinder::out
std::ostream & out(llvm::Loop *l)
Definition: InnerLoopFinder.cc:127
InnerLoopFinder::InnerLoopInfo::InnerLoopInfo
InnerLoopInfo(int tripCount)
Definition: InnerLoopFinder.hh:35
InnerLoopFinder::DumpFileIndex
std::map< std::string, std::ostream * > DumpFileIndex
Definition: InnerLoopFinder.hh:30