PRMT

Integer, logic, video and predicate instructions

fixed bit field field the encoding fixes should be

PRMT (reg)

6362616059585756555453525150494847464544434241403938373635343332
010110111100
313029282726252423222120191817161514131211109876543210
Rbpred.notpredRaRd

bits 63:48: 0101 1011 1100 ----

Runs execute_PRMT with Form() 0.

PRMT (rc)

6362616059585756555453525150494847464544434241403938373635343332
010100111100
313029282726252423222120191817161514131211109876543210
Rbpred.notpredRaRd

bits 63:48: 0101 0011 1100 ----

Runs execute_PRMT with Form() 1.

PRMT (cr)

6362616059585756555453525150494847464544434241403938373635343332
010010111100cbuf.bankcbuf.offset
313029282726252423222120191817161514131211109876543210
cbuf.offsetpred.notpredRaRd

bits 63:48: 0100 1011 1100 ----

Runs execute_PRMT with Form() 2.

PRMT (imm)

6362616059585756555453525150494847464544434241403938373635343332
0011011imm.sign1100imm
313029282726252423222120191817161514131211109876543210
immpred.notpredRaRd

bits 63:48: 0011 011- 1100 ----

Runs execute_PRMT with Form() 3.

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
[56]56execute_PRMT
mode50:48execute_PRMT
selector46:39execute_PRMT
[38:20]38:20execute_PRMT
Rb27:20RegB()
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

PRMT: Bytes 0-3 are Ra's and 4-7 C's (Rc at bit 39, or the constant buffer word in the RC form). The selector (Rb, Rc in the RC form, the constant buffer word, or the immediate) picks each result byte: in the index mode (0) its nibble i, whose bit 3 replicates the byte's sign; in the others by c, its low two bits, as PTX's prmt defines F4E (1), B4E (2), RC8 (3), ECL (4), ECR (5) and RC16 (6)

let f = Form();
let low = R_read(RegA());
let selector = if f == 0 then R_read(RegB()) else if f == 1 then R_read(UInt(Field(39, 8)))
               else if f == 2 then CbufWord()
               else Bits32(ZeroExtend(Field(20, 19), 32) | (if Field(56, 1) == 0b1 then 0xfff80000 else 0x00000000));
let high = if f == 1 then CbufWord() else R_read(UInt(Field(39, 8)));
let mode = UInt(Field(48, 3));
var result : bits(32) = 0x00000000;
let three = Bits32(0x00000003);
let sel = selector & three;
foreach (k from 0 to 3) {
    let position = Bits32(to_bits(32, k));
    let nibble = if mode == 0 then (selector >> to_bits(32, 4 * k)) & 0x0000000f else 0x00000000;
    let idx = match mode {
        0 => nibble,
        1 => sel + position,
        2 => sel - position,
        3 => sel,
        4 => if UInt(sel) < UInt(position) then position else sel,
        5 => if UInt(sel) < UInt(position) then sel else position,
        _ => ((sel & 0x00000001) << 1) + to_bits(32, MOD(k, 2))
    };
    let byte0 = PrmtByte(low, high, idx);
    let byte = if mode == 0 then {
        /* a nibble's bit 3 replicates the byte's sign across it */
        let replicate = (nibble & 0x00000008) != 0x00000000;
        let negative = (byte0 & 0x00000080) != 0x00000000;
        if replicate then (if negative then 0x000000ff else 0x00000000) else byte0
    } else byte0;
    result = result | (byte << to_bits(32, 8 * k))
};
R_write(Dst(), result)

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).