diff options
author | Chris Lattner <sabre@nondot.org> | 2002-02-05 02:51:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-02-05 02:51:01 +0000 |
commit | 5e5dfa307a6999cef7cba6d1a594f880ab72c043 (patch) | |
tree | f57e9d4dd8fb10d74fa747964759e48f86e7ac9d /include/llvm | |
parent | 0665a5f1f5716a69982f4bcd654e5ace975d0c0a (diff) | |
download | external_llvm-5e5dfa307a6999cef7cba6d1a594f880ab72c043.zip external_llvm-5e5dfa307a6999cef7cba6d1a594f880ab72c043.tar.gz external_llvm-5e5dfa307a6999cef7cba6d1a594f880ab72c043.tar.bz2 |
* Eliminate the LiveVarSet class, making applyTranferFuncForMInst a static
function in the one .cpp file that uses it. Use ValueSet's instead.
* Prepare to delete LiveVarSet.h & LiveVarSet.cpp
* Eliminate the ValueSet class, making all old member functions into global
templates that will eventually be moved to Support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1711 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h | 18 | ||||
-rw-r--r-- | include/llvm/Analysis/LiveVar/LiveVarSet.h | 25 | ||||
-rw-r--r-- | include/llvm/Analysis/LiveVar/ValueSet.h | 52 | ||||
-rw-r--r-- | include/llvm/CodeGen/FunctionLiveVarInfo.h | 18 | ||||
-rw-r--r-- | include/llvm/CodeGen/ValueSet.h | 52 |
5 files changed, 90 insertions, 75 deletions
diff --git a/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h b/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h index 0572374..07cf225 100644 --- a/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h +++ b/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h @@ -68,19 +68,19 @@ static const int DEBUG_LV = 0; #include "llvm/Pass.h" +#include "llvm/Analysis/LiveVar/ValueSet.h" class BBLiveVar; class MachineInstr; -class LiveVarSet; class MethodLiveVarInfo : public MethodPass { // A map between the BasicBlock and BBLiveVar std::map<const BasicBlock *, BBLiveVar *> BB2BBLVMap; // Machine Instr to LiveVarSet Map for providing LVset BEFORE each inst - std::map<const MachineInstr *, const LiveVarSet *> MInst2LVSetBI; + std::map<const MachineInstr *, const ValueSet *> MInst2LVSetBI; // Machine Instr to LiveVarSet Map for providing LVset AFTER each inst - std::map<const MachineInstr *, const LiveVarSet *> MInst2LVSetAI; + std::map<const MachineInstr *, const ValueSet *> MInst2LVSetAI; // --------- private methods ----------------------------------------- @@ -119,18 +119,18 @@ public: // --------- Functions to access analysis results ------------------- // gets OutSet of a BB - const LiveVarSet *getOutSetOfBB(const BasicBlock *BB) const; + const ValueSet *getOutSetOfBB(const BasicBlock *BB) const; // gets InSet of a BB - const LiveVarSet *getInSetOfBB(const BasicBlock *BB) const; + const ValueSet *getInSetOfBB(const BasicBlock *BB) const; // gets the Live var set BEFORE an instruction - const LiveVarSet *getLiveVarSetBeforeMInst(const MachineInstr *MI, - const BasicBlock *BB); + const ValueSet *getLiveVarSetBeforeMInst(const MachineInstr *MI, + const BasicBlock *BB); // gets the Live var set AFTER an instruction - const LiveVarSet *getLiveVarSetAfterMInst(const MachineInstr *MI, - const BasicBlock *BB); + const ValueSet *getLiveVarSetAfterMInst(const MachineInstr *MI, + const BasicBlock *BB); }; #endif diff --git a/include/llvm/Analysis/LiveVar/LiveVarSet.h b/include/llvm/Analysis/LiveVar/LiveVarSet.h index 2174be2..e69de29 100644 --- a/include/llvm/Analysis/LiveVar/LiveVarSet.h +++ b/include/llvm/Analysis/LiveVar/LiveVarSet.h @@ -1,25 +0,0 @@ -/* Title: LiveVarSet.h -*- C++ -*- - Author: Ruchira Sasanka - Date: Jun 30, 01 - Purpose: Contains the class definition of LiveVarSet which is used for - live variable analysis. -*/ - -#ifndef LIVE_VAR_SET_H -#define LIVE_VAR_SET_H - -#include "llvm/Analysis/LiveVar/ValueSet.h" -class MachineInstr; - -struct LiveVarSet : public ValueSet { - - // This function applies a machine instr to a live var set (accepts OutSet) - // and makes necessary changes to it (produces InSet). - // - void applyTranferFuncForMInst(const MachineInstr *MInst); -}; - - -#endif - - diff --git a/include/llvm/Analysis/LiveVar/ValueSet.h b/include/llvm/Analysis/LiveVar/ValueSet.h index 7196284..6c0a21f 100644 --- a/include/llvm/Analysis/LiveVar/ValueSet.h +++ b/include/llvm/Analysis/LiveVar/ValueSet.h @@ -1,10 +1,3 @@ -/* Title: ValueSet.h -*- C++ -*- - Author: Ruchira Sasanka - Date: Jun 30, 01 - Purpose: Contains a mathematical set of Values. LiveVarSet is derived from - this. Contains both class and method definitions. -*/ - #ifndef VALUE_SET_H #define VALUE_SET_H @@ -20,15 +13,42 @@ struct RAV { // Register Allocator Value ostream &operator<<(ostream &out, RAV Val); -//------------------- Class Definition for ValueSet -------------------------- +typedef std::set<const Value*> ValueSet; +void printSet(const ValueSet &S); -struct ValueSet : public std::set<const Value*> { - bool setUnion( const ValueSet *const set1); // for performing set union - void setSubtract( const ValueSet *const set1); // for performing set diff - - void setDifference( const ValueSet *const set1, const ValueSet *const set2); - - void printSet() const; // for printing a live variable set -}; + +// set_union(A, B) - Compute A := A u B, return whether A changed. +// +template <class E> +bool set_union(std::set<E> &S1, const std::set<E> &S2) { + bool Changed = false; + + for (std::set<E>::const_iterator SI = S2.begin(), SE = S2.end(); + SI != SE; ++SI) + if (S1.insert(*SI).second) + Changed = true; + + return Changed; +} + +// set_difference(A, B) - Return A - B +// +template <class E> +std::set<E> set_difference(const std::set<E> &S1, const std::set<E> &S2) { + std::set<E> Result; + for (std::set<E>::const_iterator SI = S1.begin(), SE = S1.end(); + SI != SE; ++SI) + if (S2.find(*SI) == S2.end()) // if the element is not in set2 + Result.insert(*SI); + return Result; +} + +// set_subtract(A, B) - Compute A := A - B +// +template <class E> +void set_subtract(std::set<E> &S1, const std::set<E> &S2) { + for (std::set<E>::const_iterator SI = S2.begin() ; SI != S2.end(); ++SI) + S1.erase(*SI); +} #endif diff --git a/include/llvm/CodeGen/FunctionLiveVarInfo.h b/include/llvm/CodeGen/FunctionLiveVarInfo.h index 0572374..07cf225 100644 --- a/include/llvm/CodeGen/FunctionLiveVarInfo.h +++ b/include/llvm/CodeGen/FunctionLiveVarInfo.h @@ -68,19 +68,19 @@ static const int DEBUG_LV = 0; #include "llvm/Pass.h" +#include "llvm/Analysis/LiveVar/ValueSet.h" class BBLiveVar; class MachineInstr; -class LiveVarSet; class MethodLiveVarInfo : public MethodPass { // A map between the BasicBlock and BBLiveVar std::map<const BasicBlock *, BBLiveVar *> BB2BBLVMap; // Machine Instr to LiveVarSet Map for providing LVset BEFORE each inst - std::map<const MachineInstr *, const LiveVarSet *> MInst2LVSetBI; + std::map<const MachineInstr *, const ValueSet *> MInst2LVSetBI; // Machine Instr to LiveVarSet Map for providing LVset AFTER each inst - std::map<const MachineInstr *, const LiveVarSet *> MInst2LVSetAI; + std::map<const MachineInstr *, const ValueSet *> MInst2LVSetAI; // --------- private methods ----------------------------------------- @@ -119,18 +119,18 @@ public: // --------- Functions to access analysis results ------------------- // gets OutSet of a BB - const LiveVarSet *getOutSetOfBB(const BasicBlock *BB) const; + const ValueSet *getOutSetOfBB(const BasicBlock *BB) const; // gets InSet of a BB - const LiveVarSet *getInSetOfBB(const BasicBlock *BB) const; + const ValueSet *getInSetOfBB(const BasicBlock *BB) const; // gets the Live var set BEFORE an instruction - const LiveVarSet *getLiveVarSetBeforeMInst(const MachineInstr *MI, - const BasicBlock *BB); + const ValueSet *getLiveVarSetBeforeMInst(const MachineInstr *MI, + const BasicBlock *BB); // gets the Live var set AFTER an instruction - const LiveVarSet *getLiveVarSetAfterMInst(const MachineInstr *MI, - const BasicBlock *BB); + const ValueSet *getLiveVarSetAfterMInst(const MachineInstr *MI, + const BasicBlock *BB); }; #endif diff --git a/include/llvm/CodeGen/ValueSet.h b/include/llvm/CodeGen/ValueSet.h index 7196284..6c0a21f 100644 --- a/include/llvm/CodeGen/ValueSet.h +++ b/include/llvm/CodeGen/ValueSet.h @@ -1,10 +1,3 @@ -/* Title: ValueSet.h -*- C++ -*- - Author: Ruchira Sasanka - Date: Jun 30, 01 - Purpose: Contains a mathematical set of Values. LiveVarSet is derived from - this. Contains both class and method definitions. -*/ - #ifndef VALUE_SET_H #define VALUE_SET_H @@ -20,15 +13,42 @@ struct RAV { // Register Allocator Value ostream &operator<<(ostream &out, RAV Val); -//------------------- Class Definition for ValueSet -------------------------- +typedef std::set<const Value*> ValueSet; +void printSet(const ValueSet &S); -struct ValueSet : public std::set<const Value*> { - bool setUnion( const ValueSet *const set1); // for performing set union - void setSubtract( const ValueSet *const set1); // for performing set diff - - void setDifference( const ValueSet *const set1, const ValueSet *const set2); - - void printSet() const; // for printing a live variable set -}; + +// set_union(A, B) - Compute A := A u B, return whether A changed. +// +template <class E> +bool set_union(std::set<E> &S1, const std::set<E> &S2) { + bool Changed = false; + + for (std::set<E>::const_iterator SI = S2.begin(), SE = S2.end(); + SI != SE; ++SI) + if (S1.insert(*SI).second) + Changed = true; + + return Changed; +} + +// set_difference(A, B) - Return A - B +// +template <class E> +std::set<E> set_difference(const std::set<E> &S1, const std::set<E> &S2) { + std::set<E> Result; + for (std::set<E>::const_iterator SI = S1.begin(), SE = S1.end(); + SI != SE; ++SI) + if (S2.find(*SI) == S2.end()) // if the element is not in set2 + Result.insert(*SI); + return Result; +} + +// set_subtract(A, B) - Compute A := A - B +// +template <class E> +void set_subtract(std::set<E> &S1, const std::set<E> &S2) { + for (std::set<E>::const_iterator SI = S2.begin() ; SI != S2.end(); ++SI) + S1.erase(*SI); +} #endif |