SHF

Integer, logic, video and predicate instructions

fixed bit field field the encoding fixes should be

SHF (l reg)

6362616059585756555453525150494847464544434241403938373635343332
0101101111111
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0101 1011 1111 1---

Runs execute_SHF with Form() 0.

SHF (l imm)

6362616059585756555453525150494847464544434241403938373635343332
001101111111
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0011 011- 1111 1---

Runs execute_SHF with Form() 1.

SHF (r reg)

6362616059585756555453525150494847464544434241403938373635343332
0101110011111
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0101 1100 1111 1---

Runs execute_SHF with Form() 2.

SHF (r imm)

6362616059585756555453525150494847464544434241403938373635343332
001110011111
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0011 100- 1111 1---

Runs execute_SHF 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
safe50execute_SHF
high46:39execute_SHF
longest38:37execute_SHF
shift38:20execute_SHF
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

SHF: the funnel shift of (c:a) by b, left or right, the count wrapped (50) or clamped to the type's (37-38: 2 and 3 the 64-bit ones, 3 signed)

let f = Form(); /* 0 LR, 1 LI, 2 RR, 3 RI */
let left_shift = f <= 1;
let shift = if f == 0 | f == 2 then R_read(RegB()) else Bits32(ZeroExtend(Field(20, 19), 32));
let longest = UInt(Field(37, 2)) >= 2;
let limit = Bits32(if longest then 0x0000003f else 0x00000020);
let wrapped = shift & (if longest then 0x0000003f else 0x0000001f);
let safe = if Field(50, 1) == 0b1 then wrapped else (if UInt(limit) < UInt(shift) then limit else shift);
let low = R_read(RegA());
let high = R_read(UInt(Field(39, 8)));
let small = safe & 0x0000001f;
let left = high << small;
let reverse = (0x00000020 - safe) & 0x0000001f;
let right = low >> reverse;
let combined0 = left | right;
let combined = if left_shift then (if safe == 0x00000000 then high else combined0) else {
    let low_part = low >> small;
    let high_part = high << reverse;
    let c = low_part | high_part;
    if safe == 0x00000000 then low else c
};
let long_shift = (safe - 0x00000020) & 0x0000001f;
let long_value = if left_shift then low << long_shift else if Field(37, 2) == 0b11 then AshrS(high, long_shift)
                 else high >> long_shift;
R_write(Dst(), if UInt(safe) < 32 then combined else long_value)

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