================ @@ -4033,6 +4033,47 @@ def CIR_ThrowOp : CIR_Op<"throw"> { // Atomic operations //===----------------------------------------------------------------------===// +def CIR_AtomicXchg : CIR_Op<"atomic.xchg", [ + AllTypesMatch<["result", "val"]> +]> { + let summary = "Atomic exchange"; + let description = [{ + C/C++ atomic exchange operation. This operation implements the C/C++ + builtin function `__atomic_exchange`, `__atomic_exchange_n`, and + `__c11_atomic_exchange`. + + This operation takes two arguments: a pointer `ptr` and a value `val`. The + operation atomically replaces the value of the object pointed-to by `ptr` + with `val`, and returns the original value of the object. + + Example: + + ```mlir + %res = cir.atomic.xchg(%ptr : !cir.ptr<!u64i>, + %val : !u64i, + seq_cst) : !u64i + ``` + }]; + + let results = (outs CIR_AnyType:$result); + let arguments = (ins Arg<CIR_PointerType, "", [MemRead, MemWrite]>:$ptr, + CIR_AnyType:$val, + Arg<CIR_MemOrder, "memory order">:$mem_order, + UnitAttr:$is_volatile); ---------------- xlauko wrote:
```suggestion let arguments = (ins Arg<CIR_PointerType, "", [MemRead, MemWrite]>:$ptr, CIR_AnyType:$val, Arg<CIR_MemOrder, "memory order">:$mem_order, UnitAttr:$is_volatile ); ``` https://github.com/llvm/llvm-project/pull/158089 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits