diff options
author | Chris Lattner <sabre@nondot.org> | 2002-02-26 21:46:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-02-26 21:46:54 +0000 |
commit | bd0ef77cde9c9e82f2b4ad33e4982c46274d6540 (patch) | |
tree | 0903b61112c9e6d336c8b623e235ede2f937f13c /include/llvm/Transforms | |
parent | 3b2541424f771ae11c30675ce06da7b380780028 (diff) |
Change over to use new style pass mechanism, now passes only expose small
creation functions in their public header file, unless they can help it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1816 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms')
-rw-r--r-- | include/llvm/Transforms/ChangeAllocations.h | 47 | ||||
-rw-r--r-- | include/llvm/Transforms/FunctionInlining.h | 17 | ||||
-rw-r--r-- | include/llvm/Transforms/HoistPHIConstants.h | 11 | ||||
-rw-r--r-- | include/llvm/Transforms/IPO.h | 32 | ||||
-rw-r--r-- | include/llvm/Transforms/IPO/ConstantMerge.h | 42 | ||||
-rw-r--r-- | include/llvm/Transforms/IPO/GlobalDCE.h | 22 | ||||
-rw-r--r-- | include/llvm/Transforms/IPO/SimpleStructMutation.h | 28 | ||||
-rw-r--r-- | include/llvm/Transforms/Instrumentation/TraceValues.h | 33 | ||||
-rw-r--r-- | include/llvm/Transforms/RaisePointerReferences.h | 19 | ||||
-rw-r--r-- | include/llvm/Transforms/Scalar/ConstantProp.h | 33 | ||||
-rw-r--r-- | include/llvm/Transforms/Scalar/DCE.h | 54 | ||||
-rw-r--r-- | include/llvm/Transforms/Scalar/IndVarSimplify.h | 15 | ||||
-rw-r--r-- | include/llvm/Transforms/Scalar/InstructionCombining.h | 11 | ||||
-rw-r--r-- | include/llvm/Transforms/Scalar/SymbolStripping.h | 33 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h | 4 |
15 files changed, 60 insertions, 341 deletions
diff --git a/include/llvm/Transforms/ChangeAllocations.h b/include/llvm/Transforms/ChangeAllocations.h index f0a06859e9..1b837419bd 100644 --- a/include/llvm/Transforms/ChangeAllocations.h +++ b/include/llvm/Transforms/ChangeAllocations.h @@ -10,51 +10,10 @@ #ifndef LLVM_TRANSFORMS_CHANGEALLOCATIONS_H #define LLVM_TRANSFORMS_CHANGEALLOCATIONS_H -#include "llvm/Pass.h" +class Pass; class TargetData; -// LowerAllocations - Turn malloc and free instructions into %malloc and %free -// calls. -// -class LowerAllocations : public BasicBlockPass { - Method *MallocMeth; // Methods in the module we are processing - Method *FreeMeth; // Initialized by doInitialization - - const TargetData &DataLayout; -public: - inline LowerAllocations(const TargetData &TD) : DataLayout(TD) { - MallocMeth = FreeMeth = 0; - } - - // doPassInitialization - For the lower allocations pass, this ensures that a - // module contains a declaration for a malloc and a free function. - // - bool doInitialization(Module *M); - - // runOnBasicBlock - This method does the actual work of converting - // instructions over, assuming that the pass has already been initialized. - // - bool runOnBasicBlock(BasicBlock *BB); -}; - -// RaiseAllocations - Turn %malloc and %free calls into the appropriate -// instruction. -// -class RaiseAllocations : public BasicBlockPass { - Method *MallocMeth; // Methods in the module we are processing - Method *FreeMeth; // Initialized by doPassInitializationVirt -public: - inline RaiseAllocations() : MallocMeth(0), FreeMeth(0) {} - - // doPassInitialization - For the raise allocations pass, this finds a - // declaration for malloc and free if they exist. - // - bool doInitialization(Module *M); - - // runOnBasicBlock - This method does the actual work of converting - // instructions over, assuming that the pass has already been initialized. - // - bool runOnBasicBlock(BasicBlock *BB); -}; +Pass *createLowerAllocationsPass(const TargetData &TD); +Pass *createRaiseAllocationsPass(); #endif diff --git a/include/llvm/Transforms/FunctionInlining.h b/include/llvm/Transforms/FunctionInlining.h index 252489749e..e321df52f7 100644 --- a/include/llvm/Transforms/FunctionInlining.h +++ b/include/llvm/Transforms/FunctionInlining.h @@ -4,23 +4,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_OPT_METHOD_INLINING_H -#define LLVM_OPT_METHOD_INLINING_H +#ifndef LLVM_TRANSFORMS_METHOD_INLINING_H +#define LLVM_TRANSFORMS_METHOD_INLINING_H -#include "llvm/Pass.h" #include "llvm/BasicBlock.h" class CallInst; +class Pass; -struct MethodInlining : public MethodPass { - // DoMethodInlining - Use a heuristic based approach to inline methods that - // seem to look good. - // - static bool doMethodInlining(Method *M); - - virtual bool runOnMethod(Method *M) { - return doMethodInlining(M); - } -}; +Pass *createMethodInliningPass(); // InlineMethod - This function forcibly inlines the called method into the // basic block of the caller. This returns true if it is not possible to inline diff --git a/include/llvm/Transforms/HoistPHIConstants.h b/include/llvm/Transforms/HoistPHIConstants.h index 27bf7ab021..3a1bab1bf1 100644 --- a/include/llvm/Transforms/HoistPHIConstants.h +++ b/include/llvm/Transforms/HoistPHIConstants.h @@ -9,14 +9,7 @@ #ifndef LLVM_TRANSFORMS_HOISTPHICONSTANTS_H #define LLVM_TRANSFORMS_HOISTPHICONSTANTS_H -#include "llvm/Pass.h" - -struct HoistPHIConstants : public MethodPass { - // doHoistPHIConstants - Hoist constants out of PHI instructions - // - static bool doHoistPHIConstants(Method *M); - - virtual bool runOnMethod(Method *M) { return doHoistPHIConstants(M); } -}; +class Pass; +Pass *createHoistPHIConstantsPass(); #endif diff --git a/include/llvm/Transforms/IPO.h b/include/llvm/Transforms/IPO.h index 313aea2090..3cc4e76aae 100644 --- a/include/llvm/Transforms/IPO.h +++ b/include/llvm/Transforms/IPO.h @@ -6,35 +6,7 @@ #ifndef LLVM_TRANSFORMS_CLEANUPGCCOUTPUT_H #define LLVM_TRANSFORMS_CLEANUPGCCOUTPUT_H -#include "llvm/Pass.h" - -struct CleanupGCCOutput : public MethodPass { - // PatchUpMethodReferences - This is a part of the functionality exported by - // the CleanupGCCOutput pass. This causes functions with different signatures - // to be linked together if they have the same name. - // - static bool PatchUpMethodReferences(Module *M); - - // doPassInitialization - For this pass, it removes global symbol table - // entries for primitive types. These are never used for linking in GCC and - // they make the output uglier to look at, so we nuke them. - // - // Also, initialize instance variables. - // - bool doInitialization(Module *M); - - // doPerMethodWork - This method simplifies the specified method hopefully. - // - bool runOnMethod(Method *M); - - // doPassFinalization - Strip out type names that are unused by the program - bool doFinalization(Module *M); - - // getAnalysisUsageInfo - This function needs FindUsedTypes to do its job... - // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided); -}; +class Pass; +Pass *createCleanupGCCOutputPass(); #endif diff --git a/include/llvm/Transforms/IPO/ConstantMerge.h b/include/llvm/Transforms/IPO/ConstantMerge.h index efc91f400b..b25fb66670 100644 --- a/include/llvm/Transforms/IPO/ConstantMerge.h +++ b/include/llvm/Transforms/IPO/ConstantMerge.h @@ -17,44 +17,8 @@ #ifndef LLVM_TRANSFORMS_CONSTANTMERGE_H #define LLVM_TRANSFORMS_CONSTANTMERGE_H -#include "llvm/Pass.h" -class Constant; -class GlobalVariable; - -// FIXME: ConstantMerge should not be a methodPass!!! -class ConstantMerge : public MethodPass { -protected: - std::map<Constant*, GlobalVariable*> Constants; - unsigned LastConstantSeen; -public: - inline ConstantMerge() : LastConstantSeen(0) {} - - // mergeDuplicateConstants - Static accessor for clients that don't want to - // deal with passes. - // - static bool mergeDuplicateConstants(Module *M); - - // doInitialization - For this pass, process all of the globals in the - // module, eliminating duplicate constants. - // - bool doInitialization(Module *M); - - bool runOnMethod(Method*) { return false; } - - // doFinalization - Clean up internal state for this module - // - bool doFinalization(Module *M) { - LastConstantSeen = 0; - Constants.clear(); - return false; - } -}; - -struct DynamicConstantMerge : public ConstantMerge { - // doPerMethodWork - Check to see if any globals have been added to the - // global list for the module. If so, eliminate them. - // - bool runOnMethod(Method *M); -}; +class Pass; +Pass *createConstantMergePass(); +Pass *createDynamicConstantMergePass(); #endif diff --git a/include/llvm/Transforms/IPO/GlobalDCE.h b/include/llvm/Transforms/IPO/GlobalDCE.h index 497416cbce..8956fc37e6 100644 --- a/include/llvm/Transforms/IPO/GlobalDCE.h +++ b/include/llvm/Transforms/IPO/GlobalDCE.h @@ -7,25 +7,7 @@ #ifndef LLVM_TRANSFORM_IPO_GLOBALDCE_H #define LLVM_TRANSFORM_IPO_GLOBALDCE_H -#include "llvm/Pass.h" - -namespace cfg { class CallGraph; } -class Module; - -struct GlobalDCE : public Pass { - - // run - Do the GlobalDCE pass on the specified module, optionally updating - // the specified callgraph to reflect the changes. - // - bool run(Module *M); - - // getAnalysisUsageInfo - This function works on the call graph of a module. - // It is capable of updating the call graph to reflect the new state of the - // module. - // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided); -}; +class Pass; +Pass *createGlobalDCEPass(); #endif diff --git a/include/llvm/Transforms/IPO/SimpleStructMutation.h b/include/llvm/Transforms/IPO/SimpleStructMutation.h index f159c4de02..ccfcea771a 100644 --- a/include/llvm/Transforms/IPO/SimpleStructMutation.h +++ b/include/llvm/Transforms/IPO/SimpleStructMutation.h @@ -8,30 +8,8 @@ #ifndef LLVM_TRANSFORMS_SIMPLESTRUCTMUTATION_H #define LLVM_TRANSFORMS_SIMPLESTRUCTMUTATION_H -#include "llvm/Transforms/IPO/MutateStructTypes.h" - -class SimpleStructMutation : public MutateStructTypes { -public: - enum Transform { SwapElements, SortElements } CurrentXForm; - - SimpleStructMutation(enum Transform XForm) : CurrentXForm(XForm) {} - - virtual bool run(Module *M) { - setTransforms(getTransforms(M, CurrentXForm)); - bool Changed = MutateStructTypes::run(M); - clearTransforms(); - return Changed; - } - - // getAnalysisUsageInfo - This function needs the results of the - // FindUsedTypes and FindUnsafePointerTypes analysis passes... - // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided); - -private: - TransformsType getTransforms(Module *M, enum Transform); -}; +class Pass; +Pass *createSwapElementsPass(); +Pass *createSortElementsPass(); #endif diff --git a/include/llvm/Transforms/Instrumentation/TraceValues.h b/include/llvm/Transforms/Instrumentation/TraceValues.h index 996db1747e..0519e1d67c 100644 --- a/include/llvm/Transforms/Instrumentation/TraceValues.h +++ b/include/llvm/Transforms/Instrumentation/TraceValues.h @@ -8,35 +8,8 @@ #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_TRACEVALUES_H #define LLVM_TRANSFORMS_INSTRUMENTATION_TRACEVALUES_H -#include "llvm/Pass.h" -class Method; - -class InsertTraceCode : public MethodPass { - bool TraceBasicBlockExits, TraceMethodExits; - Method *PrintfMeth; -public: - InsertTraceCode(bool traceBasicBlockExits, bool traceMethodExits) - : TraceBasicBlockExits(traceBasicBlockExits), - TraceMethodExits(traceMethodExits) {} - - // Add a prototype for printf if it is not already in the program. - // - bool doInitialization(Module *M); - - //-------------------------------------------------------------------------- - // Function InsertCodeToTraceValues - // - // Inserts tracing code for all live values at basic block and/or method exits - // as specified by `traceBasicBlockExits' and `traceMethodExits'. - // - static bool doit(Method *M, bool traceBasicBlockExits, - bool traceMethodExits, Method *Printf); - - // runOnMethod - This method does the work. Always successful. - // - bool runOnMethod(Method *M) { - return doit(M, TraceBasicBlockExits, TraceMethodExits, PrintfMeth); - } -}; +class Pass; +Pass *createTraceValuesPassForMethod(); // Just trace methods +Pass *createTraceValuesPassForBasicBlocks(); // Trace BB's and methods #endif diff --git a/include/llvm/Transforms/RaisePointerReferences.h b/include/llvm/Transforms/RaisePointerReferences.h index b652f33712..ec2ce319a3 100644 --- a/include/llvm/Transforms/RaisePointerReferences.h +++ b/include/llvm/Transforms/RaisePointerReferences.h @@ -9,27 +9,12 @@ #ifndef LLVM_TRANSFORMS_LEVELCHANGE_H #define LLVM_TRANSFORMS_LEVELCHANGE_H -#include "llvm/Pass.h" +class Pass; // RaisePointerReferences - Try to eliminate as many pointer arithmetic // expressions as possible, by converting expressions to use getelementptr and // friends. // -struct RaisePointerReferences : public MethodPass { - static bool doit(Method *M); - - virtual bool runOnMethod(Method *M) { return doit(M); } -}; - - -// EliminateAuxillaryInductionVariables - Eliminate all aux indvars. This -// converts all induction variables to reference a cannonical induction -// variable (which starts at 0 and counts by 1). -// -struct EliminateAuxillaryInductionVariables : public MethodPass { - static bool doit(Method *M) { return false; } // TODO! - - virtual bool runOnMethod(Method *M) { return doit(M); } -}; +Pass *createRaisePointerReferencesPass(); #endif diff --git a/include/llvm/Transforms/Scalar/ConstantProp.h b/include/llvm/Transforms/Scalar/ConstantProp.h index c4d973516c..3a8fa5b6d9 100644 --- a/include/llvm/Transforms/Scalar/ConstantProp.h +++ b/include/llvm/Transforms/Scalar/ConstantProp.h @@ -7,26 +7,19 @@ #ifndef LLVM_TRANSFORMS_SCALAR_CONSTANT_PROPOGATION_H #define LLVM_TRANSFORMS_SCALAR_CONSTANT_PROPOGATION_H -#include "llvm/Pass.h" #include "llvm/BasicBlock.h" class TerminatorInst; +class Pass; -struct ConstantPropogation : public MethodPass { - // doConstantPropogation - Do trivial constant propogation and expression - // folding - static bool doConstantPropogation(Method *M); - - // doConstantPropogation - Constant prop a specific instruction. Returns true - // and potentially moves the iterator if constant propogation was performed. - // - static bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &I); - - inline bool runOnMethod(Method *M) { - return doConstantPropogation(M); - } -}; - +//===----------------------------------------------------------------------===// +// Normal Constant Propogation Pass +// +Pass *createConstantPropogationPass(); +// doConstantPropogation - Constant prop a specific instruction. Returns true +// and potentially moves the iterator if constant propogation was performed. +// +bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &I); // ConstantFoldTerminator - If a terminator instruction is predicated on a // constant value, convert it into an unconditional branch to the constant @@ -38,12 +31,6 @@ bool ConstantFoldTerminator(TerminatorInst *T); //===----------------------------------------------------------------------===// // Sparse Conditional Constant Propogation Pass // -struct SCCPPass : public MethodPass { - static bool doSCCP(Method *M); - - inline bool runOnMethod(Method *M) { - return doSCCP(M); - } -}; +Pass *createSCCPPass(); #endif diff --git a/include/llvm/Transforms/Scalar/DCE.h b/include/llvm/Transforms/Scalar/DCE.h index 3246ed85e5..a8dcb59146 100644 --- a/include/llvm/Transforms/Scalar/DCE.h +++ b/include/llvm/Transforms/Scalar/DCE.h @@ -5,21 +5,19 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_OPT_DCE_H -#define LLVM_OPT_DCE_H +#ifndef LLVM_TRANSFORMS_SCALAR_DCE_H +#define LLVM_TRANSFORMS_SCALAR_DCE_H -#include "llvm/Pass.h" #include "llvm/Method.h" #include "llvm/BasicBlock.h" +class Pass; //===----------------------------------------------------------------------===// // DeadInstElimination - This pass quickly removes trivially dead instructions // without modifying the CFG of the function. It is a BasicBlockPass, so it // runs efficiently when queued next to other BasicBlockPass's. // -struct DeadInstElimination : public BasicBlockPass { - virtual bool runOnBasicBlock(BasicBlock *BB); -}; +Pass *createDeadInstEliminationPass(); //===----------------------------------------------------------------------===// @@ -32,34 +30,16 @@ struct DeadInstElimination : public BasicBlockPass { // otherwise simplifies control flow. This should be factored out of this pass // eventually into it's own pass. // -struct DeadCodeElimination : public MethodPass { - // External Interface: - // - static bool doDCE(Method *M); - // dceInstruction - Inspect the instruction at *BBI and figure out if it's - // [trivially] dead. If so, remove the instruction and update the iterator - // to point to the instruction that immediately succeeded the original - // instruction. - // - static bool dceInstruction(BasicBlock::InstListType &BBIL, - BasicBlock::iterator &BBI); +Pass *createDeadCodeEliminationPass(); - // Remove unused global values - This removes unused global values of no - // possible value. This currently includes unused method prototypes and - // unitialized global variables. - // - static bool RemoveUnusedGlobalValues(Module *M); - - // Pass Interface... - virtual bool doInitialization(Module *M) { - return RemoveUnusedGlobalValues(M); - } - virtual bool runOnMethod(Method *M) { return doDCE(M); } - virtual bool doFinalization(Module *M) { - return RemoveUnusedGlobalValues(M); - } -}; +// dceInstruction - Inspect the instruction at *BBI and figure out if it's +// [trivially] dead. If so, remove the instruction and update the iterator +// to point to the instruction that immediately succeeded the original +// instruction. +// +bool dceInstruction(BasicBlock::InstListType &BBIL, + BasicBlock::iterator &BBI); @@ -68,15 +48,7 @@ struct DeadCodeElimination : public MethodPass { // algorithm assumes instructions are dead until proven otherwise, which makes // it more successful are removing non-obviously dead instructions. // -struct AgressiveDCE : public MethodPass { - virtual bool runOnMethod(Method *M); - - // getAnalysisUsageInfo - We require post dominance frontiers (aka Control - // Dependence Graph) - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided); -}; +Pass *createAgressiveDCEPass(); // SimplifyCFG - This function is used to do simplification of a CFG. For diff --git a/include/llvm/Transforms/Scalar/IndVarSimplify.h b/include/llvm/Transforms/Scalar/IndVarSimplify.h index 902483eb8c..4fda9e77c2 100644 --- a/include/llvm/Transforms/Scalar/IndVarSimplify.h +++ b/include/llvm/Transforms/Scalar/IndVarSimplify.h @@ -8,18 +8,7 @@ #ifndef LLVM_TRANSFORMS_SCALAR_INDVARSIMPLIFY_H #define LLVM_TRANSFORMS_SCALAR_INDVARSIMPLIFY_H -#include "llvm/Pass.h" - -namespace cfg { class LoopInfo; } - -struct InductionVariableSimplify : public MethodPass { - static bool doit(Method *M, cfg::LoopInfo &Loops); - - virtual bool runOnMethod(Method *M); - - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided); -}; +class Pass; +Pass *createIndVarSimplifyPass(); #endif diff --git a/include/llvm/Transforms/Scalar/InstructionCombining.h b/include/llvm/Transforms/Scalar/InstructionCombining.h index 0c395720e6..37b49858ba 100644 --- a/include/llvm/Transforms/Scalar/InstructionCombining.h +++ b/include/llvm/Transforms/Scalar/InstructionCombining.h @@ -15,14 +15,7 @@ #ifndef LLVM_TRANSFORMS_SCALAR_INSTRUCTIONCOMBINING_H #define LLVM_TRANSFORMS_SCALAR_INSTRUCTIONCOMBINING_H -#include "llvm/Pass.h" -class Instruction; - -struct InstructionCombining : public MethodPass { - static bool doit(Method *M); - static bool CombineInstruction(Instruction *I); - - virtual bool runOnMethod(Method *M) { return doit(M); } -}; +class Pass; +Pass *createInstructionCombiningPass(); #endif diff --git a/include/llvm/Transforms/Scalar/SymbolStripping.h b/include/llvm/Transforms/Scalar/SymbolStripping.h index 156e21171f..f9b7c60553 100644 --- a/include/llvm/Transforms/Scalar/SymbolStripping.h +++ b/include/llvm/Transforms/Scalar/SymbolStripping.h @@ -5,35 +5,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_OPT_SYMBOL_STRIPPING_H -#define LLVM_OPT_SYMBOL_STRIPPING_H +#ifndef LLVM_TRANSFORMS_SYMBOL_STRIPPING_H +#define LLVM_TRANSFORMS_SYMBOL_STRIPPING_H -#include "llvm/Pass.h" +class Pass; -struct SymbolStripping : public MethodPass { - // doSymbolStripping - Remove all symbolic information from a method - // - static bool doSymbolStripping(Method *M); - - virtual bool runOnMethod(Method *M) { - return doSymbolStripping(M); - } -}; - -struct FullSymbolStripping : public MethodPass { - - // doStripGlobalSymbols - Remove all symbolic information from all methods - // in a module, and all module level symbols. (method names, etc...) - // - static bool doStripGlobalSymbols(Module *M); - - virtual bool doInitialization(Module *M) { - return doStripGlobalSymbols(M); - } - - virtual bool runOnMethod(Method *M) { - return SymbolStripping::doSymbolStripping(M); - } -}; +Pass *createSymbolStrippingPass(); +Pass *createFullSymbolStrippingPass(); #endif diff --git a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h index e923b92304..4c87b096f8 100644 --- a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h +++ b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h @@ -40,4 +40,8 @@ public: } }; +static inline Pass *createUnifyMethodExitNodesPass() { + return new UnifyMethodExitNodes(); +} + #endif |