[SM6.10] Add LinAlg Matrix attributes and two new attributed matrix types#8125
Conversation
| __builtin_LinAlg_Matrix [[__LinAlg_Matrix_Attributes(ComponentType::I32, 4, 5, MatrixUse::B, MatrixScope::ThreadGroup)]] mat8; | ||
|
|
||
| // expected-error@+1 {{cannot initialize a variable of type '__builtin_LinAlg_Matrix' with an lvalue of type '__builtin_LinAlg_Matrix [[__LinAlg_Matrix_Attributes(ComponentType::I32, 4, 5, MatrixUse::B, MatrixScope::ThreadGroup)]]'}} | ||
| __builtin_LinAlg_Matrix naked_mat = mat8; |
There was a problem hiding this comment.
Should it be illegal to declare this type without attributes? Is that the reason for TMP?
There was a problem hiding this comment.
We could make it illegal by intercepting every place where a type can be used and adding a special check and error if it is the __builtin_LinAlgMatrix without attributes. Or we can do nothing because the naked typed cannot be used for anything anyway. The __builtin prefix means users should not be using these directly.
…://github.com/microsoft/DirectXShaderCompiler into linalg-matrix-attributes-and-types
V-FEXrt
left a comment
There was a problem hiding this comment.
LGTM but I did a very rush job on the review. Wanted to mark my general approval before being out the next couple days
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
llvm-beanz
left a comment
There was a problem hiding this comment.
There's a lot of boilerplate here, but it all looks pretty reasonable to me.
| #ifdef __hlsl_dx_compiler | ||
| #define SIZE_TYPE int | ||
| #else | ||
| #define SIZE_TYPE uint | ||
| #endif |
There was a problem hiding this comment.
I don't expect that this header will be portable to clang, so for the purposes of DXC we can simplify this to just:
| #ifdef __hlsl_dx_compiler | |
| #define SIZE_TYPE int | |
| #else | |
| #define SIZE_TYPE uint | |
| #endif | |
| #define SIZE_TYPE int |
We should probably file an issue to decide what to do about size types generally in HLSL. I don't love that DXC decided size types were signed 32-bit integers, but we may want Clang to match that for at least some language modes (cc @tex3d & @bogner for visibility about Clang and language spec issues).
…ectly in error reporting
…iler into linalg-matrix-attributes-and-types
pow2clk
left a comment
There was a problem hiding this comment.
I just implemented almost this exact change, so I had many thoughts. Nothing is really blocking, but some things you may want to consider
…iler into linalg-matrix-attributes-and-types
Adds new type attribute
__LinAlg_Matrix_Attributesthat can be attached to__builtin_LinAlg_Matrixbuilt-in matrix handle type to specify the matrix component type, dimensions, use and scope. Includes enabling C11++ -style attributes on types in DXC.Adds two new AST types that are used to capture the information from the attribute:
AttributedLinAlgMatrixTypetype is used when the attribute specifies concrete matrix parametersDependentAttributedLinAlgMatrixTypeis for cases where the type attributes arguments are dependent on template instantiationThe
AttributedLinAlgMatrixTypeis linked toLinAlgMatrixtype alias used ingen_intrin_main.txtfor built-in function APIs.This change also adds the outline of the LinAlg
Matrixtemplate class todx/linalg.h, including the enumeration types used as arguments to the new attribute and as template parameters ofMatrix.Note that the
ComponentTypeenum indx/linalg.his defined using values matching the existing internalComponentTypeenum that was added in SM 6.9 for cooperative vectors. This is different from the current LinAlg spec. The issue to update the spec is microsoft/hlsl-specs#779.Fixes #8122