X86: Shift some register flattening work into the decoder.
authorGabe Black <gblack@eecs.umich.edu>
Fri, 17 Jul 2009 07:29:42 +0000 (00:29 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Fri, 17 Jul 2009 07:29:42 +0000 (00:29 -0700)
src/arch/x86/insts/static_inst.cc
src/arch/x86/intregs.hh
src/arch/x86/isa.cc
src/arch/x86/isa.hh

index f4ed446036a8f3032d6ae171cfc62c11288c66a6..0820a47d4126f0d17fc6bff585b851e2018433d4 100644 (file)
@@ -153,10 +153,7 @@ namespace X86ISA
             reg &= ~(1 << 6);
 
             if(fold)
-            {
                 suffix = "h";
-                reg -= 4;
-            }
             else if(reg < 8 && size == 1)
                 suffix = "l";
 
index 6f252392e7448e1b1637bddb64bb33087cd73580..627d7062f4bcaf9e62c6d64db4d03f2eaee816d7 100644 (file)
@@ -60,6 +60,8 @@
 
 #include "arch/x86/x86_traits.hh"
 #include "base/bitunion.hh"
+#include "base/misc.hh"
+#include "sim/core.hh"
 
 namespace X86ISA
 {
@@ -187,7 +189,9 @@ namespace X86ISA
     inline static IntRegIndex
     INTREG_FOLDED(int index, int foldBit)
     {
-        return (IntRegIndex)(((index & 0x1C) == 4 ? foldBit : 0) | index);
+        if ((index & 0x1C) == 4 && foldBit)
+            index = (index - 4) | foldBit;
+        return (IntRegIndex)index;
     }
 };
 
index d19a2a6cc98ad00dcb5740e566198c21b1e8d659..06a656efc02927b4829235dd463eae2b015aeb42 100644 (file)
@@ -28,7 +28,6 @@
  * Authors: Gabe Black
  */
 
-#include "arch/x86/floatregs.hh"
 #include "arch/x86/isa.hh"
 #include "arch/x86/tlb.hh"
 #include "cpu/base.hh"
@@ -355,25 +354,4 @@ ISA::unserialize(EventManager *em, Checkpoint * cp,
     UNSERIALIZE_ARRAY(regVal, NumMiscRegs);
 }
 
-int
-ISA::flattenIntIndex(int reg)
-{
-    //If we need to fold over the index to match byte semantics, do that.
-    //Otherwise, just strip off any extra bits and pass it through.
-    if (reg & (1 << 6))
-        return (reg & (~(1 << 6) - 0x4));
-    else
-        return (reg & ~(1 << 6));
-}
-
-int
-ISA::flattenFloatIndex(int reg)
-{
-    if (reg >= NUM_FLOATREGS) {
-        int top = readMiscRegNoEffect(MISCREG_X87_TOP);
-        reg = FLOATREG_STACK(reg - NUM_FLOATREGS, top);
-    }
-    return reg;
-}
-
 }
index 285f0aa82f3793f072a798e123d9be6d3bc27a7b..8d3b110c6e98c3d330149f7e5360f009d3bfb419 100644 (file)
@@ -31,6 +31,7 @@
 #ifndef __ARCH_X86_ISA_HH__
 #define __ARCH_X86_ISA_HH__
 
+#include "arch/x86/floatregs.hh"
 #include "arch/x86/miscregs.hh"
 #include "arch/x86/registers.hh"
 #include "base/types.hh"
@@ -65,8 +66,21 @@ namespace X86ISA
         void setMiscRegNoEffect(int miscReg, MiscReg val);
         void setMiscReg(int miscReg, MiscReg val, ThreadContext *tc);
 
-        int flattenIntIndex(int reg);
-        int flattenFloatIndex(int reg);
+        int
+        flattenIntIndex(int reg)
+        {
+            return reg & ~(1 << 6);
+        }
+
+        int
+        flattenFloatIndex(int reg)
+        {
+            if (reg >= NUM_FLOATREGS) {
+                reg = FLOATREG_STACK(reg - NUM_FLOATREGS,
+                                     regVal[MISCREG_X87_TOP]);
+            }
+            return reg;
+        }
 
         void serialize(EventManager *em, std::ostream &os);
         void unserialize(EventManager *em, Checkpoint *cp,