[llvm] [DirectX] Add support for heap resources to `DXILResourceMap` (PR #216454)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 12:55:19 PDT 2026
================
@@ -415,16 +416,39 @@ 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) {}
+ : BindingOrHeapID{ResourceBinding{0, Space, LowerBound, Size}},
+ HandleTy(HandleTy), Name(Name), Symbol(Symbol) {}
- void setBindingID(unsigned ID) { Binding.BindingID = ID; }
+ ResourceInfo(uint32_t HeapResourceID, TargetExtType *HandleTy)
+ : BindingOrHeapID{HeapResourceID}, HandleTy(HandleTy), Name(""),
+ Symbol(nullptr) {}
+
+ bool hasBinding() const {
+ return std::holds_alternative<ResourceBinding>(BindingOrHeapID);
+ }
+ void setBindingID(unsigned ID) {
+ assert(hasBinding() && "Resource does not have a binding");
+ std::get<ResourceBinding>(BindingOrHeapID).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 std::get<ResourceBinding>(BindingOrHeapID);
+ }
+
+ uint32_t getSize() const {
+ return hasBinding() ? std::get<ResourceBinding>(BindingOrHeapID).Size : 1;
+ }
+
+ uint32_t getHeapID() const {
+ assert(!hasBinding() && "Resource does not have a heap ID");
+ return std::get<uint32_t>(BindingOrHeapID);
+ }
----------------
bogner wrote:
The ordering feels weird here - can we put the two variant accessors next to each other and `getSize` after them?
https://github.com/llvm/llvm-project/pull/216454
More information about the llvm-commits
mailing list