s_atomic_cmpswap GPU Native ISA AMD Scalar

Scalar Memory

s_atomic_cmpswap

Compare two unsigned 32-bit integer values stored in the data comparison register and a location in the scalar memory.

Encoding

Binary Layout (AMD CDNA 4)
SOFFSET
63:57
unassigned
56:53
OFFSET
52:32
110000
31:26
10000001
25:18
IMM
17
GLC
16
NV
15
SOFFSET_EN
14
unassigned
13
SDATA
12:6
SBASE
5:0
 

The ENC_SMEM layout from AMD's machine-readable ISA specification (AMD CDNA 4). Opcode 129 in OP rebuilds 0x00000000C2040000, an identifier AMD lists for this encoding. Bits marked unassigned have no field in the specification. The same in the other 3 generations that define it.

Format SMEM
Width 64 bits
Opcode 129
Identifier 0x00000000C2040000

Operands

  • SDATA
    Written. N/A Data format: Value can be anything. (OPR_SREG, FMT_ANY)
  • SBASE
    Read. N/A Data format: 64-bit virtual memory address. (OPR_SREG, FMT_BUF)
  • SOFFSET
    Read. N/A Data format: N/A (OPR_SMEM_OFFSET, FMT_NUM_B32)

In AMD's order, as its machine-readable ISA specification lists them for the ENC_SMEM encoding (AMD CDNA 4).

GFX Target Compatibility

Per-target GFX compatibility has not yet been verified for this instruction.

Related

More in Scalar Memory

Reference

AMDGPU / GFX ISA

Description

Compare two unsigned 32-bit integer values stored in the data comparison register and a location in the scalar memory. Modify the memory location with a value in the data source register iff the comparison is equal.

Example

s_atomic_cmpswap vcc, s[2:3], s0

A real instruction accepted by the LLVM assembler, taken verbatim from LLVM's own AMDGPU MC test suite (gfx9_asm_smem.s). Not from an AMD document, and not authored here.

Sources