================
@@ -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);
+ if (ReturnType->isDependentType()) {
+ ReturnType = MMB2.addTemplateTypeParam("element_type");
+ MMB2.ReturnTy = ReturnType; // Update return type to template parameter
+ }
+
+ MMB2.addParam("Index", AST.UnsignedIntTy)
+ .addParam("Status", AST.UnsignedIntTy,
+ HLSLParamModifierAttr::Keyword_out)
+ .callBuiltin("__builtin_hlsl_resource_load_with_status", ReturnType,
+ PH::Handle, PH::_0, PH::_1)
+ .finalize();
+ };
+
+ addLoadMethod("Load", AST.UnsignedIntTy);
+ addLoadMethod("Load2", AST.getExtVectorType(AST.UnsignedIntTy, 2));
+ addLoadMethod("Load3", AST.getExtVectorType(AST.UnsignedIntTy, 3));
+ addLoadMethod("Load4", AST.getExtVectorType(AST.UnsignedIntTy, 4));
+ addLoadMethod("Load", AST.DependentTy); // Templated version
+
+ return *this;
+}
+
+BuiltinTypeDeclBuilder &
+BuiltinTypeDeclBuilder::addByteAddressBufferStoreMethods() {
+ assert(!Record->isCompleteDefinition() && "record is already complete");
+
+ using PH = BuiltinTypeMethodBuilder::PlaceHolder;
+ ASTContext &AST = SemaRef.getASTContext();
+
+ // Helper to add uint Store methods
+ auto addStoreMethod = [&](StringRef MethodName, QualType ValueType) {
+ IdentifierInfo &II = AST.Idents.get(MethodName,
tok::TokenKind::identifier);
+ DeclarationName Store(&II);
+
+ BuiltinTypeMethodBuilder MMB(*this, Store, AST.VoidTy);
+ if (ValueType->isDependentType()) {
+ ValueType = MMB.addTemplateTypeParam("element_type");
+ }
----------------
hekota wrote:
```suggestion
if (ValueType->isDependentType())
ValueType = MMB.addTemplateTypeParam("element_type");
```
nit
https://github.com/llvm/llvm-project/pull/176058
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits