================
@@ -172,6 +172,37 @@ static mlir::Value makeBinaryAtomicValue(
   return rmwi->getResult(0);
 }
 
+/// Utility to insert an atomic cmpxchg instruction.
+static mlir::Value makeAtomicCmpXchgValue(CIRGenFunction &cgf,
+                                          const CallExpr *expr,
+                                          bool returnBool) {
+  QualType typ = returnBool ? expr->getArg(1)->getType() : expr->getType();
+  Address destAddr = checkAtomicAlignment(cgf, expr);
+  clang::CIRGen::CIRGenBuilderTy &builder = cgf.getBuilder();
+
+  cir::IntType intType =
+      expr->getArg(0)->getType()->getPointeeType()->isUnsignedIntegerType()
+          ? builder.getUIntNTy(cgf.getContext().getTypeSize(typ))
+          : builder.getSIntNTy(cgf.getContext().getTypeSize(typ));
+  mlir::Value cmpVal = cgf.emitScalarExpr(expr->getArg(1));
+  cmpVal = emitToInt(cgf, cmpVal, typ, intType);
----------------
andykaylor wrote:

Similar to my comment above, I don't understand the need for `emitToInt` here. 
Can you explain? It looks like whoever wrote the classic codegen implementation 
of this was trying to coerce everything to the same type, but I'm pretty sure 
the AST builder will have already done that.

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

Reply via email to