[clang] [CIR] Upstream Cast kinds for ComplexType (PR #149717)

Amr Hesham via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 21 09:56:47 PDT 2025


================
@@ -114,19 +92,42 @@ void LoweringPreparePass::lowerCastOp(cir::CastOp op) {
     break;
 
   case cir::CastKind::float_complex_to_real:
-  case cir::CastKind::int_complex_to_real:
-  case cir::CastKind::float_complex_to_bool:
+  case cir::CastKind::int_complex_to_real: {
+    loweredValue = lowerComplexToScalarCast(getContext(), op, op.getKind());
+    break;
+  }
+
+  case cir::CastKind::float_complex_to_bool: {
+    loweredValue = lowerComplexToScalarCast(getContext(), op,
+                                            cir::CastKind::float_to_bool);
+    break;
+  }
   case cir::CastKind::int_complex_to_bool: {
-    loweredValue = lowerComplexToScalarCast(getContext(), op);
+    loweredValue =
+        lowerComplexToScalarCast(getContext(), op, cir::CastKind::int_to_bool);
     break;
   }
 
-  case cir::CastKind::float_complex:
-  case cir::CastKind::float_complex_to_int_complex:
-  case cir::CastKind::int_complex:
-  case cir::CastKind::int_complex_to_float_complex:
-    loweredValue = lowerComplexToComplexCast(getContext(), op);
+  case cir::CastKind::float_complex: {
+    loweredValue =
+        lowerComplexToComplexCast(getContext(), op, cir::CastKind::floating);
+    break;
+  }
+  case cir::CastKind::float_complex_to_int_complex: {
+    loweredValue = lowerComplexToComplexCast(getContext(), op,
+                                             cir::CastKind::float_to_int);
     break;
+  }
+  case cir::CastKind::int_complex: {
+    loweredValue =
+        lowerComplexToComplexCast(getContext(), op, cir::CastKind::integral);
+    break;
+  }
+  case cir::CastKind::int_complex_to_float_complex: {
+    loweredValue = lowerComplexToComplexCast(getContext(), op,
+                                             cir::CastKind::int_to_float);
+    break;
+  }
----------------
AmrDeveloper wrote:

Very nice, i will do that

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


More information about the cfe-commits mailing list