[Mlir-commits] [mlir] 4fb4e12 - [mlir:OpenMP][NFC] Update OpenMP API to use prefixed accessors

River Riddle llvmlistbot at llvm.org
Fri Sep 30 15:34:26 PDT 2022


Author: River Riddle
Date: 2022-09-30T15:27:11-07:00
New Revision: 4fb4e12bab4e274d38aec5112cfc8957118af429

URL: https://github.com/llvm/llvm-project/commit/4fb4e12bab4e274d38aec5112cfc8957118af429
DIFF: https://github.com/llvm/llvm-project/commit/4fb4e12bab4e274d38aec5112cfc8957118af429.diff

LOG: [mlir:OpenMP][NFC] Update OpenMP API to use prefixed accessors

This doesn't flip the switch for prefix generation yet, that'll be
done in a followup.

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
    mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
    mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
    mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 3e5a3fdb4f09e..7652f62347372 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -340,10 +340,10 @@ def WsLoopOp : OpenMP_Op<"wsloop", [AttrSizedOperandSegments,
 
   let extraClassDeclaration = [{
     /// Returns the number of loops in the worksharing-loop nest.
-    unsigned getNumLoops() { return lowerBound().size(); }
+    unsigned getNumLoops() { return getLowerBound().size(); }
 
     /// Returns the number of reduction variables.
-    unsigned getNumReductionVars() { return reduction_vars().size(); }
+    unsigned getNumReductionVars() { return getReductionVars().size(); }
   }];
   let hasCustomAssemblyFormat = 1;
   let assemblyFormat = [{
@@ -428,7 +428,7 @@ def SimdLoopOp : OpenMP_Op<"simdloop", [AttrSizedOperandSegments,
 
   let extraClassDeclaration = [{
     /// Returns the number of loops in the simd loop nest.
-    unsigned getNumLoops() { return lowerBound().size(); }
+    unsigned getNumLoops() { return getLowerBound().size(); }
 
   }];
 
@@ -538,8 +538,8 @@ def TaskOp : OpenMP_Op<"task", [AttrSizedOperandSegments,
   let extraClassDeclaration = [{
     /// Returns the reduction variables
     SmallVector<Value> getReductionVars() {
-      return SmallVector<Value>(in_reduction_vars().begin(),
-                                in_reduction_vars().end());
+      return SmallVector<Value>(getInReductionVars().begin(),
+                                getInReductionVars().end());
     }
   }];
   let hasVerifier = 1;
@@ -752,7 +752,7 @@ def TaskGroupOp : OpenMP_Op<"taskgroup", [AttrSizedOperandSegments,
 
   let extraClassDeclaration = [{
     /// Returns the reduction variables
-    operand_range getAllReductionVars() { return task_reduction_vars(); }
+    operand_range getAllReductionVars() { return getTaskReductionVars(); }
   }];
 
   let hasVerifier = 1;
@@ -1037,15 +1037,15 @@ def AtomicReadOp : OpenMP_Op<"atomic.read", [AllTypesMatch<["x", "v"]>]> {
   let extraClassDeclaration = [{
     /// The number of variable operands.
     unsigned getNumVariableOperands() {
-      assert(x() && "expected 'x' operand");
-      assert(v() && "expected 'v' operand");
+      assert(getX() && "expected 'x' operand");
+      assert(getV() && "expected 'v' operand");
       return 2;
     }
 
     /// The i-th variable operand passed.
     Value getVariableOperand(unsigned i) {
       assert(i < 2 && "invalid index position for an operand");
-      return i == 0 ? x() : v();
+      return i == 0 ? getX() : getV();
     }
   }];
 }
@@ -1085,15 +1085,15 @@ def AtomicWriteOp : OpenMP_Op<"atomic.write"> {
   let extraClassDeclaration = [{
     /// The number of variable operands.
     unsigned getNumVariableOperands() {
-      assert(address() && "expected address operand");
-      assert(value() && "expected value operand");
+      assert(getAddress() && "expected address operand");
+      assert(getValue() && "expected value operand");
       return 2;
     }
 
     /// The i-th variable operand passed.
     Value getVariableOperand(unsigned i) {
       assert(i < 2 && "invalid index position for an operand");
-      return i == 0 ? address() : value();
+      return i == 0 ? getAddress() : getValue();
     }
   }];
 }
@@ -1261,14 +1261,14 @@ def ThreadprivateOp : OpenMP_Op<"threadprivate",
   let extraClassDeclaration = [{
     /// The number of variable operands.
     unsigned getNumVariableOperands() {
-      assert(sym_addr() && "expected one variable operand");
+      assert(getSymAddr() && "expected one variable operand");
       return 1;
     }
 
     /// The i-th variable operand passed.
     Value getVariableOperand(unsigned i) {
       assert(i == 0 && "invalid index position for an operand");
-      return sym_addr();
+      return getSymAddr();
     }
   }];
 }
@@ -1353,10 +1353,10 @@ def ReductionDeclareOp : OpenMP_Op<"reduction.declare", [Symbol,
 
   let extraClassDeclaration = [{
     PointerLikeType getAccumulatorType() {
-      if (atomicReductionRegion().empty())
+      if (getAtomicReductionRegion().empty())
         return {};
 
-      return atomicReductionRegion().front().getArgument(0).getType();
+      return getAtomicReductionRegion().front().getArgument(0).getType();
     }
   }];
   let hasRegionVerifier = 1;

diff  --git a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
index 9d521bdc10c54..6a2d375c69f76 100644
--- a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
+++ b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
@@ -40,9 +40,9 @@ struct RegionOpConversion : public ConvertOpToLLVMPattern<OpType> {
                   ConversionPatternRewriter &rewriter) const override {
     auto newOp = rewriter.create<OpType>(
         curOp.getLoc(), TypeRange(), adaptor.getOperands(), curOp->getAttrs());
-    rewriter.inlineRegionBefore(curOp.region(), newOp.region(),
-                                newOp.region().end());
-    if (failed(rewriter.convertRegionTypes(&newOp.region(),
+    rewriter.inlineRegionBefore(curOp.getRegion(), newOp.getRegion(),
+                                newOp.getRegion().end());
+    if (failed(rewriter.convertRegionTypes(&newOp.getRegion(),
                                            *this->getTypeConverter())))
       return failure();
 
@@ -88,7 +88,7 @@ struct ReductionOpConversion : public ConvertOpToLLVMPattern<omp::ReductionOp> {
   LogicalResult
   matchAndRewrite(omp::ReductionOp curOp, OpAdaptor adaptor,
                   ConversionPatternRewriter &rewriter) const override {
-    if (curOp.accumulator().getType().isa<MemRefType>()) {
+    if (curOp.getAccumulator().getType().isa<MemRefType>()) {
       // TODO: Support memref type in variable operands
       return rewriter.notifyMatchFailure(curOp, "memref is not supported yet");
     }

diff  --git a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
index c7fdd6655d133..1c3e35d4a91d1 100644
--- a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
+++ b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
@@ -193,9 +193,10 @@ static omp::ReductionDeclareOp createDecl(PatternRewriter &builder,
   symbolTable.insert(decl);
 
   Type type = reduce.getOperand().getType();
-  builder.createBlock(&decl.initializerRegion(), decl.initializerRegion().end(),
-                      {type}, {reduce.getOperand().getLoc()});
-  builder.setInsertionPointToEnd(&decl.initializerRegion().back());
+  builder.createBlock(&decl.getInitializerRegion(),
+                      decl.getInitializerRegion().end(), {type},
+                      {reduce.getOperand().getLoc()});
+  builder.setInsertionPointToEnd(&decl.getInitializerRegion().back());
   Value init =
       builder.create<LLVM::ConstantOp>(reduce.getLoc(), type, initValue);
   builder.create<omp::YieldOp>(reduce.getLoc(), init);
@@ -206,8 +207,8 @@ static omp::ReductionDeclareOp createDecl(PatternRewriter &builder,
   builder.setInsertionPoint(terminator);
   builder.replaceOpWithNewOp<omp::YieldOp>(terminator,
                                            terminator->getOperands());
-  builder.inlineRegionBefore(reduce.getRegion(), decl.reductionRegion(),
-                             decl.reductionRegion().end());
+  builder.inlineRegionBefore(reduce.getRegion(), decl.getReductionRegion(),
+                             decl.getReductionRegion().end());
   return decl;
 }
 
@@ -221,10 +222,10 @@ static omp::ReductionDeclareOp addAtomicRMW(OpBuilder &builder,
   Type type = reduce.getOperand().getType();
   Type ptrType = LLVM::LLVMPointerType::get(type);
   Location reduceOperandLoc = reduce.getOperand().getLoc();
-  builder.createBlock(&decl.atomicReductionRegion(),
-                      decl.atomicReductionRegion().end(), {ptrType, ptrType},
+  builder.createBlock(&decl.getAtomicReductionRegion(),
+                      decl.getAtomicReductionRegion().end(), {ptrType, ptrType},
                       {reduceOperandLoc, reduceOperandLoc});
-  Block *atomicBlock = &decl.atomicReductionRegion().back();
+  Block *atomicBlock = &decl.getAtomicReductionRegion().back();
   builder.setInsertionPointToEnd(atomicBlock);
   Value loaded = builder.create<LLVM::LoadOp>(reduce.getLoc(),
                                               atomicBlock->getArgument(1));
@@ -349,7 +350,7 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
       if (!decl)
         return failure();
       reductionDeclSymbols.push_back(
-          SymbolRefAttr::get(rewriter.getContext(), decl.sym_name()));
+          SymbolRefAttr::get(rewriter.getContext(), decl.getSymName()));
     }
 
     // Allocate reduction variables. Make sure the we don't overflow the stack
@@ -387,7 +388,7 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
     {
 
       OpBuilder::InsertionGuard guard(rewriter);
-      rewriter.createBlock(&ompParallel.region());
+      rewriter.createBlock(&ompParallel.getRegion());
 
       // Replace the loop.
       {
@@ -397,13 +398,13 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
             parallelOp.getUpperBound(), parallelOp.getStep());
         rewriter.create<omp::TerminatorOp>(loc);
 
-        rewriter.inlineRegionBefore(parallelOp.getRegion(), loop.region(),
-                                    loop.region().begin());
+        rewriter.inlineRegionBefore(parallelOp.getRegion(), loop.getRegion(),
+                                    loop.getRegion().begin());
 
-        Block *ops = rewriter.splitBlock(&*loop.region().begin(),
-                                         loop.region().begin()->begin());
+        Block *ops = rewriter.splitBlock(&*loop.getRegion().begin(),
+                                         loop.getRegion().begin()->begin());
 
-        rewriter.setInsertionPointToStart(&*loop.region().begin());
+        rewriter.setInsertionPointToStart(&*loop.getRegion().begin());
 
         auto scope = rewriter.create<memref::AllocaScopeOp>(parallelOp.getLoc(),
                                                             TypeRange());
@@ -415,9 +416,9 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
         rewriter.replaceOpWithNewOp<memref::AllocaScopeReturnOp>(
             oldYield, oldYield->getOperands());
         if (!reductionVariables.empty()) {
-          loop.reductionsAttr(
+          loop.setReductionsAttr(
               ArrayAttr::get(rewriter.getContext(), reductionDeclSymbols));
-          loop.reduction_varsMutable().append(reductionVariables);
+          loop.getReductionVarsMutable().append(reductionVariables);
         }
       }
     }

diff  --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 27f9d1ba8f6a3..78a1cfd3a853d 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -476,10 +476,10 @@ void ParallelOp::build(OpBuilder &builder, OperationState &state,
 }
 
 LogicalResult ParallelOp::verify() {
-  if (allocate_vars().size() != allocators_vars().size())
+  if (getAllocateVars().size() != getAllocatorsVars().size())
     return emitError(
         "expected equal sizes for allocate and allocator variables");
-  return verifyReductionVarList(*this, reductions(), reduction_vars());
+  return verifyReductionVarList(*this, getReductions(), getReductionVars());
 }
 
 //===----------------------------------------------------------------------===//
@@ -487,15 +487,15 @@ LogicalResult ParallelOp::verify() {
 //===----------------------------------------------------------------------===//
 
 LogicalResult SectionsOp::verify() {
-  if (allocate_vars().size() != allocators_vars().size())
+  if (getAllocateVars().size() != getAllocatorsVars().size())
     return emitError(
         "expected equal sizes for allocate and allocator variables");
 
-  return verifyReductionVarList(*this, reductions(), reduction_vars());
+  return verifyReductionVarList(*this, getReductions(), getReductionVars());
 }
 
 LogicalResult SectionsOp::verifyRegions() {
-  for (auto &inst : *region().begin()) {
+  for (auto &inst : *getRegion().begin()) {
     if (!(isa<SectionOp>(inst) || isa<TerminatorOp>(inst))) {
       return emitOpError()
              << "expected omp.section op or terminator op inside region";
@@ -507,7 +507,7 @@ LogicalResult SectionsOp::verifyRegions() {
 
 LogicalResult SingleOp::verify() {
   // Check for allocate clause restrictions
-  if (allocate_vars().size() != allocators_vars().size())
+  if (getAllocateVars().size() != getAllocatorsVars().size())
     return emitError(
         "expected equal sizes for allocate and allocator variables");
 
@@ -574,11 +574,11 @@ void printLoopControl(OpAsmPrinter &p, Operation *op, Region &region,
 //===----------------------------------------------------------------------===//
 
 LogicalResult SimdLoopOp::verify() {
-  if (this->lowerBound().empty()) {
+  if (this->getLowerBound().empty()) {
     return emitOpError() << "empty lowerbound for simd loop operation";
   }
-  if (this->simdlen().has_value() && this->safelen().has_value() &&
-      this->simdlen().value() > this->safelen().value()) {
+  if (this->getSimdlen().has_value() && this->getSafelen().has_value() &&
+      this->getSimdlen().value() > this->getSafelen().value()) {
     return emitOpError()
            << "simdlen clause and safelen clause are both present, but the "
               "simdlen value is not less than or equal to safelen value";
@@ -607,42 +607,42 @@ static void printAtomicReductionRegion(OpAsmPrinter &printer,
 }
 
 LogicalResult ReductionDeclareOp::verifyRegions() {
-  if (initializerRegion().empty())
+  if (getInitializerRegion().empty())
     return emitOpError() << "expects non-empty initializer region";
-  Block &initializerEntryBlock = initializerRegion().front();
+  Block &initializerEntryBlock = getInitializerRegion().front();
   if (initializerEntryBlock.getNumArguments() != 1 ||
-      initializerEntryBlock.getArgument(0).getType() != type()) {
+      initializerEntryBlock.getArgument(0).getType() != getType()) {
     return emitOpError() << "expects initializer region with one argument "
                             "of the reduction type";
   }
 
-  for (YieldOp yieldOp : initializerRegion().getOps<YieldOp>()) {
-    if (yieldOp.results().size() != 1 ||
-        yieldOp.results().getTypes()[0] != type())
+  for (YieldOp yieldOp : getInitializerRegion().getOps<YieldOp>()) {
+    if (yieldOp.getResults().size() != 1 ||
+        yieldOp.getResults().getTypes()[0] != getType())
       return emitOpError() << "expects initializer region to yield a value "
                               "of the reduction type";
   }
 
-  if (reductionRegion().empty())
+  if (getReductionRegion().empty())
     return emitOpError() << "expects non-empty reduction region";
-  Block &reductionEntryBlock = reductionRegion().front();
+  Block &reductionEntryBlock = getReductionRegion().front();
   if (reductionEntryBlock.getNumArguments() != 2 ||
       reductionEntryBlock.getArgumentTypes()[0] !=
           reductionEntryBlock.getArgumentTypes()[1] ||
-      reductionEntryBlock.getArgumentTypes()[0] != type())
+      reductionEntryBlock.getArgumentTypes()[0] != getType())
     return emitOpError() << "expects reduction region with two arguments of "
                             "the reduction type";
-  for (YieldOp yieldOp : reductionRegion().getOps<YieldOp>()) {
-    if (yieldOp.results().size() != 1 ||
-        yieldOp.results().getTypes()[0] != type())
+  for (YieldOp yieldOp : getReductionRegion().getOps<YieldOp>()) {
+    if (yieldOp.getResults().size() != 1 ||
+        yieldOp.getResults().getTypes()[0] != getType())
       return emitOpError() << "expects reduction region to yield a value "
                               "of the reduction type";
   }
 
-  if (atomicReductionRegion().empty())
+  if (getAtomicReductionRegion().empty())
     return success();
 
-  Block &atomicReductionEntryBlock = atomicReductionRegion().front();
+  Block &atomicReductionEntryBlock = getAtomicReductionRegion().front();
   if (atomicReductionEntryBlock.getNumArguments() != 2 ||
       atomicReductionEntryBlock.getArgumentTypes()[0] !=
           atomicReductionEntryBlock.getArgumentTypes()[1])
@@ -650,7 +650,7 @@ LogicalResult ReductionDeclareOp::verifyRegions() {
                             "arguments of the same type";
   auto ptrType = atomicReductionEntryBlock.getArgumentTypes()[0]
                      .dyn_cast<PointerLikeType>();
-  if (!ptrType || ptrType.getElementType() != type())
+  if (!ptrType || ptrType.getElementType() != getType())
     return emitOpError() << "expects atomic reduction region arguments to "
                             "be accumulators containing the reduction type";
   return success();
@@ -664,7 +664,7 @@ LogicalResult ReductionOp::verify() {
   while (op) {
     for (const auto &var :
          cast<ReductionClauseInterface>(op).getAllReductionVars())
-      if (var == accumulator())
+      if (var == getAccumulator())
         return success();
     op = op->getParentWithTrait<ReductionClauseInterface::Trait>();
   }
@@ -675,47 +675,48 @@ LogicalResult ReductionOp::verify() {
 // TaskOp
 //===----------------------------------------------------------------------===//
 LogicalResult TaskOp::verify() {
-  return verifyReductionVarList(*this, in_reductions(), in_reduction_vars());
+  return verifyReductionVarList(*this, getInReductions(), getInReductionVars());
 }
 
 //===----------------------------------------------------------------------===//
 // TaskGroupOp
 //===----------------------------------------------------------------------===//
 LogicalResult TaskGroupOp::verify() {
-  return verifyReductionVarList(*this, task_reductions(),
-                                task_reduction_vars());
+  return verifyReductionVarList(*this, getTaskReductions(),
+                                getTaskReductionVars());
 }
 
 //===----------------------------------------------------------------------===//
 // TaskLoopOp
 //===----------------------------------------------------------------------===//
 SmallVector<Value> TaskLoopOp::getAllReductionVars() {
-  SmallVector<Value> allReductionNvars(in_reduction_vars().begin(),
-                                       in_reduction_vars().end());
-  allReductionNvars.insert(allReductionNvars.end(), reduction_vars().begin(),
-                           reduction_vars().end());
+  SmallVector<Value> allReductionNvars(getInReductionVars().begin(),
+                                       getInReductionVars().end());
+  allReductionNvars.insert(allReductionNvars.end(), getReductionVars().begin(),
+                           getReductionVars().end());
   return allReductionNvars;
 }
 
 LogicalResult TaskLoopOp::verify() {
-  if (allocate_vars().size() != allocators_vars().size())
+  if (getAllocateVars().size() != getAllocatorsVars().size())
     return emitError(
         "expected equal sizes for allocate and allocator variables");
-  if (failed(verifyReductionVarList(*this, reductions(), reduction_vars())) ||
-      failed(
-          verifyReductionVarList(*this, in_reductions(), in_reduction_vars())))
+  if (failed(
+          verifyReductionVarList(*this, getReductions(), getReductionVars())) ||
+      failed(verifyReductionVarList(*this, getInReductions(),
+                                    getInReductionVars())))
     return failure();
 
-  if (!reduction_vars().empty() && nogroup())
+  if (!getReductionVars().empty() && getNogroup())
     return emitError("if a reduction clause is present on the taskloop "
                      "directive, the nogroup clause must not be specified");
-  for (auto var : reduction_vars()) {
-    if (llvm::is_contained(in_reduction_vars(), var))
+  for (auto var : getReductionVars()) {
+    if (llvm::is_contained(getInReductionVars(), var))
       return emitError("the same list item cannot appear in both a reduction "
                        "and an in_reduction clause");
   }
 
-  if (grain_size() && num_tasks()) {
+  if (getGrainSize() && getNumTasks()) {
     return emitError(
         "the grainsize clause and num_tasks clause are mutually exclusive and "
         "may not appear on the same taskloop directive");
@@ -741,7 +742,7 @@ void WsLoopOp::build(OpBuilder &builder, OperationState &state,
 }
 
 LogicalResult WsLoopOp::verify() {
-  return verifyReductionVarList(*this, reductions(), reduction_vars());
+  return verifyReductionVarList(*this, getReductions(), getReductionVars());
 }
 
 //===----------------------------------------------------------------------===//
@@ -749,12 +750,12 @@ LogicalResult WsLoopOp::verify() {
 //===----------------------------------------------------------------------===//
 
 LogicalResult CriticalDeclareOp::verify() {
-  return verifySynchronizationHint(*this, hint_val());
+  return verifySynchronizationHint(*this, getHintVal());
 }
 
 LogicalResult CriticalOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
-  if (nameAttr()) {
-    SymbolRefAttr symbolRef = nameAttr();
+  if (getNameAttr()) {
+    SymbolRefAttr symbolRef = getNameAttr();
     auto decl = symbolTable.lookupNearestSymbolFrom<CriticalDeclareOp>(
         *this, symbolRef);
     if (!decl) {
@@ -772,13 +773,13 @@ LogicalResult CriticalOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
 
 LogicalResult OrderedOp::verify() {
   auto container = (*this)->getParentOfType<WsLoopOp>();
-  if (!container || !container.ordered_valAttr() ||
-      container.ordered_valAttr().getInt() == 0)
+  if (!container || !container.getOrderedValAttr() ||
+      container.getOrderedValAttr().getInt() == 0)
     return emitOpError() << "ordered depend directive must be closely "
                          << "nested inside a worksharing-loop with ordered "
                          << "clause with parameter present";
 
-  if (container.ordered_valAttr().getInt() != (int64_t)*num_loops_val())
+  if (container.getOrderedValAttr().getInt() != (int64_t)*getNumLoopsVal())
     return emitOpError() << "number of variables in depend clause does not "
                          << "match number of iteration variables in the "
                          << "doacross loop";
@@ -788,12 +789,12 @@ LogicalResult OrderedOp::verify() {
 
 LogicalResult OrderedRegionOp::verify() {
   // TODO: The code generation for ordered simd directive is not supported yet.
-  if (simd())
+  if (getSimd())
     return failure();
 
   if (auto container = (*this)->getParentOfType<WsLoopOp>()) {
-    if (!container.ordered_valAttr() ||
-        container.ordered_valAttr().getInt() != 0)
+    if (!container.getOrderedValAttr() ||
+        container.getOrderedValAttr().getInt() != 0)
       return emitOpError() << "ordered region must be closely nested inside "
                            << "a worksharing-loop region with an ordered "
                            << "clause without parameter present";
@@ -807,17 +808,17 @@ LogicalResult OrderedRegionOp::verify() {
 //===----------------------------------------------------------------------===//
 
 LogicalResult AtomicReadOp::verify() {
-  if (auto mo = memory_order_val()) {
+  if (auto mo = getMemoryOrderVal()) {
     if (*mo == ClauseMemoryOrderKind::Acq_rel ||
         *mo == ClauseMemoryOrderKind::Release) {
       return emitError(
           "memory-order must not be acq_rel or release for atomic reads");
     }
   }
-  if (x() == v())
+  if (getX() == getV())
     return emitError(
         "read and write must not be to the same location for atomic reads");
-  return verifySynchronizationHint(*this, hint_val());
+  return verifySynchronizationHint(*this, getHintVal());
 }
 
 //===----------------------------------------------------------------------===//
@@ -825,17 +826,17 @@ LogicalResult AtomicReadOp::verify() {
 //===----------------------------------------------------------------------===//
 
 LogicalResult AtomicWriteOp::verify() {
-  if (auto mo = memory_order_val()) {
+  if (auto mo = getMemoryOrderVal()) {
     if (*mo == ClauseMemoryOrderKind::Acq_rel ||
         *mo == ClauseMemoryOrderKind::Acquire) {
       return emitError(
           "memory-order must not be acq_rel or acquire for atomic writes");
     }
   }
-  if (address().getType().cast<PointerLikeType>().getElementType() !=
-      value().getType())
+  if (getAddress().getType().cast<PointerLikeType>().getElementType() !=
+      getValue().getType())
     return emitError("address must dereference to value type");
-  return verifySynchronizationHint(*this, hint_val());
+  return verifySynchronizationHint(*this, getHintVal());
 }
 
 //===----------------------------------------------------------------------===//
@@ -845,14 +846,14 @@ LogicalResult AtomicWriteOp::verify() {
 bool AtomicUpdateOp::isNoOp() {
   YieldOp yieldOp = dyn_cast<omp::YieldOp>(getFirstOp());
   return (yieldOp &&
-          yieldOp.results().front() == getRegion().front().getArgument(0));
+          yieldOp.getResults().front() == getRegion().front().getArgument(0));
 }
 
 Value AtomicUpdateOp::getWriteOpVal() {
   YieldOp yieldOp = dyn_cast<omp::YieldOp>(getFirstOp());
   if (yieldOp &&
-      yieldOp.results().front() != getRegion().front().getArgument(0))
-    return yieldOp.results().front();
+      yieldOp.getResults().front() != getRegion().front().getArgument(0))
+    return yieldOp.getResults().front();
   return nullptr;
 }
 
@@ -863,15 +864,16 @@ LogicalResult AtomicUpdateOp::canonicalize(AtomicUpdateOp op,
     return success();
   }
   if (Value writeVal = op.getWriteOpVal()) {
-    rewriter.replaceOpWithNewOp<AtomicWriteOp>(
-        op, op.x(), writeVal, op.hint_valAttr(), op.memory_order_valAttr());
+    rewriter.replaceOpWithNewOp<AtomicWriteOp>(op, op.getX(), writeVal,
+                                               op.getHintValAttr(),
+                                               op.getMemoryOrderValAttr());
     return success();
   }
   return failure();
 }
 
 LogicalResult AtomicUpdateOp::verify() {
-  if (auto mo = memory_order_val()) {
+  if (auto mo = getMemoryOrderVal()) {
     if (*mo == ClauseMemoryOrderKind::Acq_rel ||
         *mo == ClauseMemoryOrderKind::Acquire) {
       return emitError(
@@ -879,25 +881,26 @@ LogicalResult AtomicUpdateOp::verify() {
     }
   }
 
-  if (region().getNumArguments() != 1)
+  if (getRegion().getNumArguments() != 1)
     return emitError("the region must accept exactly one argument");
 
-  if (x().getType().cast<PointerLikeType>().getElementType() !=
-      region().getArgument(0).getType()) {
+  if (getX().getType().cast<PointerLikeType>().getElementType() !=
+      getRegion().getArgument(0).getType()) {
     return emitError("the type of the operand must be a pointer type whose "
                      "element type is the same as that of the region argument");
   }
 
-  return verifySynchronizationHint(*this, hint_val());
+  return verifySynchronizationHint(*this, getHintVal());
 }
 
 LogicalResult AtomicUpdateOp::verifyRegions() {
 
-  YieldOp yieldOp = *region().getOps<YieldOp>().begin();
+  YieldOp yieldOp = *getRegion().getOps<YieldOp>().begin();
 
-  if (yieldOp.results().size() != 1)
+  if (yieldOp.getResults().size() != 1)
     return emitError("only updated value must be returned");
-  if (yieldOp.results().front().getType() != region().getArgument(0).getType())
+  if (yieldOp.getResults().front().getType() !=
+      getRegion().getArgument(0).getType())
     return emitError("input and yielded value must have the same type");
   return success();
 }
@@ -934,11 +937,11 @@ AtomicUpdateOp AtomicCaptureOp::getAtomicUpdateOp() {
 }
 
 LogicalResult AtomicCaptureOp::verify() {
-  return verifySynchronizationHint(*this, hint_val());
+  return verifySynchronizationHint(*this, getHintVal());
 }
 
 LogicalResult AtomicCaptureOp::verifyRegions() {
-  Block::OpListType &ops = region().front().getOperations();
+  Block::OpListType &ops = getRegion().front().getOperations();
   if (ops.size() != 3)
     return emitError()
            << "expected three operations in omp.atomic.capture region (one "
@@ -957,17 +960,17 @@ LogicalResult AtomicCaptureOp::verifyRegions() {
     return ops.front().emitError()
            << "invalid sequence of operations in the capture region";
   if (firstUpdateStmt && secondReadStmt &&
-      firstUpdateStmt.x() != secondReadStmt.x())
+      firstUpdateStmt.getX() != secondReadStmt.getX())
     return firstUpdateStmt.emitError()
            << "updated variable in omp.atomic.update must be captured in "
               "second operation";
   if (firstReadStmt && secondUpdateStmt &&
-      firstReadStmt.x() != secondUpdateStmt.x())
+      firstReadStmt.getX() != secondUpdateStmt.getX())
     return firstReadStmt.emitError()
            << "captured variable in omp.atomic.read must be updated in second "
               "operation";
   if (firstReadStmt && secondWriteStmt &&
-      firstReadStmt.x() != secondWriteStmt.address())
+      firstReadStmt.getX() != secondWriteStmt.getAddress())
     return firstReadStmt.emitError()
            << "captured variable in omp.atomic.read must be updated in "
               "second operation";
@@ -988,7 +991,7 @@ LogicalResult AtomicCaptureOp::verifyRegions() {
 //===----------------------------------------------------------------------===//
 
 LogicalResult CancelOp::verify() {
-  ClauseCancellationConstructType cct = cancellation_construct_type_val();
+  ClauseCancellationConstructType cct = getCancellationConstructTypeVal();
   Operation *parentOp = (*this)->getParentOp();
 
   if (!parentOp) {
@@ -1006,11 +1009,11 @@ LogicalResult CancelOp::verify() {
       return emitOpError() << "cancel loop must appear "
                            << "inside a worksharing-loop region";
     }
-    if (cast<WsLoopOp>(parentOp).nowaitAttr()) {
+    if (cast<WsLoopOp>(parentOp).getNowaitAttr()) {
       return emitError() << "A worksharing construct that is canceled "
                          << "must not have a nowait clause";
     }
-    if (cast<WsLoopOp>(parentOp).ordered_valAttr()) {
+    if (cast<WsLoopOp>(parentOp).getOrderedValAttr()) {
       return emitError() << "A worksharing construct that is canceled "
                          << "must not have an ordered clause";
     }
@@ -1021,7 +1024,7 @@ LogicalResult CancelOp::verify() {
                            << "inside a sections region";
     }
     if (isa_and_nonnull<SectionsOp>(parentOp->getParentOp()) &&
-        cast<SectionsOp>(parentOp->getParentOp()).nowaitAttr()) {
+        cast<SectionsOp>(parentOp->getParentOp()).getNowaitAttr()) {
       return emitError() << "A sections construct that is canceled "
                          << "must not have a nowait clause";
     }
@@ -1034,7 +1037,7 @@ LogicalResult CancelOp::verify() {
 //===----------------------------------------------------------------------===//
 
 LogicalResult CancellationPointOp::verify() {
-  ClauseCancellationConstructType cct = cancellation_construct_type_val();
+  ClauseCancellationConstructType cct = getCancellationConstructTypeVal();
   Operation *parentOp = (*this)->getParentOp();
 
   if (!parentOp) {

diff  --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 2707567644d38..4edb8795bce83 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -284,13 +284,13 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
   auto finiCB = [&](InsertPointTy codeGenIP) {};
 
   llvm::Value *ifCond = nullptr;
-  if (auto ifExprVar = opInst.if_expr_var())
+  if (auto ifExprVar = opInst.getIfExprVar())
     ifCond = moduleTranslation.lookupValue(ifExprVar);
   llvm::Value *numThreads = nullptr;
-  if (auto numThreadsVar = opInst.num_threads_var())
+  if (auto numThreadsVar = opInst.getNumThreadsVar())
     numThreads = moduleTranslation.lookupValue(numThreadsVar);
   auto pbKind = llvm::omp::OMP_PROC_BIND_default;
-  if (auto bind = opInst.proc_bind_val())
+  if (auto bind = opInst.getProcBindVal())
     pbKind = getProcBindKind(*bind);
   // TODO: Is the Parallel construct cancellable?
   bool isCancellable = false;
@@ -359,19 +359,19 @@ convertOmpCritical(Operation &opInst, llvm::IRBuilderBase &builder,
   llvm::Constant *hint = nullptr;
 
   // If it has a name, it probably has a hint too.
-  if (criticalOp.nameAttr()) {
+  if (criticalOp.getNameAttr()) {
     // The verifiers in OpenMP Dialect guarentee that all the pointers are
     // non-null
-    auto symbolRef = criticalOp.nameAttr().cast<SymbolRefAttr>();
+    auto symbolRef = criticalOp.getNameAttr().cast<SymbolRefAttr>();
     auto criticalDeclareOp =
         SymbolTable::lookupNearestSymbolFrom<omp::CriticalDeclareOp>(criticalOp,
                                                                      symbolRef);
-    hint =
-        llvm::ConstantInt::get(llvm::Type::getInt32Ty(llvmContext),
-                               static_cast<int>(criticalDeclareOp.hint_val()));
+    hint = llvm::ConstantInt::get(
+        llvm::Type::getInt32Ty(llvmContext),
+        static_cast<int>(criticalDeclareOp.getHintVal()));
   }
   builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createCritical(
-      ompLoc, bodyGenCB, finiCB, criticalOp.name().value_or(""), hint));
+      ompLoc, bodyGenCB, finiCB, criticalOp.getName().value_or(""), hint));
   return success();
 }
 
@@ -382,9 +382,9 @@ static omp::ReductionDeclareOp findReductionDecl(omp::WsLoopOp container,
                                                  omp::ReductionOp reduction) {
   SymbolRefAttr reductionSymbol;
   for (unsigned i = 0, e = container.getNumReductionVars(); i < e; ++i) {
-    if (container.reduction_vars()[i] != reduction.accumulator())
+    if (container.getReductionVars()[i] != reduction.getAccumulator())
       continue;
-    reductionSymbol = (*container.reductions())[i].cast<SymbolRefAttr>();
+    reductionSymbol = (*container.getReductions())[i].cast<SymbolRefAttr>();
     break;
   }
   assert(reductionSymbol &&
@@ -398,7 +398,7 @@ static omp::ReductionDeclareOp findReductionDecl(omp::WsLoopOp container,
 static void
 collectReductionDecls(omp::WsLoopOp loop,
                       SmallVectorImpl<omp::ReductionDeclareOp> &reductions) {
-  Optional<ArrayAttr> attr = loop.reductions();
+  Optional<ArrayAttr> attr = loop.getReductions();
   if (!attr)
     return;
 
@@ -480,7 +480,7 @@ makeReductionGen(omp::ReductionDeclareOp decl, llvm::IRBuilderBase &builder,
       [&, decl](llvm::OpenMPIRBuilder::InsertPointTy insertPoint,
                 llvm::Value *lhs, llvm::Value *rhs,
                 llvm::Value *&result) mutable {
-        Region &reductionRegion = decl.reductionRegion();
+        Region &reductionRegion = decl.getReductionRegion();
         moduleTranslation.mapValue(reductionRegion.front().getArgument(0), lhs);
         moduleTranslation.mapValue(reductionRegion.front().getArgument(1), rhs);
         builder.restoreIP(insertPoint);
@@ -504,7 +504,7 @@ static OwningAtomicReductionGen
 makeAtomicReductionGen(omp::ReductionDeclareOp decl,
                        llvm::IRBuilderBase &builder,
                        LLVM::ModuleTranslation &moduleTranslation) {
-  if (decl.atomicReductionRegion().empty())
+  if (decl.getAtomicReductionRegion().empty())
     return OwningAtomicReductionGen();
 
   // The lambda is mutable because we need access to non-const methods of decl
@@ -513,7 +513,7 @@ makeAtomicReductionGen(omp::ReductionDeclareOp decl,
   OwningAtomicReductionGen atomicGen =
       [&, decl](llvm::OpenMPIRBuilder::InsertPointTy insertPoint, llvm::Type *,
                 llvm::Value *lhs, llvm::Value *rhs) mutable {
-        Region &atomicRegion = decl.atomicReductionRegion();
+        Region &atomicRegion = decl.getAtomicReductionRegion();
         moduleTranslation.mapValue(atomicRegion.front().getArgument(0), lhs);
         moduleTranslation.mapValue(atomicRegion.front().getArgument(1), rhs);
         builder.restoreIP(insertPoint);
@@ -534,11 +534,11 @@ convertOmpOrdered(Operation &opInst, llvm::IRBuilderBase &builder,
                   LLVM::ModuleTranslation &moduleTranslation) {
   auto orderedOp = cast<omp::OrderedOp>(opInst);
 
-  omp::ClauseDepend dependType = *orderedOp.depend_type_val();
+  omp::ClauseDepend dependType = *orderedOp.getDependTypeVal();
   bool isDependSource = dependType == omp::ClauseDepend::dependsource;
-  unsigned numLoops = *orderedOp.num_loops_val();
+  unsigned numLoops = *orderedOp.getNumLoopsVal();
   SmallVector<llvm::Value *> vecValues =
-      moduleTranslation.lookupValues(orderedOp.depend_vec_vars());
+      moduleTranslation.lookupValues(orderedOp.getDependVecVars());
 
   size_t indexVecValues = 0;
   while (indexVecValues < vecValues.size()) {
@@ -566,7 +566,7 @@ convertOmpOrderedRegion(Operation &opInst, llvm::IRBuilderBase &builder,
   auto orderedRegionOp = cast<omp::OrderedRegionOp>(opInst);
 
   // TODO: The code generation for ordered simd directive is not supported yet.
-  if (orderedRegionOp.simd())
+  if (orderedRegionOp.getSimd())
     return failure();
 
   // TODO: support error propagation in OpenMPIRBuilder and use it instead of
@@ -588,7 +588,7 @@ convertOmpOrderedRegion(Operation &opInst, llvm::IRBuilderBase &builder,
   llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
   builder.restoreIP(
       moduleTranslation.getOpenMPBuilder()->createOrderedThreadsSimd(
-          ompLoc, bodyGenCB, finiCB, !orderedRegionOp.simd()));
+          ompLoc, bodyGenCB, finiCB, !orderedRegionOp.getSimd()));
   return bodyGenStatus;
 }
 
@@ -603,9 +603,9 @@ convertOmpSections(Operation &opInst, llvm::IRBuilderBase &builder,
 
   // TODO: Support the following clauses: private, firstprivate, lastprivate,
   // reduction, allocate
-  if (!sectionsOp.reduction_vars().empty() || sectionsOp.reductions() ||
-      !sectionsOp.allocate_vars().empty() ||
-      !sectionsOp.allocators_vars().empty())
+  if (!sectionsOp.getReductionVars().empty() || sectionsOp.getReductions() ||
+      !sectionsOp.getAllocateVars().empty() ||
+      !sectionsOp.getAllocatorsVars().empty())
     return emitError(sectionsOp.getLoc())
            << "reduction and allocate clauses are not supported for sections "
               "construct";
@@ -613,12 +613,12 @@ convertOmpSections(Operation &opInst, llvm::IRBuilderBase &builder,
   LogicalResult bodyGenStatus = success();
   SmallVector<StorableBodyGenCallbackTy> sectionCBs;
 
-  for (Operation &op : *sectionsOp.region().begin()) {
+  for (Operation &op : *sectionsOp.getRegion().begin()) {
     auto sectionOp = dyn_cast<omp::SectionOp>(op);
     if (!sectionOp) // omp.terminator
       continue;
 
-    Region &region = sectionOp.region();
+    Region &region = sectionOp.getRegion();
     auto sectionCB = [&region, &builder, &moduleTranslation, &bodyGenStatus](
                          InsertPointTy allocaIP, InsertPointTy codeGenIP) {
       builder.restoreIP(codeGenIP);
@@ -634,7 +634,7 @@ convertOmpSections(Operation &opInst, llvm::IRBuilderBase &builder,
   if (sectionCBs.empty())
     return success();
 
-  assert(isa<omp::SectionOp>(*sectionsOp.region().op_begin()));
+  assert(isa<omp::SectionOp>(*sectionsOp.getRegion().op_begin()));
 
   // TODO: Perform appropriate actions according to the data-sharing
   // attribute (shared, private, firstprivate, ...) of variables.
@@ -655,7 +655,7 @@ convertOmpSections(Operation &opInst, llvm::IRBuilderBase &builder,
   llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
   builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createSections(
       ompLoc, allocaIP, sectionCBs, privCB, finiCB, false,
-      sectionsOp.nowait()));
+      sectionsOp.getNowait()));
   return bodyGenStatus;
 }
 
@@ -668,12 +668,12 @@ convertOmpSingle(omp::SingleOp &singleOp, llvm::IRBuilderBase &builder,
   LogicalResult bodyGenStatus = success();
   auto bodyCB = [&](InsertPointTy allocaIP, InsertPointTy codegenIP) {
     builder.restoreIP(codegenIP);
-    convertOmpOpRegions(singleOp.region(), "omp.single.region", builder,
+    convertOmpOpRegions(singleOp.getRegion(), "omp.single.region", builder,
                         moduleTranslation, bodyGenStatus);
   };
   auto finiCB = [&](InsertPointTy codeGenIP) {};
   builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createSingle(
-      ompLoc, bodyCB, finiCB, singleOp.nowait(), /*DidIt=*/nullptr));
+      ompLoc, bodyCB, finiCB, singleOp.getNowait(), /*DidIt=*/nullptr));
   return bodyGenStatus;
 }
 
@@ -683,21 +683,21 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
                  LLVM::ModuleTranslation &moduleTranslation) {
   using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
   LogicalResult bodyGenStatus = success();
-  if (taskOp.if_expr() || taskOp.final_expr() || taskOp.untiedAttr() ||
-      taskOp.mergeableAttr() || taskOp.in_reductions() || taskOp.priority() ||
-      !taskOp.allocate_vars().empty()) {
+  if (taskOp.getIfExpr() || taskOp.getFinalExpr() || taskOp.getUntiedAttr() ||
+      taskOp.getMergeableAttr() || taskOp.getInReductions() ||
+      taskOp.getPriority() || !taskOp.getAllocateVars().empty()) {
     return taskOp.emitError("unhandled clauses for translation to LLVM IR");
   }
   auto bodyCB = [&](InsertPointTy allocaIP, InsertPointTy codegenIP) {
     builder.restoreIP(codegenIP);
-    convertOmpOpRegions(taskOp.region(), "omp.task.region", builder,
+    convertOmpOpRegions(taskOp.getRegion(), "omp.task.region", builder,
                         moduleTranslation, bodyGenStatus);
   };
   llvm::OpenMPIRBuilder::InsertPointTy allocaIP =
       findAllocaInsertPoint(builder, moduleTranslation);
   llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
   builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createTask(
-      ompLoc, allocaIP, bodyCB, !taskOp.untied()));
+      ompLoc, allocaIP, bodyCB, !taskOp.getUntied()));
   return bodyGenStatus;
 }
 
@@ -707,12 +707,12 @@ convertOmpTaskgroupOp(omp::TaskGroupOp tgOp, llvm::IRBuilderBase &builder,
                       LLVM::ModuleTranslation &moduleTranslation) {
   using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
   LogicalResult bodyGenStatus = success();
-  if (!tgOp.task_reduction_vars().empty() || !tgOp.allocate_vars().empty()) {
+  if (!tgOp.getTaskReductionVars().empty() || !tgOp.getAllocateVars().empty()) {
     return tgOp.emitError("unhandled clauses for translation to LLVM IR");
   }
   auto bodyCB = [&](InsertPointTy allocaIP, InsertPointTy codegenIP) {
     builder.restoreIP(codegenIP);
-    convertOmpOpRegions(tgOp.region(), "omp.taskgroup.region", builder,
+    convertOmpOpRegions(tgOp.getRegion(), "omp.taskgroup.region", builder,
                         moduleTranslation, bodyGenStatus);
   };
   InsertPointTy allocaIP = findAllocaInsertPoint(builder, moduleTranslation);
@@ -728,19 +728,20 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
                  LLVM::ModuleTranslation &moduleTranslation) {
   auto loop = cast<omp::WsLoopOp>(opInst);
   // TODO: this should be in the op verifier instead.
-  if (loop.lowerBound().empty())
+  if (loop.getLowerBound().empty())
     return failure();
 
   // Static is the default.
-  auto schedule = loop.schedule_val().value_or(omp::ClauseScheduleKind::Static);
+  auto schedule =
+      loop.getScheduleVal().value_or(omp::ClauseScheduleKind::Static);
 
   // Find the loop configuration.
-  llvm::Value *step = moduleTranslation.lookupValue(loop.step()[0]);
+  llvm::Value *step = moduleTranslation.lookupValue(loop.getStep()[0]);
   llvm::Type *ivType = step->getType();
   llvm::Value *chunk = nullptr;
-  if (loop.schedule_chunk_var()) {
+  if (loop.getScheduleChunkVar()) {
     llvm::Value *chunkVar =
-        moduleTranslation.lookupValue(loop.schedule_chunk_var());
+        moduleTranslation.lookupValue(loop.getScheduleChunkVar());
     chunk = builder.CreateSExtOrTrunc(chunkVar, ivType);
   }
 
@@ -759,11 +760,11 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
     builder.restoreIP(allocaIP);
     for (unsigned i = 0; i < numReductions; ++i) {
       auto reductionType =
-          loop.reduction_vars()[i].getType().cast<LLVM::LLVMPointerType>();
+          loop.getReductionVars()[i].getType().cast<LLVM::LLVMPointerType>();
       llvm::Value *var = builder.CreateAlloca(
           moduleTranslation.convertType(reductionType.getElementType()));
       privateReductionVariables.push_back(var);
-      reductionVariableMap.try_emplace(loop.reduction_vars()[i], var);
+      reductionVariableMap.try_emplace(loop.getReductionVars()[i], var);
     }
   }
 
@@ -778,7 +779,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
   // up with the alloca insertion point.
   for (unsigned i = 0; i < numReductions; ++i) {
     SmallVector<llvm::Value *> phis;
-    if (failed(inlineConvertOmpRegions(reductionDecls[i].initializerRegion(),
+    if (failed(inlineConvertOmpRegions(reductionDecls[i].getInitializerRegion(),
                                        "omp.reduction.neutral", builder,
                                        moduleTranslation, &phis)))
       return failure();
@@ -811,7 +812,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
 
     // Convert the body of the loop.
     builder.restoreIP(ip);
-    convertOmpOpRegions(loop.region(), "omp.wsloop.region", builder,
+    convertOmpOpRegions(loop.getRegion(), "omp.wsloop.region", builder,
                         moduleTranslation, bodyGenStatus);
   };
 
@@ -822,10 +823,10 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
   llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
   for (unsigned i = 0, e = loop.getNumLoops(); i < e; ++i) {
     llvm::Value *lowerBound =
-        moduleTranslation.lookupValue(loop.lowerBound()[i]);
+        moduleTranslation.lookupValue(loop.getLowerBound()[i]);
     llvm::Value *upperBound =
-        moduleTranslation.lookupValue(loop.upperBound()[i]);
-    llvm::Value *step = moduleTranslation.lookupValue(loop.step()[i]);
+        moduleTranslation.lookupValue(loop.getUpperBound()[i]);
+    llvm::Value *step = moduleTranslation.lookupValue(loop.getStep()[i]);
 
     // Make sure loop trip count are emitted in the preheader of the outermost
     // loop at the latest so that they are all available for the new collapsed
@@ -838,7 +839,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
     }
     loopInfos.push_back(ompBuilder->createCanonicalLoop(
         loc, bodyGen, lowerBound, upperBound, step,
-        /*IsSigned=*/true, loop.inclusive(), computeIP));
+        /*IsSigned=*/true, loop.getInclusive(), computeIP));
 
     if (failed(bodyGenStatus))
       return failure();
@@ -853,12 +854,12 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
   allocaIP = findAllocaInsertPoint(builder, moduleTranslation);
 
   // TODO: Handle doacross loops when the ordered clause has a parameter.
-  bool isOrdered = loop.ordered_val().has_value();
-  Optional<omp::ScheduleModifier> scheduleModifier = loop.schedule_modifier();
-  bool isSimd = loop.simd_modifier();
+  bool isOrdered = loop.getOrderedVal().has_value();
+  Optional<omp::ScheduleModifier> scheduleModifier = loop.getScheduleModifier();
+  bool isSimd = loop.getSimdModifier();
 
   ompBuilder->applyWorkshareLoop(
-      ompLoc.DL, loopInfo, allocaIP, !loop.nowait(),
+      ompLoc.DL, loopInfo, allocaIP, !loop.getNowait(),
       convertToScheduleKind(schedule), chunk, isSimd,
       scheduleModifier == omp::ScheduleModifier::monotonic,
       scheduleModifier == omp::ScheduleModifier::nonmonotonic, isOrdered);
@@ -892,9 +893,9 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
     if (owningAtomicReductionGens[i])
       atomicGen = owningAtomicReductionGens[i];
     auto reductionType =
-        loop.reduction_vars()[i].getType().cast<LLVM::LLVMPointerType>();
+        loop.getReductionVars()[i].getType().cast<LLVM::LLVMPointerType>();
     llvm::Value *variable =
-        moduleTranslation.lookupValue(loop.reduction_vars()[i]);
+        moduleTranslation.lookupValue(loop.getReductionVars()[i]);
     reductionInfos.push_back(
         {moduleTranslation.convertType(reductionType.getElementType()),
          variable, privateReductionVariables[i], owningReductionGens[i],
@@ -908,7 +909,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
   builder.SetInsertPoint(tempTerminator);
   llvm::OpenMPIRBuilder::InsertPointTy contInsertPoint =
       ompBuilder->createReductions(builder.saveIP(), allocaIP, reductionInfos,
-                                   loop.nowait());
+                                   loop.getNowait());
   if (!contInsertPoint.getBlock())
     return loop->emitOpError() << "failed to convert reductions";
   auto nextInsertionPoint =
@@ -948,7 +949,7 @@ convertOmpSimdLoop(Operation &opInst, llvm::IRBuilderBase &builder,
 
     // Convert the body of the loop.
     builder.restoreIP(ip);
-    convertOmpOpRegions(loop.region(), "omp.simdloop.region", builder,
+    convertOmpOpRegions(loop.getRegion(), "omp.simdloop.region", builder,
                         moduleTranslation, bodyGenStatus);
   };
 
@@ -959,10 +960,10 @@ convertOmpSimdLoop(Operation &opInst, llvm::IRBuilderBase &builder,
   llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
   for (unsigned i = 0, e = loop.getNumLoops(); i < e; ++i) {
     llvm::Value *lowerBound =
-        moduleTranslation.lookupValue(loop.lowerBound()[i]);
+        moduleTranslation.lookupValue(loop.getLowerBound()[i]);
     llvm::Value *upperBound =
-        moduleTranslation.lookupValue(loop.upperBound()[i]);
-    llvm::Value *step = moduleTranslation.lookupValue(loop.step()[i]);
+        moduleTranslation.lookupValue(loop.getUpperBound()[i]);
+    llvm::Value *step = moduleTranslation.lookupValue(loop.getStep()[i]);
 
     // Make sure loop trip count are emitted in the preheader of the outermost
     // loop at the latest so that they are all available for the new collapsed
@@ -988,17 +989,18 @@ convertOmpSimdLoop(Operation &opInst, llvm::IRBuilderBase &builder,
       ompBuilder->collapseLoops(ompLoc.DL, loopInfos, {});
 
   llvm::ConstantInt *simdlen = nullptr;
-  if (llvm::Optional<uint64_t> simdlenVar = loop.simdlen())
+  if (llvm::Optional<uint64_t> simdlenVar = loop.getSimdlen())
     simdlen = builder.getInt64(simdlenVar.value());
 
   llvm::ConstantInt *safelen = nullptr;
-  if (llvm::Optional<uint64_t> safelenVar = loop.safelen())
+  if (llvm::Optional<uint64_t> safelenVar = loop.getSafelen())
     safelen = builder.getInt64(safelenVar.value());
 
-  ompBuilder->applySimd(
-      loopInfo,
-      loop.if_expr() ? moduleTranslation.lookupValue(loop.if_expr()) : nullptr,
-      simdlen, safelen);
+  ompBuilder->applySimd(loopInfo,
+                        loop.getIfExpr()
+                            ? moduleTranslation.lookupValue(loop.getIfExpr())
+                            : nullptr,
+                        simdlen, safelen);
 
   builder.restoreIP(afterIP);
   return success();
@@ -1035,11 +1037,13 @@ convertOmpAtomicRead(Operation &opInst, llvm::IRBuilderBase &builder,
 
   llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
 
-  llvm::AtomicOrdering AO = convertAtomicOrdering(readOp.memory_order_val());
-  llvm::Value *x = moduleTranslation.lookupValue(readOp.x());
-  Type xTy = readOp.x().getType().cast<omp::PointerLikeType>().getElementType();
-  llvm::Value *v = moduleTranslation.lookupValue(readOp.v());
-  Type vTy = readOp.v().getType().cast<omp::PointerLikeType>().getElementType();
+  llvm::AtomicOrdering AO = convertAtomicOrdering(readOp.getMemoryOrderVal());
+  llvm::Value *x = moduleTranslation.lookupValue(readOp.getX());
+  Type xTy =
+      readOp.getX().getType().cast<omp::PointerLikeType>().getElementType();
+  llvm::Value *v = moduleTranslation.lookupValue(readOp.getV());
+  Type vTy =
+      readOp.getV().getType().cast<omp::PointerLikeType>().getElementType();
   llvm::OpenMPIRBuilder::AtomicOpValue V = {
       v, moduleTranslation.convertType(vTy), false, false};
   llvm::OpenMPIRBuilder::AtomicOpValue X = {
@@ -1056,10 +1060,10 @@ convertOmpAtomicWrite(Operation &opInst, llvm::IRBuilderBase &builder,
   llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
 
   llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
-  llvm::AtomicOrdering ao = convertAtomicOrdering(writeOp.memory_order_val());
-  llvm::Value *expr = moduleTranslation.lookupValue(writeOp.value());
-  llvm::Value *dest = moduleTranslation.lookupValue(writeOp.address());
-  llvm::Type *ty = moduleTranslation.convertType(writeOp.value().getType());
+  llvm::AtomicOrdering ao = convertAtomicOrdering(writeOp.getMemoryOrderVal());
+  llvm::Value *expr = moduleTranslation.lookupValue(writeOp.getValue());
+  llvm::Value *dest = moduleTranslation.lookupValue(writeOp.getAddress());
+  llvm::Type *ty = moduleTranslation.convertType(writeOp.getValue().getType());
   llvm::OpenMPIRBuilder::AtomicOpValue x = {dest, ty, /*isSigned=*/false,
                                             /*isVolatile=*/false};
   builder.restoreIP(ompBuilder->createAtomicWrite(ompLoc, x, expr, ao));
@@ -1090,7 +1094,7 @@ convertOmpAtomicUpdate(omp::AtomicUpdateOp &opInst,
   llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
 
   // Convert values and types.
-  auto &innerOpList = opInst.region().front().getOperations();
+  auto &innerOpList = opInst.getRegion().front().getOperations();
   if (innerOpList.size() != 2)
     return opInst.emitError("exactly two operations are allowed inside an "
                             "atomic update region while lowering to LLVM IR");
@@ -1113,9 +1117,9 @@ convertOmpAtomicUpdate(omp::AtomicUpdateOp &opInst,
   mlir::Value mlirExpr = (isXBinopExpr ? innerUpdateOp.getOperand(1)
                                        : innerUpdateOp.getOperand(0));
   llvm::Value *llvmExpr = moduleTranslation.lookupValue(mlirExpr);
-  llvm::Value *llvmX = moduleTranslation.lookupValue(opInst.x());
+  llvm::Value *llvmX = moduleTranslation.lookupValue(opInst.getX());
   LLVM::LLVMPointerType mlirXType =
-      opInst.x().getType().cast<LLVM::LLVMPointerType>();
+      opInst.getX().getType().cast<LLVM::LLVMPointerType>();
   llvm::Type *llvmXElementType =
       moduleTranslation.convertType(mlirXType.getElementType());
   llvm::OpenMPIRBuilder::AtomicOpValue llvmAtomicX = {llvmX, llvmXElementType,
@@ -1123,15 +1127,15 @@ convertOmpAtomicUpdate(omp::AtomicUpdateOp &opInst,
                                                       /*isVolatile=*/false};
 
   llvm::AtomicOrdering atomicOrdering =
-      convertAtomicOrdering(opInst.memory_order_val());
+      convertAtomicOrdering(opInst.getMemoryOrderVal());
 
   // Generate update code.
   LogicalResult updateGenStatus = success();
   auto updateFn = [&opInst, &moduleTranslation, &updateGenStatus](
                       llvm::Value *atomicx,
                       llvm::IRBuilder<> &builder) -> llvm::Value * {
-    Block &bb = *opInst.region().begin();
-    moduleTranslation.mapValue(*opInst.region().args_begin(), atomicx);
+    Block &bb = *opInst.getRegion().begin();
+    moduleTranslation.mapValue(*opInst.getRegion().args_begin(), atomicx);
     moduleTranslation.mapBlock(&bb, builder.GetInsertBlock());
     if (failed(moduleTranslation.convertBlock(bb, true, builder))) {
       updateGenStatus = (opInst.emitError()
@@ -1139,10 +1143,10 @@ convertOmpAtomicUpdate(omp::AtomicUpdateOp &opInst,
       return nullptr;
     }
     omp::YieldOp yieldop = dyn_cast<omp::YieldOp>(bb.getTerminator());
-    assert(yieldop && yieldop.results().size() == 1 &&
+    assert(yieldop && yieldop.getResults().size() == 1 &&
            "terminator must be omp.yield op and it must have exactly one "
            "argument");
-    return moduleTranslation.lookupValue(yieldop.results()[0]);
+    return moduleTranslation.lookupValue(yieldop.getResults()[0]);
   };
 
   // Handle ambiguous alloca, if any.
@@ -1171,11 +1175,11 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
 
   if (atomicWriteOp) {
     isPostfixUpdate = true;
-    mlirExpr = atomicWriteOp.value();
+    mlirExpr = atomicWriteOp.getValue();
   } else {
     isPostfixUpdate = atomicCaptureOp.getSecondOp() ==
                       atomicCaptureOp.getAtomicUpdateOp().getOperation();
-    auto &innerOpList = atomicUpdateOp.region().front().getOperations();
+    auto &innerOpList = atomicUpdateOp.getRegion().front().getOperations();
     if (innerOpList.size() != 2)
       return atomicUpdateOp.emitError(
           "exactly two operations are allowed inside an "
@@ -1199,11 +1203,11 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
 
   llvm::Value *llvmExpr = moduleTranslation.lookupValue(mlirExpr);
   llvm::Value *llvmX =
-      moduleTranslation.lookupValue(atomicCaptureOp.getAtomicReadOp().x());
+      moduleTranslation.lookupValue(atomicCaptureOp.getAtomicReadOp().getX());
   llvm::Value *llvmV =
-      moduleTranslation.lookupValue(atomicCaptureOp.getAtomicReadOp().v());
+      moduleTranslation.lookupValue(atomicCaptureOp.getAtomicReadOp().getV());
   auto mlirXType = atomicCaptureOp.getAtomicReadOp()
-                       .x()
+                       .getX()
                        .getType()
                        .cast<LLVM::LLVMPointerType>();
   llvm::Type *llvmXElementType =
@@ -1216,15 +1220,16 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
                                                       /*isVolatile=*/false};
 
   llvm::AtomicOrdering atomicOrdering =
-      convertAtomicOrdering(atomicCaptureOp.memory_order_val());
+      convertAtomicOrdering(atomicCaptureOp.getMemoryOrderVal());
 
   LogicalResult updateGenStatus = success();
   auto updateFn = [&](llvm::Value *atomicx,
                       llvm::IRBuilder<> &builder) -> llvm::Value * {
     if (atomicWriteOp)
-      return moduleTranslation.lookupValue(atomicWriteOp.value());
-    Block &bb = *atomicUpdateOp.region().begin();
-    moduleTranslation.mapValue(*atomicUpdateOp.region().args_begin(), atomicx);
+      return moduleTranslation.lookupValue(atomicWriteOp.getValue());
+    Block &bb = *atomicUpdateOp.getRegion().begin();
+    moduleTranslation.mapValue(*atomicUpdateOp.getRegion().args_begin(),
+                               atomicx);
     moduleTranslation.mapBlock(&bb, builder.GetInsertBlock());
     if (failed(moduleTranslation.convertBlock(bb, true, builder))) {
       updateGenStatus = (atomicUpdateOp.emitError()
@@ -1232,10 +1237,10 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
       return nullptr;
     }
     omp::YieldOp yieldop = dyn_cast<omp::YieldOp>(bb.getTerminator());
-    assert(yieldop && yieldop.results().size() == 1 &&
+    assert(yieldop && yieldop.getResults().size() == 1 &&
            "terminator must be omp.yield op and it must have exactly one "
            "argument");
-    return moduleTranslation.lookupValue(yieldop.results()[0]);
+    return moduleTranslation.lookupValue(yieldop.getResults()[0]);
   };
 
   // Handle ambiguous alloca, if any.
@@ -1273,18 +1278,18 @@ convertOmpReductionOp(omp::ReductionOp reductionOp,
 
   // Translate the reduction operation by emitting the body of the corresponding
   // reduction declaration.
-  Region &reductionRegion = declaration.reductionRegion();
+  Region &reductionRegion = declaration.getReductionRegion();
   llvm::Value *privateReductionVar =
-      reductionVariableMap->lookup(reductionOp.accumulator());
+      reductionVariableMap->lookup(reductionOp.getAccumulator());
   llvm::Value *reductionVal = builder.CreateLoad(
-      moduleTranslation.convertType(reductionOp.operand().getType()),
+      moduleTranslation.convertType(reductionOp.getOperand().getType()),
       privateReductionVar);
 
   moduleTranslation.mapValue(reductionRegion.front().getArgument(0),
                              reductionVal);
   moduleTranslation.mapValue(
       reductionRegion.front().getArgument(1),
-      moduleTranslation.lookupValue(reductionOp.operand()));
+      moduleTranslation.lookupValue(reductionOp.getOperand()));
 
   SmallVector<llvm::Value *> phis;
   if (failed(inlineConvertOmpRegions(reductionRegion, "omp.reduction.body",
@@ -1304,7 +1309,7 @@ convertOmpThreadprivate(Operation &opInst, llvm::IRBuilderBase &builder,
   llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
   auto threadprivateOp = cast<omp::ThreadprivateOp>(opInst);
 
-  Value symAddr = threadprivateOp.sym_addr();
+  Value symAddr = threadprivateOp.getSymAddr();
   auto *symOp = symAddr.getDefiningOp();
   if (!isa<LLVM::AddressOfOp>(symOp))
     return opInst.emitError("Addressing symbol not found");


        


More information about the Mlir-commits mailing list