Skip to content

Commit 1e31f4b

Browse files
authored
[AMDGPU] Support the OpenCL generic addrspace feature by default (#137636)
This feature should be supported on AMDGCN architectures with flat addressing.
1 parent 78d95cc commit 1e31f4b

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

clang/lib/Basic/Targets/AMDGPU.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
318318
Opts["__opencl_c_images"] = true;
319319
Opts["__opencl_c_3d_image_writes"] = true;
320320
Opts["cl_khr_3d_image_writes"] = true;
321+
322+
Opts["__opencl_c_generic_address_space"] =
323+
GPUKind >= llvm::AMDGPU::GK_GFX700;
321324
}
322325
}
323326

clang/test/Misc/amdgcn.languageOptsOpenCL.cl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,11 @@
155155
#endif
156156
#pragma OPENCL EXTENSION cl_amd_media_ops2: enable
157157

158+
#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"
163+
#endif
164+
#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable
165+
#endif

clang/test/Misc/r600.languageOptsOpenCL.cl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,8 @@
146146
#pragma OPENCL EXTENSION cl_khr_subgroups: enable
147147
// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
148148

149+
#ifdef __opencl_c_generic_address_space
150+
#error "Incorrect __opencl_c_generic_address_space define"
151+
#endif
152+
#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable
153+
// expected-warning@-1{{OpenCL extension '__opencl_c_generic_address_space' unknown or does not require pragma - ignoring}}

0 commit comments

Comments
 (0)