LLVM  10.0.0
Classes | Public Types | Public Member Functions | List of all members
llvm::OpenMPIRBuilder Class Reference

An interface to create LLVM-IR for OpenMP directives. More...

#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"

Classes

struct  FinalizationInfo
 
struct  LocationDescription
 Description of a LLVM-IR insertion point (IP) and a debug/source location (filename, line, column, ...). More...
 

Public Types

using InsertPointTy = IRBuilder<>::InsertPoint
 Type used throughout for insertion points. More...
 
using FinalizeCallbackTy = std::function< void(InsertPointTy CodeGenIP)>
 Callback type for variable finalization (think destructors). More...
 
using BodyGenCallbackTy = function_ref< void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP, BasicBlock &ContinuationBB)>
 Callback type for body (=inner region) code generation. More...
 
using PrivatizeCallbackTy = function_ref< InsertPointTy(InsertPointTy AllocaIP, InsertPointTy CodeGenIP, Value &Val, Value *&ReplVal)>
 Callback type for variable privatization (think copy & default constructor). More...
 

Public Member Functions

 OpenMPIRBuilder (Module &M)
 Create a new OpenMPIRBuilder operating on the given module M. More...
 
void initialize ()
 Initialize the internal state, this will put structures types and potentially other helpers into the underlying module. More...
 
void addAttributes (omp::RuntimeFunction FnID, Function &Fn)
 Add attributes known for FnID to Fn. More...
 
void pushFinalizationCB (const FinalizationInfo &FI)
 Push a finalization callback on the finalization stack. More...
 
void popFinalizationCB ()
 Pop the last finalization callback from the finalization stack. More...
 
InsertPointTy CreateBarrier (const LocationDescription &Loc, omp::Directive DK, bool ForceSimpleCall=false, bool CheckCancelFlag=true)
 Emitter methods for OpenMP directives. More...
 
InsertPointTy CreateCancel (const LocationDescription &Loc, Value *IfCondition, omp::Directive CanceledDirective)
 Generator for '#omp cancel'. More...
 
IRBuilder ::InsertPoint CreateParallel (const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB, Value *IfCondition, Value *NumThreads, omp::ProcBindKind ProcBind, bool IsCancellable)
 Generator for '#omp parallel'. More...
 

Detailed Description

An interface to create LLVM-IR for OpenMP directives.

Each OpenMP directive has a corresponding public generator method.

Definition at line 26 of file OMPIRBuilder.h.

Member Typedef Documentation

◆ BodyGenCallbackTy

Callback type for body (=inner region) code generation.

The callback takes code locations as arguments, each describing a location at which code might need to be generated or a location that is the target of control transfer.

Parameters
AllocaIPis the insertion point at which new alloca instructions should be placed.
CodeGenIPis the insertion point at which the body code should be placed.
ContinuationBBis the basic block target to leave the body.

Note that all blocks pointed to by the arguments have terminators.

Definition at line 93 of file OMPIRBuilder.h.

◆ FinalizeCallbackTy

Callback type for variable finalization (think destructors).

Parameters
CodeGenIPis the insertion point at which the finalization code should be placed.

A finalize callback knows about all objects that need finalization, e.g. destruction, when the scope of the currently generated construct is left at the time, and location, the callback is invoked.

Definition at line 51 of file OMPIRBuilder.h.

◆ InsertPointTy

Type used throughout for insertion points.

Definition at line 41 of file OMPIRBuilder.h.

◆ PrivatizeCallbackTy

Callback type for variable privatization (think copy & default constructor).

Parameters
AllocaIPis the insertion point at which new alloca instructions should be placed.
CodeGenIPis the insertion point at which the privatization code should be placed.
ValThe value beeing copied/created.
ReplValThe replacement value, thus a copy or new created version of Val.
Returns
The new insertion point where code generation continues and ReplVal the replacement of Val.

Definition at line 110 of file OMPIRBuilder.h.

Constructor & Destructor Documentation

◆ OpenMPIRBuilder()

llvm::OpenMPIRBuilder::OpenMPIRBuilder ( Module &  M)
inline

Create a new OpenMPIRBuilder operating on the given module M.

This will not have an effect on M (see initialize).

Definition at line 30 of file OMPIRBuilder.h.

References addAttributes(), and initialize().

Member Function Documentation

◆ addAttributes()

void OpenMPIRBuilder::addAttributes ( omp::RuntimeFunction  FnID,
Function &  Fn 
)

Add attributes known for FnID to Fn.

Definition at line 42 of file OMPIRBuilder.cpp.

References assert(), and llvm::Function::getContext().

Referenced by OpenMPIRBuilder().

◆ CreateBarrier()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::CreateBarrier ( const LocationDescription &  Loc,
omp::Directive  DK,
bool  ForceSimpleCall = false,
bool  CheckCancelFlag = true 
)

Emitter methods for OpenMP directives.

{ Generator for '#omp barrier'

Parameters
LocThe location where the barrier directive was encountered.
DKThe kind of directive that caused the barrier.
ForceSimpleCallFlag to force a simple (=non-cancellation) barrier.
CheckCancelFlagFlag to indicate a cancel barrier return value should be checked and acted upon.
Returns
The insertion point after the barrier.

Definition at line 173 of file OMPIRBuilder.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, and llvm::OpenMPIRBuilder::LocationDescription::IP.

◆ CreateCancel()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::CreateCancel ( const LocationDescription &  Loc,
Value *  IfCondition,
omp::Directive  CanceledDirective 
)

Generator for '#omp cancel'.

Parameters
LocThe location where the directive was encountered.
IfConditionThe evaluated 'if' clause expression, if any.
CanceledDirectiveThe kind of directive that is cancled.
Returns
The insertion point after the barrier.

Definition at line 227 of file OMPIRBuilder.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::BasicBlock::begin(), llvm::BasicBlock::Create(), llvm::BasicBlock::end(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::getContext(), llvm::Value::getName(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), llvm::OpenMPIRBuilder::LocationDescription::IP, llvm_unreachable, llvm::SplitBlock(), and llvm::SplitBlockAndInsertIfThenElse().

◆ CreateParallel()

IRBuilder::InsertPoint OpenMPIRBuilder::CreateParallel ( const LocationDescription &  Loc,
BodyGenCallbackTy  BodyGenCB,
PrivatizeCallbackTy  PrivCB,
FinalizeCallbackTy  FiniCB,
Value *  IfCondition,
Value *  NumThreads,
omp::ProcBindKind  ProcBind,
bool  IsCancellable 
)

Generator for '#omp parallel'.

Parameters
LocThe insert and source location description.
BodyGenCBCallback that will generate the region code.
PrivCBCallback to copy a given variable (think copy constructor).
FiniCBCallback to finalize variable copies.
IfConditionThe evaluated 'if' clause expression, if any.
NumThreadsThe evaluated 'num_threads' clause expression, if any.
ProcBindThe value of the 'proc_bind' clause (see ProcBindKind).
IsCancellableFlag to indicate a cancellable parallel region.
Returns
The insertion position after the parallel.

Definition at line 304 of file OMPIRBuilder.cpp.

References llvm::Function::addParamAttr(), llvm::SmallVectorImpl< T >::append(), llvm::CallBase::arg_begin(), llvm::CallBase::arg_end(), llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::sys::path::begin(), llvm::BasicBlock::begin(), llvm::MDBuilder::createCallbackEncoding(), llvm::dbgs(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::sys::path::end(), llvm::BasicBlock::end(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::eraseFromParent(), llvm::CodeExtractor::extractCodeRegion(), F(), llvm::CodeExtractor::findAllocas(), llvm::CodeExtractor::findInputsOutputs(), llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::CallBase::getCalledFunction(), llvm::FunctionCallee::getCallee(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHI(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Constant::getNullValue(), llvm::Instruction::getNumSuccessors(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::Instruction::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::BasicBlock::getUniquePredecessor(), llvm::BasicBlock::getUniqueSuccessor(), I, llvm::SmallVectorImpl< T >::insert(), llvm::OpenMPIRBuilder::LocationDescription::IP, LLVM_DEBUG, llvm::BasicBlock::moveBefore(), llvm::NoAlias, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Instruction::removeFromParent(), llvm::Value::setName(), llvm::BasicBlock::size(), llvm::BasicBlock::splitBasicBlock(), llvm::SplitBlockAndInsertIfThenElse(), and llvm::successors().

◆ initialize()

void OpenMPIRBuilder::initialize ( )

◆ popFinalizationCB()

void llvm::OpenMPIRBuilder::popFinalizationCB ( )
inline

Pop the last finalization callback from the finalization stack.

NOTE: Temporary solution until Clang CG is gone.

Definition at line 76 of file OMPIRBuilder.h.

◆ pushFinalizationCB()

void llvm::OpenMPIRBuilder::pushFinalizationCB ( const FinalizationInfo &  FI)
inline

Push a finalization callback on the finalization stack.

NOTE: Temporary solution until Clang CG is gone.

Definition at line 69 of file OMPIRBuilder.h.


The documentation for this class was generated from the following files: