[flang-commits] [flang] 3012f35 - [flang] Updated FIR dialect to _Both

Jacques Pienaar via flang-commits flang-commits at lists.llvm.org
Thu Dec 9 15:05:32 PST 2021


Author: Jacques Pienaar
Date: 2021-12-09T15:05:13-08:00
New Revision: 3012f35f8727408550d5308a1c28a66cd005a852

URL: https://github.com/llvm/llvm-project/commit/3012f35f8727408550d5308a1c28a66cd005a852
DIFF: https://github.com/llvm/llvm-project/commit/3012f35f8727408550d5308a1c28a66cd005a852.diff

LOG: [flang] Updated FIR dialect to _Both

Change dialect (and remove now redundant accessors) to generate both
form of accessors of being generated. Tried to keep this change
reasonably minimal (this also includes keeping note about not generating
getType accessor to avoid shadowing).

Differential Revision: https://reviews.llvm.org/D115420

Added: 
    

Modified: 
    flang/include/flang/Lower/Support/Utils.h
    flang/include/flang/Optimizer/Dialect/FIRDialect.td
    flang/include/flang/Optimizer/Dialect/FIROps.td
    flang/include/flang/Optimizer/Support/Utils.h
    flang/include/flang/Optimizer/Transforms/Factory.h
    flang/lib/Optimizer/CodeGen/CodeGen.cpp
    flang/lib/Optimizer/Dialect/FIROps.cpp
    flang/lib/Optimizer/Transforms/AffinePromotion.cpp
    flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
    flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp
    flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
    flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h
index 6d215884e6267..63b614098fbba 100644
--- a/flang/include/flang/Lower/Support/Utils.h
+++ b/flang/include/flang/Lower/Support/Utils.h
@@ -32,7 +32,7 @@ inline llvm::StringRef toStringRef(const Fortran::parser::CharBlock &cb) {
 namespace fir {
 /// Return the integer value of a arith::ConstantOp.
 inline std::int64_t toInt(mlir::arith::ConstantOp cop) {
-  return cop.value().cast<mlir::IntegerAttr>().getValue().getSExtValue();
+  return cop.getValue().cast<mlir::IntegerAttr>().getValue().getSExtValue();
 }
 } // namespace fir
 

diff  --git a/flang/include/flang/Optimizer/Dialect/FIRDialect.td b/flang/include/flang/Optimizer/Dialect/FIRDialect.td
index 8b86425f4d8ca..cb424994ffeb5 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRDialect.td
+++ b/flang/include/flang/Optimizer/Dialect/FIRDialect.td
@@ -24,6 +24,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
 def fir_Dialect : Dialect {
   let name = "fir";
   let cppNamespace = "::fir";
+  let emitAccessorPrefix = kEmitAccessorPrefix_Both;
 }
 
 #endif // FORTRAN_DIALECT_FIR_DIALECT

diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 1368009b71da9..cd4d77eab521b 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -177,7 +177,6 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
     unsigned numShapeOperands() { return shape().size(); }
     operand_range getShapeOperands() { return shape(); }
     static mlir::Type getRefTy(mlir::Type ty);
-    mlir::Type getInType() { return in_type(); }
   }];
 }
 
@@ -235,7 +234,6 @@ def fir_AllocMemOp : fir_Op<"allocmem",
     unsigned numShapeOperands() { return shape().size(); }
     operand_range getShapeOperands() { return shape(); }
     static mlir::Type getRefTy(mlir::Type ty);
-    mlir::Type getInType() { return in_type(); }
   }];
 }
 
@@ -484,7 +482,6 @@ class fir_SwitchTerminatorOp<string mnemonic, list<OpTrait> traits = []> :
     }
 
     // The selector is the value being tested to determine the destination
-    mlir::Value getSelector() { return selector(); }
     mlir::Value getSelector(llvm::ArrayRef<mlir::Value> operands) {
       return operands[0];
     }
@@ -893,8 +890,6 @@ def fir_EmboxOp : fir_Op<"embox", [NoSideEffect, AttrSizedOperandSegments]> {
   let verifier = "return ::verify(*this);";
 
   let extraClassDeclaration = [{
-    mlir::Value getShape() { return shape(); }
-    mlir::Value getSlice() { return slice(); }
     bool hasLenParams() { return !typeparams().empty(); }
     unsigned numLenParams() { return typeparams().size(); }
   }];
@@ -1673,11 +1668,6 @@ def fir_CoordinateOp : fir_Op<"coordinate_of", [NoSideEffect]> {
     [{ return build($_builder, $_state, resultType, ref, coor,
            mlir::TypeAttr::get(ref.getType())); }]>,
   ];
-
-  let extraClassDeclaration = [{
-    /// Get the type of the base object.
-    mlir::Type getBaseType() { return baseType(); }
-  }];
 }
 
 def fir_ExtractValueOp : fir_OneResultOp<"extract_value", [NoSideEffect]> {
@@ -1771,12 +1761,6 @@ def fir_ShapeOp : fir_Op<"shape", [NoSideEffect]> {
   }];
 
   let verifier = "return ::verify(*this);";
-
-  let extraClassDeclaration = [{
-    std::vector<mlir::Value> getExtents() {
-      return {extents().begin(), extents().end()};
-    }
-  }];
 }
 
 def fir_ShapeShiftOp : fir_Op<"shape_shift", [NoSideEffect]> {
@@ -1854,12 +1838,6 @@ def fir_ShiftOp : fir_Op<"shift", [NoSideEffect]> {
   }];
 
   let verifier = "return ::verify(*this);";
-
-  let extraClassDeclaration = [{
-    std::vector<mlir::Value> getOrigins() {
-      return {origins().begin(), origins().end()};
-    }
-  }];
 }
 
 def fir_SliceOp : fir_Op<"slice", [NoSideEffect, AttrSizedOperandSegments]> {
@@ -2022,9 +2000,6 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoSideEffect]> {
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef fieldAttrName() { return "field_id"; }
     static constexpr llvm::StringRef typeAttrName() { return "on_type"; }
-    mlir::Type getOnType() {
-      return (*this)->getAttrOfType<TypeAttr>(typeAttrName()).getValue();
-    }
   }];
 }
 
@@ -2250,7 +2225,7 @@ def fir_IterWhileOp : region_Op<"iterate_while",
   ];
 
   let extraClassDeclaration = [{
-    static constexpr llvm::StringRef getFinalValueAttrName() {
+    static constexpr llvm::StringRef getFinalValueAttrNameStr() {
       return "finalValue";
     }
     mlir::Block *getBody() { return &region().front(); }
@@ -2336,7 +2311,7 @@ def fir_CallOp : fir_Op<"call", [CallOpInterface]> {
     }]>];
 
   let extraClassDeclaration = [{
-    static constexpr StringRef getCalleeAttrName() { return "callee"; }
+    static constexpr StringRef getCalleeAttrNameStr() { return "callee"; }
 
     mlir::FunctionType getFunctionType();
 
@@ -2396,7 +2371,7 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
     static constexpr llvm::StringRef passArgAttrName() {
       return "pass_arg_pos";
     }
-    static constexpr llvm::StringRef getMethodAttrName() { return "method"; }
+    static constexpr llvm::StringRef getMethodAttrNameStr() { return "method"; }
     unsigned passArgPos();
   }];
 }
@@ -2646,13 +2621,6 @@ def fir_GenTypeDescOp : fir_OneResultOp<"gentypedesc", [NoSideEffect]> {
   let builders = [OpBuilder<(ins "mlir::TypeAttr":$inty)>];
 
   let verifier = "return ::verify(*this);";
-
-  let extraClassDeclaration = [{
-    mlir::Type getInType() {
-      // get the type that the type descriptor describes
-      return (*this)->getAttrOfType<mlir::TypeAttr>("in_type").getValue();
-    }
-  }];
 }
 
 def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
@@ -2744,8 +2712,8 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
   ];
 
   let extraClassDeclaration = [{
-    static constexpr llvm::StringRef symbolAttrName() { return "symref"; }
-    static constexpr llvm::StringRef getConstantAttrName() {
+    static constexpr llvm::StringRef symbolAttrNameStr() { return "symref"; }
+    static constexpr llvm::StringRef getConstantAttrNameStr() {
       return "constant";
     }
     static constexpr llvm::StringRef linkageAttrName() { return "linkName"; }
@@ -2765,9 +2733,6 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
     /// the variable's initial value.
     void appendInitialValue(mlir::Operation *op);
 
-    /// A GlobalOp has one region.
-    mlir::Region &getRegion() { return (*this)->getRegion(0); }
-
     /// A GlobalOp has one block.
     mlir::Block &getBlock() { return getRegion().front(); }
 
@@ -2860,10 +2825,6 @@ def fir_DispatchTableOp : fir_Op<"dispatch_table",
     /// Append a dispatch table entry to the table.
     void appendTableEntry(mlir::Operation *op);
 
-    mlir::Region &getRegion() {
-      return (*this)->getRegion(0);
-    }
-
     mlir::Block &getBlock() {
       return getRegion().front();
     }
@@ -2892,8 +2853,8 @@ def fir_DTEntryOp : fir_Op<"dt_entry", [HasParent<"DispatchTableOp">]> {
   let printer = "::print(p, *this);";
 
   let extraClassDeclaration = [{
-    static constexpr llvm::StringRef getMethodAttrName() { return "method"; }
-    static constexpr llvm::StringRef getProcAttrName() { return "proc"; }
+    static constexpr llvm::StringRef getMethodAttrNameStr() { return "method"; }
+    static constexpr llvm::StringRef getProcAttrNameStr() { return "proc"; }
   }];
 }
 

diff  --git a/flang/include/flang/Optimizer/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h
index 4e901322f4b3b..1f4795961ded7 100644
--- a/flang/include/flang/Optimizer/Support/Utils.h
+++ b/flang/include/flang/Optimizer/Support/Utils.h
@@ -19,7 +19,7 @@
 namespace fir {
 /// Return the integer value of a arith::ConstantOp.
 inline std::int64_t toInt(mlir::arith::ConstantOp cop) {
-  return cop.value().cast<mlir::IntegerAttr>().getValue().getSExtValue();
+  return cop.getValue().cast<mlir::IntegerAttr>().getValue().getSExtValue();
 }
 } // namespace fir
 

diff  --git a/flang/include/flang/Optimizer/Transforms/Factory.h b/flang/include/flang/Optimizer/Transforms/Factory.h
index eeae18ed141af..b203413bea9fb 100644
--- a/flang/include/flang/Optimizer/Transforms/Factory.h
+++ b/flang/include/flang/Optimizer/Transforms/Factory.h
@@ -38,8 +38,10 @@ inline std::vector<mlir::Value> getOrigins(mlir::Value shapeVal) {
     if (auto *shapeOp = shapeVal.getDefiningOp()) {
       if (auto shOp = mlir::dyn_cast<fir::ShapeShiftOp>(shapeOp))
         return shOp.getOrigins();
-      if (auto shOp = mlir::dyn_cast<fir::ShiftOp>(shapeOp))
-        return shOp.getOrigins();
+      if (auto shOp = mlir::dyn_cast<fir::ShiftOp>(shapeOp)) {
+        auto operands = shOp.getOrigins();
+        return {operands.begin(), operands.end()};
+      }
     }
   return {};
 }

diff  --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 91c02c268e637..5f21f4a2c78a0 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -1060,7 +1060,7 @@ struct GlobalOpConversion : public FIROpConversion<fir::GlobalOp> {
           mlir::Type vecType = mlir::VectorType::get(
               insertOp.getType().getShape(), constant.getType());
           auto denseAttr = mlir::DenseElementsAttr::get(
-              vecType.cast<ShapedType>(), constant.value());
+              vecType.cast<ShapedType>(), constant.getValue());
           rewriter.setInsertionPointAfter(insertOp);
           rewriter.replaceOpWithNewOp<mlir::arith::ConstantOp>(
               insertOp, seqTyAttr, denseAttr);

diff  --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 09fdc2c1907ed..e16f16fa94176 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -382,8 +382,10 @@ static mlir::Type adjustedElementType(mlir::Type t) {
 std::vector<mlir::Value> fir::ArrayLoadOp::getExtents() {
   if (auto sh = shape())
     if (auto *op = sh.getDefiningOp()) {
-      if (auto shOp = dyn_cast<fir::ShapeOp>(op))
-        return shOp.getExtents();
+      if (auto shOp = dyn_cast<fir::ShapeOp>(op)) {
+        auto extents = shOp.getExtents();
+        return {extents.begin(), extents.end()};
+      }
       return cast<fir::ShapeShiftOp>(op).getExtents();
     }
   return {};
@@ -632,7 +634,7 @@ static mlir::ParseResult parseCallOp(mlir::OpAsmParser &parser,
 void fir::CallOp::build(mlir::OpBuilder &builder, mlir::OperationState &result,
                         mlir::FuncOp callee, mlir::ValueRange operands) {
   result.addOperands(operands);
-  result.addAttribute(getCalleeAttrName(), SymbolRefAttr::get(callee));
+  result.addAttribute(getCalleeAttrNameStr(), SymbolRefAttr::get(callee));
   result.addTypes(callee.getType().getResults());
 }
 
@@ -642,7 +644,7 @@ void fir::CallOp::build(mlir::OpBuilder &builder, mlir::OperationState &result,
                         mlir::ValueRange operands) {
   result.addOperands(operands);
   if (callee)
-    result.addAttribute(getCalleeAttrName(), callee);
+    result.addAttribute(getCalleeAttrNameStr(), callee);
   result.addTypes(results);
 }
 
@@ -921,11 +923,12 @@ static mlir::ParseResult parseDispatchOp(mlir::OpAsmParser &parser,
   llvm::StringRef calleeName;
   if (failed(parser.parseOptionalKeyword(&calleeName))) {
     mlir::StringAttr calleeAttr;
-    if (parser.parseAttribute(calleeAttr, fir::DispatchOp::getMethodAttrName(),
+    if (parser.parseAttribute(calleeAttr,
+                              fir::DispatchOp::getMethodAttrNameStr(),
                               result.attributes))
       return mlir::failure();
   } else {
-    result.addAttribute(fir::DispatchOp::getMethodAttrName(),
+    result.addAttribute(fir::DispatchOp::getMethodAttrNameStr(),
                         parser.getBuilder().getStringAttr(calleeName));
   }
   if (parser.parseOperandList(operands, mlir::OpAsmParser::Delimiter::Paren) ||
@@ -939,8 +942,7 @@ static mlir::ParseResult parseDispatchOp(mlir::OpAsmParser &parser,
 }
 
 static void print(mlir::OpAsmPrinter &p, fir::DispatchOp &op) {
-  p << ' ' << op.getOperation()->getAttr(fir::DispatchOp::getMethodAttrName())
-    << '(';
+  p << ' ' << op.getMethodAttr() << '(';
   p.printOperand(op.object());
   if (!op.args().empty()) {
     p << ", ";
@@ -1167,7 +1169,7 @@ static ParseResult parseGlobalOp(OpAsmParser &parser, OperationState &result) {
 
   // Parse the name as a symbol reference attribute.
   mlir::SymbolRefAttr nameAttr;
-  if (parser.parseAttribute(nameAttr, fir::GlobalOp::symbolAttrName(),
+  if (parser.parseAttribute(nameAttr, fir::GlobalOp::symbolAttrNameStr(),
                             result.attributes))
     return mlir::failure();
   result.addAttribute(mlir::SymbolTable::getSymbolAttrName(),
@@ -1211,11 +1213,10 @@ static void print(mlir::OpAsmPrinter &p, fir::GlobalOp &op) {
   if (op.linkName().hasValue())
     p << ' ' << op.linkName().getValue();
   p << ' ';
-  p.printAttributeWithoutType(
-      op.getOperation()->getAttr(fir::GlobalOp::symbolAttrName()));
+  p.printAttributeWithoutType(op.getSymrefAttr());
   if (auto val = op.getValueOrNull())
     p << '(' << val << ')';
-  if (op.getOperation()->getAttr(fir::GlobalOp::getConstantAttrName()))
+  if (op.getOperation()->getAttr(fir::GlobalOp::getConstantAttrNameStr()))
     p << " constant";
   p << " : ";
   p.printType(op.getType());
@@ -1237,7 +1238,7 @@ void fir::GlobalOp::build(mlir::OpBuilder &builder, OperationState &result,
   result.addAttribute(typeAttrName(result.name), mlir::TypeAttr::get(type));
   result.addAttribute(mlir::SymbolTable::getSymbolAttrName(),
                       builder.getStringAttr(name));
-  result.addAttribute(symbolAttrName(),
+  result.addAttribute(symbolAttrNameStr(),
                       SymbolRefAttr::get(builder.getContext(), name));
   if (isConstant)
     result.addAttribute(constantAttrName(result.name), builder.getUnitAttr());
@@ -1483,13 +1484,13 @@ struct UndoComplexPattern : public mlir::RewritePattern {
         !isZero(insval2.coor()[0]))
       return mlir::failure();
     auto eai =
-        dyn_cast_or_null<fir::ExtractValueOp>(binf.lhs().getDefiningOp());
+        dyn_cast_or_null<fir::ExtractValueOp>(binf.getLhs().getDefiningOp());
     auto ebi =
-        dyn_cast_or_null<fir::ExtractValueOp>(binf.rhs().getDefiningOp());
+        dyn_cast_or_null<fir::ExtractValueOp>(binf.getRhs().getDefiningOp());
     auto ear =
-        dyn_cast_or_null<fir::ExtractValueOp>(binf2.lhs().getDefiningOp());
+        dyn_cast_or_null<fir::ExtractValueOp>(binf2.getLhs().getDefiningOp());
     auto ebr =
-        dyn_cast_or_null<fir::ExtractValueOp>(binf2.rhs().getDefiningOp());
+        dyn_cast_or_null<fir::ExtractValueOp>(binf2.getRhs().getDefiningOp());
     if (!eai || !ebi || !ear || !ebr || ear.adt() != eai.adt() ||
         ebr.adt() != ebi.adt() || eai.coor().size() != 1 ||
         !isOne(eai.coor()[0]) || ebi.coor().size() != 1 ||
@@ -1521,7 +1522,7 @@ void fir::IterWhileOp::build(mlir::OpBuilder &builder,
   result.addOperands({lb, ub, step, iterate});
   if (finalCountValue) {
     result.addTypes(builder.getIndexType());
-    result.addAttribute(getFinalValueAttrName(), builder.getUnitAttr());
+    result.addAttribute(getFinalValueAttrNameStr(), builder.getUnitAttr());
   }
   result.addTypes(iterate.getType());
   result.addOperands(iterArgs);
@@ -1613,7 +1614,7 @@ static mlir::ParseResult parseIterWhileOp(mlir::OpAsmParser &parser,
   llvm::SmallVector<mlir::Type> argTypes;
   // Induction variable (hidden)
   if (prependCount)
-    result.addAttribute(IterWhileOp::getFinalValueAttrName(),
+    result.addAttribute(IterWhileOp::getFinalValueAttrNameStr(),
                         builder.getUnitAttr());
   else
     argTypes.push_back(indexType);
@@ -1707,7 +1708,7 @@ static void print(mlir::OpAsmPrinter &p, fir::IterWhileOp op) {
     p << " -> (" << op.getResultTypes() << ')';
   }
   p.printOptionalAttrDictWithKeyword(op->getAttrs(),
-                                     {IterWhileOp::getFinalValueAttrName()});
+                                     {op.getFinalValueAttrNameStr()});
   p.printRegion(op.region(), /*printEntryBlockArgs=*/false,
                 /*printBlockTerminators=*/true);
 }
@@ -2056,24 +2057,24 @@ static mlir::ParseResult parseDTEntryOp(mlir::OpAsmParser &parser,
   // allow `methodName` or `"methodName"`
   if (failed(parser.parseOptionalKeyword(&methodName))) {
     mlir::StringAttr methodAttr;
-    if (parser.parseAttribute(methodAttr, fir::DTEntryOp::getMethodAttrName(),
+    if (parser.parseAttribute(methodAttr,
+                              fir::DTEntryOp::getMethodAttrNameStr(),
                               result.attributes))
       return mlir::failure();
   } else {
-    result.addAttribute(fir::DTEntryOp::getMethodAttrName(),
+    result.addAttribute(fir::DTEntryOp::getMethodAttrNameStr(),
                         parser.getBuilder().getStringAttr(methodName));
   }
   mlir::SymbolRefAttr calleeAttr;
   if (parser.parseComma() ||
-      parser.parseAttribute(calleeAttr, fir::DTEntryOp::getProcAttrName(),
+      parser.parseAttribute(calleeAttr, fir::DTEntryOp::getProcAttrNameStr(),
                             result.attributes))
     return mlir::failure();
   return mlir::success();
 }
 
 static void print(mlir::OpAsmPrinter &p, fir::DTEntryOp &op) {
-  p << ' ' << op.getOperation()->getAttr(fir::DTEntryOp::getMethodAttrName())
-    << ", " << op.getOperation()->getAttr(fir::DTEntryOp::getProcAttrName());
+  p << ' ' << op.getMethodAttr() << ", " << op.getProcAttr();
 }
 
 //===----------------------------------------------------------------------===//

diff  --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
index a2614eb4047a3..045d780f5b3f8 100644
--- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
@@ -325,7 +325,7 @@ static mlir::AffineMap createArrayIndexAffineMap(unsigned dimensions,
 
 static Optional<int64_t> constantIntegerLike(const mlir::Value value) {
   if (auto definition = value.getDefiningOp<mlir::arith::ConstantOp>())
-    if (auto stepAttr = definition.value().dyn_cast<IntegerAttr>())
+    if (auto stepAttr = definition.getValue().dyn_cast<IntegerAttr>())
       return stepAttr.getInt();
   return {};
 }

diff  --git a/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp b/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
index e60cb3d1935d1..c268a56cd9e67 100644
--- a/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
+++ b/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
@@ -333,7 +333,7 @@ ArrayCopyAnalysis::arrayAccesses(ArrayLoadOp load) {
       accesses.push_back(owner);
       appendToQueue(update.getResult(1));
     } else if (auto br = mlir::dyn_cast<mlir::BranchOp>(owner)) {
-      branchOp(br.getDest(), br.destOperands());
+      branchOp(br.getDest(), br.getDestOperands());
     } else if (auto br = mlir::dyn_cast<mlir::CondBranchOp>(owner)) {
       branchOp(br.getTrueDest(), br.getTrueOperands());
       branchOp(br.getFalseDest(), br.getFalseOperands());

diff  --git a/flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp b/flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp
index 0387d62090ebe..00eba22289ff0 100644
--- a/flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp
+++ b/flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp
@@ -47,8 +47,8 @@ TEST_F(DoLoopHelperTest, createLoopWithCountTest) {
   EXPECT_TRUE(mlir::isa<arith::SubIOp>(loop.upperBound().getDefiningOp()));
   auto subOp = dyn_cast<arith::SubIOp>(loop.upperBound().getDefiningOp());
   EXPECT_EQ(c10, subOp.lhs());
-  checkConstantValue(subOp.rhs(), 1);
-  checkConstantValue(loop.step(), 1);
+  checkConstantValue(subOp.getRhs(), 1);
+  checkConstantValue(loop.getStep(), 1);
 }
 
 TEST_F(DoLoopHelperTest, createLoopWithLowerAndUpperBound) {
@@ -61,9 +61,9 @@ TEST_F(DoLoopHelperTest, createLoopWithLowerAndUpperBound) {
       firBuilder.getUnknownLoc(), firBuilder.getIndexType(), 20);
   auto loop =
       helper.createLoop(lb, ub, [&](fir::FirOpBuilder &, mlir::Value index) {});
-  checkConstantValue(loop.lowerBound(), 1);
-  checkConstantValue(loop.upperBound(), 20);
-  checkConstantValue(loop.step(), 1);
+  checkConstantValue(loop.getLowerBound(), 1);
+  checkConstantValue(loop.getUpperBound(), 20);
+  checkConstantValue(loop.getStep(), 1);
 }
 
 TEST_F(DoLoopHelperTest, createLoopWithStep) {
@@ -78,7 +78,7 @@ TEST_F(DoLoopHelperTest, createLoopWithStep) {
       firBuilder.getUnknownLoc(), firBuilder.getIndexType(), 2);
   auto loop = helper.createLoop(
       lb, ub, step, [&](fir::FirOpBuilder &, mlir::Value index) {});
-  checkConstantValue(loop.lowerBound(), 1);
-  checkConstantValue(loop.upperBound(), 20);
-  checkConstantValue(loop.step(), 2);
+  checkConstantValue(loop.getLowerBound(), 1);
+  checkConstantValue(loop.getUpperBound(), 20);
+  checkConstantValue(loop.getStep(), 2);
 }

diff  --git a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
index c65adebfa6cf8..bb8cd830f1d33 100644
--- a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
+++ b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
@@ -64,8 +64,8 @@ TEST_F(FIRBuilderTest, genIfThen) {
   auto loc = builder.getUnknownLoc();
   auto cdt = createCondition(builder);
   auto ifBuilder = builder.genIfThen(loc, cdt);
-  EXPECT_FALSE(ifBuilder.getIfOp().thenRegion().empty());
-  EXPECT_TRUE(ifBuilder.getIfOp().elseRegion().empty());
+  EXPECT_FALSE(ifBuilder.getIfOp().getThenRegion().empty());
+  EXPECT_TRUE(ifBuilder.getIfOp().getElseRegion().empty());
 }
 
 TEST_F(FIRBuilderTest, genIfThenElse) {
@@ -73,8 +73,8 @@ TEST_F(FIRBuilderTest, genIfThenElse) {
   auto loc = builder.getUnknownLoc();
   auto cdt = createCondition(builder);
   auto ifBuilder = builder.genIfThenElse(loc, cdt);
-  EXPECT_FALSE(ifBuilder.getIfOp().thenRegion().empty());
-  EXPECT_FALSE(ifBuilder.getIfOp().elseRegion().empty());
+  EXPECT_FALSE(ifBuilder.getIfOp().getThenRegion().empty());
+  EXPECT_FALSE(ifBuilder.getIfOp().getElseRegion().empty());
 }
 
 TEST_F(FIRBuilderTest, genIfWithThen) {
@@ -82,8 +82,8 @@ TEST_F(FIRBuilderTest, genIfWithThen) {
   auto loc = builder.getUnknownLoc();
   auto cdt = createCondition(builder);
   auto ifBuilder = builder.genIfOp(loc, {}, cdt, false);
-  EXPECT_FALSE(ifBuilder.getIfOp().thenRegion().empty());
-  EXPECT_TRUE(ifBuilder.getIfOp().elseRegion().empty());
+  EXPECT_FALSE(ifBuilder.getIfOp().getThenRegion().empty());
+  EXPECT_TRUE(ifBuilder.getIfOp().getElseRegion().empty());
 }
 
 TEST_F(FIRBuilderTest, genIfWithThenAndElse) {
@@ -91,8 +91,8 @@ TEST_F(FIRBuilderTest, genIfWithThenAndElse) {
   auto loc = builder.getUnknownLoc();
   auto cdt = createCondition(builder);
   auto ifBuilder = builder.genIfOp(loc, {}, cdt, true);
-  EXPECT_FALSE(ifBuilder.getIfOp().thenRegion().empty());
-  EXPECT_FALSE(ifBuilder.getIfOp().elseRegion().empty());
+  EXPECT_FALSE(ifBuilder.getIfOp().getThenRegion().empty());
+  EXPECT_FALSE(ifBuilder.getIfOp().getElseRegion().empty());
 }
 
 //===----------------------------------------------------------------------===//
@@ -107,7 +107,7 @@ TEST_F(FIRBuilderTest, genIsNotNull) {
   auto res = builder.genIsNotNull(loc, dummyValue);
   EXPECT_TRUE(mlir::isa<arith::CmpIOp>(res.getDefiningOp()));
   auto cmpOp = dyn_cast<arith::CmpIOp>(res.getDefiningOp());
-  EXPECT_EQ(arith::CmpIPredicate::ne, cmpOp.predicate());
+  EXPECT_EQ(arith::CmpIPredicate::ne, cmpOp.getPredicate());
 }
 
 TEST_F(FIRBuilderTest, genIsNull) {
@@ -118,7 +118,7 @@ TEST_F(FIRBuilderTest, genIsNull) {
   auto res = builder.genIsNull(loc, dummyValue);
   EXPECT_TRUE(mlir::isa<arith::CmpIOp>(res.getDefiningOp()));
   auto cmpOp = dyn_cast<arith::CmpIOp>(res.getDefiningOp());
-  EXPECT_EQ(arith::CmpIPredicate::eq, cmpOp.predicate());
+  EXPECT_EQ(arith::CmpIPredicate::eq, cmpOp.getPredicate());
 }
 
 TEST_F(FIRBuilderTest, createZeroConstant) {
@@ -147,7 +147,8 @@ TEST_F(FIRBuilderTest, createRealZeroConstant) {
   EXPECT_TRUE(mlir::isa<arith::ConstantOp>(cst.getDefiningOp()));
   auto cstOp = dyn_cast<arith::ConstantOp>(cst.getDefiningOp());
   EXPECT_EQ(realTy, cstOp.getType());
-  EXPECT_EQ(0u, cstOp.value().cast<FloatAttr>().getValue().convertToDouble());
+  EXPECT_EQ(
+      0u, cstOp.getValue().cast<FloatAttr>().getValue().convertToDouble());
 }
 
 TEST_F(FIRBuilderTest, createBool) {

diff  --git a/flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp b/flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp
index 13dd80ef378f6..13b3866254358 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp
+++ b/flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp
@@ -61,7 +61,7 @@ void testGenNearest(fir::FirOpBuilder &builder, mlir::Type xType,
   mlir::Value cmp = selectOp.condition();
   EXPECT_TRUE(mlir::isa<mlir::arith::CmpFOp>(cmp.getDefiningOp()));
   auto cmpOp = mlir::dyn_cast<mlir::arith::CmpFOp>(cmp.getDefiningOp());
-  EXPECT_EQ(s, cmpOp.lhs());
+  EXPECT_EQ(s, cmpOp.getLhs());
 }
 
 TEST_F(RuntimeCallTest, genNearestTest) {


        


More information about the flang-commits mailing list