[clang] Enable matrices in HLSL (PR #111415)

Greg Roth via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 14 10:09:53 PDT 2024


================
@@ -1381,7 +1381,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
   if (LangOpts.OpenACC && !LangOpts.OpenMP) {
     InitBuiltinType(ArraySectionTy, BuiltinType::ArraySection);
   }
-  if (LangOpts.MatrixTypes)
+  if (LangOpts.MatrixTypes || LangOpts.HLSL)
----------------
pow2clk wrote:

I've done this two ways now:
https://github.com/llvm/llvm-project/pull/111415/commits/ae1a58be4272bd652fb9891e7670f05574b9eb7e just enables matrices when HLSL is enabled
https://github.com/llvm/llvm-project/pull/111415/commits/eeb31651eeff04a612829c7858955772ba2b2b6e attempts to use LangStandards and make it dependent on HLSL versions

I confess I don't know why the second is preferable to the first. If I've misunderstood @llvm-beanz's suggestion, please let me know.

I'm actually unclear on how any of this prevents the problem @farzonl brought up. If what MatrixTypes represents changes so that it no longer matches what HLSL wants, then those changes will seep in without our notice. Given that the design discussion we had about this rejected the notion that we'd forge our own matrix type that inherited from the clang type, I don't see any way around that problem unless we pay attention to its evolution and weigh in when needed. Not that I'm saying that's a bad idea regardless.

All that the above changes alter is that now matrices can be declared using the clang extension which will sidestep at least the size restrictions we have not yet applied, but intend to.

I'm unconvinced this is an improvement, but it was easy enough to do that I thought I'd give us more concrete options to discuss.

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


More information about the cfe-commits mailing list