class FpOpMeta(type):
def buildCppClasses(self, name, Name, suffix, \
- code, flag_code, cond_check, else_code):
+ code, flag_code, cond_check, else_code, op_class):
# Globals to stick the output in
global header_output
# a version without it and fix up this version to use it.
if flag_code is not "" or cond_check is not "true":
self.buildCppClasses(name, Name, suffix,
- code, "", "true", else_code)
+ code, "", "true", else_code, op_class)
suffix = "Flags" + suffix
base = "X86ISA::FpOp"
"flag_code" : flag_code,
"cond_check" : cond_check,
"else_code" : else_code,
- "top_code" : "TOP = (TOP + spm + 8) % 8;"})
+ "top_code" : "TOP = (TOP + spm + 8) % 8;",
+ "op_class" : op_class})
iop = InstObjParams(name, Name + suffix, base,
{"code" : code,
"flag_code" : flag_code,
"cond_check" : cond_check,
"else_code" : else_code,
- "top_code" : ";"})
+ "top_code" : ";",
+ "op_class" : op_class})
# Generate the actual code (finally!)
header_output += MicroFpOpDeclare.subst(iop_top)
flag_code = cls.flag_code
cond_check = cls.cond_check
else_code = cls.else_code
+ op_class = cls.op_class
# Set up the C++ classes
mcls.buildCppClasses(cls, name, Name, "",
- code, flag_code, cond_check, else_code)
+ code, flag_code, cond_check, else_code, op_class)
# Hook into the microassembler dict
global microopClasses
flag_code = ""
cond_check = "true"
else_code = ";"
+ op_class = "FloatAddOp"
def __init__(self, dest, src1, spm=0, \
SetStatus=False, dataSize="env.dataSize"):
flag_code = ""
cond_check = "true"
else_code = ";"
+ op_class = "FloatAddOp"
def __init__(self, dest, src1, src2, spm=0, \
SetStatus=False, dataSize="env.dataSize"):
class Sqrtfp(FpBinaryOp):
code = 'FpDestReg = sqrt(FpSrcReg2);'
+ op_class = 'FloatSqrtOp'
class Cosfp(FpUnaryOp):
code = 'FpDestReg = cos(FpSrcReg1);'
+ op_class = 'FloatSqrtOp'
class Sinfp(FpUnaryOp):
code = 'FpDestReg = sin(FpSrcReg1);'
+ op_class = 'FloatSqrtOp'
class Tanfp(FpUnaryOp):
code = 'FpDestReg = tan(FpSrcReg1);'
+ op_class = 'FloatSqrtOp'
# Conversion microops
class ConvOp(FpBinaryOp):
abstract = True
+ op_class = 'FloatCvtOp'
def __init__(self, dest, src1):
super(ConvOp, self).__init__(dest, src1, \
"InstRegIndex(FLOATREG_MICROFP0)")
class mulfp(FpBinaryOp):
code = 'FpDestReg = FpSrcReg1 * FpSrcReg2;'
+ op_class = 'FloatMultOp'
class divfp(FpBinaryOp):
code = 'FpDestReg = FpSrcReg1 / FpSrcReg2;'
+ op_class = 'FloatDivOp'
class subfp(FpBinaryOp):
code = 'FpDestReg = FpSrcReg1 - FpSrcReg2;'
code = '''
FpDestReg = FpSrcReg2 * (log(FpSrcReg1) / log(2));
'''
+ op_class = 'FloatSqrtOp'
class PremFp(FpBinaryOp):
code = '''
FpDestReg = fmod(FpSrcReg1, FpSrcReg2);
DPRINTF(X86, "src1: %lf, src2: %lf, dest: %lf\\n", FpSrcReg1, FpSrcReg2, FpDestReg);
'''
+ op_class = 'FloatDivOp'
class Compfp(FpBinaryOp):
def __init__(self, src1, src2, spm=0, setStatus=False, \
else if(FpSrcReg1 == FpSrcReg2)
ccFlagBits = ccFlagBits | ZFBit;
'''
+ op_class = 'FloatCmpOp'
class absfp(FpUnaryOp):
code = 'FpDestReg = fabs(FpSrcReg1);'
class RegOpMeta(type):
def buildCppClasses(self, name, Name, suffix, code, big_code, \
- flag_code, cond_check, else_code, cond_control_flag_init):
+ flag_code, cond_check, else_code, cond_control_flag_init,
+ op_class):
# Globals to stick the output in
global header_output
matcher.sub(src2_name, flag_code),
matcher.sub(src2_name, cond_check),
matcher.sub(src2_name, else_code),
- matcher.sub(src2_name, cond_control_flag_init))
+ matcher.sub(src2_name, cond_control_flag_init),
+ op_class)
imm_name = "%simm8" % match.group("prefix")
self.buildCppClasses(name + "i", Name, suffix + "Imm",
matcher.sub(imm_name, code),
matcher.sub(imm_name, flag_code),
matcher.sub(imm_name, cond_check),
matcher.sub(imm_name, else_code),
- matcher.sub(imm_name, cond_control_flag_init))
+ matcher.sub(imm_name, cond_control_flag_init),
+ op_class)
return
# If there's something optional to do with flags, generate
# a version without it and fix up this version to use it.
if flag_code != "" or cond_check != "true":
self.buildCppClasses(name, Name, suffix,
- code, big_code, "", "true", else_code, "")
+ code, big_code, "", "true", else_code, "", op_class)
suffix = "Flags" + suffix
# If psrc1 or psrc2 is used, we need to actually insert code to
"flag_code" : flag_code,
"cond_check" : cond_check,
"else_code" : else_code,
- "cond_control_flag_init" : cond_control_flag_init})]
+ "cond_control_flag_init" : cond_control_flag_init,
+ "op_class" : op_class})]
if big_code != "":
iops += [InstObjParams(name, Name + suffix + "Big", base,
{"code" : big_code,
"flag_code" : flag_code,
"cond_check" : cond_check,
"else_code" : else_code,
- "cond_control_flag_init" :
- cond_control_flag_init})]
+ "cond_control_flag_init" : cond_control_flag_init,
+ "op_class" : op_class})]
# Generate the actual code (finally!)
for iop in iops:
cond_check = cls.cond_check
else_code = cls.else_code
cond_control_flag_init = cls.cond_control_flag_init
+ op_class = cls.op_class
# Set up the C++ classes
mcls.buildCppClasses(cls, name, Name, "", code, big_code,
flag_code, cond_check, else_code,
- cond_control_flag_init)
+ cond_control_flag_init, op_class)
# Hook into the microassembler dict
global microopClasses
cond_check = "true"
else_code = ";"
cond_control_flag_init = ""
+ op_class = "IntAluOp"
def __init__(self, dest, src1, op2, flags = None, dataSize = "env.dataSize"):
self.dest = dest
big_code = 'DestReg = result = (psrc1 ^ op2) & mask(dataSize * 8)'
class Mul1s(WrRegOp):
+ op_class = 'IntMultOp'
+
code = '''
ProdLow = psrc1 * op2;
int halfSize = (dataSize * 8) / 2;
'''
class Mul1u(WrRegOp):
+ op_class = 'IntMultOp'
+
code = '''
ProdLow = psrc1 * op2;
int halfSize = (dataSize * 8) / 2;
# One or two bit divide
class Div1(WrRegOp):
+ op_class = 'IntDivOp'
+
code = '''
//These are temporaries so that modifying them later won't make
//the ISA parser think they're also sources.
# Step divide
class Div2(RegOp):
+ op_class = 'IntDivOp'
+
divCode = '''
uint64_t dividend = Remainder;
uint64_t divisor = Divisor;