[flang][fir][NFC] Rename WhereOp to IfOp.

This commit is contained in:
Eric Schweitz 2021-02-11 11:23:49 -08:00
parent 573348ab9b
commit f47d7c145b
3 changed files with 23 additions and 22 deletions

View File

@ -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

View File

@ -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

View File

@ -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;