diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-14 19:36:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-14 19:36:13 +0000 |
commit | a2d845a3ff0b11ca7de6dd0485aa23edef7d149a (patch) | |
tree | 555c2876cf15805d468e07b77a09fea93f99f63d /include/llvm/Transforms/Utils/SSAUpdater.h | |
parent | f18e4c3ab4735e278427f13e13603ecfa5608f0e (diff) |
Add a new LoadAndStorePromoter class, which implements the general
"promote a bunch of load and stores" logic, allowing the code to
be shared and reused.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123456 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms/Utils/SSAUpdater.h')
-rw-r--r-- | include/llvm/Transforms/Utils/SSAUpdater.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/llvm/Transforms/Utils/SSAUpdater.h b/include/llvm/Transforms/Utils/SSAUpdater.h index e50a6b15df..9e79aca50e 100644 --- a/include/llvm/Transforms/Utils/SSAUpdater.h +++ b/include/llvm/Transforms/Utils/SSAUpdater.h @@ -108,6 +108,38 @@ private: void operator=(const SSAUpdater&); // DO NOT IMPLEMENT SSAUpdater(const SSAUpdater&); // DO NOT IMPLEMENT }; + +/// LoadAndStorePromoter - This little helper class provides a convenient way to +/// promote a collection of loads and stores into SSA Form using the SSAUpdater. +/// This handles complexities that SSAUpdater doesn't, such as multiple loads +/// and stores in one block. +/// +/// Clients of this class are expected to subclass this and implement the +/// virtual methods. +/// +class LoadAndStorePromoter { +public: + LoadAndStorePromoter() {} + virtual ~LoadAndStorePromoter() {} + + /// run - This does the promotion. Insts is a list of loads and stores to + /// promote, and Name is the basename for the PHIs to insert. After this is + /// complete, the loads and stores are removed from the code. + void run(StringRef Name, const SmallVectorImpl<Instruction*> &Insts, + SSAUpdater *SSA = 0); + + + /// Return true if the specified instruction is in the Inst list (which was + /// passed into the run method). Clients should implement this with a more + /// efficient version if possible. + virtual bool isInstInList(Instruction *I, + const SmallVectorImpl<Instruction*> &Insts) const { + for (unsigned i = 0, e = Insts.size(); i != e; ++i) + if (Insts[i] == I) + return true; + return false; + } +}; } // End llvm namespace |