Index: flang/lib/Optimizer/CodeGen/TypeConverter.h =================================================================== --- flang/lib/Optimizer/CodeGen/TypeConverter.h +++ flang/lib/Optimizer/CodeGen/TypeConverter.h @@ -56,6 +56,10 @@ }); addConversion( [&](fir::CharacterType charTy) { return convertCharType(charTy); }); + addConversion( + [&](mlir::ComplexType cmplx) { return convertComplexType(cmplx); }); + addConversion( + [&](fir::ComplexType cmplx) { return convertComplexType(cmplx); }); addConversion([&](HeapType heap) { return convertPointerLike(heap); }); addConversion([&](fir::IntegerType intTy) { return mlir::IntegerType::get( @@ -78,8 +82,6 @@ return getModel()( &getContext()); }); - addConversion( - [&](fir::ComplexType cmplx) { return convertComplexType(cmplx); }); addConversion( [&](fir::RealType real) { return convertRealType(real.getFKind()); }); addConversion( Index: flang/test/Fir/types-to-llvm.fir =================================================================== --- flang/test/Fir/types-to-llvm.fir +++ flang/test/Fir/types-to-llvm.fir @@ -176,6 +176,34 @@ // ----- +// Test MLIR `complex` conversion. + +func private @foo0(%arg0: complex) +// CHECK-LABEL: foo0 +// CHECK-SAME: !llvm.struct<(f16, f16)>) + +func private @foo1(%arg0: complex) +// CHECK-LABEL: foo1 +// CHECK-SAME: !llvm.struct<(bf16, bf16)>) + +func private @foo2(%arg0: complex) +// CHECK-LABEL: foo2 +// CHECK-SAME: !llvm.struct<(f32, f32)>) + +func private @foo3(%arg0: complex) +// CHECK-LABEL: foo3 +// CHECK-SAME: !llvm.struct<(f64, f64)>) + +func private @foo4(%arg0: complex) +// CHECK-LABEL: foo4 +// CHECK-SAME: !llvm.struct<(f80, f80)>) + +func private @foo5(%arg0: complex) +// CHECK-LABEL: foo5 +// CHECK-SAME: !llvm.struct<(f128, f128)>) + +// ----- + // Test `!fir.complex` conversion. func private @foo0(%arg0: !fir.complex<2>)