Skip to content

Commit

Permalink
Use newExclusiveStore for stwcx instruction
Browse files Browse the repository at this point in the history
Signed-off-by: Hernan Ponce de Leon <[email protected]>
  • Loading branch information
hernanponcedeleon committed Oct 26, 2024
1 parent 2525f05 commit 4d72f2e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,14 @@ public Object visitStwx(LitmusPPCParser.StwxContext ctx) {

@Override
public Object visitStwcx(LitmusPPCParser.StwcxContext ctx) {
// This instruction is usually followed by a branch instruction.
// Thus, the execution status of the store is saved in r0
// (the default register for branch conditions).
Register rs = programBuilder.getOrNewRegister(mainThread, "r0", types.getBooleanType());
Register r1 = (Register) ctx.register(0).accept(this);
Register ra = (Register) ctx.register(1).accept(this);
Register rb = (Register) ctx.register(2).accept(this);
return programBuilder.addChild(mainThread, EventFactory.Power.newRMWStoreConditional(expressions.makeAdd(ra, rb), r1, true));
return programBuilder.addChild(mainThread, EventFactory.Common.newExclusiveStore(rs, expressions.makeAdd(ra, rb), r1, ""));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.dat3m.dartagnan.program.event.Event;
import com.dat3m.dartagnan.program.event.Tag;
import com.dat3m.dartagnan.program.event.Tag.C11;
import com.dat3m.dartagnan.program.event.arch.StoreExclusive;
import com.dat3m.dartagnan.program.event.core.*;
import com.dat3m.dartagnan.program.event.lang.catomic.*;
import com.dat3m.dartagnan.program.event.lang.linux.*;
Expand Down Expand Up @@ -40,6 +41,20 @@ protected VisitorPower(boolean useRC11Scheme, PowerScheme cToPowerScheme) {
this.cToPowerScheme = cToPowerScheme;
}

// =============================================================================================
// ========================================= Common ============================================
// =============================================================================================

@Override
public List<Event> visitStoreExclusive(StoreExclusive e) {
RMWStoreExclusive store = newRMWStoreExclusiveWithMo(e.getAddress(), e.getMemValue(), true, e.getMo());

return eventSequence(
store,
newExecutionStatus(e.getResultRegister(), store)
);
}

// =============================================================================================
// ========================================= PTHREAD ===========================================
// =============================================================================================
Expand Down

0 comments on commit 4d72f2e

Please sign in to comment.