Skip to content

Commit 590cd50

Browse files
committed
disable affine in bbc
fix a few bugs
1 parent b853157 commit 590cd50

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

flang/include/flang/Optimizer/Dialect/FIRDialect.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
#ifndef OPTIMIZER_DIALECT_FIRDIALECT_H
1010
#define OPTIMIZER_DIALECT_FIRDIALECT_H
1111

12+
#include "mlir/Conversion/Passes.h"
13+
#include "mlir/Dialect/Affine/Passes.h"
1214
#include "mlir/IR/Dialect.h"
1315
#include "mlir/InitAllDialects.h"
1416
#include "mlir/Pass/Pass.h"
1517
#include "mlir/Pass/PassRegistry.h"
16-
#include "mlir/Transforms/Passes.h"
1718
#include "mlir/Transforms/LocationSnapshot.h"
18-
#include "mlir/Dialect/Affine/Passes.h"
19-
#include "mlir/Conversion/Passes.h"
19+
#include "mlir/Transforms/Passes.h"
2020

2121
namespace fir {
2222

@@ -79,9 +79,7 @@ inline void registerGeneralPasses() {
7979
mlir::registerConvertAffineToStandardPass();
8080
}
8181

82-
inline void registerFIRPasses() {
83-
registerGeneralPasses();
84-
}
82+
inline void registerFIRPasses() { registerGeneralPasses(); }
8583

8684
} // namespace fir
8785

flang/include/flang/Optimizer/Transforms/RewritePatterns.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ def createConstantOp
5151
"rewriter.getIndexAttr($1.dyn_cast<IntegerAttr>().getInt()))">;
5252

5353
def ForwardConstantConvertPattern
54-
: Pat<(fir_ConvertOp:$res (ConstantOp $attr)),
54+
: Pat<(fir_ConvertOp:$res (ConstantOp:$cnt $attr)),
5555
(createConstantOp $res, $attr),
56-
[(IndexTypePred $res)]>;
56+
[(IndexTypePred $res)
57+
,(IntegerTypePred $cnt)]>;
5758

5859
#endif // FIR_REWRITE_PATTERNS

flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
453453
if (fnTy.getResults().size() == 1) {
454454
mlir::Type ty = fnTy.getResult(0);
455455
llvm::TypeSwitch<mlir::Type>(ty)
456-
.template Case<fir::ComplexType>([&](fir::ComplexType cmplx) {
456+
.template Case<fir::ComplexType>([&](fir::ComplexType cmplx) {
457457
wrap = rewriteCallComplexResultType(cmplx, newResTys, newInTys,
458458
newOpers);
459459
})
@@ -506,13 +506,16 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
506506
}
507507
}
508508
})
509-
.template Case<fir::ComplexType>([&](fir::ComplexType cmplx) {
509+
.template Case<fir::ComplexType>([&](fir::ComplexType cmplx) {
510510
rewriteCallComplexInputType(cmplx, oper, newInTys, newOpers);
511511
})
512512
.template Case<mlir::ComplexType>([&](mlir::ComplexType cmplx) {
513513
rewriteCallComplexInputType(cmplx, oper, newInTys, newOpers);
514514
})
515-
.Default([&](mlir::Type ty) { newInTys.push_back(ty); });
515+
.Default([&](mlir::Type ty) {
516+
newInTys.push_back(ty);
517+
newOpers.push_back(oper);
518+
});
516519
}
517520
newInTys.insert(newInTys.end(), trailingInTys.begin(), trailingInTys.end());
518521
newOpers.insert(newOpers.end(), trailingOpers.begin(), trailingOpers.end());
@@ -564,7 +567,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
564567
llvm::SmallVector<mlir::Type, 8> newInTys;
565568
for (mlir::Type ty : addrTy.getResults()) {
566569
llvm::TypeSwitch<mlir::Type>(ty)
567-
.Case<fir::ComplexType>([&](fir::ComplexType ty) {
570+
.Case<fir::ComplexType>([&](fir::ComplexType ty) {
568571
lowerComplexSignatureRes(ty, newResTys, newInTys);
569572
})
570573
.Case<mlir::ComplexType>([&](mlir::ComplexType ty) {
@@ -587,8 +590,9 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
587590
}
588591
}
589592
})
590-
.Case<fir::ComplexType>(
591-
[&](fir::ComplexType ty) { lowerComplexSignatureArg(ty, newInTys); })
593+
.Case<fir::ComplexType>([&](fir::ComplexType ty) {
594+
lowerComplexSignatureArg(ty, newInTys);
595+
})
592596
.Case<mlir::ComplexType>([&](mlir::ComplexType ty) {
593597
lowerComplexSignatureArg(ty, newInTys);
594598
})
@@ -647,7 +651,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
647651
// Convert return value(s)
648652
for (auto ty : funcTy.getResults())
649653
llvm::TypeSwitch<mlir::Type>(ty)
650-
.Case<fir::ComplexType>([&](fir::ComplexType cmplx) {
654+
.Case<fir::ComplexType>([&](fir::ComplexType cmplx) {
651655
if (noComplexConversion)
652656
newResTys.push_back(cmplx);
653657
else
@@ -696,7 +700,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
696700
}
697701
}
698702
})
699-
.Case<fir::ComplexType>([&](fir::ComplexType cmplx) {
703+
.Case<fir::ComplexType>([&](fir::ComplexType cmplx) {
700704
if (noComplexConversion)
701705
newInTys.push_back(cmplx);
702706
else

flang/tools/bbc/bbc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static mlir::LogicalResult convertFortranSourceToMLIR(
264264
pm.addPass(std::make_unique<Fortran::lower::VerifierPass>());
265265
pm.addPass(mlir::createCanonicalizerPass());
266266
pm.addPass(fir::createCSEPass());
267-
pm.addPass(fir::createPromoteToAffinePass());
267+
// pm.addPass(fir::createPromoteToAffinePass());
268268
pm.addPass(fir::createFirToCfgPass());
269269
pm.addPass(fir::createControlFlowLoweringPass());
270270
pm.addPass(mlir::createLowerToCFGPass());

0 commit comments

Comments
 (0)