92c92
< Addr branchTarget(Addr branchPC) const;
---
> MipsISA::PCState branchTarget(const MipsISA::PCState &branchPC) const;
119c119
< Addr branchTarget(ThreadContext *tc) const;
---
> MipsISA::PCState branchTarget(ThreadContext *tc) const;
127,128c127,128
< Addr
< Branch::branchTarget(Addr branchPC) const
---
> MipsISA::PCState
> Branch::branchTarget(const MipsISA::PCState &branchPC) const
130c130,134
< return branchPC + 4 + disp;
---
> MipsISA::PCState target = branchPC;
> target.advance();
> target.npc(branchPC.pc() + sizeof(MachInst) + disp);
> target.nnpc(target.npc() + sizeof(MachInst));
> return target;
133c137
< Addr
---
> MipsISA::PCState
136,137c140,145
< Addr NPC = tc->readNextPC();
< return (NPC & 0xF0000000) | (disp);
---
> MipsISA::PCState target = tc->pcState();
> Addr pc = target.pc();
> target.advance();
> target.npc((pc & 0xF0000000) | disp);
> target.nnpc(target.npc() + sizeof(MachInst));
> return target;
220,221c228
< not_taken_code = ' NNPC = NNPC;\n'
< not_taken_code += '} \n'
---
> not_taken_code = ''
228c235
< code += 'R31 = NNPC;\n'
---
> code += 'R31 = pc.nnpc();\n'
230,232c237
< not_taken_code = ' NPC = NNPC;\n'
< not_taken_code += ' NNPC = NNPC + 4;\n'
< not_taken_code += '} \n'
---
> not_taken_code = 'pc.advance();'
244,248c249,259
< code = 'bool cond;\n' + code
< code += 'if (cond) {\n'
< code += ' NNPC = NPC + disp;\n'
< code += '} else {\n'
< code += not_taken_code
---
> code = '''
> bool cond;
> MipsISA::PCState pc = PCS;
> %(code)s
> if (cond) {
> pc.nnpc(pc.npc() + disp);
> } else {
> %(not_taken_code)s
> }
> PCS = pc;
> ''' % { "code" : code, "not_taken_code" : not_taken_code }
258,259c269
< not_taken_code = ' NNPC = NNPC;\n'
< not_taken_code += '} \n'
---
> not_taken_code = ''
266c276
< code += 'R31 = NNPC;\n'
---
> code += 'R32 = pc.nnpc();'
268,270c278
< not_taken_code = ' NPC = NNPC;\n'
< not_taken_code += ' NNPC = NNPC + 4;\n'
< not_taken_code += '} \n'
---
> not_taken_code = 'pc.advance();'
281,287d288
< #Declaration code
< decl_code = 'bool cond;\n'
< decl_code += 'uint32_t dspctl;\n'
<
< #Fetch code
< fetch_code = 'dspctl = DSPControl;\n'
<
289,293c290,301
< code = decl_code + fetch_code + code
< code += 'if (cond) {\n'
< code += ' NNPC = NPC + disp;\n'
< code += '} else {\n'
< code += not_taken_code
---
> code = '''
> MipsISA::PCState pc = PCS;
> bool cond;
> uint32_t dspctl = DSPControl;
> %(code)s
> if (cond) {
> pc.nnpc(pc.npc() + disp);
> } else {
> %(not_taken_code)s
> }
> PCS = pc;
> ''' % { "code" : code, "not_taken_code" : not_taken_code }
308c316,318
< code = 'R31 = NNPC;\n' + code
---
> code = '''
> R31 = pc.nnpc();
> ''' + code
313a324,327
> code = '''
> MipsISA::PCState pc = PCS;
> ''' + code
>