[flang-commits] [flang] 22eb800 - [flang][NFC] Expose patterns from PreCGRewrite pass (#85156)

via flang-commits flang-commits at lists.llvm.org
Thu Mar 14 09:39:31 PDT 2024


Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-03-14T09:39:28-07:00
New Revision: 22eb8000d22efe1bf06518e84af84d34ff6375de

URL: https://github.com/llvm/llvm-project/commit/22eb8000d22efe1bf06518e84af84d34ff6375de
DIFF: https://github.com/llvm/llvm-project/commit/22eb8000d22efe1bf06518e84af84d34ff6375de.diff

LOG: [flang][NFC] Expose patterns from PreCGRewrite pass (#85156)

Expose patterns so they can be reused in other passes.

Added: 
    

Modified: 
    flang/include/flang/Optimizer/CodeGen/CodeGen.h
    flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/CodeGen/CodeGen.h b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
index cbf02ec3912363..26097dabf56c45 100644
--- a/flang/include/flang/Optimizer/CodeGen/CodeGen.h
+++ b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
@@ -87,6 +87,9 @@ void populateFIRToLLVMConversionPatterns(fir::LLVMTypeConverter &converter,
                                          mlir::RewritePatternSet &patterns,
                                          fir::FIRToLLVMPassOptions &options);
 
+/// Populate the pattern set with the PreCGRewrite patterns.
+void populatePreCGRewritePatterns(mlir::RewritePatternSet &patterns);
+
 // declarative passes
 #define GEN_PASS_REGISTRATION
 #include "flang/Optimizer/CodeGen/CGPasses.h.inc"

diff  --git a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
index 0170b56367cf3c..9d48a2f08aba03 100644
--- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
@@ -298,8 +298,7 @@ class CodeGenRewrite : public fir::impl::CodeGenRewriteBase<CodeGenRewrite> {
                                        .isa<fir::SequenceType>());
     });
     mlir::RewritePatternSet patterns(&context);
-    patterns.insert<EmboxConversion, ArrayCoorConversion, ReboxConversion,
-                    DeclareOpConversion>(&context);
+    fir::populatePreCGRewritePatterns(patterns);
     if (mlir::failed(
             mlir::applyPartialConversion(op, target, std::move(patterns)))) {
       mlir::emitError(mlir::UnknownLoc::get(&context),
@@ -327,3 +326,8 @@ class CodeGenRewrite : public fir::impl::CodeGenRewriteBase<CodeGenRewrite> {
 std::unique_ptr<mlir::Pass> fir::createFirCodeGenRewritePass() {
   return std::make_unique<CodeGenRewrite>();
 }
+
+void fir::populatePreCGRewritePatterns(mlir::RewritePatternSet &patterns) {
+  patterns.insert<EmboxConversion, ArrayCoorConversion, ReboxConversion,
+                  DeclareOpConversion>(patterns.getContext());
+}


        


More information about the flang-commits mailing list