Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion clang/lib/Basic/Targets/AMDGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
return TT.getArch() == llvm::Triple::r600;
}

bool hasFlatSupport() const {
if (GPUKind >= llvm::AMDGPU::GK_GFX700)
return true;

// Dummy target is assumed to be gfx700+ for amdhsa.
if (GPUKind == llvm::AMDGPU::GK_NONE &&
getTriple().getOS() == llvm::Triple::AMDHSA)
return true;

return false;
}

public:
AMDGPUTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);

Expand Down Expand Up @@ -316,14 +328,16 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
Opts["cl_amd_media_ops"] = true;
Opts["cl_amd_media_ops2"] = true;

// FIXME: Check subtarget for image support.
Opts["__opencl_c_images"] = true;
Opts["__opencl_c_3d_image_writes"] = true;
Opts["__opencl_c_read_write_images"] = true;
Opts["cl_khr_3d_image_writes"] = true;
Opts["__opencl_c_program_scope_global_variables"] = true;
Opts["__opencl_c_atomic_order_seq_cst"] = true;
Opts["__opencl_c_atomic_scope_all_devices"] = true;

if (GPUKind >= llvm::AMDGPU::GK_GFX700) {
if (hasFlatSupport()) {
Opts["__opencl_c_generic_address_space"] = true;
Opts["__opencl_c_device_enqueue"] = true;
}
Expand Down
5 changes: 3 additions & 2 deletions clang/test/CodeGenOpenCL/address-spaces.cl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 -cl-ext=-all -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR
// RUN: %clang_cc1 %s -O0 -cl-std=clc++2021 -cl-ext=-all -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR
// RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20SPIR
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL3.0 -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-mesa3d -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-mesa3d -cl-std=CL3.0 -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -DCL20 -cl-std=CL2.0 -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20AMDGCN
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -DCL20 -cl-std=CL3.0 -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20AMDGCN
// RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
// RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -cl-std=CL3.0 -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
// RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGenOpenCL/builtins-alloca.cl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=OPENCL12 %s
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL2.0 \
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=OPENCL20 %s
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL3.0 \
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-mesa3d -target-cpu gfx600 -cl-std=CL3.0 \
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=OPENCL30 %s
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space \
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL3.0 \
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=OPENCL30GAS %s

// OPENCL-LABEL: define dso_local void @test1_builtin_alloca(
Expand Down
7 changes: 7 additions & 0 deletions clang/test/Misc/amdgcn.languageOptsOpenCL.cl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
// 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

// Test none target with amdhsa triple, which implies >= gfx700
// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple amdgcn-unknown-amdhsa -Wpedantic-core-features -DTEST_CORE_FEATURES -DFLAT_SUPPORT

// Extensions in all versions
#ifndef cl_clang_storage_class_specifiers
#error "Missing cl_clang_storage_class_specifiers define"
Expand Down Expand Up @@ -162,6 +165,10 @@
#ifndef __opencl_c_program_scope_global_variables
#error "Missing __opencl_c_program_scope_global_variables define"
#endif

#ifndef __opencl_c_read_write_images
#error "Missing __opencl_c_read_write_images define"
#endif
#endif

#if (__OPENCL_C_VERSION__ >= 300)
Expand Down
Loading