[clang] [Matrix][Clang][HLSL] Move MaxMatrixDimension to a LangOpt (PR #163307)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 15 08:30:40 PDT 2025


================
@@ -10,3 +10,9 @@ uint16_t4x4 mat2;
 matrix<int, 5, 5> mat3;
 // expected-error at -1 {{constraints not satisfied for alias template 'matrix' [with element = int, rows_count = 5, cols_count = 5]}}
 // expected-note@* {{because '5 <= 4' (5 <= 4) evaluated to false}}
+
+using float8x4 = __attribute__((matrix_type(8,4))) float;
+// expected-error at -1 {{matrix row size too large}}
+
+using float4x8 = __attribute__((matrix_type(4,8))) float;
+// expected-error at -1 {{matrix column size too large}}
----------------
llvm-beanz wrote:

A few other cases to consider:
```c++
using float8x8 = __attribute__((matrix_type(8,8))) float; // both dimensions too large

// these are likely tested in C/C++, but might be worth verifying or just adding them:
using floatNeg1x4 = __attribute__((matrix_type(-1,4))) float; // negative rows
using float4xNeg1 = __attribute__((matrix_type(4,-1))) float; // negative columns
using floatNeg1xNeg1 = __attribute__((matrix_type(-1,-1))) float; // both dimensions negative!

using float0x4 = __attribute__((matrix_type(0,4))) float; // zero rows?
using float4x0 = __attribute__((matrix_type(4,0))) float; // zero columns?
using float0x0 = __attribute__((matrix_type(0,0))) float; // both dimensions zero
```

https://github.com/llvm/llvm-project/pull/163307


More information about the cfe-commits mailing list