mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
Split FunctionPassManager_New into FunctionPassManager_New and FunctionPassManagerImpl_New.
FunctionPassManagerImpl_New implements the pass manager. FunctionPassManager_New is the public interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31547 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -90,6 +90,7 @@ public:
|
|||||||
|
|
||||||
class ModulePassManager_New;
|
class ModulePassManager_New;
|
||||||
class PassManagerImpl_New;
|
class PassManagerImpl_New;
|
||||||
|
class FunctionPassManagerImpl_New;
|
||||||
|
|
||||||
/// PassManagerAnalysisHelper helps pass manager analysis required by
|
/// PassManagerAnalysisHelper helps pass manager analysis required by
|
||||||
/// the managed passes. It provides methods to add/remove analysis
|
/// the managed passes. It provides methods to add/remove analysis
|
||||||
@ -148,6 +149,33 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// FunctionPassManager_New manages FunctionPasses and BasicBlockPassManagers.
|
||||||
|
class FunctionPassManager_New : public Pass,
|
||||||
|
public PassManagerAnalysisHelper {
|
||||||
|
public:
|
||||||
|
FunctionPassManager_New(ModuleProvider *P) { /* TODO */ }
|
||||||
|
FunctionPassManager_New();
|
||||||
|
~FunctionPassManager_New() { /* TODO */ };
|
||||||
|
|
||||||
|
/// add - Add a pass to the queue of passes to run. This passes
|
||||||
|
/// ownership of the Pass to the PassManager. When the
|
||||||
|
/// PassManager_X is destroyed, the pass will be destroyed as well, so
|
||||||
|
/// there is no need to delete the pass. (TODO delete passes.)
|
||||||
|
/// This implies that all passes MUST be allocated with 'new'.
|
||||||
|
void add(Pass *P);
|
||||||
|
|
||||||
|
/// Execute all of the passes scheduled for execution. Keep
|
||||||
|
/// track of whether any of the passes modifies the function, and if
|
||||||
|
/// so, return true.
|
||||||
|
bool runOnModule(Module &M);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
FunctionPassManagerImpl_New *FPM;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,18 +40,18 @@ private:
|
|||||||
std::vector<Pass *> PassVector;
|
std::vector<Pass *> PassVector;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// FunctionPassManager_New manages FunctionPasses and BasicBlockPassManagers.
|
/// FunctionPassManagerImpl_New manages FunctionPasses and BasicBlockPassManagers.
|
||||||
/// It batches all function passes and basic block pass managers together and
|
/// It batches all function passes and basic block pass managers together and
|
||||||
/// sequence them to process one function at a time before processing next
|
/// sequence them to process one function at a time before processing next
|
||||||
/// function.
|
/// function.
|
||||||
class FunctionPassManager_New : public Pass,
|
class FunctionPassManagerImpl_New : public Pass,
|
||||||
public PassManagerAnalysisHelper {
|
public PassManagerAnalysisHelper {
|
||||||
public:
|
public:
|
||||||
FunctionPassManager_New(ModuleProvider *P) { /* TODO */ }
|
FunctionPassManagerImpl_New(ModuleProvider *P) { /* TODO */ }
|
||||||
FunctionPassManager_New() {
|
FunctionPassManagerImpl_New() {
|
||||||
activeBBPassManager = NULL;
|
activeBBPassManager = NULL;
|
||||||
}
|
}
|
||||||
~FunctionPassManager_New() { /* TODO */ };
|
~FunctionPassManagerImpl_New() { /* TODO */ };
|
||||||
|
|
||||||
/// add - Add a pass to the queue of passes to run. This passes
|
/// add - Add a pass to the queue of passes to run. This passes
|
||||||
/// ownership of the Pass to the PassManager. When the
|
/// ownership of the Pass to the PassManager. When the
|
||||||
@ -97,7 +97,7 @@ private:
|
|||||||
std::vector<Pass *> PassVector;
|
std::vector<Pass *> PassVector;
|
||||||
|
|
||||||
// Active Pass Manager
|
// Active Pass Manager
|
||||||
FunctionPassManager_New *activeFunctionPassManager;
|
FunctionPassManagerImpl_New *activeFunctionPassManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// PassManager_New manages ModulePassManagers
|
/// PassManager_New manages ModulePassManagers
|
||||||
@ -219,6 +219,30 @@ BasicBlockPassManager_New::runOnFunction(Function &F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FunctionPassManager_New implementation
|
// FunctionPassManager_New implementation
|
||||||
|
/// Create new Function pass manager
|
||||||
|
FunctionPassManager_New::FunctionPassManager_New() {
|
||||||
|
FPM = new FunctionPassManagerImpl_New();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// add - Add a pass to the queue of passes to run. This passes
|
||||||
|
/// ownership of the Pass to the PassManager. When the
|
||||||
|
/// PassManager_X is destroyed, the pass will be destroyed as well, so
|
||||||
|
/// there is no need to delete the pass. (TODO delete passes.)
|
||||||
|
/// This implies that all passes MUST be allocated with 'new'.
|
||||||
|
void
|
||||||
|
FunctionPassManager_New::add(Pass *P) {
|
||||||
|
FPM->add(P);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Execute all of the passes scheduled for execution. Keep
|
||||||
|
/// track of whether any of the passes modifies the function, and if
|
||||||
|
/// so, return true.
|
||||||
|
bool
|
||||||
|
FunctionPassManager_New::runOnModule(Module &M) {
|
||||||
|
return FPM->runOnModule(M);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FunctionPassManagerImpl_New implementation
|
||||||
|
|
||||||
// FunctionPassManager
|
// FunctionPassManager
|
||||||
|
|
||||||
@ -226,7 +250,7 @@ BasicBlockPassManager_New::runOnFunction(Function &F) {
|
|||||||
/// either use it into active basic block pass manager or create new basic
|
/// either use it into active basic block pass manager or create new basic
|
||||||
/// block pass manager to handle pass P.
|
/// block pass manager to handle pass P.
|
||||||
bool
|
bool
|
||||||
FunctionPassManager_New::addPass(Pass *P) {
|
FunctionPassManagerImpl_New::addPass(Pass *P) {
|
||||||
|
|
||||||
// If P is a BasicBlockPass then use BasicBlockPassManager_New.
|
// If P is a BasicBlockPass then use BasicBlockPassManager_New.
|
||||||
if (BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P)) {
|
if (BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P)) {
|
||||||
@ -264,7 +288,7 @@ FunctionPassManager_New::addPass(Pass *P) {
|
|||||||
/// runOnFunction method. Keep track of whether any of the passes modifies
|
/// runOnFunction method. Keep track of whether any of the passes modifies
|
||||||
/// the function, and if so, return true.
|
/// the function, and if so, return true.
|
||||||
bool
|
bool
|
||||||
FunctionPassManager_New::runOnModule(Module &M) {
|
FunctionPassManagerImpl_New::runOnModule(Module &M) {
|
||||||
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
||||||
@ -281,7 +305,7 @@ FunctionPassManager_New::runOnModule(Module &M) {
|
|||||||
// ModulePassManager implementation
|
// ModulePassManager implementation
|
||||||
|
|
||||||
/// Add P into pass vector if it is manageble. If P is a FunctionPass
|
/// Add P into pass vector if it is manageble. If P is a FunctionPass
|
||||||
/// then use FunctionPassManager_New to manage it. Return false if P
|
/// then use FunctionPassManagerImpl_New to manage it. Return false if P
|
||||||
/// is not manageable by this manager.
|
/// is not manageable by this manager.
|
||||||
bool
|
bool
|
||||||
ModulePassManager_New::addPass(Pass *P) {
|
ModulePassManager_New::addPass(Pass *P) {
|
||||||
@ -294,7 +318,7 @@ ModulePassManager_New::addPass(Pass *P) {
|
|||||||
if (!activeFunctionPassManager
|
if (!activeFunctionPassManager
|
||||||
|| !activeFunctionPassManager->addPass(P)) {
|
|| !activeFunctionPassManager->addPass(P)) {
|
||||||
|
|
||||||
activeFunctionPassManager = new FunctionPassManager_New();
|
activeFunctionPassManager = new FunctionPassManagerImpl_New();
|
||||||
|
|
||||||
PassVector.push_back(activeFunctionPassManager);
|
PassVector.push_back(activeFunctionPassManager);
|
||||||
if (!activeFunctionPassManager->addPass(FP))
|
if (!activeFunctionPassManager->addPass(FP))
|
||||||
|
Reference in New Issue
Block a user