[llvm] [DirectX] Add support for heap resources to `DXILResourceMap` (PR #216454)
Joshua Batista via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 14:46:06 PDT 2026
================
@@ -415,16 +417,30 @@ class ResourceInfo {
ResourceInfo(uint32_t Space, uint32_t LowerBound, uint32_t Size,
TargetExtType *HandleTy, StringRef Name = "",
GlobalVariable *Symbol = nullptr)
- : Binding{0, Space, LowerBound, Size}, HandleTy(HandleTy), Name(Name),
- Symbol(Symbol) {}
+ : Binding{ResourceBinding{0, Space, LowerBound, Size}},
+ HandleTy(HandleTy), Name(Name), Symbol(Symbol) {}
- void setBindingID(unsigned ID) { Binding.BindingID = ID; }
+ ResourceInfo(uint32_t HeapResourceID, TargetExtType *HandleTy)
+ : Binding{std::nullopt}, HeapResourceID(HeapResourceID),
+ HandleTy(HandleTy), Name(""), Symbol(nullptr) {}
+
+ bool hasBinding() const { return Binding.has_value(); }
+ void setBindingID(unsigned ID) {
+ assert(hasBinding() && "Resource does not have a binding");
+ Binding->BindingID = ID;
+ }
bool hasCounter() const {
return CounterDirection != ResourceCounterDirection::Unknown;
}
- const ResourceBinding &getBinding() const { return Binding; }
+ const ResourceBinding &getBinding() const {
+ assert(hasBinding() && "Resource does not have a binding");
+ return Binding.value();
+ }
+
+ uint32_t getSize() const { return Binding ? Binding->Size : 1; }
----------------
bob80905 wrote:
Not sure if it makes a difference but nit: how about using `hasBinding()` instead of `Binding` ?
https://github.com/llvm/llvm-project/pull/216454
More information about the llvm-commits
mailing list