================
@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
     message( STATUS "  device: ${d} ( ${${d}_aliases} )" )
 
-    if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+    # 1.2 is Clang's default OpenCL C language standard to compile for.
+    set( opencl_lang_std "CL1.2" )
+
+    if ( ${DARCH} STREQUAL spirv )
+      set( opencl_lang_std "CL3.0" )
       set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
       set( opt_flags )
       set( spvflags --spirv-max-version=1.1 )
       set( MACRO_ARCH SPIRV32 )
       if( ARCH STREQUAL spirv64 )
         set( MACRO_ARCH SPIRV64 )
       endif()
-    elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
+    elseif( ${DARCH} STREQUAL clspv )
+      # Refer to https://github.com/google/clspv for OpenCL version.
+      set( opencl_lang_std "CL3.0" )
       set( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
       set( opt_flags -O3 )
       set( MACRO_ARCH CLSPV32 )
       if( ARCH STREQUAL clspv64 )
         set( MACRO_ARCH CLSPV64 )
       endif()
+    elseif( ${DARCH} STREQUAL nvptx )
+      # Refer to https://www.khronos.org/opencl/ for OpenCL version in NV 
implementation.
+      set( opencl_lang_std "CL3.0" )
+      set( build_flags )
+      set( opt_flags -O3 )
+      set( MACRO_ARCH ${ARCH} )
+    elseif( ${DARCH} STREQUAL amdgcn OR ${DARCH} STREQUAL amdgcn-amdhsa )
+      # Refer to https://github.com/ROCm/clr/tree/develop/opencl for OpenCL 
version.
+      set( opencl_lang_std "CL2.0" )
----------------
wenju-he wrote:

> I thought we already picked out device compatible default versions in clang?

OpenCL C version is 1.2 for all targets by default in clang if the version 
isn't specified in command line: 
https://github.com/llvm/llvm-project/blob/b07c88563febdb62b82daad0480d7b6131bc54d4/clang/lib/Basic/LangStandards.cpp#L99

There is TargetInfo api setSupportedOpenCLOpts for target to define its 
supported extensions and features.

https://github.com/llvm/llvm-project/pull/135733
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to