initial
This commit is contained in:
91
thirdparty/clang/include/llvm/Transforms/IPO/InlinerPass.h
vendored
Normal file
91
thirdparty/clang/include/llvm/Transforms/IPO/InlinerPass.h
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
//===- InlinerPass.h - Code common to all inliners --------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines a simple policy-based bottom-up inliner. This file
|
||||
// implements all of the boring mechanics of the bottom-up inlining, while the
|
||||
// subclass determines WHAT to inline, which is the much more interesting
|
||||
// component.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TRANSFORMS_IPO_INLINERPASS_H
|
||||
#define LLVM_TRANSFORMS_IPO_INLINERPASS_H
|
||||
|
||||
#include "llvm/Analysis/CallGraphSCCPass.h"
|
||||
|
||||
namespace llvm {
|
||||
class CallSite;
|
||||
class DataLayout;
|
||||
class InlineCost;
|
||||
template<class PtrType, unsigned SmallSize>
|
||||
class SmallPtrSet;
|
||||
|
||||
/// Inliner - This class contains all of the helper code which is used to
|
||||
/// perform the inlining operations that do not depend on the policy.
|
||||
///
|
||||
struct Inliner : public CallGraphSCCPass {
|
||||
explicit Inliner(char &ID);
|
||||
explicit Inliner(char &ID, int Threshold, bool InsertLifetime);
|
||||
|
||||
/// getAnalysisUsage - For this class, we declare that we require and preserve
|
||||
/// the call graph. If the derived class implements this method, it should
|
||||
/// always explicitly call the implementation here.
|
||||
virtual void getAnalysisUsage(AnalysisUsage &Info) const;
|
||||
|
||||
// Main run interface method, this implements the interface required by the
|
||||
// Pass class.
|
||||
virtual bool runOnSCC(CallGraphSCC &SCC);
|
||||
|
||||
using llvm::Pass::doFinalization;
|
||||
// doFinalization - Remove now-dead linkonce functions at the end of
|
||||
// processing to avoid breaking the SCC traversal.
|
||||
virtual bool doFinalization(CallGraph &CG);
|
||||
|
||||
/// This method returns the value specified by the -inline-threshold value,
|
||||
/// specified on the command line. This is typically not directly needed.
|
||||
///
|
||||
unsigned getInlineThreshold() const { return InlineThreshold; }
|
||||
|
||||
/// Calculate the inline threshold for given Caller. This threshold is lower
|
||||
/// if the caller is marked with OptimizeForSize and -inline-threshold is not
|
||||
/// given on the comand line. It is higher if the callee is marked with the
|
||||
/// inlinehint attribute.
|
||||
///
|
||||
unsigned getInlineThreshold(CallSite CS) const;
|
||||
|
||||
/// getInlineCost - This method must be implemented by the subclass to
|
||||
/// determine the cost of inlining the specified call site. If the cost
|
||||
/// returned is greater than the current inline threshold, the call site is
|
||||
/// not inlined.
|
||||
///
|
||||
virtual InlineCost getInlineCost(CallSite CS) = 0;
|
||||
|
||||
/// removeDeadFunctions - Remove dead functions.
|
||||
///
|
||||
/// This also includes a hack in the form of the 'AlwaysInlineOnly' flag
|
||||
/// which restricts it to deleting functions with an 'AlwaysInline'
|
||||
/// attribute. This is useful for the InlineAlways pass that only wants to
|
||||
/// deal with that subset of the functions.
|
||||
bool removeDeadFunctions(CallGraph &CG, bool AlwaysInlineOnly = false);
|
||||
|
||||
private:
|
||||
// InlineThreshold - Cache the value here for easy access.
|
||||
unsigned InlineThreshold;
|
||||
|
||||
// InsertLifetime - Insert @llvm.lifetime intrinsics.
|
||||
bool InsertLifetime;
|
||||
|
||||
/// shouldInline - Return true if the inliner should attempt to
|
||||
/// inline at the given CallSite.
|
||||
bool shouldInline(CallSite CS);
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
151
thirdparty/clang/include/llvm/Transforms/IPO/PassManagerBuilder.h
vendored
Normal file
151
thirdparty/clang/include/llvm/Transforms/IPO/PassManagerBuilder.h
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
// llvm/Transforms/IPO/PassManagerBuilder.h - Build Standard Pass -*- C++ -*-=//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the PassManagerBuilder class, which is used to set up a
|
||||
// "standard" optimization sequence suitable for languages like C and C++.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TRANSFORMS_IPO_PASSMANAGERBUILDER_H
|
||||
#define LLVM_TRANSFORMS_IPO_PASSMANAGERBUILDER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class TargetLibraryInfo;
|
||||
class PassManagerBase;
|
||||
class Pass;
|
||||
class FunctionPassManager;
|
||||
|
||||
/// PassManagerBuilder - This class is used to set up a standard optimization
|
||||
/// sequence for languages like C and C++, allowing some APIs to customize the
|
||||
/// pass sequence in various ways. A simple example of using it would be:
|
||||
///
|
||||
/// PassManagerBuilder Builder;
|
||||
/// Builder.OptLevel = 2;
|
||||
/// Builder.populateFunctionPassManager(FPM);
|
||||
/// Builder.populateModulePassManager(MPM);
|
||||
///
|
||||
/// In addition to setting up the basic passes, PassManagerBuilder allows
|
||||
/// frontends to vend a plugin API, where plugins are allowed to add extensions
|
||||
/// to the default pass manager. They do this by specifying where in the pass
|
||||
/// pipeline they want to be added, along with a callback function that adds
|
||||
/// the pass(es). For example, a plugin that wanted to add a loop optimization
|
||||
/// could do something like this:
|
||||
///
|
||||
/// static void addMyLoopPass(const PMBuilder &Builder, PassManagerBase &PM) {
|
||||
/// if (Builder.getOptLevel() > 2 && Builder.getOptSizeLevel() == 0)
|
||||
/// PM.add(createMyAwesomePass());
|
||||
/// }
|
||||
/// ...
|
||||
/// Builder.addExtension(PassManagerBuilder::EP_LoopOptimizerEnd,
|
||||
/// addMyLoopPass);
|
||||
/// ...
|
||||
class PassManagerBuilder {
|
||||
public:
|
||||
|
||||
/// Extensions are passed the builder itself (so they can see how it is
|
||||
/// configured) as well as the pass manager to add stuff to.
|
||||
typedef void (*ExtensionFn)(const PassManagerBuilder &Builder,
|
||||
PassManagerBase &PM);
|
||||
enum ExtensionPointTy {
|
||||
/// EP_EarlyAsPossible - This extension point allows adding passes before
|
||||
/// any other transformations, allowing them to see the code as it is coming
|
||||
/// out of the frontend.
|
||||
EP_EarlyAsPossible,
|
||||
|
||||
/// EP_ModuleOptimizerEarly - This extension point allows adding passes
|
||||
/// just before the main module-level optimization passes.
|
||||
EP_ModuleOptimizerEarly,
|
||||
|
||||
/// EP_LoopOptimizerEnd - This extension point allows adding loop passes to
|
||||
/// the end of the loop optimizer.
|
||||
EP_LoopOptimizerEnd,
|
||||
|
||||
/// EP_ScalarOptimizerLate - This extension point allows adding optimization
|
||||
/// passes after most of the main optimizations, but before the last
|
||||
/// cleanup-ish optimizations.
|
||||
EP_ScalarOptimizerLate,
|
||||
|
||||
/// EP_OptimizerLast -- This extension point allows adding passes that
|
||||
/// run after everything else.
|
||||
EP_OptimizerLast,
|
||||
|
||||
/// EP_EnabledOnOptLevel0 - This extension point allows adding passes that
|
||||
/// should not be disabled by O0 optimization level. The passes will be
|
||||
/// inserted after the inlining pass.
|
||||
EP_EnabledOnOptLevel0
|
||||
};
|
||||
|
||||
/// The Optimization Level - Specify the basic optimization level.
|
||||
/// 0 = -O0, 1 = -O1, 2 = -O2, 3 = -O3
|
||||
unsigned OptLevel;
|
||||
|
||||
/// SizeLevel - How much we're optimizing for size.
|
||||
/// 0 = none, 1 = -Os, 2 = -Oz
|
||||
unsigned SizeLevel;
|
||||
|
||||
/// LibraryInfo - Specifies information about the runtime library for the
|
||||
/// optimizer. If this is non-null, it is added to both the function and
|
||||
/// per-module pass pipeline.
|
||||
TargetLibraryInfo *LibraryInfo;
|
||||
|
||||
/// Inliner - Specifies the inliner to use. If this is non-null, it is
|
||||
/// added to the per-module passes.
|
||||
Pass *Inliner;
|
||||
|
||||
bool DisableSimplifyLibCalls;
|
||||
bool DisableUnitAtATime;
|
||||
bool DisableUnrollLoops;
|
||||
bool BBVectorize;
|
||||
bool SLPVectorize;
|
||||
bool LoopVectorize;
|
||||
|
||||
private:
|
||||
/// ExtensionList - This is list of all of the extensions that are registered.
|
||||
std::vector<std::pair<ExtensionPointTy, ExtensionFn> > Extensions;
|
||||
|
||||
public:
|
||||
PassManagerBuilder();
|
||||
~PassManagerBuilder();
|
||||
/// Adds an extension that will be used by all PassManagerBuilder instances.
|
||||
/// This is intended to be used by plugins, to register a set of
|
||||
/// optimisations to run automatically.
|
||||
static void addGlobalExtension(ExtensionPointTy Ty, ExtensionFn Fn);
|
||||
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn);
|
||||
|
||||
private:
|
||||
void addExtensionsToPM(ExtensionPointTy ETy, PassManagerBase &PM) const;
|
||||
void addInitialAliasAnalysisPasses(PassManagerBase &PM) const;
|
||||
public:
|
||||
|
||||
/// populateFunctionPassManager - This fills in the function pass manager,
|
||||
/// which is expected to be run on each function immediately as it is
|
||||
/// generated. The idea is to reduce the size of the IR in memory.
|
||||
void populateFunctionPassManager(FunctionPassManager &FPM);
|
||||
|
||||
/// populateModulePassManager - This sets up the primary pass manager.
|
||||
void populateModulePassManager(PassManagerBase &MPM);
|
||||
void populateLTOPassManager(PassManagerBase &PM, bool Internalize,
|
||||
bool RunInliner, bool DisableGVNLoadPRE = false);
|
||||
};
|
||||
|
||||
/// Registers a function for adding a standard set of passes. This should be
|
||||
/// used by optimizer plugins to allow all front ends to transparently use
|
||||
/// them. Create a static instance of this class in your plugin, providing a
|
||||
/// private function that the PassManagerBuilder can use to add your passes.
|
||||
struct RegisterStandardPasses {
|
||||
RegisterStandardPasses(PassManagerBuilder::ExtensionPointTy Ty,
|
||||
PassManagerBuilder::ExtensionFn Fn) {
|
||||
PassManagerBuilder::addGlobalExtension(Ty, Fn);
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
#endif
|
||||
Reference in New Issue
Block a user