X86: Shift some register flattening work into the decoder.

This commit is contained in:
Gabe Black 2009-07-17 00:29:42 -07:00
parent e557b4beb5
commit df378285f8
4 changed files with 21 additions and 28 deletions

View file

@ -153,10 +153,7 @@ namespace X86ISA
reg &= ~(1 << 6);
if(fold)
{
suffix = "h";
reg -= 4;
}
else if(reg < 8 && size == 1)
suffix = "l";

View 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;
}
};

View 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;
}
}

View 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,