ARM: Squash the low order bits of the PC when performing a regular branch.

This commit is contained in:
Gabe Black
2010-06-02 12:58:10 -05:00
parent 36eeee0133
commit 3caa75d53a
2 changed files with 11 additions and 4 deletions

View File

@@ -221,7 +221,13 @@ class ArmStaticInst : public StaticInst
static void
setNextPC(XC *xc, Addr val)
{
xc->setNextPC((xc->readNextPC() & PcModeMask) |
Addr npc = xc->readNextPC();
if (npc & (ULL(1) << PcTBitShift)) {
val &= ~mask(1);
} else {
val &= ~mask(2);
}
xc->setNextPC((npc & PcModeMask) |
(val & ~PcModeMask));
}

View File

@@ -70,10 +70,11 @@ let {{
'''
maybeAIWPCWrite = '''
if (%(reg_idx)s == PCReg) {
if (xc->readPC() & (ULL(1) << PcTBitShift)) {
setIWNextPC(xc, %(final_val)s);
} else {
bool thumb = THUMB;
if (thumb) {
setNextPC(xc, %(final_val)s);
} else {
setIWNextPC(xc, %(final_val)s);
}
} else {
xc->%(func)s(this, %(op_idx)s, %(final_val)s);