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

Chris B via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 12:37:40 PDT 2024


================
@@ -4492,6 +4492,31 @@ void CXXNameMangler::mangleType(const ArrayParameterType *T) {
   mangleType(cast<ConstantArrayType>(T));
 }
 
+void CXXNameMangler::mangleType(const HLSLAttributedResourceType *T) {
+  mangleType(T->getWrappedType());
+  const HLSLAttributedResourceType::Attributes &Attrs = T->getAttrs();
+  // map resource class to HLSL virtual register letter
+  switch (Attrs.ResourceClass) {
+  case llvm::dxil::ResourceClass::UAV:
+    Out << 'u';
+    break;
+  case llvm::dxil::ResourceClass::SRV:
+    Out << 't';
+    break;
+  case llvm::dxil::ResourceClass::CBuffer:
+    Out << 'b';
+    break;
+  case llvm::dxil::ResourceClass::Sampler:
+    Out << 's';
+    break;
+  }
+  mangleNumber(Attrs.IsROV);
+  mangleNumber(Attrs.RawBuffer);
----------------
llvm-beanz wrote:

Should we be mangling these as numbers or vendor qualifiers? I think the later. Basically something like:

```
if (Attrs.IsROV)
  mangleVendorQualifier("__ROV");
...
```

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


More information about the cfe-commits mailing list