Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang] Add genEval to the AbstractConverter #75140

Merged
merged 2 commits into from
Dec 14, 2023
Merged

Conversation

clementval
Copy link
Contributor

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 but not exposing it.

[1] https://discourse.llvm.org/t/openmp-lowering-from-pft-to-fir/75263

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
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Dec 12, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Dec 12, 2023

@llvm/pr-subscribers-flang-fir-hlfir

Author: Valentin Clement (バレンタイン クレメン) (clementval)

Changes

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 but not exposing it.

[1] https://discourse.llvm.org/t/openmp-lowering-from-pft-to-fir/75263


Full diff: https://github.com/llvm/llvm-project/pull/75140.diff

2 Files Affected:

  • (modified) flang/include/flang/Lower/AbstractConverter.h (+4)
  • (modified) flang/lib/Lower/Bridge.cpp (+5)
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
   //===--------------------------------------------------------------------===//

Copy link
Contributor

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I favor this solution since it has a much smaller footprint and only exposes the core utility.

@kparzysz kparzysz self-requested a review December 12, 2023 16:46
@kparzysz
Copy link
Contributor

We also need access to the local symbol table.

@clementval
Copy link
Contributor Author

We also need access to the local symbol table.

What for? It was not part of the discussion we had on discourse? What is the motivation here now that we know more abstraction in the dialect is the right direction to take?

By the way there is no need to expose the local symbol table on the AbstractConverter. You can pass it directly to the genOpenMPConstruct if needed.

@clementval clementval merged commit fedc54b into llvm:main Dec 14, 2023
4 checks passed
@clementval clementval deleted the geneval branch December 14, 2023 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants