[flang-commits] [flang] [flang] Add genEval to the AbstractConverter (PR #75140)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Tue Dec 12 09:19:08 PST 2023


Valentin Clement =?utf-8?b?KOODkOODrOODsw=?Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/75140 at github.com>


https://github.com/clementval updated https://github.com/llvm/llvm-project/pull/75140

>From 0212daecc9484a4276822a19047a84c5f83d521f Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Mon, 11 Dec 2023 13:43:11 -0800
Subject: [PATCH 1/2] [flang] Add genEval to the AbstractConverter

There was some discussion on discourse[1] about allowing
call to FIR generation functions from other part of lowering belonging
to OpenMP.

This solution exposes a simple `genEval` member function on the
`AbstractConverter` so that IR generation for PFT Evaluation objects
can be called from lowering outside of the FirConverter.

[1] https://discourse.llvm.org/t/openmp-lowering-from-pft-to-fir/75263
---
 flang/include/flang/Lower/AbstractConverter.h | 4 ++++
 flang/lib/Lower/Bridge.cpp                    | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index 980fde88137324..b91303387f3d71 100644
--- a/flang/include/flang/Lower/AbstractConverter.h
+++ b/flang/include/flang/Lower/AbstractConverter.h
@@ -280,6 +280,10 @@ class AbstractConverter {
   // Miscellaneous
   //===--------------------------------------------------------------------===//
 
+  /// Generate IR for Evaluation \p eval.
+  virtual void genEval(pft::Evaluation &eval,
+                       bool unstructuredContext = true) = 0;
+
   /// Return options controlling lowering behavior.
   const Fortran::lower::LoweringOptions &getLoweringOptions() const {
     return loweringOptions;
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 7e64adc3c144c9..9acdf524ba84b8 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -839,6 +839,11 @@ class FirConverter : public Fortran::lower::AbstractConverter {
     }
   }
 
+  void genEval(Fortran::lower::pft::Evaluation &eval,
+               bool unstructuredContext) override {
+    genFIR(eval, unstructuredContext);
+  }
+
   //===--------------------------------------------------------------------===//
   // Utility methods
   //===--------------------------------------------------------------------===//

>From a9af91ae635165b071bf621be8813da5d86f451d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Valentin=20Clement=20=28=E3=83=90=E3=83=AC=E3=83=B3?=
 =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=B3=20=E3=82=AF=E3=83=AC=E3=83=A1?=
 =?UTF-8?q?=E3=83=B3=29?= <clementval at gmail.com>
Date: Tue, 12 Dec 2023 09:19:02 -0800
Subject: [PATCH 2/2] Update flang/lib/Lower/Bridge.cpp

Add final
---
 flang/lib/Lower/Bridge.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 9acdf524ba84b8..6ca910d2696742 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -840,7 +840,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
   }
 
   void genEval(Fortran::lower::pft::Evaluation &eval,
-               bool unstructuredContext) override {
+               bool unstructuredContext) override final {
     genFIR(eval, unstructuredContext);
   }
 



More information about the flang-commits mailing list