LDS

Constant buffer, local, shared and global memory instructions

fixed bit field field the encoding fixes should be

LDS

6362616059585756555453525150494847464544434241403938373635343332
1110111101001
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 1110 1111 0100 1---

Runs execute_LDS with Form() 0.

Fields

The operation reads some of these fields in some forms alone (it chooses by Form()), so the diagrams show only the decoder's.

FieldBitsFrom
size50:48execute_LDS
immediate43:20execute_LDS
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

LDS and STS: shared memory at the register at 8 plus the signed offset at 20 (RZ: the offset alone), words of the size at 48-50 or a byte or halfword of the first, which a store puts in with a CAS loop (another lane may store the word's other bytes)

let store = Form() == 1;
let immediate = Bits32(SignExtend(Field(20, 24), 32)); /* made before the register's read */
let address = if RegA() == RZ then immediate else R_read(RegA()) + immediate;
let first = address >> 2;
let size = UInt(Field(48, 3));
foreach (k from 0 to SizeWords(size) - 1) {
    let index0 = if k != 0 then first + to_bits(32, k) else first;
    let pointer = SharedPointer(SharedIndex(index0, SharedWords()));
    if size < 4 then {
        let bit_offset = SubwordOffset(address, size);
        let width = SubwordWidth(size);
        if store then CasInsertShared(pointer, bit_offset, width, Dst())
        else R_write(Dst(), SubwordExtract(AtomicLoadShared(pointer), bit_offset, width, size))
    } else if store then Store(pointer, R_read(Dst() + k))
    else R_write(Dst() + k, Load(pointer))
}

Made from ScarletNX's Sail at 166ad3910f80. The Sail and the encodings' file are ScarletNX's (GPL-3.0-or-later); its encodings are from Eden's maxwell.inc (GPL-2.0-or-later).