Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.1 KiB

  1. //===- PathProfileInfo.h --------------------------------------*- C++ -*---===//
  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. //===----------------------------------------------------------------------===//
  9. //
  10. // This file outlines the interface used by optimizers to load path profiles.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_ANALYSIS_PATHPROFILEINFO_H
  14. #define LLVM_ANALYSIS_PATHPROFILEINFO_H
  15. #include "llvm/Analysis/PathNumbering.h"
  16. #include "llvm/IR/BasicBlock.h"
  17. namespace llvm {
  18. class ProfilePath;
  19. class ProfilePathEdge;
  20. class PathProfileInfo;
  21. typedef std::vector<ProfilePathEdge> ProfilePathEdgeVector;
  22. typedef std::vector<ProfilePathEdge>::iterator ProfilePathEdgeIterator;
  23. typedef std::vector<BasicBlock*> ProfilePathBlockVector;
  24. typedef std::vector<BasicBlock*>::iterator ProfilePathBlockIterator;
  25. typedef std::map<unsigned int,ProfilePath*> ProfilePathMap;
  26. typedef std::map<unsigned int,ProfilePath*>::iterator ProfilePathIterator;
  27. typedef std::map<Function*,unsigned int> FunctionPathCountMap;
  28. typedef std::map<Function*,ProfilePathMap> FunctionPathMap;
  29. typedef std::map<Function*,ProfilePathMap>::iterator FunctionPathIterator;
  30. class ProfilePathEdge {
  31. public:
  32. ProfilePathEdge(BasicBlock* source, BasicBlock* target,
  33. unsigned duplicateNumber);
  34. inline unsigned getDuplicateNumber() { return _duplicateNumber; }
  35. inline BasicBlock* getSource() { return _source; }
  36. inline BasicBlock* getTarget() { return _target; }
  37. protected:
  38. BasicBlock* _source;
  39. BasicBlock* _target;
  40. unsigned _duplicateNumber;
  41. };
  42. class ProfilePath {
  43. public:
  44. ProfilePath(unsigned int number, unsigned int count,
  45. double countStdDev, PathProfileInfo* ppi);
  46. double getFrequency() const;
  47. inline unsigned int getNumber() const { return _number; }
  48. inline unsigned int getCount() const { return _count; }
  49. inline double getCountStdDev() const { return _countStdDev; }
  50. ProfilePathEdgeVector* getPathEdges() const;
  51. ProfilePathBlockVector* getPathBlocks() const;
  52. BasicBlock* getFirstBlockInPath() const;
  53. private:
  54. unsigned int _number;
  55. unsigned int _count;
  56. double _countStdDev;
  57. // double pointer back to the profiling info
  58. PathProfileInfo* _ppi;
  59. };
  60. // TODO: overload [] operator for getting path
  61. // Add: getFunctionCallCount()
  62. class PathProfileInfo {
  63. public:
  64. PathProfileInfo();
  65. ~PathProfileInfo();
  66. void setCurrentFunction(Function* F);
  67. Function* getCurrentFunction() const;
  68. BasicBlock* getCurrentFunctionEntry();
  69. ProfilePath* getPath(unsigned int number);
  70. unsigned int getPotentialPathCount();
  71. ProfilePathIterator pathBegin();
  72. ProfilePathIterator pathEnd();
  73. unsigned int pathsRun();
  74. static char ID; // Pass identification
  75. std::string argList;
  76. protected:
  77. FunctionPathMap _functionPaths;
  78. FunctionPathCountMap _functionPathCounts;
  79. private:
  80. BallLarusDag* _currentDag;
  81. Function* _currentFunction;
  82. friend class ProfilePath;
  83. };
  84. } // end namespace llvm
  85. #endif