X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FPassSupport.h;h=f594d45f1522b83cd73d288662cf226131ae2b9c;hb=7adb53e7b1a4ec0cda17cbc946da44147c141d69;hp=9f5bc55f9c7f3e1314c034c52e1f382b2c7384b1;hpb=947c7689fc0435c7bb69b62f61ff40e266e87f0c;p=oota-llvm.git diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h index 9f5bc55f9c7..f594d45f152 100644 --- a/include/llvm/PassSupport.h +++ b/include/llvm/PassSupport.h @@ -37,20 +37,20 @@ class TargetMachine; class PassInfo { const char *PassName; // Nice name for Pass const char *PassArgument; // Command Line argument to run this pass - const std::type_info &TypeInfo; // type_info object for this Pass class + intptr_t PassID; bool IsCFGOnlyPass; // Pass only looks at the CFG. bool IsAnalysisGroup; // True if an analysis group. std::vector ItfImpl;// Interfaces implemented by this pass - Pass *(*NormalCtor)(); // No argument ctor + Pass *(*NormalCtor)(); public: /// PassInfo ctor - Do not call this directly, this should only be invoked /// through RegisterPass. - PassInfo(const char *name, const char *arg, const std::type_info &ti, - Pass *(*normal)() = 0) - : PassName(name), PassArgument(arg), TypeInfo(ti), - IsCFGOnlyPass(false), IsAnalysisGroup(false), NormalCtor(normal) { + PassInfo(const char *name, const char *arg, intptr_t pi, + Pass *(*normal)() = 0, bool isCFGOnly = false) + : PassName(name), PassArgument(arg), PassID(pi), + IsCFGOnlyPass(isCFGOnly), IsAnalysisGroup(false), NormalCtor(normal) { } /// getPassName - Return the friendly name for the pass, never returns null @@ -65,8 +65,8 @@ public: const char *getPassArgument() const { return PassArgument; } /// getTypeInfo - Return the type_info object for the pass... - /// - const std::type_info &getTypeInfo() const { return TypeInfo; } + /// TODO : Rename + intptr_t getTypeInfo() const { return PassID; } /// isAnalysisGroup - Return true if this is an analysis group, not a normal /// pass. @@ -77,7 +77,6 @@ public: /// isCFGOnlyPass - return true if this pass only looks at the CFG for the /// function. bool isCFGOnlyPass() const { return IsCFGOnlyPass; } - void SetIsCFGOnlyPass() { IsCFGOnlyPass = true; } /// getNormalCtor - Return a pointer to a function, that when called, creates /// an instance of the pass and returns it. This pointer may be null if there @@ -131,43 +130,31 @@ public: /// must be called, create a global constructor function (which takes the /// arguments you need and returns a Pass*) and register your pass like this: /// -/// Pass *createMyPass(foo &opt) { return new MyPass(opt); } -/// static RegisterPass tmp("passopt", "My Name", createMyPass); +/// static RegisterPass tmp("passopt", "My Name"); /// struct RegisterPassBase { /// getPassInfo - Get the pass info for the registered class... /// const PassInfo *getPassInfo() const { return &PIObj; } - RegisterPassBase(const char *Name, const char *Arg, const std::type_info &TI, - Pass *(*NormalCtor)() = 0) - : PIObj(Name, Arg, TI, NormalCtor) { + typedef Pass* (*NormalCtor_t)(); + + RegisterPassBase(const char *Name, const char *Arg, intptr_t TI, + NormalCtor_t NormalCtor = 0, bool CFGOnly = false) + : PIObj(Name, Arg, TI, NormalCtor, CFGOnly) { registerPass(); } - RegisterPassBase(const std::type_info &TI) + RegisterPassBase(intptr_t TI) : PIObj("", "", TI) { // This ctor may only be used for analysis groups: it does not auto-register // the pass. PIObj.SetIsAnalysisGroup(); } - - ~RegisterPassBase() { // Intentionally non-virtual. - // Analysis groups are registered/unregistered by their dtor. - if (!PIObj.isAnalysisGroup()) - unregisterPass(); - } protected: PassInfo PIObj; // The PassInfo object for this pass void registerPass(); void unregisterPass(); - - /// setOnlyUsesCFG - Notice that this pass only depends on the CFG, so - /// transformations that do not modify the CFG do not invalidate this pass. - /// - void setOnlyUsesCFG() { - PIObj.SetIsCFGOnlyPass(); - } }; template @@ -178,9 +165,8 @@ struct RegisterPass : public RegisterPassBase { // Register Pass using default constructor... RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false) - : RegisterPassBase(Name, PassArg, typeid(PassName), - callDefaultCtor) { - if (CFGOnly) setOnlyUsesCFG(); + : RegisterPassBase(Name, PassArg, (intptr_t)&PassName::ID, + (RegisterPassBase::NormalCtor_t)callDefaultCtor, CFGOnly) { } }; @@ -209,23 +195,21 @@ class RegisterAGBase : public RegisterPassBase { const PassInfo *ImplementationInfo; bool isDefaultImplementation; protected: - RegisterAGBase(const std::type_info &Interface, - const std::type_info *Pass = 0, - bool isDefault = false); + explicit RegisterAGBase(intptr_t InterfaceID, + intptr_t PassID = 0, + bool isDefault = false); void setGroupName(const char *Name); -public: - ~RegisterAGBase(); }; template struct RegisterAnalysisGroup : public RegisterAGBase { - RegisterAnalysisGroup(RegisterPassBase &RPB) - : RegisterAGBase(typeid(Interface), &RPB.getPassInfo()->getTypeInfo(), + explicit RegisterAnalysisGroup(RegisterPassBase &RPB) + : RegisterAGBase((intptr_t) &Interface::ID, RPB.getPassInfo()->getTypeInfo(), Default) { } - RegisterAnalysisGroup(const char *Name) - : RegisterAGBase(typeid(Interface)) { + explicit RegisterAnalysisGroup(const char *Name) + : RegisterAGBase((intptr_t) &Interface::ID) { setGroupName(Name); } }; @@ -255,7 +239,6 @@ struct PassRegistrationListener { /// or removed from the current executable. /// virtual void passRegistered(const PassInfo *P) {} - virtual void passUnregistered(const PassInfo *P) {} /// enumeratePasses - Iterate over the registered passes, calling the /// passEnumerate callback on each PassInfo object.