clang  3.8.0
Enumerations | Functions
CGOpenMPRuntime.cpp File Reference
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "CGOpenMPRuntime.h"
#include "CodeGenFunction.h"
#include "clang/AST/Decl.h"
#include "clang/AST/StmtOpenMP.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
Include dependency graph for CGOpenMPRuntime.cpp:

Go to the source code of this file.

Enumerations

enum  OpenMPSchedType {
  OMP_sch_lower = 32, OMP_sch_static_chunked = 33, OMP_sch_static = 34, OMP_sch_dynamic_chunked = 35,
  OMP_sch_guided_chunked = 36, OMP_sch_runtime = 37, OMP_sch_auto = 38, OMP_ord_lower = 64,
  OMP_ord_static_chunked = 65, OMP_ord_static = 66, OMP_ord_dynamic_chunked = 67, OMP_ord_guided_chunked = 68,
  OMP_ord_runtime = 69, OMP_ord_auto = 70, OMP_sch_default = OMP_sch_static
}
 Schedule types for 'omp for' loops (these enumerators are taken from the enum sched_type in kmp.h). More...
 
enum  KmpTaskTFields
 Indexes of fields for type kmp_task_t. More...
 
enum  RTCancelKind
 

Functions

static LValue emitLoadOfPointerLValue (CodeGenFunction &CGF, Address PtrAddr, QualType Ty)
 
static CharUnits getIdentAlign (CodeGenModule &CGM)
 
static CharUnits getIdentSize (CodeGenModule &CGM)
 
static CharUnits getOffsetOfIdentField (CGOpenMPRuntime::IdentFieldIndex Field)
 
static Address createIdentFieldGEP (CodeGenFunction &CGF, Address Addr, CGOpenMPRuntime::IdentFieldIndex Field, const llvm::Twine &Name="")
 
static llvm::ValuegetTypeSize (CodeGenFunction &CGF, QualType Ty)
 
static void emitOMPIfClause (CodeGenFunction &CGF, const Expr *Cond, const RegionCodeGenTy &ThenGen, const RegionCodeGenTy &ElseGen)
 Emits code for OpenMP 'if' clause using specified CodeGen function. More...
 
static void emitIfStmt (CodeGenFunction &CGF, llvm::Value *IfCond, OpenMPDirectiveKind Kind, SourceLocation Loc, const RegionCodeGenTy &BodyOpGen)
 
static Address emitAddrOfVarFromArray (CodeGenFunction &CGF, Address Array, unsigned Index, const VarDecl *Var)
 Given an array of pointers to variables, project the address of a given variable. More...
 
static llvm::ValueemitCopyprivateCopyFunction (CodeGenModule &CGM, llvm::Type *ArgsType, ArrayRef< const Expr * > CopyprivateVars, ArrayRef< const Expr * > DestExprs, ArrayRef< const Expr * > SrcExprs, ArrayRef< const Expr * > AssignmentOps)
 
static OpenMPSchedType getRuntimeSchedule (OpenMPScheduleClauseKind ScheduleKind, bool Chunked, bool Ordered)
 Map the OpenMP loop schedule to the runtime enumeration. More...
 
static llvm::Function * createOffloadingBinaryDescriptorFunction (CodeGenModule &CGM, StringRef Name, const RegionCodeGenTy &Codegen)
 Create a Ctor/Dtor-like function whose body is emitted through Codegen. More...
 
static FieldDecladdFieldToRecordDecl (ASTContext &C, DeclContext *DC, QualType FieldTy)
 
static RecordDeclcreatePrivatesRecordDecl (CodeGenModule &CGM, ArrayRef< PrivateDataTy > Privates)
 
static RecordDeclcreateKmpTaskTRecordDecl (CodeGenModule &CGM, QualType KmpInt32Ty, QualType KmpRoutineEntryPointerQTy)
 
static RecordDeclcreateKmpTaskTWithPrivatesRecordDecl (CodeGenModule &CGM, QualType KmpTaskTQTy, ArrayRef< PrivateDataTy > Privates)
 
static llvm::ValueemitProxyTaskFunction (CodeGenModule &CGM, SourceLocation Loc, QualType KmpInt32Ty, QualType KmpTaskTWithPrivatesPtrQTy, QualType KmpTaskTWithPrivatesQTy, QualType KmpTaskTQTy, QualType SharedsPtrTy, llvm::Value *TaskFunction, llvm::Value *TaskPrivatesMap)
 Emit a proxy function which accepts kmp_task_t as the second argument. More...
 
static llvm::ValueemitDestructorsFunction (CodeGenModule &CGM, SourceLocation Loc, QualType KmpInt32Ty, QualType KmpTaskTWithPrivatesPtrQTy, QualType KmpTaskTWithPrivatesQTy)
 
static llvm::ValueemitTaskPrivateMappingFunction (CodeGenModule &CGM, SourceLocation Loc, ArrayRef< const Expr * > PrivateVars, ArrayRef< const Expr * > FirstprivateVars, QualType PrivatesQTy, ArrayRef< PrivateDataTy > Privates)
 Emit a privates mapping function for correct handling of private and firstprivate variables. More...
 
static int array_pod_sort_comparator (const PrivateDataTy *P1, const PrivateDataTy *P2)
 
static void EmitOMPAggregateReduction (CodeGenFunction &CGF, QualType Type, const VarDecl *LHSVar, const VarDecl *RHSVar, const llvm::function_ref< void(CodeGenFunction &CGF, const Expr *, const Expr *, const Expr *)> &RedOpGen, const Expr *XExpr=nullptr, const Expr *EExpr=nullptr, const Expr *UpExpr=nullptr)
 Emit reduction operation for each element of array (required for array sections) LHS op = RHS. More...
 
static llvm::ValueemitReductionFunction (CodeGenModule &CGM, llvm::Type *ArgsType, ArrayRef< const Expr * > Privates, ArrayRef< const Expr * > LHSExprs, ArrayRef< const Expr * > RHSExprs, ArrayRef< const Expr * > ReductionOps)
 
static RTCancelKind getCancellationKind (OpenMPDirectiveKind CancelRegion)
 
static void getTargetEntryUniqueInfo (ASTContext &C, SourceLocation Loc, unsigned &DeviceID, unsigned &FileID, unsigned &LineNum, unsigned &ColumnNum)
 Obtain information that uniquely identifies a target entry. More...
 

Enumeration Type Documentation

Indexes of fields for type kmp_task_t.

Definition at line 1987 of file CGOpenMPRuntime.cpp.

Schedule types for 'omp for' loops (these enumerators are taken from the enum sched_type in kmp.h).

Enumerator
OMP_sch_lower 

Lower bound for default (unordered) versions.

OMP_sch_static_chunked 
OMP_sch_static 
OMP_sch_dynamic_chunked 
OMP_sch_guided_chunked 
OMP_sch_runtime 
OMP_sch_auto 
OMP_ord_lower 

Lower bound for 'ordered' versions.

OMP_ord_static_chunked 
OMP_ord_static 
OMP_ord_dynamic_chunked 
OMP_ord_guided_chunked 
OMP_ord_runtime 
OMP_ord_auto 
OMP_sch_default 

Definition at line 1750 of file CGOpenMPRuntime.cpp.

Definition at line 3614 of file CGOpenMPRuntime.cpp.

Function Documentation

static FieldDecl* addFieldToRecordDecl ( ASTContext C,
DeclContext DC,
QualType  FieldTy 
)
static
static int array_pod_sort_comparator ( const PrivateDataTy *  P1,
const PrivateDataTy *  P2 
)
static

Definition at line 2750 of file CGOpenMPRuntime.cpp.

static Address createIdentFieldGEP ( CodeGenFunction CGF,
Address  Addr,
CGOpenMPRuntime::IdentFieldIndex  Field,
const llvm::Twine &  Name = "" 
)
static
static RecordDecl* createKmpTaskTRecordDecl ( CodeGenModule CGM,
QualType  KmpInt32Ty,
QualType  KmpRoutineEntryPointerQTy 
)
static
static RecordDecl* createKmpTaskTWithPrivatesRecordDecl ( CodeGenModule CGM,
QualType  KmpTaskTQTy,
ArrayRef< PrivateDataTy >  Privates 
)
static
static llvm::Function* createOffloadingBinaryDescriptorFunction ( CodeGenModule CGM,
StringRef  Name,
const RegionCodeGenTy Codegen 
)
static
static RecordDecl* createPrivatesRecordDecl ( CodeGenModule CGM,
ArrayRef< PrivateDataTy >  Privates 
)
static
static Address emitAddrOfVarFromArray ( CodeGenFunction CGF,
Address  Array,
unsigned  Index,
const VarDecl Var 
)
static
static llvm::Value* emitCopyprivateCopyFunction ( CodeGenModule CGM,
llvm::Type *  ArgsType,
ArrayRef< const Expr * >  CopyprivateVars,
ArrayRef< const Expr * >  DestExprs,
ArrayRef< const Expr * >  SrcExprs,
ArrayRef< const Expr * >  AssignmentOps 
)
static
static llvm::Value* emitDestructorsFunction ( CodeGenModule CGM,
SourceLocation  Loc,
QualType  KmpInt32Ty,
QualType  KmpTaskTWithPrivatesPtrQTy,
QualType  KmpTaskTWithPrivatesQTy 
)
static
static void emitIfStmt ( CodeGenFunction CGF,
llvm::Value IfCond,
OpenMPDirectiveKind  Kind,
SourceLocation  Loc,
const RegionCodeGenTy BodyOpGen 
)
static
static LValue emitLoadOfPointerLValue ( CodeGenFunction CGF,
Address  PtrAddr,
QualType  Ty 
)
static
static void EmitOMPAggregateReduction ( CodeGenFunction CGF,
QualType  Type,
const VarDecl LHSVar,
const VarDecl RHSVar,
const llvm::function_ref< void(CodeGenFunction &CGF, const Expr *, const Expr *, const Expr *)> &  RedOpGen,
const Expr XExpr = nullptr,
const Expr EExpr = nullptr,
const Expr UpExpr = nullptr 
)
static

Emit reduction operation for each element of array (required for array sections) LHS op = RHS.

Parameters
TypeType of array.
LHSVarVariable on the left side of the reduction operation (references element of array in original variable).
RHSVarVariable on the right side of the reduction operation (references element of array in original variable).
RedOpGenGenerator of reduction operation with use of LHSVar and RHSVar.

Definition at line 3136 of file CGOpenMPRuntime.cpp.

References clang::CharUnits::alignmentOfArrayElement(), clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::createBasicBlock(), clang::CodeGen::CodeGenFunction::emitArrayLength(), clang::CodeGen::CodeGenFunction::EmitBlock(), clang::CodeGen::CodeGenFunction::GetAddrOfLocalVar(), clang::CodeGen::Address::getAlignment(), clang::Type::getAsArrayTypeUnsafe(), clang::CodeGen::CodeGenFunction::getContext(), clang::CodeGen::Address::getPointer(), and clang::ASTContext::getTypeSizeInChars().

Referenced by emitReductionFunction().

static void emitOMPIfClause ( CodeGenFunction CGF,
const Expr Cond,
const RegionCodeGenTy ThenGen,
const RegionCodeGenTy ElseGen 
)
static
static llvm::Value* emitProxyTaskFunction ( CodeGenModule CGM,
SourceLocation  Loc,
QualType  KmpInt32Ty,
QualType  KmpTaskTWithPrivatesPtrQTy,
QualType  KmpTaskTWithPrivatesQTy,
QualType  KmpTaskTQTy,
QualType  SharedsPtrTy,
llvm::Value TaskFunction,
llvm::Value TaskPrivatesMap 
)
static

Emit a proxy function which accepts kmp_task_t as the second argument.

kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
TaskFunction(gtid, tt->part_id, &tt->privates, task_privates_map,
tt->shareds);
return 0;
}

Definition at line 2559 of file CGOpenMPRuntime.cpp.

References clang::CodeGen::CodeGenTypes::arrangeFreeFunctionDeclaration(), clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::Create(), clang::CodeGen::CGBuilderTy::CreatePointerBitCastOrAddrSpaceCast(), clang::CodeGen::CodeGenFunction::disableDebugInfo(), clang::CodeGen::CodeGenFunction::EmitCallOrInvoke(), clang::CodeGen::CodeGenFunction::EmitLoadOfLValue(), emitLoadOfPointerLValue(), clang::CodeGen::CodeGenFunction::EmitLoadOfScalar(), clang::CodeGen::CodeGenFunction::EmitLValueForField(), clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(), clang::CodeGen::CodeGenFunction::FinishFunction(), clang::CodeGen::RValue::get(), clang::CodeGen::CodeGenFunction::GetAddrOfLocalVar(), clang::Type::getAsTagDecl(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenTypes::GetFunctionType(), clang::CodeGen::CodeGenModule::getModule(), clang::CodeGen::RValue::getScalarVal(), clang::CodeGen::CodeGenModule::getTypes(), clang::InternalLinkage, clang::CodeGen::CodeGenFunction::MakeAddrLValue(), clang::CodeGen::CodeGenFunction::ReturnValue, clang::CodeGen::CodeGenModule::SetInternalFunctionAttributes(), clang::CodeGen::CodeGenFunction::StartFunction(), clang::CodeGen::CodeGenTypeCache::VoidPtrTy, and clang::QualType::withRestrict().

static llvm::Value* emitReductionFunction ( CodeGenModule CGM,
llvm::Type *  ArgsType,
ArrayRef< const Expr * >  Privates,
ArrayRef< const Expr * >  LHSExprs,
ArrayRef< const Expr * >  RHSExprs,
ArrayRef< const Expr * >  ReductionOps 
)
static
static llvm::Value* emitTaskPrivateMappingFunction ( CodeGenModule CGM,
SourceLocation  Loc,
ArrayRef< const Expr * >  PrivateVars,
ArrayRef< const Expr * >  FirstprivateVars,
QualType  PrivatesQTy,
ArrayRef< PrivateDataTy >  Privates 
)
static
static RTCancelKind getCancellationKind ( OpenMPDirectiveKind  CancelRegion)
static

Definition at line 3623 of file CGOpenMPRuntime.cpp.

static CharUnits getIdentAlign ( CodeGenModule CGM)
static
static CharUnits getIdentSize ( CodeGenModule CGM)
static
static CharUnits getOffsetOfIdentField ( CGOpenMPRuntime::IdentFieldIndex  Field)
static

Definition at line 340 of file CGOpenMPRuntime.cpp.

References clang::CharUnits::fromQuantity().

Referenced by createIdentFieldGEP().

static OpenMPSchedType getRuntimeSchedule ( OpenMPScheduleClauseKind  ScheduleKind,
bool  Chunked,
bool  Ordered 
)
static
static void getTargetEntryUniqueInfo ( ASTContext C,
SourceLocation  Loc,
unsigned DeviceID,
unsigned FileID,
unsigned LineNum,
unsigned ColumnNum 
)
static

Obtain information that uniquely identifies a target entry.

This consists of the file and device IDs as well as line and column numbers associated with the relevant entry source location.

Definition at line 3718 of file CGOpenMPRuntime.cpp.

References clang::SourceManager::getPresumedLoc(), clang::ASTContext::getSourceManager(), clang::SourceLocation::isFileID(), clang::SourceLocation::isValid(), and SM.

Referenced by clang::emitTargetOutlinedFunction(), and clang::scanForTargetRegionsFunctions().

static llvm::Value* getTypeSize ( CodeGenFunction CGF,
QualType  Ty 
)
static