Skip to content

Commit f512dae

Browse files
committed
[AMDGPU] Adds target failure test cases and minor modificatinos
1 parent 39403ae commit f512dae

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

clang/lib/Sema/SemaAMDGPU.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID,
112112
case AMDGPU::BI__builtin_amdgcn_image_load_mip_3d_v4f16_i32:
113113
case AMDGPU::BI__builtin_amdgcn_image_load_mip_cube_v4f32_i32:
114114
case AMDGPU::BI__builtin_amdgcn_image_load_mip_cube_v4f16_i32: {
115+
StringRef FeatureList(getASTContext().BuiltinInfo.getRequiredFeatures(BuiltinID));
115116
bool HasImageInsts = Builtin::evaluateRequiredTargetFeatures("image-insts", CallerFeatureMap);
116-
117-
if(!HasImageInsts){
117+
if (!Builtin::evaluateRequiredTargetFeatures(
118+
FeatureList, CallerFeatureMap) && !HasImageInsts){
118119
Diag(TheCall->getBeginLoc(), diag::err_builtin_needs_feature)
119-
<< FD->getDeclName() << "image-insts";
120+
<< FD->getDeclName() << FeatureList;
120121
return false;
121122
}
122123

@@ -155,6 +156,15 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID,
155156
case AMDGPU::BI__builtin_amdgcn_image_store_mip_3d_v4f16_i32:
156157
case AMDGPU::BI__builtin_amdgcn_image_store_mip_cube_v4f32_i32:
157158
case AMDGPU::BI__builtin_amdgcn_image_store_mip_cube_v4f16_i32: {
159+
StringRef FeatureList(getASTContext().BuiltinInfo.getRequiredFeatures(BuiltinID));
160+
bool HasImageInsts = Builtin::evaluateRequiredTargetFeatures("image-insts", CallerFeatureMap);
161+
if (!Builtin::evaluateRequiredTargetFeatures(
162+
FeatureList, CallerFeatureMap) && !HasImageInsts){
163+
Diag(TheCall->getBeginLoc(), diag::err_builtin_needs_feature)
164+
<< FD->getDeclName() << FeatureList;
165+
return false;
166+
}
167+
158168
unsigned ArgCount = TheCall->getNumArgs() - 1;
159169
llvm::APSInt Result;
160170

clang/test/SemaOpenCL/builtins-image-load-param.cl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx1100 -S -verify=expected -o - %s
22
// RUN: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -S -verify=expected -o - %s
3+
// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx942 -S -verify=GFX94 -o - %s
34
// REQUIRES: amdgpu-registered-target
45

56
typedef int int8 __attribute__((ext_vector_type(8)));
@@ -129,3 +130,16 @@ half4 test_builtin_image_load_mip_cube_2(half4 v4f16, int i32, int8 vec8i32) {
129130

130131
return __builtin_amdgcn_image_load_mip_cube_v4f16_i32(100, i32, i32, i32, i32, vec8i32, 120, i32); //expected-error{{argument to '__builtin_amdgcn_image_load_mip_cube_v4f16_i32' must be a constant integer}}
131132
}
133+
134+
float test_builtin_image_load_2d_gfx(float f32, int i32, int8 vec8i32) {
135+
136+
return __builtin_amdgcn_image_load_2d_f32_i32(12, i32, i32, vec8i32, 106, 103); //GFX94-error{{'__builtin_amdgcn_image_load_2d_f32_i32' needs target feature image-insts}}
137+
}
138+
float4 test_builtin_image_load_2d_gfx_1(float4 v4f32, int i32, int8 vec8i32) {
139+
140+
return __builtin_amdgcn_image_load_2d_v4f32_i32(100, i32, i32, vec8i32, 120, 110); //GFX94-error{{'__builtin_amdgcn_image_load_2d_v4f32_i32' needs target feature image-insts}}
141+
}
142+
half4 test_builtin_image_load_2d_gfx_2(half4 v4f16, int i32, int8 vec8i32) {
143+
144+
return __builtin_amdgcn_image_load_2d_v4f16_i32(100, i32, i32, vec8i32, 120, 110); //GFX94-error{{'__builtin_amdgcn_image_load_2d_v4f16_i32' needs target feature image-insts}}
145+
}

clang/test/SemaOpenCL/builtins-image-store-param.cl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -S -verify=expected -o - %s
2-
// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx701 -S -verify=GFX7 -o - %s
2+
// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx942 -S -verify=GFX94 -o - %s
33
// REQUIRES: amdgpu-registered-target
44

55
typedef int int8 __attribute__((ext_vector_type(8)));
@@ -130,3 +130,16 @@ void test_builtin_image_store_mip_cube_2(half4 v4f16, int i32, int8 vec8i32) {
130130

131131
return __builtin_amdgcn_image_store_mip_cube_v4f16_i32(v4f16, 100, i32, i32, i32, i32, vec8i32, 120, i32); //expected-error{{argument to '__builtin_amdgcn_image_store_mip_cube_v4f16_i32' must be a constant integer}}
132132
}
133+
134+
void test_builtin_image_store_2d_gfx(float f32, int i32, int8 vec8i32) {
135+
136+
__builtin_amdgcn_image_store_2d_f32_i32(f32, 12, i32, i32, vec8i32, 106, 103); //GFX94-error{{'__builtin_amdgcn_image_store_2d_f32_i32' needs target feature image-insts}}
137+
}
138+
void test_builtin_image_store_2d_gfx_1(float4 v4f32, int i32, int8 vec8i32) {
139+
140+
__builtin_amdgcn_image_store_2d_v4f32_i32(v4f32, 100, i32, i32, vec8i32, 120, 110); //GFX94-error{{'__builtin_amdgcn_image_store_2d_v4f32_i32' needs target feature image-insts}}
141+
}
142+
void test_builtin_image_store_2d_gfx_2(half4 v4f16, int i32, int8 vec8i32) {
143+
144+
__builtin_amdgcn_image_store_2d_v4f16_i32(v4f16, 100, i32, i32, vec8i32, 120, 110); //GFX94-error{{'__builtin_amdgcn_image_store_2d_v4f16_i32' needs target feature image-insts}}
145+
}

0 commit comments

Comments
 (0)