[clang] [HLSL] Global resource arrays element access (PR #152454)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 18 15:47:21 PDT 2025


================
@@ -700,3 +795,90 @@ 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 subscripts
+  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");
----------------
hekota wrote:

I'll use the term "sub-arrays of multidimensional arrays" and change this to llvm_unreachable.

https://github.com/llvm/llvm-project/pull/152454


More information about the cfe-commits mailing list