Skip to content

[mlir][dxsa] Add unknown instruction#156

Open
tagolog wants to merge 2 commits into
access-softek:dxsa-mlirfrom
tagolog:dxsa-mlir-unknown-instruction
Open

[mlir][dxsa] Add unknown instruction#156
tagolog wants to merge 2 commits into
access-softek:dxsa-mlirfrom
tagolog:dxsa-mlir-unknown-instruction

Conversation

@tagolog
Copy link
Copy Markdown

@tagolog tagolog commented Jun 2, 2026

Example:
dxsa.dcl_temps 1
dxsa.unknown <tokens = [0x030007FF, 0xDEADBEEF, 0x12345678]>
dxsa.dcl_temps 2

tagolog added 2 commits June 1, 2026 16:28
Wraps the program into a module with optional attributes program type and shader version.
When the binary has no header both attributes are omitted.

Example:
  dxsa.module pixel_shader 5 0 {
    dxsa.dcl_global_flags <refactoringAllowed>
  }

  dxsa.module {
    dxsa.dcl_global_flags <refactoringAllowed>
  }

Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
Example:
  dxsa.dcl_temps 1
  dxsa.unknown <tokens = [0x030007FF, 0xDEADBEEF, 0x12345678]>
  dxsa.dcl_temps 2

Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
@tagolog tagolog requested a review from asavonic June 2, 2026 01:17
let summary = "raw tokens fallback for an undecodable instruction";
let description = [{
The `dxsa.unknown` operation represents one instruction whose raw
tokens could not be decoded into a structured op — unknown opcode,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Em dash?

/// On failure any partial IR is rewound by guard.
bool tryParseAsStructured(const InstructionSlice &slice) {
auto expectedEnd = slice.beginOffset + slice.numTokens * tokenSize;
DXBuilder::RewindGuard guard(builder);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If RewindGuard is only used once, and we still have to disarm it explicitly, it is not much different than an explicit call to a cleanup routine next to return false below.

StringRef hint; // short reason, included in the warning
};

std::optional<InstructionSlice> sliceInstruction() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

parseInstruction already decodes and verifies instruction length to verify it. Can we avoid duplicating this code here as well? With custom data it is already non trivial.

SmallVector<int32_t> snapshotTokens(size_t beginOffset, uint32_t numTokens) {
SmallVector<int32_t> out(numTokens);
for (uint32_t i = 0; i < numTokens; ++i)
out[i] = static_cast<int32_t>(support::endian::read<uint32_t>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alternatively, we can reset currentTokenOffset to beginOffset and use parseToken with additional error handling of EOF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants