From bd0ef77cde9c9e82f2b4ad33e4982c46274d6540 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 26 Feb 2002 21:46:54 +0000 Subject: 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 --- lib/Transforms/IPO/SimpleStructMutation.cpp | 47 +++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'lib/Transforms/IPO/SimpleStructMutation.cpp') diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp index 8583e3e850..168f839736 100644 --- a/lib/Transforms/IPO/SimpleStructMutation.cpp +++ b/lib/Transforms/IPO/SimpleStructMutation.cpp @@ -19,6 +19,37 @@ using std::pair; #include "llvm/Assembly/Writer.h" +namespace { + 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) { + Required.push_back(FindUsedTypes::ID); + Required.push_back(FindUnsafePointerTypes::ID); + MutateStructTypes::getAnalysisUsageInfo(Required, Destroyed, Provided); + } + + private: + TransformsType getTransforms(Module *M, enum Transform); + }; +} // end anonymous namespace + + // PruneTypes - Given a type Ty, make sure that neither it, or one of its // subtypes, occur in TypesToModify. @@ -87,6 +118,7 @@ static inline void GetTransformation(const StructType *ST, } } + SimpleStructMutation::TransformsType SimpleStructMutation::getTransforms(Module *M, enum Transform XForm) { // We need to know which types to modify, and which types we CAN'T modify @@ -137,13 +169,10 @@ SimpleStructMutation::TransformsType } -// getAnalysisUsageInfo - This function needs the results of the -// FindUsedTypes and FindUnsafePointerTypes analysis passes... -// -void SimpleStructMutation::getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided){ - Required.push_back(FindUsedTypes::ID); - Required.push_back(FindUnsafePointerTypes::ID); - MutateStructTypes::getAnalysisUsageInfo(Required, Destroyed, Provided); +Pass *createSwapElementsPass() { + return new SimpleStructMutation(SimpleStructMutation::SwapElements); +} +Pass *createSortElementsPass() { + return new SimpleStructMutation(SimpleStructMutation::SortElements); } + -- cgit v1.2.3-18-g5258