CpsrQ = (Rd < resTemp) ? 1 << 27 : 0;
} else {
uint16_t _ic, _iv, _iz, _in;
- _in = (resTemp >> %(negBit)d) & 1;
+ _in = (resTemp >> %(negBit)d);
_iz = (resTemp == 0);
- _iv = %(ivValue)s & 1;
- _ic = %(icValue)s & 1;
+ _iv = %(ivValue)s;
+ _ic = %(icValue)s;
CondCodesNZ = (_in << 1) | (_iz);
CondCodesC = _ic;
def format DataOp(code, flagtype = logic) {{
(regCcCode, immCcCode) = getCcCode(flagtype)
regCode = '''uint32_t op2 = shift_rm_rs(Rm, Rs<7:0>,
- shift, CondCodesC);
+ shift, 0);
op2 = op2;''' + code
immCode = '''uint32_t op2 = shift_rm_imm(Rm, shift_size,
- shift, CondCodesC);
+ shift, OptShiftRmCondCodesC);
op2 = op2;''' + code
regIop = InstObjParams(name, Name, 'PredIntOp',
{"code": regCode,
- "predicate_test": predicateTest})
+ "predicate_test": pickPredicate(regCode)})
immIop = InstObjParams(name, Name + "Imm", 'PredIntOp',
{"code": immCode,
- "predicate_test": predicateTest})
+ "predicate_test": pickPredicate(imm)})
regCcIop = InstObjParams(name, Name + "Cc", 'PredIntOp',
- {"code": regCode + regCcCode,
- "predicate_test": condPredicateTest})
+ {"code": regCode + regCcCode,
+ "predicate_test": pickPredicate(regCode + regCcCode)})
immCcIop = InstObjParams(name, Name + "ImmCc", 'PredIntOp',
- {"code": immCode + immCcCode,
- "predicate_test": condPredicateTest})
+ {"code": immCode + immCcCode,
+ "predicate_test": pickPredicate(immCode + immCcCode)})
header_output = BasicDeclare.subst(regIop) + \
BasicDeclare.subst(immIop) + \
BasicDeclare.subst(regCcIop) + \
code += "resTemp = resTemp;"
iop = InstObjParams(name, Name, 'PredImmOp',
{"code": code,
- "predicate_test": predicateTest})
+ "predicate_test": pickPredicate(code)})
ccIop = InstObjParams(name, Name + "Cc", 'PredImmOp',
- {"code": code + getImmCcCode(flagtype),
- "predicate_test": condPredicateTest})
+ {"code": code + getImmCcCode(flagtype),
+ "predicate_test": pickPredicate(code + getImmCcCode(flagtype))})
header_output = BasicDeclare.subst(iop) + \
BasicDeclare.subst(ccIop)
decoder_output = BasicConstructor.subst(iop) + \
def format PredOp(code, *opt_flags) {{
iop = InstObjParams(name, Name, 'PredOp',
{"code": code,
- "predicate_test": predicateTest},
+ "predicate_test": pickPredicate(code)},
opt_flags)
header_output = BasicDeclare.subst(iop)
decoder_output = BasicConstructor.subst(iop)
def format PredImmOp(code, *opt_flags) {{
iop = InstObjParams(name, Name, 'PredImmOp',
{"code": code,
- "predicate_test": predicateTest},
+ "predicate_test": pickPredicate(code)},
opt_flags)
header_output = BasicDeclare.subst(iop)
decoder_output = BasicConstructor.subst(iop)
secondOpRe = re.compile("secondOp")
immOp2 = "imm"
- regOp2 = "shift_rm_imm(Op2, shiftAmt, shiftType, CondCodesC)"
- regRegOp2 = "shift_rm_rs(Op2, Shift<7:0>, shiftType, CondCodesC)"
+ regOp2 = "shift_rm_imm(Op2, shiftAmt, shiftType, OptShiftRmCondCodesC)"
+ regRegOp2 = "shift_rm_rs(Op2, Shift<7:0>, shiftType, 0)"
def buildImmDataInst(mnem, code, flagType = "logic", suffix = "Imm", \
buildCc = True, buildNonCc = True, instFlags = []):
}
immCode = secondOpRe.sub(immOp2, code)
immIop = InstObjParams(mnem, mnem.capitalize() + suffix, "DataImmOp",
- {"code" : immCode,
- "predicate_test": predicateTest}, instFlags)
+ {"code" : immCode,
+ "predicate_test": pickPredicate(immCode)}, instFlags)
immIopCc = InstObjParams(mnem + "s", mnem.capitalize() + suffix + "Cc",
- "DataImmOp",
- {"code" : immCode + immCcCode,
- "predicate_test": condPredicateTest}, instFlags)
+ "DataImmOp",
+ {"code" : immCode + immCcCode,
+ "predicate_test": pickPredicate(immCode + immCcCode)}, instFlags)
def subst(iop):
global header_output, decoder_output, exec_output
}
regCode = secondOpRe.sub(regOp2, code)
regIop = InstObjParams(mnem, mnem.capitalize() + suffix, "DataRegOp",
- {"code" : regCode, "is_ras_pop" : isRasPop,
- "is_branch" : isBranch,
- "predicate_test": predicateTest}, instFlags)
+ {"code" : regCode, "is_ras_pop" : isRasPop,
+ "is_branch" : isBranch,
+ "predicate_test": pickPredicate(regCode)}, instFlags)
regIopCc = InstObjParams(mnem + "s", mnem.capitalize() + suffix + "Cc",
- "DataRegOp",
- {"code" : regCode + regCcCode,
- "predicate_test": condPredicateTest,
- "is_ras_pop" : isRasPop,
- "is_branch" : isBranch}, instFlags)
+ "DataRegOp",
+ {"code" : regCode + regCcCode,
+ "predicate_test": pickPredicate(regCode + regCcCode),
+ "is_ras_pop" : isRasPop,
+ "is_branch" : isBranch}, instFlags)
def subst(iop):
global header_output, decoder_output, exec_output
}
regRegCode = secondOpRe.sub(regRegOp2, code)
regRegIop = InstObjParams(mnem, mnem.capitalize() + suffix,
- "DataRegRegOp",
- {"code" : regRegCode,
- "predicate_test": predicateTest})
+ "DataRegRegOp",
+ {"code" : regRegCode,
+ "predicate_test": pickPredicate(regRegCode)})
regRegIopCc = InstObjParams(mnem + "s",
- mnem.capitalize() + suffix + "Cc",
- "DataRegRegOp",
- {"code" : regRegCode + regRegCcCode,
- "predicate_test": condPredicateTest})
+ mnem.capitalize() + suffix + "Cc",
+ "DataRegRegOp",
+ {"code" : regRegCode + regRegCcCode,
+ "predicate_test": pickPredicate(regRegCode + regRegCcCode)})
def subst(iop):
global header_output, decoder_output, exec_output
code += '''
SCTLR sctlr = Sctlr;
CPSR old_cpsr = Cpsr;
- old_cpsr.nz = CondCodesNZ;
- old_cpsr.c = CondCodesC;
- old_cpsr.v = CondCodesV;
- old_cpsr.ge = CondCodesGE;
CPSR new_cpsr =
cpsrWriteByInstr(old_cpsr, Spsr, 0xF, true, sctlr.nmfi);
def __init__(self, *args, **kargs):
super(LoadRegInst, self).__init__(*args, **kargs)
self.offset = self.op + " shift_rm_imm(Index, shiftAmt," + \
- " shiftType, CondCodesC)"
+ " shiftType, OptShiftRmCondCodesC)"
if self.add:
self.wbDecl = '''
MicroAddUop(machInst, base, base, wbIndexReg, shiftAmt, shiftType);
microRetUopCode = '''
CPSR old_cpsr = Cpsr;
SCTLR sctlr = Sctlr;
- old_cpsr.nz = CondCodesNZ;
- old_cpsr.c = CondCodesC;
- old_cpsr.v = CondCodesV;
- old_cpsr.ge = CondCodesGE;
CPSR new_cpsr =
cpsrWriteByInstr(old_cpsr, Spsr, 0xF, true, sctlr.nmfi);
'predicate_test': predicateTest},
['IsMicroop'])
+ microAddUopCode = '''
+ URa = URb + shift_rm_imm(URc, shiftAmt, shiftType, OptShiftRmCondCodesC);
+ '''
+
microAddUopIop = InstObjParams('add_uop', 'MicroAddUop',
'MicroIntRegOp',
- {'code':
- '''URa = URb + shift_rm_imm(URc, shiftAmt,
- shiftType,
- CondCodesC);
- ''',
- 'predicate_test': predicateTest},
+ {'code': microAddUopCode,
+ 'predicate_test': pickPredicate(microAddUopCode)},
['IsMicroop'])
microSubiUopIop = InstObjParams('subi_uop', 'MicroSubiUop',
'predicate_test': predicateTest},
['IsMicroop'])
+ microSubUopCode = '''
+ URa = URb - shift_rm_imm(URc, shiftAmt, shiftType, OptShiftRmCondCodesC);
+ '''
microSubUopIop = InstObjParams('sub_uop', 'MicroSubUop',
'MicroIntRegOp',
- {'code':
- '''URa = URb - shift_rm_imm(URc, shiftAmt,
- shiftType,
- CondCodesC);
- ''',
- 'predicate_test': predicateTest},
+ {'code': microSubUopCode,
+ 'predicate_test': pickPredicate(microSubUopCode)},
['IsMicroop'])
microUopRegMovIop = InstObjParams('uopReg_uop', 'MicroUopRegMov',
def pickPredicate(blobs):
opt_nz = True
- opt_c = True
+ opt_c = 'opt'
opt_v = True
- for val in blobs.values():
- if re.search('(?<!Opt)CondCodesNZ', val):
+
+ if not isinstance(blobs, dict):
+ vals = [blobs]
+ else:
+ vals = blobs.values()
+ for val in vals:
+ if re.search('(?<!Opt)CondCodesNZ(?!.*=)', val):
opt_nz = False
- if re.search('(?<!Opt)CondCodesC', val):
- opt_c = False
- if re.search('(?<!Opt)CondCodesV', val):
+ if re.search('OptShiftRmCondCodesC(?!.*=)', val):
+ opt_c = 'opt_shift_rm'
+ elif re.search('(?<!Opt)CondCodesC(?!.*=)', val):
+ opt_c = 'none'
+ if re.search('(?<!Opt)CondCodesV(?!.*=)', val):
opt_v = False
# Build up the predicate piece by piece depending on which
predicate += 'OptCondCodesNZ, '
else:
predicate += 'CondCodesNZ, '
- if opt_c:
+ if opt_c == 'opt':
predicate += 'OptCondCodesC, '
+ elif opt_c == 'opt_shift_rm':
+ predicate += 'OptShiftRmCondCodesC, '
else:
predicate += 'CondCodesC, '
if opt_v:
else:
predicate += 'CondCodesV, '
predicate += 'condCode)'
-
+ predicate += '/*auto*/'
return predicate
def memClassName(base, post, add, writeback, \
'''
ssatIop = InstObjParams("ssat", "Ssat", "RegImmRegShiftOp",
{ "code": ssatCode,
- "predicate_test": condPredicateTest }, [])
+ "predicate_test": pickPredicate(ssatCode) }, [])
header_output += RegImmRegShiftOpDeclare.subst(ssatIop)
decoder_output += RegImmRegShiftOpConstructor.subst(ssatIop)
exec_output += PredOpExecute.subst(ssatIop)
'''
usatIop = InstObjParams("usat", "Usat", "RegImmRegShiftOp",
{ "code": usatCode,
- "predicate_test": condPredicateTest }, [])
+ "predicate_test": pickPredicate(usatCode) }, [])
header_output += RegImmRegShiftOpDeclare.subst(usatIop)
decoder_output += RegImmRegShiftOpConstructor.subst(usatIop)
exec_output += PredOpExecute.subst(usatIop)
'''
ssat16Iop = InstObjParams("ssat16", "Ssat16", "RegImmRegOp",
{ "code": ssat16Code,
- "predicate_test": condPredicateTest }, [])
+ "predicate_test": pickPredicate(ssat16Code) }, [])
header_output += RegImmRegOpDeclare.subst(ssat16Iop)
decoder_output += RegImmRegOpConstructor.subst(ssat16Iop)
exec_output += PredOpExecute.subst(ssat16Iop)
'''
usat16Iop = InstObjParams("usat16", "Usat16", "RegImmRegOp",
{ "code": usat16Code,
- "predicate_test": condPredicateTest }, [])
+ "predicate_test": pickPredicate(usat16Code) }, [])
header_output += RegImmRegOpDeclare.subst(usat16Iop)
decoder_output += RegImmRegOpConstructor.subst(usat16Iop)
exec_output += PredOpExecute.subst(usat16Iop)
if unCc:
iop = InstObjParams(mnem, Name, base,
- {"code" : code,
- "predicate_test": predicateTest,
- "op_class": "IntMultOp" })
+ {"code" : code,
+ "predicate_test": pickPredicate(code),
+ "op_class": "IntMultOp" })
if doCc:
iopCc = InstObjParams(mnem + "s", Name + "Cc", base,
- {"code" : code + ccCode,
- "predicate_test": condPredicateTest,
- "op_class": "IntMultOp" })
+ {"code" : code + ccCode,
+ "predicate_test": pickPredicate(code + ccCode),
+ "op_class": "IntMultOp" })
if regs == 3:
declare = Mult3Declare
def __init__(self, *args, **kargs):
super(StoreRegInst, self).__init__(*args, **kargs)
self.offset = self.op + " shift_rm_imm(Index, shiftAmt," + \
- " shiftType, CondCodesC)"
+ " shiftType, OptShiftRmCondCodesC)"
if self.add:
self.wbDecl = '''
MicroAddUop(machInst, base, base, index, shiftAmt, shiftType);
'''(condCode == COND_HI || condCode == COND_LS ||
condCode == COND_CS || condCode == COND_CC) ?
INTREG_CONDCODES_C : INTREG_ZERO'''),
+ 'OptShiftRmCondCodesC': intRegCC(
+ '''(condCode == COND_HI || condCode == COND_LS ||
+ condCode == COND_CS || condCode == COND_CC ||
+ shiftType == ROR) ?
+ INTREG_CONDCODES_C : INTREG_ZERO'''),
'OptCondCodesV': intRegCC(
'''(condCode == COND_VS || condCode == COND_VC ||
condCode == COND_GE || condCode == COND_LT ||