BFI

Integer, logic, video and predicate instructions

fixed bit field field the encoding fixes should be

BFI (reg)

6362616059585756555453525150494847464544434241403938373635343332
0101101111110
313029282726252423222120191817161514131211109876543210
Rbpred.notpredRaRd

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

Runs execute_BFI with Form() 0.

BFI (rc)

6362616059585756555453525150494847464544434241403938373635343332
0101001111110
313029282726252423222120191817161514131211109876543210
Rbpred.notpredRaRd

bits 63:48: 0101 0011 1111 0---

Runs execute_BFI with Form() 1.

BFI (cr)

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

bits 63:48: 0100 1011 1111 0---

Runs execute_BFI with Form() 2.

BFI (imm)

6362616059585756555453525150494847464544434241403938373635343332
0011011imm.sign11110imm
313029282726252423222120191817161514131211109876543210
immpred.notpredRaRd

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

Runs execute_BFI 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
[47]47execute_BFI
base46:39execute_BFI
Rb27:20RegB()
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

BFI: a's low bits into the base at the packed operand's offset (its low byte) and width (its second), an offset past 31 leaving the base, a width cut at the word's end; .CC the flags

let f = Form();
let base = if f == 1 then CbufWord() else R_read(UInt(Field(39, 8)));
let packed = if f == 2 then CbufWord() else if f == 1 then R_read(UInt(Field(39, 8)))
             else if f == 3 then Right(2) else R_read(RegB());
let mask = Bits32(0x000000ff);
let offset = packed & mask;
let width0 = (packed >> 8) & mask;
let thirty_two = Bits32(0x00000020);
let valid = UInt(offset) < UInt(thirty_two);
let safe_offset = if valid then offset else 0x00000000;
let remaining = thirty_two - safe_offset;
let fits = UInt(width0) < UInt(remaining);
let width = if fits then width0 else remaining;
let inserted = BitsInsert(base, R_read(RegA()), safe_offset, width);
let value = if valid then inserted else base;
if Field(47, 1) == 0b1 then FlagsLogic(value);
R_write(Dst(), 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).