Go to the documentation of this file.
14 #ifndef LLVM_FRONTEND_OPENMP_OMPIRBUILDER_H
15 #define LLVM_FRONTEND_OPENMP_OMPIRBUILDER_H
22 #include <forward_list>
27 class CanonicalLoopInfo;
28 struct TargetRegionEntryInfo;
29 class OffloadEntriesInfoManager;
125 "HasUnifiedSharedMemory is not set");
131 "OpenMPOffloadMandatory is not set");
307 :
IP(IRB.saveIP()),
DL(IRB.getCurrentDebugLocation()) {}
329 bool ForceSimpleCall =
false,
330 bool CheckCancelFlag =
true);
340 omp::Directive CanceledDirective);
359 Value *NumThreads, omp::ProcBindKind ProcBind,
384 const Twine &Name =
"loop");
437 bool IsSigned,
bool InclusiveStop,
439 const Twine &Name =
"loop");
578 Value *Chunk =
nullptr);
630 llvm::omp::ScheduleKind SchedKind = llvm::omp::OMP_SCHEDULE_Default,
631 Value *ChunkSize =
nullptr,
bool HasSimdModifier =
false,
632 bool HasMonotonicModifier =
false,
bool HasNonmonotonicModifier =
false,
633 bool HasOrderedClause =
false);
678 std::vector<CanonicalLoopInfo *>
784 bool Tied =
true,
Value *Final =
nullptr,
785 Value *IfCondition =
nullptr,
819 ->isOpaqueOrPointeeTypeMatches(
ElementType) &&
"Invalid elem type");
907 bool IsNoWait =
false);
918 return Loc.
IP.getBlock() !=
nullptr;
936 unsigned Line,
unsigned Column,
952 unsigned Reserve2Flags = 0);
985 omp::Directive CanceledDirective,
1001 ArrayRef<Value *> KernelArgs);
1013 omp::Directive DK,
bool ForceSimpleCall,
1014 bool CheckCancelFlag);
1019 void emitFlush(
const LocationDescription &Loc);
1130 unsigned NumOperands);
1160 bool RequiresDevicePointerInfo =
false;
1163 bool SeparateBeginEndCalls =
false;
1175 bool SeparateBeginEndCalls)
1176 : RequiresDevicePointerInfo(RequiresDevicePointerInfo),
1177 SeparateBeginEndCalls(SeparateBeginEndCalls) {}
1201 bool EmitDebug =
false,
1202 bool ForEndCall =
false);
1310 const Twine &Name,
bool IsDependSource);
1369 bool BranchtoEnd =
true);
1420 Value *NumDependences,
1421 Value *DependenceAddress,
1422 bool HaveNowaitClause);
1436 Value *NumDependences,
1437 Value *DependenceAddress,
1438 bool HaveNowaitClause);
1452 Value *NumDependences,
Value *DependenceAddress,
1453 bool HaveNowaitClause);
1478 void setOutlinedTargetRegionFunctionAttributes(
Function *OutlinedFn,
1480 int32_t NumThreads);
1532 int32_t NumTeams, int32_t NumThreads,
1533 bool IsOffloadEntry,
Function *&OutlinedFn,
1551 int32_t NumTeams, int32_t NumThreads);
1559 #define OMP_TYPE(VarName, InitValue) Type *VarName = nullptr;
1560 #define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize) \
1561 ArrayType *VarName##Ty = nullptr; \
1562 PointerType *VarName##PtrTy = nullptr;
1563 #define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...) \
1564 FunctionType *VarName = nullptr; \
1565 PointerType *VarName##Ptr = nullptr;
1566 #define OMP_STRUCT_TYPE(VarName, StrName, ...) \
1567 StructType *VarName = nullptr; \
1568 PointerType *VarName##Ptr = nullptr;
1569 #include "llvm/Frontend/OpenMP/OMPKinds.def"
1576 void initializeTypes(
Module &
M);
1592 bool Conditional =
false);
1606 Instruction *ExitCall,
1607 bool HasFinalize =
true);
1627 EmitOMPInlinedRegion(omp::Directive OMPD, Instruction *EntryCall,
1630 bool HasFinalize =
true,
bool IsCancellable =
false);
1638 static std::string getNameWithSeparators(ArrayRef<StringRef> Parts,
1639 StringRef FirstSeparator,
1640 StringRef Separator);
1647 Value *getOMPCriticalRegionLock(StringRef CriticalName);
1661 using AtomicUpdateCallbackTy =
1665 enum AtomicKind { Read, Write, Update, Capture, Compare };
1674 bool checkAndEmitFlushAfterAtomic(
const LocationDescription &Loc,
1701 std::pair<Value *, Value *>
1704 AtomicUpdateCallbackTy &UpdateOp,
bool VolatileX,
1810 bool IsPostfixUpdate,
bool IsXBinopExpr);
1861 bool IsXBinopExpr,
bool IsPostfixUpdate,
bool IsFailOnly);
1883 const Twine &Name = {});
1931 std::make_tuple(
RHS.ParentName,
RHS.DeviceID,
RHS.FileID,
RHS.Line,
1940 unsigned OffloadingEntriesNum = 0;
1963 : Flags(Flags), Order(Order), Kind(Kind) {}
1987 unsigned Order = ~0u;
1995 unsigned size()
const {
return OffloadingEntriesNum; }
2031 assert(!
ID &&
"ID has been set before!");
2050 bool IgnoreAddressId =
false)
const;
2058 const OffloadEntryInfoTargetRegion &)>
2092 VarSize(VarSize), Linkage(Linkage) {
2118 return OffloadEntriesDeviceGlobalVar.
count(
VarName) > 0;
2142 std::map<TargetRegionEntryInfo, unsigned> OffloadEntriesTargetRegionCount;
2145 typedef std::map<TargetRegionEntryInfo, OffloadEntryInfoTargetRegion>
2146 OffloadEntriesTargetRegionTy;
2147 OffloadEntriesTargetRegionTy OffloadEntriesTargetRegion;
2151 OffloadEntriesDeviceGlobalVarTy;
2152 OffloadEntriesDeviceGlobalVarTy OffloadEntriesDeviceGlobalVar;
2275 void setTripCount(
Value *TripCount);
2324 return cast<BranchInst>(
Cond->getTerminator())->getSuccessor(0);
2357 assert(isa<CmpInst>(CmpI) &&
"First inst must compare IV with TripCount");
2366 assert(isa<PHINode>(IndVarPHI) &&
"First inst must be the IV PHI");
2380 return {Preheader, std::prev(Preheader->
end())};
2387 return {Body, Body->
begin()};
2394 return {After, After->
begin()};
2399 return Header->getParent();
2412 #endif // LLVM_FRONTEND_OPENMP_OMPIRBUILDER_H
OffloadEntryInfoDeviceGlobalVar(unsigned Order, OMPTargetGlobalVarEntryKind Flags)
void setIsTargetCodegen(bool Value)
OpenMPIRBuilder::InsertPointTy getPreheaderIP() const
Return the insertion point for user code before the loop.
CallInst * createCachedThreadPrivate(const LocationDescription &Loc, llvm::Value *Pointer, llvm::ConstantInt *Size, const llvm::Twine &Name=Twine(""))
Create a runtime call for kmpc_threadprivate_cached.
void restoreIP(InsertPoint IP)
Sets the current insert point to a previously-saved location.
StringRef firstSeparator() const
OMPTargetRegionEntryKind
Kind of the target registry entry.
Description of a LLVM-IR insertion point (IP) and a debug/source location (filename,...
Value * MapNamesArray
The array of original declaration names of mapped pointers sent to the runtime library for debugging.
OffloadEntryInfo()=delete
This is an optimization pass for GlobalISel generic memory operations.
A struct to pack the relevant information for an OpenMP depend clause.
InsertPointTy createSection(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB)
Generator for '#omp section'.
InsertPointTy createCritical(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, StringRef CriticalName, Value *HintInst)
Generator for '#omp critical'.
BasicBlock * getAfter() const
The after block is intended for clean-up code such as lifetime end markers.
Value handle that is nullable, but tries to track the Value.
SmallVector< Value *, 2 > ExcludeArgsFromAggregate
std::optional< bool > HasRequiresUnifiedSharedMemory
Flag for specifying weather a requires unified_shared_memory directive is present or not.
TargetRegionEntryInfo(StringRef ParentName, unsigned DeviceID, unsigned FileID, unsigned Line, unsigned Count=0)
bool isTargetCodegen() const
const Function * getParent() const
Return the enclosing method, or null if none.
void getTargetRegionEntryFnName(SmallVectorImpl< char > &Name, const TargetRegionEntryInfo &EntryInfo)
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.
BasicBlock * getPreheader() const
The preheader ensures that there is only a single edge entering the loop.
void pushFinalizationCB(const FinalizationInfo &FI)
Push a finalization callback on the finalization stack.
Represents a single loop in the control flow graph.
Constant * getAddress() const
static bool classof(const OffloadEntryInfo *Info)
CallInst * createOMPInteropUse(const LocationDescription &Loc, Value *InteropVar, Value *Device, Value *NumDependences, Value *DependenceAddress, bool HaveNowaitClause)
Create a runtime call for __tgt_interop_use.
@ OffloadingEntryInfoTargetRegion
Entry is a target region.
void registerDeviceGlobalVarEntryInfo(StringRef VarName, Constant *Addr, int64_t VarSize, OMPTargetGlobalVarEntryKind Flags, GlobalValue::LinkageTypes Linkage)
Register device global variable entry.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Captures attributes that affect generating LLVM-IR using the OpenMPIRBuilder and related classes.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
std::vector< CanonicalLoopInfo * > tileLoops(DebugLoc DL, ArrayRef< CanonicalLoopInfo * > Loops, ArrayRef< Value * > TileSizes)
Tile a loop nest.
const std::string ompOffloadInfoName
OMP Offload Info Metadata name string.
std::function< void(EmitMetadataErrorKind, TargetRegionEntryInfo)> EmitMetadataErrorReportFunctionTy
Callback function type.
IRBuilder<>::InsertPoint InsertPointTy
Type used throughout for insertion points.
@ EMIT_MD_TARGET_REGION_ERROR
Value * getOrCreateThreadID(Value *Ident)
Return the current thread ID.
@ OMPTargetRegionEntryCtor
Mark the entry as a global constructor.
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 = ...
static void getTargetRegionEntryFnName(SmallVectorImpl< char > &Name, StringRef ParentName, unsigned DeviceID, unsigned FileID, unsigned Line, unsigned Count)
Triple - Helper class for working with autoconf configuration names.
bool IsCancellable
Flag to indicate if the directive is cancellable.
bool empty() const
Return true if a there are no entries defined.
bool openMPOffloadMandatory() const
The instances of the Type class are immutable: once they are created, they are never changed.
std::function< void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)> StorableBodyGenCallbackTy
a struct to pack relevant information while generating atomic Ops
FinalizeCallbackTy FiniCB
The finalization callback provided by the last in-flight invocation of createXXXX for the directive o...
OpenMPIRBuilder::InsertPointTy getAfterIP() const
Return the insertion point for user code after the loop.
void initializeTargetRegionEntryInfo(const TargetRegionEntryInfo &EntryInfo, unsigned Order)
Initialize target region entry.
const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
DependData(omp::RTLDependenceKindTy DepKind, Type *DepValueType, Value *DepVal)
void spliceBB(IRBuilderBase::InsertPoint IP, BasicBlock *New, bool CreateBranch)
Move the instruction after an InsertPoint to the beginning of another BasicBlock.
unsigned getOrder() const
InsertPointTy createTargetInit(const LocationDescription &Loc, bool IsSPMD)
The omp target interface.
InsertPointTy createSingle(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, bool IsNowait, llvm::Value *DidIt)
Generator for '#omp single'.
This class implements a map that also provides access to all stored values in a deterministic order.
Value * Variable
Reduction variable of pointer type.
std::function< void(InsertPointTy CodeGenIP)> FinalizeCallbackTy
Callback type for variable finalization (think destructors).
Function * getFunction() const
Container for the arguments used to pass data to the runtime library.
OffloadEntriesInfoManager()
LinkageTypes
An enumeration for the kinds of linkage for global values.
unsigned size() const
Return number of entries defined so far.
void setLinkage(GlobalValue::LinkageTypes LT)
void emitTaskyieldImpl(const LocationDescription &Loc)
Generate a taskyield runtime call.
static unsigned getOpenMPDefaultSimdAlign(const Triple &TargetTriple, const StringMap< bool > &Features)
Get the default alignment value for given target.
InsertPointTy createReductions(const LocationDescription &Loc, InsertPointTy AllocaIP, ArrayRef< ReductionInfo > ReductionInfos, bool IsNoWait=false)
Generator for '#omp reduction'.
CanonicalLoopInfo * collapseLoops(DebugLoc DL, ArrayRef< CanonicalLoopInfo * > Loops, InsertPointTy ComputeIP)
Collapse a loop nest into a single loop.
std::optional< bool > OpenMPOffloadMandatory
Instruction * getIndVar() const
Returns the instruction representing the current logical induction variable.
LLVM Basic Block Representation.
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)'.
uint32_t getFlags() const
This is the shared class of boolean and integer constants.
Class that manages information about offload code regions and data.
void popFinalizationCB()
Pop the last finalization callback from the finalization stack.
Value * BasePointersArray
The array of base pointer passed to the runtime library.
bool hasTargetRegionEntryInfo(TargetRegionEntryInfo EntryInfo, bool IgnoreAddressId=false) const
Return true if a target region entry with the provided information exists.
@ OMPTargetGlobalVarEntryLink
Mark the entry as a to declare target link.
OffloadEntryInfoTargetRegion()
Value * MappersArray
The array of user-defined mappers passed to the runtime library.
void applySimd(CanonicalLoopInfo *Loop, MapVector< Value *, Value * > AlignedVars, Value *IfCond, omp::OrderKind Order, ConstantInt *Simdlen, ConstantInt *Safelen)
Add metadata to simd-ize a loop.
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.
void emitOffloadingArraysArgument(IRBuilderBase &Builder, OpenMPIRBuilder::TargetDataRTArgs &RTArgs, OpenMPIRBuilder::TargetDataInfo &Info, bool EmitDebug=false, bool ForEndCall=false)
Emit the arguments to be passed to the runtime library based on the arrays of base pointers,...
Module & M
The underlying LLVM-IR module.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void assertOK() const
Consistency self-check.
BasicBlock * getCond() const
The condition block computes whether there is another loop iteration.
An interface to create LLVM-IR for OpenMP directives.
SmallVector< OutlineInfo, 16 > OutlineInfos
Collection of regions that need to be outlined during finalization.
CallInst * createOMPFree(const LocationDescription &Loc, Value *Addr, Value *Allocator, std::string Name="")
Create a runtime call for kmpc_free.
bool hasRequiresUnifiedSharedMemory() const
Device global variable entries info.
void setConfig(OpenMPIRBuilderConfig C)
Constant * getOrCreateDefaultSrcLocStr(uint32_t &SrcLocStrSize)
Return the (LLVM-IR) string describing the default source location.
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.
static bool classof(const OffloadEntryInfo *Info)
(vector float) vec_cmpeq(*A, *B) C
iterator begin()
Instruction iterator methods.
void createMapperAllocas(const LocationDescription &Loc, InsertPointTy AllocaIP, unsigned NumOperands, struct MapperAllocas &MapperAllocas)
Create the allocas instruction used in call to mapper functions.
InsertPointTy createTask(const LocationDescription &Loc, InsertPointTy AllocaIP, BodyGenCallbackTy BodyGenCB, bool Tied=true, Value *Final=nullptr, Value *IfCondition=nullptr, SmallVector< DependData > Dependencies={})
Generator for #omp task
unsigned NumberOfPtrs
The total number of pointers passed to the runtime library.
InsertPointTy createBarrier(const LocationDescription &Loc, omp::Directive DK, bool ForceSimpleCall=false, bool CheckCancelFlag=true)
Emitter methods for OpenMP directives.
OffloadingEntryInfoKinds
Kind of a given entry.
InsertPointTy createAtomicRead(const LocationDescription &Loc, AtomicOpValue &X, AtomicOpValue &V, AtomicOrdering AO)
Emit atomic Read for : V = X — Only Scalar data types.
void clearArrayInfo()
Clear information about the data arrays.
int64_t getVarSize() const
bool operator<(const TargetRegionEntryInfo RHS) const
DenseMap< std::pair< Constant *, uint64_t >, Constant * > IdentMap
Map to remember existing ident_t*.
GlobalVariable * getOrCreateInternalVariable(Type *Ty, const StringRef &Name, unsigned AddressSpace=0)
Gets (if variable with the given name already exist) or creates internal global variable with the spe...
InsertPointTy getInsertionPoint()
}
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Class to represent integer types.
bool isValid() const
Returns whether this object currently represents the IR of a loop.
Constant * getOrCreateSrcLocStr(StringRef LocStr, uint32_t &SrcLocStrSize)
Return the (LLVM-IR) string describing the source location LocStr.
LocationDescription(const InsertPointTy &IP)
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 ?...
BasicBlock * splitBBWithSuffix(IRBuilderBase &Builder, bool CreateBranch, llvm::Twine Suffix=".split")
Like splitBB, but reuses the current block's name for the new name.
@ EMIT_MD_GLOBAL_VAR_LINK_ERROR
@ OffloadingEntryInfoInvalid
Invalid entry info.
void createOffloadEntriesAndInfoMetadata(OffloadEntriesInfoManager &OffloadEntriesInfoManager, EmitMetadataErrorReportFunctionTy &ErrorReportFunction)
LocationDescription(const InsertPointTy &IP, const DebugLoc &DL)
OpenMPIRBuilder::InsertPointTy getBodyIP() const
Return the insertion point for user code in the body.
Analysis containing CSE Info
bool isValid()
Return true if the current target data information has valid arrays.
GlobalValue::LinkageTypes getLinkage() const
IdentFlag
IDs for all omp runtime library ident_t flag encodings (see their defintion in openmp/runtime/src/kmp...
@ OMPTargetRegionEntryDtor
Mark the entry as a global destructor.
OpenMPIRBuilder(Module &M)
Create a new OpenMPIRBuilder operating on the given module M.
Value * MapTypesArrayEnd
The array of map types passed to the runtime library for the end of the region, or nullptr if there a...
void unrollLoopFull(DebugLoc DL, CanonicalLoopInfo *Loop)
Fully unroll a loop.
void emitTaskwaitImpl(const LocationDescription &Loc)
Generate a taskwait runtime call.
CallInst * createOMPAlloc(const LocationDescription &Loc, Value *Size, Value *Allocator, std::string Name="")
Create a runtime call for kmpc_Alloc.
void addAttributes(omp::RuntimeFunction FnID, Function &Fn)
Add attributes known for FnID to Fn.
void loadOffloadInfoMetadata(Module &M, OffloadEntriesInfoManager &OffloadEntriesInfoManager)
Loads all the offload entries information from the host IR metadata.
@ OMPTargetGlobalVarEntryTo
Mark the entry as a to declare target.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
bool separateBeginEndCalls()
OffloadEntryInfoDeviceGlobalVar()
IRBuilder Builder
The LLVM-IR Builder used to create IR.
An efficient, type-erasing, non-owning reference to a callable.
OffloadEntryInfoTargetRegion(unsigned Order, Constant *Addr, Constant *ID, OMPTargetRegionEntryKind Flags)
RuntimeFunction
IDs for all omp runtime library (RTL) functions.
AtomicOrdering
Atomic ordering for LLVM's memory model.
void createTaskyield(const LocationDescription &Loc)
Generator for '#omp taskyield'.
Target region entries info.
EmitMetadataErrorKind
The kind of errors that can occur when emitting the offload entries and metadata.
GlobalVariable * createOffloadMaptypes(SmallVectorImpl< uint64_t > &Mappings, std::string VarName)
Create the global variable holding the offload mappings information.
InsertPointTy createSections(const LocationDescription &Loc, InsertPointTy AllocaIP, ArrayRef< StorableBodyGenCallbackTy > SectionCBs, PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB, bool IsCancellable, bool IsNowait)
Generator for '#omp sections'.
CallInst * createOMPInteropDestroy(const LocationDescription &Loc, Value *InteropVar, Value *Device, Value *NumDependences, Value *DependenceAddress, bool HaveNowaitClause)
Create a runtime call for __tgt_interop_destroy.
This is an important base class in LLVM.
Constant * registerTargetRegionFunction(OffloadEntriesInfoManager &InfoManager, TargetRegionEntryInfo &EntryInfo, Function *OutlinedFunction, StringRef EntryFnName, StringRef EntryFnIDName, int32_t NumTeams, int32_t NumThreads)
Registers the given function and sets up the attribtues of the function Returns the FunctionID.
Value * PrivateVariable
Thread-private partial reduction variable.
InsertPointTy createOrderedThreadsSimd(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, bool IsThreads)
Generator for '#omp ordered [threads | simd]'.
Function * getFunction() const
Return the function that contains the region to be outlined.
void setVarSize(int64_t Size)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
function_ref< void(const TargetRegionEntryInfo &EntryInfo, const OffloadEntryInfoTargetRegion &)> OffloadTargetRegionEntryInfoActTy
brief Applies action Action on all registered entries.
@ OffloadingEntryInfoDeviceGlobalVar
Entry is a declare target variable.
LocationDescription(const IRBuilderBase &IRB)
bool pointsToAliveValue() const
bool isLastFinalizationInfoCancellable(omp::Directive DK)
Return true if the last entry in the finalization stack is of kind DK and cancellable.
std::optional< bool > IsEmbedded
Flag for specifying if the compilation is done for embedded device code or host code.
omp::Directive DK
The directive kind of the innermost directive that has an associated region which might require final...
void emitCancelationCheckImpl(Value *CancelFlag, omp::Directive CanceledDirective, FinalizeCallbackTy ExitCB={})
Generate control flow and cleanup for cancellation.
CanonicalLoopInfo * createCanonicalLoop(const LocationDescription &Loc, LoopBodyGenCallbackTy BodyGenCB, Value *TripCount, const Twine &Name="loop")
Generator for the control flow structure of an OpenMP canonical loop.
OpenMPIRBuilderConfig(bool IsEmbedded, bool IsTargetCodegen, bool HasRequiresUnifiedSharedMemory, bool OpenMPOffloadMandatory)
void setConfig(OpenMPIRBuilderConfig C)
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.
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'.
BasicBlock * OuterAllocaBB
Value * PointersArray
The array of section pointers passed to the runtime library.
InsertPointTy createTaskgroup(const LocationDescription &Loc, InsertPointTy AllocaIP, BodyGenCallbackTy BodyGenCB)
Generator for the taskgroup construct.
void finalize(Function *Fn=nullptr)
Finalize the underlying module, e.g., by outlining regions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OffloadingEntryInfoKinds getKind() const
function_ref< InsertPointTy(InsertPointTy, Value *, Value *, Value *&)> ReductionGenTy
Functions used to generate reductions.
@ BasicBlock
Various leaf nodes.
InsertPointTy emitTargetKernel(const LocationDescription &Loc, Value *&Return, Value *Ident, Value *DeviceID, Value *NumTeams, Value *NumThreads, Value *HostPtr, ArrayRef< Value * > KernelArgs)
Generate a target region entry call.
print Print MemDeps of function
TargetDataInfo(bool RequiresDevicePointerInfo, bool SeparateBeginEndCalls)
void unrollLoopHeuristic(DebugLoc DL, CanonicalLoopInfo *Loop)
Fully or partially unroll a loop.
Function * getOrCreateRuntimeFunctionPtr(omp::RuntimeFunction FnID)
OffloadEntryInfo(OffloadingEntryInfoKinds Kind)
A Module instance is used to store all the information related to an LLVM module.
InsertPointTy createMaster(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB)
Generator for '#omp master'.
function_ref< void(StringRef, const OffloadEntryInfoDeviceGlobalVar &)> OffloadDeviceGlobalVarEntryInfoActTy
Applies action Action on all registered entries.
void createFlush(const LocationDescription &Loc)
Generator for '#omp flush'.
std::string createPlatformSpecificName(ArrayRef< StringRef > Parts) const
Get the create a name using the platform specific separators.
Helper that contains information about regions we need to outline during finalization.
Class to represented the control flow structure of an OpenMP canonical loop.
GlobalValue * createGlobalFlag(unsigned Value, StringRef Name)
Create a hidden global flag Name in the module with initial value Value.
@ OMPTargetRegionEntryTargetRegion
Mark the entry as target region.
Value * MapTypesArray
The array of map types passed to the runtime library for the beginning of the region or for the entir...
std::optional< StringRef > Separator
Separator used between all of the rest consecutive parts of s name.
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.
OMPAtomicCompareOp
Atomic compare operations. Currently OpenMP only supports ==, >, and <.
Base class of the entries info.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Value * SizesArray
The array of sizes passed to the runtime library.
StringRef separator() const
SmallVector< MachineOperand, 4 > Cond
StringRef - Represent a constant reference to a string, i.e.
OMPTargetGlobalVarEntryKind
Kind of the global variable entry..
omp::RTLDependenceKindTy DepKind
Type * getType() const
All values are typed, get the type of this value.
GlobalVariable * createOffloadMapnames(SmallVectorImpl< llvm::Constant * > &Names, std::string VarName)
Create the global variable holding the offload names information.
~OffloadEntryInfo()=default
std::optional< StringRef > FirstSeparator
First separator used between the initial two parts of a name.
Common base class shared among various IRBuilders.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Machine Check Debug Module
BasicBlock * splitBB(IRBuilderBase::InsertPoint IP, bool CreateBranch, llvm::Twine Name={})
Split a BasicBlock at an InsertPoint, even if the block is degenerate (missing the terminator).
PostOutlineCBTy PostOutlineCB
void unrollLoopPartial(DebugLoc DL, CanonicalLoopInfo *Loop, int32_t Factor, CanonicalLoopInfo **UnrolledCLI)
Partially unroll a loop.
void addOutlineInfo(OutlineInfo &&OI)
Add a new region that will be outlined later.
InsertPointTy createMasked(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, Value *Filter)
Generator for '#omp masked'.
bool updateToLocation(const LocationDescription &Loc)
Update the internal location to Loc.
static bool classof(const OffloadEntryInfo *Info)
SmallVector< FinalizationInfo, 8 > FinalizationStack
The finalization stack made up of finalize callbacks currently in-flight, wrapped into FinalizationIn...
BasicBlock * getExit() const
Reaching the exit indicates no more iterations are being executed.
std::forward_list< CanonicalLoopInfo > LoopInfos
Collection of owned canonical loop objects that eventually need to be free'd.
void createTaskwait(const LocationDescription &Loc)
Generator for '#omp taskwait'.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
ReductionGenTy ReductionGen
Callback for generating the reduction body.
Struct that keeps the information that should be kept throughout a 'target data' region.
Type * ElementType
Reduction element type, must match pointee type of variable.
InsertPointTy createAtomicWrite(const LocationDescription &Loc, AtomicOpValue &X, Value *Expr, AtomicOrdering AO)
Emit atomic write for : X = Expr — Only Scalar data types.
void actOnDeviceGlobalVarEntriesInfo(const OffloadDeviceGlobalVarEntryInfoActTy &Action)
void setFlags(uint32_t NewFlags)
void setSeparator(StringRef S)
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 ,...
void emitTargetRegionFunction(OffloadEntriesInfoManager &InfoManager, TargetRegionEntryInfo &EntryInfo, FunctionGenCallback &GenerateFunctionCallback, int32_t NumTeams, int32_t NumThreads, bool IsOffloadEntry, Function *&OutlinedFn, Constant *&OutlinedFnID)
Create a unique name for the entry function using the source location information of the current targ...
void invalidate()
Invalidate this loop.
void actOnTargetRegionEntriesInfo(const OffloadTargetRegionEntryInfoActTy &Action)
StringMap< Constant *, BumpPtrAllocator > InternalVars
An ordered map of auto-generated variables to their unique names.
void setAddress(Constant *V)
std::optional< bool > IsTargetCodegen
Flag for specifying if the compilation is done for an offloading target, like GPU.
InsertPointTy createCancel(const LocationDescription &Loc, Value *IfCondition, omp::Directive CanceledDirective)
Generator for '#omp cancel'.
void setHasRequiresUnifiedSharedMemory(bool Value)
std::function< void(Function &)> PostOutlineCBTy
void registerTargetRegionEntryInfo(TargetRegionEntryInfo EntryInfo, Constant *Addr, Constant *ID, OMPTargetRegionEntryKind Flags)
Register target region entry.
BasicBlock * getHeader() const
The header is the entry for each iteration.
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
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.
Information about an OpenMP reduction.
InsertPoint saveIP() const
Returns the current insert point.
void initialize()
Initialize the internal state, this will put structures types and potentially other helpers into the ...
OffloadEntryInfoDeviceGlobalVar(unsigned Order, Constant *Addr, int64_t VarSize, OMPTargetGlobalVarEntryKind Flags, GlobalValue::LinkageTypes Linkage)
void createTargetDeinit(const LocationDescription &Loc, bool IsSPMD)
Create a runtime call for kmpc_target_deinit.
BasicBlock * getLatch() const
Reaching the latch indicates the end of the loop body code.
bool hasDeviceGlobalVarEntryInfo(StringRef VarName) const
Checks if the variable with the given name has been registered already.
Data structure to contain the information needed to uniquely identify a target entry.
function_ref< void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)> BodyGenCallbackTy
Callback type for body (=inner region) code generation.
void setIsEmbedded(bool Value)
Type * getIndVarType() const
Return the type of the induction variable (and the trip count).
StringMap< Constant * > SrcLocStrMap
Map to remember source location strings.
InsertPointTy emitBarrierImpl(const LocationDescription &Loc, omp::Directive DK, bool ForceSimpleCall, bool CheckCancelFlag)
Generate a barrier runtime call.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
OpenMPIRBuilderConfig Config
The OpenMPIRBuilder Configuration.
std::function< Function *(StringRef FunctionName)> FunctionGenCallback
Functions used to generate a function with the given name.
Value * getTripCount() const
Returns the llvm::Value containing the number of loop iterations.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
void emitFlush(const LocationDescription &Loc)
Generate a flush runtime call.
This class represents a function call, abstracting a target machine's calling convention.
void collectBlocks(SmallPtrSetImpl< BasicBlock * > &BlockSet, SmallVectorImpl< BasicBlock * > &BlockVector)
Collect all blocks in between EntryBB and ExitBB in both the given vector and set.
ReductionInfo(Type *ElementType, Value *Variable, Value *PrivateVariable, ReductionGenTy ReductionGen, AtomicReductionGenTy AtomicReductionGen)
an instruction to allocate memory on the stack
Value * getOperand(unsigned i) const
OffloadEntryInfo(OffloadingEntryInfoKinds Kind, unsigned Order, uint32_t Flags)
bool HasMapper
Indicate whether any user-defined mapper exists.
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' ...
InsertPointTy createCopyPrivate(const LocationDescription &Loc, llvm::Value *BufSize, llvm::Value *CpyBuf, llvm::Value *CpyFn, llvm::Value *DidIt)
Generator for __kmpc_copyprivate.
FunctionCallee getOrCreateRuntimeFunction(Module &M, omp::RuntimeFunction FnID)
Return the function declaration for the runtime function with FnID.
RTLDependenceKindTy
Dependence kind for RTL.
AtomicReductionGenTy AtomicReductionGen
Callback for generating the atomic reduction body, may be null.
BasicBlock * getBody() const
The body block is the single entry for a loop iteration and not controlled by CanonicalLoopInfo.
void setFirstSeparator(StringRef FS)
LLVM Value Representation.
@ EMIT_MD_DECLARE_TARGET_ERROR
bool requiresDevicePointerInfo()
void initializeDeviceGlobalVarEntryInfo(StringRef Name, OMPTargetGlobalVarEntryKind Flags, unsigned Order)
Initialize device global variable entry.
void createOffloadEntry(Constant *ID, Constant *Addr, uint64_t Size, int32_t Flags, GlobalValue::LinkageTypes)
Creates offloading entry for the provided entry ID ID, address Addr, size Size, and flags Flags.