[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 02:22:21 PST 2022
clementval created this revision.
clementval added reviewers: jeanPerier, kiranchandramohan, PeteSteinfeld, schweitz, svedanayagam.
Herald added a subscriber: mehdi_amini.
Herald added a project: Flang.
clementval requested review of this revision.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
This patch enables complex type in lowering.
It is tested on function return types.
This patch is part of the upstreaming effort from fir-dev branch.
Depends on D119698 <https://reviews.llvm.org/D119698>
Co-authored-by: Jean Perier <jperier at nvidia.com>
Repository:
rG LLVM Github Monorepo
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
@@ -61,3 +61,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) {
@@ -84,7 +91,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:
@@ -149,16 +156,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.408360.patch
Type: text/x-patch
Size: 2618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220214/8131cf36/attachment-0001.bin>
More information about the llvm-commits
mailing list