Made x86 ExtMachInsts distinguishable from each other by defining a real == and a...
authorGabe Black <gblack@eecs.umich.edu>
Wed, 4 Apr 2007 14:27:00 +0000 (14:27 +0000)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 4 Apr 2007 14:27:00 +0000 (14:27 +0000)
--HG--
extra : convert_revision : 30f29a36f6ab44e67e62aaf81b685fbe1267c746

src/arch/x86/types.hh
src/arch/x86/utility.hh

index ca4a15d243424704ca4308336507728a2bcd0154..cdac3c00ee23f24d9d15ef50e7c7bf57bb152eca 100644 (file)
@@ -161,7 +161,26 @@ namespace X86ISA
     inline static bool
         operator == (const ExtMachInst &emi1, const ExtMachInst &emi2)
     {
-        //Since this is empty, it's always equal
+        if(emi1.legacy != emi2.legacy)
+            return false;
+        if(emi1.rex != emi2.rex)
+            return false;
+        if(emi1.opcode.num != emi2.opcode.num)
+            return false;
+        if(emi1.opcode.op != emi2.opcode.op)
+            return false;
+        if(emi1.opcode.prefixA != emi2.opcode.prefixA)
+            return false;
+        if(emi1.opcode.prefixB != emi2.opcode.prefixB)
+            return false;
+        if(emi1.modRM != emi2.modRM)
+            return false;
+        if(emi1.sib != emi2.sib)
+            return false;
+        if(emi1.immediate != emi2.immediate)
+            return false;
+        if(emi1.displacement != emi2.displacement)
+            return false;
         return true;
     }
 
index d89e223de5c1ca7b8212a97880c2b2eb8d94cd25..e0bd0951558aaf98efeb14656d1b0ca5f818d66c 100644 (file)
@@ -70,8 +70,15 @@ namespace __hash_namespace {
     template<>
     struct hash<X86ISA::ExtMachInst> {
         size_t operator()(const X86ISA::ExtMachInst &emi) const {
-            //Because these are all the same, return 0
-            return 0;
+            return (((uint64_t)emi.legacy << 56) |
+                    ((uint64_t)emi.rex  << 48) |
+                    ((uint64_t)emi.modRM << 40) |
+                    ((uint64_t)emi.sib << 32) |
+                    ((uint64_t)emi.opcode.num << 24) |
+                    ((uint64_t)emi.opcode.prefixA << 16) |
+                    ((uint64_t)emi.opcode.prefixB << 8) |
+                    ((uint64_t)emi.opcode.op)) ^
+                    emi.immediate ^ emi.displacement;
         };
     };
 }