llvm::MachineIRBuilder::buildAtomicCmpXchgWithSuccess

Build and insert `OldValRes<def>, SuccessRes<def> = G_ATOMIC_CMPXCHG_WITH_SUCCESS Addr, CmpVal, NewVal, MMO`.

Synopsis

Declared in <llvm/CodeGen/GlobalISel/MachineIRBuilder.h>

MachineInstrBuilder
buildAtomicCmpXchgWithSuccess(
    DstOp const& OldValRes,
    DstOp const& SuccessRes,
    SrcOp const& Addr,
    SrcOp const& CmpVal,
    SrcOp const& NewVal,
    MachineMemOperand& MMO);

Description

Atomically replace the value at Addr with NewVal if it is currently CmpVal otherwise leaves it unchanged. Puts the original value from Addr in Res, along with an s1 indicating whether it was replaced.

Return Value

a MachineInstrBuilder for the newly created instruction.

Parameters

NameDescription
OldValResDestination receiving the previous memory value.
SuccessResDestination receiving the success flag.
AddrAddress operand.
CmpValExpected current value for the compare-exchange.
NewValReplacement value written on success.
MMOMemory operand describing the access.

Preconditions

  • setBasicBlock or setMI must have been called.
  • OldValRes must be a generic virtual register of scalar type.
  • SuccessRes must be a generic virtual register of scalar type. It will be assigned 0 on failure and 1 on success.
  • Addr must be a generic virtual register with pointer type.
  • OldValRes, CmpVal, and NewVal must be generic virtual registers of the same type.