summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/SimpleStructMutation.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-02-26 21:46:54 +0000
committerChris Lattner <sabre@nondot.org>2002-02-26 21:46:54 +0000
commit04805fa29cfed84fd748ff2f97da3968282ee3b1 (patch)
tree7f2bfbac67628f247c8929af9f6a6e352936e7d5 /llvm/lib/Transforms/IPO/SimpleStructMutation.cpp
parentb67f732b8cc2e1817a1318d596a9665d5c5c5057 (diff)
downloadbcm5719-llvm-04805fa29cfed84fd748ff2f97da3968282ee3b1.tar.gz
bcm5719-llvm-04805fa29cfed84fd748ff2f97da3968282ee3b1.zip
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. llvm-svn: 1816
Diffstat (limited to 'llvm/lib/Transforms/IPO/SimpleStructMutation.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/SimpleStructMutation.cpp47
1 files changed, 38 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/IPO/SimpleStructMutation.cpp b/llvm/lib/Transforms/IPO/SimpleStructMutation.cpp
index 8583e3e850d..168f8397366 100644
--- a/llvm/lib/Transforms/IPO/SimpleStructMutation.cpp
+++ b/llvm/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);
}
+
OpenPOWER on IntegriCloud