[PATCH] D113883: [fir] Add mlir::ComplexType conversion

Diana Picus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 15 03:57:47 PST 2021


rovka created this revision.
rovka added reviewers: clementval, awarzynski, kiranchandramohan, schweitz, jeanPerier, AlexisPerry, pmccormick.
rovka added a project: Flang.
Herald added subscribers: Chia-hungDuan, mehdi_amini, rriddle, jdoerfert.
rovka requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer.
Herald added a project: LLVM.

This patch is part of the upstreaming effort from fir-dev.

Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113883

Files:
  flang/lib/Optimizer/CodeGen/TypeConverter.h
  flang/test/Fir/types-to-llvm.fir


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<KIND>` conversion.
+
+func private @foo0(%arg0: complex<f16>)
+// CHECK-LABEL: foo0
+// CHECK-SAME: !llvm.struct<(f16, f16)>)
+
+func private @foo1(%arg0: complex<bf16>)
+// CHECK-LABEL: foo1
+// CHECK-SAME: !llvm.struct<(bf16, bf16)>)
+
+func private @foo2(%arg0: complex<f32>)
+// CHECK-LABEL: foo2
+// CHECK-SAME: !llvm.struct<(f32, f32)>)
+
+func private @foo3(%arg0: complex<f64>)
+// CHECK-LABEL: foo3
+// CHECK-SAME: !llvm.struct<(f64, f64)>)
+
+func private @foo4(%arg0: complex<f80>)
+// CHECK-LABEL: foo4
+// CHECK-SAME: !llvm.struct<(f80, f80)>)
+
+func private @foo5(%arg0: complex<f128>)
+// CHECK-LABEL: foo5
+// CHECK-SAME: !llvm.struct<(f128, f128)>)
+
+// -----
+
 // Test `!fir.complex<KIND>` conversion.
 
 func private @foo0(%arg0: !fir.complex<2>)
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<Fortran::runtime::typeInfo::TypeParameterValue>()(
           &getContext());
     });
-    addConversion(
-        [&](fir::ComplexType cmplx) { return convertComplexType(cmplx); });
     addConversion(
         [&](fir::RealType real) { return convertRealType(real.getFKind()); });
     addConversion(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113883.387202.patch
Type: text/x-patch
Size: 2054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211115/241bd4f5/attachment.bin>


More information about the llvm-commits mailing list