fixed bit field field the encoding fixes should be
| 63 | 62 | 61 | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51 | 50 | 49 | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 |
| 0 | 1 | 0 | 0 | 0 | pred | skipinv | nosched | unknown | syncstart | dest_ext | end | src1_ext | src2_ext | repeat_count | src_fmt | dest_fmt | mask | dest_bank | |||||||||||||
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| src1_bank | src2_bank | dest_n | sel3 | scale | sel1 | sel2 | src1_n | sel0_bit1 | src2_n | sel0_bit0 | |||||||||||||||||||||
bits 63:0: 0100 0xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
It is in a group of patterns that may match the same word: the decoder tries them in this order, and the first that matches decodes it: VPCK, VTST, VTSTMSK, VBW.
Runs execute_VPCK with Form() 0.
| Field | Bits | The Sail reads it in |
|---|---|---|
| pred | 58:56 | |
| skipinv | 55 | |
| nosched | 54 | |
| unknown | 53 | |
| syncstart | 52 | |
| dest_ext | 51 | Bit(51) |
| end | 50 | |
| src1_ext | 49 | Bit(49) |
| src2_ext | 48 | Bit(48) |
| repeat_count | 47:44 | execute_VPCK |
| src_fmt | 43:41 | execute_VPCK |
| dest_fmt | 40:38 | execute_VPCK |
| mask | 37:34 | execute_VPCK |
| dest_bank | 33:32 | execute_VPCK |
| src1_bank | 31:30 | execute_VPCK |
| src2_bank | 29:28 | execute_VPCK |
| dest_n | 27:21 | execute_VPCK |
| sel3 | 20:19 | execute_VPCK |
| scale | 18 | Bit(18) |
| sel1 | 17:16 | execute_VPCK |
| sel2 | 15:14 | execute_VPCK |
| src1_n | 13:8 | execute_VPCK |
| sel0_bit1 | 7 | Bit(7) |
| src2_n | 6:1 | execute_VPCK |
| sel0_bit0 | 0 | Bit(0) |
VPCK: src1's components (its swizzle the four selectors) converted from the source format to the destination's, scaled to the formats' ranges with scale; an F32 source reads src1's x and y, then src2's, as one range of four where the selectors or the registers ask it. A repeat at a time
let dest_type = PackType(UInt(Field(38, 3)));
let src_type = PackType(UInt(Field(41, 3)));
let mask = UInt(Field(34, 4));
let scale = Bit(18) == 1;
let src2_n = UInt(Field(1, 6));
Dest(DEST, UInt(Field(21, 7)), UInt(Field(32, 2)), Bit(51), false, 7);
SetType(DEST, dest_type);
let float_src = IsFloatType(src_type);
let float_dest = IsFloatType(dest_type);
let src1_n = if float_src then UInt(Field(8, 6)) else Bit(7) + 2 * UInt(Field(8, 6));
Src12(SRC1, src1_n, UInt(Field(30, 2)), Bit(49), float_src, 7);
Src12(SRC2, src2_n, UInt(Field(28, 2)), Bit(48), true, 7);
SetType(SRC1, src_type);
let sel0 = Bit(0) + 2 * (if src_type == T_F32 then Bit(7) else MOD(src2_n, 2));
let sel1 = UInt(Field(16, 2));
let sel2 = UInt(Field(14, 2));
let sel3 = UInt(Field(19, 2));
SetSwizzle(SRC1, sel0, sel1, sel2, sel3);
let no_cycle = (float_src & float_dest) | (scale & (src_type == T_U8 | dest_type == T_U8));
let use_src2 = if src_type == T_F32 & BankOf(SRC2) != B_IMM then {
let same = NumOf(SRC1) == NumOf(SRC2) & BankOf(SRC1) == BankOf(SRC2);
let contiguous = mask == 1 | mask == 3 | mask == 7 | mask == 15;
let n = Popcount4(mask);
let defaulted = (n < 1 | sel0 == 0) & (n < 2 | sel1 == 1) & (n < 3 | sel2 == 2) & (n < 4 | sel3 == 3);
not_bool(defaulted) | not_bool(same) | not_bool(contiguous)
} else false;
/* the selectors cycled over the components the mask enables (two of them, for bytes, when it enables all) */
if not_bool(no_cycle) then {
let two = (src_type == T_U8 | dest_type == T_U8) & mask == 15;
let m0 = MOD(mask, 2);
let m1 = MOD(DIV(mask, 2), 2);
let m2 = MOD(DIV(mask, 4), 2);
let n1 = m0;
let n2 = m0 + m1;
let n3 = m0 + m1 + m2;
SetSwizzle(SRC1, if two then sel0 else if m0 == 1 then sel0 else sel0,
if two then sel1 else if m1 == 1 then (if n1 == 0 then sel0 else sel1) else sel1,
if two then sel0 else if m2 == 1 then (if n2 == 0 then sel0 else if n2 == 1 then sel1 else sel2)
else sel2,
if two then sel1 else if DIV(mask, 8) == 1 then
(if n3 == 0 then sel0 else if n3 == 1 then sel1 else if n3 == 2 then sel2 else sel3)
else sel3)
};
Multiplier(1, if float_src then 2 else 1, if float_src then 2 else 1, 1);
foreach (r from 0 to UInt(Field(44, 4))) {
if not_bool(Failed()) then {
let o1 = Rep(SRC1, r, O_SRC1, R_SLMSI);
let o2 = Rep(SRC2, r, O_SRC2, R_SLMSI);
if use_src2 then {
/* the two sources as one range of four: src1's x and y, then src2's */
CopyOperand(LO, SRC1);
CopyOperand(HI, SRC2);
SetSwizzle(LO, SW_X, SW_Y, SW_Z, SW_W);
SetSwizzle(HI, SW_X, SW_Y, SW_Z, SW_W);
SetType(HI, src_type);
Load(LO, LO, 3, o1);
Load(HI, HI, 3, o2);
Reset(R, 0, K_FLOAT);
foreach (i from 0 to 3) {
if MOD(DIV(mask, 2 ^ i), 2) == 1 then {
let ch = ChannelOf(SRC1, i);
Push(R, if ch == SW_X then At(LO, 0) else if ch == SW_Y then At(LO, 1)
else if ch == SW_Z then At(HI, 0) else if ch == SW_W then At(HI, 1)
else ChannelConstant(ch))
}
}
} else Load(R, SRC1, mask, o1);
if float_dest & not_bool(float_src) then ToFloat(R, src_type, scale);
if not_bool(float_dest) & float_src then ToInt(R, dest_type, scale);
if not_bool(float_dest) & not_bool(float_src) & IsSignedType(dest_type) != IsSignedType(src_type) then {
CopyValue(OLD, R);
SetKind(R, if IsSignedType(dest_type) then K_INT else K_UINT);
foreach (i from 0 to Count(OLD) - 1) Put(R, i, At(OLD, i))
};
Store(DEST, R, mask, Rep(DEST, r, O_DEST, R_SLMSI))
}
};
ResetMultiplier()
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 Vita3K's usse_translator_entry.cpp (GPL-2.0-or-later).