[llvm-commits] [llvm] r54765 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp

Owen Anderson resistor at mac.com
Wed Aug 13 15:08:32 PDT 2008


Author: resistor
Date: Wed Aug 13 17:08:30 2008
New Revision: 54765

URL: http://llvm.org/viewvc/llvm-project?rev=54765&view=rev
Log:
Move r2iMap_ over to DenseMap from std::map.

Modified:
    llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
    llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=54765&r1=54764&r2=54765&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Wed Aug 13 17:08:30 2008
@@ -55,6 +55,20 @@
       return LHS.first < RHS.first;
     }
   };
+  
+  // Provide DenseMapInfo for unsigned.
+  template<>
+  struct DenseMapInfo<unsigned> {
+    static inline unsigned getEmptyKey() { return (unsigned)-1; }
+    static inline unsigned getTombstoneKey() { return (unsigned)-2; }
+    static unsigned getHashValue(const unsigned Val) {
+      return Val * 37;
+    }
+    static bool isEqual(const unsigned LHS, const unsigned RHS) {
+      return LHS == RHS;
+    }
+    static bool isPod() { return true; }
+  };
 
   class LiveIntervals : public MachineFunctionPass {
     MachineFunction* mf_;
@@ -86,7 +100,7 @@
     typedef std::vector<MachineInstr*> Index2MiMap;
     Index2MiMap i2miMap_;
 
-    typedef std::map<unsigned, LiveInterval*> Reg2IntervalMap;
+    typedef DenseMap<unsigned, LiveInterval*> Reg2IntervalMap;
     Reg2IntervalMap r2iMap_;
 
     BitVector allocatableRegs_;
@@ -236,7 +250,7 @@
     LiveInterval &getOrCreateInterval(unsigned reg) {
       Reg2IntervalMap::iterator I = r2iMap_.find(reg);
       if (I == r2iMap_.end())
-        I = r2iMap_.insert(I, std::make_pair(reg, createInterval(reg)));
+        I = r2iMap_.insert(std::make_pair(reg, createInterval(reg))).first;
       return *I->second;
     }
     
@@ -248,7 +262,7 @@
     // Interval removal
 
     void removeInterval(unsigned Reg) {
-      std::map<unsigned, LiveInterval*>::iterator I = r2iMap_.find(Reg);
+      DenseMap<unsigned, LiveInterval*>::iterator I = r2iMap_.find(Reg);
       delete I->second;
       r2iMap_.erase(I);
     }

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=54765&r1=54764&r2=54765&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Aug 13 17:08:30 2008
@@ -72,7 +72,7 @@
 
 void LiveIntervals::releaseMemory() {
   // Free the live intervals themselves.
-  for (std::map<unsigned, LiveInterval*>::iterator I = r2iMap_.begin(),
+  for (DenseMap<unsigned, LiveInterval*>::iterator I = r2iMap_.begin(),
        E = r2iMap_.end(); I != E; ++I)
     delete I->second;
   





More information about the llvm-commits mailing list