view.atomic.cmpxchg
← view dialect
Atomically compare the bits of one scalar view element with an expected payload, write a replacement payload when they match, and return the old observed payload. Comparison is bitwise for every accepted element type.
Operation contract
| Property |
Value |
| Semantic phase |
executable |
| Target contracts |
memory.atomic |
| Interfaces |
MemoryAccess |
| Memory effects |
readwrite view |
Signature
| Kind |
Name |
Type |
Cardinality |
Description |
| Operand |
expected |
scalar |
required |
Scalar value compared against memory. |
| Operand |
replacement |
scalar |
required |
Scalar value written on success. |
| Operand |
view |
view |
required |
Typed destination view. |
| Operand |
indices |
index |
variadic |
Dynamic logical element indices. |
| Result |
old |
scalar |
required |
Old memory value observed by the atomic operation. |
| Attribute |
success_ordering |
enum AtomicOrdering |
required |
Memory ordering used when the compare-exchange succeeds. |
| Attribute |
failure_ordering |
enum AtomicOrdering |
required |
Memory ordering used when the compare-exchange fails. |
| Attribute |
scope |
enum AtomicScope |
required |
Required atomic synchronization scope. |
| Attribute |
cache_scope |
enum CacheScope |
optional |
Optional cache/coherency scope required by target lowering. |
| Attribute |
cache_temporal |
enum CacheTemporal |
optional |
Optional temporal cache policy required by target lowering. |
| Attribute |
static_indices |
i64_array |
required |
Static logical element indices with INT64_MIN sentinels for dynamics. |
Verification constraints
HasBitwiseScalar(expected)
SameElementType(expected, replacement, view, old)
SameType(expected, replacement, old)
Examples
%old = view.atomic.cmpxchg %expected, %replacement, %view[%row, %col] {success_ordering = acq_rel, failure_ordering = acquire, scope = workgroup} : i32, view<[%M]x[%N]xi32, %layout> -> i32