[flang-commits] [flang] [mlir] [flang][OpenMP] Support for "atomic compare capture" (PR #202315)
via flang-commits
flang-commits at lists.llvm.org
Tue Jun 9 00:04:34 PDT 2026
================
@@ -4815,13 +4852,150 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
if (failed(checkImplementationStatus(*atomicCaptureOp)))
return failure();
+ omp::AtomicUpdateOp atomicUpdateOp = atomicCaptureOp.getAtomicUpdateOp();
+ omp::AtomicWriteOp atomicWriteOp = atomicCaptureOp.getAtomicWriteOp();
+ omp::AtomicCompareOp atomicCompareOp = atomicCaptureOp.getAtomicCompareOp();
+
+ // If the capture contains an atomic.compare, delegate to
+ // createAtomicCompare with the capture variable (V) set.
+ if (atomicCompareOp) {
+ omp::AtomicReadOp atomicReadOp = atomicCaptureOp.getAtomicReadOp();
+ assert(atomicReadOp && "expected atomic.read in capture+compare");
+
+ Region ®ion = atomicCompareOp.getRegion();
+ Block &block = region.front();
+
+ llvm::Type *llvmXElementType =
+ moduleTranslation.convertType(block.getArgument(0).getType());
+ llvm::Value *llvmX = moduleTranslation.lookupValue(atomicCompareOp.getX());
+ llvm::Value *llvmV = moduleTranslation.lookupValue(atomicReadOp.getV());
----------------
SunilKuravinakop wrote:
moduleTranslation.convertType() returns
1) typeTranslator.translateType(type) at line 2402 in file mlir/lib/Target/LLVMIR/ModuleTranslation.cpp.
2) TypeToLLVMIRTranslatorImpl::translateType() at line 31 in file mlir/lib/Target/LLVMIR/TypeToLLVM.cpp never returns NULL.. If the type is not on
Because of this, there is no need to check for NULL. Justify why a check is needed here.
https://github.com/llvm/llvm-project/pull/202315
More information about the flang-commits
mailing list