================
@@ -91,6 +91,59 @@ static mlir::Value emitLogbBuiltin(CIRGenFunction &cgf, 
const CallExpr *e,
   return res;
 }
 
+static mlir::Value
+emitAMDGCNImageOverloadedReturnType(CIRGenFunction &cgf, const CallExpr *e,
+                                    llvm::StringRef intrinsicName,
+                                    bool isImageStore) {
+  auto &builder = cgf.getBuilder();
+
+  auto findTextureDescIndex = [&cgf](const CallExpr *e) -> unsigned {
+    QualType texQT = cgf.getContext().AMDGPUTextureTy;
+    for (unsigned i = 0, n = e->getNumArgs(); i < n; ++i) {
+      QualType argTy = e->getArg(i)->getType();
+      if (argTy == texQT ||
+          argTy.getCanonicalType() == texQT.getCanonicalType()) {
+        return i;
+      }
+    }
+    return ~0U;
+  };
+
+  unsigned rsrcIndex = findTextureDescIndex(e);
+  if (rsrcIndex == ~0U) {
+    llvm::report_fatal_error("Invalid argument count for image builtin");
+  }
+
+  cir::VectorType vec8I32Ty = cir::VectorType::get(builder.getSInt32Ty(), 8);
+
+  llvm::SmallVector<mlir::Value, 10> args;
+  for (unsigned i = 0, n = e->getNumArgs(); i < n; ++i) {
+    mlir::Value v = cgf.emitScalarExpr(e->getArg(i));
+
+    if (i == rsrcIndex) {
+      mlir::Type vTy = v.getType();
+      if (mlir::isa<cir::PointerType>(vTy)) {
+        v = builder.createAlignedLoad(cgf.getLoc(e->getExprLoc()), vec8I32Ty, 
v,
+                                      CharUnits::fromQuantity(32));
+      }
+    }
+    args.push_back(v);
+  }
+
+  mlir::Type retTy;
+  if (isImageStore) {
+    retTy = cir::VoidType::get(builder.getContext());
+  } else {
+    retTy = cgf.convertType(e->getType());
+  }
----------------
ranapratap55 wrote:

Updated.

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

Reply via email to