Skip to content

Commit 8a855de

Browse files
arsenmgithub-actions[bot]
authored andcommitted
Automerge: clang/AMDGPU: Report some missing OpenCL 2.0 feature macros (#160826)
Report __opencl_c_program_scope_global_variables and __opencl_c_device_enqueue as supported. These 2.0 features are supported but were missing from the extension map. __opencl_c_atomic_scope_all_devices should also be reported, but that seems to not just work by adding it to the map for some reason. The existing test for these macros was also broken, since it was missing CL3.0 run lines, so add those.
2 parents 314cd72 + 9194703 commit 8a855de

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

clang/lib/Basic/Targets/AMDGPU.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,12 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
319319
Opts["__opencl_c_images"] = true;
320320
Opts["__opencl_c_3d_image_writes"] = true;
321321
Opts["cl_khr_3d_image_writes"] = true;
322+
Opts["__opencl_c_program_scope_global_variables"] = true;
322323

323-
Opts["__opencl_c_generic_address_space"] =
324-
GPUKind >= llvm::AMDGPU::GK_GFX700;
324+
if (GPUKind >= llvm::AMDGPU::GK_GFX700) {
325+
Opts["__opencl_c_generic_address_space"] = true;
326+
Opts["__opencl_c_device_enqueue"] = true;
327+
}
325328
}
326329
}
327330

clang/test/Misc/amdgcn.languageOptsOpenCL.cl

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
99
// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
1010

11+
// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
12+
// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple amdgcn-unknown-unknown -target-cpu gfx700 -Wpedantic-core-features -DTEST_CORE_FEATURES -DFLAT_SUPPORT
13+
1114
// Extensions in all versions
1215
#ifndef cl_clang_storage_class_specifiers
1316
#error "Missing cl_clang_storage_class_specifiers define"
@@ -156,10 +159,31 @@
156159
#pragma OPENCL EXTENSION cl_amd_media_ops2: enable
157160

158161
#if (__OPENCL_C_VERSION__ >= 300)
159-
#ifndef __opencl_c_generic_address_space
160-
#error "Missing __opencl_c_generic_address_space define"
161-
#else
162-
#error "Incorrect __opencl_c_generic_address_space define"
162+
#ifndef __opencl_c_program_scope_global_variables
163+
#error "Missing __opencl_c_program_scope_global_variables define"
164+
#endif
163165
#endif
164-
#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable
166+
167+
#if (__OPENCL_C_VERSION__ >= 300)
168+
#ifdef FLAT_SUPPORT
169+
#ifndef __opencl_c_generic_address_space
170+
#error "Missing __opencl_c_generic_address_space define"
171+
#endif
172+
#else
173+
#ifdef __opencl_c_generic_address_space
174+
#error "Incorrect __opencl_c_generic_address_space define"
175+
#endif
176+
#endif
177+
#endif
178+
179+
#if (__OPENCL_C_VERSION__ >= 300)
180+
#ifdef FLAT_SUPPORT
181+
#ifndef __opencl_c_device_enqueue
182+
#error "Missing __opencl_c_device_enqueue define"
183+
#endif
184+
#else
185+
#ifdef __opencl_c_device_enqueue
186+
#error "Incorrect __opencl_c_device_enqueue define"
187+
#endif
188+
#endif
165189
#endif

0 commit comments

Comments
 (0)