Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/isa/codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ MinstEncodedWord EncodeMinst(const Minst &inst) noexcept {
}
}

bits = (bits & ~inst.form->mask) | inst.form->match;

for (const auto &constraint : ConstraintsFor(*inst.form)) {
const auto *field = inst.FindDecodedField(constraint.field_name);
if (field == nullptr) {
Expand Down
60 changes: 30 additions & 30 deletions src/isa/generated_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4825,61 +4825,61 @@ const MinstFormDesc kForms[] = {
.constraint_start = 1,
.constraint_count = 0},
{.uid = "5537088c4f03",
.mnemonic = "B.IOT",
.asm_template = "B.IOT [SrcTile0<.reuse>, SrcTile1<.reuse>], group=1, ->DstTile<RegSrc>",
.mnemonic = "B.ITP",
.asm_template = "B.ITP [SrcTile0<.reuse>, SrcTile1<.reuse>], last, src_pair",
.encoding_kind = "L32",
.group = "Block Input & Output",
.uop_group = "CMD",
.uop_big_kind = "CMD",
.length_bits = 32,
.fixed_bits = 10,
.mask = 0x707fULL,
.match = 0x5013ULL,
.fixed_bits = 11,
.mask = 0xf0ffULL,
.match = 0xa013ULL,
.field_start = 77,
.field_count = 8,
.constraint_start = 1,
.constraint_count = 0},
{.uid = "f6b1a38eb134",
.mnemonic = "B.IOT",
.asm_template = "B.IOT [SrcTile0<.reuse>, SrcTile1<.reuse>], group=0, ->DstTile<RegSrc>",
.mnemonic = "B.ITP",
.asm_template = "B.ITP [SrcTile0<.reuse>, SrcTile1<.reuse>], src_pair",
.encoding_kind = "L32",
.group = "Block Input & Output",
.uop_group = "CMD",
.uop_big_kind = "CMD",
.length_bits = 32,
.fixed_bits = 10,
.mask = 0x707fULL,
.match = 0x4013ULL,
.fixed_bits = 11,
.mask = 0xf0ffULL,
.match = 0x2013ULL,
Comment on lines +4828 to +4852

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Both B.ITP instruction forms (UID 5537088c4f03 and f6b1a38eb134) have identical .mask (0x70ffULL) and .match (0x2013ULL) values. This creates a decoding ambiguity because the instruction decoder cannot uniquely distinguish between the form with the last modifier and the form without it based on the opcode mask and match. If last corresponds to a specific bit in the instruction encoding, that bit needs to be included in the mask and differentiated in the match values (similar to how bit 12 was used to distinguish the original B.IOT forms).

.field_start = 85,
.field_count = 8,
.constraint_start = 1,
.constraint_count = 0},
{.uid = "0be0ecce86bb",
.mnemonic = "B.IOTI",
.asm_template = "B.IOTI [SrcTile0<.reuse>, SrcTile1<.reuse>], group=0, ->DstTile<Size>",
.mnemonic = "B.OTA",
.asm_template = "B.OTA ->DstTile<CellCountM1>, dst_slot",
.encoding_kind = "L32",
.group = "Block Input & Output",
.uop_group = "CMD",
.uop_big_kind = "CMD",
.length_bits = 32,
.fixed_bits = 10,
.mask = 0x707fULL,
.match = 0x6013ULL,
.fixed_bits = 11,
.mask = 0xf0ffULL,
.match = 0x3013ULL,
.field_start = 93,
.field_count = 8,
.constraint_start = 1,
.constraint_count = 0},
{.uid = "fb045cf4149a",
.mnemonic = "B.IOTI",
.asm_template = "B.IOTI [SrcTile0<.reuse>, SrcTile1<.reuse>], group=1, ->DstTile<Size>",
.mnemonic = "B.OTA",
.asm_template = "B.OTA ->DstTile<CellCountM1>, last, dst_slot",
.encoding_kind = "L32",
.group = "Block Input & Output",
.uop_group = "CMD",
.uop_big_kind = "CMD",
.length_bits = 32,
.fixed_bits = 10,
.mask = 0x707fULL,
.match = 0x7013ULL,
.fixed_bits = 11,
.mask = 0xf0ffULL,
.match = 0xb013ULL,
.field_start = 101,
.field_count = 8,
.constraint_start = 1,
Expand Down Expand Up @@ -5126,7 +5126,7 @@ const MinstFormDesc kForms[] = {
.constraint_count = 0},
{.uid = "bd3f337acb9d",
.mnemonic = "BSTART.CUBE",
.asm_template = "BSTART.CUBE Function, DataType",
.asm_template = "BSTART.CUBE 0, DataType",
.encoding_kind = "L32",
.group = "Block Split",
.uop_group = "CMD",
Expand All @@ -5141,7 +5141,7 @@ const MinstFormDesc kForms[] = {
.constraint_count = 3},
{.uid = "3b0ae11126a6",
.mnemonic = "BSTART.FIXP",
.asm_template = "BSTART.FIXP TileOp, DataType",
.asm_template = "BSTART.FIXP Function, DataType",
.encoding_kind = "L32",
.group = "Block Split",
.uop_group = "CMD",
Expand Down Expand Up @@ -5470,8 +5470,8 @@ const MinstFormDesc kForms[] = {
.constraint_start = 4,
.constraint_count = 1},
{.uid = "f9da70e4e0ad",
.mnemonic = "BSTART.TMATMUL",
.asm_template = "BSTART.TMATMUL DataType",
.mnemonic = "BSTART.CUBE",
.asm_template = "BSTART.CUBE 2, DataType",
.encoding_kind = "L32",
.group = "Block Split",
.uop_group = "CMD",
Expand All @@ -5485,8 +5485,8 @@ const MinstFormDesc kForms[] = {
.constraint_start = 5,
.constraint_count = 0},
{.uid = "0c8c62e5f00a",
.mnemonic = "BSTART.TMATMUL.ACC",
.asm_template = "BSTART.TMATMUL.ACC DataType",
.mnemonic = "BSTART.CUBE",
.asm_template = "BSTART.CUBE Function, DataType",
.encoding_kind = "L32",
.group = "Block Split",
.uop_group = "CMD",
Expand All @@ -5500,8 +5500,8 @@ const MinstFormDesc kForms[] = {
.constraint_start = 5,
.constraint_count = 0},
{.uid = "211446509efb",
.mnemonic = "BSTART.TMOV",
.asm_template = "BSTART.TMOV DataType",
.mnemonic = "BSTART.FIXP",
.asm_template = "BSTART.FIXP 2, DataType",
.encoding_kind = "L32",
.group = "Block Split",
.uop_group = "CMD",
Expand All @@ -5515,8 +5515,8 @@ const MinstFormDesc kForms[] = {
.constraint_start = 5,
.constraint_count = 0},
{.uid = "4048b6e8b0f4",
.mnemonic = "BSTART.TSTORE",
.asm_template = "BSTART.TSTORE DataType",
.mnemonic = "BSTART.TMA",
.asm_template = "BSTART.TMA 1, DataType",
.encoding_kind = "L32",
.group = "Block Split",
.uop_group = "CMD",
Expand Down
45 changes: 45 additions & 0 deletions tests/unit/minst_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using linx::model::isa::DecodeMinstPacked;
using linx::model::isa::EncodeMinst;
using linx::model::isa::FieldsFor;
using linx::model::isa::LookupFormByMnemonic;
using linx::model::isa::LookupFormByUid;
using linx::model::isa::Minst;
using linx::model::isa::MinstCodecStatus;
using linx::model::isa::MinstConstraintDesc;
Expand Down Expand Up @@ -366,6 +367,45 @@ int RunAsmTemplateReplacementSmoke() {
return 0;
}

int RunDescriptorLastBitSmoke() {
struct Case {
std::string_view uid;
bool last;
};
const std::array<Case, 4> cases = {{
{"5537088c4f03", true},
{"f6b1a38eb134", false},
{"0be0ecce86bb", false},
{"fb045cf4149a", true},
}};

for (std::size_t i = 0; i < cases.size(); ++i) {
const auto *form = LookupFormByUid(cases[i].uid);
if (form == nullptr) {
return 60 + static_cast<int>(i);
}

Minst inst = BuildSatisfyingInst(*form);
const auto encoded = EncodeMinst(inst);
if (!encoded.valid || encoded.status != MinstCodecStatus::Ok) {
return 64 + static_cast<int>(i);
}
if (((encoded.bits & (std::uint64_t{1} << 15U)) != 0) != cases[i].last) {
return 68 + static_cast<int>(i);
}

Minst decoded;
if (DecodeMinstPacked(encoded.bits, encoded.length_bits, decoded) != MinstCodecStatus::Ok) {
return 72 + static_cast<int>(i);
}
if (decoded.form_id != cases[i].uid) {
return 76 + static_cast<int>(i);
}
}

return 0;
}

} // namespace

int main() {
Expand Down Expand Up @@ -399,5 +439,10 @@ int main() {
std::cerr << "RunAsmTemplateReplacementSmoke failed with code " << asm_replace << '\n';
return 6;
}
const auto descriptor_last = RunDescriptorLastBitSmoke();
if (descriptor_last != 0) {
std::cerr << "RunDescriptorLastBitSmoke failed with code " << descriptor_last << '\n';
return 7;
}
return 0;
}
Loading