================
@@ -1114,6 +1114,198 @@ void CIRGenFunction::emitAtomicExprWithMemOrder(
                                     emitAtomicOpFn);
 }
 
+static RValue emitLibCallForAtomicExpr(CIRGenFunction &cgf, AtomicExpr *e,
+                                       Address atomicPtr, Address dest,
+                                       Address val1, uint64_t atomicTySize,
+                                       QualType resultTy) {
+  mlir::Location loc = cgf.getLoc(e->getSourceRange());
+
+  llvm::SmallVector<mlir::Value> args;
+  // For non-optimized library calls, the size is the first parameter.
+  args.push_back(cgf.getBuilder().getConstInt(loc, cgf.sizeTy, atomicTySize));
+
+  // The atomic address is the second parameter.
+  // The OpenCL atomic library functions only accept pointer arguments to
+  // generic address space.
+  auto castToGenericAddrSpace = [&](mlir::Value v, QualType pt) {
+    if (!e->isOpenCL())
+      return v;
+
+    assert(!cir::MissingFeatures::openCL());
+    cgf.cgm.errorNYI(loc, "emitLibCallForAtomicExpr: openCL");
+    return v;
+  };
+  args.push_back(cgf.getBuilder().createPtrBitcast(
----------------
Lancern wrote:

The bitcast is indeed needed as the library function always expects a `void *`. 
Moved the bitcast into `castToGenericAddrSpace`.

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

Reply via email to