[clang] [HLSL] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

Greg Roth via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 9 16:02:48 PDT 2024


================
@@ -4492,6 +4492,37 @@ void CXXNameMangler::mangleType(const ArrayParameterType *T) {
   mangleType(cast<ConstantArrayType>(T));
 }
 
+void CXXNameMangler::mangleType(const HLSLAttributedResourceType *T) {
+  llvm::SmallString<64> Str("_Res");
+  const HLSLAttributedResourceType::Attributes &Attrs = T->getAttrs();
+  // map resource class to HLSL virtual register letter
+  switch (Attrs.ResourceClass) {
+  case llvm::dxil::ResourceClass::UAV:
+    Str += "_u";
+    break;
+  case llvm::dxil::ResourceClass::SRV:
+    Str += "_t";
+    break;
+  case llvm::dxil::ResourceClass::CBuffer:
+    Str += "_b";
+    break;
+  case llvm::dxil::ResourceClass::Sampler:
+    Str += "_s";
+    break;
+  }
+  mangleVendorQualifier(Str);
+  if (Attrs.IsROV)
----------------
pow2clk wrote:

I think these three string literals should probably be munged into the preceeding `Str` and `mangledVendorQualifie`d as a unit rather than giving each their own character count and prefix. 

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


More information about the cfe-commits mailing list