for (mnem, imm, link) in blxList:
Name = mnem.capitalize()
+ isRasPop = 0
if imm:
Name += "Imm"
# Since we're switching ISAs, the target ISA will be the opposite
instFlags += ["IsCall"]
else:
linkStr = ""
- instFlags += ["IsReturn"]
+ isRasPop = "op1 == INTREG_LR"
if imm and link: #blx with imm
branchStr = '''
"branch": branchStr}
blxIop = InstObjParams(mnem, Name, base,
{"code": code, "brTgtCode" : br_tgt_code,
- "predicate_test": predicateTest}, instFlags)
+ "predicate_test": predicateTest,
+ "is_ras_pop" : isRasPop }, instFlags)
header_output += declare.subst(blxIop)
decoder_output += constructor.subst(blxIop)
exec_output += PredOpExecute.subst(blxIop)
subst(immIopCc)
def buildRegDataInst(mnem, code, flagType = "logic", suffix = "Reg", \
- buildCc = True, buildNonCc = True, instFlags = []):
+ buildCc = True, buildNonCc = True, isRasPop = "0", \
+ isBranch = "0", instFlags = []):
cCode = carryCode[flagType]
vCode = overflowCode[flagType]
negBit = 31
}
regCode = secondOpRe.sub(regOp2, code)
regIop = InstObjParams(mnem, mnem.capitalize() + suffix, "DataRegOp",
- {"code" : regCode,
+ {"code" : regCode, "is_ras_pop" : isRasPop,
+ "is_branch" : isBranch,
"predicate_test": predicateTest}, instFlags)
regIopCc = InstObjParams(mnem + "s", mnem.capitalize() + suffix + "Cc",
"DataRegOp",
{"code" : regCode + regCcCode,
- "predicate_test": condPredicateTest},
- instFlags)
+ "predicate_test": condPredicateTest,
+ "is_ras_pop" : isRasPop,
+ "is_branch" : isBranch}, instFlags)
def subst(iop):
global header_output, decoder_output, exec_output
def buildDataInst(mnem, code, flagType = "logic", \
aiw = True, regRegAiw = True,
- subsPcLr = True):
+ subsPcLr = True, isRasPop = "0", isBranch = "0"):
regRegCode = instCode = code
if aiw:
instCode = "AIW" + instCode
regRegCode = "AIW" + regRegCode
buildImmDataInst(mnem, instCode, flagType)
- buildRegDataInst(mnem, instCode, flagType)
+ buildRegDataInst(mnem, instCode, flagType,
+ isRasPop = isRasPop, isBranch = isBranch)
buildRegRegDataInst(mnem, regRegCode, flagType)
if subsPcLr:
code += '''
buildDataInst("cmn", "resTemp = Op1 + secondOp;", "add", aiw = False)
buildDataInst("orr", "Dest = resTemp = Op1 | secondOp;")
buildDataInst("orn", "Dest = resTemp = Op1 | ~secondOp;", aiw = False)
- buildDataInst("mov", "Dest = resTemp = secondOp;", regRegAiw = False)
+ buildDataInst("mov", "Dest = resTemp = secondOp;", regRegAiw = False,
+ isRasPop = "op1 == INTREG_LR", isBranch = "dest == INTREG_PC")
buildDataInst("bic", "Dest = resTemp = Op1 & ~secondOp;")
buildDataInst("mvn", "Dest = resTemp = ~secondOp;")
buildDataInst("movt",
self.sign = sign
self.user = user
self.flavor = flavor
+ self.rasPop = False
if self.add:
self.op = " +"
newDecoder,
newExec) = self.fillTemplates(self.name, self.Name, codeBlobs,
self.memFlags, instFlags, base,
- wbDecl, pcDecl)
+ wbDecl, pcDecl, self.rasPop)
header_output += newHeader
decoder_output += newDecoder
else:
self.wbDecl = "MicroSubiUop(machInst, base, base, imm);"
+ if self.add and self.post and self.writeback and not self.sign and \
+ not self.user and self.size == 4:
+ self.rasPop = True
+
class LoadRegInst(LoadInst):
def __init__(self, *args, **kargs):
super(LoadRegInst, self).__init__(*args, **kargs)
self.constructTemplate = eval(self.decConstBase + 'Constructor')
def fillTemplates(self, name, Name, codeBlobs, memFlags, instFlags,
- base = 'Memory', wbDecl = None, pcDecl = None):
+ base = 'Memory', wbDecl = None, pcDecl = None,
+ rasPop = False):
# Make sure flags are in lists (convert to lists if not).
memFlags = makeList(memFlags)
instFlags = makeList(instFlags)
codeBlobsCopy['use_uops'] = 0
codeBlobsCopy['use_wb'] = 0
codeBlobsCopy['use_pc'] = 0
+ is_ras_pop = "0"
+ if rasPop:
+ is_ras_pop = "1"
+ codeBlobsCopy['is_ras_pop'] = is_ras_pop
iop = InstObjParams(name, Name, base,
codeBlobsCopy, instFlagsCopy)
"acc_name" : Name,
"use_uops" : use_uops,
"use_pc" : use_pc,
- "use_wb" : use_wb },
+ "use_wb" : use_wb,
+ "is_ras_pop" : is_ras_pop },
['IsMacroop'])
header_output += self.declareTemplate.subst(iop)
decoder_output += self.constructTemplate.subst(iop)
} else {
flags[IsUncondControl] = true;
}
+ if (%(is_ras_pop)s)
+ flags[IsReturn] = true;
}
}};
} else {
flags[IsUncondControl] = true;
}
+ if (%(is_ras_pop)s)
+ flags[IsReturn] = true;
}
}};
(IntRegIndex)_index)
{
%(constructor)s;
+ bool conditional = false;
if (!(condCode == COND_AL || condCode == COND_UC)) {
+ conditional = true;
for (int x = 0; x < _numDestRegs; x++) {
_srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
}
uops[1] = new %(wb_decl)s;
uops[1]->setDelayedCommit();
uops[2] = new MicroUopRegMov(machInst, INTREG_PC, INTREG_UREG0);
+ uops[2]->setFlag(StaticInst::IsControl);
+ uops[2]->setFlag(StaticInst::IsIndirectControl);
+ if (conditional)
+ uops[2]->setFlag(StaticInst::IsCondControl);
+ else
+ uops[2]->setFlag(StaticInst::IsUncondControl);
uops[2]->setLastMicroop();
} else if(_dest == _index) {
IntRegIndex wbIndexReg = INTREG_UREG0;
(IntRegIndex)_dest, (IntRegIndex)_base, _add, _imm)
{
%(constructor)s;
+ bool conditional = false;
if (!(condCode == COND_AL || condCode == COND_UC)) {
+ conditional = true;
for (int x = 0; x < _numDestRegs; x++) {
_srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
}
uops[1] = new %(wb_decl)s;
uops[1]->setDelayedCommit();
uops[2] = new MicroUopRegMov(machInst, INTREG_PC, INTREG_UREG0);
+ uops[2]->setFlag(StaticInst::IsControl);
+ uops[2]->setFlag(StaticInst::IsIndirectControl);
+ if (conditional)
+ uops[2]->setFlag(StaticInst::IsCondControl);
+ else
+ uops[2]->setFlag(StaticInst::IsUncondControl);
+ if (_base == INTREG_SP && _add && _imm == 4 && %(is_ras_pop)s)
+ uops[2]->setFlag(StaticInst::IsReturn);
uops[2]->setLastMicroop();
} else {
uops[0] = new %(acc_name)s(machInst, _dest, _base, _add, _imm);
_srcRegIdx[_numSrcRegs++] = _destRegIdx[x];
}
}
+
+ if (%(is_branch)s){
+ flags[IsControl] = true;
+ flags[IsIndirectControl] = true;
+ if (condCode == COND_AL || condCode == COND_UC)
+ flags[IsCondControl] = true;
+ else
+ flags[IsUncondControl] = true;
+ }
+
+ if (%(is_ras_pop)s) {
+ flags[IsReturn] = true;
+ }
}
}};