Skip to content

Commit

Permalink
irjit: Cleanup breakpoint ops.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Sep 3, 2023
1 parent a0b89b1 commit e1a1f56
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Core/MIPS/IR/IRFrontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void IRFrontend::CheckBreakpoint(u32 addr) {
ir.Write(IROp::Downcount, 0, ir.AddConstant(downcountAmount));
// Note that this means downcount can't be metadata on the block.
js.downcountAmount = -downcountOffset;
ir.Write(IROp::Breakpoint);
ir.Write(IROp::Breakpoint, 0, ir.AddConstant(addr));
ApplyRoundingMode();

js.hadBreakpoints = true;
Expand All @@ -372,7 +372,7 @@ void IRFrontend::CheckMemoryBreakpoint(int rs, int offset) {
ir.Write(IROp::Downcount, 0, ir.AddConstant(downcountAmount));
// Note that this means downcount can't be metadata on the block.
js.downcountAmount = -downcountOffset;
ir.Write(IROp::MemoryCheck, 0, rs, ir.AddConstant(offset));
ir.Write(IROp::MemoryCheck, js.inDelaySlot ? 4 : 0, rs, ir.AddConstant(offset));
ApplyRoundingMode();

js.hadBreakpoints = true;
Expand Down
4 changes: 2 additions & 2 deletions Core/MIPS/IR/IRInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ static const IRMeta irMeta[] = {
{ IROp::SetPC, "SetPC", "_G" },
{ IROp::SetPCConst, "SetPC", "_C" },
{ IROp::CallReplacement, "CallRepl", "_C", IRFLAG_BARRIER },
{ IROp::Breakpoint, "Breakpoint", "", IRFLAG_BARRIER },
{ IROp::MemoryCheck, "MemoryCheck", "_GC", IRFLAG_BARRIER },
{ IROp::Breakpoint, "Breakpoint", "_C", IRFLAG_BARRIER },
{ IROp::MemoryCheck, "MemoryCheck", "IGC", IRFLAG_BARRIER },

{ IROp::ValidateAddress8, "ValidAddr8", "_GC", IRFLAG_BARRIER },
{ IROp::ValidateAddress16, "ValidAddr16", "_GC", IRFLAG_BARRIER },
Expand Down
24 changes: 17 additions & 7 deletions Core/MIPS/IR/IRInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,30 @@ alignas(16) static const uint32_t lowBytesMask[4] = {
0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF,
};

u32 RunBreakpoint(u32 pc) {
u32 IRRunBreakpoint(u32 pc) {
// Should we skip this breakpoint?
if (CBreakPoints::CheckSkipFirst() == pc)
uint32_t skipFirst = CBreakPoints::CheckSkipFirst();
if (skipFirst == pc || skipFirst == currentMIPS->pc)
return 0;

CBreakPoints::ExecBreakPoint(currentMIPS->pc);
// Did we already hit one?
if (coreState != CORE_RUNNING && coreState != CORE_NEXTFRAME)
return 1;

CBreakPoints::ExecBreakPoint(pc);
return coreState != CORE_RUNNING ? 1 : 0;
}

u32 RunMemCheck(u32 pc, u32 addr) {
u32 IRRunMemCheck(u32 pc, u32 addr) {
// Should we skip this breakpoint?
if (CBreakPoints::CheckSkipFirst() == pc)
uint32_t skipFirst = CBreakPoints::CheckSkipFirst();
if (skipFirst == pc || skipFirst == currentMIPS->pc)
return 0;

// Did we already hit one?
if (coreState != CORE_RUNNING && coreState != CORE_NEXTFRAME)
return 1;

CBreakPoints::ExecOpMemCheck(addr, pc);
return coreState != CORE_RUNNING ? 1 : 0;
}
Expand Down Expand Up @@ -1100,14 +1110,14 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) {
break;

case IROp::Breakpoint:
if (RunBreakpoint(mips->pc)) {
if (IRRunBreakpoint(inst->constant)) {
CoreTiming::ForceCheck();
return mips->pc;
}
break;

case IROp::MemoryCheck:
if (RunMemCheck(mips->pc, mips->r[inst->src1] + inst->constant)) {
if (IRRunMemCheck(mips->pc + inst->dest, mips->r[inst->src1] + inst->constant)) {
CoreTiming::ForceCheck();
return mips->pc;
}
Expand Down
3 changes: 3 additions & 0 deletions Core/MIPS/IR/IRInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ inline static u32 ReverseBits32(u32 v) {
return v;
}

u32 IRRunBreakpoint(u32 pc);
u32 IRRunMemCheck(u32 pc, u32 addr);

u32 IRInterpret(MIPSState *ms, const IRInst *inst, int count);

0 comments on commit e1a1f56

Please sign in to comment.