LLVM
15.0.0git
|
An interface to create LLVM-IR for OpenMP directives. More...
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
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 | MapperAllocas |
struct | OutlineInfo |
Helper that contains information about regions we need to outline during finalization. More... | |
struct | ReductionInfo |
Information about an OpenMP reduction. 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)> |
Callback type for body (=inner region) code generation. More... | |
using | StorableBodyGenCallbackTy = std::function< void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)> |
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... | |
using | ReductionGenTy = function_ref< InsertPointTy(InsertPointTy, Value *, Value *, Value *&)> |
Functions used to generate reductions. More... | |
using | AtomicReductionGenTy = function_ref< InsertPointTy(InsertPointTy, Type *, Value *, Value *)> |
Functions used to generate atomic reductions. 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) |
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... | |
CanonicalLoopInfo * | createCanonicalLoop (const LocationDescription &Loc, LoopBodyGenCallbackTy BodyGenCB, Value *TripCount, const Twine &Name="loop") |
Generator for the control flow structure of an OpenMP canonical loop. More... | |
CanonicalLoopInfo * | 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. More... | |
CanonicalLoopInfo * | collapseLoops (DebugLoc DL, ArrayRef< CanonicalLoopInfo * > Loops, InsertPointTy ComputeIP) |
Collapse a loop nest into a single loop. More... | |
InsertPointTy | applyWorkshareLoop (DebugLoc DL, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP, bool NeedsBarrier, llvm::omp::ScheduleKind SchedKind=llvm::omp::OMP_SCHEDULE_Default, Value *ChunkSize=nullptr, bool HasSimdModifier=false, bool HasMonotonicModifier=false, bool HasNonmonotonicModifier=false, bool HasOrderedClause=false) |
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 | unrollLoopFull (DebugLoc DL, CanonicalLoopInfo *Loop) |
Fully unroll a loop. More... | |
void | unrollLoopHeuristic (DebugLoc DL, CanonicalLoopInfo *Loop) |
Fully or partially unroll a loop. More... | |
void | unrollLoopPartial (DebugLoc DL, CanonicalLoopInfo *Loop, int32_t Factor, CanonicalLoopInfo **UnrolledCLI) |
Partially unroll a loop. More... | |
void | applySimd (DebugLoc DL, CanonicalLoopInfo *Loop) |
Add metadata to simd-ize a loop. 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 | createTask (const LocationDescription &Loc, InsertPointTy AllocaIP, BodyGenCallbackTy BodyGenCB, bool Tied=true, Value *Final=nullptr) |
Generator for #omp task More... | |
InsertPointTy | createReductions (const LocationDescription &Loc, InsertPointTy AllocaIP, ArrayRef< ReductionInfo > ReductionInfos, bool IsNoWait=false) |
Generator for '#omp reduction'. 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... | |
Function * | getOrCreateRuntimeFunctionPtr (omp::RuntimeFunction FnID) |
Constant * | getOrCreateSrcLocStr (StringRef LocStr, uint32_t &SrcLocStrSize) |
Return the (LLVM-IR) string describing the source location LocStr . More... | |
Constant * | getOrCreateDefaultSrcLocStr (uint32_t &SrcLocStrSize) |
Return the (LLVM-IR) string describing the default source location. More... | |
Constant * | getOrCreateSrcLocStr (StringRef FunctionName, StringRef FileName, unsigned Line, unsigned Column, uint32_t &SrcLocStrSize) |
Return the (LLVM-IR) string describing the source location identified by the arguments. More... | |
Constant * | getOrCreateSrcLocStr (DebugLoc DL, uint32_t &SrcLocStrSize, Function *F=nullptr) |
Return the (LLVM-IR) string describing the DebugLoc DL . More... | |
Constant * | getOrCreateSrcLocStr (const LocationDescription &Loc, uint32_t &SrcLocStrSize) |
Return the (LLVM-IR) string describing the source location Loc . More... | |
Constant * | getOrCreateIdent (Constant *SrcLocStr, uint32_t SrcLocStrSize, omp::IdentFlag Flags=omp::IdentFlag(0), unsigned Reserve2Flags=0) |
Return an ident_t* encoding the source location SrcLocStr and Flags . More... | |
GlobalValue * | createGlobalFlag (unsigned Value, StringRef Name) |
Create a hidden global flag Name in the module with initial value Value . More... | |
void | emitOffloadingEntry (Constant *Addr, StringRef Name, uint64_t Size, int32_t Flags, StringRef SectionName="omp_offloading_entries") |
Create an offloading section struct used to register this global at runtime. More... | |
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... | |
Value * | getOrCreateThreadID (Value *Ident) |
Return the current thread ID. More... | |
void | addOutlineInfo (OutlineInfo &&OI) |
Add a new region that will be outlined later. More... | |
GlobalVariable * | createOffloadMaptypes (SmallVectorImpl< uint64_t > &Mappings, std::string VarName) |
Create the global variable holding the offload mappings information. More... | |
GlobalVariable * | createOffloadMapnames (SmallVectorImpl< llvm::Constant * > &Names, std::string VarName) |
Create the global variable holding the offload names information. More... | |
void | createMapperAllocas (const LocationDescription &Loc, InsertPointTy AllocaIP, unsigned NumOperands, struct MapperAllocas &MapperAllocas) |
Create the allocas instruction used in call to mapper functions. More... | |
void | emitMapperCall (const LocationDescription &Loc, Function *MapperFunc, Value *SrcLocInfo, Value *MaptypesArg, Value *MapnamesArg, struct MapperAllocas &MapperAllocas, int64_t DeviceID, unsigned NumOperands) |
Create the call for the target mapper function. 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, bool IsNowait, 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 | createOrderedDepend (const LocationDescription &Loc, InsertPointTy AllocaIP, unsigned NumLoops, ArrayRef< llvm::Value * > StoreValues, const Twine &Name, bool IsDependSource) |
Generator for '#omp ordered depend (source | sink)'. More... | |
InsertPointTy | createOrderedThreadsSimd (const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, bool IsThreads) |
Generator for '#omp ordered [threads | simd]'. 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... | |
CallInst * | createOMPAlloc (const LocationDescription &Loc, Value *Size, Value *Allocator, std::string Name="") |
Create a runtime call for kmpc_Alloc. More... | |
CallInst * | createOMPFree (const LocationDescription &Loc, Value *Addr, Value *Allocator, std::string Name="") |
Create a runtime call for kmpc_free. More... | |
CallInst * | createCachedThreadPrivate (const LocationDescription &Loc, llvm::Value *Pointer, llvm::ConstantInt *Size, const llvm::Twine &Name=Twine("")) |
Create a runtime call for kmpc_threadprivate_cached. More... | |
CallInst * | createOMPInteropInit (const LocationDescription &Loc, Value *InteropVar, omp::OMPInteropType InteropType, Value *Device, Value *NumDependences, Value *DependenceAddress, bool HaveNowaitClause) |
Create a runtime call for __tgt_interop_init. More... | |
CallInst * | createOMPInteropDestroy (const LocationDescription &Loc, Value *InteropVar, Value *Device, Value *NumDependences, Value *DependenceAddress, bool HaveNowaitClause) |
Create a runtime call for __tgt_interop_destroy. More... | |
CallInst * | createOMPInteropUse (const LocationDescription &Loc, Value *InteropVar, Value *Device, Value *NumDependences, Value *DependenceAddress, bool HaveNowaitClause) |
Create a runtime call for __tgt_interop_use. 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, InsertPointTy AllocaIP, AtomicOpValue &X, Value *Expr, AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp, AtomicUpdateCallbackTy &UpdateOp, bool IsXBinopExpr) |
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, InsertPointTy AllocaIP, AtomicOpValue &X, AtomicOpValue &V, Value *Expr, AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp, AtomicUpdateCallbackTy &UpdateOp, bool UpdateExpr, bool IsPostfixUpdate, bool IsXBinopExpr) |
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... | |
InsertPointTy | createAtomicCompare (const LocationDescription &Loc, AtomicOpValue &X, AtomicOpValue &V, AtomicOpValue &R, Value *E, Value *D, AtomicOrdering AO, omp::OMPAtomicCompareOp Op, bool IsXBinopExpr, bool IsPostfixUpdate, bool IsFailOnly) |
Emit atomic compare for constructs: — Only scalar data types cond-expr-stmt: x = x ordop expr ? expr : x; x = expr ordop x ? expr : x; x = x == e ? d : x; x = e == x ? d : x; (this one is not in the spec) cond-update-stmt: if (x ordop expr) { x = expr; } if (expr ordop x) { x = expr; } if (x == e) { x = d; } if (e == x) { x = d; } (this one is not in the spec) conditional-update-capture-atomic: v = x; cond-update-stmt; (IsPostfixUpdate=true, IsFailOnly=false) cond-update-stmt; v = x; (IsPostfixUpdate=false, IsFailOnly=false) if (x == e) { x = d; } else { v = x; } (IsPostfixUpdate=false, IsFailOnly=true) r = x == e; if (r) { x = d; } (IsPostfixUpdate=false, IsFailOnly=false) r = x == e; if (r) { x = d; } else { v = x; } (IsPostfixUpdate=false, IsFailOnly=true) More... | |
CanonicalLoopInfo * | createLoopSkeleton (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... | |
Module & | M |
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 >, Constant * > | 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< CanonicalLoopInfo > | LoopInfos |
Collection of owned canonical loop objects that eventually need to be free'd. More... | |
StringMap< AssertingVH< Constant >, BumpPtrAllocator > | InternalVars |
An ordered map of auto-generated variables to their unique names. More... | |
An interface to create LLVM-IR for OpenMP directives.
Each OpenMP directive has a corresponding public generator method.
Definition at line 75 of file OMPIRBuilder.h.
using llvm::OpenMPIRBuilder::AtomicReductionGenTy = function_ref<InsertPointTy(InsertPointTy, Type *, Value *, Value *)> |
Functions used to generate atomic reductions.
Such functions take two Values representing pointers to LHS and RHS of the reduction, as well as the element type of these pointers. They are expected to atomically update the LHS to the reduced value.
Definition at line 644 of file OMPIRBuilder.h.
using llvm::OpenMPIRBuilder::BodyGenCallbackTy = function_ref<void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)> |
Callback type for body (=inner region) code generation.
The callback takes code locations as arguments, each describing a location where additional instructions can be inserted.
The CodeGenIP may be in the middle of a basic block or point to the end of it. The basic block may have a terminator or be degenerate. The callback function may just insert instructions at that position, but also split the block (without the Before argument of BasicBlock::splitBasicBlock such that the identify of the split predecessor block is preserved) and insert additional control flow, including branches that do not lead back to what follows the CodeGenIP. Note that since the callback is allowed to split the block, callers must assume that InsertPoints to positions in the BasicBlock after CodeGenIP including CodeGenIP itself are invalidated. If such InsertPoints need to be preserved, it can split the block itself before calling the callback.
AllocaIP and CodeGenIP must not point to the same position.
AllocaIP | is the insertion point at which new alloca instructions should be placed. The BasicBlock it is pointing to must not be split. |
CodeGenIP | is the insertion point at which the body code should be placed. |
Definition at line 158 of file OMPIRBuilder.h.
using llvm::OpenMPIRBuilder::FinalizeCallbackTy = std::function<void(InsertPointTy CodeGenIP)> |
Callback type for variable finalization (think destructors).
CodeGenIP | is 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 106 of file OMPIRBuilder.h.
using llvm::OpenMPIRBuilder::InsertPointTy = IRBuilder<>::InsertPoint |
Type used throughout for insertion points.
Definition at line 96 of file OMPIRBuilder.h.
using llvm::OpenMPIRBuilder::LoopBodyGenCallbackTy = function_ref<void(InsertPointTy CodeGenIP, Value *IndVar)> |
Callback type for loop body code generation.
CodeGenIP | is 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. |
IndVar | is the induction variable usable at the insertion point. |
Definition at line 176 of file OMPIRBuilder.h.
using llvm::OpenMPIRBuilder::PrivatizeCallbackTy = function_ref<InsertPointTy( InsertPointTy AllocaIP, InsertPointTy CodeGenIP, Value &Original, Value &Inner, Value *&ReplVal)> |
Callback type for variable privatization (think copy & default constructor).
AllocaIP | is the insertion point at which new alloca instructions should be placed. |
CodeGenIP | is the insertion point at which the privatization code should be placed. |
Original | The value being copied/created, should not be used in the generated IR. |
Inner | The 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. |
ReplVal | The replacement value, thus a copy or new created version of Inner . |
ReplVal
the replacement value. Definition at line 198 of file OMPIRBuilder.h.
using llvm::OpenMPIRBuilder::ReductionGenTy = function_ref<InsertPointTy(InsertPointTy, Value *, Value *, Value *&)> |
Functions used to generate reductions.
Such functions take two Values representing LHS and RHS of the reduction, respectively, and a reference to the value that is updated to refer to the reduction result.
Definition at line 637 of file OMPIRBuilder.h.
using llvm::OpenMPIRBuilder::StorableBodyGenCallbackTy = std::function<void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)> |
Definition at line 165 of file OMPIRBuilder.h.
|
inline |
Create a new OpenMPIRBuilder operating on the given module M
.
This will not have an effect on M
(see initialize).
Definition at line 79 of file OMPIRBuilder.h.
OpenMPIRBuilder::~OpenMPIRBuilder | ( | ) |
Definition at line 518 of file OMPIRBuilder.cpp.
References assert().
void OpenMPIRBuilder::addAttributes | ( | omp::RuntimeFunction | FnID, |
Function & | Fn | ||
) |
Add attributes known for FnID
to Fn
.
Definition at line 329 of file OMPIRBuilder.cpp.
References llvm::Function::arg_size(), Attrs, llvm::SmallVectorImpl< T >::emplace_back(), llvm::Function::getAttributes(), and llvm::Function::getContext().
|
inline |
Add a new region that will be outlined later.
Definition at line 907 of file OMPIRBuilder.h.
References OutlineInfos.
void OpenMPIRBuilder::applySimd | ( | DebugLoc | DL, |
CanonicalLoopInfo * | Loop | ||
) |
Add metadata to simd-ize a loop.
DL | Debug location for instructions added by unrolling. |
Loop | The loop to simd-ize. |
Definition at line 2837 of file OMPIRBuilder.cpp.
References addLoopMetadata(), addSimdMetadata(), BB, Builder, F, FAM, llvm::ConstantAsMetadata::get(), llvm::MDString::get(), llvm::MDNode::get(), llvm::LoopBase< BlockT, LoopT >::getBlocks(), llvm::CanonicalLoopInfo::getCond(), llvm::MDNode::getDistinct(), llvm::CanonicalLoopInfo::getFunction(), llvm::CanonicalLoopInfo::getHeader(), llvm::Type::getInt1Ty(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::ConstantInt::getTrue(), llvm::SmallSet< T, N, C >::insert(), llvm::AnalysisManager< IRUnitT, ExtraArgTs >::registerPass(), and llvm::LoopAnalysis::run().
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::applyWorkshareLoop | ( | DebugLoc | DL, |
CanonicalLoopInfo * | CLI, | ||
InsertPointTy | AllocaIP, | ||
bool | NeedsBarrier, | ||
llvm::omp::ScheduleKind | SchedKind = llvm::omp::OMP_SCHEDULE_Default , |
||
llvm::Value * | ChunkSize = nullptr , |
||
bool | HasSimdModifier = false , |
||
bool | HasMonotonicModifier = false , |
||
bool | HasNonmonotonicModifier = false , |
||
bool | HasOrderedClause = false |
||
) |
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.
The concrete transformation is done by applyStaticWorkshareLoop, applyStaticChunkedWorkshareLoop, or applyDynamicWorkshareLoop, depending on the value of SchedKind
and ChunkSize
.
DL | Debug location for instructions added for the workshare-loop construct itself. |
CLI | A descriptor of the canonical loop to workshare. |
AllocaIP | An insertion point for Alloca instructions usable in the preheader of the loop. |
NeedsBarrier | Indicates whether a barrier must be insterted after the loop. |
SchedKind | Scheduling algorithm to use. |
ChunkSize | The chunk size for the inner loop. |
HasSimdModifier | Whether the simd modifier is present in the schedule clause. |
HasMonotonicModifier | Whether the monotonic modifier is present in the schedule clause. |
HasNonmonotonicModifier | Whether the nonmonotonic modifier is present in the schedule clause. |
HasOrderedClause | Whether the (parameterless) ordered clause is present. |
Definition at line 2197 of file OMPIRBuilder.cpp.
References assert(), llvm::omp::BaseAuto, llvm::omp::BaseBalanced, llvm::omp::BaseDynamicChunked, llvm::omp::BaseGreedy, llvm::omp::BaseGuidedAnalyticalChunked, llvm::omp::BaseGuidedChunked, llvm::omp::BaseGuidedIterativeChunked, llvm::omp::BaseGuidedSimd, llvm::omp::BaseRuntime, llvm::omp::BaseRuntimeSimd, llvm::omp::BaseStatic, llvm::omp::BaseStaticBalancedChunked, llvm::omp::BaseStaticChunked, llvm::omp::BaseSteal, computeOpenMPScheduleType(), DL, LLVM_FALLTHROUGH, llvm_unreachable, llvm::omp::ModifierMask, and llvm::omp::ModifierOrdered.
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:
After collapsing with Loops={i,j}, the loop is changed to
In the current implementation, the following limitations apply:
ComputeIP
. Non-rectangular loops are not yet supported.DL | Debug location for instructions added for collapsing, such as instructions to compute/derive the input loop's induction variables. |
Loops | Loops 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. |
ComputeIP | Where additional instruction that compute the collapsed trip count. If not set, defaults to before the generated loop. |
Definition at line 2463 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(), llvm::SmallVectorImpl< T >::reserve(), and llvm::SmallVectorImpl< T >::resize().
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicCapture | ( | const LocationDescription & | Loc, |
InsertPointTy | AllocaIP, | ||
AtomicOpValue & | X, | ||
AtomicOpValue & | V, | ||
Value * | Expr, | ||
AtomicOrdering | AO, | ||
AtomicRMWInst::BinOp | RMWOp, | ||
AtomicUpdateCallbackTy & | UpdateOp, | ||
bool | UpdateExpr, | ||
bool | IsPostfixUpdate, | ||
bool | IsXBinopExpr | ||
) |
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,.
Loc | The insert and source location description. |
AllocaIP | The insertion point to be used for alloca instructions. |
X | The target atomic pointer to be updated |
V | Memory address where to store captured value |
Expr | The value to update X with. |
AO | Atomic ordering of the generated atomic instructions |
RMWOp | The 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. |
UpdateOp | Code generator for complex expressions that cannot be expressed through atomicrmw instruction. |
UpdateExpr | true if X is an in place update of the form X = X BinOp Expr or X = Expr BinOp X |
IsXBinopExpr | true 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) |
IsPostfixUpdate | true if original value of 'x' must be stored in 'v', not an updated one. |
Definition at line 4084 of file OMPIRBuilder.cpp.
References assert(), Builder, 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.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicCompare | ( | const LocationDescription & | Loc, |
AtomicOpValue & | X, | ||
AtomicOpValue & | V, | ||
AtomicOpValue & | R, | ||
Value * | E, | ||
Value * | D, | ||
AtomicOrdering | AO, | ||
omp::OMPAtomicCompareOp | Op, | ||
bool | IsXBinopExpr, | ||
bool | IsPostfixUpdate, | ||
bool | IsFailOnly | ||
) |
Emit atomic compare for constructs: — Only scalar data types cond-expr-stmt: x = x ordop expr ? expr : x; x = expr ordop x ? expr : x; x = x == e ? d : x; x = e == x ? d : x; (this one is not in the spec) cond-update-stmt: if (x ordop expr) { x = expr; } if (expr ordop x) { x = expr; } if (x == e) { x = d; } if (e == x) { x = d; } (this one is not in the spec) conditional-update-capture-atomic: v = x; cond-update-stmt; (IsPostfixUpdate=true, IsFailOnly=false) cond-update-stmt; v = x; (IsPostfixUpdate=false, IsFailOnly=false) if (x == e) { x = d; } else { v = x; } (IsPostfixUpdate=false, IsFailOnly=true) r = x == e; if (r) { x = d; } (IsPostfixUpdate=false, IsFailOnly=false) r = x == e; if (r) { x = d; } else { v = x; } (IsPostfixUpdate=false, IsFailOnly=true)
Loc | The insert and source location description. |
X | The target atomic pointer to be updated. |
V | Memory address where to store captured value (for compare capture only). |
R | Memory address where to store comparison result (for compare capture with '==' only). |
E | The expected value ('e') for forms that use an equality comparison or an expression ('expr') for forms that use 'ordop' (logically an atomic maximum or minimum). |
D | The desired value for forms that use an equality comparison. If forms that use 'ordop', it should be nullptr . |
AO | Atomic ordering of the generated atomic instructions. |
Op | Atomic compare operation. It can only be ==, <, or >. |
IsXBinopExpr | True if the conditional statement is in the form where x is on LHS. It only matters for < or >. |
IsPostfixUpdate | True if original value of 'x' must be stored in 'v', not an updated one (for compare capture only). |
IsFailOnly | True if the original value of 'x' is stored to 'v' only when the comparison fails. This is only valid for the case the comparison is '=='. |
Definition at line 4118 of file OMPIRBuilder.cpp.
References assert(), Builder, Compare, D, E, llvm::OpenMPIRBuilder::AtomicOpValue::ElemTy, llvm::omp::EQ, llvm::Instruction::eraseFromParent(), llvm::AtomicCmpXchgInst::getStrongestFailureOrdering(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::OpenMPIRBuilder::LocationDescription::IP, llvm::Type::isPointerTy(), llvm::OpenMPIRBuilder::AtomicOpValue::IsVolatile, llvm_unreachable, llvm::omp::MAX, llvm::AtomicRMWInst::Max, llvm::omp::MIN, llvm::AtomicRMWInst::Min, llvm::BasicBlock::splitBasicBlock(), llvm::AtomicRMWInst::UMax, llvm::AtomicRMWInst::UMin, llvm::OpenMPIRBuilder::AtomicOpValue::Var, and X.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicRead | ( | const LocationDescription & | Loc, |
AtomicOpValue & | X, | ||
AtomicOpValue & | V, | ||
AtomicOrdering | AO | ||
) |
Emit atomic Read for : V = X — Only Scalar data types.
Loc | The insert and source location description. |
X | The target pointer to be atomically read |
V | Memory address where to store atomically read value |
AO | Atomic ordering of the generated atomic instructions. |
Definition at line 3840 of file OMPIRBuilder.cpp.
References assert(), Builder, llvm::IntegerType::get(), 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.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicUpdate | ( | const LocationDescription & | Loc, |
InsertPointTy | AllocaIP, | ||
AtomicOpValue & | X, | ||
Value * | Expr, | ||
AtomicOrdering | AO, | ||
AtomicRMWInst::BinOp | RMWOp, | ||
AtomicUpdateCallbackTy & | UpdateOp, | ||
bool | IsXBinopExpr | ||
) |
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.
Loc | The insert and source location description. |
AllocaIP | The insertion point to be used for alloca instructions. |
X | The target atomic pointer to be updated |
Expr | The value to update X with. |
AO | Atomic ordering of the generated atomic instructions. |
RMWOp | The 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. |
UpdateOp | Code generator for complex expressions that cannot be expressed through atomicrmw instruction. |
IsXBinopExpr | true 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) |
Definition at line 3915 of file OMPIRBuilder.cpp.
References assert(), Builder, llvm::OpenMPIRBuilder::LocationDescription::IP, isConflictIP(), 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.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicWrite | ( | const LocationDescription & | Loc, |
AtomicOpValue & | X, | ||
Value * | Expr, | ||
AtomicOrdering | AO | ||
) |
Emit atomic write for : X = Expr — Only Scalar data types.
Loc | The insert and source location description. |
X | The target pointer to be atomically written to |
Expr | The value to store. |
AO | Atomic ordering of the generated atomic instructions. |
Definition at line 3882 of file OMPIRBuilder.cpp.
References assert(), Builder, llvm::IntegerType::get(), 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.
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'
Loc | The location where the barrier directive was encountered. |
DK | The kind of directive that caused the barrier. |
ForceSimpleCall | Flag to force a simple (=non-cancellation) barrier. |
CheckCancelFlag | Flag to indicate a cancel barrier return value should be checked and acted upon. |
Definition at line 648 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::LocationDescription::IP.
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.
Loc | The insert and source location description. |
Pointer | pointer to data to be cached |
Size | size of data to be cached |
Name | Name of call Instruction for callinst |
Definition at line 3575 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, and llvm::OpenMPIRBuilder::LocationDescription::IP.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createCancel | ( | const LocationDescription & | Loc, |
Value * | IfCondition, | ||
omp::Directive | CanceledDirective | ||
) |
Generator for '#omp cancel'.
Loc | The location where the directive was encountered. |
IfCondition | The evaluated 'if' clause expression, if any. |
CanceledDirective | The kind of directive that is cancled. |
Definition at line 705 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().
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:
Sign of the step and the comparison operator might disagree:
for (int i = 0; i < 42; i -= 1u)
Loc | The insert and source location description. |
BodyGenCB | Callback that will generate the loop body code. |
Start | Value of the loop counter for the first iterations. |
Stop | Loop counter values past this will stop the loop. |
Step | Loop counter increment after each iteration; negative means counting down. |
IsSigned | Whether Start, Stop and Step are signed integers. |
InclusiveStop | Whether Stop itself is a valid value for the loop counter. |
ComputeIP | Insertion 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. |
Name | Base name used to derive BB and instruction names. |
Step
of INT_MIN cannot not be normalized to a positive direction:Definition at line 1879 of file OMPIRBuilder.cpp.
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.
Loc | The 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). |
BodyGenCB | Callback that will generate the loop body code. |
TripCount | Number of iterations the loop body is executed. |
Name | Base name used to derive BB and instruction names. |
Definition at line 1850 of file OMPIRBuilder.cpp.
References llvm::CanonicalLoopInfo::assertOK(), BB, Builder, llvm::OpenMPIRBuilder::LocationDescription::DL, llvm::CanonicalLoopInfo::getAfter(), llvm::CanonicalLoopInfo::getBodyIP(), llvm::CanonicalLoopInfo::getIndVar(), llvm::CanonicalLoopInfo::getPreheader(), llvm::OpenMPIRBuilder::LocationDescription::IP, and llvm::spliceBB().
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.
IP | insertion block for copyin conditional |
MasterVarPtr | a pointer to the master variable |
PrivateVarPtr | a pointer to the threadprivate variable |
IntPtrTy | Pointer size type |
BranchtoEnd | Create a branch between the copyin.not.master blocks |
Definition at line 3409 of file OMPIRBuilder.cpp.
References Builder, cmp, llvm::BasicBlock::Create(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), M, and llvm::BasicBlock::splitBasicBlock().
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createCopyPrivate | ( | const LocationDescription & | Loc, |
llvm::Value * | BufSize, | ||
llvm::Value * | CpyBuf, | ||
llvm::Value * | CpyFn, | ||
llvm::Value * | DidIt | ||
) |
Generator for __kmpc_copyprivate.
Loc | The source location description. |
BufSize | Number of elements in the buffer. |
CpyBuf | List of pointers to data to be copied. |
CpyFn | function to call for copying data. |
DidIt | flag variable; 1 for 'single' thread, 0 otherwise. |
Definition at line 3124 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, and llvm::OpenMPIRBuilder::LocationDescription::IP.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createCritical | ( | const LocationDescription & | Loc, |
BodyGenCallbackTy | BodyGenCB, | ||
FinalizeCallbackTy | FiniCB, | ||
StringRef | CriticalName, | ||
Value * | HintInst | ||
) |
Generator for '#omp critical'.
Loc | The insert and source location description. |
BodyGenCB | Callback that will generate the region body code. |
FiniCB | Callback to finalize variable copies. |
CriticalName | name of the lock used by the critical directive |
HintInst | Hint Instruction for hint clause associated with critical |
Definition at line 3187 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.
void OpenMPIRBuilder::createFlush | ( | const LocationDescription & | Loc | ) |
Generator for '#omp flush'.
Loc | The location where the flush directive was encountered |
Definition at line 1213 of file OMPIRBuilder.cpp.
GlobalValue * OpenMPIRBuilder::createGlobalFlag | ( | unsigned | Value, |
StringRef | Name | ||
) |
Create a hidden global flag Name
in the module with initial value Value
.
Definition at line 522 of file OMPIRBuilder.cpp.
References llvm::ConstantInt::get(), llvm::Type::getInt32Ty(), llvm::GlobalValue::HiddenVisibility, M, and llvm::GlobalValue::WeakODRLinkage.
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.
DL | DebugLoc used for the instructions in the skeleton. |
TripCount | Value to be used for the trip count. |
F | Function in which to insert the BasicBlocks. |
PreInsertBefore | Where to insert BBs that execute before the body, typically the body itself. |
PostInsertBefore | Where to insert BBs that execute after the body. |
Name | Base name used to derive BB and instruction names. |
Definition at line 1783 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.
void OpenMPIRBuilder::createMapperAllocas | ( | const LocationDescription & | Loc, |
InsertPointTy | AllocaIP, | ||
unsigned | NumOperands, | ||
struct MapperAllocas & | MapperAllocas | ||
) |
Create the allocas instruction used in call to mapper functions.
Definition at line 3733 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::OpenMPIRBuilder::MapperAllocas::Args, llvm::OpenMPIRBuilder::MapperAllocas::ArgsBase, llvm::OpenMPIRBuilder::MapperAllocas::ArgSizes, Builder, llvm::ArrayType::get(), and llvm::OpenMPIRBuilder::LocationDescription::IP.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createMasked | ( | const LocationDescription & | Loc, |
BodyGenCallbackTy | BodyGenCB, | ||
FinalizeCallbackTy | FiniCB, | ||
Value * | Filter | ||
) |
Generator for '#omp masked'.
Loc | The insert and source location description. |
BodyGenCB | Callback that will generate the region code. |
FiniCB | Callback to finialize variable copies. |
Definition at line 1759 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, llvm::Filter, and llvm::OpenMPIRBuilder::LocationDescription::IP.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createMaster | ( | const LocationDescription & | Loc, |
BodyGenCallbackTy | BodyGenCB, | ||
FinalizeCallbackTy | FiniCB | ||
) |
Generator for '#omp master'.
Loc | The insert and source location description. |
BodyGenCB | Callback that will generate the region code. |
FiniCB | Callback to finalize variable copies. |
Definition at line 1734 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, and llvm::OpenMPIRBuilder::LocationDescription::IP.
GlobalVariable * OpenMPIRBuilder::createOffloadMapnames | ( | SmallVectorImpl< llvm::Constant * > & | Names, |
std::string | VarName | ||
) |
Create the global variable holding the offload names information.
Definition at line 4268 of file OMPIRBuilder.cpp.
References llvm::ArrayType::get(), llvm::ConstantArray::get(), llvm::Type::getInt8Ty(), llvm::Type::getPointerTo(), llvm::Value::getType(), M, llvm::GlobalValue::PrivateLinkage, and llvm::tgtok::VarName.
GlobalVariable * OpenMPIRBuilder::createOffloadMaptypes | ( | SmallVectorImpl< uint64_t > & | Mappings, |
std::string | VarName | ||
) |
Create the global variable holding the offload mappings information.
Definition at line 3721 of file OMPIRBuilder.cpp.
References llvm::ConstantDataArray::get(), llvm::Value::getType(), llvm::GlobalValue::Global, M, Mappings, llvm::GlobalValue::PrivateLinkage, and llvm::tgtok::VarName.
CallInst * OpenMPIRBuilder::createOMPAlloc | ( | const LocationDescription & | Loc, |
Value * | Size, | ||
Value * | Allocator, | ||
std::string | Name = "" |
||
) |
Create a runtime call for kmpc_Alloc.
Loc | The insert and source location description. |
Size | Size of allocated memory space |
Allocator | Allocator information instruction |
Name | Name of call Instruction for OMP_alloc |
Definition at line 3459 of file OMPIRBuilder.cpp.
References Allocator, llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, and llvm::OpenMPIRBuilder::LocationDescription::IP.
CallInst * OpenMPIRBuilder::createOMPFree | ( | const LocationDescription & | Loc, |
Value * | Addr, | ||
Value * | Allocator, | ||
std::string | Name = "" |
||
) |
Create a runtime call for kmpc_free.
Loc | The insert and source location description. |
Addr | Address of memory space to be freed |
Allocator | Allocator information instruction |
Name | Name of call Instruction for OMP_Free |
Definition at line 3476 of file OMPIRBuilder.cpp.
References Addr, Allocator, llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, and llvm::OpenMPIRBuilder::LocationDescription::IP.
CallInst * OpenMPIRBuilder::createOMPInteropDestroy | ( | const LocationDescription & | Loc, |
Value * | InteropVar, | ||
Value * | Device, | ||
Value * | NumDependences, | ||
Value * | DependenceAddress, | ||
bool | HaveNowaitClause | ||
) |
Create a runtime call for __tgt_interop_destroy.
Loc | The insert and source location description. |
InteropVar | variable to be allocated |
Device | devide to which offloading will occur |
NumDependences | number of dependence variables |
DependenceAddress | pointer to dependence variables |
HaveNowaitClause | does nowait clause exist |
Definition at line 3520 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, llvm::ConstantInt::get(), llvm::ConstantPointerNull::get(), llvm::Type::getInt8PtrTy(), llvm::OpenMPIRBuilder::LocationDescription::IP, and M.
CallInst * OpenMPIRBuilder::createOMPInteropInit | ( | const LocationDescription & | Loc, |
Value * | InteropVar, | ||
omp::OMPInteropType | InteropType, | ||
Value * | Device, | ||
Value * | NumDependences, | ||
Value * | DependenceAddress, | ||
bool | HaveNowaitClause | ||
) |
Create a runtime call for __tgt_interop_init.
Loc | The insert and source location description. |
InteropVar | variable to be allocated |
InteropType | type of interop operation |
Device | devide to which offloading will occur |
NumDependences | number of dependence variables |
DependenceAddress | pointer to dependence variables |
HaveNowaitClause | does nowait clause exist |
Definition at line 3491 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, llvm::ConstantInt::get(), llvm::ConstantPointerNull::get(), llvm::Type::getInt8PtrTy(), llvm::OpenMPIRBuilder::LocationDescription::IP, and M.
CallInst * OpenMPIRBuilder::createOMPInteropUse | ( | const LocationDescription & | Loc, |
Value * | InteropVar, | ||
Value * | Device, | ||
Value * | NumDependences, | ||
Value * | DependenceAddress, | ||
bool | HaveNowaitClause | ||
) |
Create a runtime call for __tgt_interop_use.
Loc | The insert and source location description. |
InteropVar | variable to be allocated |
Device | devide to which offloading will occur |
NumDependences | number of dependence variables |
DependenceAddress | pointer to dependence variables |
HaveNowaitClause | does nowait clause exist |
Definition at line 3547 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, llvm::ConstantInt::get(), llvm::ConstantPointerNull::get(), llvm::Type::getInt8PtrTy(), llvm::OpenMPIRBuilder::LocationDescription::IP, and M.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createOrderedDepend | ( | const LocationDescription & | Loc, |
InsertPointTy | AllocaIP, | ||
unsigned | NumLoops, | ||
ArrayRef< llvm::Value * > | StoreValues, | ||
const Twine & | Name, | ||
bool | IsDependSource | ||
) |
Generator for '#omp ordered depend (source | sink)'.
Loc | The insert and source location description. |
AllocaIP | The insertion point to be used for alloca instructions. |
NumLoops | The number of loops in depend clause. |
StoreValues | The value will be stored in vector address. |
Name | The name of alloca instruction. |
IsDependSource | If true, depend source; otherwise, depend sink. |
Definition at line 3222 of file OMPIRBuilder.cpp.
References Align, llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), Builder, llvm::ArrayType::get(), llvm::Intrinsic::getType(), I, llvm::OpenMPIRBuilder::LocationDescription::IP, llvm::AllocaInst::setAlignment(), llvm::StoreInst::setAlignment(), and llvm::ArrayRef< T >::size().
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createOrderedThreadsSimd | ( | const LocationDescription & | Loc, |
BodyGenCallbackTy | BodyGenCB, | ||
FinalizeCallbackTy | FiniCB, | ||
bool | IsThreads | ||
) |
Generator for '#omp ordered [threads | simd]'.
Loc | The insert and source location description. |
BodyGenCB | Callback that will generate the region code. |
FiniCB | Callback to finalize variable copies. |
IsThreads | If true, with threads clause or without clause; otherwise, with simd clause; |
Definition at line 3267 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, and llvm::OpenMPIRBuilder::LocationDescription::IP.
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'.
Loc | The insert and source location description. |
AllocaIP | The insertion points to be used for alloca instructions. |
BodyGenCB | Callback that will generate the region code. |
PrivCB | Callback to copy a given variable (think copy constructor). |
FiniCB | Callback to finalize variable copies. |
IfCondition | The evaluated 'if' clause expression, if any. |
NumThreads | The evaluated 'num_threads' clause expression, if any. |
ProcBind | The value of the 'proc_bind' clause (see ProcBindKind). |
IsCancellable | Flag to indicate a cancellable parallel region. |
Definition at line 833 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::ExcludeArgsFromAggregate, 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, isConflictIP(), LLVM_DEBUG, move, llvm::OpenMPIRBuilder::OutlineInfo::OuterAllocaBB, llvm::OpenMPIRBuilder::OutlineInfo::PostOutlineCB, llvm::Instruction::removeFromParent(), llvm::Value::setName(), llvm::BasicBlock::splitBasicBlock(), llvm::SplitBlock(), llvm::SplitBlockAndInsertIfThenElse(), and Uses.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createReductions | ( | const LocationDescription & | Loc, |
InsertPointTy | AllocaIP, | ||
ArrayRef< ReductionInfo > | ReductionInfos, | ||
bool | IsNoWait = false |
||
) |
Generator for '#omp reduction'.
Emits the IR instructing the runtime to perform the specific kind of reductions. Expects reduction variables to have been privatized and initialized to reduction-neutral values separately. Emits the calls to runtime functions as well as the reduction function and the basic blocks performing the reduction atomically and non-atomically.
The code emitted for the following:
corresponds to the following sketch.
Loc | The location where the reduction was encountered. Must be within the associate directive and after the last local access to the reduction variables. |
AllocaIP | An insertion point suitable for allocas usable in reductions. |
ReductionInfos | A list of info on each reduction variable. |
IsNoWait | A flag set if the reduction is marked as nowait. |
Definition at line 1570 of file OMPIRBuilder.cpp.
References llvm::all_of(), assert(), llvm::OpenMPIRBuilder::ReductionInfo::AtomicReductionGen, Builder, llvm::BasicBlock::Create(), DL, llvm::OpenMPIRBuilder::ReductionInfo::ElementType, llvm::BasicBlock::end(), llvm::enumerate(), llvm::Instruction::eraseFromParent(), llvm::ArrayType::get(), llvm::Function::getArg(), llvm::Module::getContext(), llvm::Module::getDataLayout(), getFreshReductionFunc(), llvm::Type::getPointerTo(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::OpenMPIRBuilder::LocationDescription::IP, LHS, llvm::Lock, llvm::OpenMPIRBuilder::ReductionInfo::PrivateVariable, llvm::OpenMPIRBuilder::ReductionInfo::ReductionGen, RHS, llvm::BasicBlock::splitBasicBlock(), and llvm::OpenMPIRBuilder::ReductionInfo::Variable.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createSection | ( | const LocationDescription & | Loc, |
BodyGenCallbackTy | BodyGenCB, | ||
FinalizeCallbackTy | FiniCB | ||
) |
Generator for '#omp section'.
Loc | The insert and source location description. |
BodyGenCB | Callback that will generate the region body code. |
FiniCB | Callback to finalize variable copies. |
Definition at line 1524 of file OMPIRBuilder.cpp.
References Builder, I, and llvm::OpenMPIRBuilder::LocationDescription::IP.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createSections | ( | const LocationDescription & | Loc, |
InsertPointTy | AllocaIP, | ||
ArrayRef< StorableBodyGenCallbackTy > | SectionCBs, | ||
PrivatizeCallbackTy | PrivCB, | ||
FinalizeCallbackTy | FiniCB, | ||
bool | IsCancellable, | ||
bool | IsNowait | ||
) |
Generator for '#omp sections'.
Loc | The insert and source location description. |
AllocaIP | The insertion points to be used for alloca instructions. |
SectionCBs | Callbacks that will generate body of each section. |
PrivCB | Callback to copy a given variable (think copy constructor). |
FiniCB | Callback to finalize variable copies. |
IsCancellable | Flag to indicate a cancellable parallel region. |
IsNowait | If true, barrier - to ensure all sections are executed before moving forward will not be generated. |
Definition at line 1429 of file OMPIRBuilder.cpp.
References llvm::SwitchInst::addCase(), assert(), llvm::BasicBlock::begin(), Builder, llvm::BasicBlock::Create(), llvm::OpenMPIRBuilder::LocationDescription::DL, llvm::ConstantInt::get(), llvm::Type::getInt32Ty(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), I, llvm::OpenMPIRBuilder::LocationDescription::IP, isConflictIP(), M, llvm::ArrayRef< T >::size(), llvm::splitBBWithSuffix(), and llvm::ARM_MB::ST.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createSingle | ( | const LocationDescription & | Loc, |
BodyGenCallbackTy | BodyGenCB, | ||
FinalizeCallbackTy | FiniCB, | ||
bool | IsNowait, | ||
llvm::Value * | DidIt | ||
) |
Generator for '#omp single'.
Loc | The source location description. |
BodyGenCB | Callback that will generate the region code. |
FiniCB | Callback to finalize variable copies. |
IsNowait | If false, a barrier is emitted. |
DidIt | Local variable used as a flag to indicate 'single' thread |
Definition at line 3145 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, llvm::OpenMPIRBuilder::LocationDescription::DL, and llvm::OpenMPIRBuilder::LocationDescription::IP.
void OpenMPIRBuilder::createTargetDeinit | ( | const LocationDescription & | Loc, |
bool | IsSPMD, | ||
bool | RequiresFullRuntime | ||
) |
Create a runtime call for kmpc_target_deinit.
Loc | The insert and source location description. |
IsSPMD | Flag to indicate if the kernel is an SPMD kernel or not. |
RequiresFullRuntime | Indicate if a full device runtime is necessary. |
Definition at line 3649 of file OMPIRBuilder.cpp.
References Builder, llvm::ConstantInt::getBool(), llvm::Type::getInt8Ty(), llvm::ConstantInt::getSigned(), llvm::omp::OMP_TGT_EXEC_MODE_GENERIC, and llvm::omp::OMP_TGT_EXEC_MODE_SPMD.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTargetInit | ( | const LocationDescription & | Loc, |
bool | IsSPMD, | ||
bool | RequiresFullRuntime | ||
) |
The omp target
interface.
For more information about the usage of this interface,
{ Create a runtime call for kmpc_target_init
Loc | The insert and source location description. |
IsSPMD | Flag to indicate if the kernel is an SPMD kernel or not. |
RequiresFullRuntime | Indicate if a full device runtime is necessary. |
Definition at line 3596 of file OMPIRBuilder.cpp.
References Builder, llvm::BasicBlock::Create(), llvm::ConstantInt::get(), llvm::ConstantInt::getBool(), llvm::BasicBlock::getContext(), llvm::BasicBlock::getFirstInsertionPt(), llvm::Type::getInt8Ty(), llvm::BasicBlock::getParent(), llvm::ConstantInt::getSigned(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::OpenMPIRBuilder::LocationDescription::IP, llvm::omp::OMP_TGT_EXEC_MODE_GENERIC, llvm::omp::OMP_TGT_EXEC_MODE_SPMD, and llvm::BasicBlock::splitBasicBlock().
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTask | ( | const LocationDescription & | Loc, |
InsertPointTy | AllocaIP, | ||
BodyGenCallbackTy | BodyGenCB, | ||
bool | Tied = true , |
||
Value * | Final = nullptr |
||
) |
Generator for #omp task
Loc | The location where the task construct was encountered. |
AllocaIP | The insertion point to be used for alloca instructions. |
BodyGenCB | Callback that will generate the region code. |
Tied | True if the task is tied, false if the task is untied. |
Final | i1 value which is true if the task is final, false if the task is not final. |
Definition at line 1257 of file OMPIRBuilder.cpp.
References llvm::CallBase::arg_size(), assert(), llvm::BasicBlock::begin(), Builder, llvm::BasicBlock::Create(), llvm::OpenMPIRBuilder::OutlineInfo::EntryBB, llvm::Instruction::eraseFromParent(), llvm::OpenMPIRBuilder::OutlineInfo::ExitBB, llvm::FunctionType::get(), llvm::AllocaInst::getAllocatedType(), llvm::Function::getArg(), llvm::CallBase::getArgOperand(), llvm::ConstantExpr::getBitCast(), llvm::FunctionCallee::getCallee(), llvm::Value::getPointerAlignment(), llvm::Type::getPointerTo(), M, move, llvm::OpenMPIRBuilder::OutlineInfo::OuterAllocaBB, llvm::OpenMPIRBuilder::OutlineInfo::PostOutlineCB, and llvm::splitBB().
void OpenMPIRBuilder::createTaskwait | ( | const LocationDescription & | Loc | ) |
Generator for '#omp taskwait'.
Loc | The location where the taskwait directive was encountered. |
Definition at line 1232 of file OMPIRBuilder.cpp.
void OpenMPIRBuilder::createTaskyield | ( | const LocationDescription & | Loc | ) |
Generator for '#omp taskyield'.
Loc | The location where the taskyield directive was encountered. |
Definition at line 1250 of file OMPIRBuilder.cpp.
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitBarrierImpl | ( | const LocationDescription & | Loc, |
omp::Directive | DK, | ||
bool | ForceSimpleCall, | ||
bool | CheckCancelFlag | ||
) |
Generate a barrier runtime call.
Loc | The location at which the request originated and is fulfilled. |
DK | The directive which caused the barrier |
ForceSimpleCall | Flag to force a simple (=non-cancellation) barrier. |
CheckCancelFlag | Flag to indicate a cancel barrier return value should be checked and acted upon. |
Definition at line 656 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, and Builder.
void OpenMPIRBuilder::emitCancelationCheckImpl | ( | Value * | CancelFlag, |
omp::Directive | CanceledDirective, | ||
FinalizeCallbackTy | ExitCB = {} |
||
) |
Generate control flow and cleanup for cancellation.
CancelFlag | Flag indicating if the cancellation is performed. |
CanceledDirective | The kind of directive that is cancled. |
ExitCB | Extra code to be generated in the exit block. |
Definition at line 794 of file OMPIRBuilder.cpp.
References assert(), BB, llvm::BasicBlock::begin(), Builder, llvm::BasicBlock::Create(), and llvm::SplitBlock().
void OpenMPIRBuilder::emitFlush | ( | const LocationDescription & | Loc | ) |
Generate a flush runtime call.
Loc | The location at which the request originated and is fulfilled. |
Definition at line 1204 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, and Builder.
void OpenMPIRBuilder::emitMapperCall | ( | const LocationDescription & | Loc, |
Function * | MapperFunc, | ||
Value * | SrcLocInfo, | ||
Value * | MaptypesArg, | ||
Value * | MapnamesArg, | ||
struct MapperAllocas & | MapperAllocas, | ||
int64_t | DeviceID, | ||
unsigned | NumOperands | ||
) |
Create the call for the target mapper function.
Loc | The source location description. |
MapperFunc | Function to be called. |
SrcLocInfo | Source location information global. |
MaptypesArg | The argument types. |
MapnamesArg | The argument names. |
MapperAllocas | The AllocaInst used for the call. |
DeviceID | Device ID for the call. |
NumOperands | Number of operands in the call. |
Definition at line 3752 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::MapperAllocas::Args, llvm::OpenMPIRBuilder::MapperAllocas::ArgsBase, llvm::OpenMPIRBuilder::MapperAllocas::ArgSizes, Builder, llvm::ArrayType::get(), and llvm::Constant::getNullValue().
void OpenMPIRBuilder::emitOffloadingEntry | ( | Constant * | Addr, |
StringRef | Name, | ||
uint64_t | Size, | ||
int32_t | Flags, | ||
StringRef | SectionName = "omp_offloading_entries" |
||
) |
Create an offloading section struct used to register this global at runtime.
Type struct __tgt_offload_entry{ void *addr; // Pointer to the offload entry info. // (function or global) char *name; // Name of the function or global. size_t size; // Size of the entry info (0 if it a function). int32_t flags; int32_t reserved; };
Addr | The pointer to the global being registered. |
Name | The symbol name associated with the global. |
Size | The size in bytes of the global (0 for functions). |
Flags | Flags associated with the entry. |
SectionName | The section this entry will be placed at. |
Definition at line 756 of file OMPIRBuilder.cpp.
References Addr, llvm::ConstantInt::get(), llvm::ConstantStruct::get(), llvm::Type::getInt32Ty(), llvm::Type::getInt8PtrTy(), llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(), llvm::ConstantDataArray::getString(), llvm::Value::getType(), llvm::GlobalValue::Global, Int32Ty, llvm::GlobalValue::InternalLinkage, and M.
void OpenMPIRBuilder::emitTaskwaitImpl | ( | const LocationDescription & | Loc | ) |
Generate a taskwait runtime call.
Loc | The location at which the request originated and is fulfilled. |
Definition at line 1219 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, and Builder.
void OpenMPIRBuilder::emitTaskyieldImpl | ( | const LocationDescription & | Loc | ) |
Generate a taskyield runtime call.
Loc | The location at which the request originated and is fulfilled. |
Definition at line 1238 of file OMPIRBuilder.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, Builder, and llvm::Constant::getNullValue().
void OpenMPIRBuilder::finalize | ( | Function * | Fn = nullptr | ) |
Finalize the underlying module, e.g., by outlining regions.
Fn | The function to be finalized. If not used, all functions are finalized. |
Definition at line 429 of file OMPIRBuilder.cpp.
References assert(), llvm::SmallPtrSetImplBase::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::dbgs(), llvm::BasicBlock::empty(), llvm::CodeExtractor::excludeArgFromAggregate(), 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, llvm::BasicBlock::rbegin(), and llvm::Function::removeFromParent().
|
inline |
}
Return the insertion point used by the underlying IRBuilder.
Definition at line 748 of file OMPIRBuilder.h.
References Builder, and llvm::IRBuilderBase::saveIP().
Return the (LLVM-IR) string describing the default source location.
Definition at line 613 of file OMPIRBuilder.cpp.
Constant * OpenMPIRBuilder::getOrCreateIdent | ( | Constant * | SrcLocStr, |
uint32_t | SrcLocStrSize, | ||
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 533 of file OMPIRBuilder.cpp.
References Align, llvm::ConstantInt::get(), llvm::ConstantStruct::get(), llvm::Constant::getNullValue(), llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(), llvm::GlobalValue::Global, M, llvm::GlobalValue::NotThreadLocal, and llvm::GlobalValue::PrivateLinkage.
FunctionCallee OpenMPIRBuilder::getOrCreateRuntimeFunction | ( | Module & | M, |
omp::RuntimeFunction | FnID | ||
) |
Return the function declaration for the runtime function with FnID
.
Definition at line 362 of file OMPIRBuilder.cpp.
References llvm::GlobalObject::addMetadata(), assert(), llvm::MDBuilder::createCallbackEncoding(), llvm::dbgs(), llvm::MDNode::get(), llvm::ConstantExpr::getBitCast(), llvm::Function::getContext(), llvm::Function::getFunctionType(), llvm::Value::getName(), llvm::Type::getPointerTo(), llvm::GlobalObject::hasMetadata(), and LLVM_DEBUG.
Referenced by getKmpcForDynamicFiniForType(), getKmpcForDynamicInitForType(), getKmpcForDynamicNextForType(), and getKmpcForStaticInitForType().
Function * OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr | ( | omp::RuntimeFunction | FnID | ) |
Definition at line 420 of file OMPIRBuilder.cpp.
References assert(), llvm::FunctionCallee::getCallee(), and M.
Constant * OpenMPIRBuilder::getOrCreateSrcLocStr | ( | const LocationDescription & | Loc, |
uint32_t & | SrcLocStrSize | ||
) |
Return the (LLVM-IR) string describing the source location Loc
.
Definition at line 635 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::LocationDescription::DL, and llvm::OpenMPIRBuilder::LocationDescription::IP.
Constant * OpenMPIRBuilder::getOrCreateSrcLocStr | ( | DebugLoc | DL, |
uint32_t & | SrcLocStrSize, | ||
Function * | F = nullptr |
||
) |
Return the (LLVM-IR) string describing the DebugLoc DL
.
Use F
as fallback if DL
does not specify the function name.
Definition at line 618 of file OMPIRBuilder.cpp.
References DL, llvm::Function::empty(), F, M, and llvm::Sched::Source.
Constant * OpenMPIRBuilder::getOrCreateSrcLocStr | ( | StringRef | FunctionName, |
StringRef | FileName, | ||
unsigned | Line, | ||
unsigned | Column, | ||
uint32_t & | SrcLocStrSize | ||
) |
Return the (LLVM-IR) string describing the source location identified by the arguments.
Definition at line 594 of file OMPIRBuilder.cpp.
References llvm::SmallString< InternalLen >::append(), llvm::SmallString< InternalLen >::str(), and llvm::to_string().
Return the (LLVM-IR) string describing the source location LocStr
.
Definition at line 573 of file OMPIRBuilder.cpp.
References Builder, llvm::ConstantExpr::getPointerCast(), llvm::ConstantDataArray::getString(), M, and llvm::StringRef::size().
Return the current thread ID.
Ident | The ident (ident_t*) describing the query origin. |
Definition at line 641 of file OMPIRBuilder.cpp.
References Builder.
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 427 of file OMPIRBuilder.cpp.
References M.
|
inline |
Return true if the last entry in the finalization stack is of kind DK
and cancellable.
Definition at line 849 of file OMPIRBuilder.h.
References FinalizationStack.
|
inline |
Pop the last finalization callback from the finalization stack.
NOTE: Temporary solution until Clang CG is gone.
Definition at line 131 of file OMPIRBuilder.h.
References FinalizationStack.
|
inline |
Push a finalization callback on the finalization stack.
NOTE: Temporary solution until Clang CG is gone.
Definition at line 124 of file OMPIRBuilder.h.
References FinalizationStack.
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:
After tiling with Loops={i,j} and TileSizes={5,7}, the loop is changed to
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.
DL | Debug location for instructions added by tiling, for instance the floor- and tile trip count computation. |
Loops | Loops to tile. The CanonicalLoopInfo objects are invalidated by this method, i.e. should not used after tiling. |
TileSizes | For each loop in Loops , the tile size for that dimensions. |
Definition at line 2591 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::ArrayRef< T >::size(), and TileSize.
void OpenMPIRBuilder::unrollLoopFull | ( | DebugLoc | DL, |
CanonicalLoopInfo * | Loop | ||
) |
Fully unroll a loop.
Instead of unrolling the loop immediately (and duplicating its body instructions), it is deferred to LLVM's LoopUnrollPass by adding loop metadata.
DL | Debug location for instructions added by unrolling. |
Loop | The loop to unroll. The loop will be invalidated. |
Definition at line 2822 of file OMPIRBuilder.cpp.
References addLoopMetadata(), Builder, llvm::MDString::get(), and llvm::MDNode::get().
void OpenMPIRBuilder::unrollLoopHeuristic | ( | DebugLoc | DL, |
CanonicalLoopInfo * | Loop | ||
) |
Fully or partially unroll a loop.
How the loop is unrolled is determined using LLVM's LoopUnrollPass.
DL | Debug location for instructions added by unrolling. |
Loop | The loop to unroll. The loop will be invalidated. |
Definition at line 2829 of file OMPIRBuilder.cpp.
References addLoopMetadata(), Builder, llvm::MDString::get(), and llvm::MDNode::get().
void OpenMPIRBuilder::unrollLoopPartial | ( | DebugLoc | DL, |
CanonicalLoopInfo * | Loop, | ||
int32_t | Factor, | ||
CanonicalLoopInfo ** | UnrolledCLI | ||
) |
Partially unroll a loop.
The CanonicalLoopInfo of the unrolled loop for use with chained loop-associated directive can be requested using UnrolledCLI
. Not needing the CanonicalLoopInfo allows more efficient code generation by deferring the actual unrolling to the LoopUnrollPass using loop metadata. A loop-associated directive applied to the unrolled loop needs to know the new trip count which means that if using a heuristically determined unroll factor (Factor
== 0), that factor must be computed immediately. We are using the same logic as the LoopUnrollPass to derived the unroll factor, but which assumes that some canonicalization has taken place (e.g. Mem2Reg, LICM, GVN, Inlining, etc.). That is, the heuristic will perform better when the unrolled loop's CanonicalLoopInfo is not needed.
DL | Debug location for instructions added by unrolling. |
Loop | The loop to unroll. The loop will be invalidated. |
Factor | The factor to unroll the loop by. A factor of 0 indicates that a heuristic should be used to determine the unroll-factor. |
UnrolledCLI | If non-null, receives the CanonicalLoopInfo of the partially unrolled loop. Otherwise, uses loop metadata to defer unrolling to the LoopUnrollPass. |
Definition at line 3055 of file OMPIRBuilder.cpp.
References addLoopMetadata(), assert(), computeHeuristicUnrollFactor(), DL, F, llvm::ConstantInt::get(), llvm::ConstantAsMetadata::get(), llvm::MDString::get(), llvm::MDNode::get(), llvm::Type::getInt32Ty(), and llvm::Type::getIntegerBitWidth().
|
inline |
Update the internal location to Loc
.
Definition at line 751 of file OMPIRBuilder.h.
References Builder, llvm::OpenMPIRBuilder::LocationDescription::DL, llvm::OpenMPIRBuilder::LocationDescription::IP, llvm::IRBuilderBase::restoreIP(), and llvm::IRBuilderBase::SetCurrentDebugLocation().
IRBuilder llvm::OpenMPIRBuilder::Builder |
The LLVM-IR Builder used to create IR.
Definition at line 874 of file OMPIRBuilder.h.
Referenced by getInsertionPoint(), and updateToLocation().
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 845 of file OMPIRBuilder.h.
Referenced by isLastFinalizationInfoCancellable(), popFinalizationCB(), and pushFinalizationCB().
Map to remember existing ident_t*.
Definition at line 880 of file OMPIRBuilder.h.
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 914 of file OMPIRBuilder.h.
std::forward_list<CanonicalLoopInfo> llvm::OpenMPIRBuilder::LoopInfos |
Collection of owned canonical loop objects that eventually need to be free'd.
Definition at line 904 of file OMPIRBuilder.h.
Module& llvm::OpenMPIRBuilder::M |
The underlying LLVM-IR module.
Definition at line 871 of file OMPIRBuilder.h.
SmallVector<OutlineInfo, 16> llvm::OpenMPIRBuilder::OutlineInfos |
Collection of regions that need to be outlined during finalization.
Definition at line 900 of file OMPIRBuilder.h.
Referenced by addOutlineInfo().
Map to remember source location strings.
Definition at line 877 of file OMPIRBuilder.h.