mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
elimiante the dynamic_cast's from opt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94160 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -28,8 +28,8 @@ class PMStack;
|
|||||||
|
|
||||||
class LoopPass : public Pass {
|
class LoopPass : public Pass {
|
||||||
public:
|
public:
|
||||||
explicit LoopPass(intptr_t pid) : Pass(pid) {}
|
explicit LoopPass(intptr_t pid) : Pass(PT_Loop, pid) {}
|
||||||
explicit LoopPass(void *pid) : Pass(pid) {}
|
explicit LoopPass(void *pid) : Pass(PT_Loop, pid) {}
|
||||||
|
|
||||||
// runOnLoop - This method should be implemented by the subclass to perform
|
// runOnLoop - This method should be implemented by the subclass to perform
|
||||||
// whatever action is necessary for the specified Loop.
|
// whatever action is necessary for the specified Loop.
|
||||||
|
@ -32,8 +32,8 @@ class PMStack;
|
|||||||
|
|
||||||
struct CallGraphSCCPass : public Pass {
|
struct CallGraphSCCPass : public Pass {
|
||||||
|
|
||||||
explicit CallGraphSCCPass(intptr_t pid) : Pass(pid) {}
|
explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {}
|
||||||
explicit CallGraphSCCPass(void *pid) : Pass(pid) {}
|
explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {}
|
||||||
|
|
||||||
/// doInitialization - This method is called before the SCC's of the program
|
/// doInitialization - This method is called before the SCC's of the program
|
||||||
/// has been processed, allowing the pass to do initialization as necessary.
|
/// has been processed, allowing the pass to do initialization as necessary.
|
||||||
|
@ -64,6 +64,16 @@ enum PassManagerType {
|
|||||||
PMT_Last
|
PMT_Last
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Different types of passes.
|
||||||
|
enum PassKind {
|
||||||
|
PT_BasicBlock,
|
||||||
|
PT_Loop,
|
||||||
|
PT_Function,
|
||||||
|
PT_CallGraphSCC,
|
||||||
|
PT_Module,
|
||||||
|
PT_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
|
||||||
@ -72,19 +82,23 @@ enum PassManagerType {
|
|||||||
class Pass {
|
class Pass {
|
||||||
AnalysisResolver *Resolver; // Used to resolve analysis
|
AnalysisResolver *Resolver; // Used to resolve analysis
|
||||||
intptr_t PassID;
|
intptr_t PassID;
|
||||||
|
PassKind Kind;
|
||||||
void operator=(const Pass&); // DO NOT IMPLEMENT
|
void operator=(const Pass&); // DO NOT IMPLEMENT
|
||||||
Pass(const Pass &); // DO NOT IMPLEMENT
|
Pass(const Pass &); // DO NOT IMPLEMENT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) {
|
explicit Pass(PassKind K, intptr_t pid) : Resolver(0), PassID(pid), Kind(K) {
|
||||||
assert(pid && "pid cannot be 0");
|
assert(pid && "pid cannot be 0");
|
||||||
}
|
}
|
||||||
explicit Pass(const void *pid) : Resolver(0), PassID((intptr_t)pid) {
|
explicit Pass(PassKind K, const void *pid)
|
||||||
|
: Resolver(0), PassID((intptr_t)pid), Kind(K) {
|
||||||
assert(pid && "pid cannot be 0");
|
assert(pid && "pid cannot be 0");
|
||||||
}
|
}
|
||||||
virtual ~Pass();
|
virtual ~Pass();
|
||||||
|
|
||||||
|
|
||||||
|
PassKind getPassKind() const { return Kind; }
|
||||||
|
|
||||||
/// getPassName - Return a nice clean name for a pass. This usually
|
/// getPassName - Return a nice clean name for a pass. This usually
|
||||||
/// implemented in terms of the name that is registered by one of the
|
/// implemented in terms of the name that is registered by one of the
|
||||||
/// Registration templates, but can be overloaded directly.
|
/// Registration templates, but can be overloaded directly.
|
||||||
@ -118,7 +132,7 @@ public:
|
|||||||
|
|
||||||
// Access AnalysisResolver
|
// Access AnalysisResolver
|
||||||
inline void setResolver(AnalysisResolver *AR) {
|
inline void setResolver(AnalysisResolver *AR) {
|
||||||
assert (!Resolver && "Resolver is already set");
|
assert(!Resolver && "Resolver is already set");
|
||||||
Resolver = AR;
|
Resolver = AR;
|
||||||
}
|
}
|
||||||
inline AnalysisResolver *getResolver() {
|
inline AnalysisResolver *getResolver() {
|
||||||
@ -229,8 +243,8 @@ public:
|
|||||||
/// Return what kind of Pass Manager can manage this pass.
|
/// Return what kind of Pass Manager can manage this pass.
|
||||||
virtual PassManagerType getPotentialPassManagerType() const;
|
virtual PassManagerType getPotentialPassManagerType() const;
|
||||||
|
|
||||||
explicit ModulePass(intptr_t pid) : Pass(pid) {}
|
explicit ModulePass(intptr_t pid) : Pass(PT_Module, pid) {}
|
||||||
explicit ModulePass(const void *pid) : Pass(pid) {}
|
explicit ModulePass(const void *pid) : Pass(PT_Module, pid) {}
|
||||||
// Force out-of-line virtual method.
|
// Force out-of-line virtual method.
|
||||||
virtual ~ModulePass();
|
virtual ~ModulePass();
|
||||||
};
|
};
|
||||||
@ -276,8 +290,8 @@ public:
|
|||||||
///
|
///
|
||||||
class FunctionPass : public Pass {
|
class FunctionPass : public Pass {
|
||||||
public:
|
public:
|
||||||
explicit FunctionPass(intptr_t pid) : Pass(pid) {}
|
explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {}
|
||||||
explicit FunctionPass(const void *pid) : Pass(pid) {}
|
explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {}
|
||||||
|
|
||||||
/// doInitialization - Virtual method overridden by subclasses to do
|
/// doInitialization - Virtual method overridden by subclasses to do
|
||||||
/// any necessary per-module initialization.
|
/// any necessary per-module initialization.
|
||||||
@ -326,8 +340,8 @@ public:
|
|||||||
///
|
///
|
||||||
class BasicBlockPass : public Pass {
|
class BasicBlockPass : public Pass {
|
||||||
public:
|
public:
|
||||||
explicit BasicBlockPass(intptr_t pid) : Pass(pid) {}
|
explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {}
|
||||||
explicit BasicBlockPass(const void *pid) : Pass(pid) {}
|
explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {}
|
||||||
|
|
||||||
/// doInitialization - Virtual method overridden by subclasses to do
|
/// doInitialization - Virtual method overridden by subclasses to do
|
||||||
/// any necessary per-module initialization.
|
/// any necessary per-module initialization.
|
||||||
|
@ -172,7 +172,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
explicit FunctionPassManagerImpl(int Depth) :
|
explicit FunctionPassManagerImpl(int Depth) :
|
||||||
Pass(&ID), PMDataManager(Depth),
|
Pass(PT_PassManager, &ID), PMDataManager(Depth),
|
||||||
PMTopLevelManager(TLM_Function), wasRun(false) { }
|
PMTopLevelManager(TLM_Function), wasRun(false) { }
|
||||||
|
|
||||||
/// add - Add a pass to the queue of passes to run. This passes ownership of
|
/// add - Add a pass to the queue of passes to run. This passes ownership of
|
||||||
@ -241,7 +241,7 @@ class MPPassManager : public Pass, public PMDataManager {
|
|||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
explicit MPPassManager(int Depth) :
|
explicit MPPassManager(int Depth) :
|
||||||
Pass(&ID), PMDataManager(Depth) { }
|
Pass(PT_PassManager, &ID), PMDataManager(Depth) { }
|
||||||
|
|
||||||
// Delete on the fly managers.
|
// Delete on the fly managers.
|
||||||
virtual ~MPPassManager() {
|
virtual ~MPPassManager() {
|
||||||
@ -321,7 +321,8 @@ class PassManagerImpl : public Pass,
|
|||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
explicit PassManagerImpl(int Depth) :
|
explicit PassManagerImpl(int Depth) :
|
||||||
Pass(&ID), PMDataManager(Depth), PMTopLevelManager(TLM_Pass) { }
|
Pass(PT_PassManager, &ID), PMDataManager(Depth),
|
||||||
|
PMTopLevelManager(TLM_Pass) { }
|
||||||
|
|
||||||
/// add - Add a pass to the queue of passes to run. This passes ownership of
|
/// 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
|
/// the Pass to the PassManager. When the PassManager is destroyed, the pass
|
||||||
|
@ -479,16 +479,23 @@ int main(int argc, char **argv) {
|
|||||||
addPass(Passes, P);
|
addPass(Passes, P);
|
||||||
|
|
||||||
if (AnalyzeOnly) {
|
if (AnalyzeOnly) {
|
||||||
if (dynamic_cast<BasicBlockPass*>(P))
|
switch (P->getPassKind()) {
|
||||||
|
case PT_BasicBlock:
|
||||||
Passes.add(new BasicBlockPassPrinter(PassInf));
|
Passes.add(new BasicBlockPassPrinter(PassInf));
|
||||||
else if (dynamic_cast<LoopPass*>(P))
|
break;
|
||||||
|
case PT_Loop:
|
||||||
Passes.add(new LoopPassPrinter(PassInf));
|
Passes.add(new LoopPassPrinter(PassInf));
|
||||||
else if (dynamic_cast<FunctionPass*>(P))
|
break;
|
||||||
|
case PT_Function:
|
||||||
Passes.add(new FunctionPassPrinter(PassInf));
|
Passes.add(new FunctionPassPrinter(PassInf));
|
||||||
else if (dynamic_cast<CallGraphSCCPass*>(P))
|
break;
|
||||||
|
case PT_CallGraphSCC:
|
||||||
Passes.add(new CallGraphSCCPassPrinter(PassInf));
|
Passes.add(new CallGraphSCCPassPrinter(PassInf));
|
||||||
else
|
break;
|
||||||
|
default:
|
||||||
Passes.add(new ModulePassPrinter(PassInf));
|
Passes.add(new ModulePassPrinter(PassInf));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user