* Eliminate the LiveVarSet class, making applyTranferFuncForMInst a static
authorChris Lattner <sabre@nondot.org>
Tue, 5 Feb 2002 02:51:01 +0000 (02:51 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 5 Feb 2002 02:51:01 +0000 (02:51 +0000)
  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

23 files changed:
include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h
include/llvm/Analysis/LiveVar/LiveVarSet.h
include/llvm/Analysis/LiveVar/ValueSet.h
include/llvm/CodeGen/FunctionLiveVarInfo.h
include/llvm/CodeGen/ValueSet.h
lib/Analysis/LiveVar/BBLiveVar.cpp
lib/Analysis/LiveVar/BBLiveVar.h
lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
lib/Analysis/LiveVar/LiveVarSet.cpp
lib/Analysis/LiveVar/ValueSet.cpp
lib/CodeGen/InstrSched/InstrScheduling.cpp
lib/CodeGen/InstrSched/SchedPriorities.cpp
lib/CodeGen/RegAlloc/LiveRangeInfo.h
lib/CodeGen/RegAlloc/PhyRegAlloc.h
lib/Target/SparcV9/InstrSched/InstrScheduling.cpp
lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
lib/Target/SparcV9/LiveVar/BBLiveVar.cpp
lib/Target/SparcV9/LiveVar/BBLiveVar.h
lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
lib/Target/SparcV9/LiveVar/LiveVarSet.cpp
lib/Target/SparcV9/LiveVar/ValueSet.cpp
lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h
lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h

index 05723748d8af6fbe3df97d03fac12edd70ad1616..07cf225b2cac2389679a3ce35900113c511f50b3 100644 (file)
 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
index 2174be26fb7301b12642dac5934559b985cb0ca8..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -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
-
-
index 7196284964affea6ec077a688d6560f9703083d2..6c0a21f9095e9572ccf55d486d1a63185d86fdc0 100644 (file)
@@ -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
index 05723748d8af6fbe3df97d03fac12edd70ad1616..07cf225b2cac2389679a3ce35900113c511f50b3 100644 (file)
 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
index 7196284964affea6ec077a688d6560f9703083d2..6c0a21f9095e9572ccf55d486d1a63185d86fdc0 100644 (file)
@@ -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
index 81bbd387564b00aa03a77fba76bd410c7ef8dd3d..bf4af29ff0e8cae241f7338898aad5a7fc88fb43 100644 (file)
@@ -126,9 +126,8 @@ bool BBLiveVar::applyTransferFunc() {
   // IMPORTANT: caller should check whether the OutSet changed 
   //           (else no point in calling)
 
-  LiveVarSet OutMinusDef;     // set to hold (Out[B] - Def[B])
-  OutMinusDef.setDifference(&OutSet, &DefSet);
-  InSetChanged = InSet.setUnion(&OutMinusDef);
+  ValueSet OutMinusDef = set_difference(OutSet, DefSet);
+  InSetChanged = set_union(InSet, OutMinusDef);
  
   OutSetChanged = false;      // no change to OutSet since transf func applied
   return InSetChanged;
@@ -139,12 +138,12 @@ bool BBLiveVar::applyTransferFunc() {
 // calculates Out set using In sets of the predecessors
 //-----------------------------------------------------------------------------
 
-bool BBLiveVar::setPropagate(LiveVarSet *OutSet, const LiveVarSet *InSet, 
+bool BBLiveVar::setPropagate(ValueSet *OutSet, const ValueSet *InSet, 
                              const BasicBlock *PredBB) {
   bool Changed = false;
 
   // for all all elements in InSet
-  for (LiveVarSet::const_iterator InIt = InSet->begin(), InE = InSet->end();
+  for (ValueSet::const_iterator InIt = InSet->begin(), InE = InSet->end();
        InIt != InE; ++InIt) {  
     const BasicBlock *PredBBOfPhiArg = PhiArgMap[*InIt];
 
@@ -194,14 +193,14 @@ bool BBLiveVar::applyFlowFunc(std::map<const BasicBlock *, BBLiveVar *> &LVMap){
 // ----------------- Methods For Debugging (Printing) -----------------
 
 void BBLiveVar::printAllSets() const {
-  cerr << "  Defs: ";   DefSet.printSet();  cerr << "\n";
-  cerr << "  In: ";   InSet.printSet();  cerr << "\n";
-  cerr << "  Out: ";   OutSet.printSet();  cerr << "\n";
+  cerr << "  Defs: "; printSet(DefSet);  cerr << "\n";
+  cerr << "  In: ";  printSet(InSet);  cerr << "\n";
+  cerr << "  Out: "; printSet(OutSet);  cerr << "\n";
 }
 
 void BBLiveVar::printInOutSets() const {
-  cerr << "  In: ";   InSet.printSet();  cerr << "\n";
-  cerr << "  Out: ";  OutSet.printSet();  cerr << "\n";
+  cerr << "  In: ";   printSet(InSet);  cerr << "\n";
+  cerr << "  Out: ";  printSet(OutSet);  cerr << "\n";
 }
 
 
index d5c4ccaf7ba16cb6257a558d13506cfc11fb7878..1fc91f1330021bb1e00b50174e942f67400df98d 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef LIVE_VAR_BB_H
 #define LIVE_VAR_BB_H
 
-#include "llvm/Analysis/LiveVar/LiveVarSet.h"
+#include "llvm/Analysis/LiveVar/ValueSet.h"
 #include <map>
 class Method;
 class BasicBlock;
@@ -17,8 +17,8 @@ class BBLiveVar {
   const BasicBlock *BB;         // pointer to BasicBlock
   unsigned POID;                // Post-Order ID
 
-  LiveVarSet DefSet;            // Def set for LV analysis
-  LiveVarSet InSet, OutSet;     // In & Out for LV analysis
+  ValueSet DefSet;            // Def set for LV analysis
+  ValueSet InSet, OutSet;     // In & Out for LV analysis
   bool InSetChanged, OutSetChanged;   // set if the InSet/OutSet is modified
 
                                 // map that contains phi args->BB they came
@@ -26,8 +26,8 @@ class BBLiveVar {
   std::map<const Value *, const BasicBlock *> PhiArgMap;  
 
   // method to propogate an InSet to OutSet of a predecessor
-  bool setPropagate(LiveVarSet *OutSetOfPred, 
-                    const LiveVarSet *InSetOfThisBB,
+  bool setPropagate(ValueSet *OutSetOfPred, 
+                    const ValueSet *InSetOfThisBB,
                     const BasicBlock *PredBB);
 
   // To add an operand which is a def
@@ -50,8 +50,8 @@ class BBLiveVar {
   // calculates Out set using In sets of the predecessors
   bool applyFlowFunc(std::map<const BasicBlock *, BBLiveVar *> &LVMap);    
 
-  inline const LiveVarSet *getOutSet() const { return &OutSet; }
-  inline const LiveVarSet  *getInSet() const { return &InSet; }
+  inline const ValueSet *getOutSet() const { return &OutSet; }
+  inline const ValueSet  *getInSet() const { return &InSet; }
 
   void printAllSets() const;      // for printing Def/In/Out sets
   void printInOutSets() const;    // for printing In/Out sets
index cfe0fe4ba02fd04c45d83034399439cf06e75c62..98d39ec2a6e28cdd6b1656ad3fc8e5ed5fd723ae 100644 (file)
@@ -1,13 +1,9 @@
-/* Title:   MethodLiveVarInfo.cpp
-   Author:  Ruchira Sasanka
-   Date:    Jun 30, 01
-   Purpose: 
-
-   This is the interface for live variable info of a method that is required 
-   by any other part of the compiler.
-
-*/
-
+//===-- MethodLiveVarInfo.cpp - Live Variable Analysis for a Method -------===//
+//
+// This is the interface to method level live variable information that is
+// provided by live variable analysis.
+//
+//===----------------------------------------------------------------------===//
 
 #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
 #include "BBLiveVar.h"
@@ -23,12 +19,12 @@ AnalysisID MethodLiveVarInfo::ID(AnalysisID::create<MethodLiveVarInfo>());
 //-----------------------------------------------------------------------------
 
 // gets OutSet of a BB
-const LiveVarSet *MethodLiveVarInfo::getOutSetOfBB(const BasicBlock *BB) const {
+const ValueSet *MethodLiveVarInfo::getOutSetOfBB(const BasicBlock *BB) const {
   return BB2BBLVMap.find(BB)->second->getOutSet();
 }
 
 // gets InSet of a BB
-const LiveVarSet *MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const {
+const ValueSet *MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const {
   return BB2BBLVMap.find(BB)->second->getInSet();
 }
 
@@ -125,16 +121,16 @@ void MethodLiveVarInfo::releaseMemory() {
 
   BB2BBLVMap.clear();
 
-  // Then delete all objects of type LiveVarSet created in calcLiveVarSetsForBB
+  // Then delete all objects of type ValueSet created in calcLiveVarSetsForBB
   // and entered into  MInst2LVSetBI and  MInst2LVSetAI (these are caches
-  // to return LiveVarSet's before/after a machine instruction quickly). It
-  // is sufficient to free up all LiveVarSet using only one cache since 
+  // to return ValueSet's before/after a machine instruction quickly). It
+  // is sufficient to free up all ValueSet using only one cache since 
   // both caches refer to the same sets
   //
-  for (std::map<const MachineInstr*, const LiveVarSet*>::iterator
+  for (std::map<const MachineInstr*, const ValueSet*>::iterator
          MI = MInst2LVSetBI.begin(),
          ME = MInst2LVSetBI.end(); MI != ME; ++MI)
-    delete MI->second;           // delete all LiveVarSets in  MInst2LVSetBI
+    delete MI->second;           // delete all ValueSets in  MInst2LVSetBI
 
   MInst2LVSetBI.clear();
   MInst2LVSetAI.clear();
@@ -158,10 +154,10 @@ void MethodLiveVarInfo::releaseMemory() {
 // Gives live variable information before a machine instruction
 //-----------------------------------------------------------------------------
 
-const LiveVarSet *
+const ValueSet *
 MethodLiveVarInfo::getLiveVarSetBeforeMInst(const MachineInstr *MInst,
                                            const BasicBlock *BB) {
-  if (const LiveVarSet *LVSet = MInst2LVSetBI[MInst]) {
+  if (const ValueSet *LVSet = MInst2LVSetBI[MInst]) {
     return LVSet;                      // if found, just return the set
   } else { 
     calcLiveVarSetsForBB(BB);          // else, calc for all instrs in BB
@@ -173,11 +169,11 @@ MethodLiveVarInfo::getLiveVarSetBeforeMInst(const MachineInstr *MInst,
 //-----------------------------------------------------------------------------
 // Gives live variable information after a machine instruction
 //-----------------------------------------------------------------------------
-const LiveVarSet * 
+const ValueSet * 
 MethodLiveVarInfo::getLiveVarSetAfterMInst(const MachineInstr *MI,
                                            const BasicBlock *BB) {
 
-  if (const LiveVarSet *LVSet = MInst2LVSetAI[MI]) {
+  if (const ValueSet *LVSet = MInst2LVSetAI[MI]) {
     return LVSet;                       // if found, just return the set
   } else { 
     calcLiveVarSetsForBB(BB);           // else, calc for all instrs in BB
@@ -185,7 +181,37 @@ MethodLiveVarInfo::getLiveVarSetAfterMInst(const MachineInstr *MI,
   }
 }
 
+// This function applies a machine instr to a live var set (accepts OutSet) and
+// makes necessary changes to it (produces InSet). Note that two for loops are
+// used to first kill all defs and then to add all uses. This is because there
+// can be instructions like Val = Val + 1 since we allow multipe defs to a 
+// machine instruction operand.
+//
+static void applyTranferFuncForMInst(ValueSet &LVS, const MachineInstr *MInst) {
+  for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
+    if (OpI.isDef())           // kill only if this operand is a def
+      LVS.insert(*OpI);        // this definition kills any uses
+  }
+
+  // do for implicit operands as well
+  for (unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
+    if (MInst->implicitRefIsDefined(i))
+      LVS.erase(MInst->getImplicitRef(i));
+  }
 
+  for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
+    if (isa<BasicBlock>(*OpI)) continue; // don't process labels
+    
+    if (!OpI.isDef())      // add only if this operand is a use
+      LVS.insert(*OpI);            // An operand is a use - so add to use set
+  }
+
+  // do for implicit operands as well
+  for (unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
+    if (!MInst->implicitRefIsDefined(i))
+      LVS.insert(MInst->getImplicitRef(i));
+  }
+}
 
 //-----------------------------------------------------------------------------
 // This method calculates the live variable information for all the 
@@ -196,9 +222,9 @@ MethodLiveVarInfo::getLiveVarSetAfterMInst(const MachineInstr *MI,
 void MethodLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
   const MachineCodeForBasicBlock &MIVec = BB->getMachineInstrVec();
 
-  LiveVarSet *CurSet = new LiveVarSet();
-  const LiveVarSet *SetAI = getOutSetOfBB(BB); // init SetAI with OutSet
-  CurSet->setUnion(SetAI);                     // CurSet now contains OutSet
+  ValueSet *CurSet = new ValueSet();
+  const ValueSet *SetAI = getOutSetOfBB(BB); // init SetAI with OutSet
+  set_union(*CurSet, *SetAI);                  // CurSet now contains OutSet
 
   // iterate over all the machine instructions in BB
   for (MachineCodeForBasicBlock::const_reverse_iterator MII = MIVec.rbegin(),
@@ -208,9 +234,9 @@ void MethodLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
 
     MInst2LVSetAI[MI] = SetAI;                 // record in After Inst map
 
-    CurSet->applyTranferFuncForMInst(MI);      // apply the transfer Func
-    LiveVarSet *NewSet = new LiveVarSet();     // create a new set and
-    NewSet->setUnion(CurSet);                  // copy the set after T/F to it
+    applyTranferFuncForMInst(*CurSet, MI);     // apply the transfer Func
+    ValueSet *NewSet = new ValueSet();     // create a new set and
+    set_union(*NewSet, *CurSet);               // copy the set after T/F to it
  
     MInst2LVSetBI[MI] = NewSet;                // record in Before Inst map
 
index 9243d05981742a0ec3aff4becfe9af0d76ba6714..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,37 +0,0 @@
-#include "llvm/Analysis/LiveVar/LiveVarSet.h"
-#include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/Type.h"
-
-// This function applies a machine instr to a live var set (accepts OutSet) and
-// makes necessary changes to it (produces InSet). Note that two for loops are
-// used to first kill all defs and then to add all uses. This is because there
-// can be instructions like Val = Val + 1 since we allow multipe defs to a 
-// machine instruction operand.
-
-
-void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *MInst) {
-  for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
-    if (OpI.isDef())      // kill only if this operand is a def
-      insert(*OpI);        // this definition kills any uses
-  }
-
-  // do for implicit operands as well
-  for ( unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
-    if (MInst->implicitRefIsDefined(i))
-      erase(MInst->getImplicitRef(i));
-  }
-
-
-  for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
-    if ((*OpI)->getType()->isLabelType()) continue; // don't process labels
-    
-    if (!OpI.isDef())      // add only if this operand is a use
-      insert(*OpI);            // An operand is a use - so add to use set
-  }
-
-  // do for implicit operands as well
-  for (unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
-    if (!MInst->implicitRefIsDefined(i))
-      insert(MInst->getImplicitRef(i));
-  }
-}
index 431ccc6222982dac3a5c12a43ca02e66ab431ec3..88dd25a0331cfdd8c97ee9b2b17eb59befbb47f1 100644 (file)
@@ -15,28 +15,8 @@ ostream &operator<<(ostream &O, RAV V) { // func to print a Value
     return O << v  << " ";
 }
 
-bool ValueSet::setUnion( const ValueSet *S) {   
-  bool Changed = false;
-
-  for (const_iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI)
-    if (insert(*SI).second)
-      Changed = true;
-
-  return Changed;
-}
-
-void ValueSet::setDifference(const ValueSet *S1, const ValueSet *S2) {
-  for (const_iterator SI = S1->begin(), SE = S1->end() ; SI != SE; ++SI)
-    if (S2->find(*SI) == S2->end())       // if the element is not in set2
-      insert(*SI);
-}
-
-void ValueSet::setSubtract(const ValueSet *S) { 
-  for (const_iterator SI = S->begin() ; SI != S->end(); ++SI)  
-    erase(*SI);
-}
-
-void ValueSet::printSet() const {
-  for (const_iterator I = begin(), E = end(); I != E; ++I)
+void printSet(const ValueSet &S) {
+  for (ValueSet::const_iterator I = S.begin(), E = S.end(); I != E; ++I)
     std::cerr << RAV(*I);
 }
+
index d625a7b719c6422f00c9ce8fb5d1c5d2692803ae..6e6d14c7c892e1ec94653b13bd6a0712c6fc492d 100644 (file)
@@ -39,7 +39,6 @@ cl::Enum<enum SchedDebugLevel_t> SchedDebugLevel("dsched", cl::NoFlags,
 
 class InstrSchedule;
 class SchedulingManager;
-class DelaySlotInfo;
 
 
 //----------------------------------------------------------------------
index e06f84cd670c0da534ac0ff54e8b65ca7d0b16c5..74f659993e2a9d5efc8a47ac5f1714bb63bda3ec 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "SchedPriorities.h"
 #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
-#include "llvm/Analysis/LiveVar/LiveVarSet.h"
+#include "llvm/Analysis/LiveVar/ValueSet.h"
 #include "Support/PostOrderIterator.h"
 #include <iostream>
 using std::cerr;
@@ -265,8 +265,7 @@ SchedPriorities::findSetWithMaxDelay(std::vector<candIndex>& mcands,
 
 bool
 SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
-                                      const SchedGraphNode* graphNode)
-{
+                                      const SchedGraphNode* graphNode) {
   const MachineInstr* minstr = graphNode->getMachineInstr();
   
   std::hash_map<const MachineInstr*, bool>::const_iterator
@@ -277,15 +276,14 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
   // else check if instruction is a last use and save it in the hash_map
   bool hasLastUse = false;
   const BasicBlock* bb = graphNode->getBB();
-  const LiveVarSet* liveVars =
+  const ValueSet *liveVars =
     methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
   
   for (MachineInstr::val_const_op_iterator vo(minstr); ! vo.done(); ++vo)
-    if (liveVars->find(*vo) == liveVars->end())
-      {
-       hasLastUse = true;
-       break;
-      }
+    if (liveVars->find(*vo) == liveVars->end()) {
+      hasLastUse = true;
+      break;
+    }
   
   lastUseMap[minstr] = hasLastUse;
   return hasLastUse;
index 09aca44f30c6297f02d2e888083eb8667a3ce073..48e81c10682dba30183a6563ad09bed800b31559 100644 (file)
 #define LIVE_RANGE_INFO_H
 
 #include "Support/HashExtras.h"
+#include "llvm/Analysis/LiveVar/ValueSet.h"
 
 class LiveRange;
 class MachineInstr;
-class LiveVarSet;
 class RegClass;
 class MachineRegInfo;
 class TargetMachine;
@@ -60,17 +60,15 @@ class LiveRangeInfo {
 
   void unionAndUpdateLRs(LiveRange *L1, LiveRange *L2);
 
-  void addInterference(const Instruction *const Inst, 
-                      const LiveVarSet *const LVSet);
+  void addInterference(const Instruction *Inst, const ValueSet *LVSet);
   
   void suggestRegs4CallRets();
 
   const Method* getMethod() { return Meth; }
 
-
 public:
   
-  LiveRangeInfo(const Method *const M, 
+  LiveRangeInfo(const Method *M, 
                const TargetMachine& tm,
                std::vector<RegClass *> & RCList);
 
index de8d7938388e5f4957d7ccefb5d213c77b7b68e5..f3aef1cdc2fc28c533b24d32f0efe02ee9524575 100644 (file)
@@ -98,15 +98,15 @@ private:
 
   //------- ------------------ private methods---------------------------------
 
-  void addInterference(const Value *const Def, const LiveVarSet *const LVSet, 
-                      const bool isCallInst);
+  void addInterference(const Value *Def, const ValueSet *LVSet, 
+                      bool isCallInst);
 
   void addInterferencesForArgs();
   void createIGNodeListsAndIGs();
   void buildInterferenceGraphs();
 
   void setCallInterferences(const MachineInstr *MInst, 
-                           const LiveVarSet *const LVSetAft );
+                           const ValueSet *LVSetAft );
 
   void move2DelayedInstr(const MachineInstr *OrigMI, 
                         const MachineInstr *DelayedMI );
@@ -131,13 +131,13 @@ private:
   friend class UltraSparcRegInfo;
 
 
-  int getUsableUniRegAtMI(RegClass *RC,  const int RegType, 
+  int getUsableUniRegAtMI(RegClass *RC, int RegType, 
                          const MachineInstr *MInst,
-                         const LiveVarSet *LVSetBef, MachineInstr *MIBef, 
+                         const ValueSet *LVSetBef, MachineInstr *MIBef, 
                          MachineInstr *MIAft );
 
   int getUnusedUniRegAtMI(RegClass *RC,  const MachineInstr *MInst, 
-                      const LiveVarSet *LVSetBef);
+                      const ValueSet *LVSetBef);
 
   void setRelRegsUsedByThisInst(RegClass *RC, const MachineInstr *MInst );
   int getUniRegNotUsedByThisInst(RegClass *RC, const MachineInstr *MInst);
index d625a7b719c6422f00c9ce8fb5d1c5d2692803ae..6e6d14c7c892e1ec94653b13bd6a0712c6fc492d 100644 (file)
@@ -39,7 +39,6 @@ cl::Enum<enum SchedDebugLevel_t> SchedDebugLevel("dsched", cl::NoFlags,
 
 class InstrSchedule;
 class SchedulingManager;
-class DelaySlotInfo;
 
 
 //----------------------------------------------------------------------
index e06f84cd670c0da534ac0ff54e8b65ca7d0b16c5..74f659993e2a9d5efc8a47ac5f1714bb63bda3ec 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "SchedPriorities.h"
 #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
-#include "llvm/Analysis/LiveVar/LiveVarSet.h"
+#include "llvm/Analysis/LiveVar/ValueSet.h"
 #include "Support/PostOrderIterator.h"
 #include <iostream>
 using std::cerr;
@@ -265,8 +265,7 @@ SchedPriorities::findSetWithMaxDelay(std::vector<candIndex>& mcands,
 
 bool
 SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
-                                      const SchedGraphNode* graphNode)
-{
+                                      const SchedGraphNode* graphNode) {
   const MachineInstr* minstr = graphNode->getMachineInstr();
   
   std::hash_map<const MachineInstr*, bool>::const_iterator
@@ -277,15 +276,14 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
   // else check if instruction is a last use and save it in the hash_map
   bool hasLastUse = false;
   const BasicBlock* bb = graphNode->getBB();
-  const LiveVarSet* liveVars =
+  const ValueSet *liveVars =
     methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
   
   for (MachineInstr::val_const_op_iterator vo(minstr); ! vo.done(); ++vo)
-    if (liveVars->find(*vo) == liveVars->end())
-      {
-       hasLastUse = true;
-       break;
-      }
+    if (liveVars->find(*vo) == liveVars->end()) {
+      hasLastUse = true;
+      break;
+    }
   
   lastUseMap[minstr] = hasLastUse;
   return hasLastUse;
index 81bbd387564b00aa03a77fba76bd410c7ef8dd3d..bf4af29ff0e8cae241f7338898aad5a7fc88fb43 100644 (file)
@@ -126,9 +126,8 @@ bool BBLiveVar::applyTransferFunc() {
   // IMPORTANT: caller should check whether the OutSet changed 
   //           (else no point in calling)
 
-  LiveVarSet OutMinusDef;     // set to hold (Out[B] - Def[B])
-  OutMinusDef.setDifference(&OutSet, &DefSet);
-  InSetChanged = InSet.setUnion(&OutMinusDef);
+  ValueSet OutMinusDef = set_difference(OutSet, DefSet);
+  InSetChanged = set_union(InSet, OutMinusDef);
  
   OutSetChanged = false;      // no change to OutSet since transf func applied
   return InSetChanged;
@@ -139,12 +138,12 @@ bool BBLiveVar::applyTransferFunc() {
 // calculates Out set using In sets of the predecessors
 //-----------------------------------------------------------------------------
 
-bool BBLiveVar::setPropagate(LiveVarSet *OutSet, const LiveVarSet *InSet, 
+bool BBLiveVar::setPropagate(ValueSet *OutSet, const ValueSet *InSet, 
                              const BasicBlock *PredBB) {
   bool Changed = false;
 
   // for all all elements in InSet
-  for (LiveVarSet::const_iterator InIt = InSet->begin(), InE = InSet->end();
+  for (ValueSet::const_iterator InIt = InSet->begin(), InE = InSet->end();
        InIt != InE; ++InIt) {  
     const BasicBlock *PredBBOfPhiArg = PhiArgMap[*InIt];
 
@@ -194,14 +193,14 @@ bool BBLiveVar::applyFlowFunc(std::map<const BasicBlock *, BBLiveVar *> &LVMap){
 // ----------------- Methods For Debugging (Printing) -----------------
 
 void BBLiveVar::printAllSets() const {
-  cerr << "  Defs: ";   DefSet.printSet();  cerr << "\n";
-  cerr << "  In: ";   InSet.printSet();  cerr << "\n";
-  cerr << "  Out: ";   OutSet.printSet();  cerr << "\n";
+  cerr << "  Defs: "; printSet(DefSet);  cerr << "\n";
+  cerr << "  In: ";  printSet(InSet);  cerr << "\n";
+  cerr << "  Out: "; printSet(OutSet);  cerr << "\n";
 }
 
 void BBLiveVar::printInOutSets() const {
-  cerr << "  In: ";   InSet.printSet();  cerr << "\n";
-  cerr << "  Out: ";  OutSet.printSet();  cerr << "\n";
+  cerr << "  In: ";   printSet(InSet);  cerr << "\n";
+  cerr << "  Out: ";  printSet(OutSet);  cerr << "\n";
 }
 
 
index d5c4ccaf7ba16cb6257a558d13506cfc11fb7878..1fc91f1330021bb1e00b50174e942f67400df98d 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef LIVE_VAR_BB_H
 #define LIVE_VAR_BB_H
 
-#include "llvm/Analysis/LiveVar/LiveVarSet.h"
+#include "llvm/Analysis/LiveVar/ValueSet.h"
 #include <map>
 class Method;
 class BasicBlock;
@@ -17,8 +17,8 @@ class BBLiveVar {
   const BasicBlock *BB;         // pointer to BasicBlock
   unsigned POID;                // Post-Order ID
 
-  LiveVarSet DefSet;            // Def set for LV analysis
-  LiveVarSet InSet, OutSet;     // In & Out for LV analysis
+  ValueSet DefSet;            // Def set for LV analysis
+  ValueSet InSet, OutSet;     // In & Out for LV analysis
   bool InSetChanged, OutSetChanged;   // set if the InSet/OutSet is modified
 
                                 // map that contains phi args->BB they came
@@ -26,8 +26,8 @@ class BBLiveVar {
   std::map<const Value *, const BasicBlock *> PhiArgMap;  
 
   // method to propogate an InSet to OutSet of a predecessor
-  bool setPropagate(LiveVarSet *OutSetOfPred, 
-                    const LiveVarSet *InSetOfThisBB,
+  bool setPropagate(ValueSet *OutSetOfPred, 
+                    const ValueSet *InSetOfThisBB,
                     const BasicBlock *PredBB);
 
   // To add an operand which is a def
@@ -50,8 +50,8 @@ class BBLiveVar {
   // calculates Out set using In sets of the predecessors
   bool applyFlowFunc(std::map<const BasicBlock *, BBLiveVar *> &LVMap);    
 
-  inline const LiveVarSet *getOutSet() const { return &OutSet; }
-  inline const LiveVarSet  *getInSet() const { return &InSet; }
+  inline const ValueSet *getOutSet() const { return &OutSet; }
+  inline const ValueSet  *getInSet() const { return &InSet; }
 
   void printAllSets() const;      // for printing Def/In/Out sets
   void printInOutSets() const;    // for printing In/Out sets
index cfe0fe4ba02fd04c45d83034399439cf06e75c62..98d39ec2a6e28cdd6b1656ad3fc8e5ed5fd723ae 100644 (file)
@@ -1,13 +1,9 @@
-/* Title:   MethodLiveVarInfo.cpp
-   Author:  Ruchira Sasanka
-   Date:    Jun 30, 01
-   Purpose: 
-
-   This is the interface for live variable info of a method that is required 
-   by any other part of the compiler.
-
-*/
-
+//===-- MethodLiveVarInfo.cpp - Live Variable Analysis for a Method -------===//
+//
+// This is the interface to method level live variable information that is
+// provided by live variable analysis.
+//
+//===----------------------------------------------------------------------===//
 
 #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
 #include "BBLiveVar.h"
@@ -23,12 +19,12 @@ AnalysisID MethodLiveVarInfo::ID(AnalysisID::create<MethodLiveVarInfo>());
 //-----------------------------------------------------------------------------
 
 // gets OutSet of a BB
-const LiveVarSet *MethodLiveVarInfo::getOutSetOfBB(const BasicBlock *BB) const {
+const ValueSet *MethodLiveVarInfo::getOutSetOfBB(const BasicBlock *BB) const {
   return BB2BBLVMap.find(BB)->second->getOutSet();
 }
 
 // gets InSet of a BB
-const LiveVarSet *MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const {
+const ValueSet *MethodLiveVarInfo::getInSetOfBB(const BasicBlock *BB) const {
   return BB2BBLVMap.find(BB)->second->getInSet();
 }
 
@@ -125,16 +121,16 @@ void MethodLiveVarInfo::releaseMemory() {
 
   BB2BBLVMap.clear();
 
-  // Then delete all objects of type LiveVarSet created in calcLiveVarSetsForBB
+  // Then delete all objects of type ValueSet created in calcLiveVarSetsForBB
   // and entered into  MInst2LVSetBI and  MInst2LVSetAI (these are caches
-  // to return LiveVarSet's before/after a machine instruction quickly). It
-  // is sufficient to free up all LiveVarSet using only one cache since 
+  // to return ValueSet's before/after a machine instruction quickly). It
+  // is sufficient to free up all ValueSet using only one cache since 
   // both caches refer to the same sets
   //
-  for (std::map<const MachineInstr*, const LiveVarSet*>::iterator
+  for (std::map<const MachineInstr*, const ValueSet*>::iterator
          MI = MInst2LVSetBI.begin(),
          ME = MInst2LVSetBI.end(); MI != ME; ++MI)
-    delete MI->second;           // delete all LiveVarSets in  MInst2LVSetBI
+    delete MI->second;           // delete all ValueSets in  MInst2LVSetBI
 
   MInst2LVSetBI.clear();
   MInst2LVSetAI.clear();
@@ -158,10 +154,10 @@ void MethodLiveVarInfo::releaseMemory() {
 // Gives live variable information before a machine instruction
 //-----------------------------------------------------------------------------
 
-const LiveVarSet *
+const ValueSet *
 MethodLiveVarInfo::getLiveVarSetBeforeMInst(const MachineInstr *MInst,
                                            const BasicBlock *BB) {
-  if (const LiveVarSet *LVSet = MInst2LVSetBI[MInst]) {
+  if (const ValueSet *LVSet = MInst2LVSetBI[MInst]) {
     return LVSet;                      // if found, just return the set
   } else { 
     calcLiveVarSetsForBB(BB);          // else, calc for all instrs in BB
@@ -173,11 +169,11 @@ MethodLiveVarInfo::getLiveVarSetBeforeMInst(const MachineInstr *MInst,
 //-----------------------------------------------------------------------------
 // Gives live variable information after a machine instruction
 //-----------------------------------------------------------------------------
-const LiveVarSet * 
+const ValueSet * 
 MethodLiveVarInfo::getLiveVarSetAfterMInst(const MachineInstr *MI,
                                            const BasicBlock *BB) {
 
-  if (const LiveVarSet *LVSet = MInst2LVSetAI[MI]) {
+  if (const ValueSet *LVSet = MInst2LVSetAI[MI]) {
     return LVSet;                       // if found, just return the set
   } else { 
     calcLiveVarSetsForBB(BB);           // else, calc for all instrs in BB
@@ -185,7 +181,37 @@ MethodLiveVarInfo::getLiveVarSetAfterMInst(const MachineInstr *MI,
   }
 }
 
+// This function applies a machine instr to a live var set (accepts OutSet) and
+// makes necessary changes to it (produces InSet). Note that two for loops are
+// used to first kill all defs and then to add all uses. This is because there
+// can be instructions like Val = Val + 1 since we allow multipe defs to a 
+// machine instruction operand.
+//
+static void applyTranferFuncForMInst(ValueSet &LVS, const MachineInstr *MInst) {
+  for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
+    if (OpI.isDef())           // kill only if this operand is a def
+      LVS.insert(*OpI);        // this definition kills any uses
+  }
+
+  // do for implicit operands as well
+  for (unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
+    if (MInst->implicitRefIsDefined(i))
+      LVS.erase(MInst->getImplicitRef(i));
+  }
 
+  for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
+    if (isa<BasicBlock>(*OpI)) continue; // don't process labels
+    
+    if (!OpI.isDef())      // add only if this operand is a use
+      LVS.insert(*OpI);            // An operand is a use - so add to use set
+  }
+
+  // do for implicit operands as well
+  for (unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
+    if (!MInst->implicitRefIsDefined(i))
+      LVS.insert(MInst->getImplicitRef(i));
+  }
+}
 
 //-----------------------------------------------------------------------------
 // This method calculates the live variable information for all the 
@@ -196,9 +222,9 @@ MethodLiveVarInfo::getLiveVarSetAfterMInst(const MachineInstr *MI,
 void MethodLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
   const MachineCodeForBasicBlock &MIVec = BB->getMachineInstrVec();
 
-  LiveVarSet *CurSet = new LiveVarSet();
-  const LiveVarSet *SetAI = getOutSetOfBB(BB); // init SetAI with OutSet
-  CurSet->setUnion(SetAI);                     // CurSet now contains OutSet
+  ValueSet *CurSet = new ValueSet();
+  const ValueSet *SetAI = getOutSetOfBB(BB); // init SetAI with OutSet
+  set_union(*CurSet, *SetAI);                  // CurSet now contains OutSet
 
   // iterate over all the machine instructions in BB
   for (MachineCodeForBasicBlock::const_reverse_iterator MII = MIVec.rbegin(),
@@ -208,9 +234,9 @@ void MethodLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
 
     MInst2LVSetAI[MI] = SetAI;                 // record in After Inst map
 
-    CurSet->applyTranferFuncForMInst(MI);      // apply the transfer Func
-    LiveVarSet *NewSet = new LiveVarSet();     // create a new set and
-    NewSet->setUnion(CurSet);                  // copy the set after T/F to it
+    applyTranferFuncForMInst(*CurSet, MI);     // apply the transfer Func
+    ValueSet *NewSet = new ValueSet();     // create a new set and
+    set_union(*NewSet, *CurSet);               // copy the set after T/F to it
  
     MInst2LVSetBI[MI] = NewSet;                // record in Before Inst map
 
index 9243d05981742a0ec3aff4becfe9af0d76ba6714..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,37 +0,0 @@
-#include "llvm/Analysis/LiveVar/LiveVarSet.h"
-#include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/Type.h"
-
-// This function applies a machine instr to a live var set (accepts OutSet) and
-// makes necessary changes to it (produces InSet). Note that two for loops are
-// used to first kill all defs and then to add all uses. This is because there
-// can be instructions like Val = Val + 1 since we allow multipe defs to a 
-// machine instruction operand.
-
-
-void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *MInst) {
-  for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
-    if (OpI.isDef())      // kill only if this operand is a def
-      insert(*OpI);        // this definition kills any uses
-  }
-
-  // do for implicit operands as well
-  for ( unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
-    if (MInst->implicitRefIsDefined(i))
-      erase(MInst->getImplicitRef(i));
-  }
-
-
-  for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
-    if ((*OpI)->getType()->isLabelType()) continue; // don't process labels
-    
-    if (!OpI.isDef())      // add only if this operand is a use
-      insert(*OpI);            // An operand is a use - so add to use set
-  }
-
-  // do for implicit operands as well
-  for (unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
-    if (!MInst->implicitRefIsDefined(i))
-      insert(MInst->getImplicitRef(i));
-  }
-}
index 431ccc6222982dac3a5c12a43ca02e66ab431ec3..88dd25a0331cfdd8c97ee9b2b17eb59befbb47f1 100644 (file)
@@ -15,28 +15,8 @@ ostream &operator<<(ostream &O, RAV V) { // func to print a Value
     return O << v  << " ";
 }
 
-bool ValueSet::setUnion( const ValueSet *S) {   
-  bool Changed = false;
-
-  for (const_iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI)
-    if (insert(*SI).second)
-      Changed = true;
-
-  return Changed;
-}
-
-void ValueSet::setDifference(const ValueSet *S1, const ValueSet *S2) {
-  for (const_iterator SI = S1->begin(), SE = S1->end() ; SI != SE; ++SI)
-    if (S2->find(*SI) == S2->end())       // if the element is not in set2
-      insert(*SI);
-}
-
-void ValueSet::setSubtract(const ValueSet *S) { 
-  for (const_iterator SI = S->begin() ; SI != S->end(); ++SI)  
-    erase(*SI);
-}
-
-void ValueSet::printSet() const {
-  for (const_iterator I = begin(), E = end(); I != E; ++I)
+void printSet(const ValueSet &S) {
+  for (ValueSet::const_iterator I = S.begin(), E = S.end(); I != E; ++I)
     std::cerr << RAV(*I);
 }
+
index 09aca44f30c6297f02d2e888083eb8667a3ce073..48e81c10682dba30183a6563ad09bed800b31559 100644 (file)
 #define LIVE_RANGE_INFO_H
 
 #include "Support/HashExtras.h"
+#include "llvm/Analysis/LiveVar/ValueSet.h"
 
 class LiveRange;
 class MachineInstr;
-class LiveVarSet;
 class RegClass;
 class MachineRegInfo;
 class TargetMachine;
@@ -60,17 +60,15 @@ class LiveRangeInfo {
 
   void unionAndUpdateLRs(LiveRange *L1, LiveRange *L2);
 
-  void addInterference(const Instruction *const Inst, 
-                      const LiveVarSet *const LVSet);
+  void addInterference(const Instruction *Inst, const ValueSet *LVSet);
   
   void suggestRegs4CallRets();
 
   const Method* getMethod() { return Meth; }
 
-
 public:
   
-  LiveRangeInfo(const Method *const M, 
+  LiveRangeInfo(const Method *M, 
                const TargetMachine& tm,
                std::vector<RegClass *> & RCList);
 
index de8d7938388e5f4957d7ccefb5d213c77b7b68e5..f3aef1cdc2fc28c533b24d32f0efe02ee9524575 100644 (file)
@@ -98,15 +98,15 @@ private:
 
   //------- ------------------ private methods---------------------------------
 
-  void addInterference(const Value *const Def, const LiveVarSet *const LVSet, 
-                      const bool isCallInst);
+  void addInterference(const Value *Def, const ValueSet *LVSet, 
+                      bool isCallInst);
 
   void addInterferencesForArgs();
   void createIGNodeListsAndIGs();
   void buildInterferenceGraphs();
 
   void setCallInterferences(const MachineInstr *MInst, 
-                           const LiveVarSet *const LVSetAft );
+                           const ValueSet *LVSetAft );
 
   void move2DelayedInstr(const MachineInstr *OrigMI, 
                         const MachineInstr *DelayedMI );
@@ -131,13 +131,13 @@ private:
   friend class UltraSparcRegInfo;
 
 
-  int getUsableUniRegAtMI(RegClass *RC,  const int RegType, 
+  int getUsableUniRegAtMI(RegClass *RC, int RegType, 
                          const MachineInstr *MInst,
-                         const LiveVarSet *LVSetBef, MachineInstr *MIBef, 
+                         const ValueSet *LVSetBef, MachineInstr *MIBef, 
                          MachineInstr *MIAft );
 
   int getUnusedUniRegAtMI(RegClass *RC,  const MachineInstr *MInst, 
-                      const LiveVarSet *LVSetBef);
+                      const ValueSet *LVSetBef);
 
   void setRelRegsUsedByThisInst(RegClass *RC, const MachineInstr *MInst );
   int getUniRegNotUsedByThisInst(RegClass *RC, const MachineInstr *MInst);