Skip to content

Commit

Permalink
wip target
Browse files Browse the repository at this point in the history
  • Loading branch information
jdoerfert committed Dec 17, 2019
1 parent 0e729ff commit fd7b71f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clang/lib/CodeGen/CGStmtOpenMP.cpp
Expand Up @@ -4350,6 +4350,12 @@ void CodeGenFunction::EmitOMPTargetDeviceFunction(CodeGenModule &CGM,
}

void CodeGenFunction::EmitOMPTargetDirective(const OMPTargetDirective &S) {
llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder();
if (OMPBuilder) {
Builder.restoreIP(OMPBuilder->CreateTarget());
return;
}

auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
emitTargetRegion(CGF, S, Action);
};
Expand Down
17 changes: 17 additions & 0 deletions llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
Expand Up @@ -126,6 +126,14 @@ class OpenMPIRBuilder {
///
///{

/// Generator for '#omp target'
///
/// \param Loc The location where the directive was encountered.
/// \param DK The kind of directive that was encountered.
///
/// \returns The insertion point after the directive code.
InsertPointTy CreateTarget(const LocationDescription &Loc, omp::Directive DK);

/// Generator for '#omp barrier'
///
/// \param Loc The location where the barrier directive was encountered.
Expand Down Expand Up @@ -196,6 +204,15 @@ class OpenMPIRBuilder {
omp::Directive DK, bool ForceSimpleCall,
bool CheckCancelFlag);

/// Generator for the host code of a target construct.
///
/// \param Loc The location where the directive was encountered.
/// \param DK The kind of directive that was encountered.
///
/// \returns The insertion point after the directive code.
InsertPointTy emitTargetHostImpl(const LocationDescription &Loc,
omp::Directive DK);

/// 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.
Expand Down
11 changes: 11 additions & 0 deletions llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Expand Up @@ -168,6 +168,17 @@ Value *OpenMPIRBuilder::getOrCreateThreadID(Value *Ident) {
"omp_global_thread_num");
}

InsertPointTy OpenMPIRBuilder::CreateTarget(const LocationDescription &Loc,
omp::Directive DK) {
if (!updateToLocation(Loc))
return Loc.IP;
return emitTargetHostImpl(Loc, DK);
}

InsertPointTy
OpenMPIRBuilder::emitTargetHostImpl(const LocationDescription &Loc,
omp::Directive DK) {}

OpenMPIRBuilder::InsertPointTy
OpenMPIRBuilder::CreateBarrier(const LocationDescription &Loc, Directive DK,
bool ForceSimpleCall, bool CheckCancelFlag) {
Expand Down

0 comments on commit fd7b71f

Please sign in to comment.