D9306 omp 4.1 async offload support (partial): build changes for version 4.1

llvm-svn: 236746
diff --git a/openmp/runtime/CMakeLists.txt b/openmp/runtime/CMakeLists.txt
index 9841f01..6d824ab 100644
--- a/openmp/runtime/CMakeLists.txt
+++ b/openmp/runtime/CMakeLists.txt
@@ -60,7 +60,7 @@
 set(os_possible_values          lin mac win)
 set(arch_possible_values        32e 32 arm ppc64 ppc64le aarch64 mic)
 set(build_type_possible_values  release debug relwithdebinfo)
-set(omp_version_possible_values 40 30)
+set(omp_version_possible_values 41 40 30)
 set(lib_type_possible_values    normal profile stubs)
 set(mic_arch_possible_values    knf knc)
 
@@ -86,7 +86,7 @@
 set(arch          ${detected_arch}   CACHE STRING "The architecture to build for (32e/32/arm/ppc64/ppc64le/aarch64/mic).  32e is Intel(R) 64 architecture, 32 is IA-32 architecture")
 set(lib_type       normal        CACHE STRING "Performance,Profiling,Stubs library (normal/profile/stubs)")
 set(version        5             CACHE STRING "Produce libguide (version 4) or libiomp5 (version 5)")
-set(omp_version    40            CACHE STRING "The OpenMP version (40/30)")
+set(omp_version    41            CACHE STRING "The OpenMP version (41/40/30)")
 set(mic_arch       knc           CACHE STRING "Intel(R) Many Integrated Core Architecture (Intel(R) MIC Architecture) (knf/knc).   Ignored if not Intel(R) MIC Architecture build.")
 set(create_fortran_modules false CACHE BOOL   "Create Fortran module files? (requires fortran compiler)")
 
@@ -312,7 +312,7 @@
     string(SUBSTRING "${cmake_build_type_lowercase}" 0 3 build_type_suffix)
     set(suffix "${suffix}.${build_type_suffix}")
 endif()
-if(NOT "${omp_version}" STREQUAL "40")
+if(NOT "${omp_version}" STREQUAL "41")
     set(suffix "${suffix}.${omp_version}")
 endif()
 if(${STATS_GATHERING})
diff --git a/openmp/runtime/cmake/PerlFlags.cmake b/openmp/runtime/cmake/PerlFlags.cmake
index c34d29d..978b72f 100644
--- a/openmp/runtime/cmake/PerlFlags.cmake
+++ b/openmp/runtime/cmake/PerlFlags.cmake
@@ -71,6 +71,9 @@
     elseif(${STUBS_LIBRARY})
         append_gd_flags("-D stub")
     endif()
+    if(${omp_version} GREATER 41 OR ${omp_version} EQUAL 41)
+        append_gd_flags("-D OMP_41")
+    endif()
     if(${omp_version} GREATER 40 OR ${omp_version} EQUAL 40)
         append_gd_flags("-D OMP_40")
     endif()
diff --git a/openmp/runtime/cmake/SourceFiles.cmake b/openmp/runtime/cmake/SourceFiles.cmake
index 7c0de6c..c9d4a32 100644
--- a/openmp/runtime/cmake/SourceFiles.cmake
+++ b/openmp/runtime/cmake/SourceFiles.cmake
@@ -78,7 +78,7 @@
         append_cpp_source_file("kmp_dispatch.cpp")
         append_cpp_source_file("kmp_lock.cpp")
         append_cpp_source_file("kmp_sched.cpp")
-        if("${omp_version}" STREQUAL "40")
+        if(${omp_version} GREATER 40 OR ${omp_version} EQUAL 40)
             append_cpp_source_file("kmp_taskdeps.cpp")
             append_cpp_source_file("kmp_cancel.cpp")
         endif()
diff --git a/openmp/runtime/src/makefile.mk b/openmp/runtime/src/makefile.mk
index 8c75f19..c3af993 100644
--- a/openmp/runtime/src/makefile.mk
+++ b/openmp/runtime/src/makefile.mk
@@ -64,7 +64,7 @@
 # Type of library: dynamic or static linking.
 LINK_TYPE    := $(call check_variable,LINK_TYPE,dyna stat)
 # Supported OpenMP version, 2.5 or 3.0.
-OMP_VERSION  := $(call check_variable,OMP_VERSION,40 30 25)
+OMP_VERSION  := $(call check_variable,OMP_VERSION,41 40 30 25)
 # Generate optimized code.
 OPTIMIZATION := $(call check_variable,OPTIMIZATION,off on)
 # Library version: 4 -- legacy, 5 -- compat.
@@ -646,11 +646,15 @@
 ifeq "$(HAVE_QUAD)" "1"
     gd-flags += -D HAVE_QUAD
 endif
-ifeq "$(OMP_VERSION)" "40"
-    gd-flags += -D OMP_40 -D OMP_30
+ifeq "$(OMP_VERSION)" "41"
+    gd-flags += -D OMP_41 -D OMP_40 -D OMP_30
 else
-    ifeq "$(OMP_VERSION)" "30"
-        gd-flags += -D OMP_30
+    ifeq "$(OMP_VERSION)" "40"
+        gd-flags += -D OMP_40 -D OMP_30
+    else
+        ifeq "$(OMP_VERSION)" "30"
+            gd-flags += -D OMP_30
+        endif
     endif
 endif
 ifneq "$(VERSION)" "4"
@@ -756,7 +760,7 @@
         kmp_sched                    \
         $(empty)
 
-ifeq "$(OMP_VERSION)" "40"
+ifeq ($(OMP_VERSION),$(filter $(OMP_VERSION),40 41))
     lib_cpp_items += kmp_taskdeps
     lib_cpp_items += kmp_cancel
 endif
diff --git a/openmp/runtime/tools/build.pl b/openmp/runtime/tools/build.pl
index d6bc5a9..53027a5 100755
--- a/openmp/runtime/tools/build.pl
+++ b/openmp/runtime/tools/build.pl
@@ -62,7 +62,7 @@
     "lib-type"        => { targets => "rtl",               base => 1, parms => { normal  => "*", stubs => ""                  }, },
     "link-type"       => { targets => "rtl",               base => 1, parms => { dynamic => "*", static    => ""              }, },
     "mode"            => { targets => "rtl,dsl,timelimit", base => 0, parms => { release => "*", diag      => "", debug => "" }, suffix => sub { substr( $_[ 0 ], 0, 3 );       } },
-    "omp-version"     => { targets => "rtl",               base => 0, parms => { 40      => "*", 30        => ""              }, suffix => sub { $_[ 0 ]; } },
+    "omp-version"     => { targets => "rtl",               base => 0, parms => { 40      => "", 30        => "", 41 => "*"   }, suffix => sub { $_[ 0 ]; } },
     "coverage"        => { targets => "rtl",               base => 0, parms => { off     => "*", on        => ""              }, suffix => sub { $_[ 0 ] eq "on" ? "c1" : "c0"; } },
     "stats"           => { targets => "rtl",               base => 0, parms => { off     => "*", on        => ""              }, suffix => sub { $_[ 0 ] eq "on" ? "s1" : "s0"; } },
     "ompt-support"    => { targets => "rtl",               base => 0, parms => { off     => "*", on        => ""              }, suffix => sub { $_[ 0 ] eq "on" ? "ompt" : "" } },