Skip to content

[SM6.10][NFC] Refactor LinAlg Validations with helpers - #8778

Merged
Ashley Coleman (V-FEXrt) merged 2 commits into
microsoft:mainfrom
V-FEXrt:linalg-vali-refactor
Aug 14, 2026
Merged

[SM6.10][NFC] Refactor LinAlg Validations with helpers#8778
Ashley Coleman (V-FEXrt) merged 2 commits into
microsoft:mainfrom
V-FEXrt:linalg-vali-refactor

Conversation

@V-FEXrt

Copy link
Copy Markdown
Collaborator

NFC

Pulls two common boiler plate operations into helper functions then uses them across all the validation rules

Operations are

  • Get the LinAlgTargetType for a given matrix without raising a diag if its missing (as those diags are already raised)
  • Get the integer value of a Value* that is expected to be an immediate ConstantInt and raise a diag if it isn't

Copilot AI balanced review requested due to automatic review settings August 14, 2026 22:03

Copilot AI left a comment

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refactors DXIL LinAlg validation to reduce repetition by introducing helper utilities for extracting constant operands and for fetching LinAlgTargetType metadata.

Changes:

  • Added ValidateConstantIntGetValue(...) to centralize immediate-constant validation and extraction.
  • Added GetCheckedLATT(...) to centralize LinAlgTargetTypeMap lookup with std::optional results.
  • Updated multiple LinAlg validators to use these helpers instead of repeated dyn_cast/map-lookup sequences.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/DxilValidation/DxilValidation.cpp
Comment thread lib/DxilValidation/DxilValidation.cpp
Copilot AI review requested due to automatic review settings August 14, 2026 22:08

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

lib/DxilValidation/DxilValidation.cpp:1097

  • The new helper name GetCheckedLATT is hard to decode for readers unfamiliar with the LATT abbreviation. Consider renaming to a more explicit name (e.g., GetCheckedLinAlgTargetType or GetLinAlgTargetTypeIfPresent) to improve readability/maintainability.
static std::optional<LinAlgTargetType>
GetCheckedLATT(Type *Ty, ValidationContext &ValCtx) {

lib/DxilValidation/DxilValidation.cpp:989

  • ValidateConstantIntGetValue both emits a diagnostic (side effect) and returns an optional value, which makes it easy for future call sites to ignore std::nullopt and accidentally continue validation with default/placeholder values. Consider renaming this helper to make the side effect explicit (e.g., GetConstantIntValueOrEmitError) and/or documenting the expected usage pattern (treat nullopt as 'validation already failed for this operand').
static std::optional<uint64_t>
ValidateConstantIntGetValue(CallInst *CI, Value *V, ValidationContext &ValCtx,
                            StringRef ValueName, StringRef OpName) {
  if (!isa<ConstantInt>(V)) {
    ValCtx.EmitInstrFormatError(CI, ValidationRule::InstrOpConst,
                                {ValueName, OpName});
    return std::nullopt;
  }

  return cast<ConstantInt>(V)->getLimitedValue();
}

@V-FEXrt
Ashley Coleman (V-FEXrt) merged commit 4b537fd into microsoft:main Aug 14, 2026
13 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Aug 14, 2026
@V-FEXrt
Ashley Coleman (V-FEXrt) deleted the linalg-vali-refactor branch August 14, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants