[clang] [HLSL] Add support for the HLSL matrix type (PR #159446)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 22 13:12:17 PDT 2025
================
@@ -243,6 +243,7 @@ ENUM_LANGOPT(HLSLVersion, HLSLLangStd, 16, HLSL_Unset, NotCompatible, "HLSL Vers
LANGOPT(HLSLStrictAvailability, 1, 0, NotCompatible,
"Strict availability diagnostic mode for HLSL built-in functions.")
LANGOPT(HLSLSpvUseUnknownImageFormat, 1, 0, NotCompatible, "For storage images and texel buffers, sets the default format to 'Unknown' when not specified via the `vk::image_format` attribute. If this option is not used, the format is inferred from the resource's data type.")
+VALUE_LANGOPT(MaxMatrixDimension, 32, (1 << 20) - 1, NotCompatible, "maximum allowed matrix dimension")
----------------
farzonl wrote:
The goal should likely be to replace the constexpr `MaxElementsPerDimension` with this language option.
https://github.com/llvm/llvm-project/blob/129c6836b772988b77b60683f8b1e6d65ddc1ce4/clang/include/clang/AST/TypeBase.h#L4371-L4379
But that would require updating all of these static constexpr functions with something that takes a SemaPtr
https://github.com/llvm/llvm-project/blob/129c6836b772988b77b60683f8b1e6d65ddc1ce4/clang/include/clang/AST/TypeBase.h#L4399-L4407
For now we will make this an HLSL only language opt and create an issue to make it more generic:
```suggestion
VALUE_LANGOPT(HLSLMaxMatrixDimension, 32, 4, NotCompatible, "maximum allowed matrix dimension")
```
https://github.com/llvm/llvm-project/pull/159446
More information about the cfe-commits
mailing list