[clang] Implement `ByteAddressBuffer` Load/Store methods (PR #176058)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 15 14:53:22 PST 2026
================
@@ -1145,6 +1179,93 @@ BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addLoadMethods() {
return *this;
}
+BuiltinTypeDeclBuilder &
+BuiltinTypeDeclBuilder::addByteAddressBufferLoadMethods() {
+ assert(!Record->isCompleteDefinition() && "record is already complete");
+
+ using PH = BuiltinTypeMethodBuilder::PlaceHolder;
+ ASTContext &AST = SemaRef.getASTContext();
+
+ auto addLoadMethod = [&](StringRef MethodName, QualType ReturnType) {
+ IdentifierInfo &II = AST.Idents.get(MethodName, tok::TokenKind::identifier);
+ DeclarationName Load(&II);
+
+ // Load without status
+ BuiltinTypeMethodBuilder MMB(*this, Load, ReturnType);
+ if (ReturnType->isDependentType()) {
+ ReturnType = MMB.addTemplateTypeParam("element_type");
+ MMB.ReturnTy = ReturnType; // Update return type to template parameter
+ }
+ QualType AddrSpaceElemTy =
+ AST.getAddrSpaceQualType(ReturnType, LangAS::hlsl_device);
+
+ MMB.addParam("Index", AST.UnsignedIntTy)
+ .callBuiltin("__builtin_hlsl_resource_getpointer",
+ AST.getPointerType(AddrSpaceElemTy), PH::Handle, PH::_0)
+ .dereference(PH::LastStmt)
+ .finalize();
+
+ // Load with status
+ BuiltinTypeMethodBuilder MMB2(*this, Load, ReturnType);
----------------
hekota wrote:
For the templated version the `ReturnType` argument has been updated on line 1196 above. Is it ok to use the updated type it here?
https://github.com/llvm/llvm-project/pull/176058
More information about the cfe-commits
mailing list