mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
* Add a stub to FunctionPass so that subclasses can declare that they do not
modify the CFG. It currently does nothing, but will in the future. * Changes to make the public PassManager.h be MUCH smaller, and devoid of implementation details. Now PassManager is just a Pimpl class that wraps PassManagerT<Module>, but lib/VMCore/Pass.cpp is now the only class that has to #include PassManagerT.h git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2383 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3adc069c8b
commit
d30efaf56e
@ -11,7 +11,7 @@
|
|||||||
// Passes should extend one of the classes below, depending on the guarantees
|
// Passes should extend one of the classes below, depending on the guarantees
|
||||||
// that it can make about what will be modified as it is run. For example, most
|
// that it can make about what will be modified as it is run. For example, most
|
||||||
// global optimizations should derive from FunctionPass, because they do not add
|
// global optimizations should derive from FunctionPass, because they do not add
|
||||||
// or delete functionss, they operate on the internals of the function.
|
// or delete functions, they operate on the internals of the function.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
@ -26,14 +26,9 @@ class Function;
|
|||||||
class Module;
|
class Module;
|
||||||
class AnalysisUsage;
|
class AnalysisUsage;
|
||||||
class AnalysisID;
|
class AnalysisID;
|
||||||
class Pass;
|
|
||||||
template<class UnitType> class PassManagerT;
|
template<class UnitType> class PassManagerT;
|
||||||
struct AnalysisResolver;
|
struct AnalysisResolver;
|
||||||
|
|
||||||
// PassManager - Top level PassManagerT instantiation intended to be used.
|
|
||||||
// Implemented in PassManager.h
|
|
||||||
typedef PassManagerT<Module> PassManager;
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Pass interface - Implemented by all 'passes'. Subclass this if you are an
|
// Pass interface - Implemented by all 'passes'. Subclass this if you are an
|
||||||
// interprocedural optimization or you do not fit into any of the more
|
// interprocedural optimization or you do not fit into any of the more
|
||||||
@ -143,6 +138,18 @@ struct FunctionPass : public Pass {
|
|||||||
//
|
//
|
||||||
bool run(Function *F);
|
bool run(Function *F);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// doesNotModifyCFG - This function should be called by our subclasses to
|
||||||
|
// implement the getAnalysisUsage virtual function, iff they do not:
|
||||||
|
//
|
||||||
|
// 1. Add or remove basic blocks from the function
|
||||||
|
// 2. Modify terminator instructions in any way.
|
||||||
|
//
|
||||||
|
// This function annotates the AnalysisUsage info object to say that analyses
|
||||||
|
// that only depend on the CFG are preserved by this pass.
|
||||||
|
//
|
||||||
|
void doesNotModifyCFG(AnalysisUsage &Info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class PassManagerT<Module>;
|
friend class PassManagerT<Module>;
|
||||||
friend class PassManagerT<Function>;
|
friend class PassManagerT<Function>;
|
||||||
|
36
include/llvm/PassManager.h
Normal file
36
include/llvm/PassManager.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
//===- llvm/PassManager.h - Container for Passes -----------------*- C++ -*--=//
|
||||||
|
//
|
||||||
|
// This file defines the PassManager class. This class is used to hold,
|
||||||
|
// maintain, and optimize execution of Pass's. The PassManager class ensures
|
||||||
|
// that analysis results are available before a pass runs, and that Pass's are
|
||||||
|
// destroyed when the PassManager is destroyed.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_PASSMANAGER_H
|
||||||
|
#define LLVM_PASSMANAGER_H
|
||||||
|
|
||||||
|
class Pass;
|
||||||
|
class Module;
|
||||||
|
template<class UnitType> class PassManagerT;
|
||||||
|
|
||||||
|
class PassManager {
|
||||||
|
PassManagerT<Module> *PM; // This is a straightforward Pimpl class
|
||||||
|
public:
|
||||||
|
PassManager();
|
||||||
|
~PassManager();
|
||||||
|
|
||||||
|
// add - Add a pass to the queue of passes to run. This passes ownership of
|
||||||
|
// the Pass to the PassManager. When the PassManager is destroyed, the pass
|
||||||
|
// will be destroyed as well, so there is no need to delete the pass. This
|
||||||
|
// implies that all passes MUST be allocated with 'new'.
|
||||||
|
//
|
||||||
|
void add(Pass *P);
|
||||||
|
|
||||||
|
// run - Execute all of the passes scheduled for execution. Keep track of
|
||||||
|
// whether any of the functions modifies the program, and if so, return true.
|
||||||
|
//
|
||||||
|
bool run(Module *M);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -7,11 +7,14 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
|
#include "PassManagerT.h" // PassManagerT implementation
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/BasicBlock.h"
|
#include "llvm/BasicBlock.h"
|
||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include <algorithm>
|
#include "Support/CommandLine.h"
|
||||||
|
#include <typeinfo>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
// Source of unique analysis ID #'s.
|
// Source of unique analysis ID #'s.
|
||||||
unsigned AnalysisID::NextID = 0;
|
unsigned AnalysisID::NextID = 0;
|
||||||
@ -21,15 +24,22 @@ void AnalysisResolver::setAnalysisResolver(Pass *P, AnalysisResolver *AR) {
|
|||||||
P->Resolver = AR;
|
P->Resolver = AR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// PassManager implementation - The PassManager class is a simple Pimpl class
|
||||||
|
// that wraps the PassManagerT template.
|
||||||
|
//
|
||||||
|
PassManager::PassManager() : PM(new PassManagerT<Module>()) {}
|
||||||
|
PassManager::~PassManager() { delete PM; }
|
||||||
|
void PassManager::add(Pass *P) { PM->add(P); }
|
||||||
|
bool PassManager::run(Module *M) { return PM->run(M); }
|
||||||
|
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
// Pass debugging information. Often it is useful to find out what pass is
|
// Pass debugging information. Often it is useful to find out what pass is
|
||||||
// running when a crash occurs in a utility. When this library is compiled with
|
// running when a crash occurs in a utility. When this library is compiled with
|
||||||
// debugging on, a command line option (--debug-pass) is enabled that causes the
|
// debugging on, a command line option (--debug-pass) is enabled that causes the
|
||||||
// pass name to be printed before it executes.
|
// pass name to be printed before it executes.
|
||||||
//
|
//
|
||||||
#include "Support/CommandLine.h"
|
|
||||||
#include <typeinfo>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// Different debug levels that can be enabled...
|
// Different debug levels that can be enabled...
|
||||||
enum PassDebugLevel {
|
enum PassDebugLevel {
|
||||||
@ -132,6 +142,20 @@ void FunctionPass::addToPassManager(PassManagerT<Function> *PM,
|
|||||||
PM->addPass(this, AU);
|
PM->addPass(this, AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// doesNotModifyCFG - This function should be called by our subclasses to
|
||||||
|
// implement the getAnalysisUsage virtual function, iff they do not:
|
||||||
|
//
|
||||||
|
// 1. Add or remove basic blocks from the function
|
||||||
|
// 2. Modify terminator instructions in any way.
|
||||||
|
//
|
||||||
|
// This function annotates the AnalysisUsage info object to say that analyses
|
||||||
|
// that only depend on the CFG are preserved by this pass.
|
||||||
|
//
|
||||||
|
void FunctionPass::doesNotModifyCFG(AnalysisUsage &Info) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// BasicBlockPass Implementation
|
// BasicBlockPass Implementation
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user