[PATCH] D119700: [flang] Enable complex type in function lowering
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 14 23:26:17 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1ceb1d9b4025: [flang] Enable complex type in function lowering (authored by clementval).
Changed prior to commit:
https://reviews.llvm.org/D119700?vs=408589&id=408721#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119700/new/
https://reviews.llvm.org/D119700
Files:
flang/lib/Lower/ConvertType.cpp
flang/test/Lower/basic-function.f90
Index: flang/test/Lower/basic-function.f90
===================================================================
--- flang/test/Lower/basic-function.f90
+++ flang/test/Lower/basic-function.f90
@@ -98,3 +98,32 @@
! CHECK-LABEL: func @_QPrfct6() -> f128
! CHECK: return %{{.*}} : f128
+complex(2) function cplxfct1()
+end
+! CHECK-LABEL: func @_QPcplxfct1() -> !fir.complex<2>
+! CHECK: return %{{.*}} : !fir.complex<2>
+
+complex(3) function cplxfct2()
+end
+! CHECK-LABEL: func @_QPcplxfct2() -> !fir.complex<3>
+! CHECK: return %{{.*}} : !fir.complex<3>
+
+complex(4) function cplxfct3()
+end
+! CHECK-LABEL: func @_QPcplxfct3() -> !fir.complex<4>
+! CHECK: return %{{.*}} : !fir.complex<4>
+
+complex(8) function cplxfct4()
+end
+! CHECK-LABEL: func @_QPcplxfct4() -> !fir.complex<8>
+! CHECK: return %{{.*}} : !fir.complex<8>
+
+complex(10) function cplxfct5()
+end
+! CHECK-LABEL: func @_QPcplxfct5() -> !fir.complex<10>
+! CHECK: return %{{.*}} : !fir.complex<10>
+
+complex(16) function cplxfct6()
+end
+! CHECK-LABEL: func @_QPcplxfct6() -> !fir.complex<16>
+! CHECK: return %{{.*}} : !fir.complex<16>
Index: flang/lib/Lower/ConvertType.cpp
===================================================================
--- flang/lib/Lower/ConvertType.cpp
+++ flang/lib/Lower/ConvertType.cpp
@@ -75,6 +75,13 @@
return {};
}
+static mlir::Type genComplexType(mlir::MLIRContext *context, int KIND) {
+ if (Fortran::evaluate::IsValidKindOfIntrinsicType(
+ Fortran::common::TypeCategory::Complex, KIND))
+ return fir::ComplexType::get(context, KIND);
+ return {};
+}
+
static mlir::Type genFIRType(mlir::MLIRContext *context,
Fortran::common::TypeCategory tc, int kind) {
switch (tc) {
@@ -83,7 +90,7 @@
case Fortran::common::TypeCategory::Integer:
return genIntegerType(context, kind);
case Fortran::common::TypeCategory::Complex:
- TODO_NOLOC("genFIRType Complex");
+ return genComplexType(context, kind);
case Fortran::common::TypeCategory::Logical:
return genLogicalType(context, kind);
case Fortran::common::TypeCategory::Character:
@@ -138,16 +145,6 @@
return {};
}
-template <>
-mlir::Type
-genFIRType<Fortran::common::TypeCategory::Complex>(mlir::MLIRContext *context,
- int KIND) {
- if (Fortran::evaluate::IsValidKindOfIntrinsicType(
- Fortran::common::TypeCategory::Complex, KIND))
- return fir::ComplexType::get(context, KIND);
- return {};
-}
-
namespace {
/// Discover the type of an Fortran::evaluate::Expr<T> and convert it to an
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119700.408721.patch
Type: text/x-patch
Size: 2652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220215/a3b3adea/attachment.bin>
More information about the llvm-commits
mailing list