MLIR  16.0.0git
Functions
OpenMPToLLVMIRTranslation.cpp File Reference
#include "mlir/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/IR/BlockAndValueMapping.h"
#include "mlir/IR/Operation.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Target/LLVMIR/ModuleTranslation.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/IRBuilder.h"
+ Include dependency graph for OpenMPToLLVMIRTranslation.cpp:

Go to the source code of this file.

Functions

static llvm::OpenMPIRBuilder::InsertPointTy findAllocaInsertPoint (llvm::IRBuilderBase &builder, const LLVM::ModuleTranslation &moduleTranslation)
 Find the insertion point for allocas given the current insertion point for normal operations in the builder. More...
 
static llvm::BasicBlock * convertOmpOpRegions (Region &region, StringRef blockName, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation, LogicalResult &bodyGenStatus, SmallVectorImpl< llvm::PHINode *> *continuationBlockPHIs=nullptr)
 Converts the given region that appears within an OpenMP dialect operation to LLVM IR, creating a branch from the sourceBlock to the entry block of the region, and a branch from any block with an successor-less OpenMP terminator to continuationBlock. More...
 
static llvm::omp::ProcBindKind getProcBindKind (omp::ClauseProcBindKind kind)
 Convert ProcBindKind from MLIR-generated enum to LLVM enum. More...
 
static LogicalResult convertOmpParallel (omp::ParallelOp opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts the OpenMP parallel operation to LLVM IR. More...
 
static LogicalResult convertOmpMaster (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP 'master' operation into LLVM IR using OpenMPIRBuilder. More...
 
static LogicalResult convertOmpCritical (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP 'critical' operation into LLVM IR using OpenMPIRBuilder. More...
 
static omp::ReductionDeclareOp findReductionDecl (omp::WsLoopOp container, omp::ReductionOp reduction)
 Returns a reduction declaration that corresponds to the given reduction operation in the given container. More...
 
static void collectReductionDecls (omp::WsLoopOp loop, SmallVectorImpl< omp::ReductionDeclareOp > &reductions)
 Populates reductions with reduction declarations used in the given loop. More...
 
static LogicalResult inlineConvertOmpRegions (Region &region, StringRef blockName, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation, SmallVectorImpl< llvm::Value *> *continuationBlockArgs=nullptr)
 Translates the blocks contained in the given region and appends them to at the current insertion point of builder. More...
 
static OwningReductionGen makeReductionGen (omp::ReductionDeclareOp decl, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Create an OpenMPIRBuilder-compatible reduction generator for the given reduction declaration. More...
 
static OwningAtomicReductionGen makeAtomicReductionGen (omp::ReductionDeclareOp decl, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Create an OpenMPIRBuilder-compatible atomic reduction generator for the given reduction declaration. More...
 
static LogicalResult convertOmpOrdered (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP 'ordered' operation into LLVM IR using OpenMPIRBuilder. More...
 
static LogicalResult convertOmpOrderedRegion (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP 'ordered_region' operation into LLVM IR using OpenMPIRBuilder. More...
 
static LogicalResult convertOmpSections (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 
static LogicalResult convertOmpSingle (omp::SingleOp &singleOp, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP single construct into LLVM IR using OpenMPIRBuilder. More...
 
static LogicalResult convertOmpTaskOp (omp::TaskOp taskOp, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP task construct into LLVM IR using OpenMPIRBuilder. More...
 
static LogicalResult convertOmpWsLoop (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP workshare loop into LLVM IR using OpenMPIRBuilder. More...
 
static LogicalResult convertOmpSimdLoop (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP simd loop into LLVM IR using OpenMPIRBuilder. More...
 
llvm::AtomicOrdering convertAtomicOrdering (Optional< omp::ClauseMemoryOrderKind > ao)
 Convert an Atomic Ordering attribute to llvm::AtomicOrdering. More...
 
static LogicalResult convertOmpAtomicRead (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Convert omp.atomic.read operation to LLVM IR. More...
 
static LogicalResult convertOmpAtomicWrite (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an omp.atomic.write operation to LLVM IR. More...
 
llvm::AtomicRMWInst::BinOp convertBinOpToAtomic (Operation &op)
 Converts an LLVM dialect binary operation to the corresponding enum value for atomicrmw supported binary operation. More...
 
static LogicalResult convertOmpAtomicUpdate (omp::AtomicUpdateOp &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP atomic update operation using OpenMPIRBuilder. More...
 
static LogicalResult convertOmpAtomicCapture (omp::AtomicCaptureOp atomicCaptureOp, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 
static LogicalResult convertOmpReductionOp (omp::ReductionOp reductionOp, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP reduction operation using OpenMPIRBuilder. More...
 
static LogicalResult convertOmpThreadprivate (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP Threadprivate operation into LLVM IR using OpenMPIRBuilder. More...
 

Function Documentation

◆ collectReductionDecls()

static void collectReductionDecls ( omp::WsLoopOp  loop,
SmallVectorImpl< omp::ReductionDeclareOp > &  reductions 
)
static

Populates reductions with reduction declarations used in the given loop.

Definition at line 399 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpWsLoop().

◆ convertAtomicOrdering()

llvm::AtomicOrdering convertAtomicOrdering ( Optional< omp::ClauseMemoryOrderKind >  ao)

Convert an Atomic Ordering attribute to llvm::AtomicOrdering.

Definition at line 984 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpAtomicCapture(), convertOmpAtomicRead(), convertOmpAtomicUpdate(), and convertOmpAtomicWrite().

◆ convertBinOpToAtomic()

llvm::AtomicRMWInst::BinOp convertBinOpToAtomic ( Operation op)

Converts an LLVM dialect binary operation to the corresponding enum value for atomicrmw supported binary operation.

Definition at line 1046 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpAtomicCapture(), and convertOmpAtomicUpdate().

◆ convertOmpAtomicCapture()

static LogicalResult convertOmpAtomicCapture ( omp::AtomicCaptureOp  atomicCaptureOp,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ convertOmpAtomicRead()

static LogicalResult convertOmpAtomicRead ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ convertOmpAtomicUpdate()

static LogicalResult convertOmpAtomicUpdate ( omp::AtomicUpdateOp &  opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ convertOmpAtomicWrite()

static LogicalResult convertOmpAtomicWrite ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ convertOmpCritical()

static LogicalResult convertOmpCritical ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Converts an OpenMP 'critical' operation into LLVM IR using OpenMPIRBuilder.

Definition at line 337 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::Constant, convertOmpOpRegions(), mlir::LLVM::ModuleTranslation::getLLVMContext(), mlir::LLVM::ModuleTranslation::getOpenMPBuilder(), and mlir::success().

Referenced by convertOmpThreadprivate().

◆ convertOmpMaster()

static LogicalResult convertOmpMaster ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Converts an OpenMP 'master' operation into LLVM IR using OpenMPIRBuilder.

Definition at line 310 of file OpenMPToLLVMIRTranslation.cpp.

References convertOmpOpRegions(), mlir::LLVM::ModuleTranslation::getOpenMPBuilder(), and mlir::success().

Referenced by convertOmpThreadprivate().

◆ convertOmpOpRegions()

static llvm::BasicBlock* convertOmpOpRegions ( Region region,
StringRef  blockName,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation,
LogicalResult bodyGenStatus,
SmallVectorImpl< llvm::PHINode *> *  continuationBlockPHIs = nullptr 
)
static

◆ convertOmpOrdered()

static LogicalResult convertOmpOrdered ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Converts an OpenMP 'ordered' operation into LLVM IR using OpenMPIRBuilder.

Definition at line 533 of file OpenMPToLLVMIRTranslation.cpp.

References findAllocaInsertPoint(), mlir::LLVM::ModuleTranslation::getOpenMPBuilder(), mlir::LLVM::ModuleTranslation::lookupValues(), and mlir::success().

Referenced by convertOmpThreadprivate().

◆ convertOmpOrderedRegion()

static LogicalResult convertOmpOrderedRegion ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Converts an OpenMP 'ordered_region' operation into LLVM IR using OpenMPIRBuilder.

Definition at line 563 of file OpenMPToLLVMIRTranslation.cpp.

References convertOmpOpRegions(), mlir::failure(), mlir::LLVM::ModuleTranslation::getOpenMPBuilder(), and mlir::success().

Referenced by convertOmpThreadprivate().

◆ convertOmpParallel()

static LogicalResult convertOmpParallel ( omp::ParallelOp  opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ convertOmpReductionOp()

static LogicalResult convertOmpReductionOp ( omp::ReductionOp  reductionOp,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Converts an OpenMP reduction operation using OpenMPIRBuilder.

Expects the mapping between reduction variables and their private equivalents to have been stored on the ModuleTranslation stack. Currently only supports reduction within WsLoopOp, but can be easily extended.

Definition at line 1230 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::LLVM::ModuleTranslation::convertType(), mlir::failed(), mlir::failure(), findReductionDecl(), mlir::Region::front(), mlir::Block::getArgument(), inlineConvertOmpRegions(), mlir::WalkResult::interrupt(), mlir::LLVM::ModuleTranslation::lookupValue(), mlir::LLVM::ModuleTranslation::mapValue(), mlir::LLVM::ModuleTranslation::stackWalk(), and mlir::success().

Referenced by convertOmpThreadprivate().

◆ convertOmpSections()

static LogicalResult convertOmpSections ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ convertOmpSimdLoop()

static LogicalResult convertOmpSimdLoop ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ convertOmpSingle()

static LogicalResult convertOmpSingle ( omp::SingleOp &  singleOp,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Converts an OpenMP single construct into LLVM IR using OpenMPIRBuilder.

Definition at line 664 of file OpenMPToLLVMIRTranslation.cpp.

References convertOmpOpRegions(), mlir::LLVM::ModuleTranslation::getOpenMPBuilder(), and mlir::success().

Referenced by convertOmpThreadprivate().

◆ convertOmpTaskOp()

static LogicalResult convertOmpTaskOp ( omp::TaskOp  taskOp,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Converts an OpenMP task construct into LLVM IR using OpenMPIRBuilder.

Definition at line 682 of file OpenMPToLLVMIRTranslation.cpp.

References convertOmpOpRegions(), findAllocaInsertPoint(), mlir::LLVM::ModuleTranslation::getOpenMPBuilder(), and mlir::success().

Referenced by convertOmpThreadprivate().

◆ convertOmpThreadprivate()

static LogicalResult convertOmpThreadprivate ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ convertOmpWsLoop()

static LogicalResult convertOmpWsLoop ( Operation opInst,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ findAllocaInsertPoint()

static llvm::OpenMPIRBuilder::InsertPointTy findAllocaInsertPoint ( llvm::IRBuilderBase &  builder,
const LLVM::ModuleTranslation moduleTranslation 
)
static

Find the insertion point for allocas given the current insertion point for normal operations in the builder.

Definition at line 79 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::WalkResult::interrupt(), mlir::LLVM::ModuleTranslation::stackWalk(), and mlir::WalkResult::wasInterrupted().

Referenced by convertOmpAtomicCapture(), convertOmpAtomicUpdate(), convertOmpOrdered(), convertOmpParallel(), convertOmpSections(), convertOmpTaskOp(), and convertOmpWsLoop().

◆ findReductionDecl()

static omp::ReductionDeclareOp findReductionDecl ( omp::WsLoopOp  container,
omp::ReductionOp  reduction 
)
static

Returns a reduction declaration that corresponds to the given reduction operation in the given container.

Currently only supports reductions inside WsLoopOp but can be easily extended.

Definition at line 381 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpReductionOp().

◆ getProcBindKind()

static llvm::omp::ProcBindKind getProcBindKind ( omp::ClauseProcBindKind  kind)
static

Convert ProcBindKind from MLIR-generated enum to LLVM enum.

Definition at line 236 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpParallel().

◆ inlineConvertOmpRegions()

static LogicalResult inlineConvertOmpRegions ( Region region,
StringRef  blockName,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation,
SmallVectorImpl< llvm::Value *> *  continuationBlockArgs = nullptr 
)
static

Translates the blocks contained in the given region and appends them to at the current insertion point of builder.

The operations of the entry block are appended to the current insertion block, which is not expected to have a terminator. If set, continuationBlockArgs is populated with translated values that correspond to the values omp.yield'ed from the region.

Definition at line 418 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::Block::back(), mlir::LLVM::ModuleTranslation::convertBlock(), convertOmpOpRegions(), mlir::Region::empty(), mlir::failed(), mlir::failure(), mlir::LLVM::ModuleTranslation::forgetMapping(), mlir::Region::front(), mlir::Operation::getOperands(), mlir::LLVM::ModuleTranslation::lookupValues(), mlir::LLVM::ModuleTranslation::mapBlock(), and mlir::success().

Referenced by convertOmpReductionOp(), and convertOmpWsLoop().

◆ makeAtomicReductionGen()

static OwningAtomicReductionGen makeAtomicReductionGen ( omp::ReductionDeclareOp  decl,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Create an OpenMPIRBuilder-compatible atomic reduction generator for the given reduction declaration.

The generator uses builder but ignores its insertion point. Returns null if there is no atomic region available in the reduction declaration.

Definition at line 504 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpWsLoop().

◆ makeReductionGen()

static OwningReductionGen makeReductionGen ( omp::ReductionDeclareOp  decl,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Create an OpenMPIRBuilder-compatible reduction generator for the given reduction declaration.

The generator uses builder but ignores its insertion point.

Definition at line 474 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpWsLoop().