[clang] [CIR] Upstream ComplexType builtin_complex (PR #144225)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 16 09:38:22 PDT 2025


================
@@ -50,6 +50,14 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
   }
 
   mlir::Location loc = getLoc(e->getExprLoc());
-  cgm.errorNYI(loc, "non constant foldable builtin calls");
+  switch (builtinID) {
+  case Builtin::BI__builtin_complex: {
+    mlir::Value real = emitScalarExpr(e->getArg(0));
+    mlir::Value imag = emitScalarExpr(e->getArg(1));
+    return RValue::getComplex(real, imag);
+  }
+  default:
+    cgm.errorNYI(loc, "non constant foldable builtin calls");
----------------
andykaylor wrote:

I'd like to see this, along with the code on line 52, remain with the `getUndefRValue` on line 62. They're all part of the same logic to report and unhandled builtin.

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


More information about the cfe-commits mailing list