Skip to content

Commit 30bcab6

Browse files
committed
Expose cfg conversions to other passes
1 parent 192da3c commit 30bcab6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

flang/include/flang/Optimizer/Transforms/Passes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ createFunctionAttrPass(FunctionAttrTypes &functionAttr, bool noInfsFPMath,
9999
bool noNaNsFPMath, bool approxFuncFPMath,
100100
bool noSignedZerosFPMath, bool unsafeFPMath);
101101

102+
void populateCfgConversionRewrites(mlir::RewritePatternSet &patterns,
103+
bool forceLoopToExecuteOnce = false);
104+
102105
// declarative passes
103106
#define GEN_PASS_REGISTRATION
104107
#include "flang/Optimizer/Transforms/Passes.h.inc"

flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,7 @@ class CfgConversionTemplate : public PassBase<Pass> {
315315
void runOnOperation() override {
316316
auto *context = &this->getContext();
317317
mlir::RewritePatternSet patterns(context);
318-
patterns.insert<CfgLoopConv, CfgIfConv, CfgIterWhileConv>(
319-
context, this->forceLoopToExecuteOnce);
318+
fir::populateCfgConversionRewrites(patterns, this->forceLoopToExecuteOnce);
320319
mlir::ConversionTarget target(*context);
321320
target.addLegalDialect<mlir::affine::AffineDialect,
322321
mlir::cf::ControlFlowDialect, FIROpsDialect,
@@ -344,6 +343,13 @@ class CfgConversionOnReduction
344343
};
345344
} // namespace
346345

346+
/// Expose conversion rewriters to other passes
347+
void fir::populateCfgConversionRewrites(mlir::RewritePatternSet &patterns,
348+
bool forceLoopToExecuteOnce) {
349+
patterns.insert<CfgLoopConv, CfgIfConv, CfgIterWhileConv>(
350+
patterns.getContext(), forceLoopToExecuteOnce);
351+
}
352+
347353
/// Convert FIR's structured control flow ops to CFG ops. This
348354
/// conversion enables the `createLowerToCFGPass` to transform these to CFG
349355
/// form.

0 commit comments

Comments
 (0)