================
@@ -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);
----------------
kmpeng wrote:

Oh, that's a good point! I didn't run into any issues while testing, but I'll 
update the code to not actually change the ReturnType argument just in case

https://github.com/llvm/llvm-project/pull/176058
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to