[openmp] Use llvm GridValues from devicertl

Add include path to the cmakefiles and set the target_impl enums
from the llvm constants instead of copying the values.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D108391
diff --git a/openmp/libomptarget/DeviceRTL/src/Mapping.cpp b/openmp/libomptarget/DeviceRTL/src/Mapping.cpp
index fc3ca63..3bd0553 100644
--- a/openmp/libomptarget/DeviceRTL/src/Mapping.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Mapping.cpp
@@ -16,6 +16,8 @@
 
 #pragma omp declare target
 
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
+
 using namespace _OMP;
 
 namespace _OMP {
@@ -26,6 +28,10 @@
 ///{
 #pragma omp begin declare variant match(device = {arch(amdgcn)})
 
+constexpr const llvm::omp::GV &getGridValue() {
+  return llvm::omp::AMDGPUGridValues;
+}
+
 uint32_t getGridDim(uint32_t n, uint16_t d) {
   uint32_t q = n / d;
   return q + (n > q * d);
@@ -86,8 +92,6 @@
   return mapping::getThreadIdInBlock() / mapping::getWarpSize();
 }
 
-uint32_t getWarpSize() { return 64; }
-
 uint32_t getNumberOfWarpsInBlock() {
   return mapping::getBlockSize() / mapping::getWarpSize();
 }
@@ -101,6 +105,10 @@
 #pragma omp begin declare variant match(                                       \
     device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
 
+constexpr const llvm::omp::GV &getGridValue() {
+  return llvm::omp::NVPTXGridValues;
+}
+
 LaneMaskTy activemask() {
   unsigned int Mask;
   asm("activemask.b32 %0;" : "=r"(Mask));
@@ -144,8 +152,6 @@
   return mapping::getThreadIdInBlock() / mapping::getWarpSize();
 }
 
-uint32_t getWarpSize() { return 32; }
-
 uint32_t getNumberOfWarpsInBlock() {
   return (mapping::getBlockSize() + mapping::getWarpSize() - 1) /
          mapping::getWarpSize();
@@ -154,6 +160,8 @@
 #pragma omp end declare variant
 ///}
 
+uint32_t getWarpSize() { return getGridValue().GV_Warp_Size; }
+
 } // namespace impl
 } // namespace _OMP