Skip to content

Commit

Permalink
Add support for atomic_exchange_explicit in litmus code (#740)
Browse files Browse the repository at this point in the history
Signed-off-by: Hernan Ponce de Leon <[email protected]>
  • Loading branch information
hernanponcedeleon authored Sep 20, 2024
1 parent 690a283 commit 90c3a7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions dartagnan/src/main/antlr4/C11Lexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ lexer grammar C11Lexer;

C11AtomicLoad : 'atomic_load_explicit';
C11AtomicStore : 'atomic_store_explicit';
C11AtomicXchg : 'atomic_exchange_explicit';
C11AtomicSCAS : 'atomic_compare_exchange_strong_explicit';
C11AtomicWCAS : 'atomic_compare_exchange_weak_explicit';
C11AtomicFence : 'atomic_thread_fence';
Expand Down
2 changes: 2 additions & 0 deletions dartagnan/src/main/antlr4/LitmusC.g4
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ re locals [IntBinaryOp op, String mo]
| XchgAcquire LPar address = re Comma value = re RPar {$mo = Linux.MO_ACQUIRE;}
| XchgRelease LPar address = re Comma value = re RPar {$mo = Linux.MO_RELEASE;}) # reXchg

| C11AtomicXchg LPar address = re Comma value = re Comma c11Mo RPar # reC11AtomicXchg

| ( AtomicCmpXchg LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_MB;}
| AtomicCmpXchgRelaxed LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_RELAXED;}
| AtomicCmpXchgAcquire LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_ACQUIRE;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ public Expression visitReAtomicAddUnless(LitmusCParser.ReAtomicAddUnlessContext
return register;
}

@Override
public Expression visitReC11AtomicXchg(LitmusCParser.ReC11AtomicXchgContext ctx) {
Register register = getReturnRegister(true);
Expression value = (Expression) ctx.value.accept(this);
Event event = EventFactory.Atomic.newExchange(register, getAddress(ctx.address), value, ctx.c11Mo().mo);
programBuilder.addChild(currentThread, event);
return register;
}

@Override
public Expression visitReXchg(LitmusCParser.ReXchgContext ctx){
Register register = getReturnRegister(true);
Expand Down

0 comments on commit 90c3a7b

Please sign in to comment.