a6422951ceecc587a9204da7d3c30544360e22a5
[oota-llvm.git] / lib / Transforms / IPO / Inliner.h
1 //===- InlineCommon.h - Code common to all inliners -------------*- C++ -*-===//
2 //
3 // This file defines a simple policy-based bottom-up inliner.  This file
4 // implements all of the boring mechanics of the bottom-up inlining, while the
5 // subclass determines WHAT to inline, which is the much more interesting
6 // component.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef INLINER_H
11 #define INLINER_H
12
13 #define DEBUG_TYPE "inline"
14 #include "llvm/CallGraphSCCPass.h"
15 #include <set>
16 class CallSite;
17
18 /// Inliner - This class contains all of the helper code which is used to
19 /// perform the inlining operations that does not depend on the policy.
20 ///
21 struct Inliner : public CallGraphSCCPass {
22   Inliner();
23
24   // Main run interface method, this implements the interface required by the
25   // Pass class.
26   virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC);
27
28   /// This method returns the value specified by the -inline-threshold value,
29   /// specified on the command line.  This is typically not directly needed.
30   ///
31   unsigned getInlineThreshold() const { return InlineThreshold; }
32
33   /// getInlineCost - This method must be implemented by the subclass to
34   /// determine the cost of inlining the specified call site.  If the cost
35   /// returned is greater than the current inline threshold, the call site is
36   /// not inlined.
37   ///
38   virtual int getInlineCost(CallSite CS) = 0;
39   
40   /// getRecursiveInlineCost - This method can be implemented by subclasses if
41   /// it wants to treat calls to functions within the current SCC specially.  If
42   /// this method is not overloaded, it just chains to getInlineCost().
43   ///
44   virtual int getRecursiveInlineCost(CallSite CS);
45
46 private:
47   unsigned InlineThreshold;
48   bool performInlining(CallSite CS, std::set<Function*> &SCC);
49 };
50
51
52 #endif