Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 1 | //===- InlineCommon.h - Code common to all inliners -------------*- C++ -*-===// |
Misha Brukman | fd93908 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 856ba76 | 2003-10-21 15:17:13 +0000 | [diff] [blame] | 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. |
Misha Brukman | fd93908 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 856ba76 | 2003-10-21 15:17:13 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 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" |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 22 | |
| 23 | namespace llvm { |
Chris Lattner | 74c68ff | 2004-05-23 21:21:35 +0000 | [diff] [blame] | 24 | class CallSite; |
Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 25 | |
| 26 | /// Inliner - This class contains all of the helper code which is used to |
| 27 | /// perform the inlining operations that does not depend on the policy. |
| 28 | /// |
| 29 | struct Inliner : public CallGraphSCCPass { |
Devang Patel | 1997473 | 2007-05-03 01:11:54 +0000 | [diff] [blame^] | 30 | static char ID; |
Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 31 | Inliner(); |
| 32 | |
Chris Lattner | ff2dad3 | 2007-01-30 23:28:39 +0000 | [diff] [blame] | 33 | /// getAnalysisUsage - For this class, we declare that we require and preserve |
| 34 | /// the call graph. If the derived class implements this method, it should |
| 35 | /// always explicitly call the implementation here. |
| 36 | virtual void getAnalysisUsage(AnalysisUsage &Info) const; |
| 37 | |
Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 38 | // Main run interface method, this implements the interface required by the |
| 39 | // Pass class. |
| 40 | virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC); |
| 41 | |
Chris Lattner | 68d57e7 | 2004-04-20 22:06:53 +0000 | [diff] [blame] | 42 | // doFinalization - Remove now-dead linkonce functions at the end of |
| 43 | // processing to avoid breaking the SCC traversal. |
| 44 | virtual bool doFinalization(CallGraph &CG); |
| 45 | |
| 46 | |
Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 47 | /// This method returns the value specified by the -inline-threshold value, |
| 48 | /// specified on the command line. This is typically not directly needed. |
| 49 | /// |
| 50 | unsigned getInlineThreshold() const { return InlineThreshold; } |
| 51 | |
| 52 | /// getInlineCost - This method must be implemented by the subclass to |
| 53 | /// determine the cost of inlining the specified call site. If the cost |
| 54 | /// returned is greater than the current inline threshold, the call site is |
| 55 | /// not inlined. |
| 56 | /// |
| 57 | virtual int getInlineCost(CallSite CS) = 0; |
Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 58 | |
| 59 | private: |
Chris Lattner | d77922f | 2003-11-09 05:05:36 +0000 | [diff] [blame] | 60 | // InlineThreshold - Cache the value here for easy access. |
Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 61 | unsigned InlineThreshold; |
Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 64 | } // End llvm namespace |
Chris Lattner | 237ef56 | 2003-08-31 19:10:30 +0000 | [diff] [blame] | 65 | |
| 66 | #endif |