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

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

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

Collaboration diagram for llvm::OpenMPIRBuilder:
Collaboration graph
[legend]

Classes

struct  AtomicOpValue
 a struct to pack relevant information while generating atomic Ops More...
 
struct  FinalizationInfo
 
struct  LocationDescription
 Description of a LLVM-IR insertion point (IP) and a debug/source location (filename, line, column, ...). More...
 
struct  OutlineInfo
 Helper that contains information about regions we need to outline during finalization. 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 StorableBodyGenCallbackTy = std::function< void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP, BasicBlock &ContinuationBB)>
 
using LoopBodyGenCallbackTy = function_ref< void(InsertPointTy CodeGenIP, Value *IndVar)>
 Callback type for loop body code generation. More...
 
using PrivatizeCallbackTy = function_ref< InsertPointTy(InsertPointTy AllocaIP, InsertPointTy CodeGenIP, Value &Original, Value &Inner, 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...
 
 ~OpenMPIRBuilder ()
 
void initialize ()
 Initialize the internal state, this will put structures types and potentially other helpers into the underlying module. More...
 
void finalize (Function *Fn=nullptr, bool AllowExtractorSinking=false)
 Finalize the underlying module, e.g., by outlining regions. 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, InsertPointTy AllocaIP, BodyGenCallbackTy BodyGenCB, PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB, Value *IfCondition, Value *NumThreads, omp::ProcBindKind ProcBind, bool IsCancellable)
 Generator for '#omp parallel'. More...
 
CanonicalLoopInfocreateCanonicalLoop (const LocationDescription &Loc, LoopBodyGenCallbackTy BodyGenCB, Value *TripCount, const Twine &Name="loop")
 Generator for the control flow structure of an OpenMP canonical loop. More...
 
CanonicalLoopInfocreateCanonicalLoop (const LocationDescription &Loc, LoopBodyGenCallbackTy BodyGenCB, Value *Start, Value *Stop, Value *Step, bool IsSigned, bool InclusiveStop, InsertPointTy ComputeIP={}, const Twine &Name="loop")
 Generator for the control flow structure of an OpenMP canonical loop. More...
 
CanonicalLoopInfocollapseLoops (DebugLoc DL, ArrayRef< CanonicalLoopInfo * > Loops, InsertPointTy ComputeIP)
 Collapse a loop nest into a single loop. More...
 
CanonicalLoopInfocreateStaticWorkshareLoop (const LocationDescription &Loc, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP, bool NeedsBarrier, Value *Chunk=nullptr)
 Modifies the canonical loop to be a statically-scheduled workshare loop. More...
 
InsertPointTy createDynamicWorkshareLoop (const LocationDescription &Loc, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP, omp::OMPScheduleType SchedType, bool NeedsBarrier, Value *Chunk=nullptr)
 Modifies the canonical loop to be a dynamically-scheduled workshare loop. More...
 
CanonicalLoopInfocreateWorkshareLoop (const LocationDescription &Loc, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP, bool NeedsBarrier)
 Modifies the canonical loop to be a workshare loop. More...
 
std::vector< CanonicalLoopInfo * > tileLoops (DebugLoc DL, ArrayRef< CanonicalLoopInfo * > Loops, ArrayRef< Value * > TileSizes)
 Tile a loop nest. More...
 
void createFlush (const LocationDescription &Loc)
 Generator for '#omp flush'. More...
 
void createTaskwait (const LocationDescription &Loc)
 Generator for '#omp taskwait'. More...
 
void createTaskyield (const LocationDescription &Loc)
 Generator for '#omp taskyield'. More...
 
InsertPointTy getInsertionPoint ()
 } More...
 
bool updateToLocation (const LocationDescription &Loc)
 Update the internal location to Loc. More...
 
FunctionCallee getOrCreateRuntimeFunction (Module &M, omp::RuntimeFunction FnID)
 Return the function declaration for the runtime function with FnID. More...
 
FunctiongetOrCreateRuntimeFunctionPtr (omp::RuntimeFunction FnID)
 
ConstantgetOrCreateSrcLocStr (StringRef LocStr)
 Return the (LLVM-IR) string describing the source location LocStr. More...
 
ConstantgetOrCreateDefaultSrcLocStr ()
 Return the (LLVM-IR) string describing the default source location. More...
 
ConstantgetOrCreateSrcLocStr (StringRef FunctionName, StringRef FileName, unsigned Line, unsigned Column)
 Return the (LLVM-IR) string describing the source location identified by the arguments. More...
 
ConstantgetOrCreateSrcLocStr (const LocationDescription &Loc)
 Return the (LLVM-IR) string describing the source location Loc. More...
 
ValuegetOrCreateIdent (Constant *SrcLocStr, omp::IdentFlag Flags=omp::IdentFlag(0), unsigned Reserve2Flags=0)
 Return an ident_t* encoding the source location SrcLocStr and Flags. More...
 
TypegetLanemaskType ()
 
void emitCancelationCheckImpl (Value *CancelFlag, omp::Directive CanceledDirective, FinalizeCallbackTy ExitCB={})
 Generate control flow and cleanup for cancellation. More...
 
InsertPointTy emitBarrierImpl (const LocationDescription &Loc, omp::Directive DK, bool ForceSimpleCall, bool CheckCancelFlag)
 Generate a barrier runtime call. More...
 
void emitFlush (const LocationDescription &Loc)
 Generate a flush runtime call. More...
 
bool isLastFinalizationInfoCancellable (omp::Directive DK)
 Return true if the last entry in the finalization stack is of kind DK and cancellable. More...
 
void emitTaskwaitImpl (const LocationDescription &Loc)
 Generate a taskwait runtime call. More...
 
void emitTaskyieldImpl (const LocationDescription &Loc)
 Generate a taskyield runtime call. More...
 
ValuegetOrCreateThreadID (Value *Ident)
 Return the current thread ID. More...
 
void addOutlineInfo (OutlineInfo &&OI)
 Add a new region that will be outlined later. More...
 
GlobalVariablecreateOffloadMaptypes (SmallVectorImpl< uint64_t > &Mappings, std::string VarName)
 Create the global variable holding the offload mappings information. More...
 
GlobalVariablecreateOffloadMapnames (SmallVectorImpl< llvm::Constant * > &Names, std::string VarName)
 Create the global variable holding the offload names information. More...
 
InsertPointTy createCopyPrivate (const LocationDescription &Loc, llvm::Value *BufSize, llvm::Value *CpyBuf, llvm::Value *CpyFn, llvm::Value *DidIt)
 Generator for __kmpc_copyprivate. More...
 
InsertPointTy createSingle (const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, llvm::Value *DidIt)
 Generator for '#omp single'. More...
 
InsertPointTy createMaster (const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB)
 Generator for '#omp master'. More...
 
InsertPointTy createMasked (const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, Value *Filter)
 Generator for '#omp masked'. More...
 
InsertPointTy createCritical (const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, StringRef CriticalName, Value *HintInst)
 Generator for '#omp critical'. More...
 
InsertPointTy createSections (const LocationDescription &Loc, InsertPointTy AllocaIP, ArrayRef< StorableBodyGenCallbackTy > SectionCBs, PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB, bool IsCancellable, bool IsNowait)
 Generator for '#omp sections'. More...
 
InsertPointTy createSection (const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB)
 Generator for '#omp section'. More...
 
InsertPointTy createCopyinClauseBlocks (InsertPointTy IP, Value *MasterAddr, Value *PrivateAddr, llvm::IntegerType *IntPtrTy, bool BranchtoEnd=true)
 Generate conditional branch and relevant BasicBlocks through which private threads copy the 'copyin' variables from Master copy to threadprivate copies. More...
 
CallInstcreateOMPAlloc (const LocationDescription &Loc, Value *Size, Value *Allocator, std::string Name="")
 Create a runtime call for kmpc_Alloc. More...
 
CallInstcreateOMPFree (const LocationDescription &Loc, Value *Addr, Value *Allocator, std::string Name="")
 Create a runtime call for kmpc_free. More...
 
CallInstcreateCachedThreadPrivate (const LocationDescription &Loc, llvm::Value *Pointer, llvm::ConstantInt *Size, const llvm::Twine &Name=Twine(""))
 Create a runtime call for kmpc_threadprivate_cached. More...
 
InsertPointTy createTargetInit (const LocationDescription &Loc, bool IsSPMD, bool RequiresFullRuntime)
 The omp target interface. More...
 
void createTargetDeinit (const LocationDescription &Loc, bool IsSPMD, bool RequiresFullRuntime)
 Create a runtime call for kmpc_target_deinit. More...
 
InsertPointTy createAtomicRead (const LocationDescription &Loc, AtomicOpValue &X, AtomicOpValue &V, AtomicOrdering AO)
 Emit atomic Read for : V = X — Only Scalar data types. More...
 
InsertPointTy createAtomicWrite (const LocationDescription &Loc, AtomicOpValue &X, Value *Expr, AtomicOrdering AO)
 Emit atomic write for : X = Expr — Only Scalar data types. More...
 
InsertPointTy createAtomicUpdate (const LocationDescription &Loc, Instruction *AllocIP, AtomicOpValue &X, Value *Expr, AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp, AtomicUpdateCallbackTy &UpdateOp, bool IsXLHSInRHSPart)
 Emit atomic update for constructs: X = X BinOp Expr ,or X = Expr BinOp X For complex Operations: X = UpdateOp(X) => CmpExch X, old_X, UpdateOp(X) Only Scalar data types. More...
 
InsertPointTy createAtomicCapture (const LocationDescription &Loc, Instruction *AllocIP, AtomicOpValue &X, AtomicOpValue &V, Value *Expr, AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp, AtomicUpdateCallbackTy &UpdateOp, bool UpdateExpr, bool IsPostfixUpdate, bool IsXLHSInRHSPart)
 Emit atomic update for constructs: — Only Scalar data types V = X; X = X BinOp Expr , X = X BinOp Expr; V = X, V = X; X = Expr BinOp X, X = Expr BinOp X; V = X, V = X; X = UpdateOp(X), X = UpdateOp(X); V = X,. More...
 
CanonicalLoopInfocreateLoopSkeleton (DebugLoc DL, Value *TripCount, Function *F, BasicBlock *PreInsertBefore, BasicBlock *PostInsertBefore, const Twine &Name={})
 Create the control flow structure of a canonical OpenMP loop. More...
 

Public Attributes

SmallVector< FinalizationInfo, 8 > FinalizationStack
 The finalization stack made up of finalize callbacks currently in-flight, wrapped into FinalizationInfo objects that reference also the finalization target block and the kind of cancellable directive. More...
 
ModuleM
 The underlying LLVM-IR module. More...
 
IRBuilder Builder
 The LLVM-IR Builder used to create IR. More...
 
StringMap< Constant * > SrcLocStrMap
 Map to remember source location strings. More...
 
DenseMap< std::pair< Constant *, uint64_t >, Value * > IdentMap
 Map to remember existing ident_t*. More...
 
SmallVector< OutlineInfo, 16 > OutlineInfos
 Collection of regions that need to be outlined during finalization. More...
 
std::forward_list< CanonicalLoopInfoLoopInfos
 Collection of owned canonical loop objects that eventually need to be free'd. More...
 
StringMap< AssertingVH< Constant >, BumpPtrAllocatorInternalVars
 An ordered map of auto-generated variables to their unique names. More...
 

Detailed Description

An interface to create LLVM-IR for OpenMP directives.

Each OpenMP directive has a corresponding public generator method.

Definition at line 29 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 105 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 63 of file OMPIRBuilder.h.

◆ InsertPointTy

Type used throughout for insertion points.

Definition at line 53 of file OMPIRBuilder.h.

◆ LoopBodyGenCallbackTy

Callback type for loop body code generation.

Parameters
CodeGenIPis the insertion point where the loop's body code must be placed. This will be a dedicated BasicBlock with a conditional branch from the loop condition check and terminated with an unconditional branch to the loop latch.
IndVaris the induction variable usable at the insertion point.

Definition at line 124 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.
OriginalThe value being copied/created, should not be used in the generated IR.
InnerThe equivalent of Original that should be used in the generated IR; this is equal to Original if the value is a pointer and can thus be passed directly, otherwise it is an equivalent but different value.
ReplValThe replacement value, thus a copy or new created version of Inner.
Returns
The new insertion point where code generation continues and ReplVal the replacement value.

Definition at line 146 of file OMPIRBuilder.h.

◆ StorableBodyGenCallbackTy

Definition at line 113 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 33 of file OMPIRBuilder.h.

◆ ~OpenMPIRBuilder()

OpenMPIRBuilder::~OpenMPIRBuilder ( )

Definition at line 227 of file OMPIRBuilder.cpp.

References assert().

Member Function Documentation

◆ addAttributes()

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

◆ addOutlineInfo()

void llvm::OpenMPIRBuilder::addOutlineInfo ( OutlineInfo &&  OI)
inline

Add a new region that will be outlined later.

Definition at line 621 of file OMPIRBuilder.h.

References OutlineInfos.

◆ collapseLoops()

CanonicalLoopInfo * OpenMPIRBuilder::collapseLoops ( DebugLoc  DL,
ArrayRef< CanonicalLoopInfo * >  Loops,
InsertPointTy  ComputeIP 
)

Collapse a loop nest into a single loop.

Merges loops of a loop nest into a single CanonicalLoopNest representation that has the same number of innermost loop iterations as the origin loop nest. The induction variables of the input loops are derived from the collapsed loop's induction variable. This is intended to be used to implement OpenMP's collapse clause. Before applying a directive, collapseLoops normalizes a loop nest to contain only a single loop and the directive's implementation does not need to handle multiple loops itself. This does not remove the need to handle all loop nest handling by directives, such as the ordered(<n>) clause or the simd schedule-clause modifier of the worksharing-loop directive.

Example:

for (int i = 0; i < 7; ++i) // Canonical loop "i"
for (int j = 0; j < 9; ++j) // Canonical loop "j"
body(i, j);

After collapsing with Loops={i,j}, the loop is changed to

for (int ij = 0; ij < 63; ++ij) {
int i = ij / 9;
int j = ij % 9;
body(i, j);
}

In the current implementation, the following limitations apply:

  • All input loops have an induction variable of the same type.
  • The collapsed loop will have the same trip count integer type as the input loops. Therefore it is possible that the collapsed loop cannot represent all iterations of the input loops. For instance, assuming a 32 bit integer type, and two input loops both iterating 2^16 times, the theoretical trip count of the collapsed loop would be 2^32 iteration, which cannot be represented in an 32-bit integer. Behavior is undefined in this case.
  • The trip counts of every input loop must be available at ComputeIP. Non-rectangular loops are not yet supported.
  • At each nest level, code between a surrounding loop and its nested loop is hoisted into the loop body, and such code will be executed more often than before collapsing (or not at all if any inner loop iteration has a trip count of 0). This is permitted by the OpenMP specification.
Parameters
DLDebug location for instructions added for collapsing, such as instructions to compute derive the input loop's induction variables.
LoopsLoops in the loop nest to collapse. Loops are specified from outermost-to-innermost and every control flow of a loop's body must pass through its directly nested loop.
ComputeIPWhere additional instruction that compute the collapsed trip count. If not set, defaults to before the generated loop.
Returns
The CanonicalLoopInfo object representing the collapsed loop.

Definition at line 1569 of file OMPIRBuilder.cpp.

References assert(), Builder, DL, F, llvm::CanonicalLoopInfo::getAfter(), llvm::CanonicalLoopInfo::getBody(), llvm::CanonicalLoopInfo::getLatch(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::BasicBlock::getParent(), llvm::CanonicalLoopInfo::getPreheader(), llvm::CanonicalLoopInfo::getPreheaderIP(), i, Loops, redirectAllPredecessorsTo(), redirectTo(), removeUnusedBlocksFromParent(), and llvm::SmallVectorImpl< T >::reserve().

◆ createAtomicCapture()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicCapture ( const LocationDescription Loc,
Instruction AllocIP,
AtomicOpValue X,
AtomicOpValue V,
Value Expr,
AtomicOrdering  AO,
AtomicRMWInst::BinOp  RMWOp,
AtomicUpdateCallbackTy UpdateOp,
bool  UpdateExpr,
bool  IsPostfixUpdate,
bool  IsXLHSInRHSPart 
)

Emit atomic update for constructs: — Only Scalar data types V = X; X = X BinOp Expr , X = X BinOp Expr; V = X, V = X; X = Expr BinOp X, X = Expr BinOp X; V = X, V = X; X = UpdateOp(X), X = UpdateOp(X); V = X,.

Parameters
LocThe insert and source location description.
AllocIPInstruction to create AllocaInst before.
XThe target atomic pointer to be updated
VMemory address where to store captured value
ExprThe value to update X with.
AOAtomic ordering of the generated atomic instructions
RMWOpThe binary operation used for update. If operation is not supported by atomicRMW, or belong to {FADD, FSUB, BAD_BINOP}. Then a cmpExch based atomic will be generated.
UpdateOpCode generator for complex expressions that cannot be expressed through atomicrmw instruction.
UpdateExprtrue if X is an in place update of the form X = X BinOp Expr or X = Expr BinOp X
IsXLHSInRHSParttrue if X is Left H.S. in Right H.S. part of the update expression, false otherwise. (e.g. true for X = X BinOp Expr)
IsPostfixUpdatetrue if original value of 'x' must be stored in 'v', not an updated one.
Returns
Insertion point after generated atomic capture IR.

Definition at line 2609 of file OMPIRBuilder.cpp.

References assert(), Builder, llvm::Type::getPointerElementType(), llvm::OpenMPIRBuilder::LocationDescription::IP, llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::OpenMPIRBuilder::AtomicOpValue::IsVolatile, LLVM_DEBUG, llvm::AtomicRMWInst::Max, llvm::AtomicRMWInst::Min, llvm::OpenMPIRBuilder::AtomicOpValue::Var, X, and llvm::AtomicRMWInst::Xchg.

◆ createAtomicRead()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicRead ( const LocationDescription Loc,
AtomicOpValue X,
AtomicOpValue V,
AtomicOrdering  AO 
)

Emit atomic Read for : V = X — Only Scalar data types.

Parameters
LocThe insert and source location description.
XThe target pointer to be atomically read
VMemory address where to store atomically read value
AOAtomic ordering of the generated atomic instructions.
Returns
Insertion point after generated atomic read IR.

Definition at line 2382 of file OMPIRBuilder.cpp.

References assert(), Builder, llvm::IntegerType::get(), llvm::Type::getPointerElementType(), llvm::Type::getPointerTo(), llvm::Type::getScalarSizeInBits(), llvm::OpenMPIRBuilder::LocationDescription::IP, llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::OpenMPIRBuilder::AtomicOpValue::IsVolatile, M, llvm::LoadInst::setAtomic(), llvm::OpenMPIRBuilder::AtomicOpValue::Var, and X.

◆ createAtomicUpdate()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicUpdate ( const LocationDescription Loc,
Instruction AllocIP,
AtomicOpValue X,
Value Expr,
AtomicOrdering  AO,
AtomicRMWInst::BinOp  RMWOp,
AtomicUpdateCallbackTy UpdateOp,
bool  IsXLHSInRHSPart 
)

Emit atomic update for constructs: X = X BinOp Expr ,or X = Expr BinOp X For complex Operations: X = UpdateOp(X) => CmpExch X, old_X, UpdateOp(X) Only Scalar data types.

Parameters
LocThe insert and source location description.
AllocIPInstruction to create AllocaInst before.
XThe target atomic pointer to be updated
ExprThe value to update X with.
AOAtomic ordering of the generated atomic instructions.
RMWOpThe binary operation used for update. If operation is not supported by atomicRMW, or belong to {FADD, FSUB, BAD_BINOP}. Then a cmpExch based atomic will be generated.
UpdateOpCode generator for complex expressions that cannot be expressed through atomicrmw instruction.
IsXLHSInRHSParttrue if X is Left H.S. in Right H.S. part of the update expression, false otherwise. (e.g. true for X = X BinOp Expr)
Returns
Insertion point after generated atomic update IR.

Definition at line 2457 of file OMPIRBuilder.cpp.

References assert(), Builder, llvm::Type::getPointerElementType(), llvm::OpenMPIRBuilder::LocationDescription::IP, llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), LLVM_DEBUG, llvm::AtomicRMWInst::Max, llvm::AtomicRMWInst::Min, llvm::AtomicRMWInst::UMax, llvm::AtomicRMWInst::UMin, and X.

◆ createAtomicWrite()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicWrite ( const LocationDescription Loc,
AtomicOpValue X,
Value Expr,
AtomicOrdering  AO 
)

Emit atomic write for : X = Expr — Only Scalar data types.

Parameters
LocThe insert and source location description.
XThe target pointer to be atomically written to
ExprThe value to store.
AOAtomic ordering of the generated atomic instructions.
Returns
Insertion point after generated atomic Write IR.

Definition at line 2424 of file OMPIRBuilder.cpp.

References assert(), Builder, llvm::IntegerType::get(), llvm::Type::getPointerElementType(), llvm::Type::getPointerTo(), llvm::Type::getScalarSizeInBits(), llvm::OpenMPIRBuilder::LocationDescription::IP, llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), M, llvm::StoreInst::setAtomic(), and X.

◆ 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 336 of file OMPIRBuilder.cpp.

References llvm::OpenMPIRBuilder::LocationDescription::IP.

◆ createCachedThreadPrivate()

CallInst * OpenMPIRBuilder::createCachedThreadPrivate ( const LocationDescription Loc,
llvm::Value Pointer,
llvm::ConstantInt Size,
const llvm::Twine Name = Twine("") 
)

Create a runtime call for kmpc_threadprivate_cached.

Parameters
LocThe insert and source location description.
Pointerpointer to data to be cached
Sizesize of data to be cached
NameName of call Instruction for callinst
Returns
CallInst to the thread private cache call.

Definition at line 2176 of file OMPIRBuilder.cpp.

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

◆ 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 391 of file OMPIRBuilder.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, llvm::OpenMPIRBuilder::LocationDescription::DL, llvm::OpenMPIRBuilder::LocationDescription::IP, llvm_unreachable, and llvm::SplitBlockAndInsertIfThenElse().

◆ createCanonicalLoop() [1/2]

CanonicalLoopInfo * OpenMPIRBuilder::createCanonicalLoop ( const LocationDescription Loc,
LoopBodyGenCallbackTy  BodyGenCB,
Value Start,
Value Stop,
Value Step,
bool  IsSigned,
bool  InclusiveStop,
InsertPointTy  ComputeIP = {},
const Twine Name = "loop" 
)

Generator for the control flow structure of an OpenMP canonical loop.

Instead of a logical iteration space, this allows specifying user-defined loop counter values using increment, upper- and lower bounds. To disambiguate the terminology when counting downwards, instead of lower bounds we use Start for the loop counter value in the first body iteration.

Consider the following limitations:

  • A loop counter space over all integer values of its bit-width cannot be represented. E.g using uint8_t, its loop trip count of 256 cannot be stored into an 8 bit integer):

    DO I = 0, 255, 1

  • Unsigned wrapping is only supported when wrapping only "once"; E.g. effectively counting downwards:

    for (uint8_t i = 100u; i > 0; i += 127u)

TODO: May need to add additional parameters to represent:

  • Allow representing downcounting with unsigned integers.
  • Sign of the step and the comparison operator might disagree:

    for (int i = 0; i < 42; –i)

    Parameters
    LocThe insert and source location description.
    BodyGenCBCallback that will generate the loop body code.
    StartValue of the loop counter for the first iterations.
    StopLoop counter values past this will stop the the iterations.
    StepLoop counter increment after each iteration; negative means counting down.
    IsSignedWhether Start, Stop and Stop are signed integers.
    InclusiveStopWhether Stop itself is a valid value for the loop counter.
    ComputeIPInsertion point for instructions computing the trip count. Can be used to ensure the trip count is available at the outermost loop of a loop nest. If not set, defaults to the preheader of the generated loop.
    NameBase name used to derive BB and instruction names.
    Returns
    An object representing the created control flow structure which can be used for loop-associated directives.
  • A Step of INT_MIN cannot not be normalized to a positive direction:

Definition at line 1176 of file OMPIRBuilder.cpp.

◆ createCanonicalLoop() [2/2]

CanonicalLoopInfo * OpenMPIRBuilder::createCanonicalLoop ( const LocationDescription Loc,
LoopBodyGenCallbackTy  BodyGenCB,
Value TripCount,
const Twine Name = "loop" 
)

Generator for the control flow structure of an OpenMP canonical loop.

This generator operates on the logical iteration space of the loop, i.e. the caller only has to provide a loop trip count of the loop as defined by base language semantics. The trip count is interpreted as an unsigned integer. The induction variable passed to BodyGenCB will be of the same type and run from 0 to TripCount - 1. It is up to the callback to convert the logical iteration variable to the loop counter variable in the loop body.

Parameters
LocThe insert and source location description. The insert location can be between two instructions or the end of a degenerate block (e.g. a BB under construction).
BodyGenCBCallback that will generate the loop body code.
TripCountNumber of iterations the loop body is executed.
NameBase name used to derive BB and instruction names.
Returns
An object representing the created control flow structure which can be used for loop-associated directives.

Definition at line 1145 of file OMPIRBuilder.cpp.

References llvm::CanonicalLoopInfo::assertOK(), BB, llvm::BasicBlock::begin(), Builder, llvm::OpenMPIRBuilder::LocationDescription::DL, llvm::CanonicalLoopInfo::getAfter(), llvm::CanonicalLoopInfo::getBodyIP(), llvm::CanonicalLoopInfo::getIndVar(), llvm::BasicBlock::getInstList(), llvm::OpenMPIRBuilder::LocationDescription::IP, and llvm::BasicBlock::replaceSuccessorsPhiUsesWith().

◆ createCopyinClauseBlocks()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createCopyinClauseBlocks ( InsertPointTy  IP,
Value MasterAddr,
Value PrivateAddr,
llvm::IntegerType IntPtrTy,
bool  BranchtoEnd = true 
)

Generate conditional branch and relevant BasicBlocks through which private threads copy the 'copyin' variables from Master copy to threadprivate copies.

Parameters
IPinsertion block for copyin conditional
MasterVarPtra pointer to the master variable
PrivateVarPtra pointer to the threadprivate variable
IntPtrTyPointer size type
BranchtoEndCreate a branch between the copyin.not.master blocks
Returns
The insertion point where copying operation to be emitted.

Definition at line 2096 of file OMPIRBuilder.cpp.

References Builder, cmp, llvm::BasicBlock::Create(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), M, and llvm::BasicBlock::splitBasicBlock().

◆ createCopyPrivate()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createCopyPrivate ( const LocationDescription Loc,
llvm::Value BufSize,
llvm::Value CpyBuf,
llvm::Value CpyFn,
llvm::Value DidIt 
)

Generator for __kmpc_copyprivate.

Parameters
LocThe source location description.
BufSizeNumber of elements in the buffer.
CpyBufList of pointers to data to be copied.
CpyFnfunction to call for copying data.
DidItflag variable; 1 for 'single' thread, 0 otherwise.
Returns
The insertion position after the CopyPrivate call.

Definition at line 1875 of file OMPIRBuilder.cpp.

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

◆ createCritical()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createCritical ( const LocationDescription Loc,
BodyGenCallbackTy  BodyGenCB,
FinalizeCallbackTy  FiniCB,
StringRef  CriticalName,
Value HintInst 
)

Generator for '#omp critical'.

Parameters
LocThe insert and source location description.
BodyGenCBCallback that will generate the region body code.
FiniCBCallback to finalize variable copies.
CriticalNamename of the lock used by the critical directive
HintInstHint Instruction for hint clause associated with critical
Returns
The insertion position after the master.

Definition at line 1930 of file OMPIRBuilder.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::sys::path::begin(), Builder, llvm::sys::path::end(), and llvm::OpenMPIRBuilder::LocationDescription::IP.

◆ createDynamicWorkshareLoop()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createDynamicWorkshareLoop ( const LocationDescription Loc,
CanonicalLoopInfo CLI,
InsertPointTy  AllocaIP,
omp::OMPScheduleType  SchedType,
bool  NeedsBarrier,
Value Chunk = nullptr 
)

Modifies the canonical loop to be a dynamically-scheduled workshare loop.

This takes a LoopInfo representing a canonical loop, such as the one created by createCanonicalLoop and emits additional instructions to turn it into a workshare loop. In particular, it calls to an OpenMP runtime function in the preheader to obtain, and then in each iteration to update the loop counter.

Parameters
LocThe source location description, the insertion location is not used.
CLIA descriptor of the canonical loop to workshare.
AllocaIPAn insertion point for Alloca instructions usable in the preheader of the loop.
SchedTypeType of scheduling to be passed to the init function.
NeedsBarrierIndicates whether a barrier must be insterted after the loop.
ChunkThe size of loop chunk considered as a unit when scheduling. If nullptr, defaults to 1.
Returns
Point where to insert code after the loop.

Definition at line 1398 of file OMPIRBuilder.cpp.

References assert(), llvm::BasicBlock::back(), llvm::MCID::Branch, Builder, Cond, llvm::BasicBlock::Create(), llvm::OpenMPIRBuilder::LocationDescription::DL, llvm::BasicBlock::front(), llvm::ConstantInt::get(), llvm::CanonicalLoopInfo::getAfterIP(), llvm::CanonicalLoopInfo::getCond(), llvm::BasicBlock::getContext(), llvm::CanonicalLoopInfo::getExit(), llvm::BasicBlock::getFirstInsertionPt(), llvm::CanonicalLoopInfo::getHeader(), llvm::CanonicalLoopInfo::getIndVar(), llvm::Type::getInt32Ty(), getKmpcForDynamicInitForType(), getKmpcForDynamicNextForType(), llvm::Value::getName(), llvm::BasicBlock::getParent(), llvm::CanonicalLoopInfo::getPreheader(), llvm::BasicBlock::getTerminator(), llvm::CanonicalLoopInfo::getTripCount(), llvm::Value::getType(), llvm::CmpInst::ICMP_NE, M, and llvm::M68kBeads::Term.

◆ createFlush()

void OpenMPIRBuilder::createFlush ( const LocationDescription Loc)

Generator for '#omp flush'.

Parameters
LocThe location where the flush directive was encountered

Definition at line 852 of file OMPIRBuilder.cpp.

◆ createLoopSkeleton()

CanonicalLoopInfo * OpenMPIRBuilder::createLoopSkeleton ( DebugLoc  DL,
Value TripCount,
Function F,
BasicBlock PreInsertBefore,
BasicBlock PostInsertBefore,
const Twine Name = {} 
)

Create the control flow structure of a canonical OpenMP loop.

The emitted loop will be disconnected, i.e. no edge to the loop's preheader and no terminator in the AfterBB. The OpenMPIRBuilder's IRBuilder location is not preserved.

Parameters
DLDebugLoc used for the instructions in the skeleton.
TripCountValue to be used for the trip count.
FFunction in which to insert the BasicBlocks.
PreInsertBeforeWhere to insert BBs that execute before the body, typically the body itself.
PostInsertBeforeWhere to insert BBs that execute after the body.
NameBase name used to derive BB and instruction names.
Returns
The CanonicalLoopInfo that represents the emitted loop.

Definition at line 1073 of file OMPIRBuilder.cpp.

References llvm::PHINode::addIncoming(), llvm::CanonicalLoopInfo::assertOK(), Builder, Cond, llvm::BasicBlock::Create(), DL, F, llvm::ConstantInt::get(), llvm::Value::getType(), and M.

◆ createMasked()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createMasked ( const LocationDescription Loc,
BodyGenCallbackTy  BodyGenCB,
FinalizeCallbackTy  FiniCB,
Value Filter 
)

Generator for '#omp masked'.

Parameters
LocThe insert and source location description.
BodyGenCBCallback that will generate the region code.
FiniCBCallback to finialize variable copies.
Returns
The insertion position after the master.

Definition at line 1050 of file OMPIRBuilder.cpp.

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

◆ createMaster()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createMaster ( const LocationDescription Loc,
BodyGenCallbackTy  BodyGenCB,
FinalizeCallbackTy  FiniCB 
)

Generator for '#omp master'.

Parameters
LocThe insert and source location description.
BodyGenCBCallback that will generate the region code.
FiniCBCallback to finalize variable copies.
Returns
The insertion position after the master.

Definition at line 1026 of file OMPIRBuilder.cpp.

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

◆ createOffloadMapnames()

GlobalVariable * OpenMPIRBuilder::createOffloadMapnames ( SmallVectorImpl< llvm::Constant * > &  Names,
std::string  VarName 
)

◆ createOffloadMaptypes()

GlobalVariable * OpenMPIRBuilder::createOffloadMaptypes ( SmallVectorImpl< uint64_t > &  Mappings,
std::string  VarName 
)

Create the global variable holding the offload mappings information.

Definition at line 2309 of file OMPIRBuilder.cpp.

References llvm::ConstantDataArray::get(), llvm::Value::getType(), llvm::GlobalValue::Global, M, Mappings, llvm::GlobalValue::PrivateLinkage, and llvm::tgtok::VarName.

◆ createOMPAlloc()

CallInst * OpenMPIRBuilder::createOMPAlloc ( const LocationDescription Loc,
Value Size,
Value Allocator,
std::string  Name = "" 
)

Create a runtime call for kmpc_Alloc.

Parameters
LocThe insert and source location description.
SizeSize of allocated memory space
AllocatorAllocator information instruction
NameName of call Instruction for OMP_alloc
Returns
CallInst to the OMP_Alloc call

Definition at line 2146 of file OMPIRBuilder.cpp.

References Allocator, llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, llvm::OpenMPIRBuilder::LocationDescription::IP, and llvm::Check::Size.

◆ createOMPFree()

CallInst * OpenMPIRBuilder::createOMPFree ( const LocationDescription Loc,
Value Addr,
Value Allocator,
std::string  Name = "" 
)

Create a runtime call for kmpc_free.

Parameters
LocThe insert and source location description.
AddrAddress of memory space to be freed
AllocatorAllocator information instruction
NameName of call Instruction for OMP_Free
Returns
CallInst to the OMP_Free call

Definition at line 2162 of file OMPIRBuilder.cpp.

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

◆ createParallel()

IRBuilder::InsertPoint OpenMPIRBuilder::createParallel ( const LocationDescription Loc,
InsertPointTy  AllocaIP,
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.
AllocaIPThe insertion points to be used for alloca instructions.
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 480 of file OMPIRBuilder.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::CallBase::arg_begin(), llvm::CallBase::arg_end(), llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), BB, llvm::sys::path::begin(), llvm::BasicBlock::begin(), Builder, llvm::OpenMPIRBuilder::OutlineInfo::collectBlocks(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::MDBuilder::createCallbackEncoding(), llvm::dbgs(), llvm::SetVector< T, Vector, Set >::empty(), llvm::sys::path::end(), llvm::BasicBlock::end(), llvm::OpenMPIRBuilder::OutlineInfo::EntryBB, llvm::Instruction::eraseFromParent(), llvm::OpenMPIRBuilder::OutlineInfo::ExitBB, F, llvm::CodeExtractor::findAllocas(), llvm::CodeExtractor::findInputsOutputs(), llvm::ConstantInt::get(), llvm::MDNode::get(), llvm::CallBase::getCalledFunction(), llvm::FunctionCallee::getCallee(), llvm::BasicBlock::getFirstInsertionPt(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::Constant::getNullValue(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), I, llvm::OpenMPIRBuilder::LocationDescription::IP, LLVM_DEBUG, move, llvm::OpenMPIRBuilder::OutlineInfo::PostOutlineCB, llvm::Instruction::removeFromParent(), llvm::Value::setName(), llvm::BasicBlock::splitBasicBlock(), llvm::SplitBlock(), llvm::SplitBlockAndInsertIfThenElse(), and Uses.

◆ createSection()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createSection ( const LocationDescription Loc,
BodyGenCallbackTy  BodyGenCB,
FinalizeCallbackTy  FiniCB 
)

Generator for '#omp section'.

Parameters
LocThe insert and source location description.
BodyGenCBCallback that will generate the region body code.
FiniCBCallback to finalize variable copies.
Returns
The insertion position after the section.

Definition at line 991 of file OMPIRBuilder.cpp.

References Builder, I, and llvm::OpenMPIRBuilder::LocationDescription::IP.

◆ createSections()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createSections ( const LocationDescription Loc,
InsertPointTy  AllocaIP,
ArrayRef< StorableBodyGenCallbackTy SectionCBs,
PrivatizeCallbackTy  PrivCB,
FinalizeCallbackTy  FiniCB,
bool  IsCancellable,
bool  IsNowait 
)

Generator for '#omp sections'.

Parameters
LocThe insert and source location description.
AllocaIPThe insertion points to be used for alloca instructions.
SectionCBsCallbacks that will generate body of each section.
PrivCBCallback to copy a given variable (think copy constructor).
FiniCBCallback to finalize variable copies.
IsCancellableFlag to indicate a cancellable parallel region.
IsNowaitIf true, barrier - to ensure all sections are executed before moving forward will not be generated.
Returns
The insertion position after the sections.

Definition at line 893 of file OMPIRBuilder.cpp.

References llvm::SwitchInst::addCase(), assert(), Builder, llvm::BasicBlock::Create(), llvm::Instruction::eraseFromParent(), llvm::ConstantInt::get(), llvm::Type::getInt32Ty(), llvm::BasicBlock::getTerminator(), I, llvm::OpenMPIRBuilder::LocationDescription::IP, M, llvm::ArrayRef< T >::size(), llvm::BasicBlock::splitBasicBlock(), and llvm::ARM_MB::ST.

◆ createSingle()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createSingle ( const LocationDescription Loc,
BodyGenCallbackTy  BodyGenCB,
FinalizeCallbackTy  FiniCB,
llvm::Value DidIt 
)

Generator for '#omp single'.

Parameters
LocThe source location description.
BodyGenCBCallback that will generate the region code.
FiniCBCallback to finalize variable copies.
DidItLocal variable used as a flag to indicate 'single' thread
Returns
The insertion position after the single call.

Definition at line 1896 of file OMPIRBuilder.cpp.

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

◆ createStaticWorkshareLoop()

CanonicalLoopInfo * OpenMPIRBuilder::createStaticWorkshareLoop ( const LocationDescription Loc,
CanonicalLoopInfo CLI,
InsertPointTy  AllocaIP,
bool  NeedsBarrier,
Value Chunk = nullptr 
)

Modifies the canonical loop to be a statically-scheduled workshare loop.

This takes a LoopInfo representing a canonical loop, such as the one created by createCanonicalLoop and emits additional instructions to turn it into a workshare loop. In particular, it calls to an OpenMP runtime function in the preheader to obtain the loop bounds to be used in the current thread, updates the relevant instructions in the canonical loop and calls to an OpenMP runtime finalization function after the loop.

Parameters
LocThe source location description, the insertion location is not used.
CLIA descriptor of the canonical loop to workshare.
AllocaIPAn insertion point for Alloca instructions usable in the preheader of the loop.
NeedsBarrierIndicates whether a barrier must be inserted after the loop.
ChunkThe size of loop chunk considered as a unit when scheduling. If nullptr, defaults to 1.
Returns
Updated CanonicalLoopInfo.

Definition at line 1274 of file OMPIRBuilder.cpp.

References llvm::CanonicalLoopInfo::assertOK(), Builder, llvm::OpenMPIRBuilder::LocationDescription::DL, llvm::ConstantInt::get(), llvm::CanonicalLoopInfo::getBody(), llvm::CanonicalLoopInfo::getCond(), llvm::CanonicalLoopInfo::getExit(), llvm::BasicBlock::getFirstInsertionPt(), llvm::CanonicalLoopInfo::getIndVar(), llvm::Type::getInt32Ty(), llvm::ilist_node_impl< OptionsT >::getIterator(), getKmpcForStaticInitForType(), llvm::CanonicalLoopInfo::getLatch(), llvm::BasicBlock::getParent(), llvm::CanonicalLoopInfo::getPreheader(), llvm::BasicBlock::getTerminator(), llvm::CanonicalLoopInfo::getTripCount(), llvm::Value::getType(), llvm::Use::getUser(), M, llvm::Value::replaceUsesWithIf(), setCanonicalLoopTripCount(), and llvm::omp::Static.

◆ createTargetDeinit()

void OpenMPIRBuilder::createTargetDeinit ( const LocationDescription Loc,
bool  IsSPMD,
bool  RequiresFullRuntime 
)

Create a runtime call for kmpc_target_deinit.

Parameters
LocThe insert and source location description.
IsSPMDFlag to indicate if the kernel is an SPMD kernel or not.
RequiresFullRuntimeIndicate if a full device runtime is necessary.

Definition at line 2243 of file OMPIRBuilder.cpp.

References Builder, and llvm::ConstantInt::getBool().

◆ createTargetInit()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTargetInit ( const LocationDescription Loc,
bool  IsSPMD,
bool  RequiresFullRuntime 
)

The omp target interface.

For more information about the usage of this interface,

See also
openmp/libomptarget/deviceRTLs/common/include/target.h

{ Create a runtime call for kmpc_target_init

Parameters
LocThe insert and source location description.
IsSPMDFlag to indicate if the kernel is an SPMD kernel or not.
RequiresFullRuntimeIndicate if a full device runtime is necessary.

Definition at line 2196 of file OMPIRBuilder.cpp.

References Builder, llvm::BasicBlock::Create(), llvm::ConstantInt::get(), llvm::ConstantInt::getBool(), llvm::BasicBlock::getContext(), llvm::BasicBlock::getFirstInsertionPt(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::OpenMPIRBuilder::LocationDescription::IP, and llvm::BasicBlock::splitBasicBlock().

◆ createTaskwait()

void OpenMPIRBuilder::createTaskwait ( const LocationDescription Loc)

Generator for '#omp taskwait'.

Parameters
LocThe location where the taskwait directive was encountered.

Definition at line 870 of file OMPIRBuilder.cpp.

◆ createTaskyield()

void OpenMPIRBuilder::createTaskyield ( const LocationDescription Loc)

Generator for '#omp taskyield'.

Parameters
LocThe location where the taskyield directive was encountered.

Definition at line 887 of file OMPIRBuilder.cpp.

◆ createWorkshareLoop()

CanonicalLoopInfo * OpenMPIRBuilder::createWorkshareLoop ( const LocationDescription Loc,
CanonicalLoopInfo CLI,
InsertPointTy  AllocaIP,
bool  NeedsBarrier 
)

Modifies the canonical loop to be a workshare loop.

This takes a LoopInfo representing a canonical loop, such as the one created by createCanonicalLoop and emits additional instructions to turn it into a workshare loop. In particular, it calls to an OpenMP runtime function in the preheader to obtain the loop bounds to be used in the current thread, updates the relevant instructions in the canonical loop and calls to an OpenMP runtime finalization function after the loop.

Parameters
LocThe source location description, the insertion location is not used.
CLIA descriptor of the canonical loop to workshare.
AllocaIPAn insertion point for Alloca instructions usable in the preheader of the loop.
NeedsBarrierIndicates whether a barrier must be insterted after the loop.
Returns
Updated CanonicalLoopInfo.

Definition at line 1359 of file OMPIRBuilder.cpp.

◆ emitBarrierImpl()

OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitBarrierImpl ( const LocationDescription Loc,
omp::Directive  DK,
bool  ForceSimpleCall,
bool  CheckCancelFlag 
)

Generate a barrier runtime call.

Parameters
LocThe location at which the request originated and is fulfilled.
DKThe directive which 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 344 of file OMPIRBuilder.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, and Builder.

◆ emitCancelationCheckImpl()

void OpenMPIRBuilder::emitCancelationCheckImpl ( Value CancelFlag,
omp::Directive  CanceledDirective,
FinalizeCallbackTy  ExitCB = {} 
)

Generate control flow and cleanup for cancellation.

Parameters
CancelFlagFlag indicating if the cancellation is performed.
CanceledDirectiveThe kind of directive that is cancled.
ExitCBExtra code to be generated in the exit block.

Definition at line 441 of file OMPIRBuilder.cpp.

References assert(), BB, llvm::BasicBlock::begin(), Builder, llvm::BasicBlock::Create(), and llvm::SplitBlock().

◆ emitFlush()

void OpenMPIRBuilder::emitFlush ( const LocationDescription Loc)

Generate a flush runtime call.

Parameters
LocThe location at which the request originated and is fulfilled.

Definition at line 844 of file OMPIRBuilder.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, and Builder.

◆ emitTaskwaitImpl()

void OpenMPIRBuilder::emitTaskwaitImpl ( const LocationDescription Loc)

Generate a taskwait runtime call.

Parameters
LocThe location at which the request originated and is fulfilled.

Definition at line 858 of file OMPIRBuilder.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, and Builder.

◆ emitTaskyieldImpl()

void OpenMPIRBuilder::emitTaskyieldImpl ( const LocationDescription Loc)

Generate a taskyield runtime call.

Parameters
LocThe location at which the request originated and is fulfilled.

Definition at line 876 of file OMPIRBuilder.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, and llvm::Constant::getNullValue().

◆ finalize()

void OpenMPIRBuilder::finalize ( Function Fn = nullptr,
bool  AllowExtractorSinking = false 
)

Finalize the underlying module, e.g., by outlining regions.

Parameters
FnThe function to be finalized. If not used, all functions are finalized.
AllowExtractorSinkingFlag to include sinking instructions, emitted by CodeExtractor, in the outlined region. Default is false.

Definition at line 142 of file OMPIRBuilder.cpp.

References assert(), llvm::BasicBlock::begin(), llvm::SmallPtrSetImplBase::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::dbgs(), llvm::BasicBlock::empty(), llvm::CodeExtractor::extractCodeRegion(), llvm::Function::getEntryBlock(), llvm::Function::getFunction(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Function::getReturnType(), llvm::BasicBlock::getUniqueSuccessor(), llvm::CodeExtractor::isEligible(), llvm::Type::isVoidTy(), LLVM_DEBUG, M, and llvm::Function::removeFromParent().

◆ getInsertionPoint()

InsertPointTy llvm::OpenMPIRBuilder::getInsertionPoint ( )
inline

}

Return the insertion point used by the underlying IRBuilder.

Definition at line 492 of file OMPIRBuilder.h.

References Builder, and llvm::IRBuilderBase::saveIP().

◆ getLanemaskType()

Type * OpenMPIRBuilder::getLanemaskType ( )

◆ getOrCreateDefaultSrcLocStr()

Constant * OpenMPIRBuilder::getOrCreateDefaultSrcLocStr ( )

Return the (LLVM-IR) string describing the default source location.

Definition at line 309 of file OMPIRBuilder.cpp.

◆ getOrCreateIdent()

Value * OpenMPIRBuilder::getOrCreateIdent ( Constant SrcLocStr,
omp::IdentFlag  Flags = omp::IdentFlag(0),
unsigned  Reserve2Flags = 0 
)

Return an ident_t* encoding the source location SrcLocStr and Flags.

TODO: Create a enum class for the Reserve2Flags

Definition at line 231 of file OMPIRBuilder.cpp.

References Align, Builder, llvm::ConstantInt::get(), llvm::ConstantStruct::get(), llvm::Constant::getNullValue(), llvm::GlobalValue::Global, M, and llvm::GlobalValue::PrivateLinkage.

◆ getOrCreateRuntimeFunction()

FunctionCallee OpenMPIRBuilder::getOrCreateRuntimeFunction ( Module M,
omp::RuntimeFunction  FnID 
)

◆ getOrCreateRuntimeFunctionPtr()

Function * OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr ( omp::RuntimeFunction  FnID)

Definition at line 133 of file OMPIRBuilder.cpp.

References assert(), llvm::FunctionCallee::getCallee(), and M.

◆ getOrCreateSrcLocStr() [1/3]

Constant * OpenMPIRBuilder::getOrCreateSrcLocStr ( const LocationDescription Loc)

Return the (LLVM-IR) string describing the source location Loc.

Definition at line 314 of file OMPIRBuilder.cpp.

References llvm::OpenMPIRBuilder::LocationDescription::DL, llvm::Function::empty(), llvm::DebugLoc::get(), llvm::OpenMPIRBuilder::LocationDescription::IP, M, and llvm::Sched::Source.

◆ getOrCreateSrcLocStr() [2/3]

Constant * OpenMPIRBuilder::getOrCreateSrcLocStr ( StringRef  FunctionName,
StringRef  FileName,
unsigned  Line,
unsigned  Column 
)

Return the (LLVM-IR) string describing the source location identified by the arguments.

Definition at line 291 of file OMPIRBuilder.cpp.

References llvm::SmallString< InternalLen >::append(), llvm::SmallString< InternalLen >::str(), and llvm::to_string().

◆ getOrCreateSrcLocStr() [3/3]

Constant * OpenMPIRBuilder::getOrCreateSrcLocStr ( StringRef  LocStr)

Return the (LLVM-IR) string describing the source location LocStr.

Definition at line 272 of file OMPIRBuilder.cpp.

References Builder, llvm::ConstantExpr::getPointerCast(), llvm::ConstantDataArray::getString(), and M.

◆ getOrCreateThreadID()

Value * OpenMPIRBuilder::getOrCreateThreadID ( Value Ident)

Return the current thread ID.

Parameters
IdentThe ident (ident_t*) describing the query origin.

Definition at line 329 of file OMPIRBuilder.cpp.

References Builder.

◆ initialize()

void OpenMPIRBuilder::initialize ( )

Initialize the internal state, this will put structures types and potentially other helpers into the underlying module.

Must be called before any other method and only once!

Definition at line 140 of file OMPIRBuilder.cpp.

References M.

◆ isLastFinalizationInfoCancellable()

bool llvm::OpenMPIRBuilder::isLastFinalizationInfoCancellable ( omp::Directive  DK)
inline

Return true if the last entry in the finalization stack is of kind DK and cancellable.

Definition at line 564 of file OMPIRBuilder.h.

References FinalizationStack.

◆ 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 88 of file OMPIRBuilder.h.

References FinalizationStack.

◆ 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 81 of file OMPIRBuilder.h.

References FinalizationStack.

◆ tileLoops()

std::vector< CanonicalLoopInfo * > OpenMPIRBuilder::tileLoops ( DebugLoc  DL,
ArrayRef< CanonicalLoopInfo * >  Loops,
ArrayRef< Value * >  TileSizes 
)

Tile a loop nest.

Tiles the loops of Loops by the tile sizes in TileSizes. Loops in / Loops must be perfectly nested, from outermost to innermost loop (i.e. Loops.front() is the outermost loop). The trip count llvm::Value of every loop and every tile sizes must be usable in the outermost loop's preheader. This implies that the loop nest is rectangular.

Example:

for (int i = 0; i < 15; ++i) // Canonical loop "i"
for (int j = 0; j < 14; ++j) // Canonical loop "j"
body(i, j);

After tiling with Loops={i,j} and TileSizes={5,7}, the loop is changed to

for (int i1 = 0; i1 < 3; ++i1)
for (int j1 = 0; j1 < 2; ++j1)
for (int i2 = 0; i2 < 5; ++i2)
for (int j2 = 0; j2 < 7; ++j2)
body(i1*3+i2, j1*3+j2);

The returned vector are the loops {i1,j1,i2,j2}. The loops i1 and j1 are referred to the floor, and the loops i2 and j2 are the tiles. Tiling also handles non-constant trip counts, non-constant tile sizes and trip counts that are not multiples of the tile size. In the latter case the tile loop of the last floor-loop iteration will have fewer iterations than specified as its tile size.

Parameters
DLDebug location for instructions added by tiling, for instance the floor- and tile trip count computation.
LoopsLoops to tile. The CanonicalLoopInfo objects are invalidated by this method, i.e. should not used after tiling.
TileSizesFor each loop in Loops, the tile size for that dimensions.
Returns
A list of generated loops. Contains twice as many loops as the input loop nest; the first half are the floor loops and the second half are the tile loops.

Definition at line 1690 of file OMPIRBuilder.cpp.

References assert(), Builder, DL, llvm::SmallVectorImpl< T >::emplace_back(), llvm::enumerate(), F, llvm::ConstantInt::get(), llvm::CanonicalLoopInfo::getAfter(), llvm::CanonicalLoopInfo::getBody(), llvm::CanonicalLoopInfo::getExit(), llvm::CanonicalLoopInfo::getIndVar(), llvm::CanonicalLoopInfo::getLatch(), llvm::BasicBlock::getParent(), llvm::CanonicalLoopInfo::getPreheader(), llvm::CanonicalLoopInfo::getPreheaderIP(), llvm::Value::getType(), i, Loops, P, redirectAllPredecessorsTo(), redirectTo(), removeUnusedBlocksFromParent(), llvm::Value::replaceAllUsesWith(), llvm::SmallVectorImpl< T >::reserve(), Shift, llvm::Check::Size, llvm::ArrayRef< T >::size(), and TileSize.

◆ updateToLocation()

bool llvm::OpenMPIRBuilder::updateToLocation ( const LocationDescription Loc)
inline

Member Data Documentation

◆ Builder

IRBuilder llvm::OpenMPIRBuilder::Builder

The LLVM-IR Builder used to create IR.

Definition at line 589 of file OMPIRBuilder.h.

Referenced by getInsertionPoint(), and updateToLocation().

◆ FinalizationStack

SmallVector<FinalizationInfo, 8> llvm::OpenMPIRBuilder::FinalizationStack

The finalization stack made up of finalize callbacks currently in-flight, wrapped into FinalizationInfo objects that reference also the finalization target block and the kind of cancellable directive.

Definition at line 560 of file OMPIRBuilder.h.

Referenced by isLastFinalizationInfoCancellable(), popFinalizationCB(), and pushFinalizationCB().

◆ IdentMap

DenseMap<std::pair<Constant *, uint64_t>, Value *> llvm::OpenMPIRBuilder::IdentMap

Map to remember existing ident_t*.

Definition at line 595 of file OMPIRBuilder.h.

◆ InternalVars

StringMap<AssertingVH<Constant>, BumpPtrAllocator> llvm::OpenMPIRBuilder::InternalVars

An ordered map of auto-generated variables to their unique names.

It stores variables with the following names: 1) ".gomp_critical_user_" + <critical_section_name> + ".var" for "omp critical" directives; 2) <mangled_name_for_global_var> + ".cache." for cache for threadprivate variables.

Definition at line 628 of file OMPIRBuilder.h.

◆ LoopInfos

std::forward_list<CanonicalLoopInfo> llvm::OpenMPIRBuilder::LoopInfos

Collection of owned canonical loop objects that eventually need to be free'd.

Definition at line 618 of file OMPIRBuilder.h.

◆ M

Module& llvm::OpenMPIRBuilder::M

The underlying LLVM-IR module.

Definition at line 586 of file OMPIRBuilder.h.

◆ OutlineInfos

SmallVector<OutlineInfo, 16> llvm::OpenMPIRBuilder::OutlineInfos

Collection of regions that need to be outlined during finalization.

Definition at line 614 of file OMPIRBuilder.h.

Referenced by addOutlineInfo().

◆ SrcLocStrMap

StringMap<Constant *> llvm::OpenMPIRBuilder::SrcLocStrMap

Map to remember source location strings.

Definition at line 592 of file OMPIRBuilder.h.


The documentation for this class was generated from the following files:
i
i
Definition: README.txt:29
i1
Decimal Convert From to National Zoned Signed int_ppc_altivec_bcdcfno i1
Definition: README_P9.txt:147
j
return j(j<< 16)