BFE

Integer, logic, video and predicate instructions

fixed bit field field the encoding fixes should be

BFE (reg)

6362616059585756555453525150494847464544434241403938373635343332
0101110000000
313029282726252423222120191817161514131211109876543210
Rbpred.notpredRaRd

bits 63:48: 0101 1100 0000 0---

Runs execute_BFE with Form() 0.

BFE (cbuf)

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

bits 63:48: 0100 1100 0000 0---

Runs execute_BFE with Form() 1.

BFE (imm)

6362616059585756555453525150494847464544434241403938373635343332
0011100imm.sign00000imm
313029282726252423222120191817161514131211109876543210
immpred.notpredRaRd

bits 63:48: 0011 100- 0000 0---

Runs execute_BFE with Form() 2.

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
nonzero48execute_BFE
[47]47execute_BFE
source40execute_BFE
Rb27:20the right operand
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

BFE: the field of a (bit-reversed with 40) at the packed operand's offset (its low byte, clamped to 31) and width (its second byte, cut at the word's end), signed with 48; an empty field, or one at 32 or past unsigned, is 0

let packed = RightOf(Form());
let source0 = R_read(RegA());
let source = if Field(40, 1) == 0b1 then BitReverse32(source0) else source0;
let raw_offset = packed & 0x000000ff;
let thirty_one = Bits32(0x0000001f);
let offset = if UInt(thirty_one) < UInt(raw_offset) then thirty_one else raw_offset;
let raw_width = (packed >> 8) & 0x000000ff;
let remaining = 0x00000020 - offset;
let width = if UInt(remaining) < UInt(raw_width) then remaining else raw_width;
let nonzero0 = width != 0x00000000;
let nonzero = if Field(48, 1) == 0b0 then nonzero0 & (UInt(raw_offset) < 32) else nonzero0;
let safe_width = if nonzero then width else 0x00000001;
let extracted = if Field(48, 1) == 0b1 then Bits32(BitsS(source, offset, safe_width)) else BitsU(source, offset, safe_width);
let value = if nonzero then extracted else 0x00000000;
if Field(47, 1) == 0b1 then FlagsLogic(value); /* BFE.CC, as Eden writes it */
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).