Skip to content

Conversation

@farzonl
Copy link
Member

@farzonl farzonl commented Dec 8, 2025

fixes #159438

This patch adds MatrixElementExpr, a new AST node for HLSL matrix element and swizzle access (e.g. M._m00, M._11_22_33).

It introduces a shared ElementAccessExprBase used by both matrix and vector swizzle expressions, updates Sema to parse and validate zero-based and one-based accessors, detects duplicates for l-value checks, and emits improved diagnostics. CodeGen is updated to lower scalar and multi-element accesses consistently, and full AST serialization, dumping, and tooling support is included. This implementation reflects the updated RFC for HLSL matrix accessor semantics.

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

🐧 Linux x64 Test Results

  • 112682 tests passed
  • 4095 tests skipped

✅ The build succeeded and all tests passed.

@farzonl farzonl force-pushed the feature/matrix-swizzle-issue-159438 branch from d37d179 to 6e259ed Compare December 9, 2025 00:25
++NumComponents;
}
if (NumComponents == 0 || NumComponents > 4) {
S.Diag(OpLoc, diag::err_hlsl_matrix_swizzle_invalid_length)
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO add a test for this to clang/test/SemaHLSL/matrix-member-access-errors.hlsl with 5 components

@farzonl farzonl force-pushed the feature/matrix-swizzle-issue-159438 branch from 6e259ed to 33847da Compare December 9, 2025 17:13
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@farzonl farzonl force-pushed the feature/matrix-swizzle-issue-159438 branch from 33847da to fcdbceb Compare December 9, 2025 17:16
@farzonl farzonl force-pushed the feature/matrix-swizzle-issue-159438 branch from fcdbceb to 06ce71f Compare December 9, 2025 21:44
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.

[HLSL] Add _m and _<numeric> based (swizzle) accessors to hlsl::matrix.

1 participant