Index: clang/lib/Basic/Targets/AMDGPU.h =================================================================== --- clang/lib/Basic/Targets/AMDGPU.h +++ clang/lib/Basic/Targets/AMDGPU.h @@ -267,6 +267,11 @@ Opts.support("cl_khr_mipmap_image_writes"); Opts.support("cl_khr_subgroups"); Opts.support("cl_khr_3d_image_writes"); + + if (getTriple().getOS() == llvm::Triple::AMDHSA || + getTriple().getOS() == llvm::Triple::AMDPAL) + Opts.support("cl_khr_gl_sharing"); + Opts.support("cl_amd_media_ops"); Opts.support("cl_amd_media_ops2"); } Index: clang/test/Misc/amdgcn.languageOptsOpenCL.cl =================================================================== --- clang/test/Misc/amdgcn.languageOptsOpenCL.cl +++ clang/test/Misc/amdgcn.languageOptsOpenCL.cl @@ -8,6 +8,20 @@ // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES +// Test extensions supported by amdhsa and amdpal +// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple amdgcn-unknown-amdhsa -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL +// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-amdhsa -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL +// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple amdgcn-unknown-amdhsa -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL +// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple amdgcn-unknown-amdpal -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL +// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-amdpal -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL +// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple amdgcn-unknown-amdpal -Wpedantic-core-features -DTEST_CORE_FEATURES -DHSAPAL + +// Test extensions supported by mesa3d/clover +// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple amdgcn-unknown-mesa3d -Wpedantic-core-features -DTEST_CORE_FEATURES +// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-mesa3d -Wpedantic-core-features -DTEST_CORE_FEATURES +// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple amdgcn-unknown-mesa3d -Wpedantic-core-features -DTEST_CORE_FEATURES + + // Extensions in all versions #ifndef cl_clang_storage_class_specifiers #error "Missing cl_clang_storage_class_specifiers define" @@ -29,11 +43,20 @@ #endif #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable +#ifdef HSAPAL +#ifndef cl_khr_gl_sharing +#error "Incorrect cl_khr_gl_sharing define" +#endif +#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable + +#else + #ifdef cl_khr_gl_sharing #error "Incorrect cl_khr_gl_sharing define" #endif #pragma OPENCL EXTENSION cl_khr_gl_sharing: enable // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_gl_sharing' - ignoring}} +#endif #ifndef cl_khr_icd #error "Missing cl_khr_icd define"