================
@@ -523,8 +536,39 @@ class HLSLBufferCopyEmitter {
return true;
}
+ // Returns true if the type is either a struct represening a resource record,
+ // or an array of structs that are resource records. This assumes a struct is
+ // a resource record if the first element is a target type (resource handle).
+ // This is the case for all target types used by HLSL except the padding type
+ // ("{dx|spirv.Padding"), but padding will never be the first element of a
+ // struct.
+ bool isResourceOrResourceArray(llvm::Type *Ty) {
+ while (auto *AT = dyn_cast<llvm::ArrayType>(Ty))
+ Ty = AT->getElementType();
+
+ auto *ST = dyn_cast<llvm::StructType>(Ty);
+ if (!ST || ST->getNumElements() < 1)
+ return false;
+
+ auto *TargetTy = dyn_cast<llvm::TargetExtType>(ST->getElementType(0));
----------------
hekota wrote:
It is mentioned in the comment describing the function.
https://github.com/llvm/llvm-project/pull/204232
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits