[llvm] [DirectX] Add support for heap resources to `DXILResourceMap` (PR #216454)
Ashley Coleman via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 18 13:49:38 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 {
----------------
V-FEXrt wrote:
I'm happy keeping `hasBinding` (assuming that's what you mean by `isBinding`?) but I'm really not a fan of a function that asserts because you didn't check if you had a value before accessing it while also not suggesting you should check the value.
It's basically another form of dereferencing a null pointer except the API hides the fact that you even have a pointer from you
https://github.com/llvm/llvm-project/pull/216454
More information about the llvm-commits
mailing list