[llvm] [HLSL] Add support to lookup a ResourceBindingInfo from its use (PR #126556)
Farzon Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 10:27:20 PST 2025
================
@@ -770,6 +770,50 @@ void DXILBindingMap::print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
}
}
+SmallVector<dxil::ResourceBindingInfo>
+DXILBindingMap::findByUse(const Value *Key) const {
+ const PHINode *Phi = dyn_cast<PHINode>(Key);
+ if (Phi) {
+ SmallVector<dxil::ResourceBindingInfo> Children;
+ for (const Value *V : Phi->operands()) {
+ Children.append(findByUse(V));
+ }
+ return Children;
+ }
+
+ const CallInst *CI = dyn_cast<CallInst>(Key);
+ if (!CI) {
+ return {};
+ }
+
+ const Type *UseType = CI->getType();
+
+ switch (CI->getIntrinsicID()) {
+ // Check if any of the parameters are the resource we are following. If so
+ // keep searching
+ case Intrinsic::not_intrinsic: {
+ SmallVector<dxil::ResourceBindingInfo> Children;
+ for (const Value *V : CI->args()) {
+ if (V->getType() != UseType) {
----------------
farzonl wrote:
don't need brackets here on if statement.
https://github.com/llvm/llvm-project/pull/126556
More information about the llvm-commits
mailing list