X86: Take limitted advantage of the compilers type checking for microop operands.

This commit is contained in:
Gabe Black 2009-07-16 09:29:29 -07:00
parent 80c834ccac
commit ba6b8389ee
12 changed files with 131 additions and 104 deletions

View file

@ -80,13 +80,13 @@ namespace X86ISA
const char *mnem, const char *_instMnem, const char *mnem, const char *_instMnem,
bool isMicro, bool isDelayed, bool isMicro, bool isDelayed,
bool isFirst, bool isLast, bool isFirst, bool isLast,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, int8_t _spm, uint8_t _dataSize, int8_t _spm,
OpClass __opClass) : OpClass __opClass) :
X86MicroopBase(_machInst, mnem, _instMnem, X86MicroopBase(_machInst, mnem, _instMnem,
isMicro, isDelayed, isFirst, isLast, isMicro, isDelayed, isFirst, isLast,
__opClass), __opClass),
src1(_src1), src2(_src2), dest(_dest), src1(_src1.idx), src2(_src2.idx), dest(_dest.idx),
dataSize(_dataSize), spm(_spm) dataSize(_dataSize), spm(_spm)
{} {}
/* /*

View file

@ -93,20 +93,21 @@ namespace X86ISA
LdStOp(ExtMachInst _machInst, LdStOp(ExtMachInst _machInst,
const char * mnem, const char * _instMnem, const char * mnem, const char * _instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
uint8_t _scale, RegIndex _index, RegIndex _base, uint8_t _scale, InstRegIndex _index, InstRegIndex _base,
uint64_t _disp, uint8_t _segment, uint64_t _disp, InstRegIndex _segment,
RegIndex _data, InstRegIndex _data,
uint8_t _dataSize, uint8_t _addressSize, uint8_t _dataSize, uint8_t _addressSize,
Request::FlagsType _memFlags, Request::FlagsType _memFlags,
OpClass __opClass) : OpClass __opClass) :
X86MicroopBase(machInst, mnem, _instMnem, X86MicroopBase(machInst, mnem, _instMnem,
isMicro, isDelayed, isFirst, isLast, __opClass), isMicro, isDelayed, isFirst, isLast, __opClass),
scale(_scale), index(_index), base(_base), scale(_scale), index(_index.idx), base(_base.idx),
disp(_disp), segment(_segment), disp(_disp), segment(_segment.idx),
data(_data), data(_data.idx),
dataSize(_dataSize), addressSize(_addressSize), dataSize(_dataSize), addressSize(_addressSize),
memFlags(_memFlags | _segment) memFlags(_memFlags | _segment.idx)
{ {
assert(_segment.idx < NUM_SEGMENTREGS);
foldOBit = (dataSize == 1 && !_machInst.rex.present) ? 1 << 6 : 0; foldOBit = (dataSize == 1 && !_machInst.rex.present) ? 1 << 6 : 0;
foldABit = foldABit =
(addressSize == 1 && !_machInst.rex.present) ? 1 << 6 : 0; (addressSize == 1 && !_machInst.rex.present) ? 1 << 6 : 0;

View file

@ -79,13 +79,13 @@ namespace X86ISA
const char *mnem, const char *_instMnem, const char *mnem, const char *_instMnem,
bool isMicro, bool isDelayed, bool isMicro, bool isDelayed,
bool isFirst, bool isLast, bool isFirst, bool isLast,
RegIndex _src1, RegIndex _dest, InstRegIndex _src1, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext, uint8_t _dataSize, uint16_t _ext,
OpClass __opClass) : OpClass __opClass) :
X86MicroopBase(_machInst, mnem, _instMnem, X86MicroopBase(_machInst, mnem, _instMnem,
isMicro, isDelayed, isFirst, isLast, isMicro, isDelayed, isFirst, isLast,
__opClass), __opClass),
src1(_src1), dest(_dest), src1(_src1.idx), dest(_dest.idx),
dataSize(_dataSize), ext(_ext) dataSize(_dataSize), ext(_ext)
{ {
foldOBit = (dataSize == 1 && !_machInst.rex.present) ? 1 << 6 : 0; foldOBit = (dataSize == 1 && !_machInst.rex.present) ? 1 << 6 : 0;
@ -107,14 +107,14 @@ namespace X86ISA
const char *mnem, const char *_instMnem, const char *mnem, const char *_instMnem,
bool isMicro, bool isDelayed, bool isMicro, bool isDelayed,
bool isFirst, bool isLast, bool isFirst, bool isLast,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext, uint8_t _dataSize, uint16_t _ext,
OpClass __opClass) : OpClass __opClass) :
RegOpBase(_machInst, mnem, _instMnem, RegOpBase(_machInst, mnem, _instMnem,
isMicro, isDelayed, isFirst, isLast, isMicro, isDelayed, isFirst, isLast,
_src1, _dest, _dataSize, _ext, _src1, _dest, _dataSize, _ext,
__opClass), __opClass),
src2(_src2) src2(_src2.idx)
{ {
} }
@ -132,7 +132,7 @@ namespace X86ISA
const char * mnem, const char *_instMnem, const char * mnem, const char *_instMnem,
bool isMicro, bool isDelayed, bool isMicro, bool isDelayed,
bool isFirst, bool isLast, bool isFirst, bool isLast,
RegIndex _src1, uint8_t _imm8, RegIndex _dest, InstRegIndex _src1, uint8_t _imm8, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext, uint8_t _dataSize, uint16_t _ext,
OpClass __opClass) : OpClass __opClass) :
RegOpBase(_machInst, mnem, _instMnem, RegOpBase(_machInst, mnem, _instMnem,

View file

@ -63,6 +63,18 @@
namespace X86ISA namespace X86ISA
{ {
/**
* Class for register indices passed to instruction constructors. Using a
* wrapper struct for these lets take advantage of the compiler's type
* checking.
*/
struct InstRegIndex
{
RegIndex idx;
explicit InstRegIndex(RegIndex _idx) : idx(_idx)
{}
};
/** /**
* Base class for all X86 static instructions. * Base class for all X86 static instructions.
*/ */

View file

@ -109,6 +109,8 @@ output header {{
#include "cpu/static_inst.hh" #include "cpu/static_inst.hh"
#include "mem/packet.hh" #include "mem/packet.hh"
#include "sim/faults.hh" #include "sim/faults.hh"
using X86ISA::InstRegIndex;
}}; }};
output decoder {{ output decoder {{

View file

@ -28,58 +28,58 @@
microcode = ''' microcode = '''
def macroop CLTS { def macroop CLTS {
rdcr t1, 0, dataSize=8 rdcr t1, regIdx(0), dataSize=8
andi t1, t1, 0xF7, dataSize=1 andi t1, t1, 0xF7, dataSize=1
wrcr 0, t1, dataSize=8 wrcr regIdx(0), t1, dataSize=8
}; };
def macroop LMSW_R { def macroop LMSW_R {
rdcr t1, 0, dataSize=8 rdcr t1, regIdx(0), dataSize=8
# This logic sets MP, EM, and TS to whatever is in the operand. It will # This logic sets MP, EM, and TS to whatever is in the operand. It will
# set PE but not clear it. # set PE but not clear it.
limm t2, "~ULL(0xe)", dataSize=8 limm t2, "~ULL(0xe)", dataSize=8
and t1, t1, t2, dataSize=8 and t1, t1, t2, dataSize=8
andi t2, reg, 0xf, dataSize=8 andi t2, reg, 0xf, dataSize=8
or t1, t1, t2, dataSize=8 or t1, t1, t2, dataSize=8
wrcr 0, t1, dataSize=8 wrcr regIdx(0), t1, dataSize=8
}; };
def macroop LMSW_M { def macroop LMSW_M {
ld t3, seg, sib, disp, dataSize=2 ld t3, seg, sib, disp, dataSize=2
rdcr t1, 0, dataSize=8 rdcr t1, regIdx(0), dataSize=8
# This logic sets MP, EM, and TS to whatever is in the operand. It will # This logic sets MP, EM, and TS to whatever is in the operand. It will
# set PE but not clear it. # set PE but not clear it.
limm t2, "~ULL(0xe)", dataSize=8 limm t2, "~ULL(0xe)", dataSize=8
and t1, t1, t2, dataSize=8 and t1, t1, t2, dataSize=8
andi t2, t3, 0xf, dataSize=8 andi t2, t3, 0xf, dataSize=8
or t1, t1, t2, dataSize=8 or t1, t1, t2, dataSize=8
wrcr 0, t1, dataSize=8 wrcr regIdx(0), t1, dataSize=8
}; };
def macroop LMSW_P { def macroop LMSW_P {
rdip t7, dataSize=asz rdip t7, dataSize=asz
ld t3, seg, riprel, disp, dataSize=2 ld t3, seg, riprel, disp, dataSize=2
rdcr t1, 0, dataSize=8 rdcr t1, regIdx(0), dataSize=8
# This logic sets MP, EM, and TS to whatever is in the operand. It will # This logic sets MP, EM, and TS to whatever is in the operand. It will
# set PE but not clear it. # set PE but not clear it.
limm t2, "~ULL(0xe)", dataSize=8 limm t2, "~ULL(0xe)", dataSize=8
and t1, t1, t2, dataSize=8 and t1, t1, t2, dataSize=8
andi t2, t3, 0xf, dataSize=8 andi t2, t3, 0xf, dataSize=8
or t1, t1, t2, dataSize=8 or t1, t1, t2, dataSize=8
wrcr 0, t1, dataSize=8 wrcr regIdx(0), t1, dataSize=8
}; };
def macroop SMSW_R { def macroop SMSW_R {
rdcr reg, 0 rdcr reg, regIdx(0)
}; };
def macroop SMSW_M { def macroop SMSW_M {
rdcr t1, 0 rdcr t1, regIdx(0)
st t1, seg, sib, disp, dataSize=2 st t1, seg, sib, disp, dataSize=2
}; };
def macroop SMSW_P { def macroop SMSW_P {
rdcr t1, 0 rdcr t1, regIdx(0)
rdip t7, dataSize=asz rdip t7, dataSize=asz
st t1, seg, riprel, disp, dataSize=2 st t1, seg, riprel, disp, dataSize=2
}; };

View file

@ -75,14 +75,22 @@ let {{
from micro_asm import MicroAssembler, Rom_Macroop from micro_asm import MicroAssembler, Rom_Macroop
mainRom = X86MicrocodeRom('main ROM') mainRom = X86MicrocodeRom('main ROM')
assembler = MicroAssembler(X86Macroop, microopClasses, mainRom, Rom_Macroop) assembler = MicroAssembler(X86Macroop, microopClasses, mainRom, Rom_Macroop)
def regIdx(idx):
return "InstRegIndex(%s)" % idx
assembler.symbols["regIdx"] = regIdx
# Add in symbols for the microcode registers # Add in symbols for the microcode registers
for num in range(16): for num in range(16):
assembler.symbols["t%d" % num] = "NUM_INTREGS+%d" % num assembler.symbols["t%d" % num] = regIdx("NUM_INTREGS+%d" % num)
for num in range(8): for num in range(8):
assembler.symbols["ufp%d" % num] = "FLOATREG_MICROFP(%d)" % num assembler.symbols["ufp%d" % num] = \
regIdx("FLOATREG_MICROFP(%d)" % num)
# Add in symbols for the segment descriptor registers # Add in symbols for the segment descriptor registers
for letter in ("C", "D", "E", "F", "G", "H", "S"): for letter in ("C", "D", "E", "F", "G", "H", "S"):
assembler.symbols["%ss" % letter.lower()] = "SEGMENT_REG_%sS" % letter assembler.symbols["%ss" % letter.lower()] = \
regIdx("SEGMENT_REG_%sS" % letter)
# Add in symbols for the various checks of segment selectors. # Add in symbols for the various checks of segment selectors.
for check in ("NoCheck", "CSCheck", "CallGateCheck", "IntGateCheck", for check in ("NoCheck", "CSCheck", "CallGateCheck", "IntGateCheck",
@ -91,25 +99,25 @@ let {{
assembler.symbols[check] = "Seg%s" % check assembler.symbols[check] = "Seg%s" % check
for reg in ("TR", "IDTR"): for reg in ("TR", "IDTR"):
assembler.symbols[reg.lower()] = "SYS_SEGMENT_REG_%s" % reg assembler.symbols[reg.lower()] = regIdx("SYS_SEGMENT_REG_%s" % reg)
for reg in ("TSL", "TSG"): for reg in ("TSL", "TSG"):
assembler.symbols[reg.lower()] = "SEGMENT_REG_%s" % reg assembler.symbols[reg.lower()] = regIdx("SEGMENT_REG_%s" % reg)
# Miscellaneous symbols # Miscellaneous symbols
symbols = { symbols = {
"reg" : "env.reg", "reg" : regIdx("env.reg"),
"xmml" : "FLOATREG_XMM_LOW(env.reg)", "xmml" : regIdx("FLOATREG_XMM_LOW(env.reg)"),
"xmmh" : "FLOATREG_XMM_HIGH(env.reg)", "xmmh" : regIdx("FLOATREG_XMM_HIGH(env.reg)"),
"regm" : "env.regm", "regm" : regIdx("env.regm"),
"xmmlm" : "FLOATREG_XMM_LOW(env.regm)", "xmmlm" : regIdx("FLOATREG_XMM_LOW(env.regm)"),
"xmmhm" : "FLOATREG_XMM_HIGH(env.regm)", "xmmhm" : regIdx("FLOATREG_XMM_HIGH(env.regm)"),
"imm" : "adjustedImm", "imm" : "adjustedImm",
"disp" : "adjustedDisp", "disp" : "adjustedDisp",
"seg" : "env.seg", "seg" : regIdx("env.seg"),
"scale" : "env.scale", "scale" : "env.scale",
"index" : "env.index", "index" : regIdx("env.index"),
"base" : "env.base", "base" : regIdx("env.base"),
"dsz" : "env.dataSize", "dsz" : "env.dataSize",
"asz" : "env.addressSize", "asz" : "env.addressSize",
"ssz" : "env.stackSize" "ssz" : "env.stackSize"
@ -133,17 +141,18 @@ let {{
# This segment selects an internal address space mapped to MSRs, # This segment selects an internal address space mapped to MSRs,
# CPUID info, etc. # CPUID info, etc.
assembler.symbols["intseg"] = "SEGMENT_REG_MS" assembler.symbols["intseg"] = regIdx("SEGMENT_REG_MS")
# This segment always has base 0, and doesn't imply any special handling # This segment always has base 0, and doesn't imply any special handling
# like the internal segment above # like the internal segment above
assembler.symbols["flatseg"] = "SEGMENT_REG_LS" assembler.symbols["flatseg"] = regIdx("SEGMENT_REG_LS")
for reg in ('ax', 'bx', 'cx', 'dx', 'sp', 'bp', 'si', 'di', \ for reg in ('ax', 'bx', 'cx', 'dx', 'sp', 'bp', 'si', 'di', \
'8', '9', '10', '11', '12', '13', '14', '15'): '8', '9', '10', '11', '12', '13', '14', '15'):
assembler.symbols["r%s" % reg] = "INTREG_R%s" % reg.upper() assembler.symbols["r%s" % reg] = \
regIdx("INTREG_R%s" % reg.upper())
for reg in range(16): for reg in range(16):
assembler.symbols["cr%d" % reg] = "MISCREG_CR%d" % reg assembler.symbols["cr%d" % reg] = regIdx("MISCREG_CR%d" % reg)
for flag in ('CF', 'PF', 'ECF', 'AF', 'EZF', 'ZF', 'SF', 'OF', \ for flag in ('CF', 'PF', 'ECF', 'AF', 'EZF', 'ZF', 'SF', 'OF', \
'TF', 'IF', 'NT', 'RF', 'VM', 'AC', 'VIF', 'VIP', 'ID'): 'TF', 'IF', 'NT', 'RF', 'VM', 'AC', 'VIF', 'VIP', 'ID'):
@ -164,7 +173,7 @@ let {{
for reg in ('sysenter_cs', 'sysenter_esp', 'sysenter_eip', for reg in ('sysenter_cs', 'sysenter_esp', 'sysenter_eip',
'star', 'lstar', 'cstar', 'sf_mask', 'star', 'lstar', 'cstar', 'sf_mask',
'kernel_gs_base'): 'kernel_gs_base'):
assembler.symbols[reg] = "MISCREG_%s" % reg.upper() assembler.symbols[reg] = regIdx("MISCREG_%s" % reg.upper())
# Code literal which forces a default 64 bit operand size in 64 bit mode. # Code literal which forces a default 64 bit operand size in 64 bit mode.
assembler.symbols["oszIn64Override"] = ''' assembler.symbols["oszIn64Override"] = '''
@ -201,7 +210,7 @@ let {{
assembler.symbols["rom_local_label"] = rom_local_labeler assembler.symbols["rom_local_label"] = rom_local_labeler
def stack_index(index): def stack_index(index):
return "(NUM_FLOATREGS + (((%s) + 8) %% 8))" % index return regIdx("NUM_FLOATREGS + (((%s) + 8) %% 8)" % index)
assembler.symbols["st"] = stack_index assembler.symbols["st"] = stack_index

View file

@ -86,7 +86,7 @@ let {{
const EmulEnv &env = const EmulEnv &env =
macroop ? macroop->getEmulEnv() : dummyEmulEnv; macroop ? macroop->getEmulEnv() : dummyEmulEnv;
// env may not be used in the microop's constructor. // env may not be used in the microop's constructor.
RegIndex reg = env.reg; InstRegIndex reg(env.reg);
reg = reg; reg = reg;
using namespace RomLabels; using namespace RomLabels;
return %s; return %s;

View file

@ -99,12 +99,12 @@ def template MicroFpOpDeclare {{
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, int8_t _spm); uint8_t _dataSize, int8_t _spm);
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, int8_t _spm); uint8_t _dataSize, int8_t _spm);
%(BasicExecDeclare)s %(BasicExecDeclare)s
@ -120,7 +120,7 @@ def template MicroFpOpConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, int8_t _spm) : uint8_t _dataSize, int8_t _spm) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
false, false, false, false, false, false, false, false,
@ -133,7 +133,7 @@ def template MicroFpOpConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, int8_t _spm) : uint8_t _dataSize, int8_t _spm) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
isMicro, isDelayed, isFirst, isLast, isMicro, isDelayed, isFirst, isLast,
@ -256,9 +256,9 @@ let {{
"spm" : self.spm} "spm" : self.spm}
class Movfp(FpOp): class Movfp(FpOp):
def __init__(self, dest, src1, flags=0, spm=0, \ def __init__(self, dest, src1, spm=0, \
SetStatus=False, dataSize="env.dataSize"): SetStatus=False, dataSize="env.dataSize"):
super(Movfp, self).__init__(dest, src1, flags, \ super(Movfp, self).__init__(dest, src1, "InstRegIndex(0)", \
spm, SetStatus, dataSize) spm, SetStatus, dataSize)
code = 'FpDestReg.uqw = FpSrcReg1.uqw;' code = 'FpDestReg.uqw = FpSrcReg1.uqw;'
else_code = 'FpDestReg.uqw = FpDestReg.uqw;' else_code = 'FpDestReg.uqw = FpDestReg.uqw;'
@ -274,7 +274,8 @@ let {{
class ConvOp(FpOp): class ConvOp(FpOp):
abstract = True abstract = True
def __init__(self, dest, src1): def __init__(self, dest, src1):
super(ConvOp, self).__init__(dest, src1, "(int)FLOATREG_MICROFP0") super(ConvOp, self).__init__(dest, src1, \
"InstRegIndex(FLOATREG_MICROFP0)")
# These probably shouldn't look at the ExtMachInst directly to figure # These probably shouldn't look at the ExtMachInst directly to figure
# out what size to use and should instead delegate that to the macroop's # out what size to use and should instead delegate that to the macroop's
@ -318,7 +319,7 @@ let {{
class Compfp(FpOp): class Compfp(FpOp):
def __init__(self, src1, src2, spm=0, setStatus=False, \ def __init__(self, src1, src2, spm=0, setStatus=False, \
dataSize="env.dataSize"): dataSize="env.dataSize"):
super(Compfp, self).__init__("(int)FLOATREG_MICROFP0", \ super(Compfp, self).__init__("InstRegIndex(FLOATREG_MICROFP0)", \
src1, src2, spm, setStatus, dataSize) src1, src2, spm, setStatus, dataSize)
# This class sets the condition codes in rflags according to the # This class sets the condition codes in rflags according to the
# rules for comparing floating point. # rules for comparing floating point.

View file

@ -121,17 +121,17 @@ def template MicroLeaDeclare {{
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
uint8_t _scale, RegIndex _index, RegIndex _base, uint8_t _scale, InstRegIndex _index, InstRegIndex _base,
uint64_t _disp, uint8_t _segment, uint64_t _disp, InstRegIndex _segment,
RegIndex _data, InstRegIndex _data,
uint8_t _dataSize, uint8_t _addressSize, uint8_t _dataSize, uint8_t _addressSize,
Request::FlagsType _memFlags); Request::FlagsType _memFlags);
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
uint8_t _scale, RegIndex _index, RegIndex _base, uint8_t _scale, InstRegIndex _index, InstRegIndex _base,
uint64_t _disp, uint8_t _segment, uint64_t _disp, InstRegIndex _segment,
RegIndex _data, InstRegIndex _data,
uint8_t _dataSize, uint8_t _addressSize, uint8_t _dataSize, uint8_t _addressSize,
Request::FlagsType _memFlags); Request::FlagsType _memFlags);
@ -297,17 +297,17 @@ def template MicroLdStOpDeclare {{
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
uint8_t _scale, RegIndex _index, RegIndex _base, uint8_t _scale, InstRegIndex _index, InstRegIndex _base,
uint64_t _disp, uint8_t _segment, uint64_t _disp, InstRegIndex _segment,
RegIndex _data, InstRegIndex _data,
uint8_t _dataSize, uint8_t _addressSize, uint8_t _dataSize, uint8_t _addressSize,
Request::FlagsType _memFlags); Request::FlagsType _memFlags);
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
uint8_t _scale, RegIndex _index, RegIndex _base, uint8_t _scale, InstRegIndex _index, InstRegIndex _base,
uint64_t _disp, uint8_t _segment, uint64_t _disp, InstRegIndex _segment,
RegIndex _data, InstRegIndex _data,
uint8_t _dataSize, uint8_t _addressSize, uint8_t _dataSize, uint8_t _addressSize,
Request::FlagsType _memFlags); Request::FlagsType _memFlags);
@ -328,9 +328,9 @@ def template MicroLdStOpConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
uint8_t _scale, RegIndex _index, RegIndex _base, uint8_t _scale, InstRegIndex _index, InstRegIndex _base,
uint64_t _disp, uint8_t _segment, uint64_t _disp, InstRegIndex _segment,
RegIndex _data, InstRegIndex _data,
uint8_t _dataSize, uint8_t _addressSize, uint8_t _dataSize, uint8_t _addressSize,
Request::FlagsType _memFlags) : Request::FlagsType _memFlags) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
@ -345,9 +345,9 @@ def template MicroLdStOpConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
uint8_t _scale, RegIndex _index, RegIndex _base, uint8_t _scale, InstRegIndex _index, InstRegIndex _base,
uint64_t _disp, uint8_t _segment, uint64_t _disp, InstRegIndex _segment,
RegIndex _data, InstRegIndex _data,
uint8_t _dataSize, uint8_t _addressSize, uint8_t _dataSize, uint8_t _addressSize,
Request::FlagsType _memFlags) : Request::FlagsType _memFlags) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
@ -517,7 +517,7 @@ let {{
def __init__(self, segment, addr, disp = 0, def __init__(self, segment, addr, disp = 0,
dataSize="env.dataSize", dataSize="env.dataSize",
addressSize="env.addressSize"): addressSize="env.addressSize"):
super(TiaOp, self).__init__("NUM_INTREGS", segment, super(TiaOp, self).__init__("InstRegIndex(NUM_INTREGS)", segment,
addr, disp, dataSize, addressSize, "0", False, False) addr, disp, dataSize, addressSize, "0", False, False)
self.className = "Tia" self.className = "Tia"
self.mnemonic = "tia" self.mnemonic = "tia"
@ -528,7 +528,7 @@ let {{
def __init__(self, segment, addr, disp = 0, def __init__(self, segment, addr, disp = 0,
dataSize="env.dataSize", dataSize="env.dataSize",
addressSize="env.addressSize", atCPL0=False): addressSize="env.addressSize", atCPL0=False):
super(CdaOp, self).__init__("NUM_INTREGS", segment, super(CdaOp, self).__init__("InstRegIndex(NUM_INTREGS)", segment,
addr, disp, dataSize, addressSize, "0", atCPL0, False) addr, disp, dataSize, addressSize, "0", atCPL0, False)
self.className = "Cda" self.className = "Cda"
self.mnemonic = "cda" self.mnemonic = "cda"

View file

@ -88,11 +88,11 @@ def template MicroLimmOpDeclare {{
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
RegIndex _dest, uint64_t _imm, uint8_t _dataSize); InstRegIndex _dest, uint64_t _imm, uint8_t _dataSize);
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
RegIndex _dest, uint64_t _imm, uint8_t _dataSize); InstRegIndex _dest, uint64_t _imm, uint8_t _dataSize);
%(BasicExecDeclare)s %(BasicExecDeclare)s
}; };
@ -122,10 +122,10 @@ def template MicroLimmOpConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
RegIndex _dest, uint64_t _imm, uint8_t _dataSize) : InstRegIndex _dest, uint64_t _imm, uint8_t _dataSize) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
false, false, false, false, %(op_class)s), false, false, false, false, %(op_class)s),
dest(_dest), imm(_imm), dataSize(_dataSize) dest(_dest.idx), imm(_imm), dataSize(_dataSize)
{ {
buildMe(); buildMe();
} }
@ -133,10 +133,10 @@ def template MicroLimmOpConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
RegIndex _dest, uint64_t _imm, uint8_t _dataSize) : InstRegIndex _dest, uint64_t _imm, uint8_t _dataSize) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
isMicro, isDelayed, isFirst, isLast, %(op_class)s), isMicro, isDelayed, isFirst, isLast, %(op_class)s),
dest(_dest), imm(_imm), dataSize(_dataSize) dest(_dest.idx), imm(_imm), dataSize(_dataSize)
{ {
buildMe(); buildMe();
} }

View file

@ -126,12 +126,12 @@ def template MicroRegOpDeclare {{
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext); uint8_t _dataSize, uint16_t _ext);
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext); uint8_t _dataSize, uint16_t _ext);
%(BasicExecDeclare)s %(BasicExecDeclare)s
@ -149,12 +149,12 @@ def template MicroRegOpImmDeclare {{
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
RegIndex _src1, uint16_t _imm8, RegIndex _dest, InstRegIndex _src1, uint16_t _imm8, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext); uint8_t _dataSize, uint16_t _ext);
%(class_name)s(ExtMachInst _machInst, %(class_name)s(ExtMachInst _machInst,
const char * instMnem, const char * instMnem,
RegIndex _src1, uint16_t _imm8, RegIndex _dest, InstRegIndex _src1, uint16_t _imm8, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext); uint8_t _dataSize, uint16_t _ext);
%(BasicExecDeclare)s %(BasicExecDeclare)s
@ -170,7 +170,7 @@ def template MicroRegOpConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext) : uint8_t _dataSize, uint16_t _ext) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
false, false, false, false, false, false, false, false,
@ -183,7 +183,7 @@ def template MicroRegOpConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
RegIndex _src1, RegIndex _src2, RegIndex _dest, InstRegIndex _src1, InstRegIndex _src2, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext) : uint8_t _dataSize, uint16_t _ext) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
isMicro, isDelayed, isFirst, isLast, isMicro, isDelayed, isFirst, isLast,
@ -203,7 +203,7 @@ def template MicroRegOpImmConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
RegIndex _src1, uint16_t _imm8, RegIndex _dest, InstRegIndex _src1, uint16_t _imm8, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext) : uint8_t _dataSize, uint16_t _ext) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
false, false, false, false, false, false, false, false,
@ -216,7 +216,7 @@ def template MicroRegOpImmConstructor {{
inline %(class_name)s::%(class_name)s( inline %(class_name)s::%(class_name)s(
ExtMachInst machInst, const char * instMnem, ExtMachInst machInst, const char * instMnem,
bool isMicro, bool isDelayed, bool isFirst, bool isLast, bool isMicro, bool isDelayed, bool isFirst, bool isLast,
RegIndex _src1, uint16_t _imm8, RegIndex _dest, InstRegIndex _src1, uint16_t _imm8, InstRegIndex _dest,
uint8_t _dataSize, uint16_t _ext) : uint8_t _dataSize, uint16_t _ext) :
%(base_class)s(machInst, "%(mnemonic)s", instMnem, %(base_class)s(machInst, "%(mnemonic)s", instMnem,
isMicro, isDelayed, isFirst, isLast, isMicro, isDelayed, isFirst, isLast,
@ -481,12 +481,14 @@ let {{
def __init__(self, dest, src1=None, dataSize="env.dataSize"): def __init__(self, dest, src1=None, dataSize="env.dataSize"):
if not src1: if not src1:
src1 = dest src1 = dest
super(RdRegOp, self).__init__(dest, src1, "NUM_INTREGS", None, dataSize) super(RdRegOp, self).__init__(dest, src1, \
"InstRegIndex(NUM_INTREGS)", None, dataSize)
class WrRegOp(RegOp): class WrRegOp(RegOp):
abstract = True abstract = True
def __init__(self, src1, src2, flags=None, dataSize="env.dataSize"): def __init__(self, src1, src2, flags=None, dataSize="env.dataSize"):
super(WrRegOp, self).__init__("NUM_INTREGS", src1, src2, flags, dataSize) super(WrRegOp, self).__init__("InstRegIndex(NUM_INTREGS)", \
src1, src2, flags, dataSize)
class Add(FlagRegOp): class Add(FlagRegOp):
code = 'DestReg = merge(DestReg, psrc1 + op2, dataSize);' code = 'DestReg = merge(DestReg, psrc1 + op2, dataSize);'
@ -553,7 +555,8 @@ let {{
def __init__(self, dest, src1=None, flags=None, dataSize="env.dataSize"): def __init__(self, dest, src1=None, flags=None, dataSize="env.dataSize"):
if not src1: if not src1:
src1 = dest src1 = dest
super(RdRegOp, self).__init__(dest, src1, "NUM_INTREGS", flags, dataSize) super(RdRegOp, self).__init__(dest, src1, \
"InstRegIndex(NUM_INTREGS)", flags, dataSize)
code = 'DestReg = merge(SrcReg1, ProdHi, dataSize);' code = 'DestReg = merge(SrcReg1, ProdHi, dataSize);'
flag_code = ''' flag_code = '''
if (ProdHi) if (ProdHi)
@ -885,7 +888,7 @@ let {{
def __init__(self, dest, imm, flags=None, \ def __init__(self, dest, imm, flags=None, \
dataSize="env.dataSize"): dataSize="env.dataSize"):
super(Ruflag, self).__init__(dest, \ super(Ruflag, self).__init__(dest, \
"NUM_INTREGS", imm, flags, dataSize) "InstRegIndex(NUM_INTREGS)", imm, flags, dataSize)
class Rflag(RegOp): class Rflag(RegOp):
code = ''' code = '''
@ -899,7 +902,7 @@ let {{
def __init__(self, dest, imm, flags=None, \ def __init__(self, dest, imm, flags=None, \
dataSize="env.dataSize"): dataSize="env.dataSize"):
super(Rflag, self).__init__(dest, \ super(Rflag, self).__init__(dest, \
"NUM_INTREGS", imm, flags, dataSize) "InstRegIndex(NUM_INTREGS)", imm, flags, dataSize)
class Sext(RegOp): class Sext(RegOp):
code = ''' code = '''
@ -926,7 +929,7 @@ let {{
class Rddr(RegOp): class Rddr(RegOp):
def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"): def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"):
super(Rddr, self).__init__(dest, \ super(Rddr, self).__init__(dest, \
src1, "NUM_INTREGS", flags, dataSize) src1, "InstRegIndex(NUM_INTREGS)", flags, dataSize)
code = ''' code = '''
CR4 cr4 = CR4Op; CR4 cr4 = CR4Op;
DR7 dr7 = DR7Op; DR7 dr7 = DR7Op;
@ -942,14 +945,13 @@ let {{
class Wrdr(RegOp): class Wrdr(RegOp):
def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"): def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"):
super(Wrdr, self).__init__(dest, \ super(Wrdr, self).__init__(dest, \
src1, "NUM_INTREGS", flags, dataSize) src1, "InstRegIndex(NUM_INTREGS)", flags, dataSize)
code = ''' code = '''
CR4 cr4 = CR4Op; CR4 cr4 = CR4Op;
DR7 dr7 = DR7Op; DR7 dr7 = DR7Op;
if ((cr4.de == 1 && (dest == 4 || dest == 5)) || dest >= 8) { if ((cr4.de == 1 && (dest == 4 || dest == 5)) || dest >= 8) {
fault = new InvalidOpcode(); fault = new InvalidOpcode();
} else if ((dest == 6 || dest == 7) && } else if ((dest == 6 || dest == 7) && bits(psrc1, 63, 32) &&
bits(psrc1, 63, 32) &&
machInst.mode.mode == LongMode) { machInst.mode.mode == LongMode) {
fault = new GeneralProtection(0); fault = new GeneralProtection(0);
} else if (dr7.gd) { } else if (dr7.gd) {
@ -962,7 +964,7 @@ let {{
class Rdcr(RegOp): class Rdcr(RegOp):
def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"): def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"):
super(Rdcr, self).__init__(dest, \ super(Rdcr, self).__init__(dest, \
src1, "NUM_INTREGS", flags, dataSize) src1, "InstRegIndex(NUM_INTREGS)", flags, dataSize)
code = ''' code = '''
if (src1 == 1 || (src1 > 4 && src1 < 8) || (src1 > 8)) { if (src1 == 1 || (src1 > 4 && src1 < 8) || (src1 > 8)) {
fault = new InvalidOpcode(); fault = new InvalidOpcode();
@ -974,7 +976,7 @@ let {{
class Wrcr(RegOp): class Wrcr(RegOp):
def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"): def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"):
super(Wrcr, self).__init__(dest, \ super(Wrcr, self).__init__(dest, \
src1, "NUM_INTREGS", flags, dataSize) src1, "InstRegIndex(NUM_INTREGS)", flags, dataSize)
code = ''' code = '''
if (dest == 1 || (dest > 4 && dest < 8) || (dest > 8)) { if (dest == 1 || (dest > 4 && dest < 8) || (dest > 8)) {
fault = new InvalidOpcode(); fault = new InvalidOpcode();
@ -1028,7 +1030,7 @@ let {{
abstract = True abstract = True
def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"): def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"):
super(SegOp, self).__init__(dest, \ super(SegOp, self).__init__(dest, \
src1, "NUM_INTREGS", flags, dataSize) src1, "InstRegIndex(NUM_INTREGS)", flags, dataSize)
class Wrbase(SegOp): class Wrbase(SegOp):
code = ''' code = '''
@ -1072,16 +1074,16 @@ let {{
class Rdval(RegOp): class Rdval(RegOp):
def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"): def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"):
super(Rdval, self).__init__(dest, \ super(Rdval, self).__init__(dest, src1, \
src1, "NUM_INTREGS", flags, dataSize) "InstRegIndex(NUM_INTREGS)", flags, dataSize)
code = ''' code = '''
DestReg = MiscRegSrc1; DestReg = MiscRegSrc1;
''' '''
class Wrval(RegOp): class Wrval(RegOp):
def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"): def __init__(self, dest, src1, flags=None, dataSize="env.dataSize"):
super(Wrval, self).__init__(dest, \ super(Wrval, self).__init__(dest, src1, \
src1, "NUM_INTREGS", flags, dataSize) "InstRegIndex(NUM_INTREGS)", flags, dataSize)
code = ''' code = '''
MiscRegDest = SrcReg1; MiscRegDest = SrcReg1;
''' '''