Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/49752 )
Change subject: arch-x86: Use a namespace for integer registers.
......................................................................
arch-x86: Use a namespace for integer registers.
Also reformat the integer register index constants to fit with the style
guide, ie remove the INTREG_ prefix (replaced by the namespace) and
captialize only the first letter.
Change-Id: I682a337944f64a1b96b971a1beb895289b9d299e
---
M src/arch/x86/emulenv.cc
M src/arch/x86/emulenv.hh
M src/arch/x86/faults.cc
M src/arch/x86/insts/microop_args.hh
M src/arch/x86/insts/static_inst.cc
M src/arch/x86/isa.cc
M src/arch/x86/isa/macroop.isa
M src/arch/x86/isa/microasm.isa
M src/arch/x86/isa/operands.isa
M src/arch/x86/isa/specialize.isa
M src/arch/x86/linux/fs_workload.cc
M src/arch/x86/linux/linux.hh
M src/arch/x86/linux/se_workload.cc
M src/arch/x86/linux/se_workload.hh
M src/arch/x86/nativetrace.cc
M src/arch/x86/process.cc
M src/arch/x86/pseudo_inst_abi.hh
M src/arch/x86/regs/int.hh
M src/arch/x86/remote_gdb.cc
M src/cpu/kvm/x86_cpu.cc
20 files changed, 292 insertions(+), 282 deletions(-)
diff --git a/src/arch/x86/emulenv.cc b/src/arch/x86/emulenv.cc
index bfca1e5..3e3131d 100644
--- a/src/arch/x86/emulenv.cc
+++ b/src/arch/x86/emulenv.cc
@@ -56,36 +56,37 @@
base = machInst.sib.base | (machInst.rex.b << 3);
//In this special case, we don't use a base. The displacement also
//changes, but that's managed by the decoder.
- if (machInst.sib.base == INTREG_RBP && machInst.modRM.mod == 0)
- base = INTREG_T0;
+ if (machInst.sib.base == (RegIndex)int_reg::Rbp &&
+ machInst.modRM.mod == 0)
+ base = int_reg::T0;
//In -this- special case, we don't use an index.
- if (index == INTREG_RSP)
- index = INTREG_T0;
+ if (index == int_reg::Rsp)
+ index = int_reg::T0;
} else {
if (machInst.addrSize == 2) {
unsigned rm = machInst.modRM.rm;
if (rm <= 3) {
scale = 1;
if (rm < 2) {
- base = INTREG_RBX;
+ base = int_reg::Rbx;
} else {
- base = INTREG_RBP;
+ base = int_reg::Rbp;
}
- index = (rm % 2) ? INTREG_RDI : INTREG_RSI;
+ index = (rm % 2) ? int_reg::Rdi : int_reg::Rsi;
} else {
scale = 0;
switch (rm) {
case 4:
- base = INTREG_RSI;
+ base = int_reg::Rsi;
break;
case 5:
- base = INTREG_RDI;
+ base = int_reg::Rdi;
break;
case 6:
- base = INTREG_RBP;
+ base = int_reg::Rbp;
break;
case 7:
- base = INTREG_RBX;
+ base = int_reg::Rbx;
break;
}
}
@@ -95,14 +96,14 @@
if (machInst.modRM.mod == 0 && machInst.modRM.rm == 5) {
//Since we need to use a different encoding of this
//instruction anyway, just ignore the base in those cases
- base = INTREG_T0;
+ base = int_reg::T0;
}
}
}
//Figure out what segment to use. This won't be entirely accurate since
//the presence of a displacement is supposed to make the instruction
//default to the data segment.
- if ((base != INTREG_RBP && base != INTREG_RSP) || machInst.dispSize) {
+ if ((base != int_reg::Rbp && base != int_reg::Rsp) ||
machInst.dispSize) {
seg = SEGMENT_REG_DS;
//Handle any segment override that might have been in the
instruction
int segFromInst = machInst.legacy.seg;
diff --git a/src/arch/x86/emulenv.hh b/src/arch/x86/emulenv.hh
index ad14747..b097f95 100644
--- a/src/arch/x86/emulenv.hh
+++ b/src/arch/x86/emulenv.hh
@@ -62,8 +62,8 @@
EmulEnv(RegIndex _reg, RegIndex _regm,
int _dataSize, int _addressSize, int _stackSize) :
reg(_reg), regm(_regm), seg(SEGMENT_REG_DS),
- scale(0), index(INTREG_T0),
- base(INTREG_T0),
+ scale(0), index(int_reg::T0),
+ base(int_reg::T0),
dataSize(_dataSize), addressSize(_addressSize),
stackSize(_stackSize)
{;}
diff --git a/src/arch/x86/faults.cc b/src/arch/x86/faults.cc
index 35e22f8..a53397d 100644
--- a/src/arch/x86/faults.cc
+++ b/src/arch/x86/faults.cc
@@ -77,8 +77,8 @@
} else {
entry = extern_label_legacyModeInterrupt;
}
- tc->setIntReg(INTREG_MICRO(1), vector);
- tc->setIntReg(INTREG_MICRO(7), pc);
+ tc->setIntReg(intRegMicro(1), vector);
+ tc->setIntReg(intRegMicro(7), pc);
if (errorCode != (uint64_t)(-1)) {
if (m5reg.mode == LongMode) {
entry = extern_label_longModeInterruptWithError;
@@ -89,7 +89,7 @@
// Software interrupts shouldn't have error codes. If one
// does, there would need to be microcode to set it up.
assert(!isSoft());
- tc->setIntReg(INTREG_MICRO(15), errorCode);
+ tc->setIntReg(intRegMicro(15), errorCode);
}
pcState.upc(romMicroPC(entry));
pcState.nupc(romMicroPC(entry) + 1);
@@ -189,7 +189,7 @@
{
DPRINTF(Faults, "Init interrupt.\n");
// The otherwise unmodified integer registers should be set to 0.
- for (int index = 0; index < NUM_ARCH_INTREGS; index++) {
+ for (int index = 0; index < int_reg::NumArchRegs; index++) {
tc->setIntReg(index, 0);
}
@@ -279,7 +279,7 @@
// This value should be the family/model/stepping of the processor.
// (page 418). It should be consistent with the value from CPUID, but
// the actual value probably doesn't matter much.
- tc->setIntReg(INTREG_RDX, 0);
+ tc->setIntReg(int_reg::Rdx, 0);
tc->setMiscReg(MISCREG_DR0, 0);
tc->setMiscReg(MISCREG_DR1, 0);
diff --git a/src/arch/x86/insts/microop_args.hh
b/src/arch/x86/insts/microop_args.hh
index 7769764..e0c3f2b 100644
--- a/src/arch/x86/insts/microop_args.hh
+++ b/src/arch/x86/insts/microop_args.hh
@@ -156,7 +156,7 @@
template <class InstType>
FoldedOp(InstType *inst, ArgType idx) :
- Base(INTREG_FOLDED(idx.index, inst->foldOBit), inst->dataSize)
+ Base(intRegFolded(idx.index, inst->foldOBit), inst->dataSize)
{}
void
@@ -361,8 +361,8 @@
template <class InstType>
AddrOp(InstType *inst, const ArgType &args) : scale(args.scale),
- index(INTREG_FOLDED(args.index.index, inst->foldABit)),
- base(INTREG_FOLDED(args.base.index, inst->foldABit)),
+ index(intRegFolded(args.index.index, inst->foldABit)),
+ base(intRegFolded(args.base.index, inst->foldABit)),
disp(args.disp), segment(args.segment.index),
size(inst->addressSize)
{
diff --git a/src/arch/x86/insts/static_inst.cc
b/src/arch/x86/insts/static_inst.cc
index 01e62f1..0b1a000 100644
--- a/src/arch/x86/insts/static_inst.cc
+++ b/src/arch/x86/insts/static_inst.cc
@@ -166,56 +166,57 @@
suffix = "l";
switch (reg_idx) {
- case INTREG_RAX:
+ case int_reg::Rax:
ccprintf(os, abcdFormats[size], "a");
break;
- case INTREG_RBX:
+ case int_reg::Rbx:
ccprintf(os, abcdFormats[size], "b");
break;
- case INTREG_RCX:
+ case int_reg::Rcx:
ccprintf(os, abcdFormats[size], "c");
break;
- case INTREG_RDX:
+ case int_reg::Rdx:
ccprintf(os, abcdFormats[size], "d");
break;
- case INTREG_RSP:
+ case int_reg::Rsp:
ccprintf(os, piFormats[size], "sp");
break;
- case INTREG_RBP:
+ case int_reg::Rbp:
ccprintf(os, piFormats[size], "bp");
break;
- case INTREG_RSI:
+ case int_reg::Rsi:
ccprintf(os, piFormats[size], "si");
break;
- case INTREG_RDI:
+ case int_reg::Rdi:
ccprintf(os, piFormats[size], "di");
break;
- case INTREG_R8W:
+ case int_reg::R8:
ccprintf(os, longFormats[size], "8");
break;
- case INTREG_R9W:
+ case int_reg::R9:
ccprintf(os, longFormats[size], "9");
break;
- case INTREG_R10W:
+ case int_reg::R10:
ccprintf(os, longFormats[size], "10");
break;
- case INTREG_R11W:
+ case int_reg::R11:
ccprintf(os, longFormats[size], "11");
break;
- case INTREG_R12W:
+ case int_reg::R12:
ccprintf(os, longFormats[size], "12");
break;
- case INTREG_R13W:
+ case int_reg::R13:
ccprintf(os, longFormats[size], "13");
break;
- case INTREG_R14W:
+ case int_reg::R14:
ccprintf(os, longFormats[size], "14");
break;
- case INTREG_R15W:
+ case int_reg::R15:
ccprintf(os, longFormats[size], "15");
break;
default:
- ccprintf(os, microFormats[size], reg_idx -
INTREG_MICRO_BEGIN);
+ ccprintf(os, microFormats[size],
+ reg_idx - int_reg::MicroBegin);
}
ccprintf(os, suffix);
}
@@ -265,13 +266,13 @@
os << "rip";
someAddr = true;
} else {
- if (scale != 0 && index != NUM_INTREGS) {
+ if (scale != 0 && index != int_reg::NumRegs) {
if (scale != 1)
ccprintf(os, "%d*", scale);
printReg(os, RegId(IntRegClass, index), addressSize);
someAddr = true;
}
- if (base != NUM_INTREGS) {
+ if (base != int_reg::NumRegs) {
if (someAddr)
os << " + ";
printReg(os, RegId(IntRegClass, base), addressSize);
diff --git a/src/arch/x86/isa.cc b/src/arch/x86/isa.cc
index f8e3a43..769e4a3 100644
--- a/src/arch/x86/isa.cc
+++ b/src/arch/x86/isa.cc
@@ -146,7 +146,7 @@
fatal_if(vendorString.size() != 12,
"CPUID vendor string must be 12 characters\n");
- _regClasses.emplace_back(NumIntRegs, debug::IntRegs);
+ _regClasses.emplace_back(int_reg::NumRegs, debug::IntRegs);
_regClasses.emplace_back(NumFloatRegs, debug::FloatRegs);
_regClasses.emplace_back(1, debug::IntRegs); // Not applicable to X86
_regClasses.emplace_back(2, debug::IntRegs); // Not applicable to X86
@@ -181,7 +181,7 @@
ISA::copyRegsFrom(ThreadContext *src)
{
//copy int regs
- for (int i = 0; i < NumIntRegs; ++i)
+ for (int i = 0; i < int_reg::NumRegs; ++i)
tc->setIntRegFlat(i, src->readIntRegFlat(i));
//copy float regs
for (int i = 0; i < NumFloatRegs; ++i)
diff --git a/src/arch/x86/isa/macroop.isa b/src/arch/x86/isa/macroop.isa
index 97646ff..9150fe9 100644
--- a/src/arch/x86/isa/macroop.isa
+++ b/src/arch/x86/isa/macroop.isa
@@ -256,7 +256,7 @@
memoryInst = "true"
else:
memoryInst = "false"
- regSize = '''(%s || (env.base == INTREG_RSP && %s) ?
+ regSize = '''(%s || (env.base == int_reg::Rsp && %s) ?
env.stackSize :
env.dataSize)''' % (useStackSize, memoryInst)
iop = InstObjParams(self.getMnemonic(), self.name, "Macroop",
diff --git a/src/arch/x86/isa/microasm.isa b/src/arch/x86/isa/microasm.isa
index 4d4409a..549a4b1 100644
--- a/src/arch/x86/isa/microasm.isa
+++ b/src/arch/x86/isa/microasm.isa
@@ -78,7 +78,7 @@
# Add in symbols for the microcode registers
for num in range(16):
- assembler.symbols["t%d" % num] = gpRegIdx("INTREG_MICRO(%d)" % num)
+ assembler.symbols["t%d" % num] = gpRegIdx("intRegMicro(%d)" % num)
for num in range(8):
assembler.symbols["ufp%d" % num] = \
fpRegIdx("FLOATREG_MICROFP(%d)" % num)
@@ -152,12 +152,12 @@
for reg in ('ax', 'bx', 'cx', 'dx', 'sp', 'bp', 'si', 'di', \
'8', '9', '10', '11', '12', '13', '14', '15'):
assembler.symbols["r%s" % reg] = \
- gpRegIdx("INTREG_R%s" % reg.upper())
+ gpRegIdx("int_reg::R%s" % reg)
for reg in ('ah', 'bh', 'ch', 'dh'):
assembler.symbols[reg] = \
- gpRegIdx("X86ISA::INTREG_FOLDED(INTREG_%s, IntFoldBit)" %
- reg.upper())
+ gpRegIdx("X86ISA::intRegFolded(int_reg::%s, IntFoldBit)" %
+ reg.capitalize())
for reg in range(16):
assembler.symbols["cr%d" % reg] = crRegIdx("%d" % reg)
diff --git a/src/arch/x86/isa/operands.isa b/src/arch/x86/isa/operands.isa
index 677396d..dd7b4a3 100644
--- a/src/arch/x86/isa/operands.isa
+++ b/src/arch/x86/isa/operands.isa
@@ -57,7 +57,7 @@
class IntReg(IntRegOp):
@overrideInOperand
def regId(self):
- return f'(({self.reg_spec}) == gem5::X86ISA::INTREG_T0) ? ' \
+ return f'(({self.reg_spec}) == gem5::X86ISA::int_reg::T0) ? ' \
f'RegId() : RegId({self.reg_class}, {self.reg_spec})'
def __init__(self, idx, id, data_size='dataSize', *args, **kwargs):
super(IntReg, self).__init__(
@@ -149,22 +149,22 @@
'PData': PickedReg('data', 6),
'DataLow': IntReg('dataLow', 6),
'DataHi': IntReg('dataHi', 6),
- 'ProdLow': IntReg('X86ISA::INTREG_PRODLOW', 7),
- 'ProdHi': IntReg('X86ISA::INTREG_PRODHI', 8),
- 'Quotient': IntReg('X86ISA::INTREG_QUOTIENT', 9),
- 'Remainder': IntReg('X86ISA::INTREG_REMAINDER', 10),
- 'Divisor': IntReg('X86ISA::INTREG_DIVISOR', 11),
- 'DoubleBits': IntReg('X86ISA::INTREG_DOUBLEBITS', 11),
- 'Rax': IntReg('X86ISA::INTREG_RAX', 12),
- 'Rbx': IntReg('X86ISA::INTREG_RBX', 13),
- 'Rcx': IntReg('X86ISA::INTREG_RCX', 14),
- 'Rdx': IntReg('X86ISA::INTREG_RDX', 15),
- 'Rsp': IntReg('X86ISA::INTREG_RSP', 16),
- 'Rbp': IntReg('X86ISA::INTREG_RBP', 17),
- 'Rsi': IntReg('X86ISA::INTREG_RSI', 18),
- 'Rdi': IntReg('X86ISA::INTREG_RDI', 19),
- 'R8': IntReg('X86ISA::INTREG_R8', 20),
- 'R9': IntReg('X86ISA::INTREG_R9', 21),
+ 'ProdLow': IntReg('X86ISA::int_reg::Prodlow', 7),
+ 'ProdHi': IntReg('X86ISA::int_reg::Prodhi', 8),
+ 'Quotient': IntReg('X86ISA::int_reg::Quotient', 9),
+ 'Remainder': IntReg('X86ISA::int_reg::Remainder', 10),
+ 'Divisor': IntReg('X86ISA::int_reg::Divisor', 11),
+ 'DoubleBits': IntReg('X86ISA::int_reg::Doublebits', 11),
+ 'Rax': IntReg('X86ISA::int_reg::Rax', 12),
+ 'Rbx': IntReg('X86ISA::int_reg::Rbx', 13),
+ 'Rcx': IntReg('X86ISA::int_reg::Rcx', 14),
+ 'Rdx': IntReg('X86ISA::int_reg::Rdx', 15),
+ 'Rsp': IntReg('X86ISA::int_reg::Rsp', 16),
+ 'Rbp': IntReg('X86ISA::int_reg::Rbp', 17),
+ 'Rsi': IntReg('X86ISA::int_reg::Rsi', 18),
+ 'Rdi': IntReg('X86ISA::int_reg::Rdi', 19),
+ 'R8': IntReg('X86ISA::int_reg::R8', 20),
+ 'R9': IntReg('X86ISA::int_reg::R9', 21),
'FpSrcReg1': FloatReg('src1', 22),
'FpSrcReg2': FloatReg('src2', 23),
'FpDestReg': FloatReg('dest', 24),
diff --git a/src/arch/x86/isa/specialize.isa
b/src/arch/x86/isa/specialize.isa
index 839b66d..1ebe0ff 100644
--- a/src/arch/x86/isa/specialize.isa
+++ b/src/arch/x86/isa/specialize.isa
@@ -137,9 +137,9 @@
#Figure out what to do with fixed register operands
#This is the index to use, so we should stick it some
place.
if opType.reg in ("A", "B", "C", "D"):
- regString = "INTREG_R%sX" % opType.reg
+ regString = "int_reg::R%sx" % opType.reg.lower()
else:
- regString = "INTREG_R%s" % opType.reg
+ regString = "int_reg::R%s" % opType.reg.lower()
env.addReg(regString)
env.addToDisassembly(
"printReg(out, RegId(IntRegClass, %s), regSize);\n" %
@@ -256,12 +256,14 @@
if opType.tag == "X":
env.addToDisassembly(
'''printMem(out, env.seg,
- 1, X86ISA::NUM_INTREGS,
X86ISA::INTREG_RSI, 0,
+ 1, X86ISA::int_reg::NumRegs,
+ X86ISA::int_reg::Rsi, 0,
env.addressSize, false);''')
else:
env.addToDisassembly(
'''printMem(out, SEGMENT_REG_ES,
- 1, X86ISA::NUM_INTREGS,
X86ISA::INTREG_RDI, 0,
+ 1, X86ISA::int_reg::NumRegs,
+ X86ISA::int_reg::Rdi, 0,
env.addressSize, false);''')
Name += "_M"
else:
diff --git a/src/arch/x86/linux/fs_workload.cc
b/src/arch/x86/linux/fs_workload.cc
index f3c1b87..7b794e6 100644
--- a/src/arch/x86/linux/fs_workload.cc
+++ b/src/arch/x86/linux/fs_workload.cc
@@ -126,7 +126,7 @@
* Pass the location of the real mode data structure to the kernel
* using register %esi. We'll use %rsi which should be equivalent.
*/
- system->threads[0]->setIntReg(INTREG_RSI, realModeData);
+ system->threads[0]->setIntReg(int_reg::Rsi, realModeData);
}
} // namespace X86ISA
diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh
index ae85a2a..a411c73 100644
--- a/src/arch/x86/linux/linux.hh
+++ b/src/arch/x86/linux/linux.hh
@@ -71,7 +71,7 @@
}
if (stack)
- ctc->setIntReg(X86ISA::INTREG_RSP, stack);
+ ctc->setIntReg(X86ISA::int_reg::Rsp, stack);
}
class SyscallABI {};
@@ -91,7 +91,7 @@
if (ret.suppressed() || ret.needsRetry())
return;
- tc->setIntReg(X86ISA::INTREG_RAX, ret.encodedValue());
+ tc->setIntReg(X86ISA::int_reg::Rax, ret.encodedValue());
}
};
diff --git a/src/arch/x86/linux/se_workload.cc
b/src/arch/x86/linux/se_workload.cc
index 09ca2bf..30c92c6 100644
--- a/src/arch/x86/linux/se_workload.cc
+++ b/src/arch/x86/linux/se_workload.cc
@@ -97,12 +97,14 @@
EmuLinux::EmuLinux(const Params &p) : SEWorkload(p)
{}
-const std::vector<IntRegIndex> EmuLinux::SyscallABI64::ArgumentRegs = {
- INTREG_RDI, INTREG_RSI, INTREG_RDX, INTREG_R10W, INTREG_R8W, INTREG_R9W
+const std::vector<RegIndex> EmuLinux::SyscallABI64::ArgumentRegs = {
+ int_reg::Rdi, int_reg::Rsi, int_reg::Rdx,
+ int_reg::R10, int_reg::R8, int_reg::R9
};
-const std::vector<IntRegIndex> EmuLinux::SyscallABI32::ArgumentRegs = {
- INTREG_EBX, INTREG_ECX, INTREG_EDX, INTREG_ESI, INTREG_EDI, INTREG_EBP
+const std::vector<RegIndex> EmuLinux::SyscallABI32::ArgumentRegs = {
+ int_reg::Ebx, int_reg::Ecx, int_reg::Edx,
+ int_reg::Esi, int_reg::Edi, int_reg::Ebp
};
void
@@ -113,7 +115,7 @@
// This will move into the base SEWorkload function at some point.
process->Process::syscall(tc);
- RegVal rax = tc->readIntReg(INTREG_RAX);
+ RegVal rax = tc->readIntReg(int_reg::Rax);
if (dynamic_cast<X86_64Process *>(process)) {
syscallDescs64.get(rax)->doSyscall(tc);
} else if (auto *proc32 = dynamic_cast<I386Process *>(process)) {
diff --git a/src/arch/x86/linux/se_workload.hh
b/src/arch/x86/linux/se_workload.hh
index bae7dda..b9acbcb 100644
--- a/src/arch/x86/linux/se_workload.hh
+++ b/src/arch/x86/linux/se_workload.hh
@@ -78,13 +78,13 @@
struct SyscallABI64 :
public GenericSyscallABI64, public X86Linux::SyscallABI
{
- static const std::vector<IntRegIndex> ArgumentRegs;
+ static const std::vector<RegIndex> ArgumentRegs;
};
struct SyscallABI32 :
public GenericSyscallABI32, public X86Linux::SyscallABI
{
- static const std::vector<IntRegIndex> ArgumentRegs;
+ static const std::vector<RegIndex> ArgumentRegs;
};
private:
diff --git a/src/arch/x86/nativetrace.cc b/src/arch/x86/nativetrace.cc
index 9e357a8..20ba545 100644
--- a/src/arch/x86/nativetrace.cc
+++ b/src/arch/x86/nativetrace.cc
@@ -71,22 +71,22 @@
void
X86NativeTrace::ThreadState::update(ThreadContext *tc)
{
- rax = tc->readIntReg(X86ISA::INTREG_RAX);
- rcx = tc->readIntReg(X86ISA::INTREG_RCX);
- rdx = tc->readIntReg(X86ISA::INTREG_RDX);
- rbx = tc->readIntReg(X86ISA::INTREG_RBX);
- rsp = tc->readIntReg(X86ISA::INTREG_RSP);
- rbp = tc->readIntReg(X86ISA::INTREG_RBP);
- rsi = tc->readIntReg(X86ISA::INTREG_RSI);
- rdi = tc->readIntReg(X86ISA::INTREG_RDI);
- r8 = tc->readIntReg(X86ISA::INTREG_R8);
- r9 = tc->readIntReg(X86ISA::INTREG_R9);
- r10 = tc->readIntReg(X86ISA::INTREG_R10);
- r11 = tc->readIntReg(X86ISA::INTREG_R11);
- r12 = tc->readIntReg(X86ISA::INTREG_R12);
- r13 = tc->readIntReg(X86ISA::INTREG_R13);
- r14 = tc->readIntReg(X86ISA::INTREG_R14);
- r15 = tc->readIntReg(X86ISA::INTREG_R15);
+ rax = tc->readIntReg(X86ISA::int_reg::Rax);
+ rcx = tc->readIntReg(X86ISA::int_reg::Rcx);
+ rdx = tc->readIntReg(X86ISA::int_reg::Rdx);
+ rbx = tc->readIntReg(X86ISA::int_reg::Rbx);
+ rsp = tc->readIntReg(X86ISA::int_reg::Rsp);
+ rbp = tc->readIntReg(X86ISA::int_reg::Rbp);
+ rsi = tc->readIntReg(X86ISA::int_reg::Rsi);
+ rdi = tc->readIntReg(X86ISA::int_reg::Rdi);
+ r8 = tc->readIntReg(X86ISA::int_reg::R8);
+ r9 = tc->readIntReg(X86ISA::int_reg::R9);
+ r10 = tc->readIntReg(X86ISA::int_reg::R10);
+ r11 = tc->readIntReg(X86ISA::int_reg::R11);
+ r12 = tc->readIntReg(X86ISA::int_reg::R12);
+ r13 = tc->readIntReg(X86ISA::int_reg::R13);
+ r14 = tc->readIntReg(X86ISA::int_reg::R14);
+ r15 = tc->readIntReg(X86ISA::int_reg::R15);
rip = tc->pcState().npc();
//This should be expanded if x87 registers are considered
for (int i = 0; i < 8; i++)
diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc
index 5efd6b1..7203c3d 100644
--- a/src/arch/x86/process.cc
+++ b/src/arch/x86/process.cc
@@ -987,7 +987,7 @@
ThreadContext *tc = system->threads[contextIds[0]];
// Set the stack pointer register
- tc->setIntReg(INTREG_RSP, stack_min);
+ tc->setIntReg(int_reg::Rsp, stack_min);
// There doesn't need to be any segment base added in since we're
dealing
// with the flat segmentation model.
diff --git a/src/arch/x86/pseudo_inst_abi.hh
b/src/arch/x86/pseudo_inst_abi.hh
index 456a18e..386b8a4 100644
--- a/src/arch/x86/pseudo_inst_abi.hh
+++ b/src/arch/x86/pseudo_inst_abi.hh
@@ -59,7 +59,7 @@
// This assumes that all pseudo ops have their return value set
// by the pseudo op instruction. This may need to be revisited if
we
// modify the pseudo op ABI in util/m5/m5op_x86.S
- tc->setIntReg(X86ISA::INTREG_RAX, ret);
+ tc->setIntReg(X86ISA::int_reg::Rax, ret);
}
};
@@ -76,9 +76,9 @@
using namespace X86ISA;
- const int int_reg_map[] = {
- INTREG_RDI, INTREG_RSI, INTREG_RDX,
- INTREG_RCX, INTREG_R8, INTREG_R9
+ constexpr RegIndex int_reg_map[] = {
+ int_reg::Rdi, int_reg::Rsi, int_reg::Rdx,
+ int_reg::Rcx, int_reg::R8, int_reg::R9
};
return tc->readIntReg(int_reg_map[state++]);
diff --git a/src/arch/x86/regs/int.hh b/src/arch/x86/regs/int.hh
index 014f5a4..a7d9fd6 100644
--- a/src/arch/x86/regs/int.hh
+++ b/src/arch/x86/regs/int.hh
@@ -47,145 +47,149 @@
namespace X86ISA
{
- BitUnion64(X86IntReg)
- Bitfield<63,0> R;
- SignedBitfield<63,0> SR;
- Bitfield<31,0> E;
- SignedBitfield<31,0> SE;
- Bitfield<15,0> X;
- SignedBitfield<15,0> SX;
- Bitfield<15,8> H;
- SignedBitfield<15,8> SH;
- Bitfield<7, 0> L;
- SignedBitfield<7, 0> SL;
- EndBitUnion(X86IntReg)
- enum IntRegIndex
- {
- INTREG_RAX,
- INTREG_EAX = INTREG_RAX,
- INTREG_AX = INTREG_RAX,
- INTREG_AL = INTREG_RAX,
+BitUnion64(X86IntReg)
+ Bitfield<63,0> R;
+ SignedBitfield<63,0> SR;
+ Bitfield<31,0> E;
+ SignedBitfield<31,0> SE;
+ Bitfield<15,0> X;
+ SignedBitfield<15,0> SX;
+ Bitfield<15,8> H;
+ SignedBitfield<15,8> SH;
+ Bitfield<7, 0> L;
+ SignedBitfield<7, 0> SL;
+EndBitUnion(X86IntReg)
- INTREG_RCX,
- INTREG_ECX = INTREG_RCX,
- INTREG_CX = INTREG_RCX,
- INTREG_CL = INTREG_RCX,
+namespace int_reg
+{
- INTREG_RDX,
- INTREG_EDX = INTREG_RDX,
- INTREG_DX = INTREG_RDX,
- INTREG_DL = INTREG_RDX,
+enum : RegIndex
+{
+ Rax,
+ Eax = Rax,
+ Ax = Rax,
+ Al = Rax,
- INTREG_RBX,
- INTREG_EBX = INTREG_RBX,
- INTREG_BX = INTREG_RBX,
- INTREG_BL = INTREG_RBX,
+ Rcx,
+ Ecx = Rcx,
+ Cx = Rcx,
+ Cl = Rcx,
- INTREG_RSP,
- INTREG_ESP = INTREG_RSP,
- INTREG_SP = INTREG_RSP,
- INTREG_SPL = INTREG_RSP,
- INTREG_AH = INTREG_RSP,
+ Rdx,
+ Edx = Rdx,
+ Dx = Rdx,
+ Dl = Rdx,
- INTREG_RBP,
- INTREG_EBP = INTREG_RBP,
- INTREG_BP = INTREG_RBP,
- INTREG_BPL = INTREG_RBP,
- INTREG_CH = INTREG_RBP,
+ Rbx,
+ Ebx = Rbx,
+ Bx = Rbx,
+ Bl = Rbx,
- INTREG_RSI,
- INTREG_ESI = INTREG_RSI,
- INTREG_SI = INTREG_RSI,
- INTREG_SIL = INTREG_RSI,
- INTREG_DH = INTREG_RSI,
+ Rsp,
+ Esp = Rsp,
+ Sp = Rsp,
+ Spl = Rsp,
+ Ah = Rsp,
- INTREG_RDI,
- INTREG_EDI = INTREG_RDI,
- INTREG_DI = INTREG_RDI,
- INTREG_DIL = INTREG_RDI,
- INTREG_BH = INTREG_RDI,
+ Rbp,
+ Ebp = Rbp,
+ Bp = Rbp,
+ Bpl = Rbp,
+ Ch = Rbp,
- INTREG_R8,
- INTREG_R8D = INTREG_R8,
- INTREG_R8W = INTREG_R8,
- INTREG_R8B = INTREG_R8,
+ Rsi,
+ Esi = Rsi,
+ Si = Rsi,
+ Sil = Rsi,
+ Dh = Rsi,
- INTREG_R9,
- INTREG_R9D = INTREG_R9,
- INTREG_R9W = INTREG_R9,
- INTREG_R9B = INTREG_R9,
+ Rdi,
+ Edi = Rdi,
+ Di = Rdi,
+ Dil = Rdi,
+ Bh = Rdi,
- INTREG_R10,
- INTREG_R10D = INTREG_R10,
- INTREG_R10W = INTREG_R10,
- INTREG_R10B = INTREG_R10,
+ R8,
+ R8d = R8,
+ R8w = R8,
+ R8b = R8,
- INTREG_R11,
- INTREG_R11D = INTREG_R11,
- INTREG_R11W = INTREG_R11,
- INTREG_R11B = INTREG_R11,
+ R9,
+ R9d = R9,
+ R9w = R9,
+ R9b = R9,
- INTREG_R12,
- INTREG_R12D = INTREG_R12,
- INTREG_R12W = INTREG_R12,
- INTREG_R12B = INTREG_R12,
+ R10,
+ R10d = R10,
+ R10w = R10,
+ R10b = R10,
- INTREG_R13,
- INTREG_R13D = INTREG_R13,
- INTREG_R13W = INTREG_R13,
- INTREG_R13B = INTREG_R13,
+ R11,
+ R11d = R11,
+ R11w = R11,
+ R11b = R11,
- INTREG_R14,
- INTREG_R14D = INTREG_R14,
- INTREG_R14W = INTREG_R14,
- INTREG_R14B = INTREG_R14,
+ R12,
+ R12d = R12,
+ R12w = R12,
+ R12b = R12,
- INTREG_R15,
- INTREG_R15D = INTREG_R15,
- INTREG_R15W = INTREG_R15,
- INTREG_R15B = INTREG_R15,
+ R13,
+ R13d = R13,
+ R13w = R13,
+ R13b = R13,
- NUM_ARCH_INTREGS,
+ R14,
+ R14d = R14,
+ R14w = R14,
+ R14b = R14,
- INTREG_MICRO_BEGIN = NUM_ARCH_INTREGS,
- INTREG_T0 = INTREG_MICRO_BEGIN,
- INTREG_MICRO_END = INTREG_MICRO_BEGIN + NumMicroIntRegs,
+ R15,
+ R15d = R15,
+ R15w = R15,
+ R15b = R15,
- // The lower part of the result of multiplication.
- INTREG_PRODLOW,
- // The upper part of the result of multiplication.
- INTREG_PRODHI,
- // The quotient from division.
- INTREG_QUOTIENT,
- // The remainder from division.
- INTREG_REMAINDER,
- // The divisor for division.
- INTREG_DIVISOR,
- // The register to use for shift doubles.
- INTREG_DOUBLEBITS,
+ NumArchRegs,
- NUM_INTREGS,
- };
+ MicroBegin = NumArchRegs,
+ T0 = MicroBegin,
+ MicroEnd = MicroBegin + NumMicroIntRegs,
- // This needs to be large enough to miss all the other bits of an
index.
- static const IntRegIndex IntFoldBit = (IntRegIndex)(1 << 6);
+ // The lower part of the result of multiplication.
+ Prodlow,
+ // The upper part of the result of multiplication.
+ Prodhi,
+ // The quotient from division.
+ Quotient,
+ // The remainder from division.
+ Remainder,
+ // The divisor for division.
+ Divisor,
+ // The register to use for shift doubles.
+ Doublebits,
- inline static IntRegIndex
- INTREG_MICRO(int index)
- {
- return (IntRegIndex)(INTREG_MICRO_BEGIN + index);
- }
+ NumRegs,
+};
- inline static IntRegIndex
- INTREG_FOLDED(int index, int foldBit)
- {
- if ((index & 0x1C) == 4 && foldBit)
- index = (index - 4) | foldBit;
- return (IntRegIndex)index;
- }
+} // namespace int_reg
- const int NumIntRegs = NUM_INTREGS;
+// This needs to be large enough to miss all the other bits of an index.
+inline constexpr RegIndex IntFoldBit = 1 << 6;
+
+inline static constexpr RegIndex
+intRegMicro(int index)
+{
+ return int_reg::MicroBegin + index;
+}
+
+inline static constexpr RegIndex
+intRegFolded(RegIndex index, RegIndex foldBit)
+{
+ if ((index & 0x1C) == 4 && foldBit)
+ index = (index - 4) | foldBit;
+ return index;
+}
} // namespace X86ISA
} // namespace gem5
diff --git a/src/arch/x86/remote_gdb.cc b/src/arch/x86/remote_gdb.cc
index 41b4525..5096e19 100644
--- a/src/arch/x86/remote_gdb.cc
+++ b/src/arch/x86/remote_gdb.cc
@@ -125,22 +125,22 @@
RemoteGDB::AMD64GdbRegCache::getRegs(ThreadContext *context)
{
DPRINTF(GDBAcc, "getRegs in remotegdb \n");
- r.rax = context->readIntReg(INTREG_RAX);
- r.rbx = context->readIntReg(INTREG_RBX);
- r.rcx = context->readIntReg(INTREG_RCX);
- r.rdx = context->readIntReg(INTREG_RDX);
- r.rsi = context->readIntReg(INTREG_RSI);
- r.rdi = context->readIntReg(INTREG_RDI);
- r.rbp = context->readIntReg(INTREG_RBP);
- r.rsp = context->readIntReg(INTREG_RSP);
- r.r8 = context->readIntReg(INTREG_R8);
- r.r9 = context->readIntReg(INTREG_R9);
- r.r10 = context->readIntReg(INTREG_R10);
- r.r11 = context->readIntReg(INTREG_R11);
- r.r12 = context->readIntReg(INTREG_R12);
- r.r13 = context->readIntReg(INTREG_R13);
- r.r14 = context->readIntReg(INTREG_R14);
- r.r15 = context->readIntReg(INTREG_R15);
+ r.rax = context->readIntReg(int_reg::Rax);
+ r.rbx = context->readIntReg(int_reg::Rbx);
+ r.rcx = context->readIntReg(int_reg::Rcx);
+ r.rdx = context->readIntReg(int_reg::Rdx);
+ r.rsi = context->readIntReg(int_reg::Rsi);
+ r.rdi = context->readIntReg(int_reg::Rdi);
+ r.rbp = context->readIntReg(int_reg::Rbp);
+ r.rsp = context->readIntReg(int_reg::Rsp);
+ r.r8 = context->readIntReg(int_reg::R8);
+ r.r9 = context->readIntReg(int_reg::R9);
+ r.r10 = context->readIntReg(int_reg::R10);
+ r.r11 = context->readIntReg(int_reg::R11);
+ r.r12 = context->readIntReg(int_reg::R12);
+ r.r13 = context->readIntReg(int_reg::R13);
+ r.r14 = context->readIntReg(int_reg::R14);
+ r.r15 = context->readIntReg(int_reg::R15);
r.rip = context->pcState().pc();
r.eflags = context->readMiscRegNoEffect(MISCREG_RFLAGS);
r.cs = context->readMiscRegNoEffect(MISCREG_CS);
@@ -155,14 +155,14 @@
RemoteGDB::X86GdbRegCache::getRegs(ThreadContext *context)
{
DPRINTF(GDBAcc, "getRegs in remotegdb \n");
- r.eax = context->readIntReg(INTREG_RAX);
- r.ecx = context->readIntReg(INTREG_RCX);
- r.edx = context->readIntReg(INTREG_RDX);
- r.ebx = context->readIntReg(INTREG_RBX);
- r.esp = context->readIntReg(INTREG_RSP);
- r.ebp = context->readIntReg(INTREG_RBP);
- r.esi = context->readIntReg(INTREG_RSI);
- r.edi = context->readIntReg(INTREG_RDI);
+ r.eax = context->readIntReg(int_reg::Rax);
+ r.ecx = context->readIntReg(int_reg::Rcx);
+ r.edx = context->readIntReg(int_reg::Rdx);
+ r.ebx = context->readIntReg(int_reg::Rbx);
+ r.esp = context->readIntReg(int_reg::Rsp);
+ r.ebp = context->readIntReg(int_reg::Rbp);
+ r.esi = context->readIntReg(int_reg::Rsi);
+ r.edi = context->readIntReg(int_reg::Rdi);
r.eip = context->pcState().pc();
r.eflags = context->readMiscRegNoEffect(MISCREG_RFLAGS);
r.cs = context->readMiscRegNoEffect(MISCREG_CS);
@@ -177,22 +177,22 @@
RemoteGDB::AMD64GdbRegCache::setRegs(ThreadContext *context) const
{
DPRINTF(GDBAcc, "setRegs in remotegdb \n");
- context->setIntReg(INTREG_RAX, r.rax);
- context->setIntReg(INTREG_RBX, r.rbx);
- context->setIntReg(INTREG_RCX, r.rcx);
- context->setIntReg(INTREG_RDX, r.rdx);
- context->setIntReg(INTREG_RSI, r.rsi);
- context->setIntReg(INTREG_RDI, r.rdi);
- context->setIntReg(INTREG_RBP, r.rbp);
- context->setIntReg(INTREG_RSP, r.rsp);
- context->setIntReg(INTREG_R8, r.r8);
- context->setIntReg(INTREG_R9, r.r9);
- context->setIntReg(INTREG_R10, r.r10);
- context->setIntReg(INTREG_R11, r.r11);
- context->setIntReg(INTREG_R12, r.r12);
- context->setIntReg(INTREG_R13, r.r13);
- context->setIntReg(INTREG_R14, r.r14);
- context->setIntReg(INTREG_R15, r.r15);
+ context->setIntReg(int_reg::Rax, r.rax);
+ context->setIntReg(int_reg::Rbx, r.rbx);
+ context->setIntReg(int_reg::Rcx, r.rcx);
+ context->setIntReg(int_reg::Rdx, r.rdx);
+ context->setIntReg(int_reg::Rsi, r.rsi);
+ context->setIntReg(int_reg::Rdi, r.rdi);
+ context->setIntReg(int_reg::Rbp, r.rbp);
+ context->setIntReg(int_reg::Rsp, r.rsp);
+ context->setIntReg(int_reg::R8, r.r8);
+ context->setIntReg(int_reg::R9, r.r9);
+ context->setIntReg(int_reg::R10, r.r10);
+ context->setIntReg(int_reg::R11, r.r11);
+ context->setIntReg(int_reg::R12, r.r12);
+ context->setIntReg(int_reg::R13, r.r13);
+ context->setIntReg(int_reg::R14, r.r14);
+ context->setIntReg(int_reg::R15, r.r15);
context->pcState(r.rip);
context->setMiscReg(MISCREG_RFLAGS, r.eflags);
if (r.cs != context->readMiscRegNoEffect(MISCREG_CS))
@@ -213,14 +213,14 @@
RemoteGDB::X86GdbRegCache::setRegs(ThreadContext *context) const
{
DPRINTF(GDBAcc, "setRegs in remotegdb \n");
- context->setIntReg(INTREG_RAX, r.eax);
- context->setIntReg(INTREG_RCX, r.ecx);
- context->setIntReg(INTREG_RDX, r.edx);
- context->setIntReg(INTREG_RBX, r.ebx);
- context->setIntReg(INTREG_RSP, r.esp);
- context->setIntReg(INTREG_RBP, r.ebp);
- context->setIntReg(INTREG_RSI, r.esi);
- context->setIntReg(INTREG_RDI, r.edi);
+ context->setIntReg(int_reg::Rax, r.eax);
+ context->setIntReg(int_reg::Rcx, r.ecx);
+ context->setIntReg(int_reg::Rdx, r.edx);
+ context->setIntReg(int_reg::Rbx, r.ebx);
+ context->setIntReg(int_reg::Rsp, r.esp);
+ context->setIntReg(int_reg::Rbp, r.ebp);
+ context->setIntReg(int_reg::Rsi, r.esi);
+ context->setIntReg(int_reg::Rdi, r.edi);
context->pcState(r.eip);
context->setMiscReg(MISCREG_RFLAGS, r.eflags);
if (r.cs != context->readMiscRegNoEffect(MISCREG_CS))
diff --git a/src/cpu/kvm/x86_cpu.cc b/src/cpu/kvm/x86_cpu.cc
index 899bbce..c36f6d8 100644
--- a/src/cpu/kvm/x86_cpu.cc
+++ b/src/cpu/kvm/x86_cpu.cc
@@ -108,24 +108,24 @@
static_assert(sizeof(FXSave) == 512, "Unexpected size of FXSave");
-#define FOREACH_IREG() \
- do { \
- APPLY_IREG(rax, INTREG_RAX); \
- APPLY_IREG(rbx, INTREG_RBX); \
- APPLY_IREG(rcx, INTREG_RCX); \
- APPLY_IREG(rdx, INTREG_RDX); \
- APPLY_IREG(rsi, INTREG_RSI); \
- APPLY_IREG(rdi, INTREG_RDI); \
- APPLY_IREG(rsp, INTREG_RSP); \
- APPLY_IREG(rbp, INTREG_RBP); \
- APPLY_IREG(r8, INTREG_R8); \
- APPLY_IREG(r9, INTREG_R9); \
- APPLY_IREG(r10, INTREG_R10); \
- APPLY_IREG(r11, INTREG_R11); \
- APPLY_IREG(r12, INTREG_R12); \
- APPLY_IREG(r13, INTREG_R13); \
- APPLY_IREG(r14, INTREG_R14); \
- APPLY_IREG(r15, INTREG_R15); \
+#define FOREACH_IREG() \
+ do { \
+ APPLY_IREG(rax, int_reg::Rax); \
+ APPLY_IREG(rbx, int_reg::Rbx); \
+ APPLY_IREG(rcx, int_reg::Rcx); \
+ APPLY_IREG(rdx, int_reg::Rdx); \
+ APPLY_IREG(rsi, int_reg::Rsi); \
+ APPLY_IREG(rdi, int_reg::Rdi); \
+ APPLY_IREG(rsp, int_reg::Rsp); \
+ APPLY_IREG(rbp, int_reg::Rbp); \
+ APPLY_IREG(r8, int_reg::R8); \
+ APPLY_IREG(r9, int_reg::R9); \
+ APPLY_IREG(r10, int_reg::R10); \
+ APPLY_IREG(r11, int_reg::R11); \
+ APPLY_IREG(r12, int_reg::R12); \
+ APPLY_IREG(r13, int_reg::R13); \
+ APPLY_IREG(r14, int_reg::R14); \
+ APPLY_IREG(r15, int_reg::R15); \
} while (0)
#define FOREACH_SREG() \
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49752
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I682a337944f64a1b96b971a1beb895289b9d299e
Gerrit-Change-Number: 49752
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s