[flang-commits] [flang] f47d7c1 - [flang][fir][NFC] Rename WhereOp to IfOp.
Eric Schweitz via flang-commits
flang-commits at lists.llvm.org
Thu Feb 11 11:33:57 PST 2021
Author: Eric Schweitz
Date: 2021-02-11T11:33:37-08:00
New Revision: f47d7c145b89985807c1e84316d091c5711f2e49
URL: https://github.com/llvm/llvm-project/commit/f47d7c145b89985807c1e84316d091c5711f2e49
DIFF: https://github.com/llvm/llvm-project/commit/f47d7c145b89985807c1e84316d091c5711f2e49.diff
LOG: [flang][fir][NFC] Rename WhereOp to IfOp.
Added:
Modified:
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/lib/Lower/IO.cpp
flang/lib/Optimizer/Dialect/FIROps.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 918fdd400c3c..a8d610771c2c 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -1818,7 +1818,7 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoSideEffect]> {
def fir_ResultOp : fir_Op<"result",
[NoSideEffect, ReturnLike, Terminator,
- ParentOneOf<["WhereOp", "DoLoopOp", "IterWhileOp"]>]> {
+ ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
let summary = "special terminator for use in fir region operations";
let description = [{
@@ -1935,7 +1935,7 @@ def fir_DoLoopOp : region_Op<"do_loop",
}];
}
-def fir_WhereOp : region_Op<"if", [NoRegionArguments]> {
+def fir_IfOp : region_Op<"if", [NoRegionArguments]> {
let summary = "if-then-else conditional operation";
let description = [{
Used to conditionally execute operations. This operation is the FIR
diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp
index 9ce1a16d026a..3c23eb24832f 100644
--- a/flang/lib/Lower/IO.cpp
+++ b/flang/lib/Lower/IO.cpp
@@ -178,8 +178,8 @@ static void makeNextConditionalOn(Fortran::lower::FirOpBuilder &builder,
// loop scope. That is done in genIoLoop, but it is enabled here.
auto whereOp =
inIterWhileLoop
- ? builder.create<fir::WhereOp>(loc, builder.getI1Type(), ok, true)
- : builder.create<fir::WhereOp>(loc, ok, /*withOtherwise=*/false);
+ ? builder.create<fir::IfOp>(loc, builder.getI1Type(), ok, true)
+ : builder.create<fir::IfOp>(loc, ok, /*withOtherwise=*/false);
if (!insertPt.isSet())
insertPt = builder.saveInsertionPoint();
builder.setInsertionPointToStart(&whereOp.whereRegion().front());
@@ -411,9 +411,9 @@ static void genIoLoop(Fortran::lower::AbstractConverter &converter,
auto falseValue = builder.createIntegerConstant(loc, builder.getI1Type(), 0);
genItemList(ioImpliedDo, true);
// Unwind nested I/O call scopes, filling in true and false ResultOp's.
- for (auto *op = builder.getBlock()->getParentOp(); isa<fir::WhereOp>(op);
+ for (auto *op = builder.getBlock()->getParentOp(); isa<fir::IfOp>(op);
op = op->getBlock()->getParentOp()) {
- auto whereOp = dyn_cast<fir::WhereOp>(op);
+ auto whereOp = dyn_cast<fir::IfOp>(op);
auto *lastOp = &whereOp.whereRegion().front().back();
builder.setInsertionPointAfter(lastOp);
builder.create<fir::ResultOp>(loc, lastOp->getResult(0)); // runtime result
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index e1658fd4edd5..ed053fd2b1a6 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -1396,34 +1396,34 @@ mlir::OpFoldResult fir::SubfOp::fold(llvm::ArrayRef<mlir::Attribute> opnds) {
}
//===----------------------------------------------------------------------===//
-// WhereOp
+// IfOp
//===----------------------------------------------------------------------===//
-void fir::WhereOp::build(mlir::OpBuilder &builder, OperationState &result,
- mlir::Value cond, bool withElseRegion) {
+void fir::IfOp::build(mlir::OpBuilder &builder, OperationState &result,
+ mlir::Value cond, bool withElseRegion) {
build(builder, result, llvm::None, cond, withElseRegion);
}
-void fir::WhereOp::build(mlir::OpBuilder &builder, OperationState &result,
- mlir::TypeRange resultTypes, mlir::Value cond,
- bool withElseRegion) {
+void fir::IfOp::build(mlir::OpBuilder &builder, OperationState &result,
+ mlir::TypeRange resultTypes, mlir::Value cond,
+ bool withElseRegion) {
result.addOperands(cond);
result.addTypes(resultTypes);
mlir::Region *thenRegion = result.addRegion();
thenRegion->push_back(new mlir::Block());
if (resultTypes.empty())
- WhereOp::ensureTerminator(*thenRegion, builder, result.location);
+ fir::IfOp::ensureTerminator(*thenRegion, builder, result.location);
mlir::Region *elseRegion = result.addRegion();
if (withElseRegion) {
elseRegion->push_back(new mlir::Block());
if (resultTypes.empty())
- WhereOp::ensureTerminator(*elseRegion, builder, result.location);
+ fir::IfOp::ensureTerminator(*elseRegion, builder, result.location);
}
}
-static mlir::ParseResult parseWhereOp(OpAsmParser &parser,
- OperationState &result) {
+static mlir::ParseResult parseIfOp(OpAsmParser &parser,
+ OperationState &result) {
result.regions.reserve(2);
mlir::Region *thenRegion = result.addRegion();
mlir::Region *elseRegion = result.addRegion();
@@ -1438,13 +1438,14 @@ static mlir::ParseResult parseWhereOp(OpAsmParser &parser,
if (parser.parseRegion(*thenRegion, {}, {}))
return mlir::failure();
- WhereOp::ensureTerminator(*thenRegion, parser.getBuilder(), result.location);
+ fir::IfOp::ensureTerminator(*thenRegion, parser.getBuilder(),
+ result.location);
if (!parser.parseOptionalKeyword("else")) {
if (parser.parseRegion(*elseRegion, {}, {}))
return mlir::failure();
- WhereOp::ensureTerminator(*elseRegion, parser.getBuilder(),
- result.location);
+ fir::IfOp::ensureTerminator(*elseRegion, parser.getBuilder(),
+ result.location);
}
// Parse the optional attribute list.
@@ -1454,16 +1455,16 @@ static mlir::ParseResult parseWhereOp(OpAsmParser &parser,
return mlir::success();
}
-static LogicalResult verify(fir::WhereOp op) {
+static LogicalResult verify(fir::IfOp op) {
if (op.getNumResults() != 0 && op.otherRegion().empty())
return op.emitOpError("must have an else block if defining values");
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::WhereOp op) {
+static void print(mlir::OpAsmPrinter &p, fir::IfOp op) {
bool printBlockTerminators = false;
- p << fir::WhereOp::getOperationName() << ' ' << op.condition();
+ p << fir::IfOp::getOperationName() << ' ' << op.condition();
if (!op.results().empty()) {
p << " -> (" << op.getResultTypes() << ')';
printBlockTerminators = true;
More information about the flang-commits
mailing list