================
@@ -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(
+      castToGenericAddrSpace(atomicPtr.emitRawPointer(),
+                             e->getPtr()->getType()),
+      cgf.voidTy));
+
+  // The next 1-3 parameters are op-dependent.
+  cir::FuncOp callee;
+  QualType retTy;
+  bool hasRetTy = false;
+  switch (e->getOp()) {
+  case AtomicExpr::AO__c11_atomic_init:
+  case AtomicExpr::AO__opencl_atomic_init:
+    llvm_unreachable("Already handled!");
+
+  // void __atomic_store(size_t size, void *mem, void *val, int order)
+  case AtomicExpr::AO__atomic_store:
----------------
Lancern wrote:

Updated.

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