[SM6.10] LinAlg Validation: Convert - #8837
Open
Ashley Coleman (V-FEXrt) wants to merge 2 commits into
Open
Conversation
Fixes #8509 Implements LinAlg Convert validation rules
Contributor
You can test this locally with the following command:git-clang-format --diff 29da40966bad93f2880bda4e544938a2f898d382 9cbd1daea10ac89a5891ad690beee4c4dd175ad0 -- lib/DxilValidation/DxilValidation.cpp lib/DxilValidation/DxilValidationUtils.cpp lib/DxilValidation/DxilValidationUtils.hView the diff from clang-format here.diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp
index 01af6469..0db601d2 100644
--- a/lib/DxilValidation/DxilValidation.cpp
+++ b/lib/DxilValidation/DxilValidation.cpp
@@ -1553,56 +1553,66 @@ static void ValidateLinAlgConvert(CallInst *CI, ValidationContext &ValCtx) {
VectorType *InVecTy = cast<VectorType>(Op.get_inputVector()->getType());
// Input interp must be a immarg of allowed ComponentType
- std::optional<uint64_t> InputInterpV = ValidateConstantIntGetValue(
- CI, Op.get_inputInterpretation(), ValCtx, "InputInterpretation", "LinAlgConvert");
+ std::optional<uint64_t> InputInterpV =
+ ValidateConstantIntGetValue(CI, Op.get_inputInterpretation(), ValCtx,
+ "InputInterpretation", "LinAlgConvert");
if (!InputInterpV)
return;
- DXIL::ComponentType InputInterp = static_cast<DXIL::ComponentType>(*InputInterpV);
+ DXIL::ComponentType InputInterp =
+ static_cast<DXIL::ComponentType>(*InputInterpV);
ValidateLinAlgComponentType(CI, InputInterp, ValCtx, "InputInterpretation");
// Output interp must be a immarg of allowed ComponentType
- std::optional<uint64_t> OutputInterpV = ValidateConstantIntGetValue(
- CI, Op.get_outputInterpretation(), ValCtx, "OutputInterpretation", "LinAlgConvert");
+ std::optional<uint64_t> OutputInterpV =
+ ValidateConstantIntGetValue(CI, Op.get_outputInterpretation(), ValCtx,
+ "OutputInterpretation", "LinAlgConvert");
if (!OutputInterpV)
return;
- DXIL::ComponentType OutputInterp = static_cast<DXIL::ComponentType>(*OutputInterpV);
+ DXIL::ComponentType OutputInterp =
+ static_cast<DXIL::ComponentType>(*OutputInterpV);
ValidateLinAlgComponentType(CI, OutputInterp, ValCtx, "OutputInterpretation");
bool IsNativeInputInterp = IsComponentTypeNative(InputInterp);
bool IsNativeOutputInterp = IsComponentTypeNative(OutputInterp);
- // If input interp is native then input vector element type must match that type
- if (IsNativeInputInterp && !IsComponentTypeSameNativeType(InputInterp, InVecTy->getElementType()))
+ // If input interp is native then input vector element type must match that
+ // type
+ if (IsNativeInputInterp &&
+ !IsComponentTypeSameNativeType(InputInterp, InVecTy->getElementType()))
ValCtx.EmitInstrFormatError(
CI, ValidationRule::InstrLinAlgMatrixVectorTypeMustMatch,
- {"Input", TypeToString(InVecTy->getElementType()), "InputInterpretation",
- ComponentTypeToString(InputInterp)});
+ {"Input", TypeToString(InVecTy->getElementType()),
+ "InputInterpretation", ComponentTypeToString(InputInterp)});
// If input interp is non-native then input vector element type must be i32
if (!IsNativeInputInterp && !InVecTy->getElementType()->isIntegerTy(32))
ValCtx.EmitInstrFormatError(
CI, ValidationRule::InstrLinAlgMatrixVectorTypeMustMatchPacked,
- {"Input", TypeToString(InVecTy->getElementType()), "InputInterpretation",
- ComponentTypeToString(InputInterp)});
+ {"Input", TypeToString(InVecTy->getElementType()),
+ "InputInterpretation", ComponentTypeToString(InputInterp)});
- // If output interp is native then output vector element type must match that type
- if (IsNativeOutputInterp && !IsComponentTypeSameNativeType(OutputInterp, RetVecTy->getElementType()))
+ // If output interp is native then output vector element type must match that
+ // type
+ if (IsNativeOutputInterp &&
+ !IsComponentTypeSameNativeType(OutputInterp, RetVecTy->getElementType()))
ValCtx.EmitInstrFormatError(
CI, ValidationRule::InstrLinAlgMatrixVectorTypeMustMatch,
- {"Output", TypeToString(RetVecTy->getElementType()), "OutputInterpretation",
- ComponentTypeToString(OutputInterp)});
+ {"Output", TypeToString(RetVecTy->getElementType()),
+ "OutputInterpretation", ComponentTypeToString(OutputInterp)});
// If output interp is non-native then output vector element type must be i32
if (!IsNativeOutputInterp && !RetVecTy->getElementType()->isIntegerTy(32))
ValCtx.EmitInstrFormatError(
CI, ValidationRule::InstrLinAlgMatrixVectorTypeMustMatchPacked,
- {"Output", TypeToString(RetVecTy->getElementType()), "OutputInterpretation",
- ComponentTypeToString(OutputInterp)});
+ {"Output", TypeToString(RetVecTy->getElementType()),
+ "OutputInterpretation", ComponentTypeToString(OutputInterp)});
// output vector length must be properly converted from input length
- unsigned InputElemCount = InVecTy->getNumElements() * ComponentTypeElementsPerScalar(InputInterp);
+ unsigned InputElemCount =
+ InVecTy->getNumElements() * ComponentTypeElementsPerScalar(InputInterp);
unsigned OutputElemPerScalar = ComponentTypeElementsPerScalar(OutputInterp);
- unsigned ExpectedOutVecSize = (InputElemCount + OutputElemPerScalar - 1) / OutputElemPerScalar;
+ unsigned ExpectedOutVecSize =
+ (InputElemCount + OutputElemPerScalar - 1) / OutputElemPerScalar;
if (RetVecTy->getNumElements() != ExpectedOutVecSize)
ValCtx.EmitInstrFormatError(
CI, ValidationRule::InstrLinAlgMatrixDimVectorMismatch,
|
Contributor
There was a problem hiding this comment.
Pull request overview
Implements Shader Model 6.10 validation rules for LinAlg Convert operations.
Changes:
- Validates interpretation constants, vector element types, and output dimensions.
- Adds validation diagnostics and DXIL documentation.
- Adds and updates validation/code-generation tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/DxilValidation/DxilValidation.cpp |
Implements Convert validation. |
lib/DxilValidation/DxilValidationUtils.cpp |
Identifies native component types. |
lib/DxilValidation/DxilValidationUtils.h |
Declares the native-type helper. |
utils/hct/hctdb.py |
Defines new validation messages. |
docs/DXIL.rst |
Documents the new rules. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-convert.ll |
Tests validation failures. |
tools/clang/test/CodeGenDXIL/hlsl/linalg/builtins/convert/nominal.hlsl |
Updates nominal inputs to valid interpretations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return; | ||
| DXIL::ComponentType InputInterp = | ||
| static_cast<DXIL::ComponentType>(*InputInterpV); | ||
| ValidateLinAlgComponentType(CI, InputInterp, ValCtx, "InputInterpretation"); |
| (InputElemCount + OutputElemPerScalar - 1) / OutputElemPerScalar; | ||
| if (RetVecTy->getNumElements() != ExpectedOutVecSize) | ||
| ValCtx.EmitInstrFormatError( | ||
| CI, ValidationRule::InstrLinAlgMatrixDimVectorMismatch, |
| @@ -1547,6 +1547,77 @@ static void ValidateLinAlgMatrixAccumulateToMemory(CallInst *CI, | |||
|
|
|||
| static void ValidateLinAlgConvert(CallInst *CI, ValidationContext &ValCtx) { | |||
| ValidateLinAlgOpParameters(CI, ValCtx); | |||
Damyan Pepper (damyanp)
left a comment
Member
There was a problem hiding this comment.
LGTM, although some of the copilot comments look like they need addressing.
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.
Fixes #8509
Implements LinAlg Convert validation rules
Stack created with GitHub Stacks CLI • Give Feedback 💬