blob: c4662c1c52623d2f99ddc99e36bd8a71b571ca3a [file] [log] [blame]
Chris Lattner237ef562003-08-31 19:10:30 +00001//===- InlineCommon.h - Code common to all inliners -------------*- C++ -*-===//
Misha Brukmanfd939082005-04-21 23:48:37 +00002//
John Criswell856ba762003-10-21 15:17:13 +00003// 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 Brukmanfd939082005-04-21 23:48:37 +00007//
John Criswell856ba762003-10-21 15:17:13 +00008//===----------------------------------------------------------------------===//
Chris Lattner237ef562003-08-31 19:10:30 +00009//
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 Gaeked0fde302003-11-11 22:41:34 +000022
23namespace llvm {
Chris Lattner74c68ff2004-05-23 21:21:35 +000024 class CallSite;
Chris Lattner237ef562003-08-31 19:10:30 +000025
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///
29struct Inliner : public CallGraphSCCPass {
30 Inliner();
31
32 // Main run interface method, this implements the interface required by the
33 // Pass class.
34 virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC);
35
Chris Lattner68d57e72004-04-20 22:06:53 +000036 // doFinalization - Remove now-dead linkonce functions at the end of
37 // processing to avoid breaking the SCC traversal.
38 virtual bool doFinalization(CallGraph &CG);
39
40
Chris Lattner237ef562003-08-31 19:10:30 +000041 /// This method returns the value specified by the -inline-threshold value,
42 /// specified on the command line. This is typically not directly needed.
43 ///
44 unsigned getInlineThreshold() const { return InlineThreshold; }
45
46 /// getInlineCost - This method must be implemented by the subclass to
47 /// determine the cost of inlining the specified call site. If the cost
48 /// returned is greater than the current inline threshold, the call site is
49 /// not inlined.
50 ///
51 virtual int getInlineCost(CallSite CS) = 0;
Chris Lattner237ef562003-08-31 19:10:30 +000052
53private:
Chris Lattnerd77922f2003-11-09 05:05:36 +000054 // InlineThreshold - Cache the value here for easy access.
Chris Lattner237ef562003-08-31 19:10:30 +000055 unsigned InlineThreshold;
Chris Lattner237ef562003-08-31 19:10:30 +000056};
57
Brian Gaeked0fde302003-11-11 22:41:34 +000058} // End llvm namespace
Chris Lattner237ef562003-08-31 19:10:30 +000059
60#endif