[llvm-commits] [llvm] r97673 - in /llvm/trunk: include/llvm/CodeGen/MachineInstr.h lib/CodeGen/MachineCSE.cpp

Dan Gohman gohman at apple.com
Wed Mar 3 14:40:03 PST 2010


Author: djg
Date: Wed Mar  3 16:40:03 2010
New Revision: 97673

URL: http://llvm.org/viewvc/llvm-project?rev=97673&view=rev
Log:
Revert 97667. It broke a bunch of tests.

Modified:
    llvm/trunk/include/llvm/CodeGen/MachineInstr.h
    llvm/trunk/lib/CodeGen/MachineCSE.cpp

Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=97673&r1=97672&r2=97673&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Wed Mar  3 16:40:03 2010
@@ -419,68 +419,6 @@
   void AddRegOperandsToUseLists(MachineRegisterInfo &RegInfo);
 };
 
-/// DenseMapInfo for MachineInstr*.
-template<> struct DenseMapInfo<MachineInstr*> {
-  static inline MachineInstr *getEmptyKey() {
-    return 0;
-  }
-
-  static inline MachineInstr *getTombstoneKey() {
-    return reinterpret_cast<MachineInstr*>(-1);
-  }
-
-  static unsigned getHashValue(const MachineInstr* const &MI) {
-    unsigned Hash = MI->getOpcode() * 37;
-    for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
-      const MachineOperand &MO = MI->getOperand(i);
-      uint64_t Key = (uint64_t)MO.getType() << 32;
-      switch (MO.getType()) {
-        default: break;
-        case MachineOperand::MO_Register:
-          if (MO.isDef())
-            continue;  // Skip defs.
-          Key |= MO.getReg();
-          break;
-        case MachineOperand::MO_Immediate:
-          Key |= MO.getImm();
-          break;
-        case MachineOperand::MO_FrameIndex:
-        case MachineOperand::MO_ConstantPoolIndex:
-        case MachineOperand::MO_JumpTableIndex:
-          Key |= MO.getIndex();
-          break;
-        case MachineOperand::MO_MachineBasicBlock:
-          Key |= DenseMapInfo<void*>::getHashValue(MO.getMBB());
-          break;
-        case MachineOperand::MO_GlobalAddress:
-          Key |= DenseMapInfo<void*>::getHashValue(MO.getGlobal());
-          break;
-        case MachineOperand::MO_BlockAddress:
-          Key |= DenseMapInfo<void*>::getHashValue(MO.getBlockAddress());
-          break;
-      }
-      Key += ~(Key << 32);
-      Key ^= (Key >> 22);
-      Key += ~(Key << 13);
-      Key ^= (Key >> 8);
-      Key += (Key << 3);
-      Key ^= (Key >> 15);
-      Key += ~(Key << 27);
-      Key ^= (Key >> 31);
-      Hash = (unsigned)Key + Hash * 37;
-    }
-    return Hash;
-  }
-
-  static bool isEqual(const MachineInstr* const &LHS,
-                      const MachineInstr* const &RHS) {
-    if (RHS == getEmptyKey() || RHS == getTombstoneKey() ||
-        LHS == getEmptyKey() || LHS == getTombstoneKey())
-      return LHS == RHS;
-    return LHS->isIdenticalTo(RHS, MachineInstr::IgnoreVRegDefs);
-  }
-};
-
 //===----------------------------------------------------------------------===//
 // Debugging Support
 

Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineCSE.cpp?rev=97673&r1=97672&r2=97673&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineCSE.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineCSE.cpp Wed Mar  3 16:40:03 2010
@@ -28,6 +28,69 @@
 STATISTIC(NumCoalesces, "Number of copies coalesced");
 STATISTIC(NumCSEs,      "Number of common subexpression eliminated");
 
+namespace llvm {
+  template<> struct DenseMapInfo<MachineInstr*> {
+    static inline MachineInstr *getEmptyKey() {
+      return 0;
+    }
+
+    static inline MachineInstr *getTombstoneKey() {
+      return reinterpret_cast<MachineInstr*>(-1);
+    }
+
+    static unsigned getHashValue(const MachineInstr* const &MI) {
+      unsigned Hash = MI->getOpcode() * 37;
+      for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
+        const MachineOperand &MO = MI->getOperand(i);
+        uint64_t Key = (uint64_t)MO.getType() << 32;
+        switch (MO.getType()) {
+        default: break;
+        case MachineOperand::MO_Register:
+          if (MO.isDef() && TargetRegisterInfo::isVirtualRegister(MO.getReg()))
+            continue;  // Skip virtual register defs.
+          Key |= MO.getReg();
+          break;
+        case MachineOperand::MO_Immediate:
+          Key |= MO.getImm();
+          break;
+        case MachineOperand::MO_FrameIndex:
+        case MachineOperand::MO_ConstantPoolIndex:
+        case MachineOperand::MO_JumpTableIndex:
+          Key |= MO.getIndex();
+          break;
+        case MachineOperand::MO_MachineBasicBlock:
+          Key |= DenseMapInfo<void*>::getHashValue(MO.getMBB());
+          break;
+        case MachineOperand::MO_GlobalAddress:
+          Key |= DenseMapInfo<void*>::getHashValue(MO.getGlobal());
+          break;
+        case MachineOperand::MO_BlockAddress:
+          Key |= DenseMapInfo<void*>::getHashValue(MO.getBlockAddress());
+          break;
+        }
+        Key += ~(Key << 32);
+        Key ^= (Key >> 22);
+        Key += ~(Key << 13);
+        Key ^= (Key >> 8);
+        Key += (Key << 3);
+        Key ^= (Key >> 15);
+        Key += ~(Key << 27);
+        Key ^= (Key >> 31);
+        Hash = (unsigned)Key + Hash * 37;
+      }
+      return Hash;
+    }
+
+    static bool isEqual(const MachineInstr* const &LHS,
+                        const MachineInstr* const &RHS) {
+      if (RHS == getEmptyKey() || RHS == getTombstoneKey() ||
+          LHS == getEmptyKey() || LHS == getTombstoneKey())
+        return LHS == RHS;
+      return LHS->isIdenticalTo(RHS, MachineInstr::IgnoreVRegDefs);
+    }
+  };
+} // end llvm namespace
+
 namespace {
   class MachineCSE : public MachineFunctionPass {
     const TargetInstrInfo *TII;





More information about the llvm-commits mailing list