[llvm] eb3e81f - [OpenMP][NFCI] Introduce llvm/IR/OpenMPConstants.h

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 9 22:10:57 PST 2019


Author: Johannes Doerfert
Date: 2019-12-10T00:10:09-06:00
New Revision: eb3e81f43f019cd90da87169aeff0eaddc4c9ecb

URL: https://github.com/llvm/llvm-project/commit/eb3e81f43f019cd90da87169aeff0eaddc4c9ecb
DIFF: https://github.com/llvm/llvm-project/commit/eb3e81f43f019cd90da87169aeff0eaddc4c9ecb.diff

LOG: [OpenMP][NFCI] Introduce llvm/IR/OpenMPConstants.h

Summary:
The new OpenMPConstants.h is a location for all OpenMP related constants
(and helpers) to live.

This patch moves the directives there (the enum OpenMPDirectiveKind) and
rewires Clang to use the new location.

Initially part of D69785.

Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim

Subscribers: jholewinski, ppenzin, penzn, llvm-commits, cfe-commits, jfb, guansong, bollu, hiraditya, mgorny

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D69853

Added: 
    llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
    llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
    llvm/lib/Frontend/CMakeLists.txt
    llvm/lib/Frontend/LLVMBuild.txt
    llvm/lib/Frontend/OpenMP/CMakeLists.txt
    llvm/lib/Frontend/OpenMP/LLVMBuild.txt
    llvm/lib/Frontend/OpenMP/OMPConstants.cpp

Modified: 
    clang/include/clang/AST/OpenMPClause.h
    clang/include/clang/AST/StmtOpenMP.h
    clang/include/clang/Basic/OpenMPKinds.def
    clang/include/clang/Basic/OpenMPKinds.h
    clang/lib/AST/CMakeLists.txt
    clang/lib/AST/OpenMPClause.cpp
    clang/lib/AST/StmtOpenMP.cpp
    clang/lib/Basic/OpenMPKinds.cpp
    clang/lib/CodeGen/CGOpenMPRuntime.cpp
    clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
    clang/lib/CodeGen/CGStmtOpenMP.cpp
    clang/lib/CodeGen/CodeGenFunction.h
    clang/lib/Parse/CMakeLists.txt
    clang/lib/Parse/ParseOpenMP.cpp
    clang/lib/Sema/CMakeLists.txt
    clang/lib/Sema/SemaOpenMP.cpp
    clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    clang/lib/Sema/TreeTransform.h
    clang/lib/Serialization/ASTWriter.cpp
    clang/lib/Serialization/ASTWriterStmt.cpp
    llvm/lib/CMakeLists.txt
    llvm/lib/LLVMBuild.txt

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h
index b2a2035dcb3c..72c638bf6460 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -111,7 +111,7 @@ class OMPClauseWithPreInit {
   Stmt *PreInit = nullptr;
 
   /// Region that captures the associated stmt.
-  OpenMPDirectiveKind CaptureRegion = OMPD_unknown;
+  OpenMPDirectiveKind CaptureRegion = llvm::omp::OMPD_unknown;
 
 protected:
   OMPClauseWithPreInit(const OMPClause *This) {
@@ -119,7 +119,9 @@ class OMPClauseWithPreInit {
   }
 
   /// Set pre-initialization statement for the clause.
-  void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion = OMPD_unknown) {
+  void
+  setPreInitStmt(Stmt *S,
+                 OpenMPDirectiveKind ThisRegion = llvm::omp::OMPD_unknown) {
     PreInit = S;
     CaptureRegion = ThisRegion;
   }
@@ -432,7 +434,7 @@ class OMPIfClause : public OMPClause, public OMPClauseWithPreInit {
   SourceLocation ColonLoc;
 
   /// Directive name modifier for the clause.
-  OpenMPDirectiveKind NameModifier = OMPD_unknown;
+  OpenMPDirectiveKind NameModifier = llvm::omp::OMPD_unknown;
 
   /// Name modifier location.
   SourceLocation NameModifierLoc;

diff  --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h
index cc10f9e4c48e..65f0afece224 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -366,8 +366,9 @@ class OMPParallelDirective : public OMPExecutableDirective {
   ///
   OMPParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                        unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
-                               StartLoc, EndLoc, NumClauses, 1),
+      : OMPExecutableDirective(this, OMPParallelDirectiveClass,
+                               llvm::omp::OMPD_parallel, StartLoc, EndLoc,
+                               NumClauses, 1),
         HasCancel(false) {}
 
   /// Build an empty directive.
@@ -375,9 +376,9 @@ class OMPParallelDirective : public OMPExecutableDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPParallelDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               1),
+      : OMPExecutableDirective(this, OMPParallelDirectiveClass,
+                               llvm::omp::OMPD_parallel, SourceLocation(),
+                               SourceLocation(), NumClauses, 1),
         HasCancel(false) {}
 
   /// Set cancel state.
@@ -1201,8 +1202,8 @@ class OMPSimdDirective : public OMPLoopDirective {
   ///
   OMPSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                    unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPSimdDirectiveClass, OMPD_simd, StartLoc,
-                         EndLoc, CollapsedNum, NumClauses) {}
+      : OMPLoopDirective(this, OMPSimdDirectiveClass, llvm::omp::OMPD_simd,
+                         StartLoc, EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -1210,7 +1211,7 @@ class OMPSimdDirective : public OMPLoopDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPSimdDirectiveClass, OMPD_simd,
+      : OMPLoopDirective(this, OMPSimdDirectiveClass, llvm::omp::OMPD_simd,
                          SourceLocation(), SourceLocation(), CollapsedNum,
                          NumClauses) {}
 
@@ -1270,8 +1271,8 @@ class OMPForDirective : public OMPLoopDirective {
   ///
   OMPForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                   unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPForDirectiveClass, OMPD_for, StartLoc, EndLoc,
-                         CollapsedNum, NumClauses),
+      : OMPLoopDirective(this, OMPForDirectiveClass, llvm::omp::OMPD_for,
+                         StartLoc, EndLoc, CollapsedNum, NumClauses),
         HasCancel(false) {}
 
   /// Build an empty directive.
@@ -1280,8 +1281,9 @@ class OMPForDirective : public OMPLoopDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPForDirective(unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPForDirectiveClass, OMPD_for, SourceLocation(),
-                         SourceLocation(), CollapsedNum, NumClauses),
+      : OMPLoopDirective(this, OMPForDirectiveClass, llvm::omp::OMPD_for,
+                         SourceLocation(), SourceLocation(), CollapsedNum,
+                         NumClauses),
         HasCancel(false) {}
 
   /// Set cancel state.
@@ -1343,8 +1345,9 @@ class OMPForSimdDirective : public OMPLoopDirective {
   ///
   OMPForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                       unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPForSimdDirectiveClass, OMPD_for_simd,
-                         StartLoc, EndLoc, CollapsedNum, NumClauses) {}
+      : OMPLoopDirective(this, OMPForSimdDirectiveClass,
+                         llvm::omp::OMPD_for_simd, StartLoc, EndLoc,
+                         CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -1352,9 +1355,9 @@ class OMPForSimdDirective : public OMPLoopDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPForSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPForSimdDirectiveClass, OMPD_for_simd,
-                         SourceLocation(), SourceLocation(), CollapsedNum,
-                         NumClauses) {}
+      : OMPLoopDirective(this, OMPForSimdDirectiveClass,
+                         llvm::omp::OMPD_for_simd, SourceLocation(),
+                         SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -1411,8 +1414,9 @@ class OMPSectionsDirective : public OMPExecutableDirective {
   ///
   OMPSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                        unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
-                               StartLoc, EndLoc, NumClauses, 1),
+      : OMPExecutableDirective(this, OMPSectionsDirectiveClass,
+                               llvm::omp::OMPD_sections, StartLoc, EndLoc,
+                               NumClauses, 1),
         HasCancel(false) {}
 
   /// Build an empty directive.
@@ -1420,9 +1424,9 @@ class OMPSectionsDirective : public OMPExecutableDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPSectionsDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               1),
+      : OMPExecutableDirective(this, OMPSectionsDirectiveClass,
+                               llvm::omp::OMPD_sections, SourceLocation(),
+                               SourceLocation(), NumClauses, 1),
         HasCancel(false) {}
 
   /// Set cancel state.
@@ -1477,15 +1481,16 @@ class OMPSectionDirective : public OMPExecutableDirective {
   /// \param EndLoc Ending location of the directive.
   ///
   OMPSectionDirective(SourceLocation StartLoc, SourceLocation EndLoc)
-      : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
-                               StartLoc, EndLoc, 0, 1),
+      : OMPExecutableDirective(this, OMPSectionDirectiveClass,
+                               llvm::omp::OMPD_section, StartLoc, EndLoc, 0, 1),
         HasCancel(false) {}
 
   /// Build an empty directive.
   ///
   explicit OMPSectionDirective()
-      : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
-                               SourceLocation(), SourceLocation(), 0, 1),
+      : OMPExecutableDirective(this, OMPSectionDirectiveClass,
+                               llvm::omp::OMPD_section, SourceLocation(),
+                               SourceLocation(), 0, 1),
         HasCancel(false) {}
 
 public:
@@ -1537,17 +1542,18 @@ class OMPSingleDirective : public OMPExecutableDirective {
   ///
   OMPSingleDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                      unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
-                               StartLoc, EndLoc, NumClauses, 1) {}
+      : OMPExecutableDirective(this, OMPSingleDirectiveClass,
+                               llvm::omp::OMPD_single, StartLoc, EndLoc,
+                               NumClauses, 1) {}
 
   /// Build an empty directive.
   ///
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPSingleDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               1) {}
+      : OMPExecutableDirective(this, OMPSingleDirectiveClass,
+                               llvm::omp::OMPD_single, SourceLocation(),
+                               SourceLocation(), NumClauses, 1) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -1590,14 +1596,16 @@ class OMPMasterDirective : public OMPExecutableDirective {
   /// \param EndLoc Ending location of the directive.
   ///
   OMPMasterDirective(SourceLocation StartLoc, SourceLocation EndLoc)
-      : OMPExecutableDirective(this, OMPMasterDirectiveClass, OMPD_master,
-                               StartLoc, EndLoc, 0, 1) {}
+      : OMPExecutableDirective(this, OMPMasterDirectiveClass,
+                               llvm::omp::OMPD_master, StartLoc, EndLoc, 0, 1) {
+  }
 
   /// Build an empty directive.
   ///
   explicit OMPMasterDirective()
-      : OMPExecutableDirective(this, OMPMasterDirectiveClass, OMPD_master,
-                               SourceLocation(), SourceLocation(), 0, 1) {}
+      : OMPExecutableDirective(this, OMPMasterDirectiveClass,
+                               llvm::omp::OMPD_master, SourceLocation(),
+                               SourceLocation(), 0, 1) {}
 
 public:
   /// Creates directive.
@@ -1642,8 +1650,9 @@ class OMPCriticalDirective : public OMPExecutableDirective {
   ///
   OMPCriticalDirective(const DeclarationNameInfo &Name, SourceLocation StartLoc,
                        SourceLocation EndLoc, unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPCriticalDirectiveClass, OMPD_critical,
-                               StartLoc, EndLoc, NumClauses, 1),
+      : OMPExecutableDirective(this, OMPCriticalDirectiveClass,
+                               llvm::omp::OMPD_critical, StartLoc, EndLoc,
+                               NumClauses, 1),
         DirName(Name) {}
 
   /// Build an empty directive.
@@ -1651,9 +1660,9 @@ class OMPCriticalDirective : public OMPExecutableDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPCriticalDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPCriticalDirectiveClass, OMPD_critical,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               1),
+      : OMPExecutableDirective(this, OMPCriticalDirectiveClass,
+                               llvm::omp::OMPD_critical, SourceLocation(),
+                               SourceLocation(), NumClauses, 1),
         DirName() {}
 
   /// Set name of the directive.
@@ -1718,8 +1727,9 @@ class OMPParallelForDirective : public OMPLoopDirective {
   ///
   OMPParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                           unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPParallelForDirectiveClass, OMPD_parallel_for,
-                         StartLoc, EndLoc, CollapsedNum, NumClauses),
+      : OMPLoopDirective(this, OMPParallelForDirectiveClass,
+                         llvm::omp::OMPD_parallel_for, StartLoc, EndLoc,
+                         CollapsedNum, NumClauses),
         HasCancel(false) {}
 
   /// Build an empty directive.
@@ -1728,9 +1738,9 @@ class OMPParallelForDirective : public OMPLoopDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPParallelForDirective(unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPParallelForDirectiveClass, OMPD_parallel_for,
-                         SourceLocation(), SourceLocation(), CollapsedNum,
-                         NumClauses),
+      : OMPLoopDirective(this, OMPParallelForDirectiveClass,
+                         llvm::omp::OMPD_parallel_for, SourceLocation(),
+                         SourceLocation(), CollapsedNum, NumClauses),
         HasCancel(false) {}
 
   /// Set cancel state.
@@ -1795,8 +1805,8 @@ class OMPParallelForSimdDirective : public OMPLoopDirective {
   OMPParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                               unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass,
-                         OMPD_parallel_for_simd, StartLoc, EndLoc, CollapsedNum,
-                         NumClauses) {}
+                         llvm::omp::OMPD_parallel_for_simd, StartLoc, EndLoc,
+                         CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -1806,7 +1816,7 @@ class OMPParallelForSimdDirective : public OMPLoopDirective {
   explicit OMPParallelForSimdDirective(unsigned CollapsedNum,
                                        unsigned NumClauses)
       : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass,
-                         OMPD_parallel_for_simd, SourceLocation(),
+                         llvm::omp::OMPD_parallel_for_simd, SourceLocation(),
                          SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
@@ -1856,13 +1866,14 @@ class OMPParallelMasterDirective : public OMPExecutableDirective {
   OMPParallelMasterDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                              unsigned NumClauses)
       : OMPExecutableDirective(this, OMPParallelMasterDirectiveClass,
-                               OMPD_parallel_master, StartLoc, EndLoc,
-                               NumClauses, 1) {}
+                               llvm::omp::OMPD_parallel_master, StartLoc,
+                               EndLoc, NumClauses, 1) {}
 
   explicit OMPParallelMasterDirective(unsigned NumClauses)
       : OMPExecutableDirective(this, OMPParallelMasterDirectiveClass,
-                               OMPD_parallel_master, SourceLocation(),
-                               SourceLocation(), NumClauses, 1) {}
+                               llvm::omp::OMPD_parallel_master,
+                               SourceLocation(), SourceLocation(), NumClauses,
+                               1) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -1915,8 +1926,8 @@ class OMPParallelSectionsDirective : public OMPExecutableDirective {
   OMPParallelSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                                unsigned NumClauses)
       : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
-                               OMPD_parallel_sections, StartLoc, EndLoc,
-                               NumClauses, 1),
+                               llvm::omp::OMPD_parallel_sections, StartLoc,
+                               EndLoc, NumClauses, 1),
         HasCancel(false) {}
 
   /// Build an empty directive.
@@ -1925,8 +1936,9 @@ class OMPParallelSectionsDirective : public OMPExecutableDirective {
   ///
   explicit OMPParallelSectionsDirective(unsigned NumClauses)
       : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
-                               OMPD_parallel_sections, SourceLocation(),
-                               SourceLocation(), NumClauses, 1),
+                               llvm::omp::OMPD_parallel_sections,
+                               SourceLocation(), SourceLocation(), NumClauses,
+                               1),
         HasCancel(false) {}
 
   /// Set cancel state.
@@ -1984,8 +1996,9 @@ class OMPTaskDirective : public OMPExecutableDirective {
   ///
   OMPTaskDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                    unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPTaskDirectiveClass, OMPD_task, StartLoc,
-                               EndLoc, NumClauses, 1),
+      : OMPExecutableDirective(this, OMPTaskDirectiveClass,
+                               llvm::omp::OMPD_task, StartLoc, EndLoc,
+                               NumClauses, 1),
         HasCancel(false) {}
 
   /// Build an empty directive.
@@ -1993,9 +2006,9 @@ class OMPTaskDirective : public OMPExecutableDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPTaskDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPTaskDirectiveClass, OMPD_task,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               1),
+      : OMPExecutableDirective(this, OMPTaskDirectiveClass,
+                               llvm::omp::OMPD_task, SourceLocation(),
+                               SourceLocation(), NumClauses, 1),
         HasCancel(false) {}
 
   /// Set cancel state.
@@ -2047,14 +2060,16 @@ class OMPTaskyieldDirective : public OMPExecutableDirective {
   /// \param EndLoc Ending location of the directive.
   ///
   OMPTaskyieldDirective(SourceLocation StartLoc, SourceLocation EndLoc)
-      : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, OMPD_taskyield,
-                               StartLoc, EndLoc, 0, 0) {}
+      : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass,
+                               llvm::omp::OMPD_taskyield, StartLoc, EndLoc, 0,
+                               0) {}
 
   /// Build an empty directive.
   ///
   explicit OMPTaskyieldDirective()
-      : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, OMPD_taskyield,
-                               SourceLocation(), SourceLocation(), 0, 0) {}
+      : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass,
+                               llvm::omp::OMPD_taskyield, SourceLocation(),
+                               SourceLocation(), 0, 0) {}
 
 public:
   /// Creates directive.
@@ -2091,14 +2106,16 @@ class OMPBarrierDirective : public OMPExecutableDirective {
   /// \param EndLoc Ending location of the directive.
   ///
   OMPBarrierDirective(SourceLocation StartLoc, SourceLocation EndLoc)
-      : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
-                               StartLoc, EndLoc, 0, 0) {}
+      : OMPExecutableDirective(this, OMPBarrierDirectiveClass,
+                               llvm::omp::OMPD_barrier, StartLoc, EndLoc, 0,
+                               0) {}
 
   /// Build an empty directive.
   ///
   explicit OMPBarrierDirective()
-      : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
-                               SourceLocation(), SourceLocation(), 0, 0) {}
+      : OMPExecutableDirective(this, OMPBarrierDirectiveClass,
+                               llvm::omp::OMPD_barrier, SourceLocation(),
+                               SourceLocation(), 0, 0) {}
 
 public:
   /// Creates directive.
@@ -2135,14 +2152,16 @@ class OMPTaskwaitDirective : public OMPExecutableDirective {
   /// \param EndLoc Ending location of the directive.
   ///
   OMPTaskwaitDirective(SourceLocation StartLoc, SourceLocation EndLoc)
-      : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, OMPD_taskwait,
-                               StartLoc, EndLoc, 0, 0) {}
+      : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass,
+                               llvm::omp::OMPD_taskwait, StartLoc, EndLoc, 0,
+                               0) {}
 
   /// Build an empty directive.
   ///
   explicit OMPTaskwaitDirective()
-      : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, OMPD_taskwait,
-                               SourceLocation(), SourceLocation(), 0, 0) {}
+      : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass,
+                               llvm::omp::OMPD_taskwait, SourceLocation(),
+                               SourceLocation(), 0, 0) {}
 
 public:
   /// Creates directive.
@@ -2181,16 +2200,17 @@ class OMPTaskgroupDirective : public OMPExecutableDirective {
   ///
   OMPTaskgroupDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                         unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
-                               StartLoc, EndLoc, NumClauses, 2) {}
+      : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass,
+                               llvm::omp::OMPD_taskgroup, StartLoc, EndLoc,
+                               NumClauses, 2) {}
 
   /// Build an empty directive.
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPTaskgroupDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               2) {}
+      : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass,
+                               llvm::omp::OMPD_taskgroup, SourceLocation(),
+                               SourceLocation(), NumClauses, 2) {}
 
   /// Sets the task_reduction return variable.
   void setReductionRef(Expr *RR) {
@@ -2254,17 +2274,18 @@ class OMPFlushDirective : public OMPExecutableDirective {
   ///
   OMPFlushDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                     unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
-                               StartLoc, EndLoc, NumClauses, 0) {}
+      : OMPExecutableDirective(this, OMPFlushDirectiveClass,
+                               llvm::omp::OMPD_flush, StartLoc, EndLoc,
+                               NumClauses, 0) {}
 
   /// Build an empty directive.
   ///
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPFlushDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               0) {}
+      : OMPExecutableDirective(this, OMPFlushDirectiveClass,
+                               llvm::omp::OMPD_flush, SourceLocation(),
+                               SourceLocation(), NumClauses, 0) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -2309,17 +2330,18 @@ class OMPOrderedDirective : public OMPExecutableDirective {
   ///
   OMPOrderedDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                       unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
-                               StartLoc, EndLoc, NumClauses, 1) {}
+      : OMPExecutableDirective(this, OMPOrderedDirectiveClass,
+                               llvm::omp::OMPD_ordered, StartLoc, EndLoc,
+                               NumClauses, 1) {}
 
   /// Build an empty directive.
   ///
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPOrderedDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               1) {}
+      : OMPExecutableDirective(this, OMPOrderedDirectiveClass,
+                               llvm::omp::OMPD_ordered, SourceLocation(),
+                               SourceLocation(), NumClauses, 1) {}
 
 public:
   /// Creates directive.
@@ -2384,8 +2406,9 @@ class OMPAtomicDirective : public OMPExecutableDirective {
   ///
   OMPAtomicDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                      unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
-                               StartLoc, EndLoc, NumClauses, 5),
+      : OMPExecutableDirective(this, OMPAtomicDirectiveClass,
+                               llvm::omp::OMPD_atomic, StartLoc, EndLoc,
+                               NumClauses, 5),
         IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
 
   /// Build an empty directive.
@@ -2393,9 +2416,9 @@ class OMPAtomicDirective : public OMPExecutableDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPAtomicDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               5),
+      : OMPExecutableDirective(this, OMPAtomicDirectiveClass,
+                               llvm::omp::OMPD_atomic, SourceLocation(),
+                               SourceLocation(), NumClauses, 5),
         IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
 
   /// Set 'x' part of the associated expression/statement.
@@ -2498,17 +2521,18 @@ class OMPTargetDirective : public OMPExecutableDirective {
   ///
   OMPTargetDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                      unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
-                               StartLoc, EndLoc, NumClauses, 1) {}
+      : OMPExecutableDirective(this, OMPTargetDirectiveClass,
+                               llvm::omp::OMPD_target, StartLoc, EndLoc,
+                               NumClauses, 1) {}
 
   /// Build an empty directive.
   ///
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPTargetDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               1) {}
+      : OMPExecutableDirective(this, OMPTargetDirectiveClass,
+                               llvm::omp::OMPD_target, SourceLocation(),
+                               SourceLocation(), NumClauses, 1) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -2557,8 +2581,8 @@ class OMPTargetDataDirective : public OMPExecutableDirective {
   OMPTargetDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                          unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
-                               OMPD_target_data, StartLoc, EndLoc, NumClauses,
-                               1) {}
+                               llvm::omp::OMPD_target_data, StartLoc, EndLoc,
+                               NumClauses, 1) {}
 
   /// Build an empty directive.
   ///
@@ -2566,7 +2590,7 @@ class OMPTargetDataDirective : public OMPExecutableDirective {
   ///
   explicit OMPTargetDataDirective(unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
-                               OMPD_target_data, SourceLocation(),
+                               llvm::omp::OMPD_target_data, SourceLocation(),
                                SourceLocation(), NumClauses, 1) {}
 
 public:
@@ -2615,8 +2639,8 @@ class OMPTargetEnterDataDirective : public OMPExecutableDirective {
   OMPTargetEnterDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                               unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
-                               OMPD_target_enter_data, StartLoc, EndLoc,
-                               NumClauses, /*NumChildren=*/1) {}
+                               llvm::omp::OMPD_target_enter_data, StartLoc,
+                               EndLoc, NumClauses, /*NumChildren=*/1) {}
 
   /// Build an empty directive.
   ///
@@ -2624,8 +2648,8 @@ class OMPTargetEnterDataDirective : public OMPExecutableDirective {
   ///
   explicit OMPTargetEnterDataDirective(unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
-                               OMPD_target_enter_data, SourceLocation(),
-                               SourceLocation(), NumClauses,
+                               llvm::omp::OMPD_target_enter_data,
+                               SourceLocation(), SourceLocation(), NumClauses,
                                /*NumChildren=*/1) {}
 
 public:
@@ -2674,8 +2698,8 @@ class OMPTargetExitDataDirective : public OMPExecutableDirective {
   OMPTargetExitDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                              unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
-                               OMPD_target_exit_data, StartLoc, EndLoc,
-                               NumClauses, /*NumChildren=*/1) {}
+                               llvm::omp::OMPD_target_exit_data, StartLoc,
+                               EndLoc, NumClauses, /*NumChildren=*/1) {}
 
   /// Build an empty directive.
   ///
@@ -2683,8 +2707,8 @@ class OMPTargetExitDataDirective : public OMPExecutableDirective {
   ///
   explicit OMPTargetExitDataDirective(unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
-                               OMPD_target_exit_data, SourceLocation(),
-                               SourceLocation(), NumClauses,
+                               llvm::omp::OMPD_target_exit_data,
+                               SourceLocation(), SourceLocation(), NumClauses,
                                /*NumChildren=*/1) {}
 
 public:
@@ -2732,8 +2756,8 @@ class OMPTargetParallelDirective : public OMPExecutableDirective {
   OMPTargetParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                              unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
-                               OMPD_target_parallel, StartLoc, EndLoc,
-                               NumClauses, /*NumChildren=*/1) {}
+                               llvm::omp::OMPD_target_parallel, StartLoc,
+                               EndLoc, NumClauses, /*NumChildren=*/1) {}
 
   /// Build an empty directive.
   ///
@@ -2741,8 +2765,8 @@ class OMPTargetParallelDirective : public OMPExecutableDirective {
   ///
   explicit OMPTargetParallelDirective(unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
-                               OMPD_target_parallel, SourceLocation(),
-                               SourceLocation(), NumClauses,
+                               llvm::omp::OMPD_target_parallel,
+                               SourceLocation(), SourceLocation(), NumClauses,
                                /*NumChildren=*/1) {}
 
 public:
@@ -2797,7 +2821,7 @@ class OMPTargetParallelForDirective : public OMPLoopDirective {
   OMPTargetParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                                 unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
-                         OMPD_target_parallel_for, StartLoc, EndLoc,
+                         llvm::omp::OMPD_target_parallel_for, StartLoc, EndLoc,
                          CollapsedNum, NumClauses),
         HasCancel(false) {}
 
@@ -2809,7 +2833,7 @@ class OMPTargetParallelForDirective : public OMPLoopDirective {
   explicit OMPTargetParallelForDirective(unsigned CollapsedNum,
                                          unsigned NumClauses)
       : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
-                         OMPD_target_parallel_for, SourceLocation(),
+                         llvm::omp::OMPD_target_parallel_for, SourceLocation(),
                          SourceLocation(), CollapsedNum, NumClauses),
         HasCancel(false) {}
 
@@ -2871,17 +2895,18 @@ class OMPTeamsDirective : public OMPExecutableDirective {
   ///
   OMPTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                     unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
-                               StartLoc, EndLoc, NumClauses, 1) {}
+      : OMPExecutableDirective(this, OMPTeamsDirectiveClass,
+                               llvm::omp::OMPD_teams, StartLoc, EndLoc,
+                               NumClauses, 1) {}
 
   /// Build an empty directive.
   ///
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPTeamsDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               1) {}
+      : OMPExecutableDirective(this, OMPTeamsDirectiveClass,
+                               llvm::omp::OMPD_teams, SourceLocation(),
+                               SourceLocation(), NumClauses, 1) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -2928,16 +2953,17 @@ class OMPCancellationPointDirective : public OMPExecutableDirective {
   ///
   OMPCancellationPointDirective(SourceLocation StartLoc, SourceLocation EndLoc)
       : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
-                               OMPD_cancellation_point, StartLoc, EndLoc, 0, 0),
-        CancelRegion(OMPD_unknown) {}
+                               llvm::omp::OMPD_cancellation_point, StartLoc,
+                               EndLoc, 0, 0),
+        CancelRegion(llvm::omp::OMPD_unknown) {}
 
   /// Build an empty directive.
   ///
   explicit OMPCancellationPointDirective()
       : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
-                               OMPD_cancellation_point, SourceLocation(),
-                               SourceLocation(), 0, 0),
-        CancelRegion(OMPD_unknown) {}
+                               llvm::omp::OMPD_cancellation_point,
+                               SourceLocation(), SourceLocation(), 0, 0),
+        CancelRegion(llvm::omp::OMPD_unknown) {}
 
   /// Set cancel region for current cancellation point.
   /// \param CR Cancellation region.
@@ -2987,18 +3013,19 @@ class OMPCancelDirective : public OMPExecutableDirective {
   ///
   OMPCancelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                      unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
-                               StartLoc, EndLoc, NumClauses, 0),
-        CancelRegion(OMPD_unknown) {}
+      : OMPExecutableDirective(this, OMPCancelDirectiveClass,
+                               llvm::omp::OMPD_cancel, StartLoc, EndLoc,
+                               NumClauses, 0),
+        CancelRegion(llvm::omp::OMPD_unknown) {}
 
   /// Build an empty directive.
   ///
   /// \param NumClauses Number of clauses.
   explicit OMPCancelDirective(unsigned NumClauses)
-      : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
-                               SourceLocation(), SourceLocation(), NumClauses,
-                               0),
-        CancelRegion(OMPD_unknown) {}
+      : OMPExecutableDirective(this, OMPCancelDirectiveClass,
+                               llvm::omp::OMPD_cancel, SourceLocation(),
+                               SourceLocation(), NumClauses, 0),
+        CancelRegion(llvm::omp::OMPD_unknown) {}
 
   /// Set cancel region for current cancellation point.
   /// \param CR Cancellation region.
@@ -3052,8 +3079,9 @@ class OMPTaskLoopDirective : public OMPLoopDirective {
   ///
   OMPTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                        unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
-                         StartLoc, EndLoc, CollapsedNum, NumClauses) {}
+      : OMPLoopDirective(this, OMPTaskLoopDirectiveClass,
+                         llvm::omp::OMPD_taskloop, StartLoc, EndLoc,
+                         CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -3061,9 +3089,9 @@ class OMPTaskLoopDirective : public OMPLoopDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPTaskLoopDirective(unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
-                         SourceLocation(), SourceLocation(), CollapsedNum,
-                         NumClauses) {}
+      : OMPLoopDirective(this, OMPTaskLoopDirectiveClass,
+                         llvm::omp::OMPD_taskloop, SourceLocation(),
+                         SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -3118,8 +3146,8 @@ class OMPTaskLoopSimdDirective : public OMPLoopDirective {
   OMPTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                            unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
-                         OMPD_taskloop_simd, StartLoc, EndLoc, CollapsedNum,
-                         NumClauses) {}
+                         llvm::omp::OMPD_taskloop_simd, StartLoc, EndLoc,
+                         CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -3128,8 +3156,8 @@ class OMPTaskLoopSimdDirective : public OMPLoopDirective {
   ///
   explicit OMPTaskLoopSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
-                         OMPD_taskloop_simd, SourceLocation(), SourceLocation(),
-                         CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_taskloop_simd, SourceLocation(),
+                         SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -3185,8 +3213,8 @@ class OMPMasterTaskLoopDirective : public OMPLoopDirective {
   OMPMasterTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                              unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPMasterTaskLoopDirectiveClass,
-                         OMPD_master_taskloop, StartLoc, EndLoc, CollapsedNum,
-                         NumClauses) {}
+                         llvm::omp::OMPD_master_taskloop, StartLoc, EndLoc,
+                         CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -3196,7 +3224,7 @@ class OMPMasterTaskLoopDirective : public OMPLoopDirective {
   explicit OMPMasterTaskLoopDirective(unsigned CollapsedNum,
                                       unsigned NumClauses)
       : OMPLoopDirective(this, OMPMasterTaskLoopDirectiveClass,
-                         OMPD_master_taskloop, SourceLocation(),
+                         llvm::omp::OMPD_master_taskloop, SourceLocation(),
                          SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
@@ -3253,7 +3281,7 @@ class OMPMasterTaskLoopSimdDirective : public OMPLoopDirective {
   OMPMasterTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                                  unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPMasterTaskLoopSimdDirectiveClass,
-                         OMPD_master_taskloop_simd, StartLoc, EndLoc,
+                         llvm::omp::OMPD_master_taskloop_simd, StartLoc, EndLoc,
                          CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
@@ -3264,7 +3292,7 @@ class OMPMasterTaskLoopSimdDirective : public OMPLoopDirective {
   explicit OMPMasterTaskLoopSimdDirective(unsigned CollapsedNum,
                                           unsigned NumClauses)
       : OMPLoopDirective(this, OMPMasterTaskLoopSimdDirectiveClass,
-                         OMPD_master_taskloop_simd, SourceLocation(),
+                         llvm::omp::OMPD_master_taskloop_simd, SourceLocation(),
                          SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
@@ -3322,8 +3350,8 @@ class OMPParallelMasterTaskLoopDirective : public OMPLoopDirective {
                                      SourceLocation EndLoc,
                                      unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPParallelMasterTaskLoopDirectiveClass,
-                         OMPD_parallel_master_taskloop, StartLoc, EndLoc,
-                         CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_parallel_master_taskloop, StartLoc,
+                         EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -3333,8 +3361,9 @@ class OMPParallelMasterTaskLoopDirective : public OMPLoopDirective {
   explicit OMPParallelMasterTaskLoopDirective(unsigned CollapsedNum,
                                               unsigned NumClauses)
       : OMPLoopDirective(this, OMPParallelMasterTaskLoopDirectiveClass,
-                         OMPD_parallel_master_taskloop, SourceLocation(),
-                         SourceLocation(), CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_parallel_master_taskloop,
+                         SourceLocation(), SourceLocation(), CollapsedNum,
+                         NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -3393,8 +3422,8 @@ class OMPParallelMasterTaskLoopSimdDirective : public OMPLoopDirective {
                                          unsigned CollapsedNum,
                                          unsigned NumClauses)
       : OMPLoopDirective(this, OMPParallelMasterTaskLoopSimdDirectiveClass,
-                         OMPD_parallel_master_taskloop_simd, StartLoc, EndLoc,
-                         CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_parallel_master_taskloop_simd,
+                         StartLoc, EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -3404,8 +3433,9 @@ class OMPParallelMasterTaskLoopSimdDirective : public OMPLoopDirective {
   explicit OMPParallelMasterTaskLoopSimdDirective(unsigned CollapsedNum,
                                                   unsigned NumClauses)
       : OMPLoopDirective(this, OMPParallelMasterTaskLoopSimdDirectiveClass,
-                         OMPD_parallel_master_taskloop_simd, SourceLocation(),
-                         SourceLocation(), CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_parallel_master_taskloop_simd,
+                         SourceLocation(), SourceLocation(), CollapsedNum,
+                         NumClauses) {}
 
 public:
   /// Creates directive with a list of \p Clauses.
@@ -3459,9 +3489,9 @@ class OMPDistributeDirective : public OMPLoopDirective {
   ///
   OMPDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                          unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
-                         StartLoc, EndLoc, CollapsedNum, NumClauses)
-        {}
+      : OMPLoopDirective(this, OMPDistributeDirectiveClass,
+                         llvm::omp::OMPD_distribute, StartLoc, EndLoc,
+                         CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -3469,10 +3499,9 @@ class OMPDistributeDirective : public OMPLoopDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPDistributeDirective(unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
-                         SourceLocation(), SourceLocation(), CollapsedNum,
-                         NumClauses)
-        {}
+      : OMPLoopDirective(this, OMPDistributeDirectiveClass,
+                         llvm::omp::OMPD_distribute, SourceLocation(),
+                         SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -3526,8 +3555,8 @@ class OMPTargetUpdateDirective : public OMPExecutableDirective {
   OMPTargetUpdateDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                            unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
-                               OMPD_target_update, StartLoc, EndLoc, NumClauses,
-                               1) {}
+                               llvm::omp::OMPD_target_update, StartLoc, EndLoc,
+                               NumClauses, 1) {}
 
   /// Build an empty directive.
   ///
@@ -3535,7 +3564,7 @@ class OMPTargetUpdateDirective : public OMPExecutableDirective {
   ///
   explicit OMPTargetUpdateDirective(unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
-                               OMPD_target_update, SourceLocation(),
+                               llvm::omp::OMPD_target_update, SourceLocation(),
                                SourceLocation(), NumClauses, 1) {}
 
 public:
@@ -3590,8 +3619,9 @@ class OMPDistributeParallelForDirective : public OMPLoopDirective {
                                     SourceLocation EndLoc,
                                     unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
-                         OMPD_distribute_parallel_for, StartLoc, EndLoc,
-                         CollapsedNum, NumClauses), HasCancel(false) {}
+                         llvm::omp::OMPD_distribute_parallel_for, StartLoc,
+                         EndLoc, CollapsedNum, NumClauses),
+        HasCancel(false) {}
 
   /// Build an empty directive.
   ///
@@ -3601,8 +3631,9 @@ class OMPDistributeParallelForDirective : public OMPLoopDirective {
   explicit OMPDistributeParallelForDirective(unsigned CollapsedNum,
                                              unsigned NumClauses)
       : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
-                         OMPD_distribute_parallel_for, SourceLocation(),
-                         SourceLocation(), CollapsedNum, NumClauses),
+                         llvm::omp::OMPD_distribute_parallel_for,
+                         SourceLocation(), SourceLocation(), CollapsedNum,
+                         NumClauses),
         HasCancel(false) {}
 
   /// Set cancel state.
@@ -3669,7 +3700,7 @@ class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective {
                                         unsigned CollapsedNum,
                                         unsigned NumClauses)
       : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
-                         OMPD_distribute_parallel_for_simd, StartLoc,
+                         llvm::omp::OMPD_distribute_parallel_for_simd, StartLoc,
                          EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
@@ -3680,7 +3711,7 @@ class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective {
   explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum,
                                                  unsigned NumClauses)
       : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
-                         OMPD_distribute_parallel_for_simd,
+                         llvm::omp::OMPD_distribute_parallel_for_simd,
                          SourceLocation(), SourceLocation(), CollapsedNum,
                          NumClauses) {}
 
@@ -3736,8 +3767,8 @@ class OMPDistributeSimdDirective final : public OMPLoopDirective {
   OMPDistributeSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                              unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
-                         OMPD_distribute_simd, StartLoc, EndLoc, CollapsedNum,
-                         NumClauses) {}
+                         llvm::omp::OMPD_distribute_simd, StartLoc, EndLoc,
+                         CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -3747,7 +3778,7 @@ class OMPDistributeSimdDirective final : public OMPLoopDirective {
   explicit OMPDistributeSimdDirective(unsigned CollapsedNum,
                                       unsigned NumClauses)
       : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
-                         OMPD_distribute_simd, SourceLocation(),
+                         llvm::omp::OMPD_distribute_simd, SourceLocation(),
                          SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
@@ -3801,11 +3832,12 @@ class OMPTargetParallelForSimdDirective final : public OMPLoopDirective {
   /// \param CollapsedNum Number of collapsed nested loops.
   /// \param NumClauses Number of clauses.
   ///
-  OMPTargetParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
-                                unsigned CollapsedNum, unsigned NumClauses)
+  OMPTargetParallelForSimdDirective(SourceLocation StartLoc,
+                                    SourceLocation EndLoc,
+                                    unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
-                         OMPD_target_parallel_for_simd, StartLoc, EndLoc,
-                         CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_target_parallel_for_simd, StartLoc,
+                         EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -3815,8 +3847,9 @@ class OMPTargetParallelForSimdDirective final : public OMPLoopDirective {
   explicit OMPTargetParallelForSimdDirective(unsigned CollapsedNum,
                                              unsigned NumClauses)
       : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
-                         OMPD_target_parallel_for_simd, SourceLocation(),
-                         SourceLocation(), CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_target_parallel_for_simd,
+                         SourceLocation(), SourceLocation(), CollapsedNum,
+                         NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -3872,8 +3905,8 @@ class OMPTargetSimdDirective final : public OMPLoopDirective {
   OMPTargetSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                          unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPTargetSimdDirectiveClass,
-                         OMPD_target_simd, StartLoc, EndLoc, CollapsedNum,
-                         NumClauses) {}
+                         llvm::omp::OMPD_target_simd, StartLoc, EndLoc,
+                         CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -3881,9 +3914,9 @@ class OMPTargetSimdDirective final : public OMPLoopDirective {
   /// \param NumClauses Number of clauses.
   ///
   explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
-      : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd,
-                         SourceLocation(),SourceLocation(), CollapsedNum,
-                         NumClauses) {}
+      : OMPLoopDirective(this, OMPTargetSimdDirectiveClass,
+                         llvm::omp::OMPD_target_simd, SourceLocation(),
+                         SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -3938,7 +3971,7 @@ class OMPTeamsDistributeDirective final : public OMPLoopDirective {
   OMPTeamsDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                               unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
-                         OMPD_teams_distribute, StartLoc, EndLoc,
+                         llvm::omp::OMPD_teams_distribute, StartLoc, EndLoc,
                          CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
@@ -3949,7 +3982,7 @@ class OMPTeamsDistributeDirective final : public OMPLoopDirective {
   explicit OMPTeamsDistributeDirective(unsigned CollapsedNum,
                                        unsigned NumClauses)
       : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
-                         OMPD_teams_distribute, SourceLocation(),
+                         llvm::omp::OMPD_teams_distribute, SourceLocation(),
                          SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
@@ -4007,8 +4040,8 @@ class OMPTeamsDistributeSimdDirective final : public OMPLoopDirective {
                                   SourceLocation EndLoc, unsigned CollapsedNum,
                                   unsigned NumClauses)
       : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
-                         OMPD_teams_distribute_simd, StartLoc, EndLoc,
-                         CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_teams_distribute_simd, StartLoc,
+                         EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -4018,8 +4051,9 @@ class OMPTeamsDistributeSimdDirective final : public OMPLoopDirective {
   explicit OMPTeamsDistributeSimdDirective(unsigned CollapsedNum,
                                            unsigned NumClauses)
       : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
-                         OMPD_teams_distribute_simd, SourceLocation(),
-                         SourceLocation(), CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_teams_distribute_simd,
+                         SourceLocation(), SourceLocation(), CollapsedNum,
+                         NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -4079,8 +4113,8 @@ class OMPTeamsDistributeParallelForSimdDirective final
                                              unsigned CollapsedNum,
                                              unsigned NumClauses)
       : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
-                         OMPD_teams_distribute_parallel_for_simd, StartLoc,
-                         EndLoc, CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_teams_distribute_parallel_for_simd,
+                         StartLoc, EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -4090,7 +4124,7 @@ class OMPTeamsDistributeParallelForSimdDirective final
   explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum,
                                                       unsigned NumClauses)
       : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
-                         OMPD_teams_distribute_parallel_for_simd,
+                         llvm::omp::OMPD_teams_distribute_parallel_for_simd,
                          SourceLocation(), SourceLocation(), CollapsedNum,
                          NumClauses) {}
 
@@ -4151,8 +4185,9 @@ class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective {
                                          unsigned CollapsedNum,
                                          unsigned NumClauses)
       : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
-                         OMPD_teams_distribute_parallel_for, StartLoc, EndLoc,
-                         CollapsedNum, NumClauses), HasCancel(false) {}
+                         llvm::omp::OMPD_teams_distribute_parallel_for,
+                         StartLoc, EndLoc, CollapsedNum, NumClauses),
+        HasCancel(false) {}
 
   /// Build an empty directive.
   ///
@@ -4162,8 +4197,9 @@ class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective {
   explicit OMPTeamsDistributeParallelForDirective(unsigned CollapsedNum,
                                                   unsigned NumClauses)
       : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
-                         OMPD_teams_distribute_parallel_for, SourceLocation(),
-                         SourceLocation(), CollapsedNum, NumClauses),
+                         llvm::omp::OMPD_teams_distribute_parallel_for,
+                         SourceLocation(), SourceLocation(), CollapsedNum,
+                         NumClauses),
         HasCancel(false) {}
 
   /// Set cancel state.
@@ -4223,8 +4259,8 @@ class OMPTargetTeamsDirective final : public OMPExecutableDirective {
   OMPTargetTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                           unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
-                               OMPD_target_teams, StartLoc, EndLoc, NumClauses,
-                               1) {}
+                               llvm::omp::OMPD_target_teams, StartLoc, EndLoc,
+                               NumClauses, 1) {}
 
   /// Build an empty directive.
   ///
@@ -4232,7 +4268,7 @@ class OMPTargetTeamsDirective final : public OMPExecutableDirective {
   ///
   explicit OMPTargetTeamsDirective(unsigned NumClauses)
       : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
-                               OMPD_target_teams, SourceLocation(),
+                               llvm::omp::OMPD_target_teams, SourceLocation(),
                                SourceLocation(), NumClauses, 1) {}
 
 public:
@@ -4285,8 +4321,8 @@ class OMPTargetTeamsDistributeDirective final : public OMPLoopDirective {
                                     SourceLocation EndLoc,
                                     unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
-                         OMPD_target_teams_distribute, StartLoc, EndLoc,
-                         CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_target_teams_distribute, StartLoc,
+                         EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -4296,8 +4332,9 @@ class OMPTargetTeamsDistributeDirective final : public OMPLoopDirective {
   explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum,
                                              unsigned NumClauses)
       : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
-                         OMPD_target_teams_distribute, SourceLocation(),
-                         SourceLocation(), CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_target_teams_distribute,
+                         SourceLocation(), SourceLocation(), CollapsedNum,
+                         NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -4358,8 +4395,8 @@ class OMPTargetTeamsDistributeParallelForDirective final
                                                unsigned NumClauses)
       : OMPLoopDirective(this,
                          OMPTargetTeamsDistributeParallelForDirectiveClass,
-                         OMPD_target_teams_distribute_parallel_for, StartLoc,
-                         EndLoc, CollapsedNum, NumClauses),
+                         llvm::omp::OMPD_target_teams_distribute_parallel_for,
+                         StartLoc, EndLoc, CollapsedNum, NumClauses),
         HasCancel(false) {}
 
   /// Build an empty directive.
@@ -4371,8 +4408,8 @@ class OMPTargetTeamsDistributeParallelForDirective final
                                                         unsigned NumClauses)
       : OMPLoopDirective(
             this, OMPTargetTeamsDistributeParallelForDirectiveClass,
-            OMPD_target_teams_distribute_parallel_for, SourceLocation(),
-            SourceLocation(), CollapsedNum, NumClauses),
+            llvm::omp::OMPD_target_teams_distribute_parallel_for,
+            SourceLocation(), SourceLocation(), CollapsedNum, NumClauses),
         HasCancel(false) {}
 
   /// Set cancel state.
@@ -4438,10 +4475,10 @@ class OMPTargetTeamsDistributeParallelForSimdDirective final
                                                    SourceLocation EndLoc,
                                                    unsigned CollapsedNum,
                                                    unsigned NumClauses)
-      : OMPLoopDirective(this,
-                         OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
-                         OMPD_target_teams_distribute_parallel_for_simd,
-                         StartLoc, EndLoc, CollapsedNum, NumClauses) {}
+      : OMPLoopDirective(
+            this, OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
+            llvm::omp::OMPD_target_teams_distribute_parallel_for_simd, StartLoc,
+            EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -4452,8 +4489,8 @@ class OMPTargetTeamsDistributeParallelForSimdDirective final
       unsigned CollapsedNum, unsigned NumClauses)
       : OMPLoopDirective(
             this, OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
-            OMPD_target_teams_distribute_parallel_for_simd, SourceLocation(),
-            SourceLocation(), CollapsedNum, NumClauses) {}
+            llvm::omp::OMPD_target_teams_distribute_parallel_for_simd,
+            SourceLocation(), SourceLocation(), CollapsedNum, NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -4511,8 +4548,8 @@ class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective {
                                         unsigned CollapsedNum,
                                         unsigned NumClauses)
       : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
-                         OMPD_target_teams_distribute_simd, StartLoc, EndLoc,
-                         CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_target_teams_distribute_simd, StartLoc,
+                         EndLoc, CollapsedNum, NumClauses) {}
 
   /// Build an empty directive.
   ///
@@ -4522,8 +4559,9 @@ class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective {
   explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum,
                                                  unsigned NumClauses)
       : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
-                         OMPD_target_teams_distribute_simd, SourceLocation(),
-                         SourceLocation(), CollapsedNum, NumClauses) {}
+                         llvm::omp::OMPD_target_teams_distribute_simd,
+                         SourceLocation(), SourceLocation(), CollapsedNum,
+                         NumClauses) {}
 
 public:
   /// Creates directive with a list of \a Clauses.

diff  --git a/clang/include/clang/Basic/OpenMPKinds.def b/clang/include/clang/Basic/OpenMPKinds.def
index 6ab35cafc7ed..7333d94e2cfc 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -11,12 +11,6 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef OPENMP_DIRECTIVE
-#  define OPENMP_DIRECTIVE(Name)
-#endif
-#ifndef OPENMP_DIRECTIVE_EXT
-#define OPENMP_DIRECTIVE_EXT(Name, Str)
-#endif
 #ifndef OPENMP_CLAUSE
 #  define OPENMP_CLAUSE(Name, Class)
 #endif
@@ -230,69 +224,6 @@ OPENMP_CONTEXT_SELECTOR_SET(device)
 OPENMP_CONTEXT_SELECTOR(vendor)
 OPENMP_CONTEXT_SELECTOR(kind)
 
-// OpenMP directives.
-OPENMP_DIRECTIVE(threadprivate)
-OPENMP_DIRECTIVE(parallel)
-OPENMP_DIRECTIVE(task)
-OPENMP_DIRECTIVE(simd)
-OPENMP_DIRECTIVE(for)
-OPENMP_DIRECTIVE(sections)
-OPENMP_DIRECTIVE(section)
-OPENMP_DIRECTIVE(single)
-OPENMP_DIRECTIVE(master)
-OPENMP_DIRECTIVE(critical)
-OPENMP_DIRECTIVE(taskyield)
-OPENMP_DIRECTIVE(barrier)
-OPENMP_DIRECTIVE(taskwait)
-OPENMP_DIRECTIVE(taskgroup)
-OPENMP_DIRECTIVE(flush)
-OPENMP_DIRECTIVE(ordered)
-OPENMP_DIRECTIVE(atomic)
-OPENMP_DIRECTIVE(target)
-OPENMP_DIRECTIVE(teams)
-OPENMP_DIRECTIVE(cancel)
-OPENMP_DIRECTIVE(requires)
-OPENMP_DIRECTIVE_EXT(target_data, "target data")
-OPENMP_DIRECTIVE_EXT(target_enter_data, "target enter data")
-OPENMP_DIRECTIVE_EXT(target_exit_data, "target exit data")
-OPENMP_DIRECTIVE_EXT(target_parallel, "target parallel")
-OPENMP_DIRECTIVE_EXT(target_parallel_for, "target parallel for")
-OPENMP_DIRECTIVE_EXT(target_update, "target update")
-OPENMP_DIRECTIVE_EXT(parallel_for, "parallel for")
-OPENMP_DIRECTIVE_EXT(parallel_for_simd, "parallel for simd")
-OPENMP_DIRECTIVE_EXT(parallel_master, "parallel master")
-OPENMP_DIRECTIVE_EXT(parallel_sections, "parallel sections")
-OPENMP_DIRECTIVE_EXT(for_simd, "for simd")
-OPENMP_DIRECTIVE_EXT(cancellation_point, "cancellation point")
-OPENMP_DIRECTIVE_EXT(declare_reduction, "declare reduction")
-OPENMP_DIRECTIVE_EXT(declare_mapper, "declare mapper")
-OPENMP_DIRECTIVE_EXT(declare_simd, "declare simd")
-OPENMP_DIRECTIVE(taskloop)
-OPENMP_DIRECTIVE_EXT(taskloop_simd, "taskloop simd")
-OPENMP_DIRECTIVE(distribute)
-OPENMP_DIRECTIVE_EXT(declare_target, "declare target")
-OPENMP_DIRECTIVE_EXT(end_declare_target, "end declare target")
-OPENMP_DIRECTIVE_EXT(distribute_parallel_for, "distribute parallel for")
-OPENMP_DIRECTIVE_EXT(distribute_parallel_for_simd, "distribute parallel for simd")
-OPENMP_DIRECTIVE_EXT(distribute_simd, "distribute simd")
-OPENMP_DIRECTIVE_EXT(target_parallel_for_simd, "target parallel for simd")
-OPENMP_DIRECTIVE_EXT(target_simd, "target simd")
-OPENMP_DIRECTIVE_EXT(teams_distribute, "teams distribute")
-OPENMP_DIRECTIVE_EXT(teams_distribute_simd, "teams distribute simd")
-OPENMP_DIRECTIVE_EXT(teams_distribute_parallel_for_simd, "teams distribute parallel for simd")
-OPENMP_DIRECTIVE_EXT(teams_distribute_parallel_for, "teams distribute parallel for")
-OPENMP_DIRECTIVE_EXT(target_teams, "target teams")
-OPENMP_DIRECTIVE_EXT(target_teams_distribute, "target teams distribute")
-OPENMP_DIRECTIVE_EXT(target_teams_distribute_parallel_for, "target teams distribute parallel for")
-OPENMP_DIRECTIVE_EXT(target_teams_distribute_parallel_for_simd, "target teams distribute parallel for simd")
-OPENMP_DIRECTIVE_EXT(target_teams_distribute_simd, "target teams distribute simd")
-OPENMP_DIRECTIVE(allocate)
-OPENMP_DIRECTIVE_EXT(declare_variant, "declare variant")
-OPENMP_DIRECTIVE_EXT(master_taskloop, "master taskloop")
-OPENMP_DIRECTIVE_EXT(parallel_master_taskloop, "parallel master taskloop")
-OPENMP_DIRECTIVE_EXT(master_taskloop_simd, "master taskloop simd")
-OPENMP_DIRECTIVE_EXT(parallel_master_taskloop_simd, "parallel master taskloop simd")
-
 // OpenMP clauses.
 OPENMP_CLAUSE(allocator, OMPAllocatorClause)
 OPENMP_CLAUSE(if, OMPIfClause)
@@ -1137,8 +1068,6 @@ OPENMP_MATCH_KIND(implementation)
 #undef OPENMP_SCHEDULE_KIND
 #undef OPENMP_PROC_BIND_KIND
 #undef OPENMP_DEFAULT_KIND
-#undef OPENMP_DIRECTIVE
-#undef OPENMP_DIRECTIVE_EXT
 #undef OPENMP_CLAUSE
 #undef OPENMP_CRITICAL_CLAUSE
 #undef OPENMP_ORDERED_CLAUSE

diff  --git a/clang/include/clang/Basic/OpenMPKinds.h b/clang/include/clang/Basic/OpenMPKinds.h
index 2621afe7afbb..543c1cd14907 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_BASIC_OPENMPKINDS_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 
 namespace clang {
 
@@ -58,14 +59,7 @@ template <typename VectorType, typename ScoreT> struct OpenMPCtxSelectorData {
 };
 
 /// OpenMP directives.
-enum OpenMPDirectiveKind {
-#define OPENMP_DIRECTIVE(Name) \
-  OMPD_##Name,
-#define OPENMP_DIRECTIVE_EXT(Name, Str) \
-  OMPD_##Name,
-#include "clang/Basic/OpenMPKinds.def"
-  OMPD_unknown
-};
+using OpenMPDirectiveKind = llvm::omp::Directive;
 
 /// OpenMP clauses.
 enum OpenMPClauseKind {
@@ -208,9 +202,6 @@ struct OpenMPScheduleTy final {
   OpenMPScheduleClauseModifier M2 = OMPC_SCHEDULE_MODIFIER_unknown;
 };
 
-OpenMPDirectiveKind getOpenMPDirectiveKind(llvm::StringRef Str);
-const char *getOpenMPDirectiveName(OpenMPDirectiveKind Kind);
-
 OpenMPClauseKind getOpenMPClauseKind(llvm::StringRef Str);
 const char *getOpenMPClauseName(OpenMPClauseKind Kind);
 

diff  --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt
index 1ede58cc9ed6..bd9b0934591c 100644
--- a/clang/lib/AST/CMakeLists.txt
+++ b/clang/lib/AST/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   BinaryFormat
   Core
+  FrontendOpenMP
   Support
   )
 

diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index fe1334469d48..7315d7c3cdbf 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -1161,7 +1161,7 @@ OMPIsDevicePtrClause::CreateEmpty(const ASTContext &C,
 
 void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
   OS << "if(";
-  if (Node->getNameModifier() != OMPD_unknown)
+  if (Node->getNameModifier() != llvm::omp::OMPD_unknown)
     OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": ";
   Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
   OS << ")";

diff  --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index 5b61e05aae87..da6d308ad15b 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/ASTContext.h"
 
 using namespace clang;
+using namespace llvm::omp;
 
 void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) {
   assert(Clauses.size() == getNumClauses() &&

diff  --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index c075deb01a18..51fe587de999 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -18,6 +18,7 @@
 #include <cassert>
 
 using namespace clang;
+using namespace llvm::omp;
 
 OpenMPContextSelectorSetKind
 clang::getOpenMPContextSelectorSet(llvm::StringRef Str) {
@@ -62,31 +63,6 @@ clang::getOpenMPContextSelectorName(OpenMPContextSelectorKind Kind) {
   llvm_unreachable("Invalid OpenMP context selector kind");
 }
 
-OpenMPDirectiveKind clang::getOpenMPDirectiveKind(StringRef Str) {
-  return llvm::StringSwitch<OpenMPDirectiveKind>(Str)
-#define OPENMP_DIRECTIVE(Name) .Case(#Name, OMPD_##Name)
-#define OPENMP_DIRECTIVE_EXT(Name, Str) .Case(Str, OMPD_##Name)
-#include "clang/Basic/OpenMPKinds.def"
-      .Default(OMPD_unknown);
-}
-
-const char *clang::getOpenMPDirectiveName(OpenMPDirectiveKind Kind) {
-  assert(Kind <= OMPD_unknown);
-  switch (Kind) {
-  case OMPD_unknown:
-    return "unknown";
-#define OPENMP_DIRECTIVE(Name)                                                 \
-  case OMPD_##Name:                                                            \
-    return #Name;
-#define OPENMP_DIRECTIVE_EXT(Name, Str)                                        \
-  case OMPD_##Name:                                                            \
-    return Str;
-#include "clang/Basic/OpenMPKinds.def"
-    break;
-  }
-  llvm_unreachable("Invalid OpenMP directive kind");
-}
-
 OpenMPClauseKind clang::getOpenMPClauseKind(StringRef Str) {
   // 'flush' clause cannot be specified explicitly, because this is an implicit
   // clause for 'flush' directive. If the 'flush' clause is explicitly specified
@@ -449,7 +425,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
                                         OpenMPClauseKind CKind,
                                         unsigned OpenMPVersion) {
-  assert(DKind <= OMPD_unknown);
+  assert(unsigned(DKind) <= unsigned(OMPD_unknown));
   assert(CKind <= OMPC_unknown);
   switch (DKind) {
   case OMPD_parallel:

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a53808782039..fda8dbe14db6 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -32,6 +32,7 @@
 
 using namespace clang;
 using namespace CodeGen;
+using namespace llvm::omp;
 
 namespace {
 /// Base class for handling code generation inside OpenMP regions.

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
index 800940b9ef30..b98e6dee5f75 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -22,6 +22,7 @@
 
 using namespace clang;
 using namespace CodeGen;
+using namespace llvm::omp;
 
 namespace {
 enum OpenMPRTLFunctionNVPTX {

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 8369fc236df4..e23abdd385fe 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -23,6 +23,7 @@
 #include "clang/Basic/PrettyStackTrace.h"
 using namespace clang;
 using namespace CodeGen;
+using namespace llvm::omp;
 
 namespace {
 /// Lexical scope for OpenMP executable constructs, that handles correct codegen

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index a46a25248bdd..0aff6667840d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1276,7 +1276,7 @@ class CodeGenFunction : public CodeGenTypeCache {
       CancelExit(OpenMPDirectiveKind Kind, JumpDest ExitBlock,
                  JumpDest ContBlock)
           : Kind(Kind), ExitBlock(ExitBlock), ContBlock(ContBlock) {}
-      OpenMPDirectiveKind Kind = OMPD_unknown;
+      OpenMPDirectiveKind Kind = llvm::omp::OMPD_unknown;
       /// true if the exit block has been emitted already by the special
       /// emitExit() call, false if the default codegen is used.
       bool HasBeenEmitted = false;

diff  --git a/clang/lib/Parse/CMakeLists.txt b/clang/lib/Parse/CMakeLists.txt
index b868696eb6bb..3f7ab2a74af2 100644
--- a/clang/lib/Parse/CMakeLists.txt
+++ b/clang/lib/Parse/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
   MC
   MCParser
   Support

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index d25058e17ff5..89f7f909b379 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/UniqueVector.h"
 
 using namespace clang;
+using namespace llvm::omp;
 
 //===----------------------------------------------------------------------===//
 // OpenMP declarative directives.
@@ -27,7 +28,7 @@ using namespace clang;
 
 namespace {
 enum OpenMPDirectiveKindEx {
-  OMPD_cancellation = OMPD_unknown + 1,
+  OMPD_cancellation = unsigned(OMPD_unknown) + 1,
   OMPD_data,
   OMPD_declare,
   OMPD_end,
@@ -46,6 +47,20 @@ enum OpenMPDirectiveKindEx {
   OMPD_variant,
 };
 
+// Helper to unify the enum class OpenMPDirectiveKind with its extension
+// the OpenMPDirectiveKindEx enum which allows to use them together as if they
+// are unsigned values.
+struct OpenMPDirectiveKindExWrapper {
+  OpenMPDirectiveKindExWrapper(unsigned Value) : Value(Value) {}
+  OpenMPDirectiveKindExWrapper(OpenMPDirectiveKind DK) : Value(unsigned(DK)) {}
+  bool operator==(OpenMPDirectiveKind V) const { return Value == unsigned(V); }
+  bool operator!=(OpenMPDirectiveKind V) const { return Value != unsigned(V); }
+  bool operator<(OpenMPDirectiveKind V) const { return Value < unsigned(V); }
+  operator unsigned() const { return Value; }
+  operator OpenMPDirectiveKind() const { return OpenMPDirectiveKind(Value); }
+  unsigned Value;
+};
+
 class DeclDirectiveListParserHelper final {
   SmallVector<Expr *, 4> Identifiers;
   Parser *P;
@@ -67,11 +82,11 @@ class DeclDirectiveListParserHelper final {
 // Map token string to extended OMP token kind that are
 // OpenMPDirectiveKind + OpenMPDirectiveKindEx.
 static unsigned getOpenMPDirectiveKindEx(StringRef S) {
-  auto DKind = getOpenMPDirectiveKind(S);
+  OpenMPDirectiveKindExWrapper DKind = getOpenMPDirectiveKind(S);
   if (DKind != OMPD_unknown)
     return DKind;
 
-  return llvm::StringSwitch<unsigned>(S)
+  return llvm::StringSwitch<OpenMPDirectiveKindExWrapper>(S)
       .Case("cancellation", OMPD_cancellation)
       .Case("data", OMPD_data)
       .Case("declare", OMPD_declare)
@@ -86,11 +101,11 @@ static unsigned getOpenMPDirectiveKindEx(StringRef S) {
       .Default(OMPD_unknown);
 }
 
-static OpenMPDirectiveKind parseOpenMPDirectiveKind(Parser &P) {
+static OpenMPDirectiveKindExWrapper parseOpenMPDirectiveKind(Parser &P) {
   // Array of foldings: F[i][0] F[i][1] ===> F[i][2].
   // E.g.: OMPD_for OMPD_simd ===> OMPD_for_simd
   // TODO: add other combined directives in topological order.
-  static const unsigned F[][3] = {
+  static const OpenMPDirectiveKindExWrapper F[][3] = {
       {OMPD_cancellation, OMPD_point, OMPD_cancellation_point},
       {OMPD_declare, OMPD_reduction, OMPD_declare_reduction},
       {OMPD_declare, OMPD_mapper, OMPD_declare_mapper},
@@ -144,7 +159,7 @@ static OpenMPDirectiveKind parseOpenMPDirectiveKind(Parser &P) {
        OMPD_parallel_master_taskloop_simd}};
   enum { CancellationPoint = 0, DeclareReduction = 1, TargetData = 2 };
   Token Tok = P.getCurToken();
-  unsigned DKind =
+  OpenMPDirectiveKindExWrapper DKind =
       Tok.isAnnotation()
           ? static_cast<unsigned>(OMPD_unknown)
           : getOpenMPDirectiveKindEx(P.getPreprocessor().getSpelling(Tok));
@@ -156,7 +171,7 @@ static OpenMPDirectiveKind parseOpenMPDirectiveKind(Parser &P) {
       continue;
 
     Tok = P.getPreprocessor().LookAhead(0);
-    unsigned SDKind =
+    OpenMPDirectiveKindExWrapper SDKind =
         Tok.isAnnotation()
             ? static_cast<unsigned>(OMPD_unknown)
             : getOpenMPDirectiveKindEx(P.getPreprocessor().getSpelling(Tok));
@@ -238,8 +253,9 @@ Parser::DeclGroupPtrTy
 Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) {
   // Parse '('.
   BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
-  if (T.expectAndConsume(diag::err_expected_lparen_after,
-                         getOpenMPDirectiveName(OMPD_declare_reduction))) {
+  if (T.expectAndConsume(
+          diag::err_expected_lparen_after,
+          getOpenMPDirectiveName(OMPD_declare_reduction).data())) {
     SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
     return DeclGroupPtrTy();
   }
@@ -491,7 +507,7 @@ Parser::ParseOpenMPDeclareMapperDirective(AccessSpecifier AS) {
   // Parse '('
   BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
   if (T.expectAndConsume(diag::err_expected_lparen_after,
-                         getOpenMPDirectiveName(OMPD_declare_mapper))) {
+                         getOpenMPDirectiveName(OMPD_declare_mapper).data())) {
     SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
     return DeclGroupPtrTy();
   }
@@ -1956,7 +1972,7 @@ bool Parser::ParseOpenMPSimpleVarList(
   // Parse '('.
   BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
   if (T.expectAndConsume(diag::err_expected_lparen_after,
-                         getOpenMPDirectiveName(Kind)))
+                         getOpenMPDirectiveName(Kind).data()))
     return true;
   bool IsCorrect = true;
   bool NoIdentIsFound = true;
@@ -2428,15 +2444,16 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPClauseKind Kind,
     assert(Kind == OMPC_if);
     KLoc.push_back(Tok.getLocation());
     TentativeParsingAction TPA(*this);
-    Arg.push_back(parseOpenMPDirectiveKind(*this));
-    if (Arg.back() != OMPD_unknown) {
+    auto DK = parseOpenMPDirectiveKind(*this);
+    Arg.push_back(DK);
+    if (DK != OMPD_unknown) {
       ConsumeToken();
       if (Tok.is(tok::colon) && getLangOpts().OpenMP > 40) {
         TPA.Commit();
         DelimLoc = ConsumeToken();
       } else {
         TPA.Revert();
-        Arg.back() = OMPD_unknown;
+        Arg.back() = unsigned(OMPD_unknown);
       }
     } else {
       TPA.Revert();

diff  --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt
index 89c3f6c47b49..844abc7ce598 100644
--- a/clang/lib/Sema/CMakeLists.txt
+++ b/clang/lib/Sema/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
   Support
   )
 

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index baf2db810dcd..0783bb713592 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -28,8 +28,11 @@
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
+#include "llvm/ADT/IndexedMap.h"
 #include "llvm/ADT/PointerEmbeddedInt.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 using namespace clang;
+using namespace llvm::omp;
 
 //===----------------------------------------------------------------------===//
 // Stack of data-sharing attributes for variables
@@ -4152,13 +4155,17 @@ static bool checkNestingOfRegions(Sema &SemaRef, const DSAStackTy *Stack,
   return false;
 }
 
+struct Kind2Unsigned {
+  using argument_type = OpenMPDirectiveKind;
+  unsigned operator()(argument_type DK) { return unsigned(DK); }
+};
 static bool checkIfClauses(Sema &S, OpenMPDirectiveKind Kind,
                            ArrayRef<OMPClause *> Clauses,
                            ArrayRef<OpenMPDirectiveKind> AllowedNameModifiers) {
   bool ErrorFound = false;
   unsigned NamedModifiersNumber = 0;
-  SmallVector<const OMPIfClause *, OMPC_unknown + 1> FoundNameModifiers(
-      OMPD_unknown + 1);
+  llvm::IndexedMap<const OMPIfClause *, Kind2Unsigned> FoundNameModifiers;
+  FoundNameModifiers.resize(unsigned(OMPD_unknown) + 1);
   SmallVector<SourceLocation, 4> NameModifierLoc;
   for (const OMPClause *C : Clauses) {
     if (const auto *IC = dyn_cast_or_null<OMPIfClause>(C)) {

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index fb19579cca1b..e9456ebda581 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3188,7 +3188,8 @@ TemplateDeclInstantiator::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
   } else {
     // Instantiate the mapper variable.
     DeclarationNameInfo DirName;
-    SemaRef.StartOpenMPDSABlock(OMPD_declare_mapper, DirName, /*S=*/nullptr,
+    SemaRef.StartOpenMPDSABlock(llvm::omp::OMPD_declare_mapper, DirName,
+                                /*S=*/nullptr,
                                 (*D->clauselist_begin())->getBeginLoc());
     SemaRef.ActOnOpenMPDeclareMapperDirectiveVarDecl(
         NewDMD, /*S=*/nullptr, SubstMapperTy, D->getLocation(), VN);

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index c22b44a7b91d..ade0e6a0c4ce 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -37,6 +37,8 @@
 #include "llvm/Support/ErrorHandling.h"
 #include <algorithm>
 
+using namespace llvm::omp;
+
 namespace clang {
 using namespace sema;
 

diff  --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 4c186629b59b..e3458c48b14d 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -6622,7 +6622,7 @@ void OMPClauseWriter::writeClause(OMPClause *C) {
 }
 
 void OMPClauseWriter::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) {
-  Record.push_back(C->getCaptureRegion());
+  Record.push_back(uint64_t(C->getCaptureRegion()));
   Record.AddStmt(C->getPreInitStmt());
 }
 
@@ -6633,7 +6633,7 @@ void OMPClauseWriter::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
 
 void OMPClauseWriter::VisitOMPIfClause(OMPIfClause *C) {
   VisitOMPClauseWithPreInit(C);
-  Record.push_back(C->getNameModifier());
+  Record.push_back(uint64_t(C->getNameModifier()));
   Record.AddSourceLocation(C->getNameModifierLoc());
   Record.AddSourceLocation(C->getColonLoc());
   Record.AddStmt(C->getCondition());

diff  --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 1e801d02afc3..a5e90359103e 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2255,7 +2255,7 @@ void ASTStmtWriter::VisitOMPCancellationPointDirective(
     OMPCancellationPointDirective *D) {
   VisitStmt(D);
   VisitOMPExecutableDirective(D);
-  Record.push_back(D->getCancelRegion());
+  Record.push_back(uint64_t(D->getCancelRegion()));
   Code = serialization::STMT_OMP_CANCELLATION_POINT_DIRECTIVE;
 }
 
@@ -2263,7 +2263,7 @@ void ASTStmtWriter::VisitOMPCancelDirective(OMPCancelDirective *D) {
   VisitStmt(D);
   Record.push_back(D->getNumClauses());
   VisitOMPExecutableDirective(D);
-  Record.push_back(D->getCancelRegion());
+  Record.push_back(uint64_t(D->getCancelRegion()));
   Code = serialization::STMT_OMP_CANCEL_DIRECTIVE;
 }
 

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h b/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
new file mode 100644
index 000000000000..42b19091c14d
--- /dev/null
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
@@ -0,0 +1,46 @@
+//===- OMPConstants.h - OpenMP related constants and helpers ------ C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file defines constans and helpers used when dealing with OpenMP.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPENMP_CONSTANTS_H
+#define LLVM_OPENMP_CONSTANTS_H
+
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+
+namespace omp {
+
+/// IDs for all OpenMP directives.
+enum class Directive {
+#define OMP_DIRECTIVE(Enum, ...) Enum,
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+};
+
+/// Make the enum values available in the llvm::omp namespace. This allows us to
+/// write something like OMPD_parallel if we have a `using namespace omp`. At
+/// the same time we do not loose the strong type guarantees of the enum class,
+/// that is we cannot pass an unsigned as Directive without an explicit cast.
+#define OMP_DIRECTIVE(Enum, ...) constexpr auto Enum = omp::Directive::Enum;
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+
+/// Parse \p Str and return the directive it matches or OMPD_unknown if none.
+Directive getOpenMPDirectiveKind(StringRef Str);
+
+/// Return a textual representation of the directive \p D.
+StringRef getOpenMPDirectiveName(Directive D);
+
+} // end namespace omp
+
+} // end namespace llvm
+
+#endif // LLVM_OPENMP_CONSTANTS_H

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
new file mode 100644
index 000000000000..fc84ffb578c5
--- /dev/null
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -0,0 +1,102 @@
+//===--- OMPKinds.def - OpenMP directives, clauses, rt-calls -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file defines the list of supported OpenMP directives, clauses, runtime
+/// calls, and other things that need to be listed in enums.
+///
+//===----------------------------------------------------------------------===//
+
+/// OpenMP Directives and combined directives
+///
+///{
+
+#ifndef OMP_DIRECTIVE
+#define OMP_DIRECTIVE(Enum, Str)
+#endif
+
+#define __OMP_DIRECTIVE_EXT(Name, Str) OMP_DIRECTIVE(OMPD_##Name, Str)
+#define __OMP_DIRECTIVE(Name) __OMP_DIRECTIVE_EXT(Name, #Name)
+
+__OMP_DIRECTIVE(threadprivate)
+__OMP_DIRECTIVE(parallel)
+__OMP_DIRECTIVE(task)
+__OMP_DIRECTIVE(simd)
+__OMP_DIRECTIVE(for)
+__OMP_DIRECTIVE(sections)
+__OMP_DIRECTIVE(section)
+__OMP_DIRECTIVE(single)
+__OMP_DIRECTIVE(master)
+__OMP_DIRECTIVE(critical)
+__OMP_DIRECTIVE(taskyield)
+__OMP_DIRECTIVE(barrier)
+__OMP_DIRECTIVE(taskwait)
+__OMP_DIRECTIVE(taskgroup)
+__OMP_DIRECTIVE(flush)
+__OMP_DIRECTIVE(ordered)
+__OMP_DIRECTIVE(atomic)
+__OMP_DIRECTIVE(target)
+__OMP_DIRECTIVE(teams)
+__OMP_DIRECTIVE(cancel)
+__OMP_DIRECTIVE(requires)
+__OMP_DIRECTIVE_EXT(target_data, "target data")
+__OMP_DIRECTIVE_EXT(target_enter_data, "target enter data")
+__OMP_DIRECTIVE_EXT(target_exit_data, "target exit data")
+__OMP_DIRECTIVE_EXT(target_parallel, "target parallel")
+__OMP_DIRECTIVE_EXT(target_parallel_for, "target parallel for")
+__OMP_DIRECTIVE_EXT(target_update, "target update")
+__OMP_DIRECTIVE_EXT(parallel_for, "parallel for")
+__OMP_DIRECTIVE_EXT(parallel_for_simd, "parallel for simd")
+__OMP_DIRECTIVE_EXT(parallel_master, "parallel master")
+__OMP_DIRECTIVE_EXT(parallel_sections, "parallel sections")
+__OMP_DIRECTIVE_EXT(for_simd, "for simd")
+__OMP_DIRECTIVE_EXT(cancellation_point, "cancellation point")
+__OMP_DIRECTIVE_EXT(declare_reduction, "declare reduction")
+__OMP_DIRECTIVE_EXT(declare_mapper, "declare mapper")
+__OMP_DIRECTIVE_EXT(declare_simd, "declare simd")
+__OMP_DIRECTIVE(taskloop)
+__OMP_DIRECTIVE_EXT(taskloop_simd, "taskloop simd")
+__OMP_DIRECTIVE(distribute)
+__OMP_DIRECTIVE_EXT(declare_target, "declare target")
+__OMP_DIRECTIVE_EXT(end_declare_target, "end declare target")
+__OMP_DIRECTIVE_EXT(distribute_parallel_for, "distribute parallel for")
+__OMP_DIRECTIVE_EXT(distribute_parallel_for_simd,
+                    "distribute parallel for simd")
+__OMP_DIRECTIVE_EXT(distribute_simd, "distribute simd")
+__OMP_DIRECTIVE_EXT(target_parallel_for_simd, "target parallel for simd")
+__OMP_DIRECTIVE_EXT(target_simd, "target simd")
+__OMP_DIRECTIVE_EXT(teams_distribute, "teams distribute")
+__OMP_DIRECTIVE_EXT(teams_distribute_simd, "teams distribute simd")
+__OMP_DIRECTIVE_EXT(teams_distribute_parallel_for_simd,
+                    "teams distribute parallel for simd")
+__OMP_DIRECTIVE_EXT(teams_distribute_parallel_for,
+                    "teams distribute parallel for")
+__OMP_DIRECTIVE_EXT(target_teams, "target teams")
+__OMP_DIRECTIVE_EXT(target_teams_distribute, "target teams distribute")
+__OMP_DIRECTIVE_EXT(target_teams_distribute_parallel_for,
+                    "target teams distribute parallel for")
+__OMP_DIRECTIVE_EXT(target_teams_distribute_parallel_for_simd,
+                    "target teams distribute parallel for simd")
+__OMP_DIRECTIVE_EXT(target_teams_distribute_simd,
+                    "target teams distribute simd")
+__OMP_DIRECTIVE(allocate)
+__OMP_DIRECTIVE_EXT(declare_variant, "declare variant")
+__OMP_DIRECTIVE_EXT(master_taskloop, "master taskloop")
+__OMP_DIRECTIVE_EXT(parallel_master_taskloop, "parallel master taskloop")
+__OMP_DIRECTIVE_EXT(master_taskloop_simd, "master taskloop simd")
+__OMP_DIRECTIVE_EXT(parallel_master_taskloop_simd,
+                    "parallel master taskloop simd")
+
+// Has to be the last because Clang implicitly expects it to be.
+__OMP_DIRECTIVE(unknown)
+
+#undef __OMP_DIRECTIVE_EXT
+#undef __OMP_DIRECTIVE
+#undef OMP_DIRECTIVE
+
+///}

diff  --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt
index 5a41d65b0cf3..f7e08a68e673 100644
--- a/llvm/lib/CMakeLists.txt
+++ b/llvm/lib/CMakeLists.txt
@@ -8,6 +8,7 @@ add_subdirectory(CodeGen)
 add_subdirectory(BinaryFormat)
 add_subdirectory(Bitcode)
 add_subdirectory(Bitstream)
+add_subdirectory(Frontend)
 add_subdirectory(Transforms)
 add_subdirectory(Linker)
 add_subdirectory(Analysis)

diff  --git a/llvm/lib/Frontend/CMakeLists.txt b/llvm/lib/Frontend/CMakeLists.txt
new file mode 100644
index 000000000000..9730c8414edf
--- /dev/null
+++ b/llvm/lib/Frontend/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(OpenMP)

diff  --git a/llvm/lib/Frontend/LLVMBuild.txt b/llvm/lib/Frontend/LLVMBuild.txt
new file mode 100644
index 000000000000..78ec6ae5186c
--- /dev/null
+++ b/llvm/lib/Frontend/LLVMBuild.txt
@@ -0,0 +1,23 @@
+;===- ./lib/Frontend/LLVMBuild.txt -----------------------------*- Conf -*--===;
+;
+; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+; See https://llvm.org/LICENSE.txt for license information.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+;   http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[common]
+subdirectories = OpenMP
+
+[component_0]
+type = Group
+name = Frontend
+parent = Libraries

diff  --git a/llvm/lib/Frontend/OpenMP/CMakeLists.txt b/llvm/lib/Frontend/OpenMP/CMakeLists.txt
new file mode 100644
index 000000000000..5d74bcf3b9fc
--- /dev/null
+++ b/llvm/lib/Frontend/OpenMP/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_llvm_component_library(LLVMFrontendOpenMP
+  OMPConstants.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/Frontend
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/Frontend/OpenMP
+
+  DEPENDS
+  intrinsics_gen
+  )

diff  --git a/llvm/lib/Frontend/OpenMP/LLVMBuild.txt b/llvm/lib/Frontend/OpenMP/LLVMBuild.txt
new file mode 100644
index 000000000000..dfabe72fcd2f
--- /dev/null
+++ b/llvm/lib/Frontend/OpenMP/LLVMBuild.txt
@@ -0,0 +1,21 @@
+;===- ./lib/Frontend/OpenMP/LLVMBuild.txt ----------------------*- Conf -*--===;
+;
+; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+; See https://llvm.org/LICENSE.txt for license information.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+;   http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[component_0]
+type = Library
+name = FrontendOpenMP
+parent = Frontend
+required_libraries = Core Support TransformUtils

diff  --git a/llvm/lib/Frontend/OpenMP/OMPConstants.cpp b/llvm/lib/Frontend/OpenMP/OMPConstants.cpp
new file mode 100644
index 000000000000..994fb4e2fa84
--- /dev/null
+++ b/llvm/lib/Frontend/OpenMP/OMPConstants.cpp
@@ -0,0 +1,34 @@
+//===- OMPConstants.cpp - Helpers related to OpenMP code generation ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+
+using namespace llvm;
+using namespace omp;
+
+Directive llvm::omp::getOpenMPDirectiveKind(StringRef Str) {
+  return llvm::StringSwitch<Directive>(Str)
+#define OMP_DIRECTIVE(Enum, Str) .Case(Str, Enum)
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+      .Default(OMPD_unknown);
+}
+
+StringRef llvm::omp::getOpenMPDirectiveName(Directive Kind) {
+  switch (Kind) {
+#define OMP_DIRECTIVE(Enum, Str)                                               \
+  case Enum:                                                                   \
+    return Str;
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+  }
+  llvm_unreachable("Invalid OpenMP directive kind");
+}

diff  --git a/llvm/lib/LLVMBuild.txt b/llvm/lib/LLVMBuild.txt
index 4c039176267c..3f5383d9b1f1 100644
--- a/llvm/lib/LLVMBuild.txt
+++ b/llvm/lib/LLVMBuild.txt
@@ -24,6 +24,7 @@ subdirectories =
  DebugInfo
  Demangle
  ExecutionEngine
+ Frontend
  FuzzMutate
  LineEditor
  Linker


        


More information about the llvm-commits mailing list