diff options
Diffstat (limited to 'flang/lib/Lower/OpenMP/Atomic.cpp')
-rw-r--r-- | flang/lib/Lower/OpenMP/Atomic.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/flang/lib/Lower/OpenMP/Atomic.cpp b/flang/lib/Lower/OpenMP/Atomic.cpp index 6ea331c..c9a6dba 100644 --- a/flang/lib/Lower/OpenMP/Atomic.cpp +++ b/flang/lib/Lower/OpenMP/Atomic.cpp @@ -528,8 +528,8 @@ genAtomicRead(lower::AbstractConverter &converter, }(); builder.restoreInsertionPoint(atomicAt); - mlir::Operation *op = builder.create<mlir::omp::AtomicReadOp>( - loc, atomAddr, toAddr, mlir::TypeAttr::get(atomType), hint, + mlir::Operation *op = mlir::omp::AtomicReadOp::create( + builder, loc, atomAddr, toAddr, mlir::TypeAttr::get(atomType), hint, makeMemOrderAttr(converter, memOrder)); if (atomType != storeType) { @@ -537,7 +537,7 @@ genAtomicRead(lower::AbstractConverter &converter, // The READ operation could be a part of UPDATE CAPTURE, so make sure // we don't emit extra code into the body of the atomic op. builder.restoreInsertionPoint(postAt); - mlir::Value load = builder.create<fir::LoadOp>(loc, toAddr); + mlir::Value load = fir::LoadOp::create(builder, loc, toAddr); overrides.try_emplace(&atom, load); converter.overrideExprValues(&overrides); @@ -545,7 +545,7 @@ genAtomicRead(lower::AbstractConverter &converter, fir::getBase(converter.genExprValue(assign.rhs, stmtCtx, &loc)); converter.resetExprOverrides(); - builder.create<fir::StoreOp>(loc, value, storeAddr); + fir::StoreOp::create(builder, loc, value, storeAddr); } return op; } @@ -581,8 +581,9 @@ genAtomicWrite(lower::AbstractConverter &converter, mlir::Value converted = builder.createConvert(loc, atomType, value); builder.restoreInsertionPoint(atomicAt); - mlir::Operation *op = builder.create<mlir::omp::AtomicWriteOp>( - loc, atomAddr, converted, hint, makeMemOrderAttr(converter, memOrder)); + mlir::Operation *op = + mlir::omp::AtomicWriteOp::create(builder, loc, atomAddr, converted, hint, + makeMemOrderAttr(converter, memOrder)); return op; } @@ -606,7 +607,7 @@ genAtomicUpdate(lower::AbstractConverter &converter, // This must exist by now. semantics::SomeExpr rhs = assign.rhs; semantics::SomeExpr input = *evaluate::GetConvertInput(rhs); - auto [opcode, args] = evaluate::GetTopLevelOperation(input); + auto [opcode, args] = evaluate::GetTopLevelOperationIgnoreResizing(input); assert(!args.empty() && "Update operation without arguments"); // Pass args as an argument to avoid capturing a structured binding. @@ -624,7 +625,8 @@ genAtomicUpdate(lower::AbstractConverter &converter, // operations with exactly two (non-optional) arguments. rhs = genReducedMinMax(rhs, atomArg, args); input = *evaluate::GetConvertInput(rhs); - std::tie(opcode, args) = evaluate::GetTopLevelOperation(input); + std::tie(opcode, args) = + evaluate::GetTopLevelOperationIgnoreResizing(input); atomArg = nullptr; // No longer valid. } for (auto &arg : args) { @@ -634,9 +636,16 @@ genAtomicUpdate(lower::AbstractConverter &converter, } } + mlir::ModuleOp module = builder.getModule(); + mlir::omp::AtomicControlAttr atomicControlAttr = + mlir::omp::AtomicControlAttr::get( + builder.getContext(), fir::getAtomicIgnoreDenormalMode(module), + fir::getAtomicFineGrainedMemory(module), + fir::getAtomicRemoteMemory(module)); builder.restoreInsertionPoint(atomicAt); - auto updateOp = builder.create<mlir::omp::AtomicUpdateOp>( - loc, atomAddr, hint, makeMemOrderAttr(converter, memOrder)); + auto updateOp = mlir::omp::AtomicUpdateOp::create( + builder, loc, atomAddr, atomicControlAttr, hint, + makeMemOrderAttr(converter, memOrder)); mlir::Region ®ion = updateOp->getRegion(0); mlir::Block *block = builder.createBlock(®ion, {}, {atomType}, {loc}); @@ -647,7 +656,7 @@ genAtomicUpdate(lower::AbstractConverter &converter, mlir::Value updated = fir::getBase(converter.genExprValue(rhs, stmtCtx, &loc)); mlir::Value converted = builder.createConvert(loc, atomType, updated); - builder.create<mlir::omp::YieldOp>(loc, converted); + mlir::omp::YieldOp::create(builder, loc, converted); converter.resetExprOverrides(); builder.restoreInsertionPoint(postAt); // For naCtx cleanups @@ -731,8 +740,8 @@ void Fortran::lower::omp::lowerAtomic( "Expexcing two actions"); (void)action0; (void)action1; - captureOp = builder.create<mlir::omp::AtomicCaptureOp>( - loc, hint, makeMemOrderAttr(converter, memOrder)); + captureOp = mlir::omp::AtomicCaptureOp::create( + builder, loc, hint, makeMemOrderAttr(converter, memOrder)); // Set the non-atomic insertion point to before the atomic.capture. preAt = getInsertionPointBefore(captureOp); @@ -740,7 +749,7 @@ void Fortran::lower::omp::lowerAtomic( builder.setInsertionPointToEnd(block); // Set the atomic insertion point to before the terminator inside // atomic.capture. - mlir::Operation *term = builder.create<mlir::omp::TerminatorOp>(loc); + mlir::Operation *term = mlir::omp::TerminatorOp::create(builder, loc); atomicAt = getInsertionPointBefore(term); postAt = getInsertionPointAfter(captureOp); hint = nullptr; |