forked from OSchip/llvm-project
[OpenMP][NFCI] Use the libFrontend ProcBindKind in Clang
This removes the OpenMPProcBindClauseKind enum in favor of llvm::omp::ProcBindKind which lives in OpenMPConstants.h and was introduced in D70109. No change in behavior is expected. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D70289
This commit is contained in:
parent
c91bf72e2c
commit
6c5d1f40ff
|
@ -30,6 +30,7 @@
|
|||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/iterator.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/Frontend/OpenMP/OMPConstants.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/TrailingObjects.h"
|
||||
|
@ -945,7 +946,7 @@ class OMPProcBindClause : public OMPClause {
|
|||
SourceLocation LParenLoc;
|
||||
|
||||
/// A kind of the 'proc_bind' clause.
|
||||
OpenMPProcBindClauseKind Kind = OMPC_PROC_BIND_unknown;
|
||||
llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown;
|
||||
|
||||
/// Start location of the kind in source code.
|
||||
SourceLocation KindKwLoc;
|
||||
|
@ -953,7 +954,7 @@ class OMPProcBindClause : public OMPClause {
|
|||
/// Set kind of the clause.
|
||||
///
|
||||
/// \param K Kind of clause.
|
||||
void setProcBindKind(OpenMPProcBindClauseKind K) { Kind = K; }
|
||||
void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; }
|
||||
|
||||
/// Set clause kind location.
|
||||
///
|
||||
|
@ -969,7 +970,7 @@ public:
|
|||
/// \param StartLoc Starting location of the clause.
|
||||
/// \param LParenLoc Location of '('.
|
||||
/// \param EndLoc Ending location of the clause.
|
||||
OMPProcBindClause(OpenMPProcBindClauseKind A, SourceLocation ALoc,
|
||||
OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc,
|
||||
SourceLocation StartLoc, SourceLocation LParenLoc,
|
||||
SourceLocation EndLoc)
|
||||
: OMPClause(OMPC_proc_bind, StartLoc, EndLoc), LParenLoc(LParenLoc),
|
||||
|
@ -986,7 +987,7 @@ public:
|
|||
SourceLocation getLParenLoc() const { return LParenLoc; }
|
||||
|
||||
/// Returns kind of the clause.
|
||||
OpenMPProcBindClauseKind getProcBindKind() const { return Kind; }
|
||||
llvm::omp::ProcBindKind getProcBindKind() const { return Kind; }
|
||||
|
||||
/// Returns location of clause kind.
|
||||
SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
|
||||
|
|
|
@ -110,9 +110,6 @@
|
|||
#ifndef OPENMP_DEFAULT_KIND
|
||||
# define OPENMP_DEFAULT_KIND(Name)
|
||||
#endif
|
||||
#ifndef OPENMP_PROC_BIND_KIND
|
||||
# define OPENMP_PROC_BIND_KIND(Name)
|
||||
#endif
|
||||
#ifndef OPENMP_SCHEDULE_KIND
|
||||
#define OPENMP_SCHEDULE_KIND(Name)
|
||||
#endif
|
||||
|
@ -358,11 +355,6 @@ OPENMP_CANCEL_CLAUSE(if)
|
|||
OPENMP_DEFAULT_KIND(none)
|
||||
OPENMP_DEFAULT_KIND(shared)
|
||||
|
||||
// Static attributes for 'proc_bind' clause.
|
||||
OPENMP_PROC_BIND_KIND(master)
|
||||
OPENMP_PROC_BIND_KIND(close)
|
||||
OPENMP_PROC_BIND_KIND(spread)
|
||||
|
||||
// Static attributes for 'schedule' clause.
|
||||
OPENMP_SCHEDULE_KIND(static)
|
||||
OPENMP_SCHEDULE_KIND(dynamic)
|
||||
|
@ -1081,7 +1073,6 @@ OPENMP_LASTPRIVATE_KIND(conditional)
|
|||
#undef OPENMP_DEPEND_KIND
|
||||
#undef OPENMP_SCHEDULE_MODIFIER
|
||||
#undef OPENMP_SCHEDULE_KIND
|
||||
#undef OPENMP_PROC_BIND_KIND
|
||||
#undef OPENMP_DEFAULT_KIND
|
||||
#undef OPENMP_CLAUSE
|
||||
#undef OPENMP_CRITICAL_CLAUSE
|
||||
|
|
|
@ -81,14 +81,6 @@ enum OpenMPDefaultClauseKind {
|
|||
OMPC_DEFAULT_unknown
|
||||
};
|
||||
|
||||
/// OpenMP attributes for 'proc_bind' clause.
|
||||
enum OpenMPProcBindClauseKind {
|
||||
#define OPENMP_PROC_BIND_KIND(Name) \
|
||||
OMPC_PROC_BIND_##Name,
|
||||
#include "clang/Basic/OpenMPKinds.def"
|
||||
OMPC_PROC_BIND_unknown
|
||||
};
|
||||
|
||||
/// OpenMP attributes for 'schedule' clause.
|
||||
enum OpenMPScheduleClauseKind {
|
||||
#define OPENMP_SCHEDULE_KIND(Name) \
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/TinyPtrVector.h"
|
||||
#include "llvm/Frontend/OpenMP/OMPConstants.h"
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -10066,7 +10067,7 @@ public:
|
|||
SourceLocation LParenLoc,
|
||||
SourceLocation EndLoc);
|
||||
/// Called on well-formed 'proc_bind' clause.
|
||||
OMPClause *ActOnOpenMPProcBindClause(OpenMPProcBindClauseKind Kind,
|
||||
OMPClause *ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind,
|
||||
SourceLocation KindLoc,
|
||||
SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc,
|
||||
|
|
|
@ -1240,7 +1240,8 @@ void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
|
|||
|
||||
void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
|
||||
OS << "proc_bind("
|
||||
<< getOpenMPSimpleClauseTypeName(OMPC_proc_bind, Node->getProcBindKind())
|
||||
<< getOpenMPSimpleClauseTypeName(OMPC_proc_bind,
|
||||
unsigned(Node->getProcBindKind()))
|
||||
<< ")";
|
||||
}
|
||||
|
||||
|
|
|
@ -109,10 +109,10 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
|
|||
#include "clang/Basic/OpenMPKinds.def"
|
||||
.Default(OMPC_DEFAULT_unknown);
|
||||
case OMPC_proc_bind:
|
||||
return llvm::StringSwitch<OpenMPProcBindClauseKind>(Str)
|
||||
#define OPENMP_PROC_BIND_KIND(Name) .Case(#Name, OMPC_PROC_BIND_##Name)
|
||||
#include "clang/Basic/OpenMPKinds.def"
|
||||
.Default(OMPC_PROC_BIND_unknown);
|
||||
return llvm::StringSwitch<unsigned>(Str)
|
||||
#define OMP_PROC_BIND_KIND(Enum, Name, Value) .Case(Name, Value)
|
||||
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
||||
.Default(unsigned(llvm::omp::OMP_PROC_BIND_unknown));
|
||||
case OMPC_schedule:
|
||||
return llvm::StringSwitch<unsigned>(Str)
|
||||
#define OPENMP_SCHEDULE_KIND(Name) \
|
||||
|
@ -248,12 +248,10 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
|
|||
llvm_unreachable("Invalid OpenMP 'default' clause type");
|
||||
case OMPC_proc_bind:
|
||||
switch (Type) {
|
||||
case OMPC_PROC_BIND_unknown:
|
||||
return "unknown";
|
||||
#define OPENMP_PROC_BIND_KIND(Name) \
|
||||
case OMPC_PROC_BIND_##Name: \
|
||||
return #Name;
|
||||
#include "clang/Basic/OpenMPKinds.def"
|
||||
#define OMP_PROC_BIND_KIND(Enum, Name, Value) \
|
||||
case Value: \
|
||||
return Name;
|
||||
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
||||
}
|
||||
llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
|
||||
case OMPC_schedule:
|
||||
|
|
|
@ -3874,37 +3874,15 @@ void CGOpenMPRuntime::emitNumThreadsClause(CodeGenFunction &CGF,
|
|||
}
|
||||
|
||||
void CGOpenMPRuntime::emitProcBindClause(CodeGenFunction &CGF,
|
||||
OpenMPProcBindClauseKind ProcBind,
|
||||
ProcBindKind ProcBind,
|
||||
SourceLocation Loc) {
|
||||
if (!CGF.HaveInsertPoint())
|
||||
return;
|
||||
// Constants for proc bind value accepted by the runtime.
|
||||
enum ProcBindTy {
|
||||
ProcBindFalse = 0,
|
||||
ProcBindTrue,
|
||||
ProcBindMaster,
|
||||
ProcBindClose,
|
||||
ProcBindSpread,
|
||||
ProcBindIntel,
|
||||
ProcBindDefault
|
||||
} RuntimeProcBind;
|
||||
switch (ProcBind) {
|
||||
case OMPC_PROC_BIND_master:
|
||||
RuntimeProcBind = ProcBindMaster;
|
||||
break;
|
||||
case OMPC_PROC_BIND_close:
|
||||
RuntimeProcBind = ProcBindClose;
|
||||
break;
|
||||
case OMPC_PROC_BIND_spread:
|
||||
RuntimeProcBind = ProcBindSpread;
|
||||
break;
|
||||
case OMPC_PROC_BIND_unknown:
|
||||
llvm_unreachable("Unsupported proc_bind value.");
|
||||
}
|
||||
assert(ProcBind != OMP_PROC_BIND_unknown && "Unsupported proc_bind value.");
|
||||
// Build call __kmpc_push_proc_bind(&loc, global_tid, proc_bind)
|
||||
llvm::Value *Args[] = {
|
||||
emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
|
||||
llvm::ConstantInt::get(CGM.IntTy, RuntimeProcBind, /*isSigned=*/true)};
|
||||
llvm::ConstantInt::get(CGM.IntTy, unsigned(ProcBind), /*isSigned=*/true)};
|
||||
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_push_proc_bind), Args);
|
||||
}
|
||||
|
||||
|
@ -11540,7 +11518,7 @@ void CGOpenMPSIMDRuntime::emitNumThreadsClause(CodeGenFunction &CGF,
|
|||
}
|
||||
|
||||
void CGOpenMPSIMDRuntime::emitProcBindClause(CodeGenFunction &CGF,
|
||||
OpenMPProcBindClauseKind ProcBind,
|
||||
ProcBindKind ProcBind,
|
||||
SourceLocation Loc) {
|
||||
llvm_unreachable("Not supported in SIMD-only mode");
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/Frontend/OpenMP/OMPConstants.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
|
||||
|
@ -1161,7 +1162,7 @@ public:
|
|||
/// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
|
||||
/// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
|
||||
virtual void emitProcBindClause(CodeGenFunction &CGF,
|
||||
OpenMPProcBindClauseKind ProcBind,
|
||||
llvm::omp::ProcBindKind ProcBind,
|
||||
SourceLocation Loc);
|
||||
|
||||
/// Returns address of the threadprivate variable for the current
|
||||
|
@ -1910,7 +1911,7 @@ public:
|
|||
/// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
|
||||
/// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
|
||||
void emitProcBindClause(CodeGenFunction &CGF,
|
||||
OpenMPProcBindClauseKind ProcBind,
|
||||
llvm::omp::ProcBindKind ProcBind,
|
||||
SourceLocation Loc) override;
|
||||
|
||||
/// Returns address of the threadprivate variable for the current
|
||||
|
|
|
@ -1935,7 +1935,7 @@ CGOpenMPRuntimeNVPTX::CGOpenMPRuntimeNVPTX(CodeGenModule &CGM)
|
|||
}
|
||||
|
||||
void CGOpenMPRuntimeNVPTX::emitProcBindClause(CodeGenFunction &CGF,
|
||||
OpenMPProcBindClauseKind ProcBind,
|
||||
ProcBindKind ProcBind,
|
||||
SourceLocation Loc) {
|
||||
// Do nothing in case of SPMD mode and L0 parallel.
|
||||
if (getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_SPMD)
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
/// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
|
||||
/// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
|
||||
virtual void emitProcBindClause(CodeGenFunction &CGF,
|
||||
OpenMPProcBindClauseKind ProcBind,
|
||||
llvm::omp::ProcBindKind ProcBind,
|
||||
SourceLocation Loc) override;
|
||||
|
||||
/// Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32
|
||||
|
|
|
@ -11857,9 +11857,8 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
|
|||
ArgumentLoc, StartLoc, LParenLoc, EndLoc);
|
||||
break;
|
||||
case OMPC_proc_bind:
|
||||
Res = ActOnOpenMPProcBindClause(
|
||||
static_cast<OpenMPProcBindClauseKind>(Argument), ArgumentLoc, StartLoc,
|
||||
LParenLoc, EndLoc);
|
||||
Res = ActOnOpenMPProcBindClause(static_cast<ProcBindKind>(Argument),
|
||||
ArgumentLoc, StartLoc, LParenLoc, EndLoc);
|
||||
break;
|
||||
case OMPC_atomic_default_mem_order:
|
||||
Res = ActOnOpenMPAtomicDefaultMemOrderClause(
|
||||
|
@ -11980,15 +11979,16 @@ OMPClause *Sema::ActOnOpenMPDefaultClause(OpenMPDefaultClauseKind Kind,
|
|||
OMPDefaultClause(Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
|
||||
}
|
||||
|
||||
OMPClause *Sema::ActOnOpenMPProcBindClause(OpenMPProcBindClauseKind Kind,
|
||||
OMPClause *Sema::ActOnOpenMPProcBindClause(ProcBindKind Kind,
|
||||
SourceLocation KindKwLoc,
|
||||
SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc,
|
||||
SourceLocation EndLoc) {
|
||||
if (Kind == OMPC_PROC_BIND_unknown) {
|
||||
if (Kind == OMP_PROC_BIND_unknown) {
|
||||
Diag(KindKwLoc, diag::err_omp_unexpected_clause_value)
|
||||
<< getListOfPossibleValues(OMPC_proc_bind, /*First=*/0,
|
||||
/*Last=*/OMPC_PROC_BIND_unknown)
|
||||
<< getListOfPossibleValues(OMPC_proc_bind,
|
||||
/*First=*/unsigned(OMP_PROC_BIND_master),
|
||||
/*Last=*/5)
|
||||
<< getOpenMPClauseName(OMPC_proc_bind);
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -1616,7 +1616,7 @@ public:
|
|||
///
|
||||
/// By default, performs semantic analysis to build the new OpenMP clause.
|
||||
/// Subclasses may override this routine to provide different behavior.
|
||||
OMPClause *RebuildOMPProcBindClause(OpenMPProcBindClauseKind Kind,
|
||||
OMPClause *RebuildOMPProcBindClause(ProcBindKind Kind,
|
||||
SourceLocation KindKwLoc,
|
||||
SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc,
|
||||
|
|
|
@ -11771,8 +11771,7 @@ void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
|
|||
}
|
||||
|
||||
void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
|
||||
C->setProcBindKind(
|
||||
static_cast<OpenMPProcBindClauseKind>(Record.readInt()));
|
||||
C->setProcBindKind(static_cast<llvm::omp::ProcBindKind>(Record.readInt()));
|
||||
C->setLParenLoc(Record.readSourceLocation());
|
||||
C->setProcBindKindKwLoc(Record.readSourceLocation());
|
||||
}
|
||||
|
|
|
@ -6090,7 +6090,7 @@ void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) {
|
|||
}
|
||||
|
||||
void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *C) {
|
||||
Record.push_back(C->getProcBindKind());
|
||||
Record.push_back(unsigned(C->getProcBindKind()));
|
||||
Record.AddSourceLocation(C->getLParenLoc());
|
||||
Record.AddSourceLocation(C->getProcBindKindKwLoc());
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ __OMP_IDENT_FLAG(BARRIER_IMPL_WORKSHARE, 0x01C0)
|
|||
#endif
|
||||
|
||||
#define __OMP_PROC_BIND_KIND(Name, Value) \
|
||||
OMP_PROC_BIND_KIND(OMP_PB_##Name, #Name, Value)
|
||||
OMP_PROC_BIND_KIND(OMP_PROC_BIND_##Name, #Name, Value)
|
||||
|
||||
__OMP_PROC_BIND_KIND(master, 2)
|
||||
__OMP_PROC_BIND_KIND(close, 3)
|
||||
|
|
|
@ -271,7 +271,7 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::CreateParallel(
|
|||
getOrCreateRuntimeFunction(OMPRTL___kmpc_push_num_threads), Args);
|
||||
}
|
||||
|
||||
if (ProcBind != OMP_PB_default) {
|
||||
if (ProcBind != OMP_PROC_BIND_default) {
|
||||
// Build call __kmpc_push_proc_bind(&Ident, global_tid, proc_bind)
|
||||
Value *Args[] = {
|
||||
Ident, ThreadID,
|
||||
|
|
|
@ -247,7 +247,7 @@ TEST_F(OpenMPIRBuilderTest, ParallelSimple) {
|
|||
auto FiniCB = [&](InsertPointTy CodeGenIP) { ++NumFinalizationPoints; };
|
||||
|
||||
IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
|
||||
Loc, BodyGenCB, PrivCB, FiniCB, nullptr, nullptr, OMP_PB_default, false);
|
||||
Loc, BodyGenCB, PrivCB, FiniCB, nullptr, nullptr, OMP_PROC_BIND_default, false);
|
||||
|
||||
EXPECT_EQ(NumBodiesGenerated, 1U);
|
||||
EXPECT_EQ(NumPrivatizedVars, 1U);
|
||||
|
@ -342,7 +342,7 @@ TEST_F(OpenMPIRBuilderTest, ParallelIfCond) {
|
|||
|
||||
IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
|
||||
Loc, BodyGenCB, PrivCB, FiniCB, Builder.CreateIsNotNull(F->arg_begin()),
|
||||
nullptr, OMP_PB_default, false);
|
||||
nullptr, OMP_PROC_BIND_default, false);
|
||||
|
||||
EXPECT_EQ(NumBodiesGenerated, 1U);
|
||||
EXPECT_EQ(NumPrivatizedVars, 1U);
|
||||
|
@ -466,7 +466,7 @@ TEST_F(OpenMPIRBuilderTest, ParallelCancelBarrier) {
|
|||
|
||||
IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
|
||||
Loc, BodyGenCB, PrivCB, FiniCB, Builder.CreateIsNotNull(F->arg_begin()),
|
||||
nullptr, OMP_PB_default, true);
|
||||
nullptr, OMP_PROC_BIND_default, true);
|
||||
|
||||
EXPECT_EQ(NumBodiesGenerated, 1U);
|
||||
EXPECT_EQ(NumPrivatizedVars, 0U);
|
||||
|
|
Loading…
Reference in New Issue