[llvm-branch-commits] [clang] [HLSL] Global resource arrays element access (PR #152454)
Joshua Batista via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Aug 8 17:55:38 PDT 2025
================
@@ -701,3 +808,95 @@ void CGHLSLRuntime::emitInitListOpaqueValues(CodeGenFunction &CGF,
}
}
}
+
+std::optional<LValue> CGHLSLRuntime::emitResourceArraySubscriptExpr(
+ const ArraySubscriptExpr *ArraySubsExpr, CodeGenFunction &CGF) {
+ assert(ArraySubsExpr->getType()->isHLSLResourceRecord() ||
+ ArraySubsExpr->getType()->isHLSLResourceRecordArray() &&
+ "expected resource array subscript expression");
+
+ // let clang codegen handle local resource array subscrips
+ const VarDecl *ArrayDecl = dyn_cast<VarDecl>(getArrayDecl(ArraySubsExpr));
+ if (!ArrayDecl || !ArrayDecl->hasGlobalStorage())
+ return std::nullopt;
+
+ // FIXME: this is not yet implemented (llvm/llvm-project#145426)
+ assert(!ArraySubsExpr->getType()->isArrayType() &&
+ "indexing of array subsets it not supported yet");
+
+ // get total array size (= range size)
+ const Type *ResArrayTy = ArrayDecl->getType().getTypePtr();
+ assert(ResArrayTy->isHLSLResourceRecordArray() &&
----------------
bob80905 wrote:
Isn't it possible that this could be false if only the first condition of 814 is true?
I don't think getTypePtr() gets the element type, it should just strip the array type and make it canonical.
In what situation would `isHLSLResourceRecord` exit this function before we get to this line.
https://github.com/llvm/llvm-project/pull/152454
More information about the llvm-branch-commits
mailing list