The latest LinAlg spec requires that the matrix handles be attributed by the user in source (99% of the time this will be handle directly but the Matrix API, the last 1% is people holding the API wrong). This should be fairly straightforward and maybe even already done but that needs to be confirmed.
IIRC the attributes should be attached to the handle at the AST level.
The end goal should look like this handle from clang.
https://github.com/llvm/llvm-project/blob/main/clang/test/ParserHLSL/hlsl_contained_type_attr.hlsl