MLIR  19.0.0git
Classes | Functions
OpenMPToLLVMIRTranslation.cpp File Reference
#include "mlir/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Dialect/OpenMP/OpenMPInterfaces.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/Operation.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Target/LLVMIR/Dialect/OpenMPCommon.h"
#include "mlir/Target/LLVMIR/ModuleTranslation.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Frontend/OpenMP/OMPConstants.h"
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <any>
#include <optional>
#include <utility>

Go to the source code of this file.

Classes

class  OmpParallelOpConversionManager
 A RAII class that on construction replaces the region arguments of the parallel op (which correspond to private variables) with the actual private variables they correspond to. More...
 
struct  MapInfoData
 

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 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...
 
template<typename T >
static std::optional< omp::DeclareReductionOp > findReductionDeclInContainer (T container, omp::ReductionOp reduction)
 Returns a reduction declaration that corresponds to the given reduction operation in the given container. More...
 
static omp::DeclareReductionOp findReductionDecl (Operation &containerOp, omp::ReductionOp reduction)
 Searches for a reduction in a provided region and the regions it is nested in. More...
 
template<typename T >
static void collectReductionDecls (T loop, SmallVectorImpl< omp::DeclareReductionOp > &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::DeclareReductionOp decl, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Create an OpenMPIRBuilder-compatible reduction generator for the given reduction declaration. More...
 
static OwningAtomicReductionGen makeAtomicReductionGen (omp::DeclareReductionOp 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 convertOmpTeams (omp::TeamsOp op, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 
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 convertOmpTaskgroupOp (omp::TaskgroupOp tgOp, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP taskgroup construct into LLVM IR using OpenMPIRBuilder. More...
 
template<typename T >
static void allocByValReductionVars (T loop, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation, llvm::OpenMPIRBuilder::InsertPointTy &allocaIP, SmallVectorImpl< omp::DeclareReductionOp > &reductionDecls, SmallVectorImpl< llvm::Value * > &privateReductionVariables, DenseMap< Value, llvm::Value * > &reductionVariableMap)
 Allocate space for privatized reduction variables. More...
 
template<typename T >
static void mapInitializationArg (T loop, LLVM::ModuleTranslation &moduleTranslation, SmallVectorImpl< omp::DeclareReductionOp > &reductionDecls, unsigned i)
 Map input argument to all reduction initialization regions. More...
 
template<typename T >
static void collectReductionInfo (T loop, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation, SmallVector< omp::DeclareReductionOp > &reductionDecls, SmallVector< OwningReductionGen > &owningReductionGens, SmallVector< OwningAtomicReductionGen > &owningAtomicReductionGens, const SmallVector< llvm::Value * > &privateReductionVariables, SmallVector< llvm::OpenMPIRBuilder::ReductionInfo > &reductionInfos)
 Collect reduction info. More...
 
static LogicalResult inlineReductionCleanup (llvm::SmallVectorImpl< omp::DeclareReductionOp > &reductionDecls, llvm::ArrayRef< llvm::Value * > privateReductionVariables, LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase &builder)
 handling of DeclareReductionOp's cleanup region 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 convertOmpParallel (omp::ParallelOp opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts the OpenMP parallel operation to LLVM IR. More...
 
static LogicalResult convertOmpSimd (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Converts an OpenMP simd loop into LLVM IR using OpenMPIRBuilder. More...
 
static llvm::AtomicOrdering convertAtomicOrdering (std::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...
 
static llvm::OffloadEntriesInfoManager::OMPTargetDeviceClauseKind convertToDeviceClauseKind (mlir::omp::DeclareTargetDeviceType deviceClause)
 
static llvm::OffloadEntriesInfoManager::OMPTargetGlobalVarEntryKind convertToCaptureClauseKind (mlir::omp::DeclareTargetCaptureClause captureClasue)
 
static llvm::SmallString< 64 > getDeclareTargetRefPtrSuffix (LLVM::GlobalOp globalOp, llvm::OpenMPIRBuilder &ompBuilder)
 
static bool isDeclareTargetLink (mlir::Value value)
 
static llvm::Value * getRefPtrIfDeclareTarget (mlir::Value value, LLVM::ModuleTranslation &moduleTranslation)
 
uint64_t getArrayElementSizeInBits (LLVM::LLVMArrayType arrTy, DataLayout &dl)
 
llvm::Value * getSizeInBytes (DataLayout &dl, const mlir::Type &type, Operation *clauseOp, llvm::Value *basePointer, llvm::Type *baseType, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 
void collectMapDataFromMapOperands (MapInfoData &mapData, llvm::SmallVectorImpl< Value > &mapOperands, LLVM::ModuleTranslation &moduleTranslation, DataLayout &dl, llvm::IRBuilderBase &builder)
 
std::vector< llvm::Value * > calculateBoundsOffset (LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase &builder, bool isArrayTy, mlir::OperandRange bounds)
 This function calculates the array/pointer offset for map data provided with bounds operations, e.g. More...
 
static llvm::omp::OpenMPOffloadMappingFlags mapParentWithMembers (LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase &builder, llvm::OpenMPIRBuilder &ompBuilder, DataLayout &dl, llvm::OpenMPIRBuilder::MapInfosTy &combinedInfo, MapInfoData &mapData, uint64_t mapDataIndex, bool isTargetParams)
 
static bool checkIfPointerMap (mlir::omp::MapInfoOp mapOp)
 
static void processMapMembersWithParent (LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase &builder, llvm::OpenMPIRBuilder &ompBuilder, DataLayout &dl, llvm::OpenMPIRBuilder::MapInfosTy &combinedInfo, MapInfoData &mapData, uint64_t mapDataIndex, llvm::omp::OpenMPOffloadMappingFlags memberOfFlag)
 
static void processMapWithMembersOf (LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase &builder, llvm::OpenMPIRBuilder &ompBuilder, DataLayout &dl, llvm::OpenMPIRBuilder::MapInfosTy &combinedInfo, MapInfoData &mapData, uint64_t mapDataIndex, bool isTargetParams)
 
static void createAlteredByCaptureMap (MapInfoData &mapData, LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase &builder)
 
static void genMapInfos (llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation, DataLayout &dl, llvm::OpenMPIRBuilder::MapInfosTy &combinedInfo, MapInfoData &mapData, const SmallVector< Value > &devPtrOperands={}, const SmallVector< Value > &devAddrOperands={}, bool isTargetParams=false)
 
static LogicalResult convertOmpTargetData (Operation *op, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 
LogicalResult convertFlagsAttr (Operation *op, mlir::omp::FlagsAttr attribute, LLVM::ModuleTranslation &moduleTranslation)
 Lowers the FlagsAttr which is applied to the module on the device pass when offloading, this attribute contains OpenMP RTL globals that can be passed as flags to the frontend, otherwise they are set to default. More...
 
static bool getTargetEntryUniqueInfo (llvm::TargetRegionEntryInfo &targetInfo, omp::TargetOp targetOp, llvm::StringRef parentName="")
 
static bool targetOpSupported (Operation &opInst)
 
static void handleDeclareTargetMapVar (MapInfoData &mapData, LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase &builder)
 
static llvm::IRBuilderBase::InsertPoint createDeviceArgumentAccessor (MapInfoData &mapData, llvm::Argument &arg, llvm::Value *input, llvm::Value *&retVal, llvm::IRBuilderBase &builder, llvm::OpenMPIRBuilder &ompBuilder, LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase::InsertPoint allocaIP, llvm::IRBuilderBase::InsertPoint codeGenIP)
 
static LogicalResult convertOmpTarget (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 
static LogicalResult convertDeclareTargetAttr (Operation *op, mlir::omp::DeclareTargetAttr attribute, LLVM::ModuleTranslation &moduleTranslation)
 
static bool isTargetDeviceOp (Operation *op)
 
static LogicalResult convertHostOrTargetOperation (Operation *op, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Given an OpenMP MLIR operation, create the corresponding LLVM IR (including OpenMP runtime calls). More...
 
static LogicalResult convertTargetDeviceOp (Operation *op, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 
static LogicalResult convertTargetOpsInNest (Operation *op, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 

Function Documentation

◆ allocByValReductionVars()

template<typename T >
static void allocByValReductionVars ( loop,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation,
llvm::OpenMPIRBuilder::InsertPointTy &  allocaIP,
SmallVectorImpl< omp::DeclareReductionOp > &  reductionDecls,
SmallVectorImpl< llvm::Value * > &  privateReductionVariables,
DenseMap< Value, llvm::Value * > &  reductionVariableMap 
)
static

Allocate space for privatized reduction variables.

Definition at line 807 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::LLVM::ModuleTranslation::convertType(), and mlir::LLVM::ModuleTranslation::mapValue().

Referenced by convertOmpParallel(), and convertOmpWsloop().

◆ calculateBoundsOffset()

std::vector<llvm::Value *> calculateBoundsOffset ( LLVM::ModuleTranslation moduleTranslation,
llvm::IRBuilderBase &  builder,
bool  isArrayTy,
mlir::OperandRange  bounds 
)

This function calculates the array/pointer offset for map data provided with bounds operations, e.g.

when provided something like the following:

Fortran map(tofrom: array(2:5, 3:2)) or C++ map(tofrom: array[1:4][2:3]) We must calculate the initial pointer offset to pass across, this function performs this using bounds.

NOTE: which while specified in row-major order it currently needs to be flipped for Fortran's column order array allocation and access (as opposed to C++'s row-major, hence the backwards processing where order is important). This is likely important to keep in mind for the future when we incorporate a C++ frontend, both frontends will need to agree on the ordering of generated bounds operations (one may have to flip them) to make the below lowering frontend agnostic. The offload size calcualtion may also have to be adjusted for C++.

Definition at line 2104 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::LLVM::ModuleTranslation::lookupValue().

Referenced by createAlteredByCaptureMap().

◆ checkIfPointerMap()

static bool checkIfPointerMap ( mlir::omp::MapInfoOp  mapOp)
static

◆ collectMapDataFromMapOperands()

void collectMapDataFromMapOperands ( MapInfoData mapData,
llvm::SmallVectorImpl< Value > &  mapOperands,
LLVM::ModuleTranslation moduleTranslation,
DataLayout dl,
llvm::IRBuilderBase &  builder 
)

◆ collectReductionDecls()

template<typename T >
static void collectReductionDecls ( loop,
SmallVectorImpl< omp::DeclareReductionOp > &  reductions 
)
static

Populates reductions with reduction declarations used in the given loop.

Definition at line 383 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpParallel(), and convertOmpWsloop().

◆ collectReductionInfo()

template<typename T >
static void collectReductionInfo ( loop,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation,
SmallVector< omp::DeclareReductionOp > &  reductionDecls,
SmallVector< OwningReductionGen > &  owningReductionGens,
SmallVector< OwningAtomicReductionGen > &  owningAtomicReductionGens,
const SmallVector< llvm::Value * > &  privateReductionVariables,
SmallVector< llvm::OpenMPIRBuilder::ReductionInfo > &  reductionInfos 
)
static

◆ convertAtomicOrdering()

static llvm::AtomicOrdering convertAtomicOrdering ( std::optional< omp::ClauseMemoryOrderKind >  ao)
static

Convert an Atomic Ordering attribute to llvm::AtomicOrdering.

Definition at line 1498 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 1560 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpAtomicCapture(), and convertOmpAtomicUpdate().

◆ convertDeclareTargetAttr()

static LogicalResult convertDeclareTargetAttr ( Operation op,
mlir::omp::DeclareTargetAttr  attribute,
LLVM::ModuleTranslation moduleTranslation 
)
static

Definition at line 3040 of file OpenMPToLLVMIRTranslation.cpp.

◆ convertFlagsAttr()

LogicalResult convertFlagsAttr ( Operation op,
mlir::omp::FlagsAttr  attribute,
LLVM::ModuleTranslation moduleTranslation 
)

Lowers the FlagsAttr which is applied to the module on the device pass when offloading, this attribute contains OpenMP RTL globals that can be passed as flags to the frontend, otherwise they are set to default.

Definition at line 2700 of file OpenMPToLLVMIRTranslation.cpp.

◆ convertHostOrTargetOperation()

static LogicalResult convertHostOrTargetOperation ( Operation op,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Given an OpenMP MLIR operation, create the corresponding LLVM IR (including OpenMP runtime calls).

Definition at line 3151 of file OpenMPToLLVMIRTranslation.cpp.

◆ 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 291 of file OpenMPToLLVMIRTranslation.cpp.

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

◆ 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 264 of file OpenMPToLLVMIRTranslation.cpp.

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

◆ 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 528 of file OpenMPToLLVMIRTranslation.cpp.

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

◆ 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 558 of file OpenMPToLLVMIRTranslation.cpp.

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

◆ 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 and ParallelOp, but can be easily extended.

Definition at line 1743 of file OpenMPToLLVMIRTranslation.cpp.

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

◆ convertOmpSections()

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

Definition at line 591 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::emitError(), and mlir::success().

◆ convertOmpSimd()

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

◆ convertOmpSingle()

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

◆ convertOmpTarget()

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

◆ convertOmpTargetData()

static LogicalResult convertOmpTargetData ( Operation op,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Definition at line 2521 of file OpenMPToLLVMIRTranslation.cpp.

◆ convertOmpTaskgroupOp()

static LogicalResult convertOmpTaskgroupOp ( omp::TaskgroupOp  tgOp,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Converts an OpenMP taskgroup construct into LLVM IR using OpenMPIRBuilder.

Definition at line 786 of file OpenMPToLLVMIRTranslation.cpp.

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

◆ 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 730 of file OpenMPToLLVMIRTranslation.cpp.

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

◆ convertOmpTeams()

static LogicalResult convertOmpTeams ( omp::TeamsOp  op,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Definition at line 691 of file OpenMPToLLVMIRTranslation.cpp.

◆ 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

◆ convertTargetDeviceOp()

static LogicalResult convertTargetDeviceOp ( Operation op,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Definition at line 3268 of file OpenMPToLLVMIRTranslation.cpp.

◆ convertTargetOpsInNest()

static LogicalResult convertTargetOpsInNest ( Operation op,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)
static

Definition at line 3274 of file OpenMPToLLVMIRTranslation.cpp.

◆ convertToCaptureClauseKind()

static llvm::OffloadEntriesInfoManager::OMPTargetGlobalVarEntryKind convertToCaptureClauseKind ( mlir::omp::DeclareTargetCaptureClause  captureClasue)
static

Definition at line 1842 of file OpenMPToLLVMIRTranslation.cpp.

◆ convertToDeviceClauseKind()

static llvm::OffloadEntriesInfoManager::OMPTargetDeviceClauseKind convertToDeviceClauseKind ( mlir::omp::DeclareTargetDeviceType  deviceClause)
static

Definition at line 1826 of file OpenMPToLLVMIRTranslation.cpp.

◆ createAlteredByCaptureMap()

static void createAlteredByCaptureMap ( MapInfoData mapData,
LLVM::ModuleTranslation moduleTranslation,
llvm::IRBuilderBase &  builder 
)
static

◆ createDeviceArgumentAccessor()

static llvm::IRBuilderBase::InsertPoint createDeviceArgumentAccessor ( MapInfoData mapData,
llvm::Argument &  arg,
llvm::Value *  input,
llvm::Value *&  retVal,
llvm::IRBuilderBase &  builder,
llvm::OpenMPIRBuilder &  ompBuilder,
LLVM::ModuleTranslation moduleTranslation,
llvm::IRBuilderBase::InsertPoint  allocaIP,
llvm::IRBuilderBase::InsertPoint  codeGenIP 
)
static

Definition at line 2859 of file OpenMPToLLVMIRTranslation.cpp.

References MapInfoData::MapClause, and MapInfoData::OriginalValue.

Referenced by convertOmpTarget().

◆ findAllocaInsertPoint()

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

◆ findReductionDecl()

static omp::DeclareReductionOp findReductionDecl ( Operation containerOp,
omp::ReductionOp  reduction 
)
static

Searches for a reduction in a provided region and the regions it is nested in.

Definition at line 355 of file OpenMPToLLVMIRTranslation.cpp.

References findReductionDeclInContainer(), and mlir::Operation::getParentOp().

Referenced by convertOmpReductionOp().

◆ findReductionDeclInContainer()

template<typename T >
static std::optional<omp::DeclareReductionOp> findReductionDeclInContainer ( 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 and ParallelOp but can be easily extended as long as the given construct implements getNumReductionVars.

Definition at line 338 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by findReductionDecl().

◆ genMapInfos()

static void genMapInfos ( llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation,
DataLayout dl,
llvm::OpenMPIRBuilder::MapInfosTy combinedInfo,
MapInfoData mapData,
const SmallVector< Value > &  devPtrOperands = {},
const SmallVector< Value > &  devAddrOperands = {},
bool  isTargetParams = false 
)
static

Definition at line 2400 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpTarget().

◆ getArrayElementSizeInBits()

uint64_t getArrayElementSizeInBits ( LLVM::LLVMArrayType  arrTy,
DataLayout dl 
)

Definition at line 1960 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::DataLayout::getTypeSizeInBits().

Referenced by getSizeInBytes().

◆ getDeclareTargetRefPtrSuffix()

static llvm::SmallString<64> getDeclareTargetRefPtrSuffix ( LLVM::GlobalOp  globalOp,
llvm::OpenMPIRBuilder &  ompBuilder 
)
static

Definition at line 1856 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::SymbolTable::Private.

Referenced by getRefPtrIfDeclareTarget().

◆ getProcBindKind()

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

Convert ProcBindKind from MLIR-generated enum to LLVM enum.

Definition at line 248 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpParallel().

◆ getRefPtrIfDeclareTarget()

static llvm::Value* getRefPtrIfDeclareTarget ( mlir::Value  value,
LLVM::ModuleTranslation moduleTranslation 
)
static

◆ getSizeInBytes()

llvm::Value* getSizeInBytes ( DataLayout dl,
const mlir::Type type,
Operation clauseOp,
llvm::Value *  basePointer,
llvm::Type *  baseType,
llvm::IRBuilderBase &  builder,
LLVM::ModuleTranslation moduleTranslation 
)

◆ getTargetEntryUniqueInfo()

static bool getTargetEntryUniqueInfo ( llvm::TargetRegionEntryInfo &  targetInfo,
omp::TargetOp  targetOp,
llvm::StringRef  parentName = "" 
)
static

Definition at line 2737 of file OpenMPToLLVMIRTranslation.cpp.

Referenced by convertOmpTarget().

◆ handleDeclareTargetMapVar()

static void handleDeclareTargetMapVar ( MapInfoData mapData,
LLVM::ModuleTranslation moduleTranslation,
llvm::IRBuilderBase &  builder 
)
static

◆ 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. If set, continuationBlockArgs is populated with translated values that correspond to the values omp.yield'ed from the region.

Definition at line 402 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 convertOmpParallel(), convertOmpReductionOp(), convertOmpWsloop(), inlineReductionCleanup(), makeAtomicReductionGen(), and makeReductionGen().

◆ inlineReductionCleanup()

static LogicalResult inlineReductionCleanup ( llvm::SmallVectorImpl< omp::DeclareReductionOp > &  reductionDecls,
llvm::ArrayRef< llvm::Value * >  privateReductionVariables,
LLVM::ModuleTranslation moduleTranslation,
llvm::IRBuilderBase &  builder 
)
static

◆ isDeclareTargetLink()

static bool isDeclareTargetLink ( mlir::Value  value)
static

Definition at line 1875 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::Value::getDefiningOp().

Referenced by checkIfPointerMap().

◆ isTargetDeviceOp()

static bool isTargetDeviceOp ( Operation op)
static

Definition at line 3131 of file OpenMPToLLVMIRTranslation.cpp.

◆ makeAtomicReductionGen()

static OwningAtomicReductionGen makeAtomicReductionGen ( omp::DeclareReductionOp  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 499 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::failed(), mlir::Region::front(), mlir::Block::getArgument(), inlineConvertOmpRegions(), and mlir::LLVM::ModuleTranslation::mapValue().

Referenced by collectReductionInfo().

◆ makeReductionGen()

static OwningReductionGen makeReductionGen ( omp::DeclareReductionOp  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 469 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::failed(), mlir::Region::front(), mlir::Block::getArgument(), inlineConvertOmpRegions(), and mlir::LLVM::ModuleTranslation::mapValue().

Referenced by collectReductionInfo().

◆ mapInitializationArg()

template<typename T >
static void mapInitializationArg ( loop,
LLVM::ModuleTranslation moduleTranslation,
SmallVectorImpl< omp::DeclareReductionOp > &  reductionDecls,
unsigned  i 
)
static

◆ mapParentWithMembers()

static llvm::omp::OpenMPOffloadMappingFlags mapParentWithMembers ( LLVM::ModuleTranslation moduleTranslation,
llvm::IRBuilderBase &  builder,
llvm::OpenMPIRBuilder &  ompBuilder,
DataLayout dl,
llvm::OpenMPIRBuilder::MapInfosTy combinedInfo,
MapInfoData mapData,
uint64_t  mapDataIndex,
bool  isTargetParams 
)
static

◆ processMapMembersWithParent()

static void processMapMembersWithParent ( LLVM::ModuleTranslation moduleTranslation,
llvm::IRBuilderBase &  builder,
llvm::OpenMPIRBuilder &  ompBuilder,
DataLayout dl,
llvm::OpenMPIRBuilder::MapInfosTy combinedInfo,
MapInfoData mapData,
uint64_t  mapDataIndex,
llvm::omp::OpenMPOffloadMappingFlags  memberOfFlag 
)
static

◆ processMapWithMembersOf()

static void processMapWithMembersOf ( LLVM::ModuleTranslation moduleTranslation,
llvm::IRBuilderBase &  builder,
llvm::OpenMPIRBuilder &  ompBuilder,
DataLayout dl,
llvm::OpenMPIRBuilder::MapInfosTy combinedInfo,
MapInfoData mapData,
uint64_t  mapDataIndex,
bool  isTargetParams 
)
static

◆ targetOpSupported()

static bool targetOpSupported ( Operation opInst)
static

Definition at line 2757 of file OpenMPToLLVMIRTranslation.cpp.

References mlir::Operation::emitError().

Referenced by convertOmpTarget().