Skip to content

Commit e9efb92

Browse files
Style Changes: Using expanded namespace.
1 parent 66f9e9d commit e9efb92

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

flang/lib/Optimizer/Transforms/FIRToSCF.cpp

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct DoLoopConversion : public mlir::OpRewritePattern<fir::DoLoopOp> {
3636
mlir::Value high = doLoopOp.getUpperBound();
3737
assert(low && high && "must be a Value");
3838
mlir::Value step = doLoopOp.getStep();
39-
llvm::SmallVector<mlir::Value> iterArgs;
39+
mlir::SmallVector<mlir::Value> iterArgs;
4040
if (hasFinalValue)
4141
iterArgs.push_back(low);
4242
iterArgs.append(doLoopOp.getIterOperands().begin(),
@@ -88,75 +88,77 @@ struct DoLoopConversion : public mlir::OpRewritePattern<fir::DoLoopOp> {
8888
}
8989
};
9090

91-
struct IterWhileConversion : public OpRewritePattern<fir::IterWhileOp> {
91+
struct IterWhileConversion : public mlir::OpRewritePattern<fir::IterWhileOp> {
9292
using OpRewritePattern<fir::IterWhileOp>::OpRewritePattern;
9393

94-
LogicalResult matchAndRewrite(fir::IterWhileOp iterWhileOp,
95-
PatternRewriter &rewriter) const override {
94+
mlir::LogicalResult
95+
matchAndRewrite(fir::IterWhileOp iterWhileOp,
96+
mlir::PatternRewriter &rewriter) const override {
9697

97-
Location loc = iterWhileOp.getLoc();
98-
Value lowerBound = iterWhileOp.getLowerBound();
99-
Value upperBound = iterWhileOp.getUpperBound();
100-
Value step = iterWhileOp.getStep();
98+
mlir::Location loc = iterWhileOp.getLoc();
99+
mlir::Value lowerBound = iterWhileOp.getLowerBound();
100+
mlir::Value upperBound = iterWhileOp.getUpperBound();
101+
mlir::Value step = iterWhileOp.getStep();
101102

102-
Value okInit = iterWhileOp.getIterateIn();
103-
ValueRange iterArgs = iterWhileOp.getInitArgs();
103+
mlir::Value okInit = iterWhileOp.getIterateIn();
104+
mlir::ValueRange iterArgs = iterWhileOp.getInitArgs();
104105

105-
SmallVector<Value> initVals;
106+
mlir::SmallVector<mlir::Value> initVals;
106107
initVals.push_back(lowerBound);
107108
initVals.push_back(okInit);
108109
initVals.append(iterArgs.begin(), iterArgs.end());
109110

110-
SmallVector<Type> loopTypes;
111+
mlir::SmallVector<mlir::Type> loopTypes;
111112
loopTypes.push_back(lowerBound.getType());
112113
loopTypes.push_back(okInit.getType());
113114
for (auto val : iterArgs)
114115
loopTypes.push_back(val.getType());
115116

116-
auto scfWhileOp = scf::WhileOp::create(rewriter, loc, loopTypes, initVals);
117+
auto scfWhileOp =
118+
mlir::scf::WhileOp::create(rewriter, loc, loopTypes, initVals);
117119

118120
auto &beforeBlock = *rewriter.createBlock(
119121
&scfWhileOp.getBefore(), scfWhileOp.getBefore().end(), loopTypes,
120-
SmallVector<Location>(loopTypes.size(), loc));
122+
mlir::SmallVector<mlir::Location>(loopTypes.size(), loc));
121123

122-
Region::BlockArgListType argsInBefore =
124+
mlir::Region::BlockArgListType argsInBefore =
123125
scfWhileOp.getBefore().getArguments();
124126
auto ivInBefore = argsInBefore[0];
125127
auto earlyExitInBefore = argsInBefore[1];
126128

127129
rewriter.setInsertionPointToStart(&beforeBlock);
128130

129-
Value inductionCmp = mlir::arith::CmpIOp::create(
131+
mlir::Value inductionCmp = mlir::arith::CmpIOp::create(
130132
rewriter, loc, mlir::arith::CmpIPredicate::sle, ivInBefore, upperBound);
131-
Value cond = mlir::arith::AndIOp::create(rewriter, loc, inductionCmp,
132-
earlyExitInBefore);
133+
mlir::Value cond = mlir::arith::AndIOp::create(rewriter, loc, inductionCmp,
134+
earlyExitInBefore);
133135

134136
mlir::scf::ConditionOp::create(rewriter, loc, cond, argsInBefore);
135137

136138
rewriter.moveBlockBefore(iterWhileOp.getBody(), &scfWhileOp.getAfter(),
137139
scfWhileOp.getAfter().begin());
138140

139141
auto *afterBody = scfWhileOp.getAfterBody();
140-
auto resultOp = cast<fir::ResultOp>(afterBody->getTerminator());
141-
SmallVector<Value> results(resultOp->getOperands());
142-
Value ivInAfter = scfWhileOp.getAfterArguments()[0];
142+
auto resultOp = mlir::cast<fir::ResultOp>(afterBody->getTerminator());
143+
mlir::SmallVector<mlir::Value> results(resultOp->getOperands());
144+
mlir::Value ivInAfter = scfWhileOp.getAfterArguments()[0];
143145

144146
rewriter.setInsertionPointToStart(afterBody);
145147
results[0] = mlir::arith::AddIOp::create(rewriter, loc, ivInAfter, step);
146148

147149
rewriter.setInsertionPointToEnd(afterBody);
148-
rewriter.replaceOpWithNewOp<scf::YieldOp>(resultOp, results);
150+
rewriter.replaceOpWithNewOp<mlir::scf::YieldOp>(resultOp, results);
149151

150152
scfWhileOp->setAttrs(iterWhileOp->getAttrs());
151153
rewriter.replaceOp(iterWhileOp, scfWhileOp);
152-
return success();
154+
return mlir::success();
153155
}
154156
};
155157

156-
void copyBlockAndTransformResult(PatternRewriter &rewriter, Block &srcBlock,
157-
Block &dstBlock) {
158-
Operation *srcTerminator = srcBlock.getTerminator();
159-
auto resultOp = cast<fir::ResultOp>(srcTerminator);
158+
void copyBlockAndTransformResult(mlir::PatternRewriter &rewriter,
159+
mlir::Block &srcBlock, mlir::Block &dstBlock) {
160+
mlir::Operation *srcTerminator = srcBlock.getTerminator();
161+
auto resultOp = mlir::cast<fir::ResultOp>(srcTerminator);
160162

161163
dstBlock.getOperations().splice(dstBlock.begin(), srcBlock.getOperations(),
162164
srcBlock.begin(), std::prev(srcBlock.end()));
@@ -196,12 +198,12 @@ struct IfConversion : public mlir::OpRewritePattern<fir::IfOp> {
196198
} // namespace
197199

198200
void FIRToSCFPass::runOnOperation() {
199-
RewritePatternSet patterns(&getContext());
201+
mlir::RewritePatternSet patterns(&getContext());
200202
patterns.add<DoLoopConversion, IterWhileConversion, IfConversion>(
201203
patterns.getContext());
202-
ConversionTarget target(getContext());
204+
mlir::ConversionTarget target(getContext());
203205
target.addIllegalOp<fir::DoLoopOp, fir::IterWhileOp, fir::IfOp>();
204-
target.markUnknownOpDynamicallyLegal([](Operation *) { return true; });
206+
target.markUnknownOpDynamicallyLegal([](mlir::Operation *) { return true; });
205207
if (failed(
206208
applyPartialConversion(getOperation(), target, std::move(patterns))))
207209
signalPassFailure();

0 commit comments

Comments
 (0)