[clang] [CIR] Upstream __sync_<OP>_and_fetch builtins (PR #168347)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 17 12:58:23 PST 2025
================
@@ -58,6 +59,107 @@ static RValue emitBuiltinBitOp(CIRGenFunction &cgf, const CallExpr *e,
return RValue::get(result);
}
+/// Emit the conversions required to turn the given value into an
+/// integer of the given size.
+static mlir::Value emitToInt(CIRGenFunction &cgf, mlir::Value v, QualType t,
+ cir::IntType intType) {
+ v = cgf.emitToMemory(v, t);
+
+ if (isa<cir::PointerType>(v.getType()))
+ return cgf.getBuilder().createPtrToInt(v, intType);
+
+ assert(v.getType() == intType);
+ return v;
+}
+
+static mlir::Value emitFromInt(CIRGenFunction &cgf, mlir::Value v, QualType t,
+ mlir::Type resultType) {
+ v = cgf.emitFromMemory(v, t);
+
+ if (isa<cir::PointerType>(resultType))
----------------
andykaylor wrote:
```suggestion
if (mlir::isa<cir::PointerType>(resultType))
```
https://github.com/llvm/llvm-project/pull/168347
More information about the cfe-commits
mailing list