[mlir][dxsa] Add unknown instruction#156
Open
tagolog wants to merge 2 commits into
Open
Conversation
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>
asavonic
reviewed
Jun 2, 2026
| 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, |
| /// 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); |
Contributor
There was a problem hiding this comment.
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() { |
Contributor
There was a problem hiding this comment.
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>( |
Contributor
There was a problem hiding this comment.
Alternatively, we can reset currentTokenOffset to beginOffset and use parseToken with additional error handling of EOF.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Example:
dxsa.dcl_temps 1
dxsa.unknown <tokens = [0x030007FF, 0xDEADBEEF, 0x12345678]>
dxsa.dcl_temps 2