Mostly cosmetic improvements. Do fix the bug where a global value was considered...
[oota-llvm.git] / lib / Transforms / IPO / Inliner.h
1 //===- InlineCommon.h - Code common to all inliners -------------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines a simple policy-based bottom-up inliner.  This file
11 // implements all of the boring mechanics of the bottom-up inlining, while the
12 // subclass determines WHAT to inline, which is the much more interesting
13 // component.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef INLINER_H
18 #define INLINER_H
19
20 #define DEBUG_TYPE "inline"
21 #include "llvm/CallGraphSCCPass.h"
22 #include <set>
23
24 namespace llvm {
25
26 class CallSite;
27
28 /// Inliner - This class contains all of the helper code which is used to
29 /// perform the inlining operations that does not depend on the policy.
30 ///
31 struct Inliner : public CallGraphSCCPass {
32   Inliner();
33
34   // Main run interface method, this implements the interface required by the
35   // Pass class.
36   virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC);
37
38   /// This method returns the value specified by the -inline-threshold value,
39   /// specified on the command line.  This is typically not directly needed.
40   ///
41   unsigned getInlineThreshold() const { return InlineThreshold; }
42
43   /// getInlineCost - This method must be implemented by the subclass to
44   /// determine the cost of inlining the specified call site.  If the cost
45   /// returned is greater than the current inline threshold, the call site is
46   /// not inlined.
47   ///
48   virtual int getInlineCost(CallSite CS) = 0;
49   
50   /// getRecursiveInlineCost - This method can be implemented by subclasses if
51   /// it wants to treat calls to functions within the current SCC specially.  If
52   /// this method is not overloaded, it just chains to getInlineCost().
53   ///
54   virtual int getRecursiveInlineCost(CallSite CS);
55
56 private:
57   // InlineThreshold - Cache the value here for easy access.
58   unsigned InlineThreshold;
59
60   // IsRecursiveFunction - This contains all functions which are directly
61   // recursive, which we do NOT want to inline into other functions.
62   std::set<Function*> IsRecursiveFunction;
63
64   bool performInlining(CallSite CS, std::set<Function*> &SCC);
65 };
66
67 } // End llvm namespace
68
69 #endif