[clang] [z/OS][Clang] Add compare and swap builtin functions (PR #202362)

Maryam Moghadas via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 10 12:52:04 PDT 2026


================
@@ -68,11 +117,25 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID,
     Function *F = CGM.getIntrinsic(Intrinsic::s390_ntstg);
     return Builder.CreateCall(F, {Data, Address});
   }
+  case SystemZ::BI__cs: {
+    return EmitAtomicCmpXchgForZOSIntrin(*this, E, Int32Ty, false);
+  }
+  case SystemZ::BI__cs1: {
+    return EmitAtomicCmpXchgForZOSIntrin(*this, E, Int32Ty, true);
+  }
+  case SystemZ::BI__csg:
+  case SystemZ::BI__cds1: {
+    return EmitAtomicCmpXchgForZOSIntrin(*this, E, Int64Ty, true);
+  }
+  case SystemZ::BI__cdsg: {
+    llvm::Type *Int128Ty = llvm::IntegerType::get(getLLVMContext(), 128);
+    return EmitAtomicCmpXchgForZOSIntrin(*this, E, Int128Ty, true);
+  }
 
-  // Vector builtins.  Note that most vector builtins are mapped automatically
-  // to target-specific LLVM intrinsics.  The ones handled specially here can
-  // be represented via standard LLVM IR, which is preferable to enable common
-  // LLVM optimizations.
+    // Vector builtins.  Note that most vector builtins are mapped automatically
----------------
maryammo wrote:

Clang-format enforces these changes; I tried limiting it with HEAD~1, but it still reformats surrounding lines.

https://github.com/llvm/llvm-project/pull/202362


More information about the cfe-commits mailing list