[clang] [HLSL] Collect explicit resource binding information (PR #111203)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 14 14:28:14 PDT 2024


================
@@ -28,13 +28,62 @@ class AttributeCommonInfo;
 class IdentifierInfo;
 class ParsedAttr;
 class Scope;
+class VarDecl;
+
+using llvm::dxil::ResourceClass;
 
 // FIXME: This can be hidden (as static function in SemaHLSL.cpp) once we no
 // longer need to create builtin buffer types in HLSLExternalSemaSource.
 bool CreateHLSLAttributedResourceType(
     Sema &S, QualType Wrapped, ArrayRef<const Attr *> AttrList,
     QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo = nullptr);
 
+enum class BindingType : uint8_t { NotAssigned, Explicit, Implicit };
+
+// DeclBindingInfo struct stores information about required/assigned resource
+// binding onon a declaration for specific resource class.
+struct DeclBindingInfo {
+  const VarDecl *Decl;
+  ResourceClass ResClass;
+  int Size; // -1 == unbounded array
+  const HLSLResourceBindingAttr *Attr;
+  BindingType BindType;
+
+  DeclBindingInfo(const VarDecl *Decl, ResourceClass ResClass, int Size = 0,
----------------
damyanp wrote:

What does `Size==0` actually mean?  A zero sized array?

I'm wondering if `0` is actually a good default.  I notice that the only place this is called passes a value for Size anyway, so maybe it doesn't need default value.

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


More information about the cfe-commits mailing list